mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	Send modifier event to pointer focus when it changes too
This commit is contained in:
		
							parent
							
								
									67e16be8aa
								
							
						
					
					
						commit
						9afb5f61f8
					
				
					 1 changed files with 31 additions and 17 deletions
				
			
		| 
						 | 
					@ -532,13 +532,30 @@ default_grab_key(struct wl_keyboard_grab *grab,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static struct wl_resource *
 | 
				
			||||||
 | 
					find_resource_for_surface(struct wl_list *list, struct wl_surface *surface)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct wl_resource *r;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!surface)
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						wl_list_for_each(r, list, link) {
 | 
				
			||||||
 | 
							if (r->client == surface->resource.client)
 | 
				
			||||||
 | 
								return r;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return NULL;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
default_grab_modifiers(struct wl_keyboard_grab *grab, uint32_t serial,
 | 
					default_grab_modifiers(struct wl_keyboard_grab *grab, uint32_t serial,
 | 
				
			||||||
		       uint32_t mods_depressed, uint32_t mods_latched,
 | 
							       uint32_t mods_depressed, uint32_t mods_latched,
 | 
				
			||||||
		       uint32_t mods_locked, uint32_t group)
 | 
							       uint32_t mods_locked, uint32_t group)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct wl_keyboard *keyboard = grab->keyboard;
 | 
						struct wl_keyboard *keyboard = grab->keyboard;
 | 
				
			||||||
	struct wl_resource *resource;
 | 
						struct wl_pointer *pointer = keyboard->seat->pointer;
 | 
				
			||||||
 | 
						struct wl_resource *resource, *pr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resource = keyboard->focus_resource;
 | 
						resource = keyboard->focus_resource;
 | 
				
			||||||
	if (!resource)
 | 
						if (!resource)
 | 
				
			||||||
| 
						 | 
					@ -546,6 +563,19 @@ default_grab_modifiers(struct wl_keyboard_grab *grab, uint32_t serial,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_keyboard_send_modifiers(resource, serial, mods_depressed,
 | 
						wl_keyboard_send_modifiers(resource, serial, mods_depressed,
 | 
				
			||||||
				   mods_latched, mods_locked, group);
 | 
									   mods_latched, mods_locked, group);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (pointer && pointer->focus && pointer->focus != keyboard->focus) {
 | 
				
			||||||
 | 
							pr = find_resource_for_surface(&keyboard->resource_list,
 | 
				
			||||||
 | 
										       pointer->focus);
 | 
				
			||||||
 | 
							if (pr) {
 | 
				
			||||||
 | 
								wl_keyboard_send_modifiers(pr,
 | 
				
			||||||
 | 
											   serial,
 | 
				
			||||||
 | 
											   keyboard->modifiers.mods_depressed,
 | 
				
			||||||
 | 
											   keyboard->modifiers.mods_latched,
 | 
				
			||||||
 | 
											   keyboard->modifiers.mods_locked,
 | 
				
			||||||
 | 
											   keyboard->modifiers.group);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const struct wl_keyboard_grab_interface
 | 
					static const struct wl_keyboard_grab_interface
 | 
				
			||||||
| 
						 | 
					@ -704,22 +734,6 @@ wl_seat_set_touch(struct wl_seat *seat, struct wl_touch *touch)
 | 
				
			||||||
	seat_send_updated_caps(seat);
 | 
						seat_send_updated_caps(seat);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct wl_resource *
 | 
					 | 
				
			||||||
find_resource_for_surface(struct wl_list *list, struct wl_surface *surface)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct wl_resource *r;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!surface)
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	wl_list_for_each(r, list, link) {
 | 
					 | 
				
			||||||
		if (r->client == surface->resource.client)
 | 
					 | 
				
			||||||
			return r;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return NULL;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
WL_EXPORT void
 | 
					WL_EXPORT void
 | 
				
			||||||
wl_pointer_set_focus(struct wl_pointer *pointer, struct wl_surface *surface,
 | 
					wl_pointer_set_focus(struct wl_pointer *pointer, struct wl_surface *surface,
 | 
				
			||||||
		     wl_fixed_t sx, wl_fixed_t sy)
 | 
							     wl_fixed_t sx, wl_fixed_t sy)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue