From d5e2728c7f4b73821c7fb45658c3c32e4ee9177d Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Thu, 8 Sep 2022 11:50:40 -0400 Subject: [PATCH 1/3] interactive: Don't write to view->x/y/w/h directly Otherwise, the scene-graph isn't updated when calling view->impl->configure(), and the view ends up in a weird half-maximized state. --- src/interactive.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/interactive.c b/src/interactive.c index d0d8f808..be469f7b 100644 --- a/src/interactive.c +++ b/src/interactive.c @@ -31,6 +31,26 @@ interactive_begin(struct view *view, enum input_mode mode, uint32_t edges) /* We don't allow resizing while in maximized or fullscreen state */ return; } + + /* + * This function sets up an interactive move or resize operation, where + * the compositor stops propagating pointer events to clients and + * instead consumes them itself, to move or resize windows. + */ + struct seat *seat = &view->server->seat; + struct server *server = view->server; + server->grabbed_view = view; + server->input_mode = mode; + + /* Remember view and cursor positions at start of move/resize */ + server->grab_x = seat->cursor->x; + server->grab_y = seat->cursor->y; + server->grab_box.x = view->x; + server->grab_box.y = view->y; + server->grab_box.width = view->w; + server->grab_box.height = view->h; + server->resize_edges = edges; + if (view->maximized || view->tiled) { if (mode == LAB_INPUT_STATE_MOVE) { /* Exit maximized or tiled mode */ @@ -52,35 +72,16 @@ interactive_begin(struct view *view, enum input_mode mode, uint32_t edges) * the current values in server->grab_box. We pretend the * configure already happened by setting them manually. */ - view->x = new_x; - view->y = new_y; - view->w = view->natural_geometry.width; - view->h = view->natural_geometry.height; + server->grab_box.x = new_x; + server->grab_box.y = new_y; + server->grab_box.width = view->natural_geometry.width; + server->grab_box.height = view->natural_geometry.height; } } /* Moving or resizing always resets tiled state */ view->tiled = 0; - /* - * This function sets up an interactive move or resize operation, where - * the compositor stops propagating pointer events to clients and - * instead consumes them itself, to move or resize windows. - */ - struct seat *seat = &view->server->seat; - struct server *server = view->server; - server->grabbed_view = view; - server->input_mode = mode; - - /* Remember view and cursor positions at start of move/resize */ - server->grab_x = seat->cursor->x; - server->grab_y = seat->cursor->y; - struct wlr_box box = { - .x = view->x, .y = view->y, .width = view->w, .height = view->h - }; - memcpy(&server->grab_box, &box, sizeof(struct wlr_box)); - server->resize_edges = edges; - switch (mode) { case LAB_INPUT_STATE_MOVE: cursor_set(&server->seat, "grab"); From ebd0a5d5269835d70bf669d69a51ce7d61e26f68 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Thu, 8 Sep 2022 13:20:48 -0400 Subject: [PATCH 2/3] config: Redefine Title context to include blank areas of Titlebar ... and use Title for the Drag (Move) and DoubleClick (Maximize) titlebar actions, which are unexpected when the cursor is over one of the window buttons. --- docs/labwc-config.5.scd | 6 ++++-- docs/rc.xml.all | 11 ++++++----- src/config/rcxml.c | 4 ++-- src/ssd/ssd.c | 5 +++++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/docs/labwc-config.5.scd b/docs/labwc-config.5.scd index 920455b9..ea2a6efb 100644 --- a/docs/labwc-config.5.scd +++ b/docs/labwc-config.5.scd @@ -186,8 +186,10 @@ The rest of this man page describes configuration options. ** can exist within one ** Define a mouse binding. Supported context-names include: - - TitleBar: The area where the title of the window is shown. - - Title: The title of the window itself. + - TitleBar: The decoration on top of the window, where the window + buttons and the window title are shown. + - Title: The area of the titlebar (including blank space) between + the window buttons, where the window title is displayed. - WindowMenu: The button on the left. - Iconify: The button that looks like an underline. - Maximize: The button that looks like a box. diff --git a/docs/rc.xml.all b/docs/rc.xml.all index 390599f8..457038dc 100644 --- a/docs/rc.xml.all +++ b/docs/rc.xml.all @@ -215,9 +215,6 @@ - - - @@ -225,9 +222,13 @@ client-menu + + + + + + - - diff --git a/src/config/rcxml.c b/src/config/rcxml.c index c0a92991..141b2c3d 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -570,8 +570,8 @@ static struct mouse_combos { { "Frame", "A-Right", "Drag", "Resize", NULL}, { "Titlebar", "Left", "Press", "Focus", NULL}, { "Titlebar", "Left", "Press", "Raise", NULL}, - { "TitleBar", "Left", "Drag", "Move", NULL }, - { "TitleBar", "Left", "DoubleClick", "ToggleMaximize", NULL }, + { "Title", "Left", "Drag", "Move", NULL }, + { "Title", "Left", "DoubleClick", "ToggleMaximize", NULL }, { "TitleBar", "Right", "Click", "Focus", NULL}, { "TitleBar", "Right", "Click", "Raise", NULL}, { "TitleBar", "Right", "Click", "ShowMenu", "client-menu"}, diff --git a/src/ssd/ssd.c b/src/ssd/ssd.c index e6362f34..744f650e 100644 --- a/src/ssd/ssd.c +++ b/src/ssd/ssd.c @@ -243,6 +243,11 @@ ssd_part_contains(enum ssd_part_type whole, enum ssd_part_type candidate) return candidate >= LAB_SSD_BUTTON_CLOSE && candidate <= LAB_SSD_PART_TITLE; } + if (whole == LAB_SSD_PART_TITLE) { + /* "Title" includes blank areas of "Titlebar" as well */ + return candidate >= LAB_SSD_PART_TITLEBAR + && candidate <= LAB_SSD_PART_TITLE; + } if (whole == LAB_SSD_FRAME) { return candidate >= LAB_SSD_BUTTON_CLOSE && candidate <= LAB_SSD_CLIENT; From 48fde32e62c75f136c8d4c920c2f8c9612179457 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Thu, 8 Sep 2022 13:16:19 -0400 Subject: [PATCH 3/3] ssd: Make ssd_get_part_type() work for corner buttons Corner buttons (WINDOW_MENU and CLOSE) are one more level down in the scene-tree (see add_scene_button_corner() in ssd_part.c). This fixes a minor issue where, when right-clicking on the CLOSE button, the client-menu would be displayed in the wrong location. --- src/ssd/ssd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ssd/ssd.c b/src/ssd/ssd.c index 744f650e..14e7f462 100644 --- a/src/ssd/ssd.c +++ b/src/ssd/ssd.c @@ -68,12 +68,16 @@ ssd_get_part_type(struct view *view, struct wlr_scene_node *node) struct wl_list *part_list = NULL; struct wlr_scene_tree *grandparent = node->parent ? node->parent->node.parent : NULL; + struct wlr_scene_tree *greatgrandparent = + grandparent ? grandparent->node.parent : NULL; /* active titlebar */ if (node->parent == view->ssd.titlebar.active.tree) { part_list = &view->ssd.titlebar.active.parts; } else if (grandparent == view->ssd.titlebar.active.tree) { part_list = &view->ssd.titlebar.active.parts; + } else if (greatgrandparent == view->ssd.titlebar.active.tree) { + part_list = &view->ssd.titlebar.active.parts; /* extents */ } else if (node->parent == view->ssd.extents.tree) { @@ -88,6 +92,8 @@ ssd_get_part_type(struct view *view, struct wlr_scene_node *node) part_list = &view->ssd.titlebar.inactive.parts; } else if (grandparent == view->ssd.titlebar.inactive.tree) { part_list = &view->ssd.titlebar.inactive.parts; + } else if (greatgrandparent == view->ssd.titlebar.inactive.tree) { + part_list = &view->ssd.titlebar.inactive.parts; /* inactive border */ } else if (node->parent == view->ssd.border.inactive.tree) {