aboutsummaryrefslogtreecommitdiffstats
path: root/include/sway
diff options
context:
space:
mode:
Diffstat (limited to 'include/sway')
-rw-r--r--include/sway/commands.h20
-rw-r--r--include/sway/config.h119
-rw-r--r--include/sway/criteria.h10
-rw-r--r--include/sway/desktop.h13
-rw-r--r--include/sway/desktop/idle_inhibit_v1.h12
-rw-r--r--include/sway/desktop/launcher.h40
-rw-r--r--include/sway/desktop/transaction.h14
-rw-r--r--include/sway/input/cursor.h17
-rw-r--r--include/sway/input/input-manager.h8
-rw-r--r--include/sway/input/keyboard.h1
-rw-r--r--include/sway/input/libinput.h5
-rw-r--r--include/sway/input/seat.h121
-rw-r--r--include/sway/input/switch.h1
-rw-r--r--include/sway/input/tablet.h3
-rw-r--r--include/sway/input/text_input.h8
-rw-r--r--include/sway/input/text_input_popup.h20
-rw-r--r--include/sway/ipc-json.h2
-rw-r--r--include/sway/ipc-server.h1
-rw-r--r--include/sway/layers.h52
-rw-r--r--include/sway/output.h109
-rw-r--r--include/sway/scene_descriptor.h33
-rw-r--r--include/sway/server.h99
-rw-r--r--include/sway/surface.h18
-rw-r--r--include/sway/sway_text_node.h28
-rw-r--r--include/sway/swaynag.h3
-rw-r--r--include/sway/tree/container.h109
-rw-r--r--include/sway/tree/node.h13
-rw-r--r--include/sway/tree/root.h56
-rw-r--r--include/sway/tree/view.h149
-rw-r--r--include/sway/tree/workspace.h8
-rw-r--r--include/sway/xdg_decoration.h2
31 files changed, 653 insertions, 441 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 29a6bec3..27058587 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -3,13 +3,14 @@
3 3
4#include <wlr/util/edges.h> 4#include <wlr/util/edges.h>
5#include "config.h" 5#include "config.h"
6#include "stringop.h"
6 7
7struct sway_container; 8struct sway_container;
8 9
9typedef struct cmd_results *sway_cmd(int argc, char **argv); 10typedef struct cmd_results *sway_cmd(int argc, char **argv);
10 11
11struct cmd_handler { 12struct cmd_handler {
12 char *command; 13 const char *command;
13 sway_cmd *handle; 14 sway_cmd *handle;
14}; 15};
15 16
@@ -46,7 +47,7 @@ enum expected_args {
46struct cmd_results *checkarg(int argc, const char *name, 47struct cmd_results *checkarg(int argc, const char *name,
47 enum expected_args type, int val); 48 enum expected_args type, int val);
48 49
49const struct cmd_handler *find_handler(char *line, 50const struct cmd_handler *find_handler(const char *line,
50 const struct cmd_handler *cmd_handlers, size_t handlers_size); 51 const struct cmd_handler *cmd_handlers, size_t handlers_size);
51 52
52/** 53/**
@@ -76,7 +77,7 @@ struct cmd_results *config_commands_command(char *exec);
76/** 77/**
77 * Allocates a cmd_results object. 78 * Allocates a cmd_results object.
78 */ 79 */
79struct cmd_results *cmd_results_new(enum cmd_status status, const char *error, ...); 80struct cmd_results *cmd_results_new(enum cmd_status status, const char *error, ...) _SWAY_ATTRIB_PRINTF(2, 3);
80/** 81/**
81 * Frees a cmd_results object. 82 * Frees a cmd_results object.
82 */ 83 */
@@ -106,12 +107,14 @@ sway_cmd cmd_exec_process;
106sway_cmd cmd_assign; 107sway_cmd cmd_assign;
107sway_cmd cmd_bar; 108sway_cmd cmd_bar;
108sway_cmd cmd_bindcode; 109sway_cmd cmd_bindcode;
110sway_cmd cmd_bindgesture;
109sway_cmd cmd_bindswitch; 111sway_cmd cmd_bindswitch;
110sway_cmd cmd_bindsym; 112sway_cmd cmd_bindsym;
111sway_cmd cmd_border; 113sway_cmd cmd_border;
112sway_cmd cmd_client_noop; 114sway_cmd cmd_client_noop;
113sway_cmd cmd_client_focused; 115sway_cmd cmd_client_focused;
114sway_cmd cmd_client_focused_inactive; 116sway_cmd cmd_client_focused_inactive;
117sway_cmd cmd_client_focused_tab_title;
115sway_cmd cmd_client_unfocused; 118sway_cmd cmd_client_unfocused;
116sway_cmd cmd_client_urgent; 119sway_cmd cmd_client_urgent;
117sway_cmd cmd_client_placeholder; 120sway_cmd cmd_client_placeholder;
@@ -157,12 +160,11 @@ sway_cmd cmd_new_float;
157sway_cmd cmd_new_window; 160sway_cmd cmd_new_window;
158sway_cmd cmd_nop; 161sway_cmd cmd_nop;
159sway_cmd cmd_opacity; 162sway_cmd cmd_opacity;
160sway_cmd cmd_new_float;
161sway_cmd cmd_new_window;
162sway_cmd cmd_no_focus; 163sway_cmd cmd_no_focus;
163sway_cmd cmd_output; 164sway_cmd cmd_output;
164sway_cmd cmd_permit; 165sway_cmd cmd_permit;
165sway_cmd cmd_popup_during_fullscreen; 166sway_cmd cmd_popup_during_fullscreen;
167sway_cmd cmd_primary_selection;
166sway_cmd cmd_reject; 168sway_cmd cmd_reject;
167sway_cmd cmd_reload; 169sway_cmd cmd_reload;
168sway_cmd cmd_rename; 170sway_cmd cmd_rename;
@@ -190,6 +192,7 @@ sway_cmd cmd_titlebar_border_thickness;
190sway_cmd cmd_titlebar_padding; 192sway_cmd cmd_titlebar_padding;
191sway_cmd cmd_unbindcode; 193sway_cmd cmd_unbindcode;
192sway_cmd cmd_unbindswitch; 194sway_cmd cmd_unbindswitch;
195sway_cmd cmd_unbindgesture;
193sway_cmd cmd_unbindsym; 196sway_cmd cmd_unbindsym;
194sway_cmd cmd_unmark; 197sway_cmd cmd_unmark;
195sway_cmd cmd_urgent; 198sway_cmd cmd_urgent;
@@ -249,6 +252,7 @@ sway_cmd input_cmd_click_method;
249sway_cmd input_cmd_drag; 252sway_cmd input_cmd_drag;
250sway_cmd input_cmd_drag_lock; 253sway_cmd input_cmd_drag_lock;
251sway_cmd input_cmd_dwt; 254sway_cmd input_cmd_dwt;
255sway_cmd input_cmd_dwtp;
252sway_cmd input_cmd_events; 256sway_cmd input_cmd_events;
253sway_cmd input_cmd_left_handed; 257sway_cmd input_cmd_left_handed;
254sway_cmd input_cmd_map_from_region; 258sway_cmd input_cmd_map_from_region;
@@ -257,10 +261,12 @@ sway_cmd input_cmd_map_to_region;
257sway_cmd input_cmd_middle_emulation; 261sway_cmd input_cmd_middle_emulation;
258sway_cmd input_cmd_natural_scroll; 262sway_cmd input_cmd_natural_scroll;
259sway_cmd input_cmd_pointer_accel; 263sway_cmd input_cmd_pointer_accel;
264sway_cmd input_cmd_rotation_angle;
260sway_cmd input_cmd_scroll_factor; 265sway_cmd input_cmd_scroll_factor;
261sway_cmd input_cmd_repeat_delay; 266sway_cmd input_cmd_repeat_delay;
262sway_cmd input_cmd_repeat_rate; 267sway_cmd input_cmd_repeat_rate;
263sway_cmd input_cmd_scroll_button; 268sway_cmd input_cmd_scroll_button;
269sway_cmd input_cmd_scroll_button_lock;
264sway_cmd input_cmd_scroll_method; 270sway_cmd input_cmd_scroll_method;
265sway_cmd input_cmd_tap; 271sway_cmd input_cmd_tap;
266sway_cmd input_cmd_tap_button_map; 272sway_cmd input_cmd_tap_button_map;
@@ -282,12 +288,16 @@ sway_cmd output_cmd_dpms;
282sway_cmd output_cmd_enable; 288sway_cmd output_cmd_enable;
283sway_cmd output_cmd_max_render_time; 289sway_cmd output_cmd_max_render_time;
284sway_cmd output_cmd_mode; 290sway_cmd output_cmd_mode;
291sway_cmd output_cmd_modeline;
285sway_cmd output_cmd_position; 292sway_cmd output_cmd_position;
293sway_cmd output_cmd_power;
294sway_cmd output_cmd_render_bit_depth;
286sway_cmd output_cmd_scale; 295sway_cmd output_cmd_scale;
287sway_cmd output_cmd_scale_filter; 296sway_cmd output_cmd_scale_filter;
288sway_cmd output_cmd_subpixel; 297sway_cmd output_cmd_subpixel;
289sway_cmd output_cmd_toggle; 298sway_cmd output_cmd_toggle;
290sway_cmd output_cmd_transform; 299sway_cmd output_cmd_transform;
300sway_cmd output_cmd_unplug;
291 301
292sway_cmd seat_cmd_attach; 302sway_cmd seat_cmd_attach;
293sway_cmd seat_cmd_cursor; 303sway_cmd seat_cmd_cursor;
diff --git a/include/sway/config.h b/include/sway/config.h
index b8327e9c..5ccc3e77 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -8,13 +8,17 @@
8#include <wlr/types/wlr_tablet_tool.h> 8#include <wlr/types/wlr_tablet_tool.h>
9#include <wlr/util/box.h> 9#include <wlr/util/box.h>
10#include <xkbcommon/xkbcommon.h> 10#include <xkbcommon/xkbcommon.h>
11#include <xf86drmMode.h>
11#include "../include/config.h" 12#include "../include/config.h"
13#include "gesture.h"
12#include "list.h" 14#include "list.h"
15#include "stringop.h"
13#include "swaynag.h" 16#include "swaynag.h"
14#include "tree/container.h" 17#include "tree/container.h"
15#include "sway/input/tablet.h" 18#include "sway/input/tablet.h"
16#include "sway/tree/root.h" 19#include "sway/tree/root.h"
17#include "wlr-layer-shell-unstable-v1-protocol.h" 20#include "wlr-layer-shell-unstable-v1-protocol.h"
21#include <pango/pangocairo.h>
18 22
19// TODO: Refactor this shit 23// TODO: Refactor this shit
20 24
@@ -31,7 +35,8 @@ enum binding_input_type {
31 BINDING_KEYSYM, 35 BINDING_KEYSYM,
32 BINDING_MOUSECODE, 36 BINDING_MOUSECODE,
33 BINDING_MOUSESYM, 37 BINDING_MOUSESYM,
34 BINDING_SWITCH 38 BINDING_SWITCH, // dummy, only used to call seat_execute_command
39 BINDING_GESTURE // dummy, only used to call seat_execute_command
35}; 40};
36 41
37enum binding_flags { 42enum binding_flags {
@@ -44,10 +49,11 @@ enum binding_flags {
44 BINDING_RELOAD = 1 << 6, // switch only; (re)trigger binding on reload 49 BINDING_RELOAD = 1 << 6, // switch only; (re)trigger binding on reload
45 BINDING_INHIBITED = 1 << 7, // keyboard only: ignore shortcut inhibitor 50 BINDING_INHIBITED = 1 << 7, // keyboard only: ignore shortcut inhibitor
46 BINDING_NOREPEAT = 1 << 8, // keyboard only; do not trigger when repeating a held key 51 BINDING_NOREPEAT = 1 << 8, // keyboard only; do not trigger when repeating a held key
52 BINDING_EXACT = 1 << 9, // gesture only; only trigger on exact match
47}; 53};
48 54
49/** 55/**
50 * A key binding and an associated command. 56 * A key (or mouse) binding and an associated command.
51 */ 57 */
52struct sway_binding { 58struct sway_binding {
53 enum binding_input_type type; 59 enum binding_input_type type;
@@ -61,12 +67,10 @@ struct sway_binding {
61 char *command; 67 char *command;
62}; 68};
63 69
64/** 70enum sway_switch_trigger {
65 * A mouse binding and an associated command. 71 SWAY_SWITCH_TRIGGER_OFF,
66 */ 72 SWAY_SWITCH_TRIGGER_ON,
67struct sway_mouse_binding { 73 SWAY_SWITCH_TRIGGER_TOGGLE,
68 uint32_t button;
69 char *command;
70}; 74};
71 75
72/** 76/**
@@ -74,12 +78,22 @@ struct sway_mouse_binding {
74 */ 78 */
75struct sway_switch_binding { 79struct sway_switch_binding {
76 enum wlr_switch_type type; 80 enum wlr_switch_type type;
77 enum wlr_switch_state state; 81 enum sway_switch_trigger trigger;
78 uint32_t flags; 82 uint32_t flags;
79 char *command; 83 char *command;
80}; 84};
81 85
82/** 86/**
87 * A gesture binding and an associated command.
88 */
89struct sway_gesture_binding {
90 char *input;
91 uint32_t flags;
92 struct gesture gesture;
93 char *command;
94};
95
96/**
83 * Focus on window activation. 97 * Focus on window activation.
84 */ 98 */
85enum sway_fowa { 99enum sway_fowa {
@@ -98,6 +112,7 @@ struct sway_mode {
98 list_t *keycode_bindings; 112 list_t *keycode_bindings;
99 list_t *mouse_bindings; 113 list_t *mouse_bindings;
100 list_t *switch_bindings; 114 list_t *switch_bindings;
115 list_t *gesture_bindings;
101 bool pango; 116 bool pango;
102}; 117};
103 118
@@ -136,14 +151,17 @@ struct input_config {
136 int drag; 151 int drag;
137 int drag_lock; 152 int drag_lock;
138 int dwt; 153 int dwt;
154 int dwtp;
139 int left_handed; 155 int left_handed;
140 int middle_emulation; 156 int middle_emulation;
141 int natural_scroll; 157 int natural_scroll;
142 float pointer_accel; 158 float pointer_accel;
159 float rotation_angle;
143 float scroll_factor; 160 float scroll_factor;
144 int repeat_delay; 161 int repeat_delay;
145 int repeat_rate; 162 int repeat_rate;
146 int scroll_button; 163 int scroll_button;
164 int scroll_button_lock;
147 int scroll_method; 165 int scroll_method;
148 int send_events; 166 int send_events;
149 int tap; 167 int tap;
@@ -233,12 +251,6 @@ struct seat_config {
233 } xcursor_theme; 251 } xcursor_theme;
234}; 252};
235 253
236enum config_dpms {
237 DPMS_IGNORE,
238 DPMS_ON,
239 DPMS_OFF,
240};
241
242enum scale_filter_mode { 254enum scale_filter_mode {
243 SCALE_FILTER_DEFAULT, // the default is currently smart 255 SCALE_FILTER_DEFAULT, // the default is currently smart
244 SCALE_FILTER_LINEAR, 256 SCALE_FILTER_LINEAR,
@@ -246,6 +258,12 @@ enum scale_filter_mode {
246 SCALE_FILTER_SMART, 258 SCALE_FILTER_SMART,
247}; 259};
248 260
261enum render_bit_depth {
262 RENDER_BIT_DEPTH_DEFAULT, // the default is currently 8
263 RENDER_BIT_DEPTH_8,
264 RENDER_BIT_DEPTH_10,
265};
266
249/** 267/**
250 * Size and position configuration for a particular output. 268 * Size and position configuration for a particular output.
251 * 269 *
@@ -254,9 +272,11 @@ enum scale_filter_mode {
254struct output_config { 272struct output_config {
255 char *name; 273 char *name;
256 int enabled; 274 int enabled;
275 int power;
257 int width, height; 276 int width, height;
258 float refresh_rate; 277 float refresh_rate;
259 int custom_mode; 278 int custom_mode;
279 drmModeModeInfo drm_mode;
260 int x, y; 280 int x, y;
261 float scale; 281 float scale;
262 enum scale_filter_mode scale_filter; 282 enum scale_filter_mode scale_filter;
@@ -264,11 +284,19 @@ struct output_config {
264 enum wl_output_subpixel subpixel; 284 enum wl_output_subpixel subpixel;
265 int max_render_time; // In milliseconds 285 int max_render_time; // In milliseconds
266 int adaptive_sync; 286 int adaptive_sync;
287 enum render_bit_depth render_bit_depth;
267 288
268 char *background; 289 char *background;
269 char *background_option; 290 char *background_option;
270 char *background_fallback; 291 char *background_fallback;
271 enum config_dpms dpms_state; 292};
293
294/**
295 * An output config pre-matched to an output
296 */
297struct matched_output_config {
298 struct sway_output *output;
299 struct output_config *config;
272}; 300};
273 301
274/** 302/**
@@ -281,6 +309,12 @@ struct side_gaps {
281 int left; 309 int left;
282}; 310};
283 311
312enum smart_gaps_mode {
313 SMART_GAPS_OFF,
314 SMART_GAPS_ON,
315 SMART_GAPS_INVERSE_OUTER,
316};
317
284/** 318/**
285 * Stores configuration for a workspace, regardless of whether the workspace 319 * Stores configuration for a workspace, regardless of whether the workspace
286 * exists. 320 * exists.
@@ -416,14 +450,6 @@ enum sway_popup_during_fullscreen {
416 POPUP_LEAVE, 450 POPUP_LEAVE,
417}; 451};
418 452
419enum command_context {
420 CONTEXT_CONFIG = 1 << 0,
421 CONTEXT_BINDING = 1 << 1,
422 CONTEXT_IPC = 1 << 2,
423 CONTEXT_CRITERIA = 1 << 3,
424 CONTEXT_ALL = 0xFFFFFFFF,
425};
426
427enum focus_follows_mouse_mode { 453enum focus_follows_mouse_mode {
428 FOLLOWS_NO, 454 FOLLOWS_NO,
429 FOLLOWS_YES, 455 FOLLOWS_YES,
@@ -485,9 +511,10 @@ struct sway_config {
485 char *floating_scroll_right_cmd; 511 char *floating_scroll_right_cmd;
486 enum sway_container_layout default_orientation; 512 enum sway_container_layout default_orientation;
487 enum sway_container_layout default_layout; 513 enum sway_container_layout default_layout;
488 char *font; 514 char *font; // Used for IPC.
489 size_t font_height; 515 PangoFontDescription *font_description; // Used internally for rendering and validating.
490 size_t font_baseline; 516 int font_height;
517 int font_baseline;
491 bool pango_markup; 518 bool pango_markup;
492 int titlebar_border_thickness; 519 int titlebar_border_thickness;
493 int titlebar_h_padding; 520 int titlebar_h_padding;
@@ -514,11 +541,12 @@ struct sway_config {
514 bool auto_back_and_forth; 541 bool auto_back_and_forth;
515 bool show_marks; 542 bool show_marks;
516 enum alignment title_align; 543 enum alignment title_align;
544 bool primary_selection;
517 545
518 bool tiling_drag; 546 bool tiling_drag;
519 int tiling_drag_threshold; 547 int tiling_drag_threshold;
520 548
521 bool smart_gaps; 549 enum smart_gaps_mode smart_gaps;
522 int gaps_inner; 550 int gaps_inner;
523 struct side_gaps gaps_outer; 551 struct side_gaps gaps_outer;
524 552
@@ -541,12 +569,15 @@ struct sway_config {
541 struct { 569 struct {
542 struct border_colors focused; 570 struct border_colors focused;
543 struct border_colors focused_inactive; 571 struct border_colors focused_inactive;
572 struct border_colors focused_tab_title;
544 struct border_colors unfocused; 573 struct border_colors unfocused;
545 struct border_colors urgent; 574 struct border_colors urgent;
546 struct border_colors placeholder; 575 struct border_colors placeholder;
547 float background[4]; 576 float background[4];
548 } border_colors; 577 } border_colors;
549 578
579 bool has_focused_tab_title;
580
550 // floating view 581 // floating view
551 int32_t floating_maximum_width; 582 int32_t floating_maximum_width;
552 int32_t floating_maximum_height; 583 int32_t floating_maximum_height;
@@ -604,7 +635,7 @@ void run_deferred_bindings(void);
604/** 635/**
605 * Adds a warning entry to the swaynag instance used for errors. 636 * Adds a warning entry to the swaynag instance used for errors.
606 */ 637 */
607void config_add_swaynag_warning(char *fmt, ...); 638void config_add_swaynag_warning(char *fmt, ...) _SWAY_ATTRIB_PRINTF(1, 2);
608 639
609/** 640/**
610 * Free config struct 641 * Free config struct
@@ -657,20 +688,25 @@ const char *sway_output_scale_filter_to_string(enum scale_filter_mode scale_filt
657 688
658struct output_config *new_output_config(const char *name); 689struct output_config *new_output_config(const char *name);
659 690
660void merge_output_config(struct output_config *dst, struct output_config *src); 691bool apply_output_configs(struct matched_output_config *configs,
692 size_t configs_len, bool test_only, bool degrade_to_off);
661 693
662bool apply_output_config(struct output_config *oc, struct sway_output *output); 694void apply_all_output_configs(void);
663 695
664bool test_output_config(struct output_config *oc, struct sway_output *output); 696void sort_output_configs_by_priority(struct matched_output_config *configs,
697 size_t configs_len);
665 698
666struct output_config *store_output_config(struct output_config *oc); 699/**
700 * store_output_config stores a new output config. An output may be matched by
701 * three different config types, in order of precedence: Identifier, name and
702 * wildcard. When storing a config type of lower precedence, assume that the
703 * user wants the config to take immediate effect by superseding (clearing) the
704 * same values from higher presedence configuration.
705 */
706void store_output_config(struct output_config *oc);
667 707
668struct output_config *find_output_config(struct sway_output *output); 708struct output_config *find_output_config(struct sway_output *output);
669 709
670void apply_output_config_to_outputs(struct output_config *oc);
671
672void reset_outputs(void);
673
674void free_output_config(struct output_config *oc); 710void free_output_config(struct output_config *oc);
675 711
676bool spawn_swaybg(void); 712bool spawn_swaybg(void);
@@ -681,6 +717,8 @@ void free_sway_binding(struct sway_binding *sb);
681 717
682void free_switch_binding(struct sway_switch_binding *binding); 718void free_switch_binding(struct sway_switch_binding *binding);
683 719
720void free_gesture_binding(struct sway_gesture_binding *binding);
721
684void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding); 722void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding);
685 723
686void load_swaybar(struct bar_config *bar); 724void load_swaybar(struct bar_config *bar);
@@ -696,14 +734,13 @@ void free_bar_binding(struct bar_binding *binding);
696void free_workspace_config(struct workspace_config *wsc); 734void free_workspace_config(struct workspace_config *wsc);
697 735
698/** 736/**
699 * Updates the value of config->font_height based on the max title height 737 * Updates the value of config->font_height based on the metrics for title's
700 * reported by each container. If recalculate is true, the containers will 738 * font as reported by pango.
701 * recalculate their heights before reporting.
702 * 739 *
703 * If the height has changed, all containers will be rearranged to take on the 740 * If the height has changed, all containers will be rearranged to take on the
704 * new size. 741 * new size.
705 */ 742 */
706void config_update_font_height(bool recalculate); 743void config_update_font_height(void);
707 744
708/** 745/**
709 * Convert bindsym into bindcode using the first configured layout. 746 * Convert bindsym into bindcode using the first configured layout.
diff --git a/include/sway/criteria.h b/include/sway/criteria.h
index ad8610cd..758d70ed 100644
--- a/include/sway/criteria.h
+++ b/include/sway/criteria.h
@@ -1,7 +1,8 @@
1#ifndef _SWAY_CRITERIA_H 1#ifndef _SWAY_CRITERIA_H
2#define _SWAY_CRITERIA_H 2#define _SWAY_CRITERIA_H
3 3
4#include <pcre.h> 4#define PCRE2_CODE_UNIT_WIDTH 8
5#include <pcre2.h>
5#include "config.h" 6#include "config.h"
6#include "list.h" 7#include "list.h"
7#include "tree/view.h" 8#include "tree/view.h"
@@ -15,13 +16,13 @@ enum criteria_type {
15}; 16};
16 17
17enum pattern_type { 18enum pattern_type {
18 PATTERN_PCRE, 19 PATTERN_PCRE2,
19 PATTERN_FOCUSED, 20 PATTERN_FOCUSED,
20}; 21};
21 22
22struct pattern { 23struct pattern {
23 enum pattern_type match_type; 24 enum pattern_type match_type;
24 pcre *regex; 25 pcre2_code *regex;
25}; 26};
26 27
27struct criteria { 28struct criteria {
@@ -35,13 +36,14 @@ struct criteria {
35 struct pattern *app_id; 36 struct pattern *app_id;
36 struct pattern *con_mark; 37 struct pattern *con_mark;
37 uint32_t con_id; // internal ID 38 uint32_t con_id; // internal ID
38#if HAVE_XWAYLAND 39#if WLR_HAS_XWAYLAND
39 struct pattern *class; 40 struct pattern *class;
40 uint32_t id; // X11 window ID 41 uint32_t id; // X11 window ID
41 struct pattern *instance; 42 struct pattern *instance;
42 struct pattern *window_role; 43 struct pattern *window_role;
43 enum atom_name window_type; 44 enum atom_name window_type;
44#endif 45#endif
46 bool all;
45 bool floating; 47 bool floating;
46 bool tiling; 48 bool tiling;
47 char urgent; // 'l' for latest or 'o' for oldest 49 char urgent; // 'l' for latest or 'o' for oldest
diff --git a/include/sway/desktop.h b/include/sway/desktop.h
deleted file mode 100644
index c969a76b..00000000
--- a/include/sway/desktop.h
+++ /dev/null
@@ -1,13 +0,0 @@
1#include <wlr/types/wlr_surface.h>
2
3struct sway_container;
4struct sway_view;
5
6void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
7 bool whole);
8
9void desktop_damage_whole_container(struct sway_container *con);
10
11void desktop_damage_box(struct wlr_box *box);
12
13void desktop_damage_view(struct sway_view *view);
diff --git a/include/sway/desktop/idle_inhibit_v1.h b/include/sway/desktop/idle_inhibit_v1.h
index 58d54c68..84cc666d 100644
--- a/include/sway/desktop/idle_inhibit_v1.h
+++ b/include/sway/desktop/idle_inhibit_v1.h
@@ -1,8 +1,6 @@
1#ifndef _SWAY_DESKTOP_IDLE_INHIBIT_V1_H 1#ifndef _SWAY_DESKTOP_IDLE_INHIBIT_V1_H
2#define _SWAY_DESKTOP_IDLE_INHIBIT_V1_H 2#define _SWAY_DESKTOP_IDLE_INHIBIT_V1_H
3#include <wlr/types/wlr_idle_inhibit_v1.h> 3#include <wlr/types/wlr_idle_inhibit_v1.h>
4#include <wlr/types/wlr_idle.h>
5#include "sway/server.h"
6 4
7enum sway_idle_inhibit_mode { 5enum sway_idle_inhibit_mode {
8 INHIBIT_IDLE_APPLICATION, // Application set inhibitor (when visible) 6 INHIBIT_IDLE_APPLICATION, // Application set inhibitor (when visible)
@@ -16,12 +14,9 @@ struct sway_idle_inhibit_manager_v1 {
16 struct wlr_idle_inhibit_manager_v1 *wlr_manager; 14 struct wlr_idle_inhibit_manager_v1 *wlr_manager;
17 struct wl_listener new_idle_inhibitor_v1; 15 struct wl_listener new_idle_inhibitor_v1;
18 struct wl_list inhibitors; 16 struct wl_list inhibitors;
19
20 struct wlr_idle *idle;
21}; 17};
22 18
23struct sway_idle_inhibitor_v1 { 19struct sway_idle_inhibitor_v1 {
24 struct sway_idle_inhibit_manager_v1 *manager;
25 struct wlr_idle_inhibitor_v1 *wlr_inhibitor; 20 struct wlr_idle_inhibitor_v1 *wlr_inhibitor;
26 struct sway_view *view; 21 struct sway_view *view;
27 enum sway_idle_inhibit_mode mode; 22 enum sway_idle_inhibit_mode mode;
@@ -33,8 +28,7 @@ struct sway_idle_inhibitor_v1 {
33bool sway_idle_inhibit_v1_is_active( 28bool sway_idle_inhibit_v1_is_active(
34 struct sway_idle_inhibitor_v1 *inhibitor); 29 struct sway_idle_inhibitor_v1 *inhibitor);
35 30
36void sway_idle_inhibit_v1_check_active( 31void sway_idle_inhibit_v1_check_active(void);
37 struct sway_idle_inhibit_manager_v1 *manager);
38 32
39void sway_idle_inhibit_v1_user_inhibitor_register(struct sway_view *view, 33void sway_idle_inhibit_v1_user_inhibitor_register(struct sway_view *view,
40 enum sway_idle_inhibit_mode mode); 34 enum sway_idle_inhibit_mode mode);
@@ -48,6 +42,6 @@ struct sway_idle_inhibitor_v1 *sway_idle_inhibit_v1_application_inhibitor_for_vi
48void sway_idle_inhibit_v1_user_inhibitor_destroy( 42void sway_idle_inhibit_v1_user_inhibitor_destroy(
49 struct sway_idle_inhibitor_v1 *inhibitor); 43 struct sway_idle_inhibitor_v1 *inhibitor);
50 44
51struct sway_idle_inhibit_manager_v1 *sway_idle_inhibit_manager_v1_create( 45bool sway_idle_inhibit_manager_v1_init(void);
52 struct wl_display *wl_display, struct wlr_idle *idle); 46
53#endif 47#endif
diff --git a/include/sway/desktop/launcher.h b/include/sway/desktop/launcher.h
new file mode 100644
index 00000000..412068a9
--- /dev/null
+++ b/include/sway/desktop/launcher.h
@@ -0,0 +1,40 @@
1#ifndef _SWAY_LAUNCHER_H
2#define _SWAY_LAUNCHER_H
3
4#include <stdlib.h>
5#include <wayland-server-core.h>
6#include "sway/input/seat.h"
7
8struct launcher_ctx {
9 pid_t pid;
10 char *fallback_name;
11 struct wlr_xdg_activation_token_v1 *token;
12 struct wl_listener token_destroy;
13 struct sway_seat *seat;
14 struct wl_listener seat_destroy;
15
16 bool activated;
17 bool had_focused_surface;
18
19 struct sway_node *node;
20 struct wl_listener node_destroy;
21
22 struct wl_list link; // sway_server::pending_launcher_ctxs
23};
24
25struct launcher_ctx *launcher_ctx_find_pid(pid_t pid);
26
27struct sway_workspace *launcher_ctx_get_workspace(struct launcher_ctx *ctx);
28
29void launcher_ctx_consume(struct launcher_ctx *ctx);
30
31void launcher_ctx_destroy(struct launcher_ctx *ctx);
32
33struct launcher_ctx *launcher_ctx_create_internal(void);
34
35struct launcher_ctx *launcher_ctx_create(
36 struct wlr_xdg_activation_token_v1 *token, struct sway_node *node);
37
38const char *launcher_ctx_get_token_name(struct launcher_ctx *ctx);
39
40#endif
diff --git a/include/sway/desktop/transaction.h b/include/sway/desktop/transaction.h
index 7dd58ba8..dd7edb7a 100644
--- a/include/sway/desktop/transaction.h
+++ b/include/sway/desktop/transaction.h
@@ -1,6 +1,8 @@
1#ifndef _SWAY_TRANSACTION_H 1#ifndef _SWAY_TRANSACTION_H
2#define _SWAY_TRANSACTION_H 2#define _SWAY_TRANSACTION_H
3#include <stdint.h> 3#include <stdint.h>
4#include <stdbool.h>
5#include <wlr/types/wlr_scene.h>
4 6
5/** 7/**
6 * Transactions enable us to perform atomic layout updates. 8 * Transactions enable us to perform atomic layout updates.
@@ -38,8 +40,11 @@ void transaction_commit_dirty_client(void);
38 * Notify the transaction system that a view is ready for the new layout. 40 * Notify the transaction system that a view is ready for the new layout.
39 * 41 *
40 * When all views in the transaction are ready, the layout will be applied. 42 * When all views in the transaction are ready, the layout will be applied.
43 *
44 * A success boolean is returned denoting that this part of the transaction is
45 * ready.
41 */ 46 */
42void transaction_notify_view_ready_by_serial(struct sway_view *view, 47bool transaction_notify_view_ready_by_serial(struct sway_view *view,
43 uint32_t serial); 48 uint32_t serial);
44 49
45/** 50/**
@@ -47,8 +52,13 @@ void transaction_notify_view_ready_by_serial(struct sway_view *view,
47 * identifying the instruction by geometry rather than by serial. 52 * identifying the instruction by geometry rather than by serial.
48 * 53 *
49 * This is used by xwayland views, as they don't have serials. 54 * This is used by xwayland views, as they don't have serials.
55 *
56 * A success boolean is returned denoting that this part of the transaction is
57 * ready.
50 */ 58 */
51void transaction_notify_view_ready_by_geometry(struct sway_view *view, 59bool transaction_notify_view_ready_by_geometry(struct sway_view *view,
52 double x, double y, int width, int height); 60 double x, double y, int width, int height);
53 61
62void arrange_popups(struct wlr_scene_tree *popups);
63
54#endif 64#endif
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h
index 7d66e699..527d0350 100644
--- a/include/sway/input/cursor.h
+++ b/include/sway/input/cursor.h
@@ -4,7 +4,7 @@
4#include <stdint.h> 4#include <stdint.h>
5#include <wlr/types/wlr_pointer_constraints_v1.h> 5#include <wlr/types/wlr_pointer_constraints_v1.h>
6#include <wlr/types/wlr_pointer_gestures_v1.h> 6#include <wlr/types/wlr_pointer_gestures_v1.h>
7#include <wlr/types/wlr_surface.h> 7#include <wlr/types/wlr_compositor.h>
8#include "sway/input/seat.h" 8#include "sway/input/seat.h"
9#include "config.h" 9#include "config.h"
10 10
@@ -35,7 +35,8 @@ struct sway_cursor {
35 pixman_region32_t confine; // invalid if active_constraint == NULL 35 pixman_region32_t confine; // invalid if active_constraint == NULL
36 bool active_confine_requires_warp; 36 bool active_confine_requires_warp;
37 37
38 struct wlr_pointer_gestures_v1 *pointer_gestures; 38 struct wl_listener hold_begin;
39 struct wl_listener hold_end;
39 struct wl_listener pinch_begin; 40 struct wl_listener pinch_begin;
40 struct wl_listener pinch_update; 41 struct wl_listener pinch_update;
41 struct wl_listener pinch_end; 42 struct wl_listener pinch_end;
@@ -51,6 +52,7 @@ struct sway_cursor {
51 52
52 struct wl_listener touch_down; 53 struct wl_listener touch_down;
53 struct wl_listener touch_up; 54 struct wl_listener touch_up;
55 struct wl_listener touch_cancel;
54 struct wl_listener touch_motion; 56 struct wl_listener touch_motion;
55 struct wl_listener touch_frame; 57 struct wl_listener touch_frame;
56 bool simulating_pointer_from_touch; 58 bool simulating_pointer_from_touch;
@@ -62,6 +64,7 @@ struct sway_cursor {
62 struct wl_listener tool_proximity; 64 struct wl_listener tool_proximity;
63 struct wl_listener tool_button; 65 struct wl_listener tool_button;
64 bool simulating_pointer_from_tool_tip; 66 bool simulating_pointer_from_tool_tip;
67 bool simulating_pointer_from_tool_button;
65 uint32_t tool_buttons; 68 uint32_t tool_buttons;
66 69
67 struct wl_listener request_set_cursor; 70 struct wl_listener request_set_cursor;
@@ -105,12 +108,16 @@ void cursor_unhide(struct sway_cursor *cursor);
105int cursor_get_timeout(struct sway_cursor *cursor); 108int cursor_get_timeout(struct sway_cursor *cursor);
106void cursor_notify_key_press(struct sway_cursor *cursor); 109void cursor_notify_key_press(struct sway_cursor *cursor);
107 110
111void pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
112 struct wlr_input_device *device, double dx, double dy,
113 double dx_unaccel, double dy_unaccel);
114
108void dispatch_cursor_button(struct sway_cursor *cursor, 115void dispatch_cursor_button(struct sway_cursor *cursor,
109 struct wlr_input_device *device, uint32_t time_msec, uint32_t button, 116 struct wlr_input_device *device, uint32_t time_msec, uint32_t button,
110 enum wlr_button_state state); 117 enum wl_pointer_button_state state);
111 118
112void dispatch_cursor_axis(struct sway_cursor *cursor, 119void dispatch_cursor_axis(struct sway_cursor *cursor,
113 struct wlr_event_pointer_axis *event); 120 struct wlr_pointer_axis_event *event);
114 121
115void cursor_set_image(struct sway_cursor *cursor, const char *image, 122void cursor_set_image(struct sway_cursor *cursor, const char *image,
116 struct wl_client *client); 123 struct wl_client *client);
@@ -138,4 +145,6 @@ uint32_t get_mouse_button(const char *name, char **error);
138 145
139const char *get_mouse_button_name(uint32_t button); 146const char *get_mouse_button_name(uint32_t button);
140 147
148void handle_request_set_cursor_shape(struct wl_listener *listener, void *data);
149
141#endif 150#endif
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h
index c9bd08f0..45c75199 100644
--- a/include/sway/input/input-manager.h
+++ b/include/sway/input/input-manager.h
@@ -1,10 +1,10 @@
1#ifndef _SWAY_INPUT_INPUT_MANAGER_H 1#ifndef _SWAY_INPUT_INPUT_MANAGER_H
2#define _SWAY_INPUT_INPUT_MANAGER_H 2#define _SWAY_INPUT_INPUT_MANAGER_H
3#include <libinput.h> 3#include <libinput.h>
4#include <wlr/types/wlr_input_inhibitor.h>
5#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h> 4#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h>
6#include <wlr/types/wlr_virtual_keyboard_v1.h> 5#include <wlr/types/wlr_virtual_keyboard_v1.h>
7#include <wlr/types/wlr_virtual_pointer_v1.h> 6#include <wlr/types/wlr_virtual_pointer_v1.h>
7#include <wlr/types/wlr_transient_seat_v1.h>
8#include "sway/server.h" 8#include "sway/server.h"
9#include "sway/config.h" 9#include "sway/config.h"
10#include "list.h" 10#include "list.h"
@@ -21,10 +21,11 @@ struct sway_input_manager {
21 struct wl_list devices; 21 struct wl_list devices;
22 struct wl_list seats; 22 struct wl_list seats;
23 23
24 struct wlr_input_inhibit_manager *inhibit;
25 struct wlr_keyboard_shortcuts_inhibit_manager_v1 *keyboard_shortcuts_inhibit; 24 struct wlr_keyboard_shortcuts_inhibit_manager_v1 *keyboard_shortcuts_inhibit;
26 struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard; 25 struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard;
27 struct wlr_virtual_pointer_manager_v1 *virtual_pointer; 26 struct wlr_virtual_pointer_manager_v1 *virtual_pointer;
27 struct wlr_pointer_gestures_v1 *pointer_gestures;
28 struct wlr_transient_seat_manager_v1 *transient_seat_manager;
28 29
29 struct wl_listener new_input; 30 struct wl_listener new_input;
30 struct wl_listener inhibit_activate; 31 struct wl_listener inhibit_activate;
@@ -32,6 +33,7 @@ struct sway_input_manager {
32 struct wl_listener keyboard_shortcuts_inhibit_new_inhibitor; 33 struct wl_listener keyboard_shortcuts_inhibit_new_inhibitor;
33 struct wl_listener virtual_keyboard_new; 34 struct wl_listener virtual_keyboard_new;
34 struct wl_listener virtual_pointer_new; 35 struct wl_listener virtual_pointer_new;
36 struct wl_listener transient_seat_create;
35}; 37};
36 38
37struct sway_input_manager *input_manager_create(struct sway_server *server); 39struct sway_input_manager *input_manager_create(struct sway_server *server);
@@ -44,7 +46,7 @@ void input_manager_configure_xcursor(void);
44 46
45void input_manager_apply_input_config(struct input_config *input_config); 47void input_manager_apply_input_config(struct input_config *input_config);
46 48
47void input_manager_configure_all_inputs(void); 49void input_manager_configure_all_input_mappings(void);
48 50
49void input_manager_reset_input(struct sway_input_device *input_device); 51void input_manager_reset_input(struct sway_input_device *input_device);
50 52
diff --git a/include/sway/input/keyboard.h b/include/sway/input/keyboard.h
index 2c61e5a7..571d9e6f 100644
--- a/include/sway/input/keyboard.h
+++ b/include/sway/input/keyboard.h
@@ -50,6 +50,7 @@ struct sway_shortcut_state {
50 50
51struct sway_keyboard { 51struct sway_keyboard {
52 struct sway_seat_device *seat_device; 52 struct sway_seat_device *seat_device;
53 struct wlr_keyboard *wlr;
53 54
54 struct xkb_keymap *keymap; 55 struct xkb_keymap *keymap;
55 xkb_layout_index_t effective_layout; 56 xkb_layout_index_t effective_layout;
diff --git a/include/sway/input/libinput.h b/include/sway/input/libinput.h
index 890d632e..1f84a8e3 100644
--- a/include/sway/input/libinput.h
+++ b/include/sway/input/libinput.h
@@ -2,7 +2,10 @@
2#define _SWAY_INPUT_LIBINPUT_H 2#define _SWAY_INPUT_LIBINPUT_H
3#include "sway/input/input-manager.h" 3#include "sway/input/input-manager.h"
4 4
5void sway_input_configure_libinput_device(struct sway_input_device *device); 5bool sway_input_configure_libinput_device(struct sway_input_device *device);
6
7void sway_input_configure_libinput_device_send_events(
8 struct sway_input_device *device);
6 9
7void sway_input_reset_libinput_device(struct sway_input_device *device); 10void sway_input_reset_libinput_device(struct sway_input_device *device);
8 11
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h
index 4118df66..428f9679 100644
--- a/include/sway/input/seat.h
+++ b/include/sway/input/seat.h
@@ -3,7 +3,9 @@
3 3
4#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h> 4#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h>
5#include <wlr/types/wlr_layer_shell_v1.h> 5#include <wlr/types/wlr_layer_shell_v1.h>
6#include <wlr/types/wlr_scene.h>
6#include <wlr/types/wlr_seat.h> 7#include <wlr/types/wlr_seat.h>
8#include <wlr/types/wlr_touch.h>
7#include <wlr/util/edges.h> 9#include <wlr/util/edges.h>
8#include "sway/config.h" 10#include "sway/config.h"
9#include "sway/input/input-manager.h" 11#include "sway/input/input-manager.h"
@@ -15,19 +17,41 @@ struct sway_seat;
15struct sway_seatop_impl { 17struct sway_seatop_impl {
16 void (*button)(struct sway_seat *seat, uint32_t time_msec, 18 void (*button)(struct sway_seat *seat, uint32_t time_msec,
17 struct wlr_input_device *device, uint32_t button, 19 struct wlr_input_device *device, uint32_t button,
18 enum wlr_button_state state); 20 enum wl_pointer_button_state state);
19 void (*pointer_motion)(struct sway_seat *seat, uint32_t time_msec); 21 void (*pointer_motion)(struct sway_seat *seat, uint32_t time_msec);
20 void (*pointer_axis)(struct sway_seat *seat, 22 void (*pointer_axis)(struct sway_seat *seat,
21 struct wlr_event_pointer_axis *event); 23 struct wlr_pointer_axis_event *event);
24 void (*hold_begin)(struct sway_seat *seat,
25 struct wlr_pointer_hold_begin_event *event);
26 void (*hold_end)(struct sway_seat *seat,
27 struct wlr_pointer_hold_end_event *event);
28 void (*pinch_begin)(struct sway_seat *seat,
29 struct wlr_pointer_pinch_begin_event *event);
30 void (*pinch_update)(struct sway_seat *seat,
31 struct wlr_pointer_pinch_update_event *event);
32 void (*pinch_end)(struct sway_seat *seat,
33 struct wlr_pointer_pinch_end_event *event);
34 void (*swipe_begin)(struct sway_seat *seat,
35 struct wlr_pointer_swipe_begin_event *event);
36 void (*swipe_update)(struct sway_seat *seat,
37 struct wlr_pointer_swipe_update_event *event);
38 void (*swipe_end)(struct sway_seat *seat,
39 struct wlr_pointer_swipe_end_event *event);
22 void (*rebase)(struct sway_seat *seat, uint32_t time_msec); 40 void (*rebase)(struct sway_seat *seat, uint32_t time_msec);
41 void (*touch_motion)(struct sway_seat *seat,
42 struct wlr_touch_motion_event *event, double lx, double ly);
43 void (*touch_up)(struct sway_seat *seat,
44 struct wlr_touch_up_event *event);
45 void (*touch_down)(struct sway_seat *seat,
46 struct wlr_touch_down_event *event, double lx, double ly);
47 void (*touch_cancel)(struct sway_seat *seat,
48 struct wlr_touch_cancel_event *event);
23 void (*tablet_tool_motion)(struct sway_seat *seat, 49 void (*tablet_tool_motion)(struct sway_seat *seat,
24 struct sway_tablet_tool *tool, uint32_t time_msec); 50 struct sway_tablet_tool *tool, uint32_t time_msec);
25 void (*tablet_tool_tip)(struct sway_seat *seat, struct sway_tablet_tool *tool, 51 void (*tablet_tool_tip)(struct sway_seat *seat, struct sway_tablet_tool *tool,
26 uint32_t time_msec, enum wlr_tablet_tool_tip_state state); 52 uint32_t time_msec, enum wlr_tablet_tool_tip_state state);
27 void (*end)(struct sway_seat *seat); 53 void (*end)(struct sway_seat *seat);
28 void (*unref)(struct sway_seat *seat, struct sway_container *con); 54 void (*unref)(struct sway_seat *seat, struct sway_container *con);
29 void (*render)(struct sway_seat *seat, struct sway_output *output,
30 pixman_region32_t *damage);
31 bool allow_set_cursor; 55 bool allow_set_cursor;
32}; 56};
33 57
@@ -50,19 +74,6 @@ struct sway_seat_node {
50 struct wl_listener destroy; 74 struct wl_listener destroy;
51}; 75};
52 76
53struct sway_drag_icon {
54 struct sway_seat *seat;
55 struct wlr_drag_icon *wlr_drag_icon;
56 struct wl_list link; // sway_root::drag_icons
57
58 double x, y; // in layout-local coordinates
59
60 struct wl_listener surface_commit;
61 struct wl_listener map;
62 struct wl_listener unmap;
63 struct wl_listener destroy;
64};
65
66struct sway_drag { 77struct sway_drag {
67 struct sway_seat *seat; 78 struct sway_seat *seat;
68 struct wlr_drag *wlr_drag; 79 struct wlr_drag *wlr_drag;
@@ -73,16 +84,23 @@ struct sway_seat {
73 struct wlr_seat *wlr_seat; 84 struct wlr_seat *wlr_seat;
74 struct sway_cursor *cursor; 85 struct sway_cursor *cursor;
75 86
87 // Seat scene tree structure
88 // - scene_tree
89 // - drag icons
90 // - drag icon 1
91 // - drag icon 2
92 // - seatop specific stuff
93 struct wlr_scene_tree *scene_tree;
94 struct wlr_scene_tree *drag_icons;
95
76 bool has_focus; 96 bool has_focus;
77 struct wl_list focus_stack; // list of containers in focus order 97 struct wl_list focus_stack; // list of containers in focus order
78 struct sway_workspace *workspace; 98 struct sway_workspace *workspace;
79 char *prev_workspace_name; // for workspace back_and_forth 99 char *prev_workspace_name; // for workspace back_and_forth
80 100
81 // If the focused layer is set, views cannot receive keyboard focus
82 struct wlr_layer_surface_v1 *focused_layer; 101 struct wlr_layer_surface_v1 *focused_layer;
83 102 // If the exclusive layer is set, views cannot receive keyboard focus
84 // If exclusive_client is set, no other clients will receive input events 103 bool has_exclusive_layer;
85 struct wl_client *exclusive_client;
86 104
87 // Last touch point 105 // Last touch point
88 int32_t touch_id; 106 int32_t touch_id;
@@ -106,6 +124,7 @@ struct sway_seat {
106 struct wl_listener start_drag; 124 struct wl_listener start_drag;
107 struct wl_listener request_set_selection; 125 struct wl_listener request_set_selection;
108 struct wl_listener request_set_primary_selection; 126 struct wl_listener request_set_primary_selection;
127 struct wl_listener destroy;
109 128
110 struct wl_list devices; // sway_seat_device::link 129 struct wl_list devices; // sway_seat_device::link
111 struct wl_list keyboard_groups; // sway_keyboard_group::link 130 struct wl_list keyboard_groups; // sway_keyboard_group::link
@@ -141,6 +160,9 @@ void seat_add_device(struct sway_seat *seat,
141void seat_configure_device(struct sway_seat *seat, 160void seat_configure_device(struct sway_seat *seat,
142 struct sway_input_device *device); 161 struct sway_input_device *device);
143 162
163void seat_configure_device_mapping(struct sway_seat *seat,
164 struct sway_input_device *input_device);
165
144void seat_reset_device(struct sway_seat *seat, 166void seat_reset_device(struct sway_seat *seat,
145 struct sway_input_device *input_device); 167 struct sway_input_device *input_device);
146 168
@@ -171,8 +193,7 @@ void seat_set_focus_surface(struct sway_seat *seat,
171void seat_set_focus_layer(struct sway_seat *seat, 193void seat_set_focus_layer(struct sway_seat *seat,
172 struct wlr_layer_surface_v1 *layer); 194 struct wlr_layer_surface_v1 *layer);
173 195
174void seat_set_exclusive_client(struct sway_seat *seat, 196void seat_unfocus_unless_client(struct sway_seat *seat, struct wl_client *client);
175 struct wl_client *client);
176 197
177struct sway_node *seat_get_focus(struct sway_seat *seat); 198struct sway_node *seat_get_focus(struct sway_seat *seat);
178 199
@@ -231,7 +252,7 @@ void seat_idle_notify_activity(struct sway_seat *seat,
231 252
232bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface); 253bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface);
233 254
234void drag_icon_update_position(struct sway_drag_icon *icon); 255void drag_icons_update_position(struct sway_seat *seat);
235 256
236enum wlr_edges find_resize_edge(struct sway_container *cont, 257enum wlr_edges find_resize_edge(struct sway_container *cont,
237 struct wlr_surface *surface, struct sway_cursor *cursor); 258 struct wlr_surface *surface, struct sway_cursor *cursor);
@@ -239,7 +260,13 @@ enum wlr_edges find_resize_edge(struct sway_container *cont,
239void seatop_begin_default(struct sway_seat *seat); 260void seatop_begin_default(struct sway_seat *seat);
240 261
241void seatop_begin_down(struct sway_seat *seat, struct sway_container *con, 262void seatop_begin_down(struct sway_seat *seat, struct sway_container *con,
242 uint32_t time_msec, int sx, int sy); 263 double sx, double sy);
264
265void seatop_begin_down_on_surface(struct sway_seat *seat,
266 struct wlr_surface *surface, double sx, double sy);
267
268void seatop_begin_touch_down(struct sway_seat *seat, struct wlr_surface *surface,
269 struct wlr_touch_down_event *event, double sx, double sy, double lx, double ly);
243 270
244void seatop_begin_move_floating(struct sway_seat *seat, 271void seatop_begin_move_floating(struct sway_seat *seat,
245 struct sway_container *con); 272 struct sway_container *con);
@@ -260,18 +287,18 @@ struct sway_container *seat_get_focus_inactive_floating(struct sway_seat *seat,
260 struct sway_workspace *workspace); 287 struct sway_workspace *workspace);
261 288
262void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec, 289void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec,
263 uint32_t button, enum wlr_button_state state); 290 uint32_t button, enum wl_pointer_button_state state);
264 291
265void seat_consider_warp_to_focus(struct sway_seat *seat); 292void seat_consider_warp_to_focus(struct sway_seat *seat);
266 293
267void seatop_button(struct sway_seat *seat, uint32_t time_msec, 294void seatop_button(struct sway_seat *seat, uint32_t time_msec,
268 struct wlr_input_device *device, uint32_t button, 295 struct wlr_input_device *device, uint32_t button,
269 enum wlr_button_state state); 296 enum wl_pointer_button_state state);
270 297
271void seatop_pointer_motion(struct sway_seat *seat, uint32_t time_msec); 298void seatop_pointer_motion(struct sway_seat *seat, uint32_t time_msec);
272 299
273void seatop_pointer_axis(struct sway_seat *seat, 300void seatop_pointer_axis(struct sway_seat *seat,
274 struct wlr_event_pointer_axis *event); 301 struct wlr_pointer_axis_event *event);
275 302
276void seatop_tablet_tool_tip(struct sway_seat *seat, 303void seatop_tablet_tool_tip(struct sway_seat *seat,
277 struct sway_tablet_tool *tool, uint32_t time_msec, 304 struct sway_tablet_tool *tool, uint32_t time_msec,
@@ -280,6 +307,37 @@ void seatop_tablet_tool_tip(struct sway_seat *seat,
280void seatop_tablet_tool_motion(struct sway_seat *seat, 307void seatop_tablet_tool_motion(struct sway_seat *seat,
281 struct sway_tablet_tool *tool, uint32_t time_msec); 308 struct sway_tablet_tool *tool, uint32_t time_msec);
282 309
310void seatop_hold_begin(struct sway_seat *seat,
311 struct wlr_pointer_hold_begin_event *event);
312void seatop_hold_end(struct sway_seat *seat,
313 struct wlr_pointer_hold_end_event *event);
314
315void seatop_pinch_begin(struct sway_seat *seat,
316 struct wlr_pointer_pinch_begin_event *event);
317void seatop_pinch_update(struct sway_seat *seat,
318 struct wlr_pointer_pinch_update_event *event);
319void seatop_pinch_end(struct sway_seat *seat,
320 struct wlr_pointer_pinch_end_event *event);
321
322void seatop_swipe_begin(struct sway_seat *seat,
323 struct wlr_pointer_swipe_begin_event *event);
324void seatop_swipe_update(struct sway_seat *seat,
325 struct wlr_pointer_swipe_update_event *event);
326void seatop_swipe_end(struct sway_seat *seat,
327 struct wlr_pointer_swipe_end_event *event);
328
329void seatop_touch_motion(struct sway_seat *seat,
330 struct wlr_touch_motion_event *event, double lx, double ly);
331
332void seatop_touch_up(struct sway_seat *seat,
333 struct wlr_touch_up_event *event);
334
335void seatop_touch_down(struct sway_seat *seat,
336 struct wlr_touch_down_event *event, double lx, double ly);
337
338void seatop_touch_cancel(struct sway_seat *seat,
339 struct wlr_touch_cancel_event *event);
340
283void seatop_rebase(struct sway_seat *seat, uint32_t time_msec); 341void seatop_rebase(struct sway_seat *seat, uint32_t time_msec);
284 342
285/** 343/**
@@ -294,13 +352,6 @@ void seatop_end(struct sway_seat *seat);
294 */ 352 */
295void seatop_unref(struct sway_seat *seat, struct sway_container *con); 353void seatop_unref(struct sway_seat *seat, struct sway_container *con);
296 354
297/**
298 * Instructs a seatop to render anything that it needs to render
299 * (eg. dropzone for move-tiling)
300 */
301void seatop_render(struct sway_seat *seat, struct sway_output *output,
302 pixman_region32_t *damage);
303
304bool seatop_allows_set_cursor(struct sway_seat *seat); 355bool seatop_allows_set_cursor(struct sway_seat *seat);
305 356
306/** 357/**
diff --git a/include/sway/input/switch.h b/include/sway/input/switch.h
index 213b471d..de6787b7 100644
--- a/include/sway/input/switch.h
+++ b/include/sway/input/switch.h
@@ -5,6 +5,7 @@
5 5
6struct sway_switch { 6struct sway_switch {
7 struct sway_seat_device *seat_device; 7 struct sway_seat_device *seat_device;
8 struct wlr_switch *wlr;
8 enum wlr_switch_state state; 9 enum wlr_switch_state state;
9 enum wlr_switch_type type; 10 enum wlr_switch_type type;
10 11
diff --git a/include/sway/input/tablet.h b/include/sway/input/tablet.h
index d7e4c242..2fa5db6d 100644
--- a/include/sway/input/tablet.h
+++ b/include/sway/input/tablet.h
@@ -32,6 +32,7 @@ struct sway_tablet_pad {
32 struct wl_list link; 32 struct wl_list link;
33 struct sway_seat_device *seat_device; 33 struct sway_seat_device *seat_device;
34 struct sway_tablet *tablet; 34 struct sway_tablet *tablet;
35 struct wlr_tablet_pad *wlr;
35 struct wlr_tablet_v2_tablet_pad *tablet_v2_pad; 36 struct wlr_tablet_v2_tablet_pad *tablet_v2_pad;
36 37
37 struct wl_listener attach; 38 struct wl_listener attach;
@@ -62,7 +63,7 @@ void sway_configure_tablet_pad(struct sway_tablet_pad *tablet_pad);
62 63
63void sway_tablet_pad_destroy(struct sway_tablet_pad *tablet_pad); 64void sway_tablet_pad_destroy(struct sway_tablet_pad *tablet_pad);
64 65
65void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad, 66void sway_tablet_pad_set_focus(struct sway_tablet_pad *tablet_pad,
66 struct wlr_surface *surface); 67 struct wlr_surface *surface);
67 68
68#endif 69#endif
diff --git a/include/sway/input/text_input.h b/include/sway/input/text_input.h
index 37744266..1993f928 100644
--- a/include/sway/input/text_input.h
+++ b/include/sway/input/text_input.h
@@ -3,13 +3,12 @@
3 3
4#include <wlr/types/wlr_text_input_v3.h> 4#include <wlr/types/wlr_text_input_v3.h>
5#include <wlr/types/wlr_input_method_v2.h> 5#include <wlr/types/wlr_input_method_v2.h>
6#include <wlr/types/wlr_surface.h> 6#include <wlr/types/wlr_compositor.h>
7#include "sway/input/seat.h"
8 7
9/** 8/**
10 * The relay structure manages the relationship between text-input and 9 * The relay structure manages the relationship between text-input and
11 * input_method interfaces on a given seat. Multiple text-input interfaces may 10 * input_method interfaces on a given seat. Multiple text-input interfaces may
12 * be bound to a relay, but at most one will be focused (reveiving events) at 11 * be bound to a relay, but at most one will be focused (receiving events) at
13 * a time. At most one input-method interface may be bound to the seat. The 12 * a time. At most one input-method interface may be bound to the seat. The
14 * relay manages life cycle of both sides. When both sides are present and 13 * relay manages life cycle of both sides. When both sides are present and
15 * focused, the relay passes messages between them. 14 * focused, the relay passes messages between them.
@@ -22,18 +21,21 @@ struct sway_input_method_relay {
22 struct sway_seat *seat; 21 struct sway_seat *seat;
23 22
24 struct wl_list text_inputs; // sway_text_input::link 23 struct wl_list text_inputs; // sway_text_input::link
24 struct wl_list input_popups; // sway_input_popup::link
25 struct wlr_input_method_v2 *input_method; // doesn't have to be present 25 struct wlr_input_method_v2 *input_method; // doesn't have to be present
26 26
27 struct wl_listener text_input_new; 27 struct wl_listener text_input_new;
28 28
29 struct wl_listener input_method_new; 29 struct wl_listener input_method_new;
30 struct wl_listener input_method_commit; 30 struct wl_listener input_method_commit;
31 struct wl_listener input_method_new_popup_surface;
31 struct wl_listener input_method_grab_keyboard; 32 struct wl_listener input_method_grab_keyboard;
32 struct wl_listener input_method_destroy; 33 struct wl_listener input_method_destroy;
33 34
34 struct wl_listener input_method_keyboard_grab_destroy; 35 struct wl_listener input_method_keyboard_grab_destroy;
35}; 36};
36 37
38
37struct sway_text_input { 39struct sway_text_input {
38 struct sway_input_method_relay *relay; 40 struct sway_input_method_relay *relay;
39 41
diff --git a/include/sway/input/text_input_popup.h b/include/sway/input/text_input_popup.h
new file mode 100644
index 00000000..e5f6ab8b
--- /dev/null
+++ b/include/sway/input/text_input_popup.h
@@ -0,0 +1,20 @@
1#ifndef _SWAY_INPUT_TEXT_INPUT_POPUP_H
2#define _SWAY_INPUT_TEXT_INPUT_POPUP_H
3
4#include "sway/tree/view.h"
5
6struct sway_input_popup {
7 struct sway_input_method_relay *relay;
8
9 struct wlr_scene_tree *scene_tree;
10 struct sway_popup_desc desc;
11 struct wlr_input_popup_surface_v2 *popup_surface;
12
13 struct wl_list link;
14
15 struct wl_listener popup_destroy;
16 struct wl_listener popup_surface_commit;
17
18 struct wl_listener focused_surface_unmap;
19};
20#endif
diff --git a/include/sway/ipc-json.h b/include/sway/ipc-json.h
index 6f4ade1a..bc9f4985 100644
--- a/include/sway/ipc-json.h
+++ b/include/sway/ipc-json.h
@@ -1,6 +1,7 @@
1#ifndef _SWAY_IPC_JSON_H 1#ifndef _SWAY_IPC_JSON_H
2#define _SWAY_IPC_JSON_H 2#define _SWAY_IPC_JSON_H
3#include <json.h> 3#include <json.h>
4#include "sway/output.h"
4#include "sway/tree/container.h" 5#include "sway/tree/container.h"
5#include "sway/input/input-manager.h" 6#include "sway/input/input-manager.h"
6 7
@@ -9,6 +10,7 @@ json_object *ipc_json_get_version(void);
9json_object *ipc_json_get_binding_mode(void); 10json_object *ipc_json_get_binding_mode(void);
10 11
11json_object *ipc_json_describe_disabled_output(struct sway_output *o); 12json_object *ipc_json_describe_disabled_output(struct sway_output *o);
13json_object *ipc_json_describe_non_desktop_output(struct sway_output_non_desktop *o);
12json_object *ipc_json_describe_node(struct sway_node *node); 14json_object *ipc_json_describe_node(struct sway_node *node);
13json_object *ipc_json_describe_node_recursive(struct sway_node *node); 15json_object *ipc_json_describe_node_recursive(struct sway_node *node);
14json_object *ipc_json_describe_input(struct sway_input_device *device); 16json_object *ipc_json_describe_input(struct sway_input_device *device);
diff --git a/include/sway/ipc-server.h b/include/sway/ipc-server.h
index bc4f781a..d4c00942 100644
--- a/include/sway/ipc-server.h
+++ b/include/sway/ipc-server.h
@@ -21,5 +21,6 @@ void ipc_event_mode(const char *mode, bool pango);
21void ipc_event_shutdown(const char *reason); 21void ipc_event_shutdown(const char *reason);
22void ipc_event_binding(struct sway_binding *binding); 22void ipc_event_binding(struct sway_binding *binding);
23void ipc_event_input(const char *change, struct sway_input_device *device); 23void ipc_event_input(const char *change, struct sway_input_device *device);
24void ipc_event_output(void);
24 25
25#endif 26#endif
diff --git a/include/sway/layers.h b/include/sway/layers.h
index 82ac5368..fd6384e0 100644
--- a/include/sway/layers.h
+++ b/include/sway/layers.h
@@ -1,58 +1,44 @@
1#ifndef _SWAY_LAYERS_H 1#ifndef _SWAY_LAYERS_H
2#define _SWAY_LAYERS_H 2#define _SWAY_LAYERS_H
3#include <stdbool.h> 3#include <stdbool.h>
4#include <wlr/types/wlr_surface.h> 4#include <wlr/types/wlr_compositor.h>
5#include <wlr/types/wlr_layer_shell_v1.h> 5#include <wlr/types/wlr_layer_shell_v1.h>
6 6#include "sway/tree/view.h"
7enum layer_parent {
8 LAYER_PARENT_LAYER,
9 LAYER_PARENT_POPUP,
10};
11 7
12struct sway_layer_surface { 8struct sway_layer_surface {
13 struct wlr_layer_surface_v1 *layer_surface;
14 struct wl_list link;
15
16 struct wl_listener destroy;
17 struct wl_listener map; 9 struct wl_listener map;
18 struct wl_listener unmap; 10 struct wl_listener unmap;
19 struct wl_listener surface_commit; 11 struct wl_listener surface_commit;
20 struct wl_listener output_destroy; 12 struct wl_listener output_destroy;
13 struct wl_listener node_destroy;
21 struct wl_listener new_popup; 14 struct wl_listener new_popup;
22 struct wl_listener new_subsurface;
23 15
24 struct wlr_box geo; 16 bool mapped;
25 enum zwlr_layer_shell_v1_layer layer; 17
18 struct wlr_scene_tree *popups;
19 struct sway_popup_desc desc;
20
21 struct sway_output *output;
22 struct wlr_scene_layer_surface_v1 *scene;
23 struct wlr_scene_tree *tree;
24 struct wlr_layer_surface_v1 *layer_surface;
26}; 25};
27 26
28struct sway_layer_popup { 27struct sway_layer_popup {
29 struct wlr_xdg_popup *wlr_popup; 28 struct wlr_xdg_popup *wlr_popup;
30 enum layer_parent parent_type; 29 struct wlr_scene_tree *scene;
31 union { 30 struct sway_layer_surface *toplevel;
32 struct sway_layer_surface *parent_layer;
33 struct sway_layer_popup *parent_popup;
34 };
35 struct wl_listener map;
36 struct wl_listener unmap;
37 struct wl_listener destroy;
38 struct wl_listener commit;
39 struct wl_listener new_popup;
40};
41 31
42struct sway_layer_subsurface {
43 struct wlr_subsurface *wlr_subsurface;
44 struct sway_layer_surface *layer_surface;
45
46 struct wl_listener map;
47 struct wl_listener unmap;
48 struct wl_listener destroy; 32 struct wl_listener destroy;
33 struct wl_listener new_popup;
49 struct wl_listener commit; 34 struct wl_listener commit;
50}; 35};
51 36
52struct sway_output; 37struct sway_output;
53void arrange_layers(struct sway_output *output);
54 38
55struct sway_layer_surface *layer_from_wlr_layer_surface_v1( 39struct wlr_layer_surface_v1 *toplevel_layer_surface_from_surface(
56 struct wlr_layer_surface_v1 *layer_surface); 40 struct wlr_surface *surface);
41
42void arrange_layers(struct sway_output *output);
57 43
58#endif 44#endif
diff --git a/include/sway/output.h b/include/sway/output.h
index 5dfe0fff..d546d488 100644
--- a/include/sway/output.h
+++ b/include/sway/output.h
@@ -3,7 +3,9 @@
3#include <time.h> 3#include <time.h>
4#include <unistd.h> 4#include <unistd.h>
5#include <wayland-server-core.h> 5#include <wayland-server-core.h>
6#include <wlr/types/wlr_damage_ring.h>
6#include <wlr/types/wlr_output.h> 7#include <wlr/types/wlr_output.h>
8#include <wlr/types/wlr_scene.h>
7#include "config.h" 9#include "config.h"
8#include "sway/tree/node.h" 10#include "sway/tree/node.h"
9#include "sway/tree/view.h" 11#include "sway/tree/view.h"
@@ -18,43 +20,63 @@ struct sway_output_state {
18 20
19struct sway_output { 21struct sway_output {
20 struct sway_node node; 22 struct sway_node node;
23
24 struct {
25 struct wlr_scene_tree *shell_background;
26 struct wlr_scene_tree *shell_bottom;
27 struct wlr_scene_tree *tiling;
28 struct wlr_scene_tree *fullscreen;
29 struct wlr_scene_tree *shell_top;
30 struct wlr_scene_tree *shell_overlay;
31 struct wlr_scene_tree *session_lock;
32 } layers;
33
34 // when a container is fullscreen, in case the fullscreen surface is
35 // translucent (can see behind) we must make sure that the background is a
36 // solid color in order to conform to the wayland protocol. This rect
37 // ensures that when looking through a surface, all that will be seen
38 // is black.
39 struct wlr_scene_rect *fullscreen_background;
40
21 struct wlr_output *wlr_output; 41 struct wlr_output *wlr_output;
42 struct wlr_scene_output *scene_output;
22 struct sway_server *server; 43 struct sway_server *server;
23 struct wl_list link; 44 struct wl_list link;
24 45
25 struct wl_list layers[4]; // sway_layer_surface::link
26 struct wlr_box usable_area; 46 struct wlr_box usable_area;
27 47
28 struct timespec last_frame;
29 struct wlr_output_damage *damage;
30
31 int lx, ly; // layout coords 48 int lx, ly; // layout coords
32 int width, height; // transformed buffer size 49 int width, height; // transformed buffer size
33 enum wl_output_subpixel detected_subpixel; 50 enum wl_output_subpixel detected_subpixel;
34 enum scale_filter_mode scale_filter; 51 enum scale_filter_mode scale_filter;
35 // last applied mode when the output is DPMS'ed
36 struct wlr_output_mode *current_mode;
37 52
38 bool enabling, enabled; 53 bool enabled;
39 list_t *workspaces; 54 list_t *workspaces;
40 55
41 struct sway_output_state current; 56 struct sway_output_state current;
42 57
58 struct wl_listener layout_destroy;
43 struct wl_listener destroy; 59 struct wl_listener destroy;
44 struct wl_listener commit; 60 struct wl_listener commit;
45 struct wl_listener mode;
46 struct wl_listener present; 61 struct wl_listener present;
47 struct wl_listener damage_destroy; 62 struct wl_listener frame;
48 struct wl_listener damage_frame; 63 struct wl_listener request_state;
49 64
50 struct { 65 struct {
51 struct wl_signal destroy; 66 struct wl_signal disable;
52 } events; 67 } events;
53 68
54 struct timespec last_presentation; 69 struct timespec last_presentation;
55 uint32_t refresh_nsec; 70 uint32_t refresh_nsec;
56 int max_render_time; // In milliseconds 71 int max_render_time; // In milliseconds
57 struct wl_event_source *repaint_timer; 72 struct wl_event_source *repaint_timer;
73 bool gamma_lut_changed;
74};
75
76struct sway_output_non_desktop {
77 struct wlr_output *wlr_output;
78
79 struct wl_listener destroy;
58}; 80};
59 81
60struct sway_output *output_create(struct wlr_output *wlr_output); 82struct sway_output *output_create(struct wlr_output *wlr_output);
@@ -75,18 +97,8 @@ typedef void (*sway_surface_iterator_func_t)(struct sway_output *output,
75 struct sway_view *view, struct wlr_surface *surface, struct wlr_box *box, 97 struct sway_view *view, struct wlr_surface *surface, struct wlr_box *box,
76 void *user_data); 98 void *user_data);
77 99
78void output_damage_whole(struct sway_output *output); 100bool output_match_name_or_id(struct sway_output *output,
79 101 const char *name_or_id);
80void output_damage_surface(struct sway_output *output, double ox, double oy,
81 struct wlr_surface *surface, bool whole);
82
83void output_damage_from_view(struct sway_output *output,
84 struct sway_view *view);
85
86void output_damage_box(struct sway_output *output, struct wlr_box *box);
87
88void output_damage_whole_container(struct sway_output *output,
89 struct sway_container *con);
90 102
91// this ONLY includes the enabled outputs 103// this ONLY includes the enabled outputs
92struct sway_output *output_by_name_or_id(const char *name_or_id); 104struct sway_output *output_by_name_or_id(const char *name_or_id);
@@ -100,47 +112,8 @@ void output_enable(struct sway_output *output);
100 112
101void output_disable(struct sway_output *output); 113void output_disable(struct sway_output *output);
102 114
103bool output_has_opaque_overlay_layer_surface(struct sway_output *output);
104
105struct sway_workspace *output_get_active_workspace(struct sway_output *output); 115struct sway_workspace *output_get_active_workspace(struct sway_output *output);
106 116
107void output_render(struct sway_output *output, struct timespec *when,
108 pixman_region32_t *damage);
109
110void output_surface_for_each_surface(struct sway_output *output,
111 struct wlr_surface *surface, double ox, double oy,
112 sway_surface_iterator_func_t iterator, void *user_data);
113
114void output_view_for_each_surface(struct sway_output *output,
115 struct sway_view *view, sway_surface_iterator_func_t iterator,
116 void *user_data);
117
118void output_view_for_each_popup_surface(struct sway_output *output,
119 struct sway_view *view, sway_surface_iterator_func_t iterator,
120 void *user_data);
121
122void output_layer_for_each_surface(struct sway_output *output,
123 struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
124 void *user_data);
125
126void output_layer_for_each_toplevel_surface(struct sway_output *output,
127 struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
128 void *user_data);
129
130void output_layer_for_each_popup_surface(struct sway_output *output,
131 struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
132 void *user_data);
133
134#if HAVE_XWAYLAND
135void output_unmanaged_for_each_surface(struct sway_output *output,
136 struct wl_list *unmanaged, sway_surface_iterator_func_t iterator,
137 void *user_data);
138#endif
139
140void output_drag_icons_for_each_surface(struct sway_output *output,
141 struct wl_list *drag_icons, sway_surface_iterator_func_t iterator,
142 void *user_data);
143
144void output_for_each_workspace(struct sway_output *output, 117void output_for_each_workspace(struct sway_output *output,
145 void (*f)(struct sway_workspace *ws, void *data), void *data); 118 void (*f)(struct sway_workspace *ws, void *data), void *data);
146 119
@@ -158,18 +131,12 @@ void output_get_box(struct sway_output *output, struct wlr_box *box);
158enum sway_container_layout output_get_default_layout( 131enum sway_container_layout output_get_default_layout(
159 struct sway_output *output); 132 struct sway_output *output);
160 133
161void render_rect(struct sway_output *output,
162 pixman_region32_t *output_damage, const struct wlr_box *_box,
163 float color[static 4]);
164
165void premultiply_alpha(float color[4], float opacity);
166
167void scale_box(struct wlr_box *box, float scale);
168
169enum wlr_direction opposite_direction(enum wlr_direction d); 134enum wlr_direction opposite_direction(enum wlr_direction d);
170 135
171void handle_output_layout_change(struct wl_listener *listener, void *data); 136void handle_output_layout_change(struct wl_listener *listener, void *data);
172 137
138void handle_gamma_control_set_gamma(struct wl_listener *listener, void *data);
139
173void handle_output_manager_apply(struct wl_listener *listener, void *data); 140void handle_output_manager_apply(struct wl_listener *listener, void *data);
174 141
175void handle_output_manager_test(struct wl_listener *listener, void *data); 142void handle_output_manager_test(struct wl_listener *listener, void *data);
@@ -177,4 +144,6 @@ void handle_output_manager_test(struct wl_listener *listener, void *data);
177void handle_output_power_manager_set_mode(struct wl_listener *listener, 144void handle_output_power_manager_set_mode(struct wl_listener *listener,
178 void *data); 145 void *data);
179 146
147struct sway_output_non_desktop *output_non_desktop_create(struct wlr_output *wlr_output);
148
180#endif 149#endif
diff --git a/include/sway/scene_descriptor.h b/include/sway/scene_descriptor.h
new file mode 100644
index 00000000..2649d7c2
--- /dev/null
+++ b/include/sway/scene_descriptor.h
@@ -0,0 +1,33 @@
1/**
2 * Across a wayland compositor, there are multiple shells: It can be
3 * a toplevel, or a layer_shell, or even something more meta like a drag
4 * icon or highlight indicators when dragging windows around.
5 *
6 * This object lets us store values that represent these modes of operation
7 * and keep track of what object is being represented.
8 */
9#ifndef _SWAY_SCENE_DESCRIPTOR_H
10#define _SWAY_SCENE_DESCRIPTOR_H
11#include <wlr/types/wlr_scene.h>
12
13enum sway_scene_descriptor_type {
14 SWAY_SCENE_DESC_BUFFER_TIMER,
15 SWAY_SCENE_DESC_NON_INTERACTIVE,
16 SWAY_SCENE_DESC_CONTAINER,
17 SWAY_SCENE_DESC_VIEW,
18 SWAY_SCENE_DESC_LAYER_SHELL,
19 SWAY_SCENE_DESC_XWAYLAND_UNMANAGED,
20 SWAY_SCENE_DESC_POPUP,
21 SWAY_SCENE_DESC_DRAG_ICON,
22};
23
24bool scene_descriptor_assign(struct wlr_scene_node *node,
25 enum sway_scene_descriptor_type type, void *data);
26
27void *scene_descriptor_try_get(struct wlr_scene_node *node,
28 enum sway_scene_descriptor_type type);
29
30void scene_descriptor_destroy(struct wlr_scene_node *node,
31 enum sway_scene_descriptor_type type);
32
33#endif
diff --git a/include/sway/server.h b/include/sway/server.h
index 3a5670d9..90f187fd 100644
--- a/include/sway/server.h
+++ b/include/sway/server.h
@@ -2,41 +2,43 @@
2#define _SWAY_SERVER_H 2#define _SWAY_SERVER_H
3#include <stdbool.h> 3#include <stdbool.h>
4#include <wayland-server-core.h> 4#include <wayland-server-core.h>
5#include <wlr/backend.h>
6#include <wlr/backend/session.h>
7#include <wlr/render/wlr_renderer.h>
8#include <wlr/types/wlr_compositor.h>
9#include <wlr/types/wlr_data_device.h>
10#include <wlr/types/wlr_input_method_v2.h>
11#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
12#include <wlr/types/wlr_layer_shell_v1.h>
13#include <wlr/types/wlr_output_management_v1.h>
14#include <wlr/types/wlr_output_power_management_v1.h>
15#include <wlr/types/wlr_presentation_time.h>
16#include <wlr/types/wlr_relative_pointer_v1.h>
17#include <wlr/types/wlr_server_decoration.h>
18#include <wlr/types/wlr_text_input_v3.h>
19#include <wlr/types/wlr_xdg_shell.h>
20#include "config.h" 5#include "config.h"
21#include "list.h" 6#include "list.h"
22#if HAVE_XWAYLAND 7#include "sway/desktop/idle_inhibit_v1.h"
8#if WLR_HAS_XWAYLAND
23#include "sway/xwayland.h" 9#include "sway/xwayland.h"
24#endif 10#endif
25 11
26struct sway_transaction; 12struct sway_transaction;
27 13
14struct sway_session_lock {
15 struct wlr_session_lock_v1 *lock;
16 struct wlr_surface *focused;
17 bool abandoned;
18
19 struct wl_list outputs; // struct sway_session_lock_output
20
21 // invalid if the session is abandoned
22 struct wl_listener new_surface;
23 struct wl_listener unlock;
24 struct wl_listener destroy;
25};
26
28struct sway_server { 27struct sway_server {
29 struct wl_display *wl_display; 28 struct wl_display *wl_display;
30 struct wl_event_loop *wl_event_loop; 29 struct wl_event_loop *wl_event_loop;
31 const char *socket; 30 const char *socket;
32 31
33 struct wlr_backend *backend; 32 struct wlr_backend *backend;
34 struct wlr_backend *noop_backend; 33 struct wlr_session *session;
35 // secondary headless backend used for creating virtual outputs on-the-fly 34 // secondary headless backend used for creating virtual outputs on-the-fly
36 struct wlr_backend *headless_backend; 35 struct wlr_backend *headless_backend;
36 struct wlr_renderer *renderer;
37 struct wlr_allocator *allocator;
37 38
38 struct wlr_compositor *compositor; 39 struct wlr_compositor *compositor;
39 struct wl_listener compositor_new_surface; 40
41 struct wlr_linux_dmabuf_v1 *linux_dmabuf_v1;
40 42
41 struct wlr_data_device_manager *data_device_manager; 43 struct wlr_data_device_manager *data_device_manager;
42 44
@@ -44,19 +46,20 @@ struct sway_server {
44 46
45 struct wl_listener new_output; 47 struct wl_listener new_output;
46 struct wl_listener output_layout_change; 48 struct wl_listener output_layout_change;
49 struct wl_listener renderer_lost;
47 50
48 struct wlr_idle *idle; 51 struct wlr_idle_notifier_v1 *idle_notifier_v1;
49 struct sway_idle_inhibit_manager_v1 *idle_inhibit_manager_v1; 52 struct sway_idle_inhibit_manager_v1 idle_inhibit_manager_v1;
50 53
51 struct wlr_layer_shell_v1 *layer_shell; 54 struct wlr_layer_shell_v1 *layer_shell;
52 struct wl_listener layer_shell_surface; 55 struct wl_listener layer_shell_surface;
53 56
54 struct wlr_xdg_shell *xdg_shell; 57 struct wlr_xdg_shell *xdg_shell;
55 struct wl_listener xdg_shell_surface; 58 struct wl_listener xdg_shell_toplevel;
56 59
57 struct wlr_tablet_manager_v2 *tablet_v2; 60 struct wlr_tablet_manager_v2 *tablet_v2;
58 61
59#if HAVE_XWAYLAND 62#if WLR_HAS_XWAYLAND
60 struct sway_xwayland xwayland; 63 struct sway_xwayland xwayland;
61 struct wl_listener xwayland_surface; 64 struct wl_listener xwayland_surface;
62 struct wl_listener xwayland_ready; 65 struct wl_listener xwayland_ready;
@@ -72,7 +75,8 @@ struct sway_server {
72 struct wl_listener xdg_decoration; 75 struct wl_listener xdg_decoration;
73 struct wl_list xdg_decorations; // sway_xdg_decoration::link 76 struct wl_list xdg_decorations; // sway_xdg_decoration::link
74 77
75 struct wlr_presentation *presentation; 78 struct wlr_drm_lease_v1_manager *drm_lease_manager;
79 struct wl_listener drm_lease_request;
76 80
77 struct wlr_pointer_constraints_v1 *pointer_constraints; 81 struct wlr_pointer_constraints_v1 *pointer_constraints;
78 struct wl_listener pointer_constraint; 82 struct wl_listener pointer_constraint;
@@ -81,14 +85,36 @@ struct sway_server {
81 struct wl_listener output_manager_apply; 85 struct wl_listener output_manager_apply;
82 struct wl_listener output_manager_test; 86 struct wl_listener output_manager_test;
83 87
88 struct wlr_gamma_control_manager_v1 *gamma_control_manager_v1;
89 struct wl_listener gamma_control_set_gamma;
90
91 struct {
92 struct sway_session_lock *lock;
93 struct wlr_session_lock_manager_v1 *manager;
94
95 struct wl_listener new_lock;
96 struct wl_listener manager_destroy;
97 } session_lock;
98
84 struct wlr_output_power_manager_v1 *output_power_manager_v1; 99 struct wlr_output_power_manager_v1 *output_power_manager_v1;
85 struct wl_listener output_power_manager_set_mode; 100 struct wl_listener output_power_manager_set_mode;
86 struct wlr_input_method_manager_v2 *input_method; 101 struct wlr_input_method_manager_v2 *input_method;
87 struct wlr_text_input_manager_v3 *text_input; 102 struct wlr_text_input_manager_v3 *text_input;
103 struct wlr_ext_foreign_toplevel_list_v1 *foreign_toplevel_list;
88 struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager; 104 struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager;
105 struct wlr_content_type_manager_v1 *content_type_manager_v1;
106 struct wlr_data_control_manager_v1 *data_control_manager_v1;
107 struct wlr_screencopy_manager_v1 *screencopy_manager_v1;
108 struct wlr_export_dmabuf_manager_v1 *export_dmabuf_manager_v1;
109 struct wlr_security_context_manager_v1 *security_context_manager_v1;
89 110
90 struct wlr_xdg_activation_v1 *xdg_activation_v1; 111 struct wlr_xdg_activation_v1 *xdg_activation_v1;
91 struct wl_listener xdg_activation_v1_request_activate; 112 struct wl_listener xdg_activation_v1_request_activate;
113 struct wl_listener xdg_activation_v1_new_token;
114
115 struct wl_listener request_set_cursor_shape;
116
117 struct wl_list pending_launcher_ctxs; // launcher_ctx::link
92 118
93 // The timeout for transactions, after which a transaction is applied 119 // The timeout for transactions, after which a transaction is applied
94 // regardless of readiness. 120 // regardless of readiness.
@@ -115,30 +141,31 @@ struct sway_debug {
115 bool noatomic; // Ignore atomic layout updates 141 bool noatomic; // Ignore atomic layout updates
116 bool txn_timings; // Log verbose messages about transactions 142 bool txn_timings; // Log verbose messages about transactions
117 bool txn_wait; // Always wait for the timeout before applying 143 bool txn_wait; // Always wait for the timeout before applying
118 144 bool legacy_wl_drm; // Enable the legacy wl_drm interface
119 enum {
120 DAMAGE_DEFAULT, // Default behaviour
121 DAMAGE_HIGHLIGHT, // Highlight regions of the screen being damaged
122 DAMAGE_RERENDER, // Render the full output when any damage occurs
123 } damage;
124}; 145};
125 146
126extern struct sway_debug debug; 147extern struct sway_debug debug;
127 148
128/* Prepares an unprivileged server_init by performing all privileged operations in advance */ 149extern bool allow_unsupported_gpu;
129bool server_privileged_prepare(struct sway_server *server); 150
130bool server_init(struct sway_server *server); 151bool server_init(struct sway_server *server);
131void server_fini(struct sway_server *server); 152void server_fini(struct sway_server *server);
132bool server_start(struct sway_server *server); 153bool server_start(struct sway_server *server);
133void server_run(struct sway_server *server); 154void server_run(struct sway_server *server);
134 155
135void handle_compositor_new_surface(struct wl_listener *listener, void *data); 156void restore_nofile_limit(void);
157
136void handle_new_output(struct wl_listener *listener, void *data); 158void handle_new_output(struct wl_listener *listener, void *data);
137 159
138void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data); 160void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data);
139void handle_layer_shell_surface(struct wl_listener *listener, void *data); 161void handle_layer_shell_surface(struct wl_listener *listener, void *data);
140void handle_xdg_shell_surface(struct wl_listener *listener, void *data); 162void sway_session_lock_init(void);
141#if HAVE_XWAYLAND 163void sway_session_lock_add_output(struct sway_session_lock *lock,
164 struct sway_output *output);
165bool sway_session_lock_has_surface(struct sway_session_lock *lock,
166 struct wlr_surface *surface);
167void handle_xdg_shell_toplevel(struct wl_listener *listener, void *data);
168#if WLR_HAS_XWAYLAND
142void handle_xwayland_surface(struct wl_listener *listener, void *data); 169void handle_xwayland_surface(struct wl_listener *listener, void *data);
143#endif 170#endif
144void handle_server_decoration(struct wl_listener *listener, void *data); 171void handle_server_decoration(struct wl_listener *listener, void *data);
@@ -146,5 +173,9 @@ void handle_xdg_decoration(struct wl_listener *listener, void *data);
146void handle_pointer_constraint(struct wl_listener *listener, void *data); 173void handle_pointer_constraint(struct wl_listener *listener, void *data);
147void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, 174void xdg_activation_v1_handle_request_activate(struct wl_listener *listener,
148 void *data); 175 void *data);
176void xdg_activation_v1_handle_new_token(struct wl_listener *listener,
177 void *data);
178
179void set_rr_scheduling(void);
149 180
150#endif 181#endif
diff --git a/include/sway/surface.h b/include/sway/surface.h
deleted file mode 100644
index 4da96c02..00000000
--- a/include/sway/surface.h
+++ /dev/null
@@ -1,18 +0,0 @@
1#ifndef _SWAY_SURFACE_H
2#define _SWAY_SURFACE_H
3#include <wlr/types/wlr_surface.h>
4
5struct sway_surface {
6 struct wlr_surface *wlr_surface;
7
8 struct wl_listener destroy;
9
10 /**
11 * This timer can be used for issuing delayed frame done callbacks (for
12 * example, to improve presentation latency). Its handler is set to a
13 * function that issues a frame done callback to this surface.
14 */
15 struct wl_event_source *frame_done_timer;
16};
17
18#endif
diff --git a/include/sway/sway_text_node.h b/include/sway/sway_text_node.h
new file mode 100644
index 00000000..0d4209bb
--- /dev/null
+++ b/include/sway/sway_text_node.h
@@ -0,0 +1,28 @@
1#ifndef _SWAY_BUFFER_H
2#define _SWAY_BUFFER_H
3#include <wlr/types/wlr_scene.h>
4
5struct sway_text_node {
6 int width;
7 int max_width;
8 int height;
9 int baseline;
10 bool pango_markup;
11 float color[4];
12 float background[4];
13
14 struct wlr_scene_node *node;
15};
16
17struct sway_text_node *sway_text_node_create(struct wlr_scene_tree *parent,
18 char *text, float color[4], bool pango_markup);
19
20void sway_text_node_set_color(struct sway_text_node *node, float color[4]);
21
22void sway_text_node_set_text(struct sway_text_node *node, char *text);
23
24void sway_text_node_set_max_width(struct sway_text_node *node, int max_width);
25
26void sway_text_node_set_background(struct sway_text_node *node, float background[4]);
27
28#endif
diff --git a/include/sway/swaynag.h b/include/sway/swaynag.h
index 74d9ea18..03bd52c3 100644
--- a/include/sway/swaynag.h
+++ b/include/sway/swaynag.h
@@ -1,6 +1,7 @@
1#ifndef _SWAY_SWAYNAG_H 1#ifndef _SWAY_SWAYNAG_H
2#define _SWAY_SWAYNAG_H 2#define _SWAY_SWAYNAG_H
3#include <wayland-server-core.h> 3#include <wayland-server-core.h>
4#include "stringop.h"
4 5
5struct swaynag_instance { 6struct swaynag_instance {
6 struct wl_client *client; 7 struct wl_client *client;
@@ -21,7 +22,7 @@ bool swaynag_spawn(const char *swaynag_command,
21// Write a log message to swaynag->fd[1]. This will fail when swaynag->detailed 22// Write a log message to swaynag->fd[1]. This will fail when swaynag->detailed
22// is false. 23// is false.
23void swaynag_log(const char *swaynag_command, struct swaynag_instance *swaynag, 24void swaynag_log(const char *swaynag_command, struct swaynag_instance *swaynag,
24 const char *fmt, ...); 25 const char *fmt, ...) _SWAY_ATTRIB_PRINTF(3, 4);
25 26
26// If swaynag->detailed, close swaynag->fd[1] so swaynag displays 27// If swaynag->detailed, close swaynag->fd[1] so swaynag displays
27void swaynag_show(struct swaynag_instance *swaynag); 28void swaynag_show(struct swaynag_instance *swaynag);
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 38ee68bd..93f6bfbb 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -2,7 +2,8 @@
2#define _SWAY_CONTAINER_H 2#define _SWAY_CONTAINER_H
3#include <stdint.h> 3#include <stdint.h>
4#include <sys/types.h> 4#include <sys/types.h>
5#include <wlr/types/wlr_surface.h> 5#include <wlr/types/wlr_compositor.h>
6#include <wlr/types/wlr_scene.h>
6#include "list.h" 7#include "list.h"
7#include "sway/tree/node.h" 8#include "sway/tree/node.h"
8 9
@@ -68,11 +69,39 @@ struct sway_container {
68 struct sway_node node; 69 struct sway_node node;
69 struct sway_view *view; 70 struct sway_view *view;
70 71
72 struct wlr_scene_tree *scene_tree;
73
74 struct {
75 struct wlr_scene_tree *tree;
76
77 struct wlr_scene_tree *border;
78 struct wlr_scene_tree *background;
79
80 struct sway_text_node *title_text;
81 struct sway_text_node *marks_text;
82 } title_bar;
83
84 struct {
85 struct wlr_scene_tree *tree;
86
87 struct wlr_scene_rect *top;
88 struct wlr_scene_rect *bottom;
89 struct wlr_scene_rect *left;
90 struct wlr_scene_rect *right;
91 } border;
92
93 struct wlr_scene_tree *content_tree;
94 struct wlr_scene_buffer *output_handler;
95
96 struct wl_listener output_enter;
97 struct wl_listener output_leave;
98
71 struct sway_container_state current; 99 struct sway_container_state current;
72 struct sway_container_state pending; 100 struct sway_container_state pending;
73 101
74 char *title; // The view's title (unformatted) 102 char *title; // The view's title (unformatted)
75 char *formatted_title; // The title displayed in the title bar 103 char *formatted_title; // The title displayed in the title bar
104 int title_width;
76 105
77 enum sway_container_layout prev_split_layout; 106 enum sway_container_layout prev_split_layout;
78 107
@@ -100,33 +129,19 @@ struct sway_container {
100 double child_total_width; 129 double child_total_width;
101 double child_total_height; 130 double child_total_height;
102 131
103 // In most cases this is the same as the content x and y, but if the view
104 // refuses to resize to the content dimensions then it can be smaller.
105 // These are in layout coordinates.
106 double surface_x, surface_y;
107
108 // Outputs currently being intersected
109 list_t *outputs; // struct sway_output
110
111 // Indicates that the container is a scratchpad container. 132 // Indicates that the container is a scratchpad container.
112 // Both hidden and visible scratchpad containers have scratchpad=true. 133 // Both hidden and visible scratchpad containers have scratchpad=true.
113 // Hidden scratchpad containers have a NULL parent. 134 // Hidden scratchpad containers have a NULL parent.
114 bool scratchpad; 135 bool scratchpad;
115 136
116 float alpha; 137 // Stores last output size and position for adjusting coordinates of
138 // scratchpad windows.
139 // Unused for non-scratchpad windows.
140 struct wlr_box transform;
117 141
118 struct wlr_texture *title_focused; 142 float alpha;
119 struct wlr_texture *title_focused_inactive;
120 struct wlr_texture *title_unfocused;
121 struct wlr_texture *title_urgent;
122 size_t title_height;
123 size_t title_baseline;
124 143
125 list_t *marks; // char * 144 list_t *marks; // char *
126 struct wlr_texture *marks_focused;
127 struct wlr_texture *marks_focused_inactive;
128 struct wlr_texture *marks_unfocused;
129 struct wlr_texture *marks_urgent;
130 145
131 struct { 146 struct {
132 struct wl_signal destroy; 147 struct wl_signal destroy;
@@ -146,19 +161,6 @@ void container_begin_destroy(struct sway_container *con);
146struct sway_container *container_find_child(struct sway_container *container, 161struct sway_container *container_find_child(struct sway_container *container,
147 bool (*test)(struct sway_container *view, void *data), void *data); 162 bool (*test)(struct sway_container *view, void *data), void *data);
148 163
149/**
150 * Find a container at the given coordinates. Returns the surface and
151 * surface-local coordinates of the given layout coordinates if the container
152 * is a view and the view contains a surface at those coordinates.
153 */
154struct sway_container *container_at(struct sway_workspace *workspace,
155 double lx, double ly, struct wlr_surface **surface,
156 double *sx, double *sy);
157
158struct sway_container *tiling_container_at(
159 struct sway_node *parent, double lx, double ly,
160 struct wlr_surface **surface, double *sx, double *sy);
161
162void container_for_each_child(struct sway_container *container, 164void container_for_each_child(struct sway_container *container,
163 void (*f)(struct sway_container *container, void *data), void *data); 165 void (*f)(struct sway_container *container, void *data), void *data);
164 166
@@ -175,18 +177,13 @@ bool container_has_ancestor(struct sway_container *container,
175 177
176void container_update_textures_recursive(struct sway_container *con); 178void container_update_textures_recursive(struct sway_container *con);
177 179
178void container_damage_whole(struct sway_container *container);
179
180void container_reap_empty(struct sway_container *con); 180void container_reap_empty(struct sway_container *con);
181 181
182struct sway_container *container_flatten(struct sway_container *container); 182struct sway_container *container_flatten(struct sway_container *container);
183 183
184void container_update_title_textures(struct sway_container *container); 184void container_update_title_bar(struct sway_container *container);
185 185
186/** 186void container_update_marks(struct sway_container *container);
187 * Calculate the container's title_height property.
188 */
189void container_calculate_title_height(struct sway_container *container);
190 187
191size_t container_build_representation(enum sway_container_layout layout, 188size_t container_build_representation(enum sway_container_layout layout,
192 list_t *children, char *buffer); 189 list_t *children, char *buffer);
@@ -201,6 +198,9 @@ size_t container_titlebar_height(void);
201void floating_calculate_constraints(int *min_width, int *max_width, 198void floating_calculate_constraints(int *min_width, int *max_width,
202 int *min_height, int *max_height); 199 int *min_height, int *max_height);
203 200
201void floating_fix_coordinates(struct sway_container *con,
202 struct wlr_box *old, struct wlr_box *new);
203
204void container_floating_resize_and_center(struct sway_container *con); 204void container_floating_resize_and_center(struct sway_container *con);
205 205
206void container_floating_set_default_size(struct sway_container *con); 206void container_floating_set_default_size(struct sway_container *con);
@@ -220,11 +220,6 @@ void container_set_geometry_from_content(struct sway_container *con);
220bool container_is_floating(struct sway_container *container); 220bool container_is_floating(struct sway_container *container);
221 221
222/** 222/**
223 * Same as above, but for current container state.
224 */
225bool container_is_current_floating(struct sway_container *container);
226
227/**
228 * Get a container's box in layout coordinates. 223 * Get a container's box in layout coordinates.
229 */ 224 */
230void container_get_box(struct sway_container *container, struct wlr_box *box); 225void container_get_box(struct sway_container *container, struct wlr_box *box);
@@ -286,26 +281,12 @@ bool container_is_floating_or_child(struct sway_container *container);
286 */ 281 */
287bool container_is_fullscreen_or_child(struct sway_container *container); 282bool container_is_fullscreen_or_child(struct sway_container *container);
288 283
289/**
290 * Return the output which will be used for scale purposes.
291 * This is the most recently entered output.
292 * If the container is not on any output, return NULL.
293 */
294struct sway_output *container_get_effective_output(struct sway_container *con);
295
296void container_discover_outputs(struct sway_container *con);
297
298enum sway_container_layout container_parent_layout(struct sway_container *con); 284enum sway_container_layout container_parent_layout(struct sway_container *con);
299 285
300enum sway_container_layout container_current_parent_layout(
301 struct sway_container *con);
302
303list_t *container_get_siblings(struct sway_container *container); 286list_t *container_get_siblings(struct sway_container *container);
304 287
305int container_sibling_index(struct sway_container *child); 288int container_sibling_index(struct sway_container *child);
306 289
307list_t *container_get_current_siblings(struct sway_container *container);
308
309void container_handle_fullscreen_reparent(struct sway_container *con); 290void container_handle_fullscreen_reparent(struct sway_container *con);
310 291
311void container_add_child(struct sway_container *parent, 292void container_add_child(struct sway_container *parent,
@@ -353,8 +334,6 @@ bool container_has_mark(struct sway_container *container, char *mark);
353 334
354void container_add_mark(struct sway_container *container, char *mark); 335void container_add_mark(struct sway_container *container, char *mark);
355 336
356void container_update_marks_textures(struct sway_container *container);
357
358void container_raise_floating(struct sway_container *con); 337void container_raise_floating(struct sway_container *con);
359 338
360bool container_is_scratchpad_hidden(struct sway_container *con); 339bool container_is_scratchpad_hidden(struct sway_container *con);
@@ -369,7 +348,7 @@ bool container_is_sticky_or_child(struct sway_container *con);
369 * This will destroy pairs of redundant H/V splits 348 * This will destroy pairs of redundant H/V splits
370 * e.g. H[V[H[app app]] app] -> H[app app app] 349 * e.g. H[V[H[app app]] app] -> H[app app app]
371 * The middle "V[H[" are eliminated by a call to container_squash 350 * The middle "V[H[" are eliminated by a call to container_squash
372 * on the V[ con. It's grandchildren are added to it's parent. 351 * on the V[ con. It's grandchildren are added to its parent.
373 * 352 *
374 * This function is roughly equivalent to i3's tree_flatten here: 353 * This function is roughly equivalent to i3's tree_flatten here:
375 * https://github.com/i3/i3/blob/1f0c628cde40cf87371481041b7197344e0417c6/src/tree.c#L651 354 * https://github.com/i3/i3/blob/1f0c628cde40cf87371481041b7197344e0417c6/src/tree.c#L651
@@ -378,4 +357,10 @@ bool container_is_sticky_or_child(struct sway_container *con);
378 */ 357 */
379int container_squash(struct sway_container *con); 358int container_squash(struct sway_container *con);
380 359
360void container_arrange_title_bar(struct sway_container *con);
361
362void container_update(struct sway_container *con);
363
364void container_update_itself_and_parents(struct sway_container *con);
365
381#endif 366#endif
diff --git a/include/sway/tree/node.h b/include/sway/tree/node.h
index 470ee3b5..e2dbcdf0 100644
--- a/include/sway/tree/node.h
+++ b/include/sway/tree/node.h
@@ -1,6 +1,8 @@
1#ifndef _SWAY_NODE_H 1#ifndef _SWAY_NODE_H
2#define _SWAY_NODE_H 2#define _SWAY_NODE_H
3#include <wayland-server-core.h>
3#include <stdbool.h> 4#include <stdbool.h>
5#include <wlr/types/wlr_scene.h>
4#include "list.h" 6#include "list.h"
5 7
6#define MIN_SANE_W 100 8#define MIN_SANE_W 100
@@ -74,4 +76,15 @@ list_t *node_get_children(struct sway_node *node);
74 76
75bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor); 77bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor);
76 78
79// when destroying a sway tree, it's not known which order the tree will be
80// destroyed. To prevent freeing of scene_nodes recursing up the tree,
81// let's use this helper function to disown them to the staging node.
82void scene_node_disown_children(struct wlr_scene_tree *tree);
83
84// a helper function used to allocate tree nodes. If an allocation failure
85// occurs a flag is flipped that can be checked later to destroy a parent
86// of this scene node preventing memory leaks.
87struct wlr_scene_tree *alloc_scene_tree(struct wlr_scene_tree *parent,
88 bool *failed);
89
77#endif 90#endif
diff --git a/include/sway/tree/root.h b/include/sway/tree/root.h
index e8f4d573..7de0abcd 100644
--- a/include/sway/tree/root.h
+++ b/include/sway/tree/root.h
@@ -2,11 +2,12 @@
2#define _SWAY_ROOT_H 2#define _SWAY_ROOT_H
3#include <wayland-server-core.h> 3#include <wayland-server-core.h>
4#include <wayland-util.h> 4#include <wayland-util.h>
5#include <wlr/config.h>
5#include <wlr/types/wlr_output_layout.h> 6#include <wlr/types/wlr_output_layout.h>
7#include <wlr/types/wlr_scene.h>
6#include <wlr/render/wlr_texture.h> 8#include <wlr/render/wlr_texture.h>
7#include "sway/tree/container.h" 9#include "sway/tree/container.h"
8#include "sway/tree/node.h" 10#include "sway/tree/node.h"
9#include "config.h"
10#include "list.h" 11#include "list.h"
11 12
12extern struct sway_root *root; 13extern struct sway_root *root;
@@ -16,10 +17,44 @@ struct sway_root {
16 struct wlr_output_layout *output_layout; 17 struct wlr_output_layout *output_layout;
17 18
18 struct wl_listener output_layout_change; 19 struct wl_listener output_layout_change;
19#if HAVE_XWAYLAND 20
20 struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link 21 // scene node layout:
22 // - root
23 // - staging
24 // - layer shell stuff
25 // - tiling
26 // - floating
27 // - fullscreen stuff
28 // - seat stuff
29 // - ext_session_lock
30 struct wlr_scene *root_scene;
31
32 // since wlr_scene nodes can't be orphaned and must always
33 // have a parent, use this staging scene_tree so that a
34 // node always have a valid parent. Nothing in this
35 // staging node will be visible.
36 struct wlr_scene_tree *staging;
37
38 // tree containing all layers the compositor will render. Cursor handling
39 // will end up iterating this tree.
40 struct wlr_scene_tree *layer_tree;
41
42 struct {
43 struct wlr_scene_tree *shell_background;
44 struct wlr_scene_tree *shell_bottom;
45 struct wlr_scene_tree *tiling;
46 struct wlr_scene_tree *floating;
47 struct wlr_scene_tree *shell_top;
48 struct wlr_scene_tree *fullscreen;
49 struct wlr_scene_tree *fullscreen_global;
50#if WLR_HAS_XWAYLAND
51 struct wlr_scene_tree *unmanaged;
21#endif 52#endif
22 struct wl_list drag_icons; // sway_drag_icon::link 53 struct wlr_scene_tree *shell_overlay;
54 struct wlr_scene_tree *popup;
55 struct wlr_scene_tree *seat;
56 struct wlr_scene_tree *session_lock;
57 } layers;
23 58
24 // Includes disabled outputs 59 // Includes disabled outputs
25 struct wl_list all_outputs; // sway_output::link 60 struct wl_list all_outputs; // sway_output::link
@@ -28,10 +63,11 @@ struct sway_root {
28 double width, height; 63 double width, height;
29 64
30 list_t *outputs; // struct sway_output 65 list_t *outputs; // struct sway_output
66 list_t *non_desktop_outputs; // struct sway_output_non_desktop
31 list_t *scratchpad; // struct sway_container 67 list_t *scratchpad; // struct sway_container
32 68
33 // For when there's no connected outputs 69 // For when there's no connected outputs
34 struct sway_output *noop_output; 70 struct sway_output *fallback_output;
35 71
36 struct sway_container *fullscreen_global; 72 struct sway_container *fullscreen_global;
37 73
@@ -40,7 +76,7 @@ struct sway_root {
40 } events; 76 } events;
41}; 77};
42 78
43struct sway_root *root_create(void); 79struct sway_root *root_create(struct wl_display *display);
44 80
45void root_destroy(struct sway_root *root); 81void root_destroy(struct sway_root *root);
46 82
@@ -68,12 +104,6 @@ void root_scratchpad_show(struct sway_container *con);
68 */ 104 */
69void root_scratchpad_hide(struct sway_container *con); 105void root_scratchpad_hide(struct sway_container *con);
70 106
71struct sway_workspace *root_workspace_for_pid(pid_t pid);
72
73void root_record_workspace_pid(pid_t pid);
74
75void root_remove_workspace_pid(pid_t pid);
76
77void root_for_each_workspace(void (*f)(struct sway_workspace *ws, void *data), 107void root_for_each_workspace(void (*f)(struct sway_workspace *ws, void *data),
78 void *data); 108 void *data);
79 109
@@ -91,6 +121,4 @@ struct sway_container *root_find_container(
91 121
92void root_get_box(struct sway_root *root, struct wlr_box *box); 122void root_get_box(struct sway_root *root, struct wlr_box *box);
93 123
94void root_rename_pid_workspaces(const char *old_name, const char *new_name);
95
96#endif 124#endif
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 923498ec..3ae8cf22 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -1,9 +1,11 @@
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/config.h>
5#include "config.h" 5#include <wlr/types/wlr_compositor.h>
6#if HAVE_XWAYLAND 6#include <wlr/types/wlr_scene.h>
7#include "sway/config.h"
8#if WLR_HAS_XWAYLAND
7#include <wlr/xwayland.h> 9#include <wlr/xwayland.h>
8#endif 10#endif
9#include "sway/input/input-manager.h" 11#include "sway/input/input-manager.h"
@@ -14,7 +16,7 @@ struct sway_xdg_decoration;
14 16
15enum sway_view_type { 17enum sway_view_type {
16 SWAY_VIEW_XDG_SHELL, 18 SWAY_VIEW_XDG_SHELL,
17#if HAVE_XWAYLAND 19#if WLR_HAS_XWAYLAND
18 SWAY_VIEW_XWAYLAND, 20 SWAY_VIEW_XWAYLAND,
19#endif 21#endif
20}; 22};
@@ -26,7 +28,7 @@ enum sway_view_prop {
26 VIEW_PROP_INSTANCE, 28 VIEW_PROP_INSTANCE,
27 VIEW_PROP_WINDOW_TYPE, 29 VIEW_PROP_WINDOW_TYPE,
28 VIEW_PROP_WINDOW_ROLE, 30 VIEW_PROP_WINDOW_ROLE,
29#if HAVE_XWAYLAND 31#if WLR_HAS_XWAYLAND
30 VIEW_PROP_X11_WINDOW_ID, 32 VIEW_PROP_X11_WINDOW_ID,
31 VIEW_PROP_X11_PARENT_ID, 33 VIEW_PROP_X11_PARENT_ID,
32#endif 34#endif
@@ -45,10 +47,6 @@ struct sway_view_impl {
45 void (*set_fullscreen)(struct sway_view *view, bool fullscreen); 47 void (*set_fullscreen)(struct sway_view *view, bool fullscreen);
46 void (*set_resizing)(struct sway_view *view, bool resizing); 48 void (*set_resizing)(struct sway_view *view, bool resizing);
47 bool (*wants_floating)(struct sway_view *view); 49 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, 50 bool (*is_transient_for)(struct sway_view *child,
53 struct sway_view *ancestor); 51 struct sway_view *ancestor);
54 void (*close)(struct sway_view *view); 52 void (*close)(struct sway_view *view);
@@ -56,24 +54,20 @@ struct sway_view_impl {
56 void (*destroy)(struct sway_view *view); 54 void (*destroy)(struct sway_view *view);
57}; 55};
58 56
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 { 57struct sway_view {
69 enum sway_view_type type; 58 enum sway_view_type type;
70 const struct sway_view_impl *impl; 59 const struct sway_view_impl *impl;
71 60
61 struct wlr_scene_tree *scene_tree;
62 struct wlr_scene_tree *content_tree;
63 struct wlr_scene_tree *saved_surface_tree;
64
72 struct sway_container *container; // NULL if unmapped and transactions finished 65 struct sway_container *container; // NULL if unmapped and transactions finished
73 struct wlr_surface *surface; // NULL for unmapped views 66 struct wlr_surface *surface; // NULL for unmapped views
74 struct sway_xdg_decoration *xdg_decoration; 67 struct sway_xdg_decoration *xdg_decoration;
75 68
76 pid_t pid; 69 pid_t pid;
70 struct launcher_ctx *ctx;
77 71
78 // The size the view would want to be if it weren't tiled. 72 // The size the view would want to be if it weren't tiled.
79 // Used when changing a view from tiled to floating. 73 // Used when changing a view from tiled to floating.
@@ -87,15 +81,11 @@ struct sway_view {
87 bool allow_request_urgent; 81 bool allow_request_urgent;
88 struct wl_event_source *urgent_timer; 82 struct wl_event_source *urgent_timer;
89 83
90 struct wl_list saved_buffers; // sway_saved_buffer::link
91
92 // The geometry for whatever the client is committing, regardless of 84 // The geometry for whatever the client is committing, regardless of
93 // transaction state. Updated on every commit. 85 // transaction state. Updated on every commit.
94 struct wlr_box geometry; 86 struct wlr_box geometry;
95 87
96 // The "old" geometry during a transaction. Used to damage the old location 88 struct wlr_ext_foreign_toplevel_handle_v1 *ext_foreign_toplevel;
97 // when a transaction is applied.
98 struct wlr_box saved_geometry;
99 89
100 struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel; 90 struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel;
101 struct wl_listener foreign_activate_request; 91 struct wl_listener foreign_activate_request;
@@ -108,8 +98,8 @@ struct sway_view {
108 list_t *executed_criteria; // struct criteria * 98 list_t *executed_criteria; // struct criteria *
109 99
110 union { 100 union {
111 struct wlr_xdg_surface *wlr_xdg_surface; 101 struct wlr_xdg_toplevel *wlr_xdg_toplevel;
112#if HAVE_XWAYLAND 102#if WLR_HAS_XWAYLAND
113 struct wlr_xwayland_surface *wlr_xwayland_surface; 103 struct wlr_xwayland_surface *wlr_xwayland_surface;
114#endif 104#endif
115 }; 105 };
@@ -118,8 +108,6 @@ struct sway_view {
118 struct wl_signal unmap; 108 struct wl_signal unmap;
119 } events; 109 } events;
120 110
121 struct wl_listener surface_new_subsurface;
122
123 int max_render_time; // In milliseconds 111 int max_render_time; // In milliseconds
124 112
125 enum seat_config_shortcuts_inhibit shortcuts_inhibit; 113 enum seat_config_shortcuts_inhibit shortcuts_inhibit;
@@ -140,10 +128,12 @@ struct sway_xdg_shell_view {
140 struct wl_listener unmap; 128 struct wl_listener unmap;
141 struct wl_listener destroy; 129 struct wl_listener destroy;
142}; 130};
143#if HAVE_XWAYLAND 131#if WLR_HAS_XWAYLAND
144struct sway_xwayland_view { 132struct sway_xwayland_view {
145 struct sway_view view; 133 struct sway_view view;
146 134
135 struct wlr_scene_tree *surface_tree;
136
147 struct wl_listener commit; 137 struct wl_listener commit;
148 struct wl_listener request_move; 138 struct wl_listener request_move;
149 struct wl_listener request_resize; 139 struct wl_listener request_resize;
@@ -155,71 +145,55 @@ struct sway_xwayland_view {
155 struct wl_listener set_title; 145 struct wl_listener set_title;
156 struct wl_listener set_class; 146 struct wl_listener set_class;
157 struct wl_listener set_role; 147 struct wl_listener set_role;
148 struct wl_listener set_startup_id;
158 struct wl_listener set_window_type; 149 struct wl_listener set_window_type;
159 struct wl_listener set_hints; 150 struct wl_listener set_hints;
160 struct wl_listener set_decorations; 151 struct wl_listener set_decorations;
152 struct wl_listener associate;
153 struct wl_listener dissociate;
161 struct wl_listener map; 154 struct wl_listener map;
162 struct wl_listener unmap; 155 struct wl_listener unmap;
163 struct wl_listener destroy; 156 struct wl_listener destroy;
164 struct wl_listener override_redirect; 157 struct wl_listener override_redirect;
158
159 struct wl_listener surface_tree_destroy;
165}; 160};
166 161
167struct sway_xwayland_unmanaged { 162struct sway_xwayland_unmanaged {
168 struct wlr_xwayland_surface *wlr_xwayland_surface; 163 struct wlr_xwayland_surface *wlr_xwayland_surface;
169 struct wl_list link;
170 164
171 int lx, ly; 165 struct wlr_scene_surface *surface_scene;
172 166
167 struct wl_listener request_activate;
173 struct wl_listener request_configure; 168 struct wl_listener request_configure;
174 struct wl_listener request_fullscreen; 169 struct wl_listener request_fullscreen;
175 struct wl_listener commit;
176 struct wl_listener set_geometry; 170 struct wl_listener set_geometry;
171 struct wl_listener associate;
172 struct wl_listener dissociate;
177 struct wl_listener map; 173 struct wl_listener map;
178 struct wl_listener unmap; 174 struct wl_listener unmap;
179 struct wl_listener destroy; 175 struct wl_listener destroy;
180 struct wl_listener override_redirect; 176 struct wl_listener override_redirect;
181}; 177};
182#endif 178#endif
183struct sway_view_child;
184
185struct sway_view_child_impl {
186 void (*get_root_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 179
180struct sway_popup_desc {
181 struct wlr_scene_node *relative;
197 struct sway_view *view; 182 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}; 183};
216 184
217struct sway_xdg_popup { 185struct sway_xdg_popup {
218 struct sway_view_child child; 186 struct sway_view *view;
187
188 struct wlr_scene_tree *scene_tree;
189 struct wlr_scene_tree *xdg_surface_tree;
190 struct wlr_xdg_popup *wlr_xdg_popup;
219 191
220 struct wlr_xdg_surface *wlr_xdg_surface; 192 struct sway_popup_desc desc;
221 193
194 struct wl_listener surface_commit;
222 struct wl_listener new_popup; 195 struct wl_listener new_popup;
196 struct wl_listener reposition;
223 struct wl_listener destroy; 197 struct wl_listener destroy;
224}; 198};
225 199
@@ -268,7 +242,12 @@ void view_set_activated(struct sway_view *view, bool activated);
268/** 242/**
269 * Called when the view requests to be focused. 243 * Called when the view requests to be focused.
270 */ 244 */
271void view_request_activate(struct sway_view *view); 245void view_request_activate(struct sway_view *view, struct sway_seat *seat);
246
247/*
248 * Called when the view requests urgent state
249 */
250void view_request_urgent(struct sway_view *view);
272 251
273/** 252/**
274 * If possible, instructs the client to change their decoration mode. 253 * If possible, instructs the client to change their decoration mode.
@@ -287,52 +266,42 @@ void view_close(struct sway_view *view);
287 266
288void view_close_popups(struct sway_view *view); 267void view_close_popups(struct sway_view *view);
289 268
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 269// view implementation
305 270
306void view_init(struct sway_view *view, enum sway_view_type type, 271bool view_init(struct sway_view *view, enum sway_view_type type,
307 const struct sway_view_impl *impl); 272 const struct sway_view_impl *impl);
308 273
309void view_destroy(struct sway_view *view); 274void view_destroy(struct sway_view *view);
310 275
311void view_begin_destroy(struct sway_view *view); 276void view_begin_destroy(struct sway_view *view);
312 277
278/**
279 * Map a view, ie. make it visible in the tree.
280 *
281 * `fullscreen` should be set to true (and optionally `fullscreen_output`
282 * should be populated) if the view should be made fullscreen immediately.
283 *
284 * `decoration` should be set to true if the client prefers CSD. The client's
285 * preference may be ignored.
286 */
313void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, 287void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
314 bool fullscreen, struct wlr_output *fullscreen_output, bool decoration); 288 bool fullscreen, struct wlr_output *fullscreen_output, bool decoration);
315 289
316void view_unmap(struct sway_view *view); 290void view_unmap(struct sway_view *view);
317 291
318void view_update_size(struct sway_view *view); 292void view_update_size(struct sway_view *view);
319void view_center_surface(struct sway_view *view); 293void view_center_and_clip_surface(struct sway_view *view);
320
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 294
328struct sway_view *view_from_wlr_xdg_surface( 295struct sway_view *view_from_wlr_xdg_surface(
329 struct wlr_xdg_surface *xdg_surface); 296 struct wlr_xdg_surface *xdg_surface);
330#if HAVE_XWAYLAND 297#if WLR_HAS_XWAYLAND
331struct sway_view *view_from_wlr_xwayland_surface( 298struct sway_view *view_from_wlr_xwayland_surface(
332 struct wlr_xwayland_surface *xsurface); 299 struct wlr_xwayland_surface *xsurface);
333#endif 300#endif
334struct sway_view *view_from_wlr_surface(struct wlr_surface *surface); 301struct sway_view *view_from_wlr_surface(struct wlr_surface *surface);
335 302
303void view_update_app_id(struct sway_view *view);
304
336/** 305/**
337 * Re-read the view's title property and update any relevant title bars. 306 * 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 307 * The force argument makes it recreate the title bars even if the title hasn't
@@ -362,4 +331,8 @@ void view_save_buffer(struct sway_view *view);
362 331
363bool view_is_transient_for(struct sway_view *child, struct sway_view *ancestor); 332bool view_is_transient_for(struct sway_view *child, struct sway_view *ancestor);
364 333
334void view_assign_ctx(struct sway_view *view, struct launcher_ctx *ctx);
335
336void view_send_frame_done(struct sway_view *view);
337
365#endif 338#endif
diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h
index b3d93a81..58bde20c 100644
--- a/include/sway/tree/workspace.h
+++ b/include/sway/tree/workspace.h
@@ -2,6 +2,8 @@
2#define _SWAY_WORKSPACE_H 2#define _SWAY_WORKSPACE_H
3 3
4#include <stdbool.h> 4#include <stdbool.h>
5#include <wlr/types/wlr_scene.h>
6#include "sway/config.h"
5#include "sway/tree/container.h" 7#include "sway/tree/container.h"
6#include "sway/tree/node.h" 8#include "sway/tree/node.h"
7 9
@@ -22,6 +24,12 @@ struct sway_workspace_state {
22 24
23struct sway_workspace { 25struct sway_workspace {
24 struct sway_node node; 26 struct sway_node node;
27
28 struct {
29 struct wlr_scene_tree *tiling;
30 struct wlr_scene_tree *fullscreen;
31 } layers;
32
25 struct sway_container *fullscreen; 33 struct sway_container *fullscreen;
26 34
27 char *name; 35 char *name;
diff --git a/include/sway/xdg_decoration.h b/include/sway/xdg_decoration.h
index 8bef4c6d..2388ebcb 100644
--- a/include/sway/xdg_decoration.h
+++ b/include/sway/xdg_decoration.h
@@ -16,4 +16,6 @@ struct sway_xdg_decoration {
16struct sway_xdg_decoration *xdg_decoration_from_surface( 16struct sway_xdg_decoration *xdg_decoration_from_surface(
17 struct wlr_surface *surface); 17 struct wlr_surface *surface);
18 18
19void set_xdg_decoration_mode(struct sway_xdg_decoration *deco);
20
19#endif 21#endif