diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-03-29 00:07:35 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-03-29 22:11:08 -0400 |
commit | e5e8094dc3119584ae611c3197b38243b6c016c9 (patch) | |
tree | 6d0c6f0ff47f495f0cafc1a6d617a471330d2258 /swaybar/bar.c | |
parent | Wire up basic IPC support (diff) | |
download | sway-e5e8094dc3119584ae611c3197b38243b6c016c9.tar.gz sway-e5e8094dc3119584ae611c3197b38243b6c016c9.tar.zst sway-e5e8094dc3119584ae611c3197b38243b6c016c9.zip |
Only utilize the configured outputs
Diffstat (limited to 'swaybar/bar.c')
-rw-r--r-- | swaybar/bar.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c index 433e2948..a6e3b780 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c | |||
@@ -65,13 +65,13 @@ static void handle_global(void *data, struct wl_registry *registry, | |||
65 | bar->shm = wl_registry_bind(registry, name, | 65 | bar->shm = wl_registry_bind(registry, name, |
66 | &wl_shm_interface, 1); | 66 | &wl_shm_interface, 1); |
67 | } else if (strcmp(interface, wl_output_interface.name) == 0) { | 67 | } else if (strcmp(interface, wl_output_interface.name) == 0) { |
68 | static int idx = 0; | 68 | static size_t index = 0; |
69 | struct swaybar_output *output = | 69 | struct swaybar_output *output = |
70 | calloc(1, sizeof(struct swaybar_output)); | 70 | calloc(1, sizeof(struct swaybar_output)); |
71 | output->bar = bar; | 71 | output->bar = bar; |
72 | output->output = wl_registry_bind(registry, name, | 72 | output->output = wl_registry_bind(registry, name, |
73 | &wl_output_interface, 1); | 73 | &wl_output_interface, 1); |
74 | output->idx = idx++; | 74 | output->index = index++; |
75 | wl_list_insert(&bar->outputs, &output->link); | 75 | wl_list_insert(&bar->outputs, &output->link); |
76 | } else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) { | 76 | } else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) { |
77 | bar->layer_shell = wl_registry_bind( | 77 | bar->layer_shell = wl_registry_bind( |
@@ -108,16 +108,24 @@ void bar_setup(struct swaybar *bar, | |||
108 | // TODO: we might not necessarily be meant to do all of the outputs | 108 | // TODO: we might not necessarily be meant to do all of the outputs |
109 | struct swaybar_output *output; | 109 | struct swaybar_output *output; |
110 | wl_list_for_each(output, &bar->outputs, link) { | 110 | wl_list_for_each(output, &bar->outputs, link) { |
111 | assert(output->surface = wl_compositor_create_surface(bar->compositor)); | 111 | struct config_output *coutput; |
112 | output->layer_surface = zwlr_layer_shell_v1_get_layer_surface( | 112 | wl_list_for_each(coutput, &bar->config->outputs, link) { |
113 | bar->layer_shell, output->surface, output->output, | 113 | if (coutput->index != output->index) { |
114 | ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM, "panel"); | 114 | continue; |
115 | assert(output->layer_surface); | 115 | } |
116 | zwlr_layer_surface_v1_add_listener(output->layer_surface, | 116 | assert(output->surface = wl_compositor_create_surface( |
117 | &layer_surface_listener, output); | 117 | bar->compositor)); |
118 | zwlr_layer_surface_v1_set_anchor(output->layer_surface, | 118 | output->layer_surface = zwlr_layer_shell_v1_get_layer_surface( |
119 | bar->config->position); | 119 | bar->layer_shell, output->surface, output->output, |
120 | render_frame(bar, output); | 120 | ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM, "panel"); |
121 | assert(output->layer_surface); | ||
122 | zwlr_layer_surface_v1_add_listener(output->layer_surface, | ||
123 | &layer_surface_listener, output); | ||
124 | zwlr_layer_surface_v1_set_anchor(output->layer_surface, | ||
125 | bar->config->position); | ||
126 | render_frame(bar, output); | ||
127 | break; | ||
128 | } | ||
121 | } | 129 | } |
122 | } | 130 | } |
123 | 131 | ||