mirror of
https://github.com/swaywm/sway.git
synced 2026-04-27 06:46:25 -04:00
swaybar: add multiseat support
This just adds multiseat support to swaybar
This commit is contained in:
parent
b6e55064fe
commit
142af76e24
4 changed files with 131 additions and 57 deletions
|
|
@ -215,8 +215,16 @@ static void output_scale(void *data, struct wl_output *wl_output,
|
|||
int32_t factor) {
|
||||
struct swaybar_output *output = data;
|
||||
output->scale = factor;
|
||||
if (output == output->bar->pointer.current) {
|
||||
update_cursor(output->bar);
|
||||
|
||||
bool render = false;
|
||||
struct swaybar_seat *seat;
|
||||
wl_list_for_each(seat, &output->bar->seats, link) {
|
||||
if (output == seat->pointer.current) {
|
||||
update_cursor(seat);
|
||||
render = true;
|
||||
}
|
||||
};
|
||||
if (render) {
|
||||
render_frame(output);
|
||||
}
|
||||
}
|
||||
|
|
@ -317,9 +325,16 @@ static void handle_global(void *data, struct wl_registry *registry,
|
|||
bar->compositor = wl_registry_bind(registry, name,
|
||||
&wl_compositor_interface, 4);
|
||||
} else if (strcmp(interface, wl_seat_interface.name) == 0) {
|
||||
bar->seat = wl_registry_bind(registry, name,
|
||||
&wl_seat_interface, 3);
|
||||
wl_seat_add_listener(bar->seat, &seat_listener, bar);
|
||||
struct swaybar_seat *seat = calloc(1, sizeof(struct swaybar_seat));
|
||||
if (!seat) {
|
||||
sway_abort("Failed to allocate swaybar_seat");
|
||||
return;
|
||||
}
|
||||
seat->bar = bar;
|
||||
seat->wl_name = name;
|
||||
seat->wl_seat = wl_registry_bind(registry, name, &wl_seat_interface, 3);
|
||||
wl_seat_add_listener(seat->wl_seat, &seat_listener, seat);
|
||||
wl_list_insert(&bar->seats, &seat->link);
|
||||
} else if (strcmp(interface, wl_shm_interface.name) == 0) {
|
||||
bar->shm = wl_registry_bind(registry, name,
|
||||
&wl_shm_interface, 1);
|
||||
|
|
@ -354,7 +369,14 @@ static void handle_global_remove(void *data, struct wl_registry *registry,
|
|||
wl_list_for_each_safe(output, tmp, &bar->outputs, link) {
|
||||
if (output->wl_name == name) {
|
||||
swaybar_output_free(output);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
struct swaybar_seat *seat, *tmp_seat;
|
||||
wl_list_for_each_safe(seat, tmp_seat, &bar->seats, link) {
|
||||
if (seat->wl_name == name) {
|
||||
swaybar_seat_free(seat);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -368,6 +390,7 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) {
|
|||
bar->visible = true;
|
||||
bar->config = init_config();
|
||||
wl_list_init(&bar->outputs);
|
||||
wl_list_init(&bar->seats);
|
||||
bar->eventloop = loop_create();
|
||||
|
||||
bar->ipc_socketfd = ipc_open_socket(socket_path);
|
||||
|
|
@ -396,9 +419,16 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) {
|
|||
// Second roundtrip for xdg-output
|
||||
wl_display_roundtrip(bar->display);
|
||||
|
||||
struct swaybar_pointer *pointer = &bar->pointer;
|
||||
pointer->cursor_surface = wl_compositor_create_surface(bar->compositor);
|
||||
assert(pointer->cursor_surface);
|
||||
struct swaybar_seat *seat;
|
||||
wl_list_for_each(seat, &bar->seats, link) {
|
||||
struct swaybar_pointer *pointer = &seat->pointer;
|
||||
if (!pointer) {
|
||||
continue;
|
||||
}
|
||||
pointer->cursor_surface =
|
||||
wl_compositor_create_surface(bar->compositor);
|
||||
assert(pointer->cursor_surface);
|
||||
}
|
||||
|
||||
#if HAVE_TRAY
|
||||
if (!bar->config->tray_hidden) {
|
||||
|
|
@ -467,11 +497,19 @@ static void free_outputs(struct wl_list *list) {
|
|||
}
|
||||
}
|
||||
|
||||
static void free_seats(struct wl_list *list) {
|
||||
struct swaybar_seat *seat, *tmp;
|
||||
wl_list_for_each_safe(seat, tmp, list, link) {
|
||||
swaybar_seat_free(seat);
|
||||
}
|
||||
}
|
||||
|
||||
void bar_teardown(struct swaybar *bar) {
|
||||
#if HAVE_TRAY
|
||||
destroy_tray(bar->tray);
|
||||
#endif
|
||||
free_outputs(&bar->outputs);
|
||||
free_seats(&bar->seats);
|
||||
if (bar->config) {
|
||||
free_config(bar->config);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue