focus: add <focusOnTitlebarEnter> option to follow-mouse on SSD titlebars

This commit is contained in:
Maik Broemme 2025-11-13 12:52:27 +01:00
parent 9f4178955a
commit 7d9024d33a
No known key found for this signature in database
GPG key ID: 27BE1125704B8B02
3 changed files with 17 additions and 0 deletions

View file

@ -199,6 +199,9 @@ struct rcxml {
float mag_scale;
float mag_increment;
bool mag_filter;
/* Focus behavior */
bool focus_titlebar_on_mouse_enter;
};
extern struct rcxml rc;

View file

@ -1142,6 +1142,8 @@ entry(xmlNode *node, char *nodename, char *content)
set_bool(content, &rc.focus_follow_mouse_requires_movement);
} else if (!strcasecmp(nodename, "raiseOnFocus.focus")) {
set_bool(content, &rc.raise_on_focus);
} else if (!strcasecmp(nodename, "focusOnTitlebarEnter.focus")) {
set_bool(content, &rc.focus_titlebar_on_mouse_enter);
} else if (!strcasecmp(nodename, "doubleClickTime.mouse")) {
long doubleclick_time_parsed = strtol(content, NULL, 10);
if (doubleclick_time_parsed > 0) {
@ -1406,6 +1408,9 @@ rcxml_init(void)
}
has_run = true;
/* default: don't focus on titlebar enter */
rc.focus_titlebar_on_mouse_enter = false;
rc.placement_policy = LAB_PLACE_CASCADE;
rc.placement_cascade_offset_x = 0;
rc.placement_cascade_offset_y = 0;

View file

@ -563,6 +563,15 @@ cursor_update_common(struct server *server, struct cursor_context *ctx,
* a drag operation.
*/
wlr_seat_pointer_notify_clear_focus(wlr_seat);
/* Optional: focus toplevel when entering SSD titlebar/title/buttons */
if (rc.focus_follow_mouse && rc.focus_titlebar_on_mouse_enter && ctx->view) {
/* Titlebar region, window title, or any titlebar button */
if (ctx->type == LAB_NODE_TITLEBAR || ctx->type == LAB_NODE_TITLE
|| node_type_contains(LAB_NODE_BUTTON, ctx->type)) {
desktop_focus_view_or_surface(&server->seat,
ctx->view, NULL, rc.raise_on_focus);
}
}
if (!seat->drag.active) {
enum lab_cursors cursor = cursor_get_from_ssd(ctx->type);
if (ctx->view && ctx->view->shaded && cursor > LAB_CURSOR_GRAB) {