]> git.mdlowis.com Git - proto/labwc.git/commitdiff
workspaces: Implement config parsing
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Wed, 15 Jun 2022 00:07:22 +0000 (02:07 +0200)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Wed, 15 Jun 2022 20:26:21 +0000 (22:26 +0200)
docs/labwc-config.5.scd
docs/rc.xml.all
src/config/rcxml.c

index 73c74bfe0abf0c0c02a55f9d86fb0736ff984b94..034fb3247acfef83d62ddcaf4bc8eef9a718e877 100644 (file)
@@ -88,6 +88,7 @@ The rest of this man page describes configuration options.
        Raise window to top when focused. Default is no.
 
 ## WINDOW SNAPPING
+
 *<snapping><range>*
        The distance in pixels from the edge of an ouput for window Move
        operations to trigger SnapToEdge. A range of 0 disables window snapping.
@@ -96,6 +97,18 @@ The rest of this man page describes configuration options.
 *<snapping><topMaximize>* [yes|no]
        Maximize window if Move operation ends on the top edge. Default is yes.
 
+## WORKSPACES
+
+*<desktops><names><name>*
+       Define workspaces. A workspace covers all outputs. The OSD only shows
+       windows on the current workspace. Workspaces can be switched to with
+       GoToDesktop and windows can be moved with SendToDesktop. See
+       labwc-actions(5) for more information about their arguments.
+
+*<desktops><popupTime>*
+       Define the timeout after which to hide the workspace OSD.
+       A setting of 0 disables the OSD. Default is 1000 ms.
+
 ## THEME
 
 *<theme><name>*
index 5acc5bcc62fe2e5f57a2e54cc0bd8557bb0b987b..1468b9f7a919a1407ac475c8430ed7a3336f3984 100644 (file)
     <topMaximize>yes</topMaximize>
   </snapping>
 
+  <!--
+    Use GoToDesktop left | right to switch workspaces.
+    Use SendToDesktop left | right to move windows.
+    See man labwc-actions for futher information.
+
+    Workspaces can be configured like this:
+    <desktops>
+      <popupTime>1000</popupTime>
+      <names>
+        <name>Workspace 1</name>
+        <name>Workspace 2</name>
+        <name>Workspace 3</name>
+      </names>
+    </desktops>
+  -->
+  <desktops>
+    <!--
+      popupTime defaults to 1000 so could be left out.
+      Set to 0 to completely disable the workspace OSD.
+    -->
+    <popupTime>1000</popupTime>
+    <names>
+      <name>Default</name>
+    </names>
+  </desktops>
+
   <!--
     Keybind actions are specified in labwc-actions(5)
     The following keybind modifiers are supported:
index 894ca5fa610f600cabe0061fa61bed11b7df35e1..31a7c1384e619e9fc30146b55f1489ce2494d9e1 100644 (file)
@@ -21,6 +21,7 @@
 #include "config/libinput.h"
 #include "config/mousebind.h"
 #include "config/rcxml.h"
+#include "workspaces.h"
 
 static bool in_keybind;
 static bool in_mousebind;
@@ -387,6 +388,12 @@ entry(xmlNode *node, char *nodename, char *content)
                rc.snap_top_maximize = get_bool(content);
        } else if (!strcasecmp(nodename, "cycleViewPreview.core")) {
                rc.cycle_preview_contents = get_bool(content);
+       } else if (!strcasecmp(nodename, "name.names.desktops")) {
+               struct workspace *workspace = calloc(1, sizeof(struct workspace));
+               workspace->name = strdup(content);
+               wl_list_insert(rc.workspace_config.workspaces.prev, &workspace->link);
+       } else if (!strcasecmp(nodename, "popupTime.desktops")) {
+               rc.workspace_config.popuptime = atoi(content);
        }
 }
 
@@ -486,6 +493,8 @@ rcxml_init()
        rc.snap_edge_range = 1;
        rc.snap_top_maximize = true;
        rc.cycle_preview_contents = false;
+       rc.workspace_config.popuptime = INT_MIN;
+       wl_list_init(&rc.workspace_config.workspaces);
 }
 
 static struct {
@@ -620,6 +629,14 @@ post_processing(void)
                struct libinput_category *l = libinput_category_create();
                l->type = TOUCH_DEVICE;
        }
+       if (!wl_list_length(&rc.workspace_config.workspaces)) {
+               struct workspace *workspace = calloc(1, sizeof(struct workspace));
+               workspace->name = strdup("Default");
+               wl_list_insert(rc.workspace_config.workspaces.prev, &workspace->link);
+       }
+       if (rc.workspace_config.popuptime == INT_MIN) {
+               rc.workspace_config.popuptime = 1000;
+       }
 }
 
 static void
@@ -718,6 +735,13 @@ rcxml_finish(void)
                zfree(l);
        }
 
+       struct workspace *w, *w_tmp;
+       wl_list_for_each_safe(w, w_tmp, &rc.workspace_config.workspaces, link) {
+               wl_list_remove(&w->link);
+               zfree(w->name);
+               zfree(w);
+       }
+
        /* Reset state vars for starting fresh when Reload is triggered */
        current_keybind = NULL;
        current_mousebind = NULL;