| 
									
										
										
										
											2018-12-31 00:12:33 +01:00
										 |  |  | #ifndef CG_VIEW_H
 | 
					
						
							|  |  |  | #define CG_VIEW_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 17:24:21 +01:00
										 |  |  | #include "config.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 00:12:33 +01:00
										 |  |  | #include <stdbool.h>
 | 
					
						
							|  |  |  | #include <wayland-server.h>
 | 
					
						
							|  |  |  | #include <wlr/types/wlr_box.h>
 | 
					
						
							|  |  |  | #include <wlr/types/wlr_surface.h>
 | 
					
						
							|  |  |  | #include <wlr/types/wlr_xdg_shell.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "server.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum cg_view_type { | 
					
						
							|  |  |  | 	CAGE_XDG_SHELL_VIEW, | 
					
						
							| 
									
										
										
										
											2018-12-31 17:24:21 +01:00
										 |  |  | #ifdef CAGE_HAS_XWAYLAND
 | 
					
						
							|  |  |  | 	CAGE_XWAYLAND_VIEW, | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-12-31 00:12:33 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct cg_view { | 
					
						
							|  |  |  | 	struct cg_server *server; | 
					
						
							|  |  |  | 	struct wl_list link; // server::views
 | 
					
						
							|  |  |  | 	struct wlr_surface *wlr_surface; | 
					
						
							|  |  |  | 	int x, y; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	enum cg_view_type type; | 
					
						
							|  |  |  | 	union { | 
					
						
							|  |  |  | 		struct wlr_xdg_surface *xdg_surface; | 
					
						
							| 
									
										
										
										
											2018-12-31 17:24:21 +01:00
										 |  |  | #ifdef CAGE_HAS_XWAYLAND
 | 
					
						
							|  |  |  | 		struct wlr_xwayland_surface *xwayland_surface; | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-12-31 00:12:33 +01:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct wl_listener destroy; | 
					
						
							| 
									
										
										
										
											2018-12-31 19:52:47 +01:00
										 |  |  | 	struct wl_listener unmap; | 
					
						
							| 
									
										
										
										
											2018-12-31 00:12:33 +01:00
										 |  |  | 	struct wl_listener map; | 
					
						
							|  |  |  | 	// TODO: allow applications to go to fullscreen from maximized?
 | 
					
						
							|  |  |  | 	// struct wl_listener request_fullscreen;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void (*activate)(struct cg_view *view, bool activate); | 
					
						
							|  |  |  | 	void (*maximize)(struct cg_view *view, int output_width, int output_height); | 
					
						
							| 
									
										
										
										
											2018-12-31 20:44:20 +01:00
										 |  |  | 	void (*get_geometry)(struct cg_view *view, int *width_out, int *height_out); | 
					
						
							| 
									
										
										
										
											2019-01-02 21:23:16 +01:00
										 |  |  | 	void (*for_each_surface)(struct cg_view *view, wlr_surface_iterator_func_t iterator, | 
					
						
							|  |  |  | 				 void *data); | 
					
						
							| 
									
										
										
										
											2019-01-02 21:31:30 +01:00
										 |  |  | 	struct wlr_surface *(*wlr_surface_at)(struct cg_view *view, double sx, double sy, | 
					
						
							|  |  |  | 					      double *sub_x, double *sub_y); | 
					
						
							| 
									
										
										
										
											2018-12-31 00:12:33 +01:00
										 |  |  | 	bool (*is_primary)(struct cg_view *view); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void view_activate(struct cg_view *view, bool activate); | 
					
						
							|  |  |  | void view_maximize(struct cg_view *view); | 
					
						
							|  |  |  | void view_center(struct cg_view *view); | 
					
						
							| 
									
										
										
										
											2019-01-02 21:23:16 +01:00
										 |  |  | void view_for_each_surface(struct cg_view *view, wlr_surface_iterator_func_t iterator, void *data); | 
					
						
							| 
									
										
										
										
											2019-01-02 21:31:30 +01:00
										 |  |  | struct wlr_surface *view_wlr_surface_at(struct cg_view *view, double sx, double sy, | 
					
						
							|  |  |  | 					double *sub_x, double *sub_y); | 
					
						
							| 
									
										
										
										
											2018-12-31 00:12:33 +01:00
										 |  |  | bool view_is_primary(struct cg_view *view); | 
					
						
							| 
									
										
										
										
											2018-12-31 19:52:47 +01:00
										 |  |  | void view_unmap(struct cg_view *view); | 
					
						
							| 
									
										
										
										
											2018-12-31 00:12:33 +01:00
										 |  |  | void view_map(struct cg_view *view, struct wlr_surface *surface); | 
					
						
							|  |  |  | void view_destroy(struct cg_view *view); | 
					
						
							|  |  |  | struct cg_view *cg_view_create(struct cg_server *server); | 
					
						
							|  |  |  | struct cg_view *cg_view_from_wlr_surface(struct cg_server *server, struct wlr_surface *surface); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 |