mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	Maintain keyboard modifier state in wayland-server
Provide a slot for keyboard modifier state inside wl_keyboard for implementations to update, and use this to send wl_keyboard:;modifier events whenever the keyboard or pointer focus changes. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
		
							parent
							
								
									2261007953
								
							
						
					
					
						commit
						bcefacb89d
					
				
					 2 changed files with 26 additions and 1 deletions
				
			
		| 
						 | 
					@ -724,7 +724,8 @@ 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)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct wl_resource *resource;
 | 
						struct wl_keyboard *kbd = pointer->seat->keyboard;
 | 
				
			||||||
 | 
						struct wl_resource *resource, *kr;
 | 
				
			||||||
	uint32_t serial;
 | 
						uint32_t serial;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	resource = pointer->focus_resource;
 | 
						resource = pointer->focus_resource;
 | 
				
			||||||
| 
						 | 
					@ -741,6 +742,18 @@ wl_pointer_set_focus(struct wl_pointer *pointer, struct wl_surface *surface,
 | 
				
			||||||
	    (pointer->focus != surface ||
 | 
						    (pointer->focus != surface ||
 | 
				
			||||||
	     pointer->focus_resource != resource)) {
 | 
						     pointer->focus_resource != resource)) {
 | 
				
			||||||
		serial = wl_display_next_serial(resource->client->display);
 | 
							serial = wl_display_next_serial(resource->client->display);
 | 
				
			||||||
 | 
							if (kbd) {
 | 
				
			||||||
 | 
								kr = find_resource_for_surface(&kbd->resource_list,
 | 
				
			||||||
 | 
											       surface);
 | 
				
			||||||
 | 
								if (kr) {
 | 
				
			||||||
 | 
									wl_keyboard_send_modifiers(resource,
 | 
				
			||||||
 | 
												   serial,
 | 
				
			||||||
 | 
												   kbd->modifiers.mods_depressed,
 | 
				
			||||||
 | 
												   kbd->modifiers.mods_latched,
 | 
				
			||||||
 | 
												   kbd->modifiers.mods_locked,
 | 
				
			||||||
 | 
												   kbd->modifiers.group);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		wl_pointer_send_enter(resource, serial, &surface->resource,
 | 
							wl_pointer_send_enter(resource, serial, &surface->resource,
 | 
				
			||||||
				      sx, sy);
 | 
									      sx, sy);
 | 
				
			||||||
		wl_signal_add(&resource->destroy_signal,
 | 
							wl_signal_add(&resource->destroy_signal,
 | 
				
			||||||
| 
						 | 
					@ -774,6 +787,11 @@ wl_keyboard_set_focus(struct wl_keyboard *keyboard, struct wl_surface *surface)
 | 
				
			||||||
	    (keyboard->focus != surface ||
 | 
						    (keyboard->focus != surface ||
 | 
				
			||||||
	     keyboard->focus_resource != resource)) {
 | 
						     keyboard->focus_resource != resource)) {
 | 
				
			||||||
		serial = wl_display_next_serial(resource->client->display);
 | 
							serial = wl_display_next_serial(resource->client->display);
 | 
				
			||||||
 | 
							wl_keyboard_send_modifiers(resource, serial,
 | 
				
			||||||
 | 
										   keyboard->modifiers.mods_depressed,
 | 
				
			||||||
 | 
										   keyboard->modifiers.mods_latched,
 | 
				
			||||||
 | 
										   keyboard->modifiers.mods_locked,
 | 
				
			||||||
 | 
										   keyboard->modifiers.group);
 | 
				
			||||||
		wl_keyboard_send_enter(resource, serial, &surface->resource,
 | 
							wl_keyboard_send_enter(resource, serial, &surface->resource,
 | 
				
			||||||
				       &keyboard->keys);
 | 
									       &keyboard->keys);
 | 
				
			||||||
		wl_signal_add(&resource->destroy_signal,
 | 
							wl_signal_add(&resource->destroy_signal,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -280,6 +280,13 @@ struct wl_keyboard {
 | 
				
			||||||
	uint32_t grab_time;
 | 
						uint32_t grab_time;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wl_array keys;
 | 
						struct wl_array keys;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct {
 | 
				
			||||||
 | 
							uint32_t mods_depressed;
 | 
				
			||||||
 | 
							uint32_t mods_latched;
 | 
				
			||||||
 | 
							uint32_t mods_locked;
 | 
				
			||||||
 | 
							uint32_t group;
 | 
				
			||||||
 | 
						} modifiers;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wl_touch {
 | 
					struct wl_touch {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue