mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Move code to make a window a shell surface into seperate function
This commit is contained in:
		
							parent
							
								
									51204b33c1
								
							
						
					
					
						commit
						bb35960e65
					
				
					 2 changed files with 8 additions and 3 deletions
				
			
		| 
						 | 
					@ -42,5 +42,6 @@ struct window *window_setup(struct registry *registry, uint32_t width, uint32_t
 | 
				
			||||||
void window_teardown(struct window *state);
 | 
					void window_teardown(struct window *state);
 | 
				
			||||||
int window_prerender(struct window *state);
 | 
					int window_prerender(struct window *state);
 | 
				
			||||||
int window_render(struct window *state);
 | 
					int window_render(struct window *state);
 | 
				
			||||||
 | 
					void window_make_shell(struct window *window);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,6 +59,12 @@ static const struct wl_shell_surface_listener surface_listener = {
 | 
				
			||||||
	.configure = shell_surface_configure
 | 
						.configure = shell_surface_configure
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void window_make_shell(struct window *window) {
 | 
				
			||||||
 | 
						window->shell_surface = wl_shell_get_shell_surface(window->registry->shell, window->surface);
 | 
				
			||||||
 | 
						wl_shell_surface_add_listener(window->shell_surface, &surface_listener, window);
 | 
				
			||||||
 | 
						wl_shell_surface_set_toplevel(window->shell_surface);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct window *window_setup(struct registry *registry, uint32_t width, uint32_t height, bool shell_surface) {
 | 
					struct window *window_setup(struct registry *registry, uint32_t width, uint32_t height, bool shell_surface) {
 | 
				
			||||||
	struct window *window = malloc(sizeof(struct window));
 | 
						struct window *window = malloc(sizeof(struct window));
 | 
				
			||||||
	memset(window, 0, sizeof(struct window));
 | 
						memset(window, 0, sizeof(struct window));
 | 
				
			||||||
| 
						 | 
					@ -69,9 +75,7 @@ struct window *window_setup(struct registry *registry, uint32_t width, uint32_t
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	window->surface = wl_compositor_create_surface(registry->compositor);
 | 
						window->surface = wl_compositor_create_surface(registry->compositor);
 | 
				
			||||||
	if (shell_surface) {
 | 
						if (shell_surface) {
 | 
				
			||||||
		window->shell_surface = wl_shell_get_shell_surface(registry->shell, window->surface);
 | 
							window_make_shell(window);
 | 
				
			||||||
		wl_shell_surface_add_listener(window->shell_surface, &surface_listener, window);
 | 
					 | 
				
			||||||
		wl_shell_surface_set_toplevel(window->shell_surface);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (registry->pointer) {
 | 
						if (registry->pointer) {
 | 
				
			||||||
		wl_pointer_add_listener(registry->pointer, &pointer_listener, window);
 | 
							wl_pointer_add_listener(registry->pointer, &pointer_listener, window);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue