diff --git a/src/animation/client.h b/src/animation/client.h index f988651e..35d2a30f 100644 --- a/src/animation/client.h +++ b/src/animation/client.h @@ -699,17 +699,6 @@ void client_set_drop_area(Client *c) { bool dwindle_familiar = cur_layout->id == DWINDLE && config.dwindle_drop_simple_split; - uint32_t nmaster = c->mon->pertag->nmasters[c->mon->pertag->curtag]; - - bool should_swap = - (cur_layout->id == DECK || cur_layout->id == VERTICAL_DECK || - cur_layout->id == MONOCLE || cur_layout->id == GRID || - cur_layout->id == FAIR || cur_layout->id == VERTICAL_FAIR || - cur_layout->id == VERTICAL_GRID) || - ((cur_layout->id == TILE || cur_layout->id == VERTICAL_TILE || - cur_layout->id == CENTER_TILE || cur_layout->id == RIGHT_TILE) && - nmaster == 1 && c->ismaster); - if (dwindle_familiar) { bool split_h = c->geom.width >= c->geom.height; float ratio = config.dwindle_split_ratio; @@ -743,42 +732,87 @@ void client_set_drop_area(Client *c) { client_height - (int32_t)(client_height * ratio); } } - } else if (should_swap) { - drop_box.x = bw; - drop_box.y = bw; - drop_box.width = client_width; - drop_box.height = client_height; - drop_direction = UNDIR; } else if (cur_layout->id == TILE || cur_layout->id == DECK || cur_layout->id == CENTER_TILE || cur_layout->id == RIGHT_TILE) { - if (rel_y < client_height * 0.5) { - drop_direction = UP; - drop_box.x = bw; - drop_box.y = bw; - drop_box.width = client_width; - drop_box.height = client_height / 2; + + if (c->ismaster) { + if (c->mon->visible_tiling_clients == 1) { + if (rel_x < client_width * 0.5) { + drop_direction = LEFT; + drop_box.x = bw; + drop_box.y = bw; + drop_box.width = client_width / 2; + drop_box.height = client_height; + } else { + drop_direction = RIGHT; + drop_box.x = bw + client_width / 2; + drop_box.y = bw; + drop_box.width = client_width / 2; + drop_box.height = client_height; + } + } else { + drop_box.x = bw; + drop_box.y = bw; + drop_box.width = client_width; + drop_box.height = client_height; + drop_direction = UNDIR; + } } else { - drop_direction = DOWN; - drop_box.x = bw; - drop_box.y = bw + client_height / 2; - drop_box.width = client_width; - drop_box.height = client_height / 2; + if (rel_y < client_height * 0.5) { + drop_direction = UP; + drop_box.x = bw; + drop_box.y = bw; + drop_box.width = client_width; + drop_box.height = client_height / 2; + } else { + drop_direction = DOWN; + drop_box.x = bw; + drop_box.y = bw + client_height / 2; + drop_box.width = client_width; + drop_box.height = client_height / 2; + } } } else if (cur_layout->id == VERTICAL_TILE || cur_layout->id == VERTICAL_DECK) { - if (rel_x < client_width * 0.5) { - drop_direction = LEFT; - drop_box.x = bw; - drop_box.y = bw; - drop_box.width = client_width / 2; - drop_box.height = client_height; + if (c->ismaster) { + if (c->mon->visible_tiling_clients == 1) { + if (rel_y < client_height * 0.5) { + drop_direction = UP; + drop_box.x = bw; + drop_box.y = bw; + drop_box.width = client_width; + drop_box.height = client_height / 2; + } else { + drop_direction = DOWN; + drop_box.x = bw; + drop_box.y = bw + client_height / 2; + drop_box.width = client_width; + drop_box.height = client_height / 2; + } + } else { + drop_box.x = bw; + drop_box.y = bw; + drop_box.width = client_width; + drop_box.height = client_height; + drop_direction = UNDIR; + } + } else { - drop_direction = RIGHT; - drop_box.x = bw + client_width / 2; - drop_box.y = bw; - drop_box.width = client_width / 2; - drop_box.height = client_height; + if (rel_x < client_width * 0.5) { + drop_direction = LEFT; + drop_box.x = bw; + drop_box.y = bw; + drop_box.width = client_width / 2; + drop_box.height = client_height; + } else { + drop_direction = RIGHT; + drop_box.x = bw + client_width / 2; + drop_box.y = bw; + drop_box.width = client_width / 2; + drop_box.height = client_height; + } } + } else { double dist_left = rel_x; double dist_right = client_width - rel_x; diff --git a/src/mango.c b/src/mango.c index 731c0ac3..1e39ddb5 100644 --- a/src/mango.c +++ b/src/mango.c @@ -2202,9 +2202,10 @@ void hold_end(struct wl_listener *listener, void *data) { Client *find_closest_tiled_client(Client *c) { Client *tc, *closest = NULL; long min_dist = LONG_MAX; + Monitor *cursor_mon = xytomon(cursor->x, cursor->y); wl_list_for_each(tc, &clients, link) { - if (tc == c || !ISTILED(tc) || !VISIBLEON(tc, c->mon)) + if (tc == c || !ISTILED(tc) || !VISIBLEON(tc, cursor_mon)) continue; if (cursor->x >= tc->geom.x && @@ -2236,7 +2237,9 @@ void place_drag_tile_client(Client *c) { if (closest->drop_direction == UNDIR) { setfloating(c, 0); - exchange_two_client(c, closest); + wl_list_remove(&c->link); + wl_list_insert(closest->link.prev, &c->link); + arrange(closest->mon, false, false); return; }