mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	Handle buttons in grab objects too
This commit is contained in:
		
							parent
							
								
									9c3e8d734e
								
							
						
					
					
						commit
						b3fc757cd8
					
				
					 2 changed files with 36 additions and 5 deletions
				
			
		| 
						 | 
					@ -571,6 +571,12 @@ move_grab_motion(struct wl_grab *grab,
 | 
				
			||||||
	wlsc_surface_update_matrix(es);
 | 
						wlsc_surface_update_matrix(es);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					move_grab_button(struct wl_grab *grab,
 | 
				
			||||||
 | 
							 uint32_t time, int32_t button, int32_t state)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
move_grab_end(struct wl_grab *grab, uint32_t time)
 | 
					move_grab_end(struct wl_grab *grab, uint32_t time)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -579,6 +585,7 @@ move_grab_end(struct wl_grab *grab, uint32_t time)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const struct wl_grab_interface move_grab_interface = {
 | 
					static const struct wl_grab_interface move_grab_interface = {
 | 
				
			||||||
	move_grab_motion,
 | 
						move_grab_motion,
 | 
				
			||||||
 | 
						move_grab_button,
 | 
				
			||||||
	move_grab_end
 | 
						move_grab_end
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -652,6 +659,12 @@ resize_grab_motion(struct wl_grab *grab,
 | 
				
			||||||
			     surface, sx, sy, width, height);
 | 
								     surface, sx, sy, width, height);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					resize_grab_button(struct wl_grab *grab,
 | 
				
			||||||
 | 
							   uint32_t time, int32_t button, int32_t state)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
resize_grab_end(struct wl_grab *grab, uint32_t time)
 | 
					resize_grab_end(struct wl_grab *grab, uint32_t time)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -660,6 +673,7 @@ resize_grab_end(struct wl_grab *grab, uint32_t time)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const struct wl_grab_interface resize_grab_interface = {
 | 
					static const struct wl_grab_interface resize_grab_interface = {
 | 
				
			||||||
	resize_grab_motion,
 | 
						resize_grab_motion,
 | 
				
			||||||
 | 
						resize_grab_button,
 | 
				
			||||||
	resize_grab_end
 | 
						resize_grab_end
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -862,6 +876,16 @@ motion_grab_motion(struct wl_grab *grab,
 | 
				
			||||||
			     time, x, y, sx, sy);
 | 
								     time, x, y, sx, sy);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					motion_grab_button(struct wl_grab *grab,
 | 
				
			||||||
 | 
							   uint32_t time, int32_t button, int32_t state)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						wl_client_post_event(grab->input_device->pointer_focus->client,
 | 
				
			||||||
 | 
								     &grab->input_device->object,
 | 
				
			||||||
 | 
								     WL_INPUT_DEVICE_BUTTON,
 | 
				
			||||||
 | 
								     time, button, state);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
motion_grab_end(struct wl_grab *grab, uint32_t time)
 | 
					motion_grab_end(struct wl_grab *grab, uint32_t time)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -869,6 +893,7 @@ motion_grab_end(struct wl_grab *grab, uint32_t time)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const struct wl_grab_interface motion_grab_interface = {
 | 
					static const struct wl_grab_interface motion_grab_interface = {
 | 
				
			||||||
	motion_grab_motion,
 | 
						motion_grab_motion,
 | 
				
			||||||
 | 
						motion_grab_button,
 | 
				
			||||||
	motion_grab_end
 | 
						motion_grab_end
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -973,11 +998,8 @@ notify_button(struct wl_input_device *device,
 | 
				
			||||||
			     (struct wl_shell *) &compositor->shell,
 | 
								     (struct wl_shell *) &compositor->shell,
 | 
				
			||||||
			     &surface->surface, device, time,
 | 
								     &surface->surface, device, time,
 | 
				
			||||||
			     WLSC_DEVICE_GRAB_RESIZE_BOTTOM_RIGHT);
 | 
								     WLSC_DEVICE_GRAB_RESIZE_BOTTOM_RIGHT);
 | 
				
			||||||
	else if (device->grab == NULL || device->grab == &device->motion_grab)
 | 
					
 | 
				
			||||||
		wl_client_post_event(surface->surface.client,
 | 
						device->grab->interface->button(device->grab, time, button, state);
 | 
				
			||||||
				     &device->object,
 | 
					 | 
				
			||||||
				     WL_INPUT_DEVICE_BUTTON,
 | 
					 | 
				
			||||||
				     time, button, state);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!state && device->grab && device->grab_button == button)
 | 
						if (!state && device->grab && device->grab_button == button)
 | 
				
			||||||
		wl_input_device_end_grab(device, time);
 | 
							wl_input_device_end_grab(device, time);
 | 
				
			||||||
| 
						 | 
					@ -1203,6 +1225,12 @@ drag_grab_motion(struct wl_grab *grab,
 | 
				
			||||||
				     time, x, y, sx, sy);
 | 
									     time, x, y, sx, sy);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					drag_grab_button(struct wl_grab *grab,
 | 
				
			||||||
 | 
							 uint32_t time, int32_t button, int32_t state)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
drag_grab_end(struct wl_grab *grab, uint32_t time)
 | 
					drag_grab_end(struct wl_grab *grab, uint32_t time)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -1218,6 +1246,7 @@ drag_grab_end(struct wl_grab *grab, uint32_t time)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const struct wl_grab_interface drag_grab_interface = {
 | 
					static const struct wl_grab_interface drag_grab_interface = {
 | 
				
			||||||
	drag_grab_motion,
 | 
						drag_grab_motion,
 | 
				
			||||||
 | 
						drag_grab_button,
 | 
				
			||||||
	drag_grab_end
 | 
						drag_grab_end
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -137,6 +137,8 @@ struct wl_grab;
 | 
				
			||||||
struct wl_grab_interface {
 | 
					struct wl_grab_interface {
 | 
				
			||||||
	void (*motion)(struct wl_grab *grab,
 | 
						void (*motion)(struct wl_grab *grab,
 | 
				
			||||||
		       uint32_t time, int32_t x, int32_t y);
 | 
							       uint32_t time, int32_t x, int32_t y);
 | 
				
			||||||
 | 
						void (*button)(struct wl_grab *grab,
 | 
				
			||||||
 | 
							       uint32_t time, int32_t button, int32_t state);
 | 
				
			||||||
	void (*end)(struct wl_grab *grab, uint32_t time);
 | 
						void (*end)(struct wl_grab *grab, uint32_t time);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue