mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	HiDPI: send enter and leave events to views when switching monitors
This commit is contained in:
		
							parent
							
								
									1d92404108
								
							
						
					
					
						commit
						6698ca7300
					
				
					 4 changed files with 29 additions and 10 deletions
				
			
		| 
						 | 
					@ -213,6 +213,7 @@ struct view {
 | 
				
			||||||
	enum view_type type;
 | 
						enum view_type type;
 | 
				
			||||||
	const struct view_impl *impl;
 | 
						const struct view_impl *impl;
 | 
				
			||||||
	struct wl_list link;
 | 
						struct wl_list link;
 | 
				
			||||||
 | 
						struct output *output;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	union {
 | 
						union {
 | 
				
			||||||
		struct wlr_xdg_surface *xdg_surface;
 | 
							struct wlr_xdg_surface *xdg_surface;
 | 
				
			||||||
| 
						 | 
					@ -376,8 +377,7 @@ void view_for_each_surface(struct view *view,
 | 
				
			||||||
	wlr_surface_iterator_func_t iterator, void *user_data);
 | 
						wlr_surface_iterator_func_t iterator, void *user_data);
 | 
				
			||||||
void view_for_each_popup_surface(struct view *view,
 | 
					void view_for_each_popup_surface(struct view *view,
 | 
				
			||||||
	wlr_surface_iterator_func_t iterator, void *data);
 | 
						wlr_surface_iterator_func_t iterator, void *data);
 | 
				
			||||||
void view_output_enter(struct view *view, struct wlr_output *wlr_output);
 | 
					void view_discover_output(struct view *view);
 | 
				
			||||||
void view_output_leave(struct view *view, struct wlr_output *wlr_output);
 | 
					 | 
				
			||||||
void view_move_to_edge(struct view *view, const char *direction);
 | 
					void view_move_to_edge(struct view *view, const char *direction);
 | 
				
			||||||
void view_snap_to_edge(struct view *view, const char *direction);
 | 
					void view_snap_to_edge(struct view *view, const char *direction);
 | 
				
			||||||
const char *view_get_string_prop(struct view *view, const char *prop);
 | 
					const char *view_get_string_prop(struct view *view, const char *prop);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										29
									
								
								src/view.c
									
										
									
									
									
								
							
							
						
						
									
										29
									
								
								src/view.c
									
										
									
									
									
								
							| 
						 | 
					@ -23,6 +23,7 @@ view_move_resize(struct view *view, struct wlr_box geo)
 | 
				
			||||||
		view->impl->configure(view, geo);
 | 
							view->impl->configure(view, geo);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	ssd_update_title(view);
 | 
						ssd_update_title(view);
 | 
				
			||||||
 | 
						view_discover_output(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
| 
						 | 
					@ -31,6 +32,7 @@ view_move(struct view *view, double x, double y)
 | 
				
			||||||
	if (view->impl->move) {
 | 
						if (view->impl->move) {
 | 
				
			||||||
		view->impl->move(view, x, y);
 | 
							view->impl->move(view, x, y);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						view_discover_output(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define MIN_VIEW_WIDTH (100)
 | 
					#define MIN_VIEW_WIDTH (100)
 | 
				
			||||||
| 
						 | 
					@ -254,7 +256,7 @@ view_border(struct view *view)
 | 
				
			||||||
	return border;
 | 
						return border;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					static void
 | 
				
			||||||
surface_enter_for_each_surface(struct wlr_surface *surface, int sx, int sy,
 | 
					surface_enter_for_each_surface(struct wlr_surface *surface, int sx, int sy,
 | 
				
			||||||
		void *user_data)
 | 
							void *user_data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -262,7 +264,7 @@ surface_enter_for_each_surface(struct wlr_surface *surface, int sx, int sy,
 | 
				
			||||||
	wlr_surface_send_enter(surface, wlr_output);
 | 
						wlr_surface_send_enter(surface, wlr_output);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					static void
 | 
				
			||||||
surface_leave_for_each_surface(struct wlr_surface *surface, int sx, int sy,
 | 
					surface_leave_for_each_surface(struct wlr_surface *surface, int sx, int sy,
 | 
				
			||||||
		void *user_data)
 | 
							void *user_data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -270,7 +272,7 @@ surface_leave_for_each_surface(struct wlr_surface *surface, int sx, int sy,
 | 
				
			||||||
	wlr_surface_send_leave(surface, wlr_output);
 | 
						wlr_surface_send_leave(surface, wlr_output);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					static void
 | 
				
			||||||
view_output_enter(struct view *view, struct wlr_output *wlr_output)
 | 
					view_output_enter(struct view *view, struct wlr_output *wlr_output)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	view_for_each_surface(view, surface_enter_for_each_surface,
 | 
						view_for_each_surface(view, surface_enter_for_each_surface,
 | 
				
			||||||
| 
						 | 
					@ -281,7 +283,7 @@ view_output_enter(struct view *view, struct wlr_output *wlr_output)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					static void
 | 
				
			||||||
view_output_leave(struct view *view, struct wlr_output *wlr_output)
 | 
					view_output_leave(struct view *view, struct wlr_output *wlr_output)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	view_for_each_surface(view, surface_leave_for_each_surface,
 | 
						view_for_each_surface(view, surface_leave_for_each_surface,
 | 
				
			||||||
| 
						 | 
					@ -292,6 +294,25 @@ view_output_leave(struct view *view, struct wlr_output *wlr_output)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * At present, a view can only 'enter' one output at a time, although the view
 | 
				
			||||||
 | 
					 * may span multiple outputs. Ideally we would handle multiple outputs, but
 | 
				
			||||||
 | 
					 * this method is the simplest form of what we want.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					view_discover_output(struct view *view)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct output *old_output = view->output;
 | 
				
			||||||
 | 
						struct output *new_output = view_output(view);
 | 
				
			||||||
 | 
						if (old_output != new_output) {
 | 
				
			||||||
 | 
							view->output = new_output;
 | 
				
			||||||
 | 
							view_output_enter(view, new_output->wlr_output);
 | 
				
			||||||
 | 
							if (old_output) {
 | 
				
			||||||
 | 
								view_output_leave(view, old_output->wlr_output);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
view_move_to_edge(struct view *view, const char *direction)
 | 
					view_move_to_edge(struct view *view, const char *direction)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -343,8 +343,7 @@ xdg_toplevel_view_map(struct view *view)
 | 
				
			||||||
				 current.link) {
 | 
									 current.link) {
 | 
				
			||||||
			view_subsurface_create(view, subsurface);
 | 
								view_subsurface_create(view, subsurface);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		struct wlr_output *wlr_output = view_wlr_output(view);
 | 
							view_discover_output(view);
 | 
				
			||||||
		view_output_enter(view, wlr_output);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		view->been_mapped = true;
 | 
							view->been_mapped = true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -257,8 +257,7 @@ map(struct view *view)
 | 
				
			||||||
		view->y = box.y;
 | 
							view->y = box.y;
 | 
				
			||||||
		view_center(view);
 | 
							view_center(view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		struct wlr_output *wlr_output = view_wlr_output(view);
 | 
							view_discover_output(view);
 | 
				
			||||||
		view_output_enter(view, wlr_output);
 | 
					 | 
				
			||||||
		view->been_mapped = true;
 | 
							view->been_mapped = true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue