mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	Add wlr_surface_is_*_surface
And wlr_*_surface_from_wlr_surface
This commit is contained in:
		
							parent
							
								
									9ae861c416
								
							
						
					
					
						commit
						333ab59902
					
				
					 9 changed files with 65 additions and 2 deletions
				
			
		| 
						 | 
					@ -99,4 +99,9 @@ void wlr_layer_surface_configure(struct wlr_layer_surface *surface,
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void wlr_layer_surface_close(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
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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,
 | 
							struct wlr_wl_shell_surface *surface, double sx, double sy,
 | 
				
			||||||
		double *popup_sx, double *popup_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
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -229,4 +229,9 @@ struct wlr_xdg_surface *wlr_xdg_surface_popup_at(
 | 
				
			||||||
		struct wlr_xdg_surface *surface, double sx, double sy,
 | 
							struct wlr_xdg_surface *surface, double sx, double sy,
 | 
				
			||||||
		double *popup_sx, double *popup_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
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -289,4 +289,9 @@ void wlr_positioner_v6_invert_x(
 | 
				
			||||||
void wlr_positioner_v6_invert_y(
 | 
					void wlr_positioner_v6_invert_y(
 | 
				
			||||||
		struct wlr_xdg_positioner_v6 *positioner);
 | 
							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
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -271,8 +271,9 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case WLR_BUTTON_PRESSED:
 | 
							case WLR_BUTTON_PRESSED:
 | 
				
			||||||
			roots_seat_set_focus(seat, view);
 | 
								roots_seat_set_focus(seat, view);
 | 
				
			||||||
			if (surface && !view) {
 | 
								if (wlr_surface_is_layer_surface(surface)) {
 | 
				
			||||||
				struct wlr_layer_surface *layer = surface->role_data;
 | 
									struct wlr_layer_surface *layer =
 | 
				
			||||||
 | 
										wlr_layer_surface_from_wlr_surface(surface);
 | 
				
			||||||
				if (layer->current.keyboard_interactive) {
 | 
									if (layer->current.keyboard_interactive) {
 | 
				
			||||||
					roots_seat_set_focus_layer(seat, layer);
 | 
										roots_seat_set_focus_layer(seat, layer);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,6 +34,16 @@ static struct wlr_layer_surface *layer_surface_from_resource(
 | 
				
			||||||
	return wl_resource_get_user_data(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(
 | 
					static void layer_surface_configure_destroy(
 | 
				
			||||||
		struct wlr_layer_surface_configure *configure) {
 | 
							struct wlr_layer_surface_configure *configure) {
 | 
				
			||||||
	if (configure == NULL) {
 | 
						if (configure == NULL) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,6 +12,16 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const char *wlr_wl_shell_surface_role = "wl-shell-surface";
 | 
					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) {
 | 
					static void shell_pointer_grab_end(struct wlr_seat_pointer_grab *grab) {
 | 
				
			||||||
	struct wlr_wl_shell_popup_grab *popup_grab = grab->data;
 | 
						struct wlr_wl_shell_popup_grab *popup_grab = grab->data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,6 +16,17 @@
 | 
				
			||||||
static const char *wlr_desktop_xdg_toplevel_role = "xdg_toplevel";
 | 
					static const char *wlr_desktop_xdg_toplevel_role = "xdg_toplevel";
 | 
				
			||||||
static const char *wlr_desktop_xdg_popup_role = "xdg_popup";
 | 
					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 wlr_xdg_positioner {
 | 
				
			||||||
	struct wl_resource *resource;
 | 
						struct wl_resource *resource;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,6 +16,17 @@
 | 
				
			||||||
static const char *wlr_desktop_xdg_toplevel_role = "xdg_toplevel_v6";
 | 
					static const char *wlr_desktop_xdg_toplevel_role = "xdg_toplevel_v6";
 | 
				
			||||||
static const char *wlr_desktop_xdg_popup_role = "xdg_popup_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 wlr_xdg_positioner_v6_resource {
 | 
				
			||||||
	struct wl_resource *resource;
 | 
						struct wl_resource *resource;
 | 
				
			||||||
	struct wlr_xdg_positioner_v6 attrs;
 | 
						struct wlr_xdg_positioner_v6 attrs;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue