mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	cursor.c: Keep sending adjusted motion events while button is pressed
This allows to keep dragging a scrollbar or selecting text even when moving outside of the window. Fixes #241
This commit is contained in:
		
							parent
							
								
									067b0e8798
								
							
						
					
					
						commit
						befe66d93f
					
				
					 4 changed files with 34 additions and 0 deletions
				
			
		
							
								
								
									
										16
									
								
								src/cursor.c
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								src/cursor.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -195,6 +195,15 @@ process_cursor_motion(struct server *server, uint32_t time)
 | 
			
		|||
	} else if (server->input_mode == LAB_INPUT_STATE_RESIZE) {
 | 
			
		||||
		process_cursor_resize(server, time);
 | 
			
		||||
		return;
 | 
			
		||||
	} else if (server->seat.active_view && !server->seat.drag_icon) {
 | 
			
		||||
		/* Button has been pressed while over a view surface */
 | 
			
		||||
		struct view *view = server->seat.active_view;
 | 
			
		||||
		double sx = server->seat.cursor->x - view->x;
 | 
			
		||||
		double sy = server->seat.cursor->y - view->y;
 | 
			
		||||
		sx = sx < 0 ? 0 : (sx > view->w ? view->w : sx);
 | 
			
		||||
		sy = sy < 0 ? 0 : (sy > view->h ? view->h : sy);
 | 
			
		||||
		wlr_seat_pointer_notify_motion(server->seat.seat, time, sx, sy);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Otherwise, find view under the pointer and send the event along */
 | 
			
		||||
| 
						 | 
				
			
			@ -317,6 +326,7 @@ start_drag(struct wl_listener *listener, void *data)
 | 
			
		|||
{
 | 
			
		||||
	struct seat *seat = wl_container_of(listener, seat, start_drag);
 | 
			
		||||
	struct wlr_drag *wlr_drag = data;
 | 
			
		||||
	seat->active_view = NULL;
 | 
			
		||||
	seat->drag_icon = wlr_drag->icon;
 | 
			
		||||
	wl_signal_add(&seat->drag_icon->events.destroy, &seat->destroy_drag);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -647,6 +657,8 @@ cursor_button(struct wl_listener *listener, void *data)
 | 
			
		|||
 | 
			
		||||
	/* handle _release_ */
 | 
			
		||||
	if (event->state == WLR_BUTTON_RELEASED) {
 | 
			
		||||
		server->seat.active_view = NULL;
 | 
			
		||||
 | 
			
		||||
		if (server->input_mode == LAB_INPUT_STATE_MENU) {
 | 
			
		||||
			if (close_menu) {
 | 
			
		||||
				if (server->menu_current) {
 | 
			
		||||
| 
						 | 
				
			
			@ -674,6 +686,10 @@ cursor_button(struct wl_listener *listener, void *data)
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	/* Handle _press */
 | 
			
		||||
	if (view_area == LAB_SSD_CLIENT) {
 | 
			
		||||
		server->seat.active_view = view;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (server->input_mode == LAB_INPUT_STATE_MENU) {
 | 
			
		||||
		if (view_area != LAB_SSD_MENU) {
 | 
			
		||||
			/* We close the menu on release so we don't leak a stray release */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue