aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/wlr/types/wlr_layer_shell.h5
-rw-r--r--include/wlr/types/wlr_wl_shell.h5
-rw-r--r--include/wlr/types/wlr_xdg_shell.h5
-rw-r--r--include/wlr/types/wlr_xdg_shell_v6.h5
-rw-r--r--rootston/cursor.c5
-rw-r--r--types/wlr_layer_shell.c10
-rw-r--r--types/wlr_wl_shell.c10
-rw-r--r--types/wlr_xdg_shell.c11
-rw-r--r--types/wlr_xdg_shell_v6.c11
9 files changed, 65 insertions, 2 deletions
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
diff --git a/rootston/cursor.c b/rootston/cursor.c
index 6252b6e1..6fb2688c 100644
--- a/rootston/cursor.c
+++ b/rootston/cursor.c
@@ -271,8 +271,9 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
break;
case WLR_BUTTON_PRESSED:
roots_seat_set_focus(seat, view);
- if (surface && !view) {
- struct wlr_layer_surface *layer = surface->role_data;
+ if (wlr_surface_is_layer_surface(surface)) {
+ struct wlr_layer_surface *layer =
+ wlr_layer_surface_from_wlr_surface(surface);
if (layer->current.keyboard_interactive) {
roots_seat_set_focus_layer(seat, layer);
}
diff --git a/types/wlr_layer_shell.c b/types/wlr_layer_shell.c
index b81fb4c6..c4e39a17 100644
--- a/types/wlr_layer_shell.c
+++ b/types/wlr_layer_shell.c
@@ -34,6 +34,16 @@ static struct wlr_layer_surface *layer_surface_from_resource(
return wl_resource_get_user_data(resource);
}
+bool wlr_surface_is_layer_surface(struct wlr_surface *surface) {
+ return strcmp(surface->role, zwlr_layer_surface_role) == 0;
+}
+
+struct wlr_layer_surface *wlr_layer_surface_from_wlr_surface(
+ struct wlr_surface *surface) {
+ assert(wlr_surface_is_layer_surface(surface));
+ return (struct wlr_layer_surface *)surface->role_data;
+}
+
static void layer_surface_configure_destroy(
struct wlr_layer_surface_configure *configure) {
if (configure == NULL) {
diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c
index cac64c44..a2123bce 100644
--- a/types/wlr_wl_shell.c
+++ b/types/wlr_wl_shell.c
@@ -12,6 +12,16 @@
static const char *wlr_wl_shell_surface_role = "wl-shell-surface";
+bool wlr_surface_is_wl_shell_surface(struct wlr_surface *surface) {
+ return strcmp(surface->role, wlr_wl_shell_surface_role) == 0;
+}
+
+struct wlr_wl_surface *wlr_wl_shell_surface_from_wlr_surface(
+ struct wlr_surface *surface) {
+ assert(wlr_surface_is_wl_shell_surface(surface));
+ return (struct wlr_wl_surface *)surface->role_data;
+}
+
static void shell_pointer_grab_end(struct wlr_seat_pointer_grab *grab) {
struct wlr_wl_shell_popup_grab *popup_grab = grab->data;
diff --git a/types/wlr_xdg_shell.c b/types/wlr_xdg_shell.c
index d3be2c4f..d70021fd 100644
--- a/types/wlr_xdg_shell.c
+++ b/types/wlr_xdg_shell.c
@@ -16,6 +16,17 @@
static const char *wlr_desktop_xdg_toplevel_role = "xdg_toplevel";
static const char *wlr_desktop_xdg_popup_role = "xdg_popup";
+bool wlr_surface_is_xdg_surface(struct wlr_surface *surface) {
+ return strcmp(surface->role, wlr_desktop_xdg_toplevel_role) == 0 ||
+ strcmp(surface->role, wlr_desktop_xdg_popup_role) == 0;
+}
+
+struct wlr_xdg_surface *wlr_xdg_surface_from_wlr_surface(
+ struct wlr_surface *surface) {
+ assert(wlr_surface_is_xdg_surface(surface));
+ return (struct wlr_xdg_surface *)surface->role_data;
+}
+
struct wlr_xdg_positioner {
struct wl_resource *resource;
diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c
index 64d44f22..5c83db70 100644
--- a/types/wlr_xdg_shell_v6.c
+++ b/types/wlr_xdg_shell_v6.c
@@ -16,6 +16,17 @@
static const char *wlr_desktop_xdg_toplevel_role = "xdg_toplevel_v6";
static const char *wlr_desktop_xdg_popup_role = "xdg_popup_v6";
+bool wlr_surface_is_xdg_surface_v6(struct wlr_surface *surface) {
+ return strcmp(surface->role, wlr_desktop_xdg_toplevel_role) == 0 ||
+ strcmp(surface->role, wlr_desktop_xdg_popup_role) == 0;
+}
+
+struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6_from_wlr_surface(
+ struct wlr_surface *surface) {
+ assert(wlr_surface_is_xdg_surface_v6(surface));
+ return (struct wlr_xdg_surface_v6 *)surface->role_data;
+}
+
struct wlr_xdg_positioner_v6_resource {
struct wl_resource *resource;
struct wlr_xdg_positioner_v6 attrs;