mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	Add mouse emulation for touch devices (#2277)
This commit is contained in:
		
							parent
							
								
									4d3efb4339
								
							
						
					
					
						commit
						45a9bd95e7
					
				
					 5 changed files with 24 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -24,6 +24,17 @@ static struct wlr_surface*
 | 
			
		|||
touch_get_coords(struct seat *seat, struct wlr_touch *touch, double x, double y,
 | 
			
		||||
		double *x_offset, double *y_offset)
 | 
			
		||||
{
 | 
			
		||||
	/*
 | 
			
		||||
	 * Do not return a surface when mouse emulation is enforced. Not
 | 
			
		||||
	 * having a surface will trigger the fallback to cursor move/button
 | 
			
		||||
	 * emulation in the touch signal handlers.
 | 
			
		||||
	 */
 | 
			
		||||
	struct touch_config_entry *config_entry =
 | 
			
		||||
		touch_find_config_for_device(touch->base.name);
 | 
			
		||||
	if (config_entry && config_entry->force_mouse_emulation) {
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Convert coordinates: first [0, 1] => layout, then layout => surface */
 | 
			
		||||
	double lx, ly;
 | 
			
		||||
	wlr_cursor_absolute_to_layout_coords(seat->cursor, &touch->base,
 | 
			
		||||
| 
						 | 
				
			
			@ -93,7 +104,7 @@ handle_touch_down(struct wl_listener *listener, void *data)
 | 
			
		|||
 | 
			
		||||
	/* Compute layout => surface offset and save for this touch point */
 | 
			
		||||
	struct touch_point *touch_point = znew(*touch_point);
 | 
			
		||||
	double x_offset, y_offset;
 | 
			
		||||
	double x_offset = 0.0, y_offset = 0.0;
 | 
			
		||||
	touch_point->surface = touch_get_coords(seat, event->touch,
 | 
			
		||||
			event->x, event->y, &x_offset, &y_offset);
 | 
			
		||||
	touch_point->touch_id = event->touch_id;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue