Implement assignments of workspaces to screens, big cleanup of workspace code
Please test this! Plug in screens, unplug them, use your video projector, change resolutions, etc. To use the assignments, use the following syntax: workspace <number> [screen <screen>] [name] Where screen can be one of: <number> (It is not provided that these numbers stay constant, so use with care) <x>x<y> (Coordinates where the screen starts, so 1280 will be fine to match the screen right of the main screen if your main screen is 1280 pixels width. However, 1281 will not match) <x> x<y> Some examples follow: workspace 1 screen 0 workspace 1 screen 1 workspace 1 screen 1280x0 workspace 2 screen 1280 workspace 3 screen x0 workspace 3 screen 1 www workspace 4 screen 0 mail
This commit is contained in:
26
src/config.c
26
src/config.c
@ -349,9 +349,10 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
|
||||
continue;
|
||||
}
|
||||
|
||||
/* name "workspace number" "name of the workspace" */
|
||||
if (strcasecmp(key, "name") == 0) {
|
||||
LOG("name workspace: %s\n",value);
|
||||
/* workspace "workspace number" [screen <screen>] ["name of the workspace"]
|
||||
* with screen := <number> | <position>, e.g. screen 1280 or screen 1 */
|
||||
if (strcasecmp(key, "name") == 0 || strcasecmp(key, "workspace") == 0) {
|
||||
LOG("workspace: %s\n",value);
|
||||
char *ws_str = sstrdup(value);
|
||||
char *end = strchr(ws_str, ' ');
|
||||
if (end == NULL)
|
||||
@ -371,11 +372,30 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
|
||||
char *name = value;
|
||||
name += strlen(ws_str) + 1;
|
||||
|
||||
if (strncasecmp(name, "screen ", strlen("screen ")) == 0) {
|
||||
char *screen = strdup(name + strlen("screen "));
|
||||
if ((end = strchr(screen, ' ')) != NULL)
|
||||
*end = '\0';
|
||||
LOG("Setting preferred screen for workspace %d to \"%s\"\n", ws_num, screen);
|
||||
workspaces[ws_num - 1].preferred_screen = screen;
|
||||
|
||||
name += strlen("screen ") + strlen(screen);
|
||||
|
||||
}
|
||||
|
||||
/* Strip leading whitespace */
|
||||
while (*name != '\0' && *name == ' ')
|
||||
name++;
|
||||
|
||||
LOG("rest to parse = %s\n", name);
|
||||
|
||||
if (name == '\0') {
|
||||
free(ws_str);
|
||||
continue;
|
||||
}
|
||||
|
||||
LOG("setting name to \"%s\"\n", name);
|
||||
|
||||
workspace_set_name(&(workspaces[ws_num - 1]), name);
|
||||
free(ws_str);
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user