From e29cec64e4e4391ac995577887641eb29d98c1c5 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Tue, 26 May 2026 22:24:58 +0800 Subject: [PATCH] opt: focusid allow cross tag --- src/action/client.h | 28 +++++++++++++++++++++++++++- src/dispatch/bind_define.h | 2 +- src/ext-protocol/foreign-toplevel.h | 18 +----------------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/action/client.h b/src/action/client.h index 43eb2c7b..b7960d70 100644 --- a/src/action/client.h +++ b/src/action/client.h @@ -60,4 +60,30 @@ void client_tile_resize(Client *c, struct wlr_box geo, int32_t interact) { } static uint32_t next_client_id = 0; -uint32_t generate_client_id(void) { return ++next_client_id; } \ No newline at end of file +uint32_t generate_client_id(void) { return ++next_client_id; } + +void client_active(Client *c) { + uint32_t target; + + if (client_is_unmanaged(c)) { + focusclient(c, 1); + return; + } + + if (c->swallowing || !c->mon) + return; + + if (c->isminimized) { + c->is_in_scratchpad = 0; + c->isnamedscratchpad = 0; + c->is_scratchpad_show = 0; + setborder_color(c); + show_hide_client(c); + arrange(c->mon, true, false); + return; + } + + target = get_tags_first_tag(c->tags); + view_in_mon(&(Arg){.ui = target}, true, c->mon, true); + focusclient(c, 1); +} \ No newline at end of file diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index 6b0808f0..73b95a67 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -2001,6 +2001,6 @@ int32_t focusid(const Arg *arg) { return 0; Client *c = arg->tc; - focusclient(c, 1); + client_active(c); return 0; } \ No newline at end of file diff --git a/src/ext-protocol/foreign-toplevel.h b/src/ext-protocol/foreign-toplevel.h index 0c09e0c2..4fdbbe98 100644 --- a/src/ext-protocol/foreign-toplevel.h +++ b/src/ext-protocol/foreign-toplevel.h @@ -4,24 +4,8 @@ static struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager; void handle_foreign_activate_request(struct wl_listener *listener, void *data) { Client *c = wl_container_of(listener, c, foreign_activate_request); - uint32_t target; - if (c->swallowing || !c->mon) - return; - - if (c->isminimized) { - c->is_in_scratchpad = 0; - c->isnamedscratchpad = 0; - c->is_scratchpad_show = 0; - setborder_color(c); - show_hide_client(c); - arrange(c->mon, true, false); - return; - } - - target = get_tags_first_tag(c->tags); - view_in_mon(&(Arg){.ui = target}, true, c->mon, true); - focusclient(c, 1); + client_active(c); } void handle_foreign_maximize_request(struct wl_listener *listener, void *data) {