diff options
author | Alex Maese <memaese@hotmail.com> | 2022-06-09 18:27:24 -0500 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2022-09-19 07:26:45 -0400 |
commit | c015db4a9f115bfa10bd0b4c3fa05aca51b04c9b (patch) | |
tree | 0581ccd8c3639a20df1397b8c7e2dab6881a3289 /sway/tree | |
parent | Fix crash in xdg_activation_v1.c (diff) | |
download | sway-c015db4a9f115bfa10bd0b4c3fa05aca51b04c9b.tar.gz sway-c015db4a9f115bfa10bd0b4c3fa05aca51b04c9b.tar.zst sway-c015db4a9f115bfa10bd0b4c3fa05aca51b04c9b.zip |
sway: Add non-desktop-output type
Currently, when encountering a non-desktop display, sway offers the
output for leasing and returns without storing it in a sway specific
output type like `struct sway_output`. Additionally, running
`swaymsg -t get_outputs` doesn't show non-desktop outputs.
This commit stores the non-desktop outputs into a struct called
`sway_output_non_desktop`, and adds them to a list on `sway_root`
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/output.c | 28 | ||||
-rw-r--r-- | sway/tree/root.c | 1 |
2 files changed, 29 insertions, 0 deletions
diff --git a/sway/tree/output.c b/sway/tree/output.c index 52826c91..b30e646e 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "sway/output.h" | 9 | #include "sway/output.h" |
10 | #include "sway/tree/arrange.h" | 10 | #include "sway/tree/arrange.h" |
11 | #include "sway/tree/workspace.h" | 11 | #include "sway/tree/workspace.h" |
12 | #include "sway/server.h" | ||
12 | #include "log.h" | 13 | #include "log.h" |
13 | #include "util.h" | 14 | #include "util.h" |
14 | 15 | ||
@@ -390,6 +391,33 @@ void output_get_box(struct sway_output *output, struct wlr_box *box) { | |||
390 | box->height = output->height; | 391 | box->height = output->height; |
391 | } | 392 | } |
392 | 393 | ||
394 | static void handle_destroy_non_desktop(struct wl_listener *listener, void *data) { | ||
395 | struct sway_output_non_desktop *output = | ||
396 | wl_container_of(listener, output, destroy); | ||
397 | |||
398 | sway_log(SWAY_DEBUG, "Destroying non-desktop output '%s'", output->wlr_output->name); | ||
399 | |||
400 | int index = list_find(root->non_desktop_outputs, output); | ||
401 | list_del(root->non_desktop_outputs, index); | ||
402 | |||
403 | wl_list_remove(&output->destroy.link); | ||
404 | |||
405 | free(output); | ||
406 | } | ||
407 | |||
408 | struct sway_output_non_desktop *output_non_desktop_create( | ||
409 | struct wlr_output *wlr_output) { | ||
410 | struct sway_output_non_desktop *output = | ||
411 | calloc(1, sizeof(struct sway_output_non_desktop)); | ||
412 | |||
413 | output->wlr_output = wlr_output; | ||
414 | |||
415 | wl_signal_add(&wlr_output->events.destroy, &output->destroy); | ||
416 | output->destroy.notify = handle_destroy_non_desktop; | ||
417 | |||
418 | return output; | ||
419 | } | ||
420 | |||
393 | enum sway_container_layout output_get_default_layout( | 421 | enum sway_container_layout output_get_default_layout( |
394 | struct sway_output *output) { | 422 | struct sway_output *output) { |
395 | if (config->default_orientation != L_NONE) { | 423 | if (config->default_orientation != L_NONE) { |
diff --git a/sway/tree/root.c b/sway/tree/root.c index 8508e9eb..7df0b237 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c | |||
@@ -38,6 +38,7 @@ struct sway_root *root_create(void) { | |||
38 | wl_list_init(&root->drag_icons); | 38 | wl_list_init(&root->drag_icons); |
39 | wl_signal_init(&root->events.new_node); | 39 | wl_signal_init(&root->events.new_node); |
40 | root->outputs = create_list(); | 40 | root->outputs = create_list(); |
41 | root->non_desktop_outputs = create_list(); | ||
41 | root->scratchpad = create_list(); | 42 | root->scratchpad = create_list(); |
42 | 43 | ||
43 | root->output_layout_change.notify = output_layout_handle_change; | 44 | root->output_layout_change.notify = output_layout_handle_change; |