Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1200 from alexbakker/destroy-signal
Browse files Browse the repository at this point in the history
Add destroy signals to types that are destroyed by wl_display_destroy
  • Loading branch information
ddevault authored Aug 27, 2018
2 parents c6955fa + 20db297 commit 792f98c
Show file tree
Hide file tree
Showing 35 changed files with 68 additions and 5 deletions.
1 change: 1 addition & 0 deletions backend/session/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ void wlr_session_destroy(struct wlr_session *session) {
return;
}

wlr_signal_emit_safe(&session->events.destroy, session);
wl_list_remove(&session->display_destroy.link);

wl_event_source_remove(session->udev_event);
Expand Down
4 changes: 4 additions & 0 deletions include/wlr/backend/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ struct wlr_session {
struct wl_list devices;

struct wl_listener display_destroy;

struct {
struct wl_signal destroy;
} events;
};

/*
Expand Down
4 changes: 4 additions & 0 deletions include/wlr/types/wlr_gamma_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ struct wlr_gamma_control_manager {

struct wl_listener display_destroy;

struct {
struct wl_signal destroy;
} events;

void *data;
};

Expand Down
4 changes: 4 additions & 0 deletions include/wlr/types/wlr_gamma_control_v1.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ struct wlr_gamma_control_manager_v1 {

struct wl_listener display_destroy;

struct {
struct wl_signal destroy;
} events;

void *data;
};

Expand Down
1 change: 1 addition & 0 deletions include/wlr/types/wlr_idle.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct wlr_idle {
struct wl_listener display_destroy;
struct {
struct wl_signal activity_notify;
struct wl_signal destroy;
} events;

void *data;
Expand Down
1 change: 1 addition & 0 deletions include/wlr/types/wlr_idle_inhibit_v1.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct wlr_idle_inhibit_manager_v1 {

struct {
struct wl_signal new_inhibitor;
struct wl_signal destroy;
} events;

void *data;
Expand Down
1 change: 1 addition & 0 deletions include/wlr/types/wlr_input_inhibitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct wlr_input_inhibit_manager {
struct {
struct wl_signal activate; // struct wlr_input_inhibit_manager *
struct wl_signal deactivate; // struct wlr_input_inhibit_manager *
struct wl_signal destroy;
} events;

void *data;
Expand Down
1 change: 1 addition & 0 deletions include/wlr/types/wlr_layer_shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct wlr_layer_shell {
// Note: the output may be NULL. In this case, it is your
// responsibility to assign an output before returning.
struct wl_signal new_surface;
struct wl_signal destroy;
} events;

void *data;
Expand Down
4 changes: 4 additions & 0 deletions include/wlr/types/wlr_primary_selection.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ struct wlr_primary_selection_device_manager {

struct wl_listener display_destroy;

struct {
struct wl_signal destroy;
} events;

void *data;
};

Expand Down
4 changes: 4 additions & 0 deletions include/wlr/types/wlr_screencopy_v1.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ struct wlr_screencopy_manager_v1 {

struct wl_listener display_destroy;

struct {
struct wl_signal destroy;
} events;

void *data;
};

Expand Down
4 changes: 4 additions & 0 deletions include/wlr/types/wlr_screenshooter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ struct wlr_screenshooter {

struct wl_listener display_destroy;

struct {
struct wl_signal destroy;
} events;

void *data;
};

Expand Down
1 change: 1 addition & 0 deletions include/wlr/types/wlr_server_decoration.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct wlr_server_decoration_manager {

struct {
struct wl_signal new_decoration;
struct wl_signal destroy;
} events;

void *data;
Expand Down
4 changes: 4 additions & 0 deletions include/wlr/types/wlr_tablet_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ struct wlr_tablet_manager_v2 {

struct wl_listener display_destroy;

struct {
struct wl_signal destroy;
} events;

void *data;
};

Expand Down
1 change: 1 addition & 0 deletions include/wlr/types/wlr_virtual_keyboard_v1.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct wlr_virtual_keyboard_manager_v1 {

struct {
struct wl_signal new_virtual_keyboard; // struct wlr_virtual_keyboard_v1*
struct wl_signal destroy;
} events;
};

Expand Down
1 change: 1 addition & 0 deletions include/wlr/types/wlr_wl_shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct wlr_wl_shell {

struct {
struct wl_signal new_surface;
struct wl_signal destroy;
} events;

void *data;
Expand Down
1 change: 1 addition & 0 deletions include/wlr/types/wlr_xdg_decoration_v1.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct wlr_xdg_decoration_manager_v1 {

struct {
struct wl_signal new_toplevel_decoration; // struct wlr_xdg_toplevel_decoration *
struct wl_signal destroy;
} events;

void *data;
Expand Down
4 changes: 4 additions & 0 deletions include/wlr/types/wlr_xdg_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ struct wlr_xdg_output_manager {
struct wl_listener layout_add;
struct wl_listener layout_change;
struct wl_listener layout_destroy;

struct {
struct wl_signal destroy;
} events;
};

struct wlr_xdg_output_manager *wlr_xdg_output_manager_create(
Expand Down
1 change: 1 addition & 0 deletions include/wlr/types/wlr_xdg_shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct wlr_xdg_shell {
* surface will be ready to be managed on the `map` event.
*/
struct wl_signal new_surface;
struct wl_signal destroy;
} events;

void *data;
Expand Down
1 change: 1 addition & 0 deletions include/wlr/types/wlr_xdg_shell_v6.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct wlr_xdg_shell_v6 {
* surface will be ready to be managed on the `map` event.
*/
struct wl_signal new_surface;
struct wl_signal destroy;
} events;

void *data;
Expand Down
2 changes: 2 additions & 0 deletions types/tablet_v2/wlr_tablet_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <wlr/types/wlr_tablet_v2.h>
#include <wlr/util/log.h>
#include "tablet-unstable-v2-protocol.h"
#include "util/signal.h"

#define TABLET_MANAGER_VERSION 1

Expand Down Expand Up @@ -281,6 +282,7 @@ void wlr_tablet_v2_destroy(struct wlr_tablet_manager_v2 *manager) {
wlr_tablet_manager_v2_destroy(pos->resource);
}

wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_global_destroy(manager->wl_global);
free(manager);
}
Expand Down
3 changes: 2 additions & 1 deletion types/wlr_gamma_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,12 @@ void wlr_gamma_control_manager_destroy(
if (!manager) {
return;
}
wl_list_remove(&manager->display_destroy.link);
struct wlr_gamma_control *gamma_control, *tmp;
wl_list_for_each_safe(gamma_control, tmp, &manager->controls, link) {
gamma_control_destroy(gamma_control);
}
wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_list_remove(&manager->display_destroy.link);
wl_global_destroy(manager->global);
free(manager);
}
Expand Down
3 changes: 2 additions & 1 deletion types/wlr_gamma_control_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,12 @@ void wlr_gamma_control_manager_v1_destroy(
if (!manager) {
return;
}
wl_list_remove(&manager->display_destroy.link);
struct wlr_gamma_control_v1 *gamma_control, *tmp;
wl_list_for_each_safe(gamma_control, tmp, &manager->controls, link) {
wl_resource_destroy(gamma_control->resource);
}
wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_list_remove(&manager->display_destroy.link);
struct wl_resource *resource, *resource_tmp;
wl_resource_for_each_safe(resource, resource_tmp, &manager->resources) {
wl_resource_destroy(resource);
Expand Down
1 change: 1 addition & 0 deletions types/wlr_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ void wlr_idle_destroy(struct wlr_idle *idle) {
if (!idle) {
return;
}
wlr_signal_emit_safe(&idle->events.destroy, idle);
wl_list_remove(&idle->display_destroy.link);
struct wlr_idle_timeout *timer, *tmp;
wl_list_for_each_safe(timer, tmp, &idle->idle_timers, link) {
Expand Down
5 changes: 3 additions & 2 deletions types/wlr_idle_inhibit_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,15 @@ void wlr_idle_inhibit_v1_destroy(struct wlr_idle_inhibit_manager_v1 *idle_inhibi
return;
}

wl_list_remove(&idle_inhibit->display_destroy.link);

struct wlr_idle_inhibitor_v1 *inhibitor;
struct wlr_idle_inhibitor_v1 *tmp;
wl_list_for_each_safe(inhibitor, tmp, &idle_inhibit->inhibitors, link) {
idle_inhibitor_v1_destroy(inhibitor);
}

wlr_signal_emit_safe(&idle_inhibit->events.destroy, idle_inhibit);
wl_list_remove(&idle_inhibit->display_destroy.link);

struct wl_resource *resource;
struct wl_resource *tmp_resource;
wl_resource_for_each_safe(resource, tmp_resource, &idle_inhibit->resources) {
Expand Down
1 change: 1 addition & 0 deletions types/wlr_input_inhibitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ void wlr_input_inhibit_manager_destroy(
input_inhibitor_destroy(manager->active_client,
manager->active_inhibitor);
}
wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_list_remove(&manager->display_destroy.link);
wl_global_destroy(manager->global);
free(manager);
Expand Down
1 change: 1 addition & 0 deletions types/wlr_layer_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ void wlr_layer_shell_destroy(struct wlr_layer_shell *layer_shell) {
wl_resource_for_each_safe(client, tmp, &layer_shell->client_resources) {
wl_resource_destroy(client);
}
wlr_signal_emit_safe(&layer_shell->events.destroy, layer_shell);
wl_list_remove(&layer_shell->display_destroy.link);
wl_global_destroy(layer_shell->global);
free(layer_shell);
Expand Down
1 change: 1 addition & 0 deletions types/wlr_primary_selection.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ void wlr_primary_selection_device_manager_destroy(
if (manager == NULL) {
return;
}
wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_list_remove(&manager->display_destroy.link);
// TODO: free resources
wl_global_destroy(manager->global);
Expand Down
2 changes: 2 additions & 0 deletions types/wlr_screencopy_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <wlr/types/wlr_screencopy_v1.h>
#include <wlr/backend.h>
#include "wlr-screencopy-unstable-v1-protocol.h"
#include "util/signal.h"

#define SCREENCOPY_MANAGER_VERSION 1

Expand Down Expand Up @@ -306,6 +307,7 @@ void wlr_screencopy_manager_v1_destroy(
if (manager == NULL) {
return;
}
wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_list_remove(&manager->display_destroy.link);
struct wlr_screencopy_frame_v1 *frame, *tmp_frame;
wl_list_for_each_safe(frame, tmp_frame, &manager->frames, link) {
Expand Down
2 changes: 2 additions & 0 deletions types/wlr_screenshooter.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <wlr/types/wlr_screenshooter.h>
#include <wlr/util/log.h>
#include "screenshooter-protocol.h"
#include "util/signal.h"

static struct wlr_screenshot *screenshot_from_resource(
struct wl_resource *resource) {
Expand Down Expand Up @@ -177,6 +178,7 @@ void wlr_screenshooter_destroy(struct wlr_screenshooter *screenshooter) {
wl_list_for_each_safe(screenshot, tmp, &screenshooter->screenshots, link) {
screenshot_destroy(screenshot);
}
wlr_signal_emit_safe(&screenshooter->events.destroy, screenshooter);
wl_global_destroy(screenshooter->global);
free(screenshooter);
}
Expand Down
3 changes: 2 additions & 1 deletion types/wlr_server_decoration.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ void wlr_server_decoration_manager_destroy(
if (manager == NULL) {
return;
}
wl_list_remove(&manager->display_destroy.link);
struct wlr_server_decoration *decoration, *tmp_decoration;
wl_list_for_each_safe(decoration, tmp_decoration, &manager->decorations,
link) {
server_decoration_destroy(decoration);
}
wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_list_remove(&manager->display_destroy.link);
struct wl_resource *resource, *tmp_resource;
wl_resource_for_each_safe(resource, tmp_resource, &manager->resources) {
server_decoration_manager_destroy_resource(resource);
Expand Down
1 change: 1 addition & 0 deletions types/wlr_virtual_keyboard_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ struct wlr_virtual_keyboard_manager_v1*

void wlr_virtual_keyboard_manager_v1_destroy(
struct wlr_virtual_keyboard_manager_v1 *manager) {
wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_list_remove(&manager->display_destroy.link);
wl_global_destroy(manager->global);
struct wl_resource *resource, *resource_tmp;
Expand Down
1 change: 1 addition & 0 deletions types/wlr_xdg_decoration_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ void wlr_xdg_decoration_manager_v1_destroy(
if (manager == NULL) {
return;
}
wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_list_remove(&manager->display_destroy.link);
struct wlr_xdg_toplevel_decoration_v1 *decoration, *tmp_decoration;
wl_list_for_each_safe(decoration, tmp_decoration, &manager->decorations,
Expand Down
2 changes: 2 additions & 0 deletions types/wlr_xdg_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <wlr/types/wlr_xdg_output.h>
#include <wlr/util/log.h>
#include "xdg-output-unstable-v1-protocol.h"
#include "util/signal.h"

#define OUTPUT_MANAGER_VERSION 2

Expand Down Expand Up @@ -245,6 +246,7 @@ void wlr_xdg_output_manager_destroy(struct wlr_xdg_output_manager *manager) {
wl_resource_for_each_safe(resource, resource_tmp, &manager->resources) {
wl_resource_destroy(resource);
}
wlr_signal_emit_safe(&manager->events.destroy, manager);
wl_list_remove(&manager->layout_add.link);
wl_list_remove(&manager->layout_change.link);
wl_list_remove(&manager->layout_destroy.link);
Expand Down
1 change: 1 addition & 0 deletions types/xdg_shell/wlr_xdg_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ void wlr_xdg_shell_destroy(struct wlr_xdg_shell *xdg_shell) {
if (!xdg_shell) {
return;
}
wlr_signal_emit_safe(&xdg_shell->events.destroy, xdg_shell);
wl_list_remove(&xdg_shell->display_destroy.link);
wl_global_destroy(xdg_shell->global);
free(xdg_shell);
Expand Down
1 change: 1 addition & 0 deletions types/xdg_shell_v6/wlr_xdg_shell_v6.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ void wlr_xdg_shell_v6_destroy(struct wlr_xdg_shell_v6 *xdg_shell) {
if (!xdg_shell) {
return;
}
wlr_signal_emit_safe(&xdg_shell->events.destroy, xdg_shell);
wl_list_remove(&xdg_shell->display_destroy.link);
wl_global_destroy(xdg_shell->global);
free(xdg_shell);
Expand Down

0 comments on commit 792f98c

Please sign in to comment.