mirror of
https://github.com/labwc/labwc.git
synced 2025-11-05 13:29:58 -05:00
common: add and use CONNECT_SIGNAL macro
This makes the code a bit more readable IMHO (and forces us to be consistent with event handler function names). Adjust scripts/checkpatch.pl to not complain.
This commit is contained in:
parent
a036d985d7
commit
5cb1d0e83f
6 changed files with 73 additions and 101 deletions
|
|
@ -16,4 +16,20 @@
|
|||
*/
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
|
||||
/**
|
||||
* CONNECT_SIGNAL() - Connect a signal handler function to a wl_signal.
|
||||
*
|
||||
* @param src Signal emitter (struct containing wl_signal)
|
||||
* @param dest Signal receiver (struct containing wl_listener)
|
||||
* @param name Signal name
|
||||
*
|
||||
* This assumes that the common pattern is followed where:
|
||||
* - the wl_signal is (*src).events.<name>
|
||||
* - the wl_listener is (*dest).<name>
|
||||
* - the signal handler function is named handle_<name>
|
||||
*/
|
||||
#define CONNECT_SIGNAL(src, dest, name) \
|
||||
(dest)->name.notify = handle_##name; \
|
||||
wl_signal_add(&(src)->events.name, &(dest)->name)
|
||||
|
||||
#endif /* LABWC_MACROS_H */
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ struct xwayland_unmanaged {
|
|||
struct wl_listener map;
|
||||
struct wl_listener unmap;
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener override_redirect;
|
||||
struct wl_listener set_override_redirect;
|
||||
};
|
||||
|
||||
struct xwayland_view {
|
||||
|
|
@ -30,9 +30,9 @@ struct xwayland_view {
|
|||
/* Events unique to XWayland views */
|
||||
struct wl_listener request_activate;
|
||||
struct wl_listener request_configure;
|
||||
struct wl_listener set_app_id; /* TODO: s/set_app_id/class/ */
|
||||
struct wl_listener set_class;
|
||||
struct wl_listener set_decorations;
|
||||
struct wl_listener override_redirect;
|
||||
struct wl_listener set_override_redirect;
|
||||
|
||||
/* Not (yet) implemented */
|
||||
/* struct wl_listener set_role; */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue