From bc0288effbb95da035da2d9ec8ce698d752ac58c Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Sat, 8 Feb 2025 21:59:06 +0800 Subject: [PATCH] feat: add switch window like gnome alt+tab --- config.def.h | 3 ++- main.c | 24 +++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/config.def.h b/config.def.h index 510c462..711ec18 100644 --- a/config.def.h +++ b/config.def.h @@ -28,6 +28,7 @@ static int log_level = WLR_ERROR; static const unsigned int numlockon = 1; // Enable numlock static const unsigned int hotarea_size = 10; // Hot area size, 10x10 static const unsigned int enable_hotarea = 1; // Enable mouse hot area +static const unsigned int ov_tab_mode = 1; // Enable switch window like gnome alt+tab static int smartgaps = 0; /* 1 means no outer gap when there is only one window */ static int sloppyfocus = 1; /* Focus follows mouse */ static unsigned int gappih = 5; /* Horizontal inner gap between windows */ @@ -252,7 +253,7 @@ static const Button buttons[] = { { 0, BTN_MIDDLE, togglefakefullscreen, {0} }, // Middle button triggers fake fullscreen { WLR_MODIFIER_LOGO, BTN_RIGHT, moveresize, {.ui = CurResize } }, { WLR_MODIFIER_ALT|WLR_MODIFIER_CTRL, BTN_LEFT, spawn, SHCMD("bash ~/tool/shotTranslate.sh shot")}, - { 0, BTN_LEFT, toggleoverview, {0} }, + { 0, BTN_LEFT, toggleoverview, {.i = -1 } }, { 0, BTN_RIGHT, killclient, {0} }, }; diff --git a/main.c b/main.c index 38d9942..c3678f7 100644 --- a/main.c +++ b/main.c @@ -1722,7 +1722,7 @@ void client_set_pending_state(Client *c) { (!c->is_open_animation && wlr_box_equal(&c->current, &c->pending))) { c->animation.should_animate = false; - } else { + } else { c->animation.should_animate = true; c->animation.initial = c->animainit_geom; } @@ -2810,6 +2810,17 @@ keypress(struct wl_listener *listener, void *data) { uint32_t mods = wlr_keyboard_get_modifiers(kb->wlr_keyboard); wlr_idle_notifier_v1_notify_activity(idle_notifier, seat); + + // ov tab mode detect moe key release + if (ov_tab_mode && !locked && event->state == WL_KEYBOARD_KEY_STATE_RELEASED && + (keycode == 133 || keycode == 37 || keycode == 64 || keycode == 50 || + keycode == 134 || keycode == 105 || keycode == 108 || keycode == 62) && + selmon->sel) { + if(selmon->isoverview && selmon->sel) { + toggleoverview(&(Arg){.i=-1}); + } + } + #ifdef IM if (!locked && event->state == WL_KEYBOARD_KEY_STATE_RELEASED && (keycode == 133 || keycode == 37 || keycode == 64 || keycode == 50 || @@ -4633,6 +4644,12 @@ void overview_restore(Client *c, const Arg *arg) { void toggleoverview(const Arg *arg) { Client *c; + + if(selmon->isoverview && ov_tab_mode && arg->i != -1 && selmon->sel) { + focusstack(&(Arg){.i=1}); + return; + } + selmon->isoverview ^= 1; unsigned int target; unsigned int visible_client_number = 0; @@ -4674,6 +4691,11 @@ void toggleoverview(const Arg *arg) { } view(&(Arg){.ui = target}, false); + + if (ov_tab_mode && selmon->isoverview && selmon->sel) { + focusstack(&(Arg){.i=1}); + } + } void tile(Monitor *m, unsigned int gappo, unsigned int uappi) {