mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 07:51:28 +00:00
Fix swaybar output config.
This commit is contained in:
parent
48fca1c7ec
commit
c38de16722
|
@ -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,19 +291,22 @@ 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;
|
||||
struct swaybar_output *output =
|
||||
calloc(1, sizeof(struct swaybar_output));
|
||||
output->bar = bar;
|
||||
output->output = wl_registry_bind(registry, name,
|
||||
&wl_output_interface, 3);
|
||||
wl_output_add_listener(output->output, &output_listener, output);
|
||||
output->scale = 1;
|
||||
output->index = index++;
|
||||
output->wl_name = name;
|
||||
wl_list_init(&output->workspaces);
|
||||
wl_list_init(&output->hotspots);
|
||||
wl_list_insert(&bar->outputs, &output->link);
|
||||
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;
|
||||
output->output = wl_registry_bind(registry, name,
|
||||
&wl_output_interface, 3);
|
||||
wl_output_add_listener(output->output, &output_listener, output);
|
||||
output->scale = 1;
|
||||
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,26 +378,24 @@ 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->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);
|
||||
render_all_frames(bar);
|
||||
|
|
Loading…
Reference in a new issue