aboutsummaryrefslogtreecommitdiffstats
path: root/include/sway/tree/view.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sway/tree/view.h')
-rw-r--r--include/sway/tree/view.h121
1 files changed, 42 insertions, 79 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 95708a04..7faacdcc 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -2,7 +2,8 @@
2#define _SWAY_VIEW_H 2#define _SWAY_VIEW_H
3#include <wayland-server-core.h> 3#include <wayland-server-core.h>
4#include <wlr/types/wlr_compositor.h> 4#include <wlr/types/wlr_compositor.h>
5#include "config.h" 5#include <wlr/types/wlr_scene.h>
6#include "sway/config.h"
6#if HAVE_XWAYLAND 7#if HAVE_XWAYLAND
7#include <wlr/xwayland.h> 8#include <wlr/xwayland.h>
8#endif 9#endif
@@ -45,10 +46,6 @@ struct sway_view_impl {
45 void (*set_fullscreen)(struct sway_view *view, bool fullscreen); 46 void (*set_fullscreen)(struct sway_view *view, bool fullscreen);
46 void (*set_resizing)(struct sway_view *view, bool resizing); 47 void (*set_resizing)(struct sway_view *view, bool resizing);
47 bool (*wants_floating)(struct sway_view *view); 48 bool (*wants_floating)(struct sway_view *view);
48 void (*for_each_surface)(struct sway_view *view,
49 wlr_surface_iterator_func_t iterator, void *user_data);
50 void (*for_each_popup_surface)(struct sway_view *view,
51 wlr_surface_iterator_func_t iterator, void *user_data);
52 bool (*is_transient_for)(struct sway_view *child, 49 bool (*is_transient_for)(struct sway_view *child,
53 struct sway_view *ancestor); 50 struct sway_view *ancestor);
54 void (*close)(struct sway_view *view); 51 void (*close)(struct sway_view *view);
@@ -56,24 +53,20 @@ struct sway_view_impl {
56 void (*destroy)(struct sway_view *view); 53 void (*destroy)(struct sway_view *view);
57}; 54};
58 55
59struct sway_saved_buffer {
60 struct wlr_client_buffer *buffer;
61 int x, y;
62 int width, height;
63 enum wl_output_transform transform;
64 struct wlr_fbox source_box;
65 struct wl_list link; // sway_view::saved_buffers
66};
67
68struct sway_view { 56struct sway_view {
69 enum sway_view_type type; 57 enum sway_view_type type;
70 const struct sway_view_impl *impl; 58 const struct sway_view_impl *impl;
71 59
60 struct wlr_scene_tree *scene_tree;
61 struct wlr_scene_tree *content_tree;
62 struct wlr_scene_tree *saved_surface_tree;
63
72 struct sway_container *container; // NULL if unmapped and transactions finished 64 struct sway_container *container; // NULL if unmapped and transactions finished
73 struct wlr_surface *surface; // NULL for unmapped views 65 struct wlr_surface *surface; // NULL for unmapped views
74 struct sway_xdg_decoration *xdg_decoration; 66 struct sway_xdg_decoration *xdg_decoration;
75 67
76 pid_t pid; 68 pid_t pid;
69 struct launcher_ctx *ctx;
77 70
78 // The size the view would want to be if it weren't tiled. 71 // The size the view would want to be if it weren't tiled.
79 // Used when changing a view from tiled to floating. 72 // Used when changing a view from tiled to floating.
@@ -87,15 +80,11 @@ struct sway_view {
87 bool allow_request_urgent; 80 bool allow_request_urgent;
88 struct wl_event_source *urgent_timer; 81 struct wl_event_source *urgent_timer;
89 82
90 struct wl_list saved_buffers; // sway_saved_buffer::link
91
92 // The geometry for whatever the client is committing, regardless of 83 // The geometry for whatever the client is committing, regardless of
93 // transaction state. Updated on every commit. 84 // transaction state. Updated on every commit.
94 struct wlr_box geometry; 85 struct wlr_box geometry;
95 86
96 // The "old" geometry during a transaction. Used to damage the old location 87 struct wlr_ext_foreign_toplevel_handle_v1 *ext_foreign_toplevel;
97 // when a transaction is applied.
98 struct wlr_box saved_geometry;
99 88
100 struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel; 89 struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel;
101 struct wl_listener foreign_activate_request; 90 struct wl_listener foreign_activate_request;
@@ -118,8 +107,6 @@ struct sway_view {
118 struct wl_signal unmap; 107 struct wl_signal unmap;
119 } events; 108 } events;
120 109
121 struct wl_listener surface_new_subsurface;
122
123 int max_render_time; // In milliseconds 110 int max_render_time; // In milliseconds
124 111
125 enum seat_config_shortcuts_inhibit shortcuts_inhibit; 112 enum seat_config_shortcuts_inhibit shortcuts_inhibit;
@@ -131,6 +118,7 @@ struct sway_xdg_shell_view {
131 struct wl_listener commit; 118 struct wl_listener commit;
132 struct wl_listener request_move; 119 struct wl_listener request_move;
133 struct wl_listener request_resize; 120 struct wl_listener request_resize;
121 struct wl_listener request_maximize;
134 struct wl_listener request_fullscreen; 122 struct wl_listener request_fullscreen;
135 struct wl_listener set_title; 123 struct wl_listener set_title;
136 struct wl_listener set_app_id; 124 struct wl_listener set_app_id;
@@ -143,6 +131,8 @@ struct sway_xdg_shell_view {
143struct sway_xwayland_view { 131struct sway_xwayland_view {
144 struct sway_view view; 132 struct sway_view view;
145 133
134 struct wlr_scene_tree *surface_tree;
135
146 struct wl_listener commit; 136 struct wl_listener commit;
147 struct wl_listener request_move; 137 struct wl_listener request_move;
148 struct wl_listener request_resize; 138 struct wl_listener request_resize;
@@ -154,72 +144,55 @@ struct sway_xwayland_view {
154 struct wl_listener set_title; 144 struct wl_listener set_title;
155 struct wl_listener set_class; 145 struct wl_listener set_class;
156 struct wl_listener set_role; 146 struct wl_listener set_role;
147 struct wl_listener set_startup_id;
157 struct wl_listener set_window_type; 148 struct wl_listener set_window_type;
158 struct wl_listener set_hints; 149 struct wl_listener set_hints;
159 struct wl_listener set_decorations; 150 struct wl_listener set_decorations;
151 struct wl_listener associate;
152 struct wl_listener dissociate;
160 struct wl_listener map; 153 struct wl_listener map;
161 struct wl_listener unmap; 154 struct wl_listener unmap;
162 struct wl_listener destroy; 155 struct wl_listener destroy;
163 struct wl_listener override_redirect; 156 struct wl_listener override_redirect;
157
158 struct wl_listener surface_tree_destroy;
164}; 159};
165 160
166struct sway_xwayland_unmanaged { 161struct sway_xwayland_unmanaged {
167 struct wlr_xwayland_surface *wlr_xwayland_surface; 162 struct wlr_xwayland_surface *wlr_xwayland_surface;
168 struct wl_list link;
169 163
170 int lx, ly; 164 struct wlr_scene_surface *surface_scene;
171 165
172 struct wl_listener request_activate; 166 struct wl_listener request_activate;
173 struct wl_listener request_configure; 167 struct wl_listener request_configure;
174 struct wl_listener request_fullscreen; 168 struct wl_listener request_fullscreen;
175 struct wl_listener commit;
176 struct wl_listener set_geometry; 169 struct wl_listener set_geometry;
170 struct wl_listener associate;
171 struct wl_listener dissociate;
177 struct wl_listener map; 172 struct wl_listener map;
178 struct wl_listener unmap; 173 struct wl_listener unmap;
179 struct wl_listener destroy; 174 struct wl_listener destroy;
180 struct wl_listener override_redirect; 175 struct wl_listener override_redirect;
181}; 176};
182#endif 177#endif
183struct sway_view_child;
184
185struct sway_view_child_impl {
186 void (*get_view_coords)(struct sway_view_child *child, int *sx, int *sy);
187 void (*destroy)(struct sway_view_child *child);
188};
189
190/**
191 * A view child is a surface in the view tree, such as a subsurface or a popup.
192 */
193struct sway_view_child {
194 const struct sway_view_child_impl *impl;
195 struct wl_list link;
196 178
179struct sway_popup_desc {
180 struct wlr_scene_node *relative;
197 struct sway_view *view; 181 struct sway_view *view;
198 struct sway_view_child *parent;
199 struct wl_list children; // sway_view_child::link
200 struct wlr_surface *surface;
201 bool mapped;
202
203 struct wl_listener surface_commit;
204 struct wl_listener surface_new_subsurface;
205 struct wl_listener surface_map;
206 struct wl_listener surface_unmap;
207 struct wl_listener surface_destroy;
208 struct wl_listener view_unmap;
209};
210
211struct sway_subsurface {
212 struct sway_view_child child;
213
214 struct wl_listener destroy;
215}; 182};
216 183
217struct sway_xdg_popup { 184struct sway_xdg_popup {
218 struct sway_view_child child; 185 struct sway_view *view;
219 186
187 struct wlr_scene_tree *scene_tree;
188 struct wlr_scene_tree *xdg_surface_tree;
220 struct wlr_xdg_popup *wlr_xdg_popup; 189 struct wlr_xdg_popup *wlr_xdg_popup;
221 190
191 struct sway_popup_desc desc;
192
193 struct wl_listener surface_commit;
222 struct wl_listener new_popup; 194 struct wl_listener new_popup;
195 struct wl_listener reposition;
223 struct wl_listener destroy; 196 struct wl_listener destroy;
224}; 197};
225 198
@@ -268,7 +241,12 @@ void view_set_activated(struct sway_view *view, bool activated);
268/** 241/**
269 * Called when the view requests to be focused. 242 * Called when the view requests to be focused.
270 */ 243 */
271void view_request_activate(struct sway_view *view); 244void view_request_activate(struct sway_view *view, struct sway_seat *seat);
245
246/*
247 * Called when the view requests urgent state
248 */
249void view_request_urgent(struct sway_view *view);
272 250
273/** 251/**
274 * If possible, instructs the client to change their decoration mode. 252 * If possible, instructs the client to change their decoration mode.
@@ -287,23 +265,9 @@ void view_close(struct sway_view *view);
287 265
288void view_close_popups(struct sway_view *view); 266void view_close_popups(struct sway_view *view);
289 267
290void view_damage_from(struct sway_view *view);
291
292/**
293 * Iterate all surfaces of a view (toplevels + popups).
294 */
295void view_for_each_surface(struct sway_view *view,
296 wlr_surface_iterator_func_t iterator, void *user_data);
297
298/**
299 * Iterate all popup surfaces of a view.
300 */
301void view_for_each_popup_surface(struct sway_view *view,
302 wlr_surface_iterator_func_t iterator, void *user_data);
303
304// view implementation 268// view implementation
305 269
306void view_init(struct sway_view *view, enum sway_view_type type, 270bool view_init(struct sway_view *view, enum sway_view_type type,
307 const struct sway_view_impl *impl); 271 const struct sway_view_impl *impl);
308 272
309void view_destroy(struct sway_view *view); 273void view_destroy(struct sway_view *view);
@@ -325,14 +289,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
325void view_unmap(struct sway_view *view); 289void view_unmap(struct sway_view *view);
326 290
327void view_update_size(struct sway_view *view); 291void view_update_size(struct sway_view *view);
328void view_center_surface(struct sway_view *view); 292void view_center_and_clip_surface(struct sway_view *view);
329
330void view_child_init(struct sway_view_child *child,
331 const struct sway_view_child_impl *impl, struct sway_view *view,
332 struct wlr_surface *surface);
333
334void view_child_destroy(struct sway_view_child *child);
335
336 293
337struct sway_view *view_from_wlr_xdg_surface( 294struct sway_view *view_from_wlr_xdg_surface(
338 struct wlr_xdg_surface *xdg_surface); 295 struct wlr_xdg_surface *xdg_surface);
@@ -342,6 +299,8 @@ struct sway_view *view_from_wlr_xwayland_surface(
342#endif 299#endif
343struct sway_view *view_from_wlr_surface(struct wlr_surface *surface); 300struct sway_view *view_from_wlr_surface(struct wlr_surface *surface);
344 301
302void view_update_app_id(struct sway_view *view);
303
345/** 304/**
346 * Re-read the view's title property and update any relevant title bars. 305 * Re-read the view's title property and update any relevant title bars.
347 * The force argument makes it recreate the title bars even if the title hasn't 306 * The force argument makes it recreate the title bars even if the title hasn't
@@ -371,4 +330,8 @@ void view_save_buffer(struct sway_view *view);
371 330
372bool view_is_transient_for(struct sway_view *child, struct sway_view *ancestor); 331bool view_is_transient_for(struct sway_view *child, struct sway_view *ancestor);
373 332
333void view_assign_ctx(struct sway_view *view, struct launcher_ctx *ctx);
334
335void view_send_frame_done(struct sway_view *view);
336
374#endif 337#endif