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:
John Lindgren 2023-10-16 02:01:35 -04:00 committed by Johan Malm
parent a036d985d7
commit 5cb1d0e83f
6 changed files with 73 additions and 101 deletions

View file

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <assert.h>
#include "common/macros.h"
#include "common/mem.h"
#include "decorations.h"
#include "labwc.h"
@ -39,7 +40,7 @@ xdg_toplevel_from_view(struct view *view)
}
static void
handle_new_xdg_popup(struct wl_listener *listener, void *data)
handle_new_popup(struct wl_listener *listener, void *data)
{
struct xdg_toplevel_view *xdg_toplevel_view =
wl_container_of(listener, xdg_toplevel_view, new_popup);
@ -695,34 +696,21 @@ xdg_surface_new(struct wl_listener *listener, void *data)
/* In support of xdg popups */
xdg_surface->surface->data = tree;
view->map.notify = handle_map;
wl_signal_add(&xdg_surface->events.map, &view->map);
view->unmap.notify = handle_unmap;
wl_signal_add(&xdg_surface->events.unmap, &view->unmap);
view->destroy.notify = handle_destroy;
wl_signal_add(&xdg_surface->events.destroy, &view->destroy);
CONNECT_SIGNAL(xdg_surface, view, map);
CONNECT_SIGNAL(xdg_surface, view, unmap);
CONNECT_SIGNAL(xdg_surface, view, destroy);
struct wlr_xdg_toplevel *toplevel = xdg_surface->toplevel;
view->request_move.notify = handle_request_move;
wl_signal_add(&toplevel->events.request_move, &view->request_move);
view->request_resize.notify = handle_request_resize;
wl_signal_add(&toplevel->events.request_resize, &view->request_resize);
view->request_minimize.notify = handle_request_minimize;
wl_signal_add(&toplevel->events.request_minimize, &view->request_minimize);
view->request_maximize.notify = handle_request_maximize;
wl_signal_add(&toplevel->events.request_maximize, &view->request_maximize);
view->request_fullscreen.notify = handle_request_fullscreen;
wl_signal_add(&toplevel->events.request_fullscreen, &view->request_fullscreen);
view->set_title.notify = handle_set_title;
wl_signal_add(&toplevel->events.set_title, &view->set_title);
CONNECT_SIGNAL(toplevel, view, request_move);
CONNECT_SIGNAL(toplevel, view, request_resize);
CONNECT_SIGNAL(toplevel, view, request_minimize);
CONNECT_SIGNAL(toplevel, view, request_maximize);
CONNECT_SIGNAL(toplevel, view, request_fullscreen);
CONNECT_SIGNAL(toplevel, view, set_title);
/* Events specific to XDG toplevel views */
xdg_toplevel_view->set_app_id.notify = handle_set_app_id;
wl_signal_add(&toplevel->events.set_app_id, &xdg_toplevel_view->set_app_id);
xdg_toplevel_view->new_popup.notify = handle_new_xdg_popup;
wl_signal_add(&xdg_surface->events.new_popup, &xdg_toplevel_view->new_popup);
CONNECT_SIGNAL(toplevel, xdg_toplevel_view, set_app_id);
CONNECT_SIGNAL(xdg_surface, xdg_toplevel_view, new_popup);
wl_list_insert(&server->views, &view->link);
}