mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	Revert "desktop: allow re-focus between "globally active" views of the same PID"
This is undesired when a focusable popup (e.g. applications menu) of an
unfocusable view (e.g. XWayland panel) is closed.
This reverts commit f6e3527767.
			
			
This commit is contained in:
		
							parent
							
								
									4eb34f97de
								
							
						
					
					
						commit
						11cdad0c11
					
				
					 3 changed files with 5 additions and 30 deletions
				
			
		| 
						 | 
					@ -351,14 +351,6 @@ void view_array_append(struct server *server, struct wl_array *views,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum view_wants_focus view_wants_focus(struct view *view);
 | 
					enum view_wants_focus view_wants_focus(struct view *view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * view_is_focusable_from() - variant of view_is_focusable()
 | 
					 | 
				
			||||||
 * that takes into account the previously focused surface
 | 
					 | 
				
			||||||
 * @view: view to be checked
 | 
					 | 
				
			||||||
 * @prev_surface: previously focused surface
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
bool view_is_focusable_from(struct view *view, struct wlr_surface *prev);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * view_edge_invert() - select the opposite of a provided edge
 | 
					 * view_edge_invert() - select the opposite of a provided edge
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					@ -380,10 +372,7 @@ enum view_edge view_edge_invert(enum view_edge edge);
 | 
				
			||||||
 * The only views that are allowed to be focusd are those that have a surface
 | 
					 * The only views that are allowed to be focusd are those that have a surface
 | 
				
			||||||
 * and have been mapped at some point since creation.
 | 
					 * and have been mapped at some point since creation.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static inline bool
 | 
					bool view_is_focusable(struct view *view);
 | 
				
			||||||
view_is_focusable(struct view *view) {
 | 
					 | 
				
			||||||
	return view_is_focusable_from(view, NULL);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void mappable_connect(struct mappable *mappable, struct wlr_surface *surface,
 | 
					void mappable_connect(struct mappable *mappable, struct wlr_surface *surface,
 | 
				
			||||||
	wl_notify_func_t notify_map, wl_notify_func_t notify_unmap);
 | 
						wl_notify_func_t notify_map, wl_notify_func_t notify_unmap);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -214,8 +214,6 @@ desktop_cycle_view(struct server *server, struct view *start_view,
 | 
				
			||||||
struct view *
 | 
					struct view *
 | 
				
			||||||
desktop_topmost_focusable_view(struct server *server)
 | 
					desktop_topmost_focusable_view(struct server *server)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct wlr_surface *prev =
 | 
					 | 
				
			||||||
		server->seat.seat->keyboard_state.focused_surface;
 | 
					 | 
				
			||||||
	struct view *view;
 | 
						struct view *view;
 | 
				
			||||||
	struct wl_list *node_list;
 | 
						struct wl_list *node_list;
 | 
				
			||||||
	struct wlr_scene_node *node;
 | 
						struct wlr_scene_node *node;
 | 
				
			||||||
| 
						 | 
					@ -226,7 +224,7 @@ desktop_topmost_focusable_view(struct server *server)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		view = node_view_from_node(node);
 | 
							view = node_view_from_node(node);
 | 
				
			||||||
		if (view->mapped && view_is_focusable_from(view, prev)) {
 | 
							if (view->mapped && view_is_focusable(view)) {
 | 
				
			||||||
			return view;
 | 
								return view;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										18
									
								
								src/view.c
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								src/view.c
									
										
									
									
									
								
							| 
						 | 
					@ -163,28 +163,16 @@ view_wants_focus(struct view *view)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool
 | 
					bool
 | 
				
			||||||
view_is_focusable_from(struct view *view, struct wlr_surface *prev)
 | 
					view_is_focusable(struct view *view)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	assert(view);
 | 
						assert(view);
 | 
				
			||||||
	if (!view->surface) {
 | 
						if (!view->surface) {
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (!view->mapped && !view->minimized) {
 | 
						if (view_wants_focus(view) != VIEW_WANTS_FOCUS_ALWAYS) {
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	enum view_wants_focus wants_focus = view_wants_focus(view);
 | 
						return (view->mapped || view->minimized);
 | 
				
			||||||
	/*
 | 
					 | 
				
			||||||
	 * Consider "offer focus" (Globally Active) views as focusable
 | 
					 | 
				
			||||||
	 * only if another surface from the same application already had
 | 
					 | 
				
			||||||
	 * focus. The goal is to allow focusing a parent window when a
 | 
					 | 
				
			||||||
	 * dialog/popup is closed, but still avoid focusing standalone
 | 
					 | 
				
			||||||
	 * panels/toolbars/notifications. Note that we are basically
 | 
					 | 
				
			||||||
	 * guessing whether Globally Active views want focus, and will
 | 
					 | 
				
			||||||
	 * probably be wrong some of the time.
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	return (wants_focus == VIEW_WANTS_FOCUS_ALWAYS
 | 
					 | 
				
			||||||
		|| (wants_focus == VIEW_WANTS_FOCUS_OFFER
 | 
					 | 
				
			||||||
			&& prev && view_is_related(view, prev)));
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue