mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	xdg-popups
This commit is contained in:
		
							parent
							
								
									4c8c9b29e4
								
							
						
					
					
						commit
						76ce629198
					
				
					 2 changed files with 45 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -118,6 +118,33 @@ static void render_surface(struct wlr_surface *surface,
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void render_xdg_v6_popups(struct wlr_xdg_surface_v6 *surface,
 | 
			
		||||
		struct wlr_output *wlr_output, struct timespec *when, double base_x,
 | 
			
		||||
		double base_y, float rotation) {
 | 
			
		||||
	double width = surface->surface->current->width;
 | 
			
		||||
	double height = surface->surface->current->height;
 | 
			
		||||
 | 
			
		||||
	struct wlr_xdg_surface_v6 *popup;
 | 
			
		||||
	wl_list_for_each(popup, &surface->popups, popup_link) {
 | 
			
		||||
		if (!popup->configured) {
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		double popup_width = popup->surface->current->width;
 | 
			
		||||
		double popup_height = popup->surface->current->height;
 | 
			
		||||
 | 
			
		||||
		double popup_sx, popup_sy;
 | 
			
		||||
		wlr_xdg_surface_v6_popup_get_position(popup, &popup_sx, &popup_sy);
 | 
			
		||||
		rotate_child_position(&popup_sx, &popup_sy, popup_width, popup_height,
 | 
			
		||||
			width, height, rotation);
 | 
			
		||||
 | 
			
		||||
		render_surface(popup->surface, wlr_output, when,
 | 
			
		||||
			base_x + popup_sx, base_y + popup_sy, rotation);
 | 
			
		||||
		render_xdg_v6_popups(popup, wlr_output, when,
 | 
			
		||||
			base_x + popup_sx, base_y + popup_sy, rotation);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void output_frame_view(swayc_t *view, void *data) {
 | 
			
		||||
	struct sway_output *output = data;
 | 
			
		||||
	struct wlr_output *wlr_output = output->wlr_output;
 | 
			
		||||
| 
						 | 
				
			
			@ -132,6 +159,10 @@ static void output_frame_view(swayc_t *view, void *data) {
 | 
			
		|||
			view->x - window_offset_x,
 | 
			
		||||
			view->y - window_offset_y,
 | 
			
		||||
			0);
 | 
			
		||||
		render_xdg_v6_popups(sway_view->wlr_xdg_surface_v6, wlr_output,
 | 
			
		||||
			&output->last_frame,
 | 
			
		||||
			view->x - window_offset_x, view->y - window_offset_y,
 | 
			
		||||
			0);
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
	case SWAY_WL_SHELL_VIEW:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -259,7 +259,6 @@ swayc_t *swayc_at(swayc_t *parent, double lx, double ly,
 | 
			
		|||
			int width = swayc->sway_view->surface->current->width;
 | 
			
		||||
			int height = swayc->sway_view->surface->current->height;
 | 
			
		||||
 | 
			
		||||
			// TODO popups and subsurfaces
 | 
			
		||||
			switch (sview->type) {
 | 
			
		||||
				case SWAY_WL_SHELL_VIEW:
 | 
			
		||||
					break;
 | 
			
		||||
| 
						 | 
				
			
			@ -268,6 +267,20 @@ swayc_t *swayc_at(swayc_t *parent, double lx, double ly,
 | 
			
		|||
					// coordinate of the top left corner of the window geometry
 | 
			
		||||
					view_sx += sview->wlr_xdg_surface_v6->geometry->x;
 | 
			
		||||
					view_sy += sview->wlr_xdg_surface_v6->geometry->y;
 | 
			
		||||
 | 
			
		||||
					// check for popups
 | 
			
		||||
					double popup_sx, popup_sy;
 | 
			
		||||
					struct wlr_xdg_surface_v6 *popup =
 | 
			
		||||
						wlr_xdg_surface_v6_popup_at(sview->wlr_xdg_surface_v6,
 | 
			
		||||
								view_sx, view_sy, &popup_sx, &popup_sy);
 | 
			
		||||
 | 
			
		||||
					if (popup) {
 | 
			
		||||
						*sx = view_sx - popup_sx;
 | 
			
		||||
						*sy = view_sy - popup_sy;
 | 
			
		||||
						*surface = popup->surface;
 | 
			
		||||
						list_free(queue);
 | 
			
		||||
						return swayc;
 | 
			
		||||
					}
 | 
			
		||||
					break;
 | 
			
		||||
				case SWAY_XWAYLAND_VIEW:
 | 
			
		||||
					break;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue