mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	view.c: rename+simplify focus_view()
This commit is contained in:
		
							parent
							
								
									778e4e890b
								
							
						
					
					
						commit
						759fbe683b
					
				
					 5 changed files with 10 additions and 11 deletions
				
			
		
							
								
								
									
										2
									
								
								labwc.h
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								labwc.h
									
										
									
									
									
								
							| 
						 | 
					@ -140,7 +140,7 @@ void xwl_surface_new(struct wl_listener *listener, void *data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool view_want_deco(struct view *view);
 | 
					bool view_want_deco(struct view *view);
 | 
				
			||||||
void view_focus_last_toplevel(struct server *server);
 | 
					void view_focus_last_toplevel(struct server *server);
 | 
				
			||||||
void focus_view(struct view *view, struct wlr_surface *surface);
 | 
					void view_focus(struct view *view);
 | 
				
			||||||
void view_focus_next_toplevel(struct view *current);
 | 
					void view_focus_next_toplevel(struct view *current);
 | 
				
			||||||
void begin_interactive(struct view *view, enum cursor_mode mode,
 | 
					void begin_interactive(struct view *view, enum cursor_mode mode,
 | 
				
			||||||
		       uint32_t edges);
 | 
							       uint32_t edges);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										2
									
								
								server.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								server.c
									
										
									
									
									
								
							| 
						 | 
					@ -362,7 +362,7 @@ void server_cursor_button(struct wl_listener *listener, void *data)
 | 
				
			||||||
		server->cursor_mode = TINYWL_CURSOR_PASSTHROUGH;
 | 
							server->cursor_mode = TINYWL_CURSOR_PASSTHROUGH;
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		/* Focus that client if the button was _pressed_ */
 | 
							/* Focus that client if the button was _pressed_ */
 | 
				
			||||||
		focus_view(view, surface);
 | 
							view_focus(view);
 | 
				
			||||||
		switch (view_area) {
 | 
							switch (view_area) {
 | 
				
			||||||
		case LAB_DECO_PART_TOP:
 | 
							case LAB_DECO_PART_TOP:
 | 
				
			||||||
			begin_interactive(view, TINYWL_CURSOR_MOVE, 0);
 | 
								begin_interactive(view, TINYWL_CURSOR_MOVE, 0);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										13
									
								
								view.c
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								view.c
									
										
									
									
									
								
							| 
						 | 
					@ -47,7 +47,7 @@ void view_focus_last_toplevel(struct server *server)
 | 
				
			||||||
	if (wl_list_length(&server->views) < 2)
 | 
						if (wl_list_length(&server->views) < 2)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	struct view *view = last_toplevel(server);
 | 
						struct view *view = last_toplevel(server);
 | 
				
			||||||
	focus_view(view, view->surface);
 | 
						view_focus(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct view *next_toplevel(struct view *current)
 | 
					static struct view *next_toplevel(struct view *current)
 | 
				
			||||||
| 
						 | 
					@ -65,7 +65,7 @@ void view_focus_next_toplevel(struct view *current)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct view *view;
 | 
						struct view *view;
 | 
				
			||||||
	view = next_toplevel(current);
 | 
						view = next_toplevel(current);
 | 
				
			||||||
	focus_view(view, view->surface);
 | 
						view_focus(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void move_to_front(struct view *view)
 | 
					static void move_to_front(struct view *view)
 | 
				
			||||||
| 
						 | 
					@ -105,18 +105,17 @@ static void set_activated(struct wlr_surface *s, bool activated)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* FIXME: why have we got both view and surface here???? */
 | 
					void view_focus(struct view *view)
 | 
				
			||||||
void focus_view(struct view *view, struct wlr_surface *surface)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/* Note: this function only deals with keyboard focus. */
 | 
						/* Note: this function only deals with keyboard focus. */
 | 
				
			||||||
	if (!view)
 | 
						if (!view || !view->surface)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	struct server *server = view->server;
 | 
						struct server *server = view->server;
 | 
				
			||||||
	struct wlr_seat *seat = server->seat;
 | 
						struct wlr_seat *seat = server->seat;
 | 
				
			||||||
	struct wlr_surface *prev_surface;
 | 
						struct wlr_surface *prev_surface;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prev_surface = seat->keyboard_state.focused_surface;
 | 
						prev_surface = seat->keyboard_state.focused_surface;
 | 
				
			||||||
	if (prev_surface == surface) {
 | 
						if (prev_surface == view->surface) {
 | 
				
			||||||
		/* Don't re-focus an already focused surface. */
 | 
							/* Don't re-focus an already focused surface. */
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -202,7 +201,7 @@ void begin_interactive(struct view *view, enum cursor_mode mode, uint32_t edges)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static bool _view_at(struct view *view, double lx, double ly,
 | 
					static bool _view_at(struct view *view, double lx, double ly,
 | 
				
			||||||
		    struct wlr_surface **surface, double *sx, double *sy)
 | 
							     struct wlr_surface **surface, double *sx, double *sy)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * XDG toplevels may have nested surfaces, such as popup windows for
 | 
						 * XDG toplevels may have nested surfaces, such as popup windows for
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										2
									
								
								xdg.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								xdg.c
									
										
									
									
									
								
							| 
						 | 
					@ -54,7 +54,7 @@ void xdg_surface_map(struct wl_listener *listener, void *data)
 | 
				
			||||||
	view->mapped = true;
 | 
						view->mapped = true;
 | 
				
			||||||
	view->been_mapped = true;
 | 
						view->been_mapped = true;
 | 
				
			||||||
	view->surface = view->xdg_surface->surface;
 | 
						view->surface = view->xdg_surface->surface;
 | 
				
			||||||
	focus_view(view, view->xdg_surface->surface);
 | 
						view_focus(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void xdg_surface_unmap(struct wl_listener *listener, void *data)
 | 
					void xdg_surface_unmap(struct wl_listener *listener, void *data)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										2
									
								
								xwl.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								xwl.c
									
										
									
									
									
								
							| 
						 | 
					@ -42,7 +42,7 @@ void xwl_surface_map(struct wl_listener *listener, void *data)
 | 
				
			||||||
	if (!view->been_mapped)
 | 
						if (!view->been_mapped)
 | 
				
			||||||
		position(view);
 | 
							position(view);
 | 
				
			||||||
	view->been_mapped = true;
 | 
						view->been_mapped = true;
 | 
				
			||||||
	focus_view(view, view->xwayland_surface->surface);
 | 
						view_focus(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void xwl_surface_unmap(struct wl_listener *listener, void *data)
 | 
					void xwl_surface_unmap(struct wl_listener *listener, void *data)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue