From a76829f3756d3df22fe46e6688374497de29c2e1 Mon Sep 17 00:00:00 2001
From: Drew DeVault <sir@cmpwn.com>
Date: Thu, 29 Mar 2018 12:19:20 -0400
Subject: Some layer shell fixes

Based on the corresponding rootston changes
---
 include/sway/layers.h      |  2 --
 include/sway/output.h      |  1 +
 sway/desktop/layer_shell.c | 22 ----------------------
 sway/desktop/output.c      |  8 ++++++++
 4 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/include/sway/layers.h b/include/sway/layers.h
index 22054be1..ee47c5ad 100644
--- a/include/sway/layers.h
+++ b/include/sway/layers.h
@@ -14,8 +14,6 @@ struct sway_layer_surface {
 	struct wl_listener unmap;
 	struct wl_listener surface_commit;
 	struct wl_listener output_destroy;
-	struct wl_listener output_mode;
-	struct wl_listener output_transform;
 
 	bool configured;
 	struct wlr_box geo;
diff --git a/include/sway/output.h b/include/sway/output.h
index f899230f..6fb79987 100644
--- a/include/sway/output.h
+++ b/include/sway/output.h
@@ -21,6 +21,7 @@ struct sway_output {
 	struct wl_listener frame;
 	struct wl_listener destroy;
 	struct wl_listener mode;
+	struct wl_listener transform;
 
 	pid_t bg_pid;
 };
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c
index bd62f84a..31679fb2 100644
--- a/sway/desktop/layer_shell.c
+++ b/sway/desktop/layer_shell.c
@@ -193,22 +193,10 @@ static void handle_output_destroy(struct wl_listener *listener, void *data) {
 	struct sway_layer_surface *sway_layer =
 		wl_container_of(listener, sway_layer, output_destroy);
 	wl_list_remove(&sway_layer->output_destroy.link);
-	wl_list_remove(&sway_layer->output_mode.link);
-	wl_list_remove(&sway_layer->output_transform.link);
 	sway_layer->layer_surface->output = NULL;
 	wlr_layer_surface_close(sway_layer->layer_surface);
 }
 
-static void handle_output_mode(struct wl_listener *listener, void *data) {
-	struct wlr_output *output = data;
-	arrange_layers((struct sway_output *)output->data);
-}
-
-static void handle_output_transform(struct wl_listener *listener, void *data) {
-	struct wlr_output *output = data;
-	arrange_layers((struct sway_output *)output->data);
-}
-
 static void handle_surface_commit(struct wl_listener *listener, void *data) {
 	struct sway_layer_surface *layer =
 		wl_container_of(listener, layer, surface_commit);
@@ -243,8 +231,6 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
 	wl_list_remove(&sway_layer->surface_commit.link);
 	if (sway_layer->layer_surface->output != NULL) {
 		wl_list_remove(&sway_layer->output_destroy.link);
-		wl_list_remove(&sway_layer->output_mode.link);
-		wl_list_remove(&sway_layer->output_transform.link);
 	}
 	struct sway_output *output = sway_layer->layer_surface->output->data;
 	arrange_layers(output);
@@ -289,14 +275,6 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
 	wl_signal_add(&layer_surface->output->events.destroy,
 		&sway_layer->output_destroy);
 
-	sway_layer->output_mode.notify = handle_output_mode;
-	wl_signal_add(&layer_surface->output->events.mode,
-		&sway_layer->output_mode);
-
-	sway_layer->output_transform.notify = handle_output_transform;
-	wl_signal_add(&layer_surface->output->events.transform,
-		&sway_layer->output_transform);
-
 	sway_layer->destroy.notify = handle_destroy;
 	wl_signal_add(&layer_surface->events.destroy, &sway_layer->destroy);
 	sway_layer->map.notify = handle_map;
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index b8253ace..30b23a18 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -268,6 +268,12 @@ static void handle_output_mode(struct wl_listener *listener, void *data) {
 	arrange_windows(output->swayc, -1, -1);
 }
 
+static void handle_output_transform(struct wl_listener *listener, void *data) {
+	struct sway_output *output = wl_container_of(listener, output, transform);
+	arrange_layers(output);
+	arrange_windows(output->swayc, -1, -1);
+}
+
 void handle_new_output(struct wl_listener *listener, void *data) {
 	struct sway_server *server = wl_container_of(listener, server, new_output);
 	struct wlr_output *wlr_output = data;
@@ -306,6 +312,8 @@ void handle_new_output(struct wl_listener *listener, void *data) {
 	output->destroy.notify = handle_output_destroy;
 	wl_signal_add(&wlr_output->events.mode, &output->mode);
 	output->mode.notify = handle_output_mode;
+	wl_signal_add(&wlr_output->events.transform, &output->transform);
+	output->transform.notify = handle_output_transform;
 
 	arrange_layers(output);
 	arrange_windows(&root_container, -1, -1);
-- 
cgit v1.2.3