mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	xdg-popup: validate positioner on reposition request
This commit is contained in:
		
							parent
							
								
									e7deea44fd
								
							
						
					
					
						commit
						1e58e4006d
					
				
					 3 changed files with 20 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -446,6 +446,11 @@ void wlr_xdg_popup_destroy(struct wlr_xdg_popup *popup);
 | 
			
		|||
void wlr_xdg_popup_get_position(struct wlr_xdg_popup *popup,
 | 
			
		||||
		double *popup_sx, double *popup_sy);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Returns true if a positioner is complete.
 | 
			
		||||
 */
 | 
			
		||||
bool wlr_xdg_positioner_is_complete(struct wlr_xdg_positioner *positioner);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get the geometry based on positioner rules.
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -317,8 +317,13 @@ static void xdg_popup_handle_reposition(
 | 
			
		|||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	struct wlr_xdg_positioner *positioner =
 | 
			
		||||
		wlr_xdg_positioner_from_resource(positioner_resource);
 | 
			
		||||
	struct wlr_xdg_positioner *positioner = wlr_xdg_positioner_from_resource(positioner_resource);
 | 
			
		||||
	if (!wlr_xdg_positioner_is_complete(positioner)) {
 | 
			
		||||
		wl_resource_post_error(popup->base->client->resource,
 | 
			
		||||
			XDG_WM_BASE_ERROR_INVALID_POSITIONER, "positioner object is not complete");
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	wlr_xdg_positioner_rules_get_geometry(
 | 
			
		||||
		&positioner->rules, &popup->scheduled.geometry);
 | 
			
		||||
	popup->scheduled.rules = positioner->rules;
 | 
			
		||||
| 
						 | 
				
			
			@ -365,14 +370,11 @@ static void xdg_popup_handle_resource_destroy(struct wl_resource *resource) {
 | 
			
		|||
	wlr_xdg_popup_destroy(popup);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void create_xdg_popup(struct wlr_xdg_surface *surface,
 | 
			
		||||
		struct wlr_xdg_surface *parent,
 | 
			
		||||
void create_xdg_popup(struct wlr_xdg_surface *surface, struct wlr_xdg_surface *parent,
 | 
			
		||||
		struct wlr_xdg_positioner *positioner, uint32_t id) {
 | 
			
		||||
	if (positioner->rules.size.width == 0 ||
 | 
			
		||||
			positioner->rules.anchor_rect.width == 0) {
 | 
			
		||||
	if (!wlr_xdg_positioner_is_complete(positioner)) {
 | 
			
		||||
		wl_resource_post_error(surface->client->resource,
 | 
			
		||||
			XDG_WM_BASE_ERROR_INVALID_POSITIONER,
 | 
			
		||||
			"positioner object is not complete");
 | 
			
		||||
			XDG_WM_BASE_ERROR_INVALID_POSITIONER, "positioner object is not complete");
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -203,6 +203,11 @@ static uint32_t xdg_positioner_gravity_to_wlr_edges(
 | 
			
		|||
	return xdg_positioner_anchor_to_wlr_edges((enum xdg_positioner_anchor)gravity);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool wlr_xdg_positioner_is_complete(struct wlr_xdg_positioner *positioner) {
 | 
			
		||||
	struct wlr_xdg_positioner_rules *rules = &positioner->rules;
 | 
			
		||||
	return rules->size.width > 0 && rules->anchor_rect.width > 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wlr_xdg_positioner_rules_get_geometry(
 | 
			
		||||
		const struct wlr_xdg_positioner_rules *rules, struct wlr_box *box) {
 | 
			
		||||
	box->x = rules->offset.x;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue