Add con_exists function

Checks the all_cons queue and returns true if a given con is found.
next
Orestis Floros 2017-09-22 19:22:48 +03:00
parent dd13cae5c0
commit be9a2bb7f8
2 changed files with 16 additions and 0 deletions

View File

@ -165,6 +165,13 @@ Con *con_by_window_id(xcb_window_t window);
*/
Con *con_by_con_id(long target);
/**
* Returns true if the given container (still) exists.
* This can be used, e.g., to make sure a container hasn't been closed in the meantime.
*
*/
bool con_exists(Con *con);
/**
* Returns the container with the given frame ID or NULL if no such container
* exists.

View File

@ -597,6 +597,15 @@ Con *con_by_con_id(long target) {
return NULL;
}
/*
* Returns true if the given container (still) exists.
* This can be used, e.g., to make sure a container hasn't been closed in the meantime.
*
*/
bool con_exists(Con *con) {
return con_by_con_id((long)con) != NULL;
}
/*
* Returns the container with the given frame ID or NULL if no such container
* exists.