mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	Don't crash when the previous keyboard surface goes away
Just always set keyboard focus to the top surface.
This commit is contained in:
		
							parent
							
								
									0ce245761c
								
							
						
					
					
						commit
						f992b2fc47
					
				
					 2 changed files with 16 additions and 11 deletions
				
			
		| 
						 | 
					@ -901,22 +901,28 @@ notify_pointer_focus(struct wl_input_device *device,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
notify_keyboard_focus(struct wl_input_device *device_base,
 | 
					notify_keyboard_focus(struct wl_input_device *device,
 | 
				
			||||||
		      uint32_t time, struct wlsc_output *output,
 | 
							      uint32_t time, struct wlsc_output *output,
 | 
				
			||||||
		      struct wl_array *keys)
 | 
							      struct wl_array *keys)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct wlsc_input_device *device =
 | 
						struct wlsc_input_device *wd =
 | 
				
			||||||
		(struct wlsc_input_device *) device_base;
 | 
							(struct wlsc_input_device *) device;
 | 
				
			||||||
 | 
						struct wlsc_compositor *compositor =
 | 
				
			||||||
 | 
							(struct wlsc_compositor *) device->compositor;
 | 
				
			||||||
 | 
						struct wlsc_surface *es;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!wl_list_empty(&compositor->surface_list))
 | 
				
			||||||
 | 
							es = container_of(compositor->surface_list.next,
 | 
				
			||||||
 | 
									  struct wlsc_surface, link);
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							es = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (output) {
 | 
						if (output) {
 | 
				
			||||||
		wl_array_copy(&device->input_device.keys, keys);
 | 
							wl_array_copy(&wd->input_device.keys, keys);
 | 
				
			||||||
		wl_input_device_set_keyboard_focus(&device->input_device,
 | 
							wl_input_device_set_keyboard_focus(&wd->input_device,
 | 
				
			||||||
						   device->saved_keyboard_focus,
 | 
											   &es->surface, time);
 | 
				
			||||||
						   time);
 | 
					 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		device->saved_keyboard_focus =
 | 
							wl_input_device_set_keyboard_focus(&wd->input_device,
 | 
				
			||||||
			device->input_device.keyboard_focus;
 | 
					 | 
				
			||||||
		wl_input_device_set_keyboard_focus(&device->input_device,
 | 
					 | 
				
			||||||
						   NULL, time);
 | 
											   NULL, time);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -70,7 +70,6 @@ struct wlsc_input_device {
 | 
				
			||||||
	struct wl_list link;
 | 
						struct wl_list link;
 | 
				
			||||||
	uint32_t modifier_state;
 | 
						uint32_t modifier_state;
 | 
				
			||||||
	struct wl_selection *selection;
 | 
						struct wl_selection *selection;
 | 
				
			||||||
	struct wl_surface *saved_keyboard_focus;
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wlsc_drm {
 | 
					struct wlsc_drm {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue