diff options
Diffstat (limited to 'include/sway/tree/view.h')
-rw-r--r-- | include/sway/tree/view.h | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h new file mode 100644 index 00000000..b51c54b5 --- /dev/null +++ b/include/sway/tree/view.h | |||
@@ -0,0 +1,186 @@ | |||
1 | #ifndef _SWAY_VIEW_H | ||
2 | #define _SWAY_VIEW_H | ||
3 | #include <wayland-server.h> | ||
4 | #include <wlr/types/wlr_surface.h> | ||
5 | #include <wlr/types/wlr_xdg_shell_v6.h> | ||
6 | #include <wlr/xwayland.h> | ||
7 | #include "sway/input/input-manager.h" | ||
8 | #include "sway/input/seat.h" | ||
9 | |||
10 | struct sway_container; | ||
11 | |||
12 | enum sway_view_type { | ||
13 | SWAY_VIEW_WL_SHELL, | ||
14 | SWAY_VIEW_XDG_SHELL_V6, | ||
15 | SWAY_VIEW_XWAYLAND, | ||
16 | }; | ||
17 | |||
18 | enum sway_view_prop { | ||
19 | VIEW_PROP_TITLE, | ||
20 | VIEW_PROP_APP_ID, | ||
21 | VIEW_PROP_CLASS, | ||
22 | VIEW_PROP_INSTANCE, | ||
23 | }; | ||
24 | |||
25 | struct sway_view_impl { | ||
26 | const char *(*get_prop)(struct sway_view *view, | ||
27 | enum sway_view_prop prop); | ||
28 | void (*configure)(struct sway_view *view, double ox, double oy, int width, | ||
29 | int height); | ||
30 | void (*set_activated)(struct sway_view *view, bool activated); | ||
31 | void (*for_each_surface)(struct sway_view *view, | ||
32 | wlr_surface_iterator_func_t iterator, void *user_data); | ||
33 | void (*close)(struct sway_view *view); | ||
34 | void (*destroy)(struct sway_view *view); | ||
35 | }; | ||
36 | |||
37 | struct sway_view { | ||
38 | enum sway_view_type type; | ||
39 | const struct sway_view_impl *impl; | ||
40 | |||
41 | struct sway_container *swayc; // NULL for unmanaged views | ||
42 | struct wlr_surface *surface; // NULL for unmapped views | ||
43 | int width, height; | ||
44 | |||
45 | union { | ||
46 | struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6; | ||
47 | struct wlr_xwayland_surface *wlr_xwayland_surface; | ||
48 | struct wlr_wl_shell_surface *wlr_wl_shell_surface; | ||
49 | }; | ||
50 | |||
51 | struct { | ||
52 | struct wl_signal unmap; | ||
53 | } events; | ||
54 | |||
55 | struct wl_listener surface_new_subsurface; | ||
56 | struct wl_listener container_reparent; | ||
57 | }; | ||
58 | |||
59 | struct sway_xdg_shell_v6_view { | ||
60 | struct sway_view view; | ||
61 | |||
62 | struct wl_listener commit; | ||
63 | struct wl_listener request_move; | ||
64 | struct wl_listener request_resize; | ||
65 | struct wl_listener request_maximize; | ||
66 | struct wl_listener new_popup; | ||
67 | struct wl_listener map; | ||
68 | struct wl_listener unmap; | ||
69 | struct wl_listener destroy; | ||
70 | |||
71 | int pending_width, pending_height; | ||
72 | }; | ||
73 | |||
74 | struct sway_xwayland_view { | ||
75 | struct sway_view view; | ||
76 | |||
77 | struct wl_listener commit; | ||
78 | struct wl_listener request_move; | ||
79 | struct wl_listener request_resize; | ||
80 | struct wl_listener request_maximize; | ||
81 | struct wl_listener request_configure; | ||
82 | struct wl_listener map; | ||
83 | struct wl_listener unmap; | ||
84 | struct wl_listener destroy; | ||
85 | |||
86 | int pending_width, pending_height; | ||
87 | }; | ||
88 | |||
89 | struct sway_xwayland_unmanaged { | ||
90 | struct wlr_xwayland_surface *wlr_xwayland_surface; | ||
91 | struct wl_list link; | ||
92 | |||
93 | int lx, ly; | ||
94 | |||
95 | struct wl_listener request_configure; | ||
96 | struct wl_listener commit; | ||
97 | struct wl_listener map; | ||
98 | struct wl_listener unmap; | ||
99 | struct wl_listener destroy; | ||
100 | }; | ||
101 | |||
102 | struct sway_wl_shell_view { | ||
103 | struct sway_view view; | ||
104 | |||
105 | struct wl_listener commit; | ||
106 | struct wl_listener request_move; | ||
107 | struct wl_listener request_resize; | ||
108 | struct wl_listener request_maximize; | ||
109 | struct wl_listener destroy; | ||
110 | |||
111 | int pending_width, pending_height; | ||
112 | }; | ||
113 | |||
114 | struct sway_view_child; | ||
115 | |||
116 | struct sway_view_child_impl { | ||
117 | void (*destroy)(struct sway_view_child *child); | ||
118 | }; | ||
119 | |||
120 | /** | ||
121 | * A view child is a surface in the view tree, such as a subsurface or a popup. | ||
122 | */ | ||
123 | struct sway_view_child { | ||
124 | const struct sway_view_child_impl *impl; | ||
125 | |||
126 | struct sway_view *view; | ||
127 | struct wlr_surface *surface; | ||
128 | |||
129 | struct wl_listener surface_commit; | ||
130 | struct wl_listener surface_new_subsurface; | ||
131 | struct wl_listener surface_destroy; | ||
132 | struct wl_listener view_unmap; | ||
133 | }; | ||
134 | |||
135 | struct sway_xdg_popup_v6 { | ||
136 | struct sway_view_child child; | ||
137 | |||
138 | struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6; | ||
139 | |||
140 | struct wl_listener new_popup; | ||
141 | struct wl_listener unmap; | ||
142 | struct wl_listener destroy; | ||
143 | }; | ||
144 | |||
145 | const char *view_get_title(struct sway_view *view); | ||
146 | |||
147 | const char *view_get_app_id(struct sway_view *view); | ||
148 | |||
149 | const char *view_get_class(struct sway_view *view); | ||
150 | |||
151 | const char *view_get_instance(struct sway_view *view); | ||
152 | |||
153 | void view_configure(struct sway_view *view, double ox, double oy, int width, | ||
154 | int height); | ||
155 | |||
156 | void view_set_activated(struct sway_view *view, bool activated); | ||
157 | |||
158 | void view_close(struct sway_view *view); | ||
159 | |||
160 | void view_damage(struct sway_view *view, bool whole); | ||
161 | |||
162 | void view_for_each_surface(struct sway_view *view, | ||
163 | wlr_surface_iterator_func_t iterator, void *user_data); | ||
164 | |||
165 | // view implementation | ||
166 | |||
167 | void view_init(struct sway_view *view, enum sway_view_type type, | ||
168 | const struct sway_view_impl *impl); | ||
169 | |||
170 | void view_destroy(struct sway_view *view); | ||
171 | |||
172 | void view_map(struct sway_view *view, struct wlr_surface *wlr_surface); | ||
173 | |||
174 | void view_unmap(struct sway_view *view); | ||
175 | |||
176 | void view_update_position(struct sway_view *view, double ox, double oy); | ||
177 | |||
178 | void view_update_size(struct sway_view *view, int width, int height); | ||
179 | |||
180 | void view_child_init(struct sway_view_child *child, | ||
181 | const struct sway_view_child_impl *impl, struct sway_view *view, | ||
182 | struct wlr_surface *surface); | ||
183 | |||
184 | void view_child_destroy(struct sway_view_child *child); | ||
185 | |||
186 | #endif | ||