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,
|
.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,
|
static void handle_global(void *data, struct wl_registry *registry,
|
||||||
uint32_t name, const char *interface, uint32_t version) {
|
uint32_t name, const char *interface, uint32_t version) {
|
||||||
struct swaybar *bar = data;
|
struct swaybar *bar = data;
|
||||||
|
@ -278,19 +291,22 @@ static void handle_global(void *data, struct wl_registry *registry,
|
||||||
bar->shm = wl_registry_bind(registry, name,
|
bar->shm = wl_registry_bind(registry, name,
|
||||||
&wl_shm_interface, 1);
|
&wl_shm_interface, 1);
|
||||||
} else if (strcmp(interface, wl_output_interface.name) == 0) {
|
} else if (strcmp(interface, wl_output_interface.name) == 0) {
|
||||||
static size_t index = 0;
|
static size_t output_index = 0;
|
||||||
struct swaybar_output *output =
|
if (bar_uses_output(bar, output_index)) {
|
||||||
calloc(1, sizeof(struct swaybar_output));
|
struct swaybar_output *output =
|
||||||
output->bar = bar;
|
calloc(1, sizeof(struct swaybar_output));
|
||||||
output->output = wl_registry_bind(registry, name,
|
output->bar = bar;
|
||||||
&wl_output_interface, 3);
|
output->output = wl_registry_bind(registry, name,
|
||||||
wl_output_add_listener(output->output, &output_listener, output);
|
&wl_output_interface, 3);
|
||||||
output->scale = 1;
|
wl_output_add_listener(output->output, &output_listener, output);
|
||||||
output->index = index++;
|
output->scale = 1;
|
||||||
output->wl_name = name;
|
output->index = output_index;
|
||||||
wl_list_init(&output->workspaces);
|
output->wl_name = name;
|
||||||
wl_list_init(&output->hotspots);
|
wl_list_init(&output->workspaces);
|
||||||
wl_list_insert(&bar->outputs, &output->link);
|
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) {
|
} else if (strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) {
|
||||||
bar->layer_shell = wl_registry_bind(
|
bar->layer_shell = wl_registry_bind(
|
||||||
registry, name, &zwlr_layer_shell_v1_interface, 1);
|
registry, name, &zwlr_layer_shell_v1_interface, 1);
|
||||||
|
@ -362,26 +378,24 @@ void bar_setup(struct swaybar *bar,
|
||||||
pointer->cursor_surface = wl_compositor_create_surface(bar->compositor);
|
pointer->cursor_surface = wl_compositor_create_surface(bar->compositor);
|
||||||
assert(pointer->cursor_surface);
|
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) {
|
wl_list_for_each(output, &bar->outputs, link) {
|
||||||
struct config_output *coutput;
|
struct config_output *coutput;
|
||||||
wl_list_for_each(coutput, &bar->config->outputs, link) {
|
wl_list_for_each(coutput, &bar->config->outputs, link) {
|
||||||
if (coutput->index != output->index) {
|
if (coutput->index == output->index) {
|
||||||
continue;
|
output->name = strdup(coutput->name);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
output->name = strdup(coutput->name);
|
|
||||||
output->surface = wl_compositor_create_surface(bar->compositor);
|
|
||||||
assert(output->surface);
|
|
||||||
output->layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
|
||||||
bar->layer_shell, output->surface, output->output,
|
|
||||||
ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM, "panel");
|
|
||||||
assert(output->layer_surface);
|
|
||||||
zwlr_layer_surface_v1_add_listener(output->layer_surface,
|
|
||||||
&layer_surface_listener, output);
|
|
||||||
zwlr_layer_surface_v1_set_anchor(output->layer_surface,
|
|
||||||
bar->config->position);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
output->surface = wl_compositor_create_surface(bar->compositor);
|
||||||
|
assert(output->surface);
|
||||||
|
output->layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
||||||
|
bar->layer_shell, output->surface, output->output,
|
||||||
|
ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM, "panel");
|
||||||
|
assert(output->layer_surface);
|
||||||
|
zwlr_layer_surface_v1_add_listener(output->layer_surface,
|
||||||
|
&layer_surface_listener, output);
|
||||||
|
zwlr_layer_surface_v1_set_anchor(output->layer_surface,
|
||||||
|
bar->config->position);
|
||||||
}
|
}
|
||||||
ipc_get_workspaces(bar);
|
ipc_get_workspaces(bar);
|
||||||
render_all_frames(bar);
|
render_all_frames(bar);
|
||||||
|
|
Loading…
Reference in a new issue