]> git.sur5r.net Git - i3/i3/blobdiff - src/workspace.c
Bring back some more EWMH support.
[i3/i3] / src / workspace.c
index fa84e2041cf2a68581d11e09e7053d7147991a13..77b5ceb2eca52b91276ecd13d3d0ce7214ef9f42 100644 (file)
@@ -17,7 +17,7 @@
  * memory and initializing the data structures correctly).
  *
  */
-Con *workspace_get(const char *num) {
+Con *workspace_get(const char *num, bool *created) {
     Con *output, *workspace = NULL, *child;
 
     /* TODO: could that look like this in the future?
@@ -63,9 +63,12 @@ Con *workspace_get(const char *num) {
         con_attach(workspace, content, false);
 
         ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"init\"}");
+        if (created != NULL)
+            *created = true;
+    }
+    else if (created != NULL) {
+        *created = false;
     }
-
-    //ewmh_update_workarea();
 
     return workspace;
 }
@@ -201,7 +204,8 @@ static void workspace_reassign_sticky(Con *con) {
 void workspace_show(const char *num) {
     Con *workspace, *current, *old = NULL;
 
-    workspace = workspace_get(num);
+    bool changed_num_workspaces;
+    workspace = workspace_get(num, &changed_num_workspaces);
 
     /* disable fullscreen for the other workspaces and get the workspace we are
      * currently on. */
@@ -236,6 +240,7 @@ void workspace_show(const char *num) {
             LOG("Closing old workspace (%p / %s), it is empty\n", old, old->name);
             tree_close(old, false, false);
             ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"empty\"}");
+            changed_num_workspaces = true;
         }
     }
 
@@ -243,6 +248,11 @@ void workspace_show(const char *num) {
     workspace->fullscreen_mode = CF_OUTPUT;
     LOG("focused now = %p / %s\n", focused, focused->name);
 
+    /* Update the EWMH hints */
+    if (changed_num_workspaces)
+        ewmh_update_workarea();
+    ewmh_update_current_desktop();
+
     ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"focus\"}");
 #if 0
 
@@ -454,7 +464,7 @@ Workspace *get_first_workspace_for_output(Output *output) {
                 int last_ws = 0;
                 TAILQ_FOREACH(ws, workspaces, workspaces)
                         last_ws = ws->num;
-                result = workspace_get(last_ws + 1);
+                result = workspace_get(last_ws + 1, NULL);
         }
 
         workspace_initialize(result, output, false);