From 333ab599022a645f92facf41cde03ab03866b08f Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 2 Apr 2018 20:39:33 -0400 Subject: Add wlr_surface_is_*_surface And wlr_*_surface_from_wlr_surface --- include/wlr/types/wlr_layer_shell.h | 5 +++++ include/wlr/types/wlr_wl_shell.h | 5 +++++ include/wlr/types/wlr_xdg_shell.h | 5 +++++ include/wlr/types/wlr_xdg_shell_v6.h | 5 +++++ 4 files changed, 20 insertions(+) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_layer_shell.h b/include/wlr/types/wlr_layer_shell.h index 8d093ada..1312e568 100644 --- a/include/wlr/types/wlr_layer_shell.h +++ b/include/wlr/types/wlr_layer_shell.h @@ -99,4 +99,9 @@ void wlr_layer_surface_configure(struct wlr_layer_surface *surface, */ void wlr_layer_surface_close(struct wlr_layer_surface *surface); +bool wlr_surface_is_layer_surface(struct wlr_surface *surface); + +struct wlr_layer_surface *wlr_layer_surface_from_wlr_surface( + struct wlr_surface *surface); + #endif diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h index 00f2bb69..63b1a837 100644 --- a/include/wlr/types/wlr_wl_shell.h +++ b/include/wlr/types/wlr_wl_shell.h @@ -150,4 +150,9 @@ struct wlr_wl_shell_surface *wlr_wl_shell_surface_popup_at( struct wlr_wl_shell_surface *surface, double sx, double sy, double *popup_sx, double *popup_sy); +bool wlr_surface_is_wl_shell_surface(struct wlr_surface *surface); + +struct wlr_wl_surface *wlr_wl_shell_surface_from_wlr_surface( + struct wlr_surface *surface); + #endif diff --git a/include/wlr/types/wlr_xdg_shell.h b/include/wlr/types/wlr_xdg_shell.h index 9938f4b1..b779017f 100644 --- a/include/wlr/types/wlr_xdg_shell.h +++ b/include/wlr/types/wlr_xdg_shell.h @@ -229,4 +229,9 @@ struct wlr_xdg_surface *wlr_xdg_surface_popup_at( struct wlr_xdg_surface *surface, double sx, double sy, double *popup_sx, double *popup_sy); +bool wlr_surface_is_xdg_surface(struct wlr_surface *surface); + +struct wlr_xdg_surface *wlr_xdg_surface_from_wlr_surface( + struct wlr_surface *surface); + #endif diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index d01240eb..04c1f324 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -289,4 +289,9 @@ void wlr_positioner_v6_invert_x( void wlr_positioner_v6_invert_y( struct wlr_xdg_positioner_v6 *positioner); +bool wlr_surface_is_xdg_surface_v6(struct wlr_surface *surface); + +struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6_from_wlr_surface( + struct wlr_surface *surface); + #endif -- cgit v1.2.3 From 506acbdecd4436117729e4c40678645725ed2d1f Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 2 Apr 2018 20:57:09 -0400 Subject: Missed a spot --- include/wlr/xwayland.h | 5 +++++ xwayland/xwm.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+) (limited to 'include/wlr') diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h index 9b9d9cf9..66622de3 100644 --- a/include/wlr/xwayland.h +++ b/include/wlr/xwayland.h @@ -185,4 +185,9 @@ void wlr_xwayland_set_seat(struct wlr_xwayland *xwayland, bool wlr_xwayland_surface_is_unmanaged( const struct wlr_xwayland_surface *surface); +bool wlr_surface_is_xwayland_surface(struct wlr_surface *surface); + +struct wlr_xwayland_surface *wlr_xwayland_surface_from_wlr_surface( + struct wlr_surface *surface); + #endif diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 6702c3c9..4fa7d311 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -1,6 +1,7 @@ #ifndef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200809L #endif +#include #include #include #include @@ -58,6 +59,18 @@ const char *atom_map[ATOM_LAST] = { "_NET_WM_WINDOW_TYPE_COMBO", }; +const char *wlr_xwayland_surface_role = "wlr_xwayland_surface"; + +bool wlr_surface_is_xwayland_surface(struct wlr_surface *surface) { + return strcmp(surface->role, wlr_xwayland_surface_role) == 0; +} + +struct wlr_xwayland_surface *wlr_xwayland_surface_from_wlr_surface( + struct wlr_surface *surface) { + assert(wlr_surface_is_xwayland_surface(surface)); + return (struct wlr_xwayland_surface *)surface->role_data; +} + /* General helpers */ // TODO: replace this with hash table? static struct wlr_xwayland_surface *lookup_surface(struct wlr_xwm *xwm, @@ -574,6 +587,7 @@ static void xwm_map_shell_surface(struct wlr_xwm *xwm, read_surface_property(xwm, xsurface, props[i]); } + wlr_surface_set_role(xsurface->surface, wlr_xwayland_surface_role, NULL, 0); wlr_surface_set_role_committed(xsurface->surface, handle_surface_commit, xsurface); -- cgit v1.2.3