mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	input: move touch only with one touch point
In other words, do not move the cursor when more than one finger is down.
This commit is contained in:
		
							parent
							
								
									a3d8688c17
								
							
						
					
					
						commit
						3dbd5f30fc
					
				
					 1 changed files with 19 additions and 8 deletions
				
			
		| 
						 | 
					@ -63,6 +63,8 @@ handle_touch_motion(struct wl_listener *listener, void *data)
 | 
				
			||||||
	struct wlr_touch_motion_event *event = data;
 | 
						struct wlr_touch_motion_event *event = data;
 | 
				
			||||||
	idle_manager_notify_activity(seat->seat);
 | 
						idle_manager_notify_activity(seat->seat);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						int touch_point_count = wl_list_length(&seat->touch_points);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Find existing touch point to determine initial offsets to subtract */
 | 
						/* Find existing touch point to determine initial offsets to subtract */
 | 
				
			||||||
	struct touch_point *touch_point;
 | 
						struct touch_point *touch_point;
 | 
				
			||||||
	wl_list_for_each(touch_point, &seat->touch_points, link) {
 | 
						wl_list_for_each(touch_point, &seat->touch_points, link) {
 | 
				
			||||||
| 
						 | 
					@ -77,14 +79,18 @@ handle_touch_motion(struct wl_listener *listener, void *data)
 | 
				
			||||||
				double sx = lx - touch_point->x_offset;
 | 
									double sx = lx - touch_point->x_offset;
 | 
				
			||||||
				double sy = ly - touch_point->y_offset;
 | 
									double sy = ly - touch_point->y_offset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				wlr_cursor_warp_absolute(seat->cursor,
 | 
									if (touch_point_count == 1) {
 | 
				
			||||||
					&event->touch->base, event->x, event->y);
 | 
										wlr_cursor_warp_absolute(seat->cursor, &event->touch->base,
 | 
				
			||||||
 | 
											event->x, event->y);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
				wlr_seat_touch_notify_motion(seat->seat, event->time_msec,
 | 
									wlr_seat_touch_notify_motion(seat->seat, event->time_msec,
 | 
				
			||||||
					event->touch_id, sx, sy);
 | 
										event->touch_id, sx, sy);
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
 | 
									if (touch_point_count == 1) {
 | 
				
			||||||
					cursor_emulate_move_absolute(seat, &event->touch->base,
 | 
										cursor_emulate_move_absolute(seat, &event->touch->base,
 | 
				
			||||||
						event->x, event->y, event->time_msec);
 | 
											event->x, event->y, event->time_msec);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -114,6 +120,7 @@ handle_touch_down(struct wl_listener *listener, void *data)
 | 
				
			||||||
	touch_point->y_offset = y_offset;
 | 
						touch_point->y_offset = y_offset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_list_insert(&seat->touch_points, &touch_point->link);
 | 
						wl_list_insert(&seat->touch_points, &touch_point->link);
 | 
				
			||||||
 | 
						int touch_point_count = wl_list_length(&seat->touch_points);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (touch_point->surface) {
 | 
						if (touch_point->surface) {
 | 
				
			||||||
		/* Convert coordinates: first [0, 1] => layout */
 | 
							/* Convert coordinates: first [0, 1] => layout */
 | 
				
			||||||
| 
						 | 
					@ -135,13 +142,17 @@ handle_touch_down(struct wl_listener *listener, void *data)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		wlr_cursor_warp_absolute(seat->cursor,
 | 
							if (touch_point_count == 1) {
 | 
				
			||||||
			&event->touch->base, event->x, event->y);
 | 
								wlr_cursor_warp_absolute(seat->cursor, &event->touch->base,
 | 
				
			||||||
 | 
									event->x, event->y);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		wlr_seat_touch_notify_down(seat->seat, touch_point->surface,
 | 
							wlr_seat_touch_notify_down(seat->seat, touch_point->surface,
 | 
				
			||||||
			event->time_msec, event->touch_id, sx, sy);
 | 
								event->time_msec, event->touch_id, sx, sy);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
 | 
							if (touch_point_count == 1) {
 | 
				
			||||||
			cursor_emulate_move_absolute(seat, &event->touch->base,
 | 
								cursor_emulate_move_absolute(seat, &event->touch->base,
 | 
				
			||||||
				event->x, event->y, event->time_msec);
 | 
									event->x, event->y, event->time_msec);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		cursor_emulate_button(seat, BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED,
 | 
							cursor_emulate_button(seat, BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED,
 | 
				
			||||||
			event->time_msec);
 | 
								event->time_msec);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue