mirror of
https://github.com/labwc/labwc.git
synced 2026-04-13 08:21:15 -04:00
[wip] only provide 2 functions: listeners_{init, remove}
This commit is contained in:
parent
7a2ea5b54c
commit
c15ab4e88f
4 changed files with 62 additions and 60 deletions
|
|
@ -38,10 +38,8 @@ struct view_impl {
|
||||||
void (*maximize)(struct view *view, bool maximize);
|
void (*maximize)(struct view *view, bool maximize);
|
||||||
void (*move_to_front)(struct view *view);
|
void (*move_to_front)(struct view *view);
|
||||||
void (*move_to_back)(struct view *view);
|
void (*move_to_back)(struct view *view);
|
||||||
void (*setup_common_listeners)(struct view *view);
|
void (*listeners_init)(struct view *view);
|
||||||
void (*setup_specific_listeners)(struct view *view);
|
void (*listeners_remove)(struct view *view);
|
||||||
void (*remove_common_listeners)(struct view *view);
|
|
||||||
void (*remove_specific_listeners)(struct view *view);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct view {
|
struct view {
|
||||||
|
|
|
||||||
|
|
@ -119,8 +119,7 @@ view_init(struct view *view)
|
||||||
node_descriptor_create(&view->scene_tree->node,
|
node_descriptor_create(&view->scene_tree->node,
|
||||||
LAB_NODE_DESC_VIEW, view);
|
LAB_NODE_DESC_VIEW, view);
|
||||||
|
|
||||||
view->impl->setup_common_listeners(view);
|
view->impl->listeners_init(view);
|
||||||
view->impl->setup_specific_listeners(view);
|
|
||||||
|
|
||||||
wl_list_insert(&view->server->views, &view->link);
|
wl_list_insert(&view->server->views, &view->link);
|
||||||
}
|
}
|
||||||
|
|
@ -132,8 +131,7 @@ view_destroy(struct view *view)
|
||||||
struct server *server = view->server;
|
struct server *server = view->server;
|
||||||
bool need_cursor_update = false;
|
bool need_cursor_update = false;
|
||||||
|
|
||||||
view->impl->remove_common_listeners(view);
|
view->impl->listeners_remove(view);
|
||||||
view->impl->remove_specific_listeners(view);
|
|
||||||
|
|
||||||
if (view->toplevel.handle) {
|
if (view->toplevel.handle) {
|
||||||
wlr_foreign_toplevel_handle_v1_destroy(view->toplevel.handle);
|
wlr_foreign_toplevel_handle_v1_destroy(view->toplevel.handle);
|
||||||
|
|
|
||||||
43
src/xdg.c
43
src/xdg.c
|
|
@ -481,7 +481,22 @@ xdg_activation_handle_request(struct wl_listener *listener, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xdg_setup_common_listeners(struct view *view)
|
xdg_listeners_init_specific(struct view *view)
|
||||||
|
{
|
||||||
|
struct xdg_toplevel_view *xdg_view = xdg_toplevel_view_from_view(view);
|
||||||
|
struct wlr_xdg_surface *xdg_surface = xdg_view->xdg_surface;
|
||||||
|
struct wlr_xdg_toplevel *toplevel = xdg_surface->toplevel;
|
||||||
|
|
||||||
|
/* Events specific to XDG toplevel views */
|
||||||
|
xdg_view->set_app_id.notify = handle_set_app_id;
|
||||||
|
wl_signal_add(&toplevel->events.set_app_id, &xdg_view->set_app_id);
|
||||||
|
|
||||||
|
xdg_view->new_popup.notify = handle_new_xdg_popup;
|
||||||
|
wl_signal_add(&xdg_surface->events.new_popup, &xdg_view->new_popup);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xdg_listeners_init(struct view *view)
|
||||||
{
|
{
|
||||||
struct wlr_xdg_surface *xdg_surface = xdg_surface_from_view(view);
|
struct wlr_xdg_surface *xdg_surface = xdg_surface_from_view(view);
|
||||||
struct wlr_xdg_toplevel *toplevel = xdg_surface->toplevel;
|
struct wlr_xdg_toplevel *toplevel = xdg_surface->toplevel;
|
||||||
|
|
@ -513,29 +528,19 @@ xdg_setup_common_listeners(struct view *view)
|
||||||
|
|
||||||
view->set_title.notify = handle_set_title;
|
view->set_title.notify = handle_set_title;
|
||||||
wl_signal_add(&toplevel->events.set_title, &view->set_title);
|
wl_signal_add(&toplevel->events.set_title, &view->set_title);
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
xdg_setup_specific_listeners(struct view *view)
|
|
||||||
{
|
|
||||||
struct xdg_toplevel_view *xdg_view = xdg_toplevel_view_from_view(view);
|
|
||||||
struct wlr_xdg_surface *xdg_surface = xdg_view->xdg_surface;
|
|
||||||
struct wlr_xdg_toplevel *toplevel = xdg_surface->toplevel;
|
|
||||||
|
|
||||||
/* Events specific to XDG toplevel views */
|
/* Events specific to XDG toplevel views */
|
||||||
xdg_view->set_app_id.notify = handle_set_app_id;
|
xdg_listeners_init_specific(view);
|
||||||
wl_signal_add(&toplevel->events.set_app_id, &xdg_view->set_app_id);
|
|
||||||
|
|
||||||
xdg_view->new_popup.notify = handle_new_xdg_popup;
|
|
||||||
wl_signal_add(&xdg_surface->events.new_popup, &xdg_view->new_popup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xdg_remove_specific_listeners(struct view *view)
|
xdg_listeners_remove(struct view *view)
|
||||||
{
|
{
|
||||||
struct xdg_toplevel_view *xdg_view = xdg_toplevel_view_from_view(view);
|
/* Remove common listeners */
|
||||||
|
view_impl_remove_common_listeners(view);
|
||||||
|
|
||||||
/* Remove xdg-shell view specific listeners */
|
/* Remove xdg-shell view specific listeners */
|
||||||
|
struct xdg_toplevel_view *xdg_view = xdg_toplevel_view_from_view(view);
|
||||||
wl_list_remove(&xdg_view->set_app_id.link);
|
wl_list_remove(&xdg_view->set_app_id.link);
|
||||||
wl_list_remove(&xdg_view->new_popup.link);
|
wl_list_remove(&xdg_view->new_popup.link);
|
||||||
}
|
}
|
||||||
|
|
@ -551,10 +556,8 @@ static const struct view_impl xdg_toplevel_view_impl = {
|
||||||
.maximize = xdg_toplevel_view_maximize,
|
.maximize = xdg_toplevel_view_maximize,
|
||||||
.move_to_front = view_impl_move_to_front,
|
.move_to_front = view_impl_move_to_front,
|
||||||
.move_to_back = view_impl_move_to_back,
|
.move_to_back = view_impl_move_to_back,
|
||||||
.setup_common_listeners = xdg_setup_common_listeners,
|
.listeners_init = xdg_listeners_init,
|
||||||
.setup_specific_listeners = xdg_setup_specific_listeners,
|
.listeners_remove = xdg_listeners_remove,
|
||||||
.remove_common_listeners = view_impl_remove_common_listeners,
|
|
||||||
.remove_specific_listeners = xdg_remove_specific_listeners,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -575,7 +575,34 @@ xwayland_view_set_fullscreen(struct view *view, bool fullscreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xwayland_setup_common_listeners(struct view *view)
|
xwayland_listeners_init_specific(struct view *view)
|
||||||
|
{
|
||||||
|
struct xwayland_view *xwayland_view = xwayland_view_from_view(view);
|
||||||
|
struct wlr_xwayland_surface *xsurface = xwayland_view->xwayland_surface;
|
||||||
|
|
||||||
|
/* Events specific to XWayland views */
|
||||||
|
xwayland_view->request_activate.notify = handle_request_activate;
|
||||||
|
wl_signal_add(&xsurface->events.request_activate,
|
||||||
|
&xwayland_view->request_activate);
|
||||||
|
|
||||||
|
xwayland_view->request_configure.notify = handle_request_configure;
|
||||||
|
wl_signal_add(&xsurface->events.request_configure,
|
||||||
|
&xwayland_view->request_configure);
|
||||||
|
|
||||||
|
xwayland_view->set_app_id.notify = handle_set_class;
|
||||||
|
wl_signal_add(&xsurface->events.set_class, &xwayland_view->set_app_id);
|
||||||
|
|
||||||
|
xwayland_view->set_decorations.notify = handle_set_decorations;
|
||||||
|
wl_signal_add(&xsurface->events.set_decorations,
|
||||||
|
&xwayland_view->set_decorations);
|
||||||
|
|
||||||
|
xwayland_view->override_redirect.notify = handle_override_redirect;
|
||||||
|
wl_signal_add(&xsurface->events.set_override_redirect,
|
||||||
|
&xwayland_view->override_redirect);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xwayland_listeners_init(struct view *view)
|
||||||
{
|
{
|
||||||
struct wlr_xwayland_surface *xsurface = xwayland_surface_from_view(view);
|
struct wlr_xwayland_surface *xsurface = xwayland_surface_from_view(view);
|
||||||
|
|
||||||
|
|
@ -606,41 +633,19 @@ xwayland_setup_common_listeners(struct view *view)
|
||||||
|
|
||||||
view->set_title.notify = handle_set_title;
|
view->set_title.notify = handle_set_title;
|
||||||
wl_signal_add(&xsurface->events.set_title, &view->set_title);
|
wl_signal_add(&xsurface->events.set_title, &view->set_title);
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
xwayland_setup_specific_listeners(struct view *view)
|
|
||||||
{
|
|
||||||
struct xwayland_view *xwayland_view = xwayland_view_from_view(view);
|
|
||||||
struct wlr_xwayland_surface *xsurface = xwayland_view->xwayland_surface;
|
|
||||||
|
|
||||||
/* Events specific to XWayland views */
|
/* Events specific to XWayland views */
|
||||||
xwayland_view->request_activate.notify = handle_request_activate;
|
xwayland_listeners_init_specific(view);
|
||||||
wl_signal_add(&xsurface->events.request_activate,
|
|
||||||
&xwayland_view->request_activate);
|
|
||||||
|
|
||||||
xwayland_view->request_configure.notify = handle_request_configure;
|
|
||||||
wl_signal_add(&xsurface->events.request_configure,
|
|
||||||
&xwayland_view->request_configure);
|
|
||||||
|
|
||||||
xwayland_view->set_app_id.notify = handle_set_class;
|
|
||||||
wl_signal_add(&xsurface->events.set_class, &xwayland_view->set_app_id);
|
|
||||||
|
|
||||||
xwayland_view->set_decorations.notify = handle_set_decorations;
|
|
||||||
wl_signal_add(&xsurface->events.set_decorations,
|
|
||||||
&xwayland_view->set_decorations);
|
|
||||||
|
|
||||||
xwayland_view->override_redirect.notify = handle_override_redirect;
|
|
||||||
wl_signal_add(&xsurface->events.set_override_redirect,
|
|
||||||
&xwayland_view->override_redirect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xwayland_remove_specific_listeners(struct view *view)
|
xwayland_listeners_remove(struct view *view)
|
||||||
{
|
{
|
||||||
struct xwayland_view *xwayland_view = xwayland_view_from_view(view);
|
/* Remove common listeners */
|
||||||
|
view_impl_remove_common_listeners(view);
|
||||||
|
|
||||||
/* Remove XWayland view specific listeners */
|
/* Remove XWayland view specific listeners */
|
||||||
|
struct xwayland_view *xwayland_view = xwayland_view_from_view(view);
|
||||||
wl_list_remove(&xwayland_view->request_activate.link);
|
wl_list_remove(&xwayland_view->request_activate.link);
|
||||||
wl_list_remove(&xwayland_view->request_configure.link);
|
wl_list_remove(&xwayland_view->request_configure.link);
|
||||||
wl_list_remove(&xwayland_view->set_app_id.link);
|
wl_list_remove(&xwayland_view->set_app_id.link);
|
||||||
|
|
@ -659,10 +664,8 @@ static const struct view_impl xwayland_view_impl = {
|
||||||
.maximize = xwayland_view_maximize,
|
.maximize = xwayland_view_maximize,
|
||||||
.move_to_front = xwayland_view_move_to_front,
|
.move_to_front = xwayland_view_move_to_front,
|
||||||
.move_to_back = xwayland_view_move_to_back,
|
.move_to_back = xwayland_view_move_to_back,
|
||||||
.setup_common_listeners = xwayland_setup_common_listeners,
|
.listeners_init = xwayland_listeners_init,
|
||||||
.setup_specific_listeners = xwayland_setup_specific_listeners,
|
.listeners_remove = xwayland_listeners_remove,
|
||||||
.remove_common_listeners = view_impl_remove_common_listeners,
|
|
||||||
.remove_specific_listeners = xwayland_remove_specific_listeners,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct xwayland_view *
|
struct xwayland_view *
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue