Merge pull request #531 from jlindgren90/titlebar-fixes

Titlebar fixes
This commit is contained in:
Johan Malm 2022-09-09 21:35:30 +01:00 committed by GitHub
commit 1483158b26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 32 deletions

View file

@ -186,8 +186,10 @@ The rest of this man page describes configuration options.
*<action>* can exist within one *<mousebind>*
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.

View file

@ -215,9 +215,6 @@
<action name="Focus"/>
<action name="Raise"/>
</mousebind>
<mousebind button="Left" action="Drag">
<action name="Move"/>
</mousebind>
<mousebind button="Right" action="Click">
<action name="Focus" />
<action name="Raise" />
@ -225,9 +222,13 @@
<menu>client-menu</menu>
</action>
</mousebind>
</context>
<context name="Title">
<mousebind button="Left" action="Drag">
<action name="Move"/>
</mousebind>
<mousebind button="Left" action="DoubleClick">
<action name="Focus"/>
<action name="Raise"/>
<action name="ToggleMaximize"/>
</mousebind>
</context>

View file

@ -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"},

View file

@ -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");

View file

@ -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) {
@ -243,6 +249,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;