feat: add option exchange_cross_monitor

This commit is contained in:
DreamMaoMao 2025-09-20 19:34:07 +08:00
parent e5f6f9e415
commit 980ada2658
3 changed files with 30 additions and 4 deletions

View file

@ -173,6 +173,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;
@ -977,6 +978,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) {
@ -2359,6 +2362,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);
@ -2508,6 +2512,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;

View file

@ -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;

View file

@ -4137,7 +4137,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;
}
@ -4178,8 +4183,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
@ -4579,7 +4594,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(