summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-04-15 09:17:36 -0400
committerLibravatar GitHub <noreply@github.com>2018-04-15 09:17:36 -0400
commitdbc36935ee857375669e7ab3d0f20f1b5b098d23 (patch)
tree4a3ddb25d093bb5d584356764c4d9de4acdf16a5
parentMerge pull request #1811 from martinetd/gcc_warnings (diff)
parentremove empty workspace when focusing its output (diff)
downloadsway-dbc36935ee857375669e7ab3d0f20f1b5b098d23.tar.gz
sway-dbc36935ee857375669e7ab3d0f20f1b5b098d23.tar.zst
sway-dbc36935ee857375669e7ab3d0f20f1b5b098d23.zip
Merge pull request #1816 from thejan2009/multi-output-ws-destroy
remove empty workspace when focusing its output
-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;