From b97f5928cfa4591090add1c7143024ce86dbc717 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Sat, 20 Sep 2025 19:34:07 +0800 Subject: [PATCH] feat: add option exchange_cross_monitor --- src/config/parse_config.h | 5 +++++ src/config/preset.h | 1 + src/mango.c | 28 ++++++++++++++++++++++++---- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/config/parse_config.h b/src/config/parse_config.h index cbbfd72..f5a5047 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -171,6 +171,7 @@ typedef struct { int scroller_prefer_center; int edge_scroller_pointer_focus; int focus_cross_monitor; + int exchange_cross_monitor; int focus_cross_tag; int view_current_to_back; int no_border_when_single; @@ -960,6 +961,8 @@ void parse_config_line(Config *config, const char *line) { config->edge_scroller_pointer_focus = atoi(value); } else if (strcmp(key, "focus_cross_monitor") == 0) { config->focus_cross_monitor = atoi(value); + } else if (strcmp(key, "exchange_cross_monitor") == 0) { + config->exchange_cross_monitor = atoi(value); } else if (strcmp(key, "focus_cross_tag") == 0) { config->focus_cross_tag = atoi(value); } else if (strcmp(key, "view_current_to_back") == 0) { @@ -2293,6 +2296,7 @@ void override_config(void) { sloppyfocus = CLAMP_INT(config.sloppyfocus, 0, 1); warpcursor = CLAMP_INT(config.warpcursor, 0, 1); focus_cross_monitor = CLAMP_INT(config.focus_cross_monitor, 0, 1); + exchange_cross_monitor = CLAMP_INT(config.exchange_cross_monitor, 0, 1); focus_cross_tag = CLAMP_INT(config.focus_cross_tag, 0, 1); view_current_to_back = CLAMP_INT(config.view_current_to_back, 0, 1); enable_floating_snap = CLAMP_INT(config.enable_floating_snap, 0, 1); @@ -2423,6 +2427,7 @@ void set_value_default() { config.scroller_prefer_center = scroller_prefer_center; config.edge_scroller_pointer_focus = edge_scroller_pointer_focus; config.focus_cross_monitor = focus_cross_monitor; + config.exchange_cross_monitor = exchange_cross_monitor; config.focus_cross_tag = focus_cross_tag; config.view_current_to_back = view_current_to_back; config.single_scratchpad = single_scratchpad; diff --git a/src/config/preset.h b/src/config/preset.h index 27bb9d3..0f63e75 100644 --- a/src/config/preset.h +++ b/src/config/preset.h @@ -61,6 +61,7 @@ int scroller_focus_center = 0; int scroller_prefer_center = 0; int focus_cross_monitor = 0; int focus_cross_tag = 0; +int exchange_cross_monitor = 0; int view_current_to_back = 1; int no_border_when_single = 0; int no_radius_when_single = 0; diff --git a/src/mango.c b/src/mango.c index 845857e..bcad2a4 100644 --- a/src/mango.c +++ b/src/mango.c @@ -4079,7 +4079,12 @@ void setborder_color(Client *c) { } void exchange_two_client(Client *c1, Client *c2) { - if (c1 == NULL || c2 == NULL || c1->mon != c2->mon) { + + Monitor *tmp_mon; + unsigned int tmp_tags; + + if (c1 == NULL || c2 == NULL || + (!exchange_cross_monitor && c1->mon != c2->mon)) { return; } @@ -4120,8 +4125,18 @@ void exchange_two_client(Client *c1, Client *c2) { tmp2_next->prev = &c1->link; } - arrange(c1->mon, false); - focusclient(c1, 0); + if (exchange_cross_monitor) { + tmp_mon = c2->mon; + tmp_tags = c2->tags; + setmon(c2, c1->mon, c1->tags, false); + setmon(c1, tmp_mon, tmp_tags, false); + arrange(c1->mon, false); + arrange(c2->mon, false); + focusclient(c1, 0); + } else { + arrange(c1->mon, false); + focusclient(c1, 0); + } } void // 17 @@ -4521,7 +4536,12 @@ void setmon(Client *c, Monitor *m, unsigned int newtags, bool focus) { if (m && focus) focusclient(focustop(m), 1); - if (!c->foreign_toplevel && m) { + if (m) { + + if (c->foreign_toplevel) { + remove_foreign_topleve(c); + } + add_foreign_toplevel(c); if (m->sel && m->sel->foreign_toplevel) wlr_foreign_toplevel_handle_v1_set_activated(