Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Add con_exists function
Browse files Browse the repository at this point in the history
Checks the all_cons queue and returns true if a given con is found.
  • Loading branch information
orestisfl authored and stapelberg committed Sep 24, 2017
1 parent 8653bfe commit 2e83d21
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/con.h
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions src/con.c
Expand Up @@ -604,6 +604,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.
Expand Down

0 comments on commit 2e83d21

Please sign in to comment.