From 7d9024d33a4c6fa329e77c092e7bd33523e954ca Mon Sep 17 00:00:00 2001 From: Maik Broemme Date: Thu, 13 Nov 2025 12:52:27 +0100 Subject: [PATCH] focus: add `` option to follow-mouse on SSD titlebars --- include/config/rcxml.h | 3 +++ src/config/rcxml.c | 5 +++++ src/input/cursor.c | 9 +++++++++ 3 files changed, 17 insertions(+) diff --git a/include/config/rcxml.h b/include/config/rcxml.h index 91a73d58..7addd6f4 100644 --- a/include/config/rcxml.h +++ b/include/config/rcxml.h @@ -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; diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 264c65a8..0897e2ea 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -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; diff --git a/src/input/cursor.c b/src/input/cursor.c index 6c12d3da..ea69f3e3 100644 --- a/src/input/cursor.c +++ b/src/input/cursor.c @@ -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) {