mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	text_input: Fix ime panic in ext-session-lock
in the origin text_input.c, we only check the sway_view and layershell, but now we have the third shell named sessionlock, so we need to modify both text_input.c and view.c to handle the new type of shell
This commit is contained in:
		
							parent
							
								
									30434b2beb
								
							
						
					
					
						commit
						d148560f50
					
				
					 2 changed files with 29 additions and 0 deletions
				
			
		| 
						 | 
					@ -10,6 +10,7 @@
 | 
				
			||||||
#include "sway/input/text_input_popup.h"
 | 
					#include "sway/input/text_input_popup.h"
 | 
				
			||||||
#include "sway/layers.h"
 | 
					#include "sway/layers.h"
 | 
				
			||||||
#include "sway/server.h"
 | 
					#include "sway/server.h"
 | 
				
			||||||
 | 
					#include <wlr/types/wlr_session_lock_v1.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct sway_text_input *relay_get_focusable_text_input(
 | 
					static struct sway_text_input *relay_get_focusable_text_input(
 | 
				
			||||||
		struct sway_input_method_relay *relay) {
 | 
							struct sway_input_method_relay *relay) {
 | 
				
			||||||
| 
						 | 
					@ -385,6 +386,8 @@ static void input_popup_set_focus(struct sway_input_popup *popup,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wlr_layer_surface_v1 *layer_surface =
 | 
						struct wlr_layer_surface_v1 *layer_surface =
 | 
				
			||||||
		wlr_layer_surface_v1_try_from_wlr_surface(surface);
 | 
							wlr_layer_surface_v1_try_from_wlr_surface(surface);
 | 
				
			||||||
 | 
						struct wlr_session_lock_surface_v1 *lock_surface =
 | 
				
			||||||
 | 
							wlr_session_lock_surface_v1_try_from_wlr_surface(surface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wlr_scene_tree *relative_parent;
 | 
						struct wlr_scene_tree *relative_parent;
 | 
				
			||||||
	if (layer_surface) {
 | 
						if (layer_surface) {
 | 
				
			||||||
| 
						 | 
					@ -404,8 +407,30 @@ static void input_popup_set_focus(struct sway_input_popup *popup,
 | 
				
			||||||
		// surface. Layer surfaces get destroyed as part of the output being
 | 
							// surface. Layer surfaces get destroyed as part of the output being
 | 
				
			||||||
		// destroyed, thus also trickling down to popups.
 | 
							// destroyed, thus also trickling down to popups.
 | 
				
			||||||
		popup->fixed_output = layer->layer_surface->output;
 | 
							popup->fixed_output = layer->layer_surface->output;
 | 
				
			||||||
 | 
						} else if (lock_surface) {
 | 
				
			||||||
 | 
							wl_signal_add(&lock_surface->surface->events.unmap,
 | 
				
			||||||
 | 
								&popup->focused_surface_unmap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							struct sway_layer_surface *lock = lock_surface->data;
 | 
				
			||||||
 | 
							if (lock == NULL) {
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							relative_parent = lock->scene->tree;
 | 
				
			||||||
 | 
							popup->desc.view = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// we don't need to add an event here to NULL out this field because
 | 
				
			||||||
 | 
							// this field will only be initialized if the popup is part of a layer
 | 
				
			||||||
 | 
							// surface. Layer surfaces get destroyed as part of the output being
 | 
				
			||||||
 | 
							// destroyed, thus also trickling down to popups.
 | 
				
			||||||
 | 
							popup->fixed_output = lock->layer_surface->output;
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		struct sway_view *view = view_from_wlr_surface(surface);
 | 
							struct sway_view *view = view_from_wlr_surface(surface);
 | 
				
			||||||
 | 
							// In the future there may be other shells been added, so we also need to check here.
 | 
				
			||||||
 | 
							if (view == NULL) {
 | 
				
			||||||
 | 
								sway_log(SWAY_DEBUG, "Unsupported IME focus surface");
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		wl_signal_add(&view->events.unmap, &popup->focused_surface_unmap);
 | 
							wl_signal_add(&view->events.unmap, &popup->focused_surface_unmap);
 | 
				
			||||||
		relative_parent = view->scene_tree;
 | 
							relative_parent = view->scene_tree;
 | 
				
			||||||
		popup->desc.view = view;
 | 
							popup->desc.view = view;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,6 +12,7 @@
 | 
				
			||||||
#include <wlr/types/wlr_server_decoration.h>
 | 
					#include <wlr/types/wlr_server_decoration.h>
 | 
				
			||||||
#include <wlr/types/wlr_subcompositor.h>
 | 
					#include <wlr/types/wlr_subcompositor.h>
 | 
				
			||||||
#include <wlr/types/wlr_xdg_decoration_v1.h>
 | 
					#include <wlr/types/wlr_xdg_decoration_v1.h>
 | 
				
			||||||
 | 
					#include <wlr/types/wlr_session_lock_v1.h>
 | 
				
			||||||
#if WLR_HAS_XWAYLAND
 | 
					#if WLR_HAS_XWAYLAND
 | 
				
			||||||
#include <wlr/xwayland.h>
 | 
					#include <wlr/xwayland.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -1010,6 +1011,9 @@ struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) {
 | 
				
			||||||
	if (wlr_layer_surface_v1_try_from_wlr_surface(wlr_surface) != NULL) {
 | 
						if (wlr_layer_surface_v1_try_from_wlr_surface(wlr_surface) != NULL) {
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if (wlr_session_lock_surface_v1_try_from_wlr_surface(wlr_surface) != NULL) {
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const char *role = wlr_surface->role ? wlr_surface->role->name : NULL;
 | 
						const char *role = wlr_surface->role ? wlr_surface->role->name : NULL;
 | 
				
			||||||
	sway_log(SWAY_DEBUG, "Surface of unknown type (role %s): %p",
 | 
						sway_log(SWAY_DEBUG, "Surface of unknown type (role %s): %p",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue