feat: add switch window like gnome alt+tab

This commit is contained in:
DreamMaoMao 2025-02-08 21:59:06 +08:00
parent 2c2c5baa3e
commit bc0288effb
2 changed files with 25 additions and 2 deletions

View file

@ -28,6 +28,7 @@ static int log_level = WLR_ERROR;
static const unsigned int numlockon = 1; // Enable numlock static const unsigned int numlockon = 1; // Enable numlock
static const unsigned int hotarea_size = 10; // Hot area size, 10x10 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 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 smartgaps = 0; /* 1 means no outer gap when there is only one window */
static int sloppyfocus = 1; /* Focus follows mouse */ static int sloppyfocus = 1; /* Focus follows mouse */
static unsigned int gappih = 5; /* Horizontal inner gap between windows */ 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 { 0, BTN_MIDDLE, togglefakefullscreen, {0} }, // Middle button triggers fake fullscreen
{ WLR_MODIFIER_LOGO, BTN_RIGHT, moveresize, {.ui = CurResize } }, { WLR_MODIFIER_LOGO, BTN_RIGHT, moveresize, {.ui = CurResize } },
{ WLR_MODIFIER_ALT|WLR_MODIFIER_CTRL, BTN_LEFT, spawn, SHCMD("bash ~/tool/shotTranslate.sh shot")}, { 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} }, { 0, BTN_RIGHT, killclient, {0} },
}; };

24
main.c
View file

@ -1722,7 +1722,7 @@ void client_set_pending_state(Client *c) {
(!c->is_open_animation && (!c->is_open_animation &&
wlr_box_equal(&c->current, &c->pending))) { wlr_box_equal(&c->current, &c->pending))) {
c->animation.should_animate = false; c->animation.should_animate = false;
} else { } else {
c->animation.should_animate = true; c->animation.should_animate = true;
c->animation.initial = c->animainit_geom; 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); uint32_t mods = wlr_keyboard_get_modifiers(kb->wlr_keyboard);
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat); 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 #ifdef IM
if (!locked && event->state == WL_KEYBOARD_KEY_STATE_RELEASED && if (!locked && event->state == WL_KEYBOARD_KEY_STATE_RELEASED &&
(keycode == 133 || keycode == 37 || keycode == 64 || keycode == 50 || (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) { void toggleoverview(const Arg *arg) {
Client *c; Client *c;
if(selmon->isoverview && ov_tab_mode && arg->i != -1 && selmon->sel) {
focusstack(&(Arg){.i=1});
return;
}
selmon->isoverview ^= 1; selmon->isoverview ^= 1;
unsigned int target; unsigned int target;
unsigned int visible_client_number = 0; unsigned int visible_client_number = 0;
@ -4674,6 +4691,11 @@ void toggleoverview(const Arg *arg) {
} }
view(&(Arg){.ui = target}, false); 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) { void tile(Monitor *m, unsigned int gappo, unsigned int uappi) {