aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seat.c
diff options
context:
space:
mode:
authorLibravatar db <github@benedik.si>2018-04-15 08:24:04 +0200
committerLibravatar db <github@benedik.si>2018-04-15 08:30:30 +0200
commitf555edf353a189c1879640b3169c5cc65701ae2c (patch)
tree4a3ddb25d093bb5d584356764c4d9de4acdf16a5 /sway/input/seat.c
parentMerge pull request #1811 from martinetd/gcc_warnings (diff)
downloadsway-f555edf353a189c1879640b3169c5cc65701ae2c.tar.gz
sway-f555edf353a189c1879640b3169c5cc65701ae2c.tar.zst
sway-f555edf353a189c1879640b3169c5cc65701ae2c.zip
remove empty workspace when focusing its output
Until now, focus changing code only considered cleaning up the last focused workspace. This commit adds removal of empty workspace from output that just received focus on a different workspace. Fixes: #1797
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 431460c4..09927a1a 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -448,6 +448,21 @@ void seat_set_focus_warp(struct sway_seat *seat,
448 return; 448 return;
449 } 449 }
450 450
451 struct sway_container *last_output = last_focus;
452 if (last_output && last_output->type != C_OUTPUT) {
453 last_output = container_parent(last_output, C_OUTPUT);
454 }
455 struct sway_container *new_output = container;
456 if (new_output && new_output->type != C_OUTPUT) {
457 new_output = container_parent(new_output, C_OUTPUT);
458 }
459
460 // find new output's old workspace, which might have to be removed if empty
461 struct sway_container *new_output_last_ws = NULL;
462 if (last_output && new_output && last_output != new_output) {
463 new_output_last_ws = seat_get_focus_by_type(seat, new_output, C_WORKSPACE);
464 }
465
451 if (container) { 466 if (container) {
452 struct sway_seat_container *seat_con = 467 struct sway_seat_container *seat_con =
453 seat_container_from_container(seat, container); 468 seat_container_from_container(seat, container);
@@ -482,6 +497,14 @@ void seat_set_focus_warp(struct sway_seat *seat,
482 } 497 }
483 } 498 }
484 499
500 // clean up unfocused empty workspace on new output
501 if (new_output_last_ws) {
502 if (!workspace_is_visible(new_output_last_ws)
503 && new_output_last_ws->children->length == 0) {
504 container_destroy(new_output_last_ws);
505 }
506 }
507
485 if (last_focus) { 508 if (last_focus) {
486 struct sway_container *last_ws = last_focus; 509 struct sway_container *last_ws = last_focus;
487 if (last_ws && last_ws->type != C_WORKSPACE) { 510 if (last_ws && last_ws->type != C_WORKSPACE) {
@@ -499,14 +522,6 @@ void seat_set_focus_warp(struct sway_seat *seat,
499 } 522 }
500 523
501 if (config->mouse_warping && warp) { 524 if (config->mouse_warping && warp) {
502 struct sway_container *last_output = last_focus;
503 if (last_output && last_output->type != C_OUTPUT) {
504 last_output = container_parent(last_output, C_OUTPUT);
505 }
506 struct sway_container *new_output = container;
507 if (new_output && new_output->type != C_OUTPUT) {
508 new_output = container_parent(new_output, C_OUTPUT);
509 }
510 if (new_output && last_output && new_output != last_output) { 525 if (new_output && last_output && new_output != last_output) {
511 double x = new_output->x + container->x + 526 double x = new_output->x + container->x +
512 container->width / 2.0; 527 container->width / 2.0;