workspaces: Implement config parsing

This commit is contained in:
Consolatis 2022-06-15 02:07:22 +02:00
parent d557623c34
commit ae2fa1571b
3 changed files with 63 additions and 0 deletions

View 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>*

View file

@ -39,6 +39,32 @@
<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:

View 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;