aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <mail@isaacfreund.com>2022-01-17 19:11:08 +0100
committerIsaac Freund <mail@isaacfreund.com>2022-01-17 19:11:08 +0100
commit1bd0ea3a809bdba092ef051120bb6d32f79c0ffb (patch)
treec2201a3fe45ca1e5ab55db595050f155b65d0352
parent5091118bed82394de5a151d658e895bb44059b61 (diff)
foreign-toplevel: send enter if needed on output bind
Currently the output enter event is never sent if the client has not yet bound the output, which happens every time the compositor creates a new output. To fix this, listen for the output bind event and inform clients as if needed.
-rw-r--r--include/wlr/types/wlr_foreign_toplevel_management_v1.h7
-rw-r--r--types/wlr_foreign_toplevel_management_v1.c21
2 files changed, 26 insertions, 2 deletions
diff --git a/include/wlr/types/wlr_foreign_toplevel_management_v1.h b/include/wlr/types/wlr_foreign_toplevel_management_v1.h
index 6ea9d47f..d9030b2e 100644
--- a/include/wlr/types/wlr_foreign_toplevel_management_v1.h
+++ b/include/wlr/types/wlr_foreign_toplevel_management_v1.h
@@ -36,10 +36,13 @@ enum wlr_foreign_toplevel_handle_v1_state {
struct wlr_foreign_toplevel_handle_v1_output {
struct wl_list link; // wlr_foreign_toplevel_handle_v1::outputs
- struct wl_listener output_destroy;
struct wlr_output *output;
-
struct wlr_foreign_toplevel_handle_v1 *toplevel;
+
+ // private state
+
+ struct wl_listener output_bind;
+ struct wl_listener output_destroy;
};
struct wlr_foreign_toplevel_handle_v1 {
diff --git a/types/wlr_foreign_toplevel_management_v1.c b/types/wlr_foreign_toplevel_management_v1.c
index 9bf811a4..a700a115 100644
--- a/types/wlr_foreign_toplevel_management_v1.c
+++ b/types/wlr_foreign_toplevel_management_v1.c
@@ -257,6 +257,23 @@ static void toplevel_send_output(struct wlr_foreign_toplevel_handle_v1 *toplevel
toplevel_update_idle_source(toplevel);
}
+static void toplevel_handle_output_bind(struct wl_listener *listener,
+ void *data) {
+ struct wlr_foreign_toplevel_handle_v1_output *toplevel_output =
+ wl_container_of(listener, toplevel_output, output_bind);
+ struct wlr_output_event_bind *event = data;
+ struct wl_client *client = wl_resource_get_client(event->resource);
+
+ struct wl_resource *resource;
+ wl_resource_for_each(resource, &toplevel_output->toplevel->resources) {
+ if (wl_resource_get_client(resource) == client) {
+ send_output_to_resource(resource, toplevel_output->output, true);
+ }
+ }
+
+ toplevel_update_idle_source(toplevel_output->toplevel);
+}
+
static void toplevel_handle_output_destroy(struct wl_listener *listener,
void *data) {
struct wlr_foreign_toplevel_handle_v1_output *toplevel_output =
@@ -286,6 +303,9 @@ void wlr_foreign_toplevel_handle_v1_output_enter(
toplevel_output->toplevel = toplevel;
wl_list_insert(&toplevel->outputs, &toplevel_output->link);
+ toplevel_output->output_bind.notify = toplevel_handle_output_bind;
+ wl_signal_add(&output->events.bind, &toplevel_output->output_bind);
+
toplevel_output->output_destroy.notify = toplevel_handle_output_destroy;
wl_signal_add(&output->events.destroy, &toplevel_output->output_destroy);
@@ -295,6 +315,7 @@ void wlr_foreign_toplevel_handle_v1_output_enter(
static void toplevel_output_destroy(
struct wlr_foreign_toplevel_handle_v1_output *toplevel_output) {
wl_list_remove(&toplevel_output->link);
+ wl_list_remove(&toplevel_output->output_bind.link);
wl_list_remove(&toplevel_output->output_destroy.link);
free(toplevel_output);
}