mirror of
https://github.com/swaywm/sway.git
synced 2024-11-26 18:01:29 +00:00
Merge pull request #1791 from RyanDwyer/fix-swaybar-output-config
Fix swaybar output config
This commit is contained in:
commit
4240ede065
|
@ -264,6 +264,19 @@ struct wl_output_listener output_listener = {
|
|||
.scale = output_scale,
|
||||
};
|
||||
|
||||
static bool bar_uses_output(struct swaybar *bar, size_t output_index) {
|
||||
if (bar->config->all_outputs) {
|
||||
return true;
|
||||
}
|
||||
struct config_output *coutput;
|
||||
wl_list_for_each(coutput, &bar->config->outputs, link) {
|
||||
if (coutput->index == output_index) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void handle_global(void *data, struct wl_registry *registry,
|
||||
uint32_t name, const char *interface, uint32_t version) {
|
||||
struct swaybar *bar = data;
|
||||
|
@ -278,7 +291,8 @@ static void handle_global(void *data, struct wl_registry *registry,
|
|||
bar->shm = wl_registry_bind(registry, name,
|
||||
&wl_shm_interface, 1);
|
||||
} else if (strcmp(interface, wl_output_interface.name) == 0) {
|
||||
static size_t index = 0;
|
||||
static size_t output_index = 0;
|
||||
if (bar_uses_output(bar, output_index)) {
|
||||
struct swaybar_output *output =
|
||||
calloc(1, sizeof(struct swaybar_output));
|
||||
output->bar = bar;
|
||||
|
@ -286,11 +300,13 @@ static void handle_global(void *data, struct wl_registry *registry,
|
|||
&wl_output_interface, 3);
|
||||
wl_output_add_listener(output->output, &output_listener, output);
|
||||
output->scale = 1;
|
||||
output->index = index++;
|
||||
output->index = output_index;
|
||||
output->wl_name = name;
|
||||
wl_list_init(&output->workspaces);
|
||||
wl_list_init(&output->hotspots);
|
||||
wl_list_insert(&bar->outputs, &output->link);
|
||||
}
|
||||
++output_index;
|
||||
} else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) {
|
||||
bar->layer_shell = wl_registry_bind(
|
||||
registry, name, &zwlr_layer_shell_v1_interface, 1);
|
||||
|
@ -362,14 +378,14 @@ void bar_setup(struct swaybar *bar,
|
|||
pointer->cursor_surface = wl_compositor_create_surface(bar->compositor);
|
||||
assert(pointer->cursor_surface);
|
||||
|
||||
// TODO: we might not necessarily be meant to do all of the outputs
|
||||
wl_list_for_each(output, &bar->outputs, link) {
|
||||
struct config_output *coutput;
|
||||
wl_list_for_each(coutput, &bar->config->outputs, link) {
|
||||
if (coutput->index != output->index) {
|
||||
continue;
|
||||
}
|
||||
if (coutput->index == output->index) {
|
||||
output->name = strdup(coutput->name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
output->surface = wl_compositor_create_surface(bar->compositor);
|
||||
assert(output->surface);
|
||||
output->layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
||||
|
@ -380,8 +396,6 @@ void bar_setup(struct swaybar *bar,
|
|||
&layer_surface_listener, output);
|
||||
zwlr_layer_surface_v1_set_anchor(output->layer_surface,
|
||||
bar->config->position);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ipc_get_workspaces(bar);
|
||||
render_all_frames(bar);
|
||||
|
|
Loading…
Reference in a new issue