mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Don't unfocus when an override redirect window is mapped
This commit is contained in:
		
							parent
							
								
									fb4eca5d56
								
							
						
					
					
						commit
						747725b8bb
					
				
					 3 changed files with 19 additions and 26 deletions
				
			
		| 
						 | 
					@ -83,7 +83,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
 | 
				
			||||||
		struct sway_container *container, bool warp);
 | 
							struct sway_container *container, bool warp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void seat_set_focus_surface(struct sway_seat *seat,
 | 
					void seat_set_focus_surface(struct sway_seat *seat,
 | 
				
			||||||
		struct wlr_surface *surface);
 | 
							struct wlr_surface *surface, bool unfocus);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void seat_set_focus_layer(struct sway_seat *seat,
 | 
					void seat_set_focus_layer(struct sway_seat *seat,
 | 
				
			||||||
		struct wlr_layer_surface *layer);
 | 
							struct wlr_layer_surface *layer);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -69,16 +69,11 @@ static void unmanaged_handle_map(struct wl_listener *listener, void *data) {
 | 
				
			||||||
	surface->ly = xsurface->y;
 | 
						surface->ly = xsurface->y;
 | 
				
			||||||
	desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, true);
 | 
						desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!xsurface->override_redirect) {
 | 
						struct sway_seat *seat = input_manager_current_seat(input_manager);
 | 
				
			||||||
		struct sway_seat *seat = input_manager_current_seat(input_manager);
 | 
						struct wlr_xwayland *xwayland =
 | 
				
			||||||
		struct wlr_xwayland *xwayland =
 | 
							seat->input->server->xwayland.wlr_xwayland;
 | 
				
			||||||
			seat->input->server->xwayland.wlr_xwayland;
 | 
						wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
 | 
				
			||||||
		wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
 | 
						seat_set_focus_surface(seat, xsurface->surface, false);
 | 
				
			||||||
		seat_set_focus_surface(seat, xsurface->surface);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// TODO: we don't send surface enter/leave events to xwayland unmanaged
 | 
					 | 
				
			||||||
	// surfaces, but xwayland doesn't support HiDPI anyway
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
 | 
					static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
 | 
				
			||||||
| 
						 | 
					@ -89,18 +84,16 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
 | 
				
			||||||
	wl_list_remove(&surface->link);
 | 
						wl_list_remove(&surface->link);
 | 
				
			||||||
	wl_list_remove(&surface->commit.link);
 | 
						wl_list_remove(&surface->commit.link);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!xsurface->override_redirect) {
 | 
						struct sway_seat *seat = input_manager_current_seat(input_manager);
 | 
				
			||||||
		struct sway_seat *seat = input_manager_current_seat(input_manager);
 | 
						if (seat->wlr_seat->keyboard_state.focused_surface ==
 | 
				
			||||||
		if (seat->wlr_seat->keyboard_state.focused_surface ==
 | 
								xsurface->surface) {
 | 
				
			||||||
				xsurface->surface) {
 | 
							// Restore focus
 | 
				
			||||||
			// Restore focus
 | 
							struct sway_container *previous =
 | 
				
			||||||
			struct sway_container *previous =
 | 
								seat_get_focus_inactive(seat, &root_container);
 | 
				
			||||||
				seat_get_focus_inactive(seat, &root_container);
 | 
							if (previous) {
 | 
				
			||||||
			if (previous) {
 | 
								// Hack to get seat to re-focus the return value of get_focus
 | 
				
			||||||
				// Hack to get seat to re-focus the return value of get_focus
 | 
								seat_set_focus(seat, previous->parent);
 | 
				
			||||||
				seat_set_focus(seat, previous->parent);
 | 
								seat_set_focus(seat, previous);
 | 
				
			||||||
				seat_set_focus(seat, previous);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -753,11 +753,11 @@ void seat_set_focus(struct sway_seat *seat,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void seat_set_focus_surface(struct sway_seat *seat,
 | 
					void seat_set_focus_surface(struct sway_seat *seat,
 | 
				
			||||||
		struct wlr_surface *surface) {
 | 
							struct wlr_surface *surface, bool unfocus) {
 | 
				
			||||||
	if (seat->focused_layer != NULL) {
 | 
						if (seat->focused_layer != NULL) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (seat->has_focus) {
 | 
						if (seat->has_focus && unfocus) {
 | 
				
			||||||
		struct sway_container *focus = seat_get_focus(seat);
 | 
							struct sway_container *focus = seat_get_focus(seat);
 | 
				
			||||||
		seat_send_unfocus(focus, seat);
 | 
							seat_send_unfocus(focus, seat);
 | 
				
			||||||
		seat->has_focus = false;
 | 
							seat->has_focus = false;
 | 
				
			||||||
| 
						 | 
					@ -789,7 +789,7 @@ void seat_set_focus_layer(struct sway_seat *seat,
 | 
				
			||||||
	} else if (!layer || seat->focused_layer == layer) {
 | 
						} else if (!layer || seat->focused_layer == layer) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	seat_set_focus_surface(seat, layer->surface);
 | 
						seat_set_focus_surface(seat, layer->surface, true);
 | 
				
			||||||
	if (layer->layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) {
 | 
						if (layer->layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) {
 | 
				
			||||||
		seat->focused_layer = layer;
 | 
							seat->focused_layer = layer;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue