]> git.sur5r.net Git - i3/i3/blobdiff - src/con.c
Replace duplicate "__" workspace prefix checks with a single function.
[i3/i3] / src / con.c
index 8bc9badc7ee364447197fd978c255480a1db4ccd..acc5e8afc072da4557f7ab0040c63964d4f8a7f6 100644 (file)
--- a/src/con.c
+++ b/src/con.c
@@ -359,6 +359,14 @@ Con *con_get_fullscreen_con(Con *con, int fullscreen_mode) {
     return NULL;
 }
 
+/**
+ * Returns true if the container is internal, such as __i3_scratch
+ *
+ */
+bool con_is_internal(Con *con) {
+    return (con->name[0] == '_' && con->name[1] == '_');
+}
+
 /*
  * Returns true if the node is floating.
  *
@@ -692,7 +700,7 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool
      * calling tree_render(), so for the "real" focus this is a no-op).
      * We don’t focus the con for i3 pseudo workspaces like __i3_scratch and
      * we don’t focus when there is a fullscreen con on that workspace. */
-    if ((workspace->name[0] != '_' || workspace->name[1] != '_') &&
+    if (!con_is_internal(workspace) &&
         con_get_fullscreen_con(workspace, CF_OUTPUT) == NULL)
         con_focus(con_descend_focused(con));
 
@@ -701,8 +709,7 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool
      * don’t want to focus invisible workspaces */
     if (source_output != dest_output &&
         workspace_is_visible(workspace) &&
-        workspace->name[0] != '_' &&
-        workspace->name[1] != '_') {
+        !con_is_internal(workspace)) {
         DLOG("Moved to a different output, focusing target\n");
     } else {
         /* Descend focus stack in case focus_next is a workspace which can