*/
Con *con_by_window_id(xcb_window_t window);
+/**
+ * Returns the container with the given container ID or NULL if no such
+ * container exists.
+ *
+ */
+Con *con_by_con_id(long target);
+
/**
* Returns the container with the given frame ID or NULL if no such container
* exists.
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.
my ($result);
my @urgent;
+###############################################################################
+# Invalid con_id should not crash i3
+# See issue #2895.
+###############################################################################
+
+$pid = launch_with_config($config);
+$ws = fresh_workspace;
+
+open_window;
+cmd "swap container with con_id 1";
+
+does_i3_live;
+exit_gracefully($pid);
+
+###############################################################################
+# Swap 2 windows in different workspaces using con_id
+###############################################################################
+
+$pid = launch_with_config($config);
+
+$ws = fresh_workspace;
+open_window;
+$A = get_focused($ws);
+
+$ws = fresh_workspace;
+open_window;
+
+cmd "swap container with con_id $A";
+is(get_focused($ws), $A, 'A is now focused');
+
+exit_gracefully($pid);
+
###############################################################################
# Swap two containers next to each other.
# Focus should stay on B because both windows are on the focused workspace.