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.h129
1 files changed, 42 insertions, 87 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index e071e6c9..3e5a9bfe 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -1,8 +1,9 @@
1#ifndef _SWAY_VIEW_H 1#ifndef _SWAY_VIEW_H
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_surface.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,16 +80,10 @@ 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
97 // when a transaction is applied.
98 struct wlr_box saved_geometry;
99
100 struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel; 87 struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel;
101 struct wl_listener foreign_activate_request; 88 struct wl_listener foreign_activate_request;
102 struct wl_listener foreign_fullscreen_request; 89 struct wl_listener foreign_fullscreen_request;
@@ -108,19 +95,16 @@ struct sway_view {
108 list_t *executed_criteria; // struct criteria * 95 list_t *executed_criteria; // struct criteria *
109 96
110 union { 97 union {
111 struct wlr_xdg_surface *wlr_xdg_surface; 98 struct wlr_xdg_toplevel *wlr_xdg_toplevel;
112#if HAVE_XWAYLAND 99#if HAVE_XWAYLAND
113 struct wlr_xwayland_surface *wlr_xwayland_surface; 100 struct wlr_xwayland_surface *wlr_xwayland_surface;
114#endif 101#endif
115 struct wlr_wl_shell_surface *wlr_wl_shell_surface;
116 }; 102 };
117 103
118 struct { 104 struct {
119 struct wl_signal unmap; 105 struct wl_signal unmap;
120 } events; 106 } events;
121 107
122 struct wl_listener surface_new_subsurface;
123
124 int max_render_time; // In milliseconds 108 int max_render_time; // In milliseconds
125 109
126 enum seat_config_shortcuts_inhibit shortcuts_inhibit; 110 enum seat_config_shortcuts_inhibit shortcuts_inhibit;
@@ -145,6 +129,8 @@ struct sway_xdg_shell_view {
145struct sway_xwayland_view { 129struct sway_xwayland_view {
146 struct sway_view view; 130 struct sway_view view;
147 131
132 struct wlr_scene_tree *surface_tree;
133
148 struct wl_listener commit; 134 struct wl_listener commit;
149 struct wl_listener request_move; 135 struct wl_listener request_move;
150 struct wl_listener request_resize; 136 struct wl_listener request_resize;
@@ -156,70 +142,46 @@ struct sway_xwayland_view {
156 struct wl_listener set_title; 142 struct wl_listener set_title;
157 struct wl_listener set_class; 143 struct wl_listener set_class;
158 struct wl_listener set_role; 144 struct wl_listener set_role;
145 struct wl_listener set_startup_id;
159 struct wl_listener set_window_type; 146 struct wl_listener set_window_type;
160 struct wl_listener set_hints; 147 struct wl_listener set_hints;
161 struct wl_listener set_decorations; 148 struct wl_listener set_decorations;
149 struct wl_listener associate;
150 struct wl_listener dissociate;
162 struct wl_listener map; 151 struct wl_listener map;
163 struct wl_listener unmap; 152 struct wl_listener unmap;
164 struct wl_listener destroy; 153 struct wl_listener destroy;
165 struct wl_listener override_redirect; 154 struct wl_listener override_redirect;
155
156 struct wl_listener surface_tree_destroy;
166}; 157};
167 158
168struct sway_xwayland_unmanaged { 159struct sway_xwayland_unmanaged {
169 struct wlr_xwayland_surface *wlr_xwayland_surface; 160 struct wlr_xwayland_surface *wlr_xwayland_surface;
170 struct wl_list link;
171 161
172 int lx, ly; 162 struct wlr_scene_surface *surface_scene;
173 163
164 struct wl_listener request_activate;
174 struct wl_listener request_configure; 165 struct wl_listener request_configure;
175 struct wl_listener request_fullscreen; 166 struct wl_listener request_fullscreen;
176 struct wl_listener commit;
177 struct wl_listener set_geometry; 167 struct wl_listener set_geometry;
168 struct wl_listener associate;
169 struct wl_listener dissociate;
178 struct wl_listener map; 170 struct wl_listener map;
179 struct wl_listener unmap; 171 struct wl_listener unmap;
180 struct wl_listener destroy; 172 struct wl_listener destroy;
181 struct wl_listener override_redirect; 173 struct wl_listener override_redirect;
182}; 174};
183#endif 175#endif
184struct sway_view_child;
185
186struct sway_view_child_impl {
187 void (*get_root_coords)(struct sway_view_child *child, int *sx, int *sy);
188 void (*destroy)(struct sway_view_child *child);
189};
190
191/**
192 * A view child is a surface in the view tree, such as a subsurface or a popup.
193 */
194struct sway_view_child {
195 const struct sway_view_child_impl *impl;
196 struct wl_list link;
197
198 struct sway_view *view;
199 struct sway_view_child *parent;
200 struct wl_list children; // sway_view_child::link
201 struct wlr_surface *surface;
202 bool mapped;
203
204 struct wl_listener surface_commit;
205 struct wl_listener surface_new_subsurface;
206 struct wl_listener surface_map;
207 struct wl_listener surface_unmap;
208 struct wl_listener surface_destroy;
209 struct wl_listener view_unmap;
210};
211
212struct sway_subsurface {
213 struct sway_view_child child;
214
215 struct wl_listener destroy;
216};
217 176
218struct sway_xdg_popup { 177struct sway_xdg_popup {
219 struct sway_view_child child; 178 struct sway_view *view;
220 179
221 struct wlr_xdg_surface *wlr_xdg_surface; 180 struct wlr_scene_tree *scene_tree;
181 struct wlr_scene_tree *xdg_surface_tree;
182 struct wlr_xdg_popup *wlr_xdg_popup;
222 183
184 struct wl_listener surface_commit;
223 struct wl_listener new_popup; 185 struct wl_listener new_popup;
224 struct wl_listener destroy; 186 struct wl_listener destroy;
225}; 187};
@@ -269,7 +231,7 @@ void view_set_activated(struct sway_view *view, bool activated);
269/** 231/**
270 * Called when the view requests to be focused. 232 * Called when the view requests to be focused.
271 */ 233 */
272void view_request_activate(struct sway_view *view); 234void view_request_activate(struct sway_view *view, struct sway_seat *seat);
273 235
274/** 236/**
275 * If possible, instructs the client to change their decoration mode. 237 * If possible, instructs the client to change their decoration mode.
@@ -288,42 +250,31 @@ void view_close(struct sway_view *view);
288 250
289void view_close_popups(struct sway_view *view); 251void view_close_popups(struct sway_view *view);
290 252
291void view_damage_from(struct sway_view *view);
292
293/**
294 * Iterate all surfaces of a view (toplevels + popups).
295 */
296void view_for_each_surface(struct sway_view *view,
297 wlr_surface_iterator_func_t iterator, void *user_data);
298
299/**
300 * Iterate all popup surfaces of a view.
301 */
302void view_for_each_popup_surface(struct sway_view *view,
303 wlr_surface_iterator_func_t iterator, void *user_data);
304
305// view implementation 253// view implementation
306 254
307void view_init(struct sway_view *view, enum sway_view_type type, 255bool view_init(struct sway_view *view, enum sway_view_type type,
308 const struct sway_view_impl *impl); 256 const struct sway_view_impl *impl);
309 257
310void view_destroy(struct sway_view *view); 258void view_destroy(struct sway_view *view);
311 259
312void view_begin_destroy(struct sway_view *view); 260void view_begin_destroy(struct sway_view *view);
313 261
262/**
263 * Map a view, ie. make it visible in the tree.
264 *
265 * `fullscreen` should be set to true (and optionally `fullscreen_output`
266 * should be populated) if the view should be made fullscreen immediately.
267 *
268 * `decoration` should be set to true if the client prefers CSD. The client's
269 * preference may be ignored.
270 */
314void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, 271void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
315 bool fullscreen, struct wlr_output *fullscreen_output, bool decoration); 272 bool fullscreen, struct wlr_output *fullscreen_output, bool decoration);
316 273
317void view_unmap(struct sway_view *view); 274void view_unmap(struct sway_view *view);
318 275
319void view_update_size(struct sway_view *view, int width, int height); 276void view_update_size(struct sway_view *view);
320 277void view_center_and_clip_surface(struct sway_view *view);
321void view_child_init(struct sway_view_child *child,
322 const struct sway_view_child_impl *impl, struct sway_view *view,
323 struct wlr_surface *surface);
324
325void view_child_destroy(struct sway_view_child *child);
326
327 278
328struct sway_view *view_from_wlr_xdg_surface( 279struct sway_view *view_from_wlr_xdg_surface(
329 struct wlr_xdg_surface *xdg_surface); 280 struct wlr_xdg_surface *xdg_surface);
@@ -362,4 +313,8 @@ void view_save_buffer(struct sway_view *view);
362 313
363bool view_is_transient_for(struct sway_view *child, struct sway_view *ancestor); 314bool view_is_transient_for(struct sway_view *child, struct sway_view *ancestor);
364 315
316void view_assign_ctx(struct sway_view *view, struct launcher_ctx *ctx);
317
318void view_send_frame_done(struct sway_view *view);
319
365#endif 320#endif