From af51e86b32a5a27e4634a77aca85acce11d7e44b Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Sun, 16 Mar 2025 09:00:23 +0800 Subject: [PATCH] feat: avoid continuous scrolling for scroller layout Avoid continuous scrolling of the scroll layout by moving the mouse to the edge of the screen --- maomao.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/maomao.c b/maomao.c index 4e85842..c328ee0 100644 --- a/maomao.c +++ b/maomao.c @@ -640,6 +640,7 @@ static Monitor *selmon; static int enablegaps = 1; /* enables gaps, used by togglegaps */ static int axis_apply_time = 0; static int axis_apply_dir = 0; +static int scroller_focus_lock = 0; /* global event handlers */ static struct zdwl_ipc_manager_v2_interface dwl_manager_implementation = { @@ -3812,6 +3813,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, LayerSurface *l = NULL; struct wlr_surface *surface = NULL; struct wlr_pointer_constraint_v1 *constraint; + bool should_lock = false; /* Find the client under the pointer and send the event along. */ xytonode(cursor->x, cursor->y, &surface, &c, NULL, &sx, &sy); @@ -3888,7 +3890,23 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, if (!surface && !seat->drag) wlr_cursor_set_xcursor(cursor, cursor_mgr, "left_ptr"); - pointerfocus(c, surface, sx, sy, time); + + if(c && c->mon && !c->animation.running && !(c->geom.x + c->geom.width > c->mon->m.x + c->mon->m.width || c->geom.x < c->mon->m.x)) { + scroller_focus_lock = 0; + } + + should_lock = false; + if(!scroller_focus_lock || !(c && c->mon && (c->geom.x + c->geom.width > c->mon->m.x + c->mon->m.width || c->geom.x < c->mon->m.x)) ) { + if(c && c->mon && strcmp(c->mon->pertag->ltidxs[selmon->pertag->curtag]->name, + "scroller") == 0 && (c->geom.x + c->geom.width > c->mon->m.x + c->mon->m.width || c->geom.x < c->mon->m.x)) { + should_lock = true; + } + pointerfocus(c, surface, sx, sy, time); + + if(should_lock && c && c->mon && c == c->mon->sel) { + scroller_focus_lock = 1; + } + } } void // fix for 0.5 光标相对位置移动事件处理