mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	src/view.c: Prevent crash by killing a moving application
When a view is destroyed labwc calls interactive_end(view) which may reposition the view which is partly destroyed and doesn't own any surface anymore. To prevent this scenario from happening don't call interactive_end() at all and just reset server->grabbed_view and server->input_mode directly. Before this patch, the bug could be reproduced by: - xcalc & - sleep 5; killall xcalc - move the xcalc window completely to one of the edges The change in src/xwayland.c is not required for this bug to be fixed but may prevent something similar in the future.
This commit is contained in:
		
							parent
							
								
									1f0055a7e0
								
							
						
					
					
						commit
						f1ba0a89fc
					
				
					 2 changed files with 21 additions and 6 deletions
				
			
		
							
								
								
									
										23
									
								
								src/view.c
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								src/view.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -759,25 +759,36 @@ view_update_app_id(struct view *view)
 | 
			
		|||
void
 | 
			
		||||
view_destroy(struct view *view)
 | 
			
		||||
{
 | 
			
		||||
	struct server *server = view->server;
 | 
			
		||||
 | 
			
		||||
	if (view->toplevel_handle) {
 | 
			
		||||
		wlr_foreign_toplevel_handle_v1_destroy(view->toplevel_handle);
 | 
			
		||||
	}
 | 
			
		||||
	interactive_end(view);
 | 
			
		||||
 | 
			
		||||
	struct server *server = view->server;
 | 
			
		||||
	if (server->grabbed_view == view) {
 | 
			
		||||
		/* Application got killed while moving around */
 | 
			
		||||
		server->input_mode = LAB_INPUT_STATE_PASSTHROUGH;
 | 
			
		||||
		server->grabbed_view = NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (server->seat.pressed.view == view) {
 | 
			
		||||
		/* Mouse was pressed on surface and is still pressed */
 | 
			
		||||
		server->seat.pressed.view = NULL;
 | 
			
		||||
		server->seat.pressed.surface = NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (server->cycle_view == view) {
 | 
			
		||||
		/* If we are the current OSD selected view, cycle
 | 
			
		||||
		 * to the next because we are dying. */
 | 
			
		||||
		/*
 | 
			
		||||
		 * If we are the current OSD selected view, cycle
 | 
			
		||||
		 * to the next because we are dying.
 | 
			
		||||
		 */
 | 
			
		||||
		server->cycle_view = desktop_cycle_view(server,
 | 
			
		||||
			server->cycle_view, LAB_CYCLE_DIR_BACKWARD);
 | 
			
		||||
 | 
			
		||||
		/* If we cycled back to ourselves, then we have no windows.
 | 
			
		||||
		 * just remove it and close the OSD for good. */
 | 
			
		||||
		/*
 | 
			
		||||
		 * If we cycled back to ourselves, then we have no windows.
 | 
			
		||||
		 * just remove it and close the OSD for good.
 | 
			
		||||
		 */
 | 
			
		||||
		if (server->cycle_view == view || !server->cycle_view) {
 | 
			
		||||
			server->cycle_view = NULL;
 | 
			
		||||
			osd_finish(server);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue