mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	view: assign output on surface creation instead of mapping...
...and notify the client of the preferred output scale when doing so.
This should allow clients to better determine an optimal size if they
are initially configured (unmapped) with zero size.
In particular, this fixes an issue with foot:
    https://codeberg.org/dnkl/foot/issues/1579
			
			
This commit is contained in:
		
							parent
							
								
									02d274e32c
								
							
						
					
					
						commit
						4238d7fc33
					
				
					 1 changed files with 19 additions and 0 deletions
				
			
		
							
								
								
									
										19
									
								
								src/xdg.c
									
										
									
									
									
								
							
							
						
						
									
										19
									
								
								src/xdg.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,6 +1,8 @@
 | 
				
			||||||
// SPDX-License-Identifier: GPL-2.0-only
 | 
					// SPDX-License-Identifier: GPL-2.0-only
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <assert.h>
 | 
					#include <assert.h>
 | 
				
			||||||
 | 
					#include <wlr/types/wlr_fractional_scale_v1.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "common/macros.h"
 | 
					#include "common/macros.h"
 | 
				
			||||||
#include "common/mem.h"
 | 
					#include "common/mem.h"
 | 
				
			||||||
#include "decorations.h"
 | 
					#include "decorations.h"
 | 
				
			||||||
| 
						 | 
					@ -483,7 +485,13 @@ xdg_toplevel_view_map(struct view *view)
 | 
				
			||||||
	if (view->mapped) {
 | 
						if (view->mapped) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	view->mapped = true;
 | 
						view->mapped = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * An output should have been chosen when the surface was first
 | 
				
			||||||
 | 
						 * created, but take one more opportunity to assign an output if not.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
	if (!view->output) {
 | 
						if (!view->output) {
 | 
				
			||||||
		view_set_output(view, output_nearest_to_cursor(view->server));
 | 
							view_set_output(view, output_nearest_to_cursor(view->server));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -641,6 +649,17 @@ xdg_surface_new(struct wl_listener *listener, void *data)
 | 
				
			||||||
	view->impl = &xdg_toplevel_view_impl;
 | 
						view->impl = &xdg_toplevel_view_impl;
 | 
				
			||||||
	xdg_toplevel_view->xdg_surface = xdg_surface;
 | 
						xdg_toplevel_view->xdg_surface = xdg_surface;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * Pick an output for the surface as soon as its created, so that the
 | 
				
			||||||
 | 
						 * client can be notified about any fractional scale before it is given
 | 
				
			||||||
 | 
						 * the chance to configure itself (and possibly pick its dimensions).
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						view_set_output(view, output_nearest_to_cursor(server));
 | 
				
			||||||
 | 
						if (view->output) {
 | 
				
			||||||
 | 
							wlr_fractional_scale_v1_notify_scale(xdg_surface->surface,
 | 
				
			||||||
 | 
								view->output->wlr_output->scale);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	view->workspace = server->workspace_current;
 | 
						view->workspace = server->workspace_current;
 | 
				
			||||||
	view->scene_tree = wlr_scene_tree_create(view->workspace->tree);
 | 
						view->scene_tree = wlr_scene_tree_create(view->workspace->tree);
 | 
				
			||||||
	wlr_scene_node_set_enabled(&view->scene_tree->node, false);
 | 
						wlr_scene_node_set_enabled(&view->scene_tree->node, false);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue