mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Fix logic used for mouse_warping output
Turns out we don't need to store the previous focus, and it should be based on which output the cursor was in.
This commit is contained in:
		
							parent
							
								
									96e3686ae8
								
							
						
					
					
						commit
						4d743b64d0
					
				
					 2 changed files with 9 additions and 6 deletions
				
			
		| 
						 | 
					@ -52,7 +52,6 @@ struct sway_seat {
 | 
				
			||||||
	bool has_focus;
 | 
						bool has_focus;
 | 
				
			||||||
	struct wl_list focus_stack; // list of containers in focus order
 | 
						struct wl_list focus_stack; // list of containers in focus order
 | 
				
			||||||
	struct sway_workspace *workspace;
 | 
						struct sway_workspace *workspace;
 | 
				
			||||||
	struct sway_node *prev_focus;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// If the focused layer is set, views cannot receive keyboard focus
 | 
						// If the focused layer is set, views cannot receive keyboard focus
 | 
				
			||||||
	struct wlr_layer_surface_v1 *focused_layer;
 | 
						struct wlr_layer_surface_v1 *focused_layer;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -646,7 +646,6 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct sway_node *last_focus = seat_get_focus(seat);
 | 
						struct sway_node *last_focus = seat_get_focus(seat);
 | 
				
			||||||
	seat->prev_focus = last_focus;
 | 
					 | 
				
			||||||
	if (last_focus == node) {
 | 
						if (last_focus == node) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -1190,13 +1189,18 @@ void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void seat_consider_warp_to_focus(struct sway_seat *seat) {
 | 
					void seat_consider_warp_to_focus(struct sway_seat *seat) {
 | 
				
			||||||
	struct sway_node *focus = seat_get_focus(seat);
 | 
						struct sway_node *focus = seat_get_focus(seat);
 | 
				
			||||||
	if (config->mouse_warping == WARP_NO || !focus || !seat->prev_focus) {
 | 
						if (config->mouse_warping == WARP_NO || !focus) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (config->mouse_warping == WARP_OUTPUT &&
 | 
						if (config->mouse_warping == WARP_OUTPUT) {
 | 
				
			||||||
			node_get_output(focus) == node_get_output(seat->prev_focus)) {
 | 
							struct sway_output *output = node_get_output(focus);
 | 
				
			||||||
 | 
							struct wlr_box box;
 | 
				
			||||||
 | 
							output_get_box(output, &box);
 | 
				
			||||||
 | 
							if (wlr_box_contains_point(&box,
 | 
				
			||||||
 | 
										seat->cursor->cursor->x, seat->cursor->cursor->y)) {
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (focus->type == N_CONTAINER) {
 | 
						if (focus->type == N_CONTAINER) {
 | 
				
			||||||
		cursor_warp_to_container(seat->cursor, focus->sway_container);
 | 
							cursor_warp_to_container(seat->cursor, focus->sway_container);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue