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.h138
1 files changed, 55 insertions, 83 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index e071e6c9..7faacdcc 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,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;
@@ -108,19 +97,16 @@ struct sway_view {
108 list_t *executed_criteria; // struct criteria * 97 list_t *executed_criteria; // struct criteria *
109 98
110 union { 99 union {
111 struct wlr_xdg_surface *wlr_xdg_surface; 100 struct wlr_xdg_toplevel *wlr_xdg_toplevel;
112#if HAVE_XWAYLAND 101#if HAVE_XWAYLAND
113 struct wlr_xwayland_surface *wlr_xwayland_surface; 102 struct wlr_xwayland_surface *wlr_xwayland_surface;
114#endif 103#endif
115 struct wlr_wl_shell_surface *wlr_wl_shell_surface;
116 }; 104 };
117 105
118 struct { 106 struct {
119 struct wl_signal unmap; 107 struct wl_signal unmap;
120 } events; 108 } events;
121 109
122 struct wl_listener surface_new_subsurface;
123
124 int max_render_time; // In milliseconds 110 int max_render_time; // In milliseconds
125 111
126 enum seat_config_shortcuts_inhibit shortcuts_inhibit; 112 enum seat_config_shortcuts_inhibit shortcuts_inhibit;
@@ -145,6 +131,8 @@ struct sway_xdg_shell_view {
145struct sway_xwayland_view { 131struct sway_xwayland_view {
146 struct sway_view view; 132 struct sway_view view;
147 133
134 struct wlr_scene_tree *surface_tree;
135
148 struct wl_listener commit; 136 struct wl_listener commit;
149 struct wl_listener request_move; 137 struct wl_listener request_move;
150 struct wl_listener request_resize; 138 struct wl_listener request_resize;
@@ -156,71 +144,55 @@ struct sway_xwayland_view {
156 struct wl_listener set_title; 144 struct wl_listener set_title;
157 struct wl_listener set_class; 145 struct wl_listener set_class;
158 struct wl_listener set_role; 146 struct wl_listener set_role;
147 struct wl_listener set_startup_id;
159 struct wl_listener set_window_type; 148 struct wl_listener set_window_type;
160 struct wl_listener set_hints; 149 struct wl_listener set_hints;
161 struct wl_listener set_decorations; 150 struct wl_listener set_decorations;
151 struct wl_listener associate;
152 struct wl_listener dissociate;
162 struct wl_listener map; 153 struct wl_listener map;
163 struct wl_listener unmap; 154 struct wl_listener unmap;
164 struct wl_listener destroy; 155 struct wl_listener destroy;
165 struct wl_listener override_redirect; 156 struct wl_listener override_redirect;
157
158 struct wl_listener surface_tree_destroy;
166}; 159};
167 160
168struct sway_xwayland_unmanaged { 161struct sway_xwayland_unmanaged {
169 struct wlr_xwayland_surface *wlr_xwayland_surface; 162 struct wlr_xwayland_surface *wlr_xwayland_surface;
170 struct wl_list link;
171 163
172 int lx, ly; 164 struct wlr_scene_surface *surface_scene;
173 165
166 struct wl_listener request_activate;
174 struct wl_listener request_configure; 167 struct wl_listener request_configure;
175 struct wl_listener request_fullscreen; 168 struct wl_listener request_fullscreen;
176 struct wl_listener commit;
177 struct wl_listener set_geometry; 169 struct wl_listener set_geometry;
170 struct wl_listener associate;
171 struct wl_listener dissociate;
178 struct wl_listener map; 172 struct wl_listener map;
179 struct wl_listener unmap; 173 struct wl_listener unmap;
180 struct wl_listener destroy; 174 struct wl_listener destroy;
181 struct wl_listener override_redirect; 175 struct wl_listener override_redirect;
182}; 176};
183#endif 177#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 178
179struct sway_popup_desc {
180 struct wlr_scene_node *relative;
198 struct sway_view *view; 181 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}; 182};
217 183
218struct sway_xdg_popup { 184struct sway_xdg_popup {
219 struct sway_view_child child; 185 struct sway_view *view;
186
187 struct wlr_scene_tree *scene_tree;
188 struct wlr_scene_tree *xdg_surface_tree;
189 struct wlr_xdg_popup *wlr_xdg_popup;
220 190
221 struct wlr_xdg_surface *wlr_xdg_surface; 191 struct sway_popup_desc desc;
222 192
193 struct wl_listener surface_commit;
223 struct wl_listener new_popup; 194 struct wl_listener new_popup;
195 struct wl_listener reposition;
224 struct wl_listener destroy; 196 struct wl_listener destroy;
225}; 197};
226 198
@@ -269,7 +241,12 @@ void view_set_activated(struct sway_view *view, bool activated);
269/** 241/**
270 * Called when the view requests to be focused. 242 * Called when the view requests to be focused.
271 */ 243 */
272void 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);
273 250
274/** 251/**
275 * If possible, instructs the client to change their decoration mode. 252 * If possible, instructs the client to change their decoration mode.
@@ -288,42 +265,31 @@ void view_close(struct sway_view *view);
288 265
289void view_close_popups(struct sway_view *view); 266void view_close_popups(struct sway_view *view);
290 267
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 268// view implementation
306 269
307void view_init(struct sway_view *view, enum sway_view_type type, 270bool view_init(struct sway_view *view, enum sway_view_type type,
308 const struct sway_view_impl *impl); 271 const struct sway_view_impl *impl);
309 272
310void view_destroy(struct sway_view *view); 273void view_destroy(struct sway_view *view);
311 274
312void view_begin_destroy(struct sway_view *view); 275void view_begin_destroy(struct sway_view *view);
313 276
277/**
278 * Map a view, ie. make it visible in the tree.
279 *
280 * `fullscreen` should be set to true (and optionally `fullscreen_output`
281 * should be populated) if the view should be made fullscreen immediately.
282 *
283 * `decoration` should be set to true if the client prefers CSD. The client's
284 * preference may be ignored.
285 */
314void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, 286void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
315 bool fullscreen, struct wlr_output *fullscreen_output, bool decoration); 287 bool fullscreen, struct wlr_output *fullscreen_output, bool decoration);
316 288
317void view_unmap(struct sway_view *view); 289void view_unmap(struct sway_view *view);
318 290
319void view_update_size(struct sway_view *view, int width, int height); 291void view_update_size(struct sway_view *view);
320 292void 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 293
328struct sway_view *view_from_wlr_xdg_surface( 294struct sway_view *view_from_wlr_xdg_surface(
329 struct wlr_xdg_surface *xdg_surface); 295 struct wlr_xdg_surface *xdg_surface);
@@ -333,6 +299,8 @@ struct sway_view *view_from_wlr_xwayland_surface(
333#endif 299#endif
334struct sway_view *view_from_wlr_surface(struct wlr_surface *surface); 300struct sway_view *view_from_wlr_surface(struct wlr_surface *surface);
335 301
302void view_update_app_id(struct sway_view *view);
303
336/** 304/**
337 * 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.
338 * 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
@@ -362,4 +330,8 @@ void view_save_buffer(struct sway_view *view);
362 330
363bool 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);
364 332
333void view_assign_ctx(struct sway_view *view, struct launcher_ctx *ctx);
334
335void view_send_frame_done(struct sway_view *view);
336
365#endif 337#endif