mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
ssd: add titleLayout setting
This commit is contained in:
parent
7125a312aa
commit
9a252249c9
4 changed files with 96 additions and 0 deletions
|
|
@ -432,6 +432,18 @@ extending outward from the snapped edge.
|
|||
*<theme><name>*
|
||||
The name of the Openbox theme to use. It is not set by default.
|
||||
|
||||
*<theme><titleLayout>*
|
||||
Selection and order of buttons in a window's titlebar.
|
||||
The following letters can be used, each only once:
|
||||
- L: window label (aka. title)
|
||||
- |: empty space (can be used instead of a title)
|
||||
- W: window menu
|
||||
- I: iconify
|
||||
- M: maximize
|
||||
- C: close
|
||||
|
||||
Example: WLIMC
|
||||
|
||||
*<theme><cornerRadius>*
|
||||
The radius of server side decoration top corners. Default is 8.
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
<!-- <font><theme> can be defined without an attribute to set all places -->
|
||||
<theme>
|
||||
<name></name>
|
||||
<titleLayout>WLIMC</titleLayout>
|
||||
<cornerRadius>8</cornerRadius>
|
||||
<keepBorder>yes</keepBorder>
|
||||
<dropShadows>no</dropShadows>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include "config/tablet-tool.h"
|
||||
#include "config/libinput.h"
|
||||
#include "resize-indicator.h"
|
||||
#include "ssd.h"
|
||||
#include "theme.h"
|
||||
|
||||
enum view_placement_policy {
|
||||
|
|
@ -45,6 +46,11 @@ enum tiling_events_mode {
|
|||
(LAB_TILING_EVENTS_REGION | LAB_TILING_EVENTS_EDGE),
|
||||
};
|
||||
|
||||
struct title_button {
|
||||
enum ssd_part_type type;
|
||||
struct wl_list link;
|
||||
};
|
||||
|
||||
struct usable_area_override {
|
||||
struct border margin;
|
||||
char *output;
|
||||
|
|
@ -75,7 +81,11 @@ struct rcxml {
|
|||
|
||||
/* theme */
|
||||
char *theme_name;
|
||||
struct wl_list title_buttons_left;
|
||||
struct wl_list title_buttons_right;
|
||||
int corner_radius;
|
||||
bool show_title;
|
||||
bool title_layout_loaded;
|
||||
bool ssd_keep_border;
|
||||
bool shadows_enabled;
|
||||
struct font font_activewindow;
|
||||
|
|
|
|||
|
|
@ -116,6 +116,59 @@ parse_window_type(const char *type)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
fill_title_layout(char *nodename, char *content)
|
||||
{
|
||||
char *c, *c2;
|
||||
enum ssd_part_type type;
|
||||
struct title_button *item;
|
||||
struct wl_list *list = &rc.title_buttons_left;
|
||||
|
||||
for (c = content; *c != '\0'; c++) {
|
||||
for (c2 = content; c2 < c; c2++) {
|
||||
if (*c2 == *c) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (c2 != c) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (*c) {
|
||||
/* case 'N': icon */
|
||||
case 'L':
|
||||
list = &rc.title_buttons_right;
|
||||
rc.show_title = true;
|
||||
continue;
|
||||
case '|':
|
||||
list = &rc.title_buttons_right;
|
||||
continue;
|
||||
case 'W':
|
||||
type = LAB_SSD_BUTTON_WINDOW_MENU;
|
||||
break;
|
||||
case 'I':
|
||||
type = LAB_SSD_BUTTON_ICONIFY;
|
||||
break;
|
||||
case 'M':
|
||||
type = LAB_SSD_BUTTON_MAXIMIZE;
|
||||
break;
|
||||
case 'C':
|
||||
type = LAB_SSD_BUTTON_CLOSE;
|
||||
break;
|
||||
/* case 'S': shade */
|
||||
/* case 'D': omnipresent */
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
item = znew(*item);
|
||||
item->type = type;
|
||||
wl_list_append(list, &item->link);
|
||||
}
|
||||
|
||||
rc.title_layout_loaded = true;
|
||||
}
|
||||
|
||||
static void
|
||||
fill_usable_area_override(char *nodename, char *content)
|
||||
{
|
||||
|
|
@ -916,6 +969,8 @@ entry(xmlNode *node, char *nodename, char *content)
|
|||
rc.placement_cascade_offset_y = atoi(content);
|
||||
} else if (!strcmp(nodename, "name.theme")) {
|
||||
rc.theme_name = xstrdup(content);
|
||||
} else if (!strcmp(nodename, "titlelayout.theme")) {
|
||||
fill_title_layout(nodename, content);
|
||||
} else if (!strcmp(nodename, "cornerradius.theme")) {
|
||||
rc.corner_radius = atoi(content);
|
||||
} else if (!strcasecmp(nodename, "keepBorder.theme")) {
|
||||
|
|
@ -1236,6 +1291,8 @@ rcxml_init(void)
|
|||
static bool has_run;
|
||||
|
||||
if (!has_run) {
|
||||
wl_list_init(&rc.title_buttons_left);
|
||||
wl_list_init(&rc.title_buttons_right);
|
||||
wl_list_init(&rc.usable_area_overrides);
|
||||
wl_list_init(&rc.keybinds);
|
||||
wl_list_init(&rc.mousebinds);
|
||||
|
|
@ -1253,6 +1310,8 @@ rcxml_init(void)
|
|||
rc.placement_cascade_offset_y = 0;
|
||||
|
||||
rc.xdg_shell_server_side_deco = true;
|
||||
rc.show_title = false;
|
||||
rc.title_layout_loaded = false;
|
||||
rc.ssd_keep_border = true;
|
||||
rc.corner_radius = 8;
|
||||
rc.shadows_enabled = false;
|
||||
|
|
@ -1494,6 +1553,10 @@ post_processing(void)
|
|||
load_default_mouse_bindings();
|
||||
}
|
||||
|
||||
if (!rc.title_layout_loaded) {
|
||||
fill_title_layout("titlelayout.theme", "WLIMC");
|
||||
}
|
||||
|
||||
/*
|
||||
* Replace all earlier bindings by later ones
|
||||
* and clear the ones with an empty action list.
|
||||
|
|
@ -1720,6 +1783,16 @@ rcxml_finish(void)
|
|||
zfree(rc.theme_name);
|
||||
zfree(rc.workspace_config.prefix);
|
||||
|
||||
struct title_button *p, *p_tmp;
|
||||
wl_list_for_each_safe(p, p_tmp, &rc.title_buttons_left, link) {
|
||||
wl_list_remove(&p->link);
|
||||
zfree(p);
|
||||
}
|
||||
wl_list_for_each_safe(p, p_tmp, &rc.title_buttons_right, link) {
|
||||
wl_list_remove(&p->link);
|
||||
zfree(p);
|
||||
}
|
||||
|
||||
struct usable_area_override *area, *area_tmp;
|
||||
wl_list_for_each_safe(area, area_tmp, &rc.usable_area_overrides, link) {
|
||||
wl_list_remove(&area->link);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue