aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-08-30 13:28:50 -0400
committerTony Crisci <tony@dubstepdish.com>2017-08-31 07:47:44 -0400
commitd84deb07420aefb7e16bae846c57f7b4c021e803 (patch)
treebefd3916e304970e972135fce83335c1cb0e1f1c
parentfa3d4ecc849f4228dac56e34872fa97b02aab273 (diff)
add wlr_output destroy event
-rw-r--r--include/wlr/types/wlr_output.h1
-rw-r--r--types/wlr_output.c3
-rw-r--r--types/wlr_output_layout.c17
3 files changed, 21 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index 11160d33..3371dcb5 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -37,6 +37,7 @@ struct wlr_output {
struct {
struct wl_signal frame;
struct wl_signal resolution;
+ struct wl_signal destroy;
} events;
struct {
diff --git a/types/wlr_output.c b/types/wlr_output.c
index 0a38d591..ee050dc4 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -100,6 +100,7 @@ void wlr_output_init(struct wlr_output *output,
output->scale = 1;
wl_signal_init(&output->events.frame);
wl_signal_init(&output->events.resolution);
+ wl_signal_init(&output->events.destroy);
}
void wlr_output_enable(struct wlr_output *output, bool enable) {
@@ -176,6 +177,8 @@ void wlr_output_destroy(struct wlr_output *output) {
return;
}
+ wl_signal_emit(&output->events.destroy, output);
+
wlr_texture_destroy(output->cursor.texture);
wlr_renderer_destroy(output->cursor.renderer);
diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c
index 503b9ec7..b189bd46 100644
--- a/types/wlr_output_layout.c
+++ b/types/wlr_output_layout.c
@@ -13,9 +13,13 @@ struct wlr_output_layout_state {
struct wlr_output_layout_output_state {
struct wlr_output_layout *layout;
+ struct wlr_output_layout_output *l_output;
+
struct wlr_box *_box;
bool auto_configured;
+
struct wl_listener resolution;
+ struct wl_listener output_destroy;
};
struct wlr_output_layout *wlr_output_layout_init() {
@@ -30,6 +34,7 @@ struct wlr_output_layout *wlr_output_layout_init() {
static void wlr_output_layout_output_destroy(
struct wlr_output_layout_output *l_output) {
wl_list_remove(&l_output->state->resolution.link);
+ wl_list_remove(&l_output->state->output_destroy.link);
wl_list_remove(&l_output->link);
free(l_output->state->_box);
free(l_output->state);
@@ -111,11 +116,20 @@ static void handle_output_resolution(struct wl_listener *listener, void *data) {
wlr_output_layout_reconfigure(state->layout);
}
+static void handle_output_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_output_layout_output_state *state =
+ wl_container_of(listener, state, output_destroy);
+ struct wlr_output_layout *layout = state->layout;
+ wlr_output_layout_output_destroy(state->l_output);
+ wlr_output_layout_reconfigure(layout);
+}
+
static struct wlr_output_layout_output *wlr_output_layout_output_create(
struct wlr_output_layout *layout, struct wlr_output *output) {
struct wlr_output_layout_output *l_output;
l_output= calloc(1, sizeof(struct wlr_output_layout_output));
l_output->state = calloc(1, sizeof(struct wlr_output_layout_output_state));
+ l_output->state->l_output = l_output;
l_output->state->_box = calloc(1, sizeof(struct wlr_box));
l_output->state->layout = layout;
l_output->output = output;
@@ -124,6 +138,9 @@ static struct wlr_output_layout_output *wlr_output_layout_output_create(
wl_signal_add(&output->events.resolution, &l_output->state->resolution);
l_output->state->resolution.notify = handle_output_resolution;
+ wl_signal_add(&output->events.destroy, &l_output->state->output_destroy);
+ l_output->state->output_destroy.notify = handle_output_destroy;
+
return l_output;
}