From 3e6601fa2989d750135d218c1fea3a13ddeae5c3 Mon Sep 17 00:00:00 2001 From: Max Verevkin <34583604+MaxVerevkin@users.noreply.github.com> Date: Fri, 3 Feb 2023 21:48:08 +0200 Subject: [PATCH] ext_workspace_unstable: send output_enter when wl_output is bound late (#1480) --- src/wlrunstable/wlr_ext_workspace_v1.cpp | 19 +++++++++++++++++++ src/wlrunstable/wlr_ext_workspace_v1.hpp | 1 + 2 files changed, 20 insertions(+) diff --git a/src/wlrunstable/wlr_ext_workspace_v1.cpp b/src/wlrunstable/wlr_ext_workspace_v1.cpp index f3020cd6..bd91916f 100644 --- a/src/wlrunstable/wlr_ext_workspace_v1.cpp +++ b/src/wlrunstable/wlr_ext_workspace_v1.cpp @@ -405,6 +405,22 @@ static void group_send_output(struct wlr_ext_workspace_group_handle_v1 *group, } } +static void workspace_handle_output_bind(struct wl_listener *listener, + void *data) { + struct wlr_output_event_bind *evt = (wlr_output_event_bind *)data; + struct wlr_ext_workspace_group_handle_v1_output *output = + wl_container_of(listener, output, output_bind); + struct wl_client *client = wl_resource_get_client(evt->resource); + + struct wl_resource *group_resource, *tmp; + wl_resource_for_each_safe(group_resource, tmp, &output->group_handle->resources) { + if (client == wl_resource_get_client(group_resource)) { + zext_workspace_group_handle_v1_send_output_enter(group_resource, + evt->resource); + } + } +} + static void workspace_handle_output_destroy(struct wl_listener *listener, void *data) { struct wlr_ext_workspace_group_handle_v1_output *output = @@ -432,6 +448,9 @@ void wlr_ext_workspace_group_handle_v1_output_enter( group_output->group_handle = group; wl_list_insert(&group->outputs, &group_output->link); + group_output->output_bind.notify = workspace_handle_output_bind; + wl_signal_add(&output->events.bind, &group_output->output_bind); + group_output->output_destroy.notify = workspace_handle_output_destroy; wl_signal_add(&output->events.destroy, &group_output->output_destroy); diff --git a/src/wlrunstable/wlr_ext_workspace_v1.hpp b/src/wlrunstable/wlr_ext_workspace_v1.hpp index 1dbd03b0..26086fd0 100644 --- a/src/wlrunstable/wlr_ext_workspace_v1.hpp +++ b/src/wlrunstable/wlr_ext_workspace_v1.hpp @@ -52,6 +52,7 @@ struct wlr_ext_workspace_group_handle_v1_create_workspace_event { struct wlr_ext_workspace_group_handle_v1_output { struct wl_list link; // wlr_ext_workspace_group_handle_v1::outputs + struct wl_listener output_bind; struct wl_listener output_destroy; struct wlr_output *output;