mirror of
https://github.com/swaywm/sway.git
synced 2024-11-23 08:21:28 +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,7 +291,8 @@ 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;
|
||||||
|
if (bar_uses_output(bar, output_index)) {
|
||||||
struct swaybar_output *output =
|
struct swaybar_output *output =
|
||||||
calloc(1, sizeof(struct swaybar_output));
|
calloc(1, sizeof(struct swaybar_output));
|
||||||
output->bar = bar;
|
output->bar = bar;
|
||||||
|
@ -286,11 +300,13 @@ static void handle_global(void *data, struct wl_registry *registry,
|
||||||
&wl_output_interface, 3);
|
&wl_output_interface, 3);
|
||||||
wl_output_add_listener(output->output, &output_listener, output);
|
wl_output_add_listener(output->output, &output_listener, output);
|
||||||
output->scale = 1;
|
output->scale = 1;
|
||||||
output->index = index++;
|
output->index = output_index;
|
||||||
output->wl_name = name;
|
output->wl_name = name;
|
||||||
wl_list_init(&output->workspaces);
|
wl_list_init(&output->workspaces);
|
||||||
wl_list_init(&output->hotspots);
|
wl_list_init(&output->hotspots);
|
||||||
wl_list_insert(&bar->outputs, &output->link);
|
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,14 +378,14 @@ 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);
|
output->name = strdup(coutput->name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
output->surface = wl_compositor_create_surface(bar->compositor);
|
output->surface = wl_compositor_create_surface(bar->compositor);
|
||||||
assert(output->surface);
|
assert(output->surface);
|
||||||
output->layer_surface = zwlr_layer_shell_v1_get_layer_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);
|
&layer_surface_listener, output);
|
||||||
zwlr_layer_surface_v1_set_anchor(output->layer_surface,
|
zwlr_layer_surface_v1_set_anchor(output->layer_surface,
|
||||||
bar->config->position);
|
bar->config->position);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ipc_get_workspaces(bar);
|
ipc_get_workspaces(bar);
|
||||||
render_all_frames(bar);
|
render_all_frames(bar);
|
||||||
|
|
Loading…
Reference in a new issue