mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	view: add view_center()
This commit is contained in:
		
							parent
							
								
									4234d53fd7
								
							
						
					
					
						commit
						cb98f8f197
					
				
					 2 changed files with 17 additions and 0 deletions
				
			
		
							
								
								
									
										16
									
								
								src/view.c
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								src/view.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -49,6 +49,22 @@ view_output(struct view *view)
 | 
			
		|||
	return output;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
view_center(struct view *view)
 | 
			
		||||
{
 | 
			
		||||
	struct wlr_output *output = view_output(view);
 | 
			
		||||
	if (!output) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	struct wlr_output_layout *layout = view->server->output_layout;
 | 
			
		||||
	struct wlr_output_layout_output* ol_output =
 | 
			
		||||
		wlr_output_layout_get(layout, output);
 | 
			
		||||
	int center_x = ol_output->x + output->width / 2;
 | 
			
		||||
	int center_y = ol_output->y + output->height / 2;
 | 
			
		||||
	view_move(view, center_x - view->w / 2, center_y - view->h / 2);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
view_maximize(struct view *view, bool maximize)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue