mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	src/cursor.c: add cursor lock confinement
This commit is contained in:
		
							parent
							
								
									c25e2c7a7d
								
							
						
					
					
						commit
						22ba7f6744
					
				
					 1 changed files with 12 additions and 0 deletions
				
			
		
							
								
								
									
										12
									
								
								src/cursor.c
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								src/cursor.c
									
										
									
									
									
								
							| 
						 | 
					@ -595,6 +595,7 @@ apply_constraint(struct seat *seat, struct wlr_pointer *pointer, double *x, doub
 | 
				
			||||||
	if (!seat->current_constraint || pointer->base.type != WLR_INPUT_DEVICE_POINTER) {
 | 
						if (!seat->current_constraint || pointer->base.type != WLR_INPUT_DEVICE_POINTER) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						assert(seat->current_constraint->type == WLR_POINTER_CONSTRAINT_V1_CONFINED);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	double sx = seat->cursor->x;
 | 
						double sx = seat->cursor->x;
 | 
				
			||||||
	double sy = seat->cursor->y;
 | 
						double sy = seat->cursor->y;
 | 
				
			||||||
| 
						 | 
					@ -612,10 +613,21 @@ apply_constraint(struct seat *seat, struct wlr_pointer *pointer, double *x, doub
 | 
				
			||||||
	*y = sy_confined - sy;
 | 
						*y = sy_confined - sy;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static bool
 | 
				
			||||||
 | 
					cursor_locked(struct seat *seat, struct wlr_pointer *pointer)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return seat->current_constraint
 | 
				
			||||||
 | 
							&& pointer->base.type == WLR_INPUT_DEVICE_POINTER
 | 
				
			||||||
 | 
							&& seat->current_constraint->type == WLR_POINTER_CONSTRAINT_V1_LOCKED;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
preprocess_cursor_motion(struct seat *seat, struct wlr_pointer *pointer,
 | 
					preprocess_cursor_motion(struct seat *seat, struct wlr_pointer *pointer,
 | 
				
			||||||
		uint32_t time_msec, double dx, double dy)
 | 
							uint32_t time_msec, double dx, double dy)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						if (cursor_locked(seat, pointer)) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	apply_constraint(seat, pointer, &dx, &dy);
 | 
						apply_constraint(seat, pointer, &dx, &dy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue