Check if con_id exists in cmd_swap (#2898)

Also adds some testcases for swap using con_id.

Fixes #2895
This commit is contained in:
Orestis
2017-09-06 08:34:14 +03:00
committed by Michael Stapelberg
parent dedfda1e01
commit 369c9ed50f
4 changed files with 56 additions and 1 deletions

View File

@ -557,6 +557,22 @@ Con *con_by_window_id(xcb_window_t window) {
return NULL;
}
/*
* Returns the container with the given container ID or NULL if no such
* container exists.
*
*/
Con *con_by_con_id(long target) {
Con *con;
TAILQ_FOREACH(con, &all_cons, all_cons) {
if (con == (Con *)target) {
return con;
}
}
return NULL;
}
/*
* Returns the container with the given frame ID or NULL if no such container
* exists.