diff options
Diffstat (limited to 'include')
34 files changed, 378 insertions, 142 deletions
diff --git a/include/background-image.h b/include/background-image.h index 15935ffd..a97ef375 100644 --- a/include/background-image.h +++ b/include/background-image.h | |||
@@ -1,6 +1,6 @@ | |||
1 | #ifndef _SWAY_BACKGROUND_IMAGE_H | 1 | #ifndef _SWAY_BACKGROUND_IMAGE_H |
2 | #define _SWAY_BACKGROUND_IMAGE_H | 2 | #define _SWAY_BACKGROUND_IMAGE_H |
3 | #include "cairo.h" | 3 | #include "cairo_util.h" |
4 | 4 | ||
5 | enum background_mode { | 5 | enum background_mode { |
6 | BACKGROUND_MODE_STRETCH, | 6 | BACKGROUND_MODE_STRETCH, |
diff --git a/include/cairo.h b/include/cairo_util.h index c1275db2..dc049c6d 100644 --- a/include/cairo.h +++ b/include/cairo_util.h | |||
@@ -1,8 +1,8 @@ | |||
1 | #ifndef _SWAY_CAIRO_H | 1 | #ifndef _SWAY_CAIRO_UTIL_H |
2 | #define _SWAY_CAIRO_H | 2 | #define _SWAY_CAIRO_UTIL_H |
3 | #include "config.h" | 3 | #include "config.h" |
4 | #include <stdint.h> | 4 | #include <stdint.h> |
5 | #include <cairo/cairo.h> | 5 | #include <cairo.h> |
6 | #include <wayland-client-protocol.h> | 6 | #include <wayland-client-protocol.h> |
7 | 7 | ||
8 | void cairo_set_source_u32(cairo_t *cairo, uint32_t color); | 8 | void cairo_set_source_u32(cairo_t *cairo, uint32_t color); |
diff --git a/include/gesture.h b/include/gesture.h new file mode 100644 index 00000000..9c6b0f91 --- /dev/null +++ b/include/gesture.h | |||
@@ -0,0 +1,104 @@ | |||
1 | #ifndef _SWAY_GESTURE_H | ||
2 | #define _SWAY_GESTURE_H | ||
3 | |||
4 | #include <stdbool.h> | ||
5 | #include <stdint.h> | ||
6 | |||
7 | /** | ||
8 | * A gesture type used in binding. | ||
9 | */ | ||
10 | enum gesture_type { | ||
11 | GESTURE_TYPE_NONE = 0, | ||
12 | GESTURE_TYPE_HOLD, | ||
13 | GESTURE_TYPE_PINCH, | ||
14 | GESTURE_TYPE_SWIPE, | ||
15 | }; | ||
16 | |||
17 | // Turns single type enum value to constant string representation. | ||
18 | const char *gesture_type_string(enum gesture_type direction); | ||
19 | |||
20 | // Value to use to accept any finger count | ||
21 | extern const uint8_t GESTURE_FINGERS_ANY; | ||
22 | |||
23 | /** | ||
24 | * A gesture direction used in binding. | ||
25 | */ | ||
26 | enum gesture_direction { | ||
27 | GESTURE_DIRECTION_NONE = 0, | ||
28 | // Directions based on delta x and y | ||
29 | GESTURE_DIRECTION_UP = 1 << 0, | ||
30 | GESTURE_DIRECTION_DOWN = 1 << 1, | ||
31 | GESTURE_DIRECTION_LEFT = 1 << 2, | ||
32 | GESTURE_DIRECTION_RIGHT = 1 << 3, | ||
33 | // Directions based on scale | ||
34 | GESTURE_DIRECTION_INWARD = 1 << 4, | ||
35 | GESTURE_DIRECTION_OUTWARD = 1 << 5, | ||
36 | // Directions based on rotation | ||
37 | GESTURE_DIRECTION_CLOCKWISE = 1 << 6, | ||
38 | GESTURE_DIRECTION_COUNTERCLOCKWISE = 1 << 7, | ||
39 | }; | ||
40 | |||
41 | // Turns single direction enum value to constant string representation. | ||
42 | const char *gesture_direction_string(enum gesture_direction direction); | ||
43 | |||
44 | /** | ||
45 | * Struct representing a pointer gesture | ||
46 | */ | ||
47 | struct gesture { | ||
48 | enum gesture_type type; | ||
49 | uint8_t fingers; | ||
50 | uint32_t directions; | ||
51 | }; | ||
52 | |||
53 | /** | ||
54 | * Parses gesture from <gesture>[:<fingers>][:<directions>] string. | ||
55 | * | ||
56 | * Return NULL on success, otherwise error message string | ||
57 | */ | ||
58 | char *gesture_parse(const char *input, struct gesture *output); | ||
59 | |||
60 | // Turns gesture into string representation | ||
61 | char *gesture_to_string(struct gesture *gesture); | ||
62 | |||
63 | // Check if gesture is of certain type and finger count. | ||
64 | bool gesture_check(struct gesture *target, | ||
65 | enum gesture_type type, uint8_t fingers); | ||
66 | |||
67 | // Check if a gesture target/binding is match by other gesture/input | ||
68 | bool gesture_match(struct gesture *target, | ||
69 | struct gesture *to_match, bool exact); | ||
70 | |||
71 | // Returns true if gesture are exactly the same | ||
72 | bool gesture_equal(struct gesture *a, struct gesture *b); | ||
73 | |||
74 | // Compare distance between two matched target gestures. | ||
75 | int8_t gesture_compare(struct gesture *a, struct gesture *b); | ||
76 | |||
77 | // Small helper struct to track gestures over time | ||
78 | struct gesture_tracker { | ||
79 | enum gesture_type type; | ||
80 | uint8_t fingers; | ||
81 | double dx, dy; | ||
82 | double scale; | ||
83 | double rotation; | ||
84 | }; | ||
85 | |||
86 | // Begin gesture tracking | ||
87 | void gesture_tracker_begin(struct gesture_tracker *tracker, | ||
88 | enum gesture_type type, uint8_t fingers); | ||
89 | |||
90 | // Check if the provides type is currently being tracked | ||
91 | bool gesture_tracker_check(struct gesture_tracker *tracker, | ||
92 | enum gesture_type type); | ||
93 | |||
94 | // Update gesture track with new data point | ||
95 | void gesture_tracker_update(struct gesture_tracker *tracker, double dx, | ||
96 | double dy, double scale, double rotation); | ||
97 | |||
98 | // Reset tracker | ||
99 | void gesture_tracker_cancel(struct gesture_tracker *tracker); | ||
100 | |||
101 | // Reset tracker and return gesture tracked | ||
102 | struct gesture *gesture_tracker_end(struct gesture_tracker *tracker); | ||
103 | |||
104 | #endif | ||
diff --git a/include/ipc-client.h b/include/ipc-client.h index d3895023..9c5712d7 100644 --- a/include/ipc-client.h +++ b/include/ipc-client.h | |||
@@ -1,6 +1,9 @@ | |||
1 | #ifndef _SWAY_IPC_CLIENT_H | 1 | #ifndef _SWAY_IPC_CLIENT_H |
2 | #define _SWAY_IPC_CLIENT_H | 2 | #define _SWAY_IPC_CLIENT_H |
3 | 3 | ||
4 | // arbitrary number, it's probably sufficient, higher number = more memory usage | ||
5 | #define JSON_MAX_DEPTH 512 | ||
6 | |||
4 | #include <stdbool.h> | 7 | #include <stdbool.h> |
5 | #include <stdint.h> | 8 | #include <stdint.h> |
6 | #include <sys/time.h> | 9 | #include <sys/time.h> |
diff --git a/include/pango.h b/include/pango.h index 6ab83c16..1db113c2 100644 --- a/include/pango.h +++ b/include/pango.h | |||
@@ -3,7 +3,7 @@ | |||
3 | #include <stdarg.h> | 3 | #include <stdarg.h> |
4 | #include <stdbool.h> | 4 | #include <stdbool.h> |
5 | #include <stdint.h> | 5 | #include <stdint.h> |
6 | #include <cairo/cairo.h> | 6 | #include <cairo.h> |
7 | #include <pango/pangocairo.h> | 7 | #include <pango/pangocairo.h> |
8 | 8 | ||
9 | /** | 9 | /** |
@@ -13,11 +13,12 @@ | |||
13 | * escaped string to dest if provided. | 13 | * escaped string to dest if provided. |
14 | */ | 14 | */ |
15 | size_t escape_markup_text(const char *src, char *dest); | 15 | size_t escape_markup_text(const char *src, char *dest); |
16 | PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, | 16 | PangoLayout *get_pango_layout(cairo_t *cairo, const PangoFontDescription *desc, |
17 | const char *text, double scale, bool markup); | 17 | const char *text, double scale, bool markup); |
18 | void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, | 18 | void get_text_size(cairo_t *cairo, const PangoFontDescription *desc, int *width, int *height, |
19 | int *baseline, double scale, bool markup, const char *fmt, ...); | 19 | int *baseline, double scale, bool markup, const char *fmt, ...); |
20 | void pango_printf(cairo_t *cairo, const char *font, | 20 | void get_text_metrics(const PangoFontDescription *desc, int *height, int *baseline); |
21 | void render_text(cairo_t *cairo, PangoFontDescription *desc, | ||
21 | double scale, bool markup, const char *fmt, ...); | 22 | double scale, bool markup, const char *fmt, ...); |
22 | 23 | ||
23 | #endif | 24 | #endif |
diff --git a/include/pool-buffer.h b/include/pool-buffer.h index 54f5be06..b7a95afe 100644 --- a/include/pool-buffer.h +++ b/include/pool-buffer.h | |||
@@ -1,6 +1,6 @@ | |||
1 | #ifndef _SWAY_BUFFERS_H | 1 | #ifndef _SWAY_BUFFERS_H |
2 | #define _SWAY_BUFFERS_H | 2 | #define _SWAY_BUFFERS_H |
3 | #include <cairo/cairo.h> | 3 | #include <cairo.h> |
4 | #include <pango/pangocairo.h> | 4 | #include <pango/pangocairo.h> |
5 | #include <stdbool.h> | 5 | #include <stdbool.h> |
6 | #include <stdint.h> | 6 | #include <stdint.h> |
diff --git a/include/stringop.h b/include/stringop.h index 8d7089e9..b29f59b2 100644 --- a/include/stringop.h +++ b/include/stringop.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define _SWAY_STRINGOP_H | 2 | #define _SWAY_STRINGOP_H |
3 | 3 | ||
4 | #include <stdbool.h> | 4 | #include <stdbool.h> |
5 | #include <stddef.h> | ||
5 | #include "list.h" | 6 | #include "list.h" |
6 | 7 | ||
7 | void strip_whitespace(char *str); | 8 | void strip_whitespace(char *str); |
diff --git a/include/sway/commands.h b/include/sway/commands.h index 964b3661..013a7b82 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h | |||
@@ -46,8 +46,8 @@ enum expected_args { | |||
46 | struct cmd_results *checkarg(int argc, const char *name, | 46 | struct cmd_results *checkarg(int argc, const char *name, |
47 | enum expected_args type, int val); | 47 | enum expected_args type, int val); |
48 | 48 | ||
49 | struct cmd_handler *find_handler(char *line, struct cmd_handler *cmd_handlers, | 49 | const struct cmd_handler *find_handler(char *line, |
50 | size_t handlers_size); | 50 | const struct cmd_handler *cmd_handlers, size_t handlers_size); |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * Parse and executes a command. | 53 | * Parse and executes a command. |
@@ -68,7 +68,7 @@ struct cmd_results *config_command(char *command, char **new_block); | |||
68 | * Parse and handle a sub command | 68 | * Parse and handle a sub command |
69 | */ | 69 | */ |
70 | struct cmd_results *config_subcommand(char **argv, int argc, | 70 | struct cmd_results *config_subcommand(char **argv, int argc, |
71 | struct cmd_handler *handlers, size_t handlers_size); | 71 | const struct cmd_handler *handlers, size_t handlers_size); |
72 | /* | 72 | /* |
73 | * Parses a command policy rule. | 73 | * Parses a command policy rule. |
74 | */ | 74 | */ |
@@ -106,12 +106,14 @@ sway_cmd cmd_exec_process; | |||
106 | sway_cmd cmd_assign; | 106 | sway_cmd cmd_assign; |
107 | sway_cmd cmd_bar; | 107 | sway_cmd cmd_bar; |
108 | sway_cmd cmd_bindcode; | 108 | sway_cmd cmd_bindcode; |
109 | sway_cmd cmd_bindgesture; | ||
109 | sway_cmd cmd_bindswitch; | 110 | sway_cmd cmd_bindswitch; |
110 | sway_cmd cmd_bindsym; | 111 | sway_cmd cmd_bindsym; |
111 | sway_cmd cmd_border; | 112 | sway_cmd cmd_border; |
112 | sway_cmd cmd_client_noop; | 113 | sway_cmd cmd_client_noop; |
113 | sway_cmd cmd_client_focused; | 114 | sway_cmd cmd_client_focused; |
114 | sway_cmd cmd_client_focused_inactive; | 115 | sway_cmd cmd_client_focused_inactive; |
116 | sway_cmd cmd_client_focused_tab_title; | ||
115 | sway_cmd cmd_client_unfocused; | 117 | sway_cmd cmd_client_unfocused; |
116 | sway_cmd cmd_client_urgent; | 118 | sway_cmd cmd_client_urgent; |
117 | sway_cmd cmd_client_placeholder; | 119 | sway_cmd cmd_client_placeholder; |
@@ -190,6 +192,7 @@ sway_cmd cmd_titlebar_border_thickness; | |||
190 | sway_cmd cmd_titlebar_padding; | 192 | sway_cmd cmd_titlebar_padding; |
191 | sway_cmd cmd_unbindcode; | 193 | sway_cmd cmd_unbindcode; |
192 | sway_cmd cmd_unbindswitch; | 194 | sway_cmd cmd_unbindswitch; |
195 | sway_cmd cmd_unbindgesture; | ||
193 | sway_cmd cmd_unbindsym; | 196 | sway_cmd cmd_unbindsym; |
194 | sway_cmd cmd_unmark; | 197 | sway_cmd cmd_unmark; |
195 | sway_cmd cmd_urgent; | 198 | sway_cmd cmd_urgent; |
@@ -282,7 +285,10 @@ sway_cmd output_cmd_dpms; | |||
282 | sway_cmd output_cmd_enable; | 285 | sway_cmd output_cmd_enable; |
283 | sway_cmd output_cmd_max_render_time; | 286 | sway_cmd output_cmd_max_render_time; |
284 | sway_cmd output_cmd_mode; | 287 | sway_cmd output_cmd_mode; |
288 | sway_cmd output_cmd_modeline; | ||
285 | sway_cmd output_cmd_position; | 289 | sway_cmd output_cmd_position; |
290 | sway_cmd output_cmd_power; | ||
291 | sway_cmd output_cmd_render_bit_depth; | ||
286 | sway_cmd output_cmd_scale; | 292 | sway_cmd output_cmd_scale; |
287 | sway_cmd output_cmd_scale_filter; | 293 | sway_cmd output_cmd_scale_filter; |
288 | sway_cmd output_cmd_subpixel; | 294 | sway_cmd output_cmd_subpixel; |
diff --git a/include/sway/config.h b/include/sway/config.h index 59f22ae2..68c06846 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -5,16 +5,19 @@ | |||
5 | #include <string.h> | 5 | #include <string.h> |
6 | #include <time.h> | 6 | #include <time.h> |
7 | #include <wlr/interfaces/wlr_switch.h> | 7 | #include <wlr/interfaces/wlr_switch.h> |
8 | #include <wlr/types/wlr_box.h> | ||
9 | #include <wlr/types/wlr_tablet_tool.h> | 8 | #include <wlr/types/wlr_tablet_tool.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" |
13 | #include "swaynag.h" | 15 | #include "swaynag.h" |
14 | #include "tree/container.h" | 16 | #include "tree/container.h" |
15 | #include "sway/input/tablet.h" | 17 | #include "sway/input/tablet.h" |
16 | #include "sway/tree/root.h" | 18 | #include "sway/tree/root.h" |
17 | #include "wlr-layer-shell-unstable-v1-protocol.h" | 19 | #include "wlr-layer-shell-unstable-v1-protocol.h" |
20 | #include <pango/pangocairo.h> | ||
18 | 21 | ||
19 | // TODO: Refactor this shit | 22 | // TODO: Refactor this shit |
20 | 23 | ||
@@ -31,7 +34,8 @@ enum binding_input_type { | |||
31 | BINDING_KEYSYM, | 34 | BINDING_KEYSYM, |
32 | BINDING_MOUSECODE, | 35 | BINDING_MOUSECODE, |
33 | BINDING_MOUSESYM, | 36 | BINDING_MOUSESYM, |
34 | BINDING_SWITCH | 37 | BINDING_SWITCH, // dummy, only used to call seat_execute_command |
38 | BINDING_GESTURE // dummy, only used to call seat_execute_command | ||
35 | }; | 39 | }; |
36 | 40 | ||
37 | enum binding_flags { | 41 | enum binding_flags { |
@@ -44,10 +48,11 @@ enum binding_flags { | |||
44 | BINDING_RELOAD = 1 << 6, // switch only; (re)trigger binding on reload | 48 | BINDING_RELOAD = 1 << 6, // switch only; (re)trigger binding on reload |
45 | BINDING_INHIBITED = 1 << 7, // keyboard only: ignore shortcut inhibitor | 49 | BINDING_INHIBITED = 1 << 7, // keyboard only: ignore shortcut inhibitor |
46 | BINDING_NOREPEAT = 1 << 8, // keyboard only; do not trigger when repeating a held key | 50 | BINDING_NOREPEAT = 1 << 8, // keyboard only; do not trigger when repeating a held key |
51 | BINDING_EXACT = 1 << 9, // gesture only; only trigger on exact match | ||
47 | }; | 52 | }; |
48 | 53 | ||
49 | /** | 54 | /** |
50 | * A key binding and an associated command. | 55 | * A key (or mouse) binding and an associated command. |
51 | */ | 56 | */ |
52 | struct sway_binding { | 57 | struct sway_binding { |
53 | enum binding_input_type type; | 58 | enum binding_input_type type; |
@@ -61,12 +66,10 @@ struct sway_binding { | |||
61 | char *command; | 66 | char *command; |
62 | }; | 67 | }; |
63 | 68 | ||
64 | /** | 69 | enum sway_switch_trigger { |
65 | * A mouse binding and an associated command. | 70 | SWAY_SWITCH_TRIGGER_OFF, |
66 | */ | 71 | SWAY_SWITCH_TRIGGER_ON, |
67 | struct sway_mouse_binding { | 72 | SWAY_SWITCH_TRIGGER_TOGGLE, |
68 | uint32_t button; | ||
69 | char *command; | ||
70 | }; | 73 | }; |
71 | 74 | ||
72 | /** | 75 | /** |
@@ -74,12 +77,22 @@ struct sway_mouse_binding { | |||
74 | */ | 77 | */ |
75 | struct sway_switch_binding { | 78 | struct sway_switch_binding { |
76 | enum wlr_switch_type type; | 79 | enum wlr_switch_type type; |
77 | enum wlr_switch_state state; | 80 | enum sway_switch_trigger trigger; |
78 | uint32_t flags; | 81 | uint32_t flags; |
79 | char *command; | 82 | char *command; |
80 | }; | 83 | }; |
81 | 84 | ||
82 | /** | 85 | /** |
86 | * A gesture binding and an associated command. | ||
87 | */ | ||
88 | struct sway_gesture_binding { | ||
89 | char *input; | ||
90 | uint32_t flags; | ||
91 | struct gesture gesture; | ||
92 | char *command; | ||
93 | }; | ||
94 | |||
95 | /** | ||
83 | * Focus on window activation. | 96 | * Focus on window activation. |
84 | */ | 97 | */ |
85 | enum sway_fowa { | 98 | enum sway_fowa { |
@@ -98,6 +111,7 @@ struct sway_mode { | |||
98 | list_t *keycode_bindings; | 111 | list_t *keycode_bindings; |
99 | list_t *mouse_bindings; | 112 | list_t *mouse_bindings; |
100 | list_t *switch_bindings; | 113 | list_t *switch_bindings; |
114 | list_t *gesture_bindings; | ||
101 | bool pango; | 115 | bool pango; |
102 | }; | 116 | }; |
103 | 117 | ||
@@ -233,12 +247,6 @@ struct seat_config { | |||
233 | } xcursor_theme; | 247 | } xcursor_theme; |
234 | }; | 248 | }; |
235 | 249 | ||
236 | enum config_dpms { | ||
237 | DPMS_IGNORE, | ||
238 | DPMS_ON, | ||
239 | DPMS_OFF, | ||
240 | }; | ||
241 | |||
242 | enum scale_filter_mode { | 250 | enum scale_filter_mode { |
243 | SCALE_FILTER_DEFAULT, // the default is currently smart | 251 | SCALE_FILTER_DEFAULT, // the default is currently smart |
244 | SCALE_FILTER_LINEAR, | 252 | SCALE_FILTER_LINEAR, |
@@ -246,6 +254,12 @@ enum scale_filter_mode { | |||
246 | SCALE_FILTER_SMART, | 254 | SCALE_FILTER_SMART, |
247 | }; | 255 | }; |
248 | 256 | ||
257 | enum render_bit_depth { | ||
258 | RENDER_BIT_DEPTH_DEFAULT, // the default is currently 8 | ||
259 | RENDER_BIT_DEPTH_8, | ||
260 | RENDER_BIT_DEPTH_10, | ||
261 | }; | ||
262 | |||
249 | /** | 263 | /** |
250 | * Size and position configuration for a particular output. | 264 | * Size and position configuration for a particular output. |
251 | * | 265 | * |
@@ -254,9 +268,11 @@ enum scale_filter_mode { | |||
254 | struct output_config { | 268 | struct output_config { |
255 | char *name; | 269 | char *name; |
256 | int enabled; | 270 | int enabled; |
271 | int power; | ||
257 | int width, height; | 272 | int width, height; |
258 | float refresh_rate; | 273 | float refresh_rate; |
259 | int custom_mode; | 274 | int custom_mode; |
275 | drmModeModeInfo drm_mode; | ||
260 | int x, y; | 276 | int x, y; |
261 | float scale; | 277 | float scale; |
262 | enum scale_filter_mode scale_filter; | 278 | enum scale_filter_mode scale_filter; |
@@ -264,11 +280,11 @@ struct output_config { | |||
264 | enum wl_output_subpixel subpixel; | 280 | enum wl_output_subpixel subpixel; |
265 | int max_render_time; // In milliseconds | 281 | int max_render_time; // In milliseconds |
266 | int adaptive_sync; | 282 | int adaptive_sync; |
283 | enum render_bit_depth render_bit_depth; | ||
267 | 284 | ||
268 | char *background; | 285 | char *background; |
269 | char *background_option; | 286 | char *background_option; |
270 | char *background_fallback; | 287 | char *background_fallback; |
271 | enum config_dpms dpms_state; | ||
272 | }; | 288 | }; |
273 | 289 | ||
274 | /** | 290 | /** |
@@ -281,6 +297,12 @@ struct side_gaps { | |||
281 | int left; | 297 | int left; |
282 | }; | 298 | }; |
283 | 299 | ||
300 | enum smart_gaps_mode { | ||
301 | SMART_GAPS_OFF, | ||
302 | SMART_GAPS_ON, | ||
303 | SMART_GAPS_INVERSE_OUTER, | ||
304 | }; | ||
305 | |||
284 | /** | 306 | /** |
285 | * Stores configuration for a workspace, regardless of whether the workspace | 307 | * Stores configuration for a workspace, regardless of whether the workspace |
286 | * exists. | 308 | * exists. |
@@ -292,6 +314,12 @@ struct workspace_config { | |||
292 | struct side_gaps gaps_outer; | 314 | struct side_gaps gaps_outer; |
293 | }; | 315 | }; |
294 | 316 | ||
317 | enum pango_markup_config { | ||
318 | PANGO_MARKUP_DISABLED = false, | ||
319 | PANGO_MARKUP_ENABLED = true, | ||
320 | PANGO_MARKUP_DEFAULT // The default is font dependent ("pango:" prefix) | ||
321 | }; | ||
322 | |||
295 | struct bar_config { | 323 | struct bar_config { |
296 | char *swaybar_command; | 324 | char *swaybar_command; |
297 | struct wl_client *client; | 325 | struct wl_client *client; |
@@ -323,7 +351,7 @@ struct bar_config { | |||
323 | char *position; | 351 | char *position; |
324 | list_t *bindings; | 352 | list_t *bindings; |
325 | char *status_command; | 353 | char *status_command; |
326 | bool pango_markup; | 354 | enum pango_markup_config pango_markup; |
327 | char *font; | 355 | char *font; |
328 | int height; // -1 not defined | 356 | int height; // -1 not defined |
329 | bool workspace_buttons; | 357 | bool workspace_buttons; |
@@ -410,14 +438,6 @@ enum sway_popup_during_fullscreen { | |||
410 | POPUP_LEAVE, | 438 | POPUP_LEAVE, |
411 | }; | 439 | }; |
412 | 440 | ||
413 | enum command_context { | ||
414 | CONTEXT_CONFIG = 1 << 0, | ||
415 | CONTEXT_BINDING = 1 << 1, | ||
416 | CONTEXT_IPC = 1 << 2, | ||
417 | CONTEXT_CRITERIA = 1 << 3, | ||
418 | CONTEXT_ALL = 0xFFFFFFFF, | ||
419 | }; | ||
420 | |||
421 | enum focus_follows_mouse_mode { | 441 | enum focus_follows_mouse_mode { |
422 | FOLLOWS_NO, | 442 | FOLLOWS_NO, |
423 | FOLLOWS_YES, | 443 | FOLLOWS_YES, |
@@ -479,9 +499,10 @@ struct sway_config { | |||
479 | char *floating_scroll_right_cmd; | 499 | char *floating_scroll_right_cmd; |
480 | enum sway_container_layout default_orientation; | 500 | enum sway_container_layout default_orientation; |
481 | enum sway_container_layout default_layout; | 501 | enum sway_container_layout default_layout; |
482 | char *font; | 502 | char *font; // Used for IPC. |
483 | size_t font_height; | 503 | PangoFontDescription *font_description; // Used internally for rendering and validating. |
484 | size_t font_baseline; | 504 | int font_height; |
505 | int font_baseline; | ||
485 | bool pango_markup; | 506 | bool pango_markup; |
486 | int titlebar_border_thickness; | 507 | int titlebar_border_thickness; |
487 | int titlebar_h_padding; | 508 | int titlebar_h_padding; |
@@ -512,7 +533,7 @@ struct sway_config { | |||
512 | bool tiling_drag; | 533 | bool tiling_drag; |
513 | int tiling_drag_threshold; | 534 | int tiling_drag_threshold; |
514 | 535 | ||
515 | bool smart_gaps; | 536 | enum smart_gaps_mode smart_gaps; |
516 | int gaps_inner; | 537 | int gaps_inner; |
517 | struct side_gaps gaps_outer; | 538 | struct side_gaps gaps_outer; |
518 | 539 | ||
@@ -535,12 +556,15 @@ struct sway_config { | |||
535 | struct { | 556 | struct { |
536 | struct border_colors focused; | 557 | struct border_colors focused; |
537 | struct border_colors focused_inactive; | 558 | struct border_colors focused_inactive; |
559 | struct border_colors focused_tab_title; | ||
538 | struct border_colors unfocused; | 560 | struct border_colors unfocused; |
539 | struct border_colors urgent; | 561 | struct border_colors urgent; |
540 | struct border_colors placeholder; | 562 | struct border_colors placeholder; |
541 | float background[4]; | 563 | float background[4]; |
542 | } border_colors; | 564 | } border_colors; |
543 | 565 | ||
566 | bool has_focused_tab_title; | ||
567 | |||
544 | // floating view | 568 | // floating view |
545 | int32_t floating_maximum_width; | 569 | int32_t floating_maximum_width; |
546 | int32_t floating_maximum_height; | 570 | int32_t floating_maximum_height; |
@@ -559,7 +583,7 @@ struct sway_config { | |||
559 | struct sway_node *node; | 583 | struct sway_node *node; |
560 | struct sway_container *container; | 584 | struct sway_container *container; |
561 | struct sway_workspace *workspace; | 585 | struct sway_workspace *workspace; |
562 | bool using_criteria; | 586 | bool node_overridden; // True if the node is selected by means other than focus |
563 | struct { | 587 | struct { |
564 | int argc; | 588 | int argc; |
565 | char **argv; | 589 | char **argv; |
@@ -675,6 +699,8 @@ void free_sway_binding(struct sway_binding *sb); | |||
675 | 699 | ||
676 | void free_switch_binding(struct sway_switch_binding *binding); | 700 | void free_switch_binding(struct sway_switch_binding *binding); |
677 | 701 | ||
702 | void free_gesture_binding(struct sway_gesture_binding *binding); | ||
703 | |||
678 | void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding); | 704 | void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding); |
679 | 705 | ||
680 | void load_swaybar(struct bar_config *bar); | 706 | void load_swaybar(struct bar_config *bar); |
@@ -690,14 +716,13 @@ void free_bar_binding(struct bar_binding *binding); | |||
690 | void free_workspace_config(struct workspace_config *wsc); | 716 | void free_workspace_config(struct workspace_config *wsc); |
691 | 717 | ||
692 | /** | 718 | /** |
693 | * Updates the value of config->font_height based on the max title height | 719 | * Updates the value of config->font_height based on the metrics for title's |
694 | * reported by each container. If recalculate is true, the containers will | 720 | * font as reported by pango. |
695 | * recalculate their heights before reporting. | 721 | * |
696 | * | ||
697 | * If the height has changed, all containers will be rearranged to take on the | 722 | * If the height has changed, all containers will be rearranged to take on the |
698 | * new size. | 723 | * new size. |
699 | */ | 724 | */ |
700 | void config_update_font_height(bool recalculate); | 725 | void config_update_font_height(void); |
701 | 726 | ||
702 | /** | 727 | /** |
703 | * Convert bindsym into bindcode using the first configured layout. | 728 | * Convert bindsym into bindcode using the first configured layout. |
diff --git a/include/sway/criteria.h b/include/sway/criteria.h index ad8610cd..59f57f94 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 | ||
17 | enum pattern_type { | 18 | enum pattern_type { |
18 | PATTERN_PCRE, | 19 | PATTERN_PCRE2, |
19 | PATTERN_FOCUSED, | 20 | PATTERN_FOCUSED, |
20 | }; | 21 | }; |
21 | 22 | ||
22 | struct pattern { | 23 | struct pattern { |
23 | enum pattern_type match_type; | 24 | enum pattern_type match_type; |
24 | pcre *regex; | 25 | pcre2_code *regex; |
25 | }; | 26 | }; |
26 | 27 | ||
27 | struct criteria { | 28 | struct criteria { |
diff --git a/include/sway/desktop.h b/include/sway/desktop.h index c969a76b..7f2f5b3e 100644 --- a/include/sway/desktop.h +++ b/include/sway/desktop.h | |||
@@ -1,4 +1,4 @@ | |||
1 | #include <wlr/types/wlr_surface.h> | 1 | #include <wlr/types/wlr_compositor.h> |
2 | 2 | ||
3 | struct sway_container; | 3 | struct sway_container; |
4 | struct sway_view; | 4 | struct sway_view; |
diff --git a/include/sway/desktop/idle_inhibit_v1.h b/include/sway/desktop/idle_inhibit_v1.h index 0adafdb9..58d54c68 100644 --- a/include/sway/desktop/idle_inhibit_v1.h +++ b/include/sway/desktop/idle_inhibit_v1.h | |||
@@ -22,6 +22,7 @@ struct sway_idle_inhibit_manager_v1 { | |||
22 | 22 | ||
23 | struct sway_idle_inhibitor_v1 { | 23 | struct sway_idle_inhibitor_v1 { |
24 | struct sway_idle_inhibit_manager_v1 *manager; | 24 | struct sway_idle_inhibit_manager_v1 *manager; |
25 | struct wlr_idle_inhibitor_v1 *wlr_inhibitor; | ||
25 | struct sway_view *view; | 26 | struct sway_view *view; |
26 | enum sway_idle_inhibit_mode mode; | 27 | enum sway_idle_inhibit_mode mode; |
27 | 28 | ||
diff --git a/include/sway/desktop/transaction.h b/include/sway/desktop/transaction.h index 175489c5..7dd58ba8 100644 --- a/include/sway/desktop/transaction.h +++ b/include/sway/desktop/transaction.h | |||
@@ -28,6 +28,12 @@ struct sway_view; | |||
28 | */ | 28 | */ |
29 | void transaction_commit_dirty(void); | 29 | void transaction_commit_dirty(void); |
30 | 30 | ||
31 | /* | ||
32 | * Same as transaction_commit_dirty, but signalling that this is a | ||
33 | * client-initiated change has already taken effect. | ||
34 | */ | ||
35 | void transaction_commit_dirty_client(void); | ||
36 | |||
31 | /** | 37 | /** |
32 | * Notify the transaction system that a view is ready for the new layout. | 38 | * Notify the transaction system that a view is ready for the new layout. |
33 | * | 39 | * |
@@ -45,10 +51,4 @@ void transaction_notify_view_ready_by_serial(struct sway_view *view, | |||
45 | void transaction_notify_view_ready_by_geometry(struct sway_view *view, | 51 | void transaction_notify_view_ready_by_geometry(struct sway_view *view, |
46 | double x, double y, int width, int height); | 52 | double x, double y, int width, int height); |
47 | 53 | ||
48 | /** | ||
49 | * Unconditionally notify the transaction system that a view is ready for the | ||
50 | * new layout. | ||
51 | */ | ||
52 | void transaction_notify_view_ready_immediately(struct sway_view *view); | ||
53 | |||
54 | #endif | 54 | #endif |
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 6a38190b..8a2898dd 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 | ||
@@ -36,6 +36,8 @@ struct sway_cursor { | |||
36 | bool active_confine_requires_warp; | 36 | bool active_confine_requires_warp; |
37 | 37 | ||
38 | struct wlr_pointer_gestures_v1 *pointer_gestures; | 38 | struct wlr_pointer_gestures_v1 *pointer_gestures; |
39 | struct wl_listener hold_begin; | ||
40 | struct wl_listener hold_end; | ||
39 | struct wl_listener pinch_begin; | 41 | struct wl_listener pinch_begin; |
40 | struct wl_listener pinch_update; | 42 | struct wl_listener pinch_update; |
41 | struct wl_listener pinch_end; | 43 | struct wl_listener pinch_end; |
@@ -52,7 +54,9 @@ struct sway_cursor { | |||
52 | struct wl_listener touch_down; | 54 | struct wl_listener touch_down; |
53 | struct wl_listener touch_up; | 55 | struct wl_listener touch_up; |
54 | struct wl_listener touch_motion; | 56 | struct wl_listener touch_motion; |
57 | struct wl_listener touch_frame; | ||
55 | bool simulating_pointer_from_touch; | 58 | bool simulating_pointer_from_touch; |
59 | bool pointer_touch_up; | ||
56 | int32_t pointer_touch_id; | 60 | int32_t pointer_touch_id; |
57 | 61 | ||
58 | struct wl_listener tool_axis; | 62 | struct wl_listener tool_axis; |
@@ -108,7 +112,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor, | |||
108 | enum wlr_button_state state); | 112 | enum wlr_button_state state); |
109 | 113 | ||
110 | void dispatch_cursor_axis(struct sway_cursor *cursor, | 114 | void dispatch_cursor_axis(struct sway_cursor *cursor, |
111 | struct wlr_event_pointer_axis *event); | 115 | struct wlr_pointer_axis_event *event); |
112 | 116 | ||
113 | void cursor_set_image(struct sway_cursor *cursor, const char *image, | 117 | void cursor_set_image(struct sway_cursor *cursor, const char *image, |
114 | struct wl_client *client); | 118 | struct wl_client *client); |
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 | ||
51 | struct sway_keyboard { | 51 | struct 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 de019976..890d632e 100644 --- a/include/sway/input/libinput.h +++ b/include/sway/input/libinput.h | |||
@@ -6,4 +6,6 @@ void sway_input_configure_libinput_device(struct sway_input_device *device); | |||
6 | 6 | ||
7 | void sway_input_reset_libinput_device(struct sway_input_device *device); | 7 | void sway_input_reset_libinput_device(struct sway_input_device *device); |
8 | 8 | ||
9 | bool sway_libinput_device_is_builtin(struct sway_input_device *device); | ||
10 | |||
9 | #endif | 11 | #endif |
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 4118df66..c2041742 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -18,7 +18,23 @@ struct sway_seatop_impl { | |||
18 | enum wlr_button_state state); | 18 | enum wlr_button_state state); |
19 | void (*pointer_motion)(struct sway_seat *seat, uint32_t time_msec); | 19 | void (*pointer_motion)(struct sway_seat *seat, uint32_t time_msec); |
20 | void (*pointer_axis)(struct sway_seat *seat, | 20 | void (*pointer_axis)(struct sway_seat *seat, |
21 | struct wlr_event_pointer_axis *event); | 21 | struct wlr_pointer_axis_event *event); |
22 | void (*hold_begin)(struct sway_seat *seat, | ||
23 | struct wlr_pointer_hold_begin_event *event); | ||
24 | void (*hold_end)(struct sway_seat *seat, | ||
25 | struct wlr_pointer_hold_end_event *event); | ||
26 | void (*pinch_begin)(struct sway_seat *seat, | ||
27 | struct wlr_pointer_pinch_begin_event *event); | ||
28 | void (*pinch_update)(struct sway_seat *seat, | ||
29 | struct wlr_pointer_pinch_update_event *event); | ||
30 | void (*pinch_end)(struct sway_seat *seat, | ||
31 | struct wlr_pointer_pinch_end_event *event); | ||
32 | void (*swipe_begin)(struct sway_seat *seat, | ||
33 | struct wlr_pointer_swipe_begin_event *event); | ||
34 | void (*swipe_update)(struct sway_seat *seat, | ||
35 | struct wlr_pointer_swipe_update_event *event); | ||
36 | void (*swipe_end)(struct sway_seat *seat, | ||
37 | struct wlr_pointer_swipe_end_event *event); | ||
22 | void (*rebase)(struct sway_seat *seat, uint32_t time_msec); | 38 | void (*rebase)(struct sway_seat *seat, uint32_t time_msec); |
23 | void (*tablet_tool_motion)(struct sway_seat *seat, | 39 | void (*tablet_tool_motion)(struct sway_seat *seat, |
24 | struct sway_tablet_tool *tool, uint32_t time_msec); | 40 | struct sway_tablet_tool *tool, uint32_t time_msec); |
@@ -185,6 +201,10 @@ struct sway_workspace *seat_get_last_known_workspace(struct sway_seat *seat); | |||
185 | 201 | ||
186 | struct sway_container *seat_get_focused_container(struct sway_seat *seat); | 202 | struct sway_container *seat_get_focused_container(struct sway_seat *seat); |
187 | 203 | ||
204 | // Force focus to a particular surface that is not part of the workspace | ||
205 | // hierarchy (used for lockscreen) | ||
206 | void sway_force_focus(struct wlr_surface *surface); | ||
207 | |||
188 | /** | 208 | /** |
189 | * Return the last container to be focused for the seat (or the most recently | 209 | * Return the last container to be focused for the seat (or the most recently |
190 | * opened if no container has received focused) that is a child of the given | 210 | * opened if no container has received focused) that is a child of the given |
@@ -239,7 +259,10 @@ enum wlr_edges find_resize_edge(struct sway_container *cont, | |||
239 | void seatop_begin_default(struct sway_seat *seat); | 259 | void seatop_begin_default(struct sway_seat *seat); |
240 | 260 | ||
241 | void seatop_begin_down(struct sway_seat *seat, struct sway_container *con, | 261 | void seatop_begin_down(struct sway_seat *seat, struct sway_container *con, |
242 | uint32_t time_msec, int sx, int sy); | 262 | uint32_t time_msec, double sx, double sy); |
263 | |||
264 | void seatop_begin_down_on_surface(struct sway_seat *seat, | ||
265 | struct wlr_surface *surface, uint32_t time_msec, double sx, double sy); | ||
243 | 266 | ||
244 | void seatop_begin_move_floating(struct sway_seat *seat, | 267 | void seatop_begin_move_floating(struct sway_seat *seat, |
245 | struct sway_container *con); | 268 | struct sway_container *con); |
@@ -271,7 +294,7 @@ void seatop_button(struct sway_seat *seat, uint32_t time_msec, | |||
271 | void seatop_pointer_motion(struct sway_seat *seat, uint32_t time_msec); | 294 | void seatop_pointer_motion(struct sway_seat *seat, uint32_t time_msec); |
272 | 295 | ||
273 | void seatop_pointer_axis(struct sway_seat *seat, | 296 | void seatop_pointer_axis(struct sway_seat *seat, |
274 | struct wlr_event_pointer_axis *event); | 297 | struct wlr_pointer_axis_event *event); |
275 | 298 | ||
276 | void seatop_tablet_tool_tip(struct sway_seat *seat, | 299 | void seatop_tablet_tool_tip(struct sway_seat *seat, |
277 | struct sway_tablet_tool *tool, uint32_t time_msec, | 300 | struct sway_tablet_tool *tool, uint32_t time_msec, |
@@ -280,6 +303,25 @@ void seatop_tablet_tool_tip(struct sway_seat *seat, | |||
280 | void seatop_tablet_tool_motion(struct sway_seat *seat, | 303 | void seatop_tablet_tool_motion(struct sway_seat *seat, |
281 | struct sway_tablet_tool *tool, uint32_t time_msec); | 304 | struct sway_tablet_tool *tool, uint32_t time_msec); |
282 | 305 | ||
306 | void seatop_hold_begin(struct sway_seat *seat, | ||
307 | struct wlr_pointer_hold_begin_event *event); | ||
308 | void seatop_hold_end(struct sway_seat *seat, | ||
309 | struct wlr_pointer_hold_end_event *event); | ||
310 | |||
311 | void seatop_pinch_begin(struct sway_seat *seat, | ||
312 | struct wlr_pointer_pinch_begin_event *event); | ||
313 | void seatop_pinch_update(struct sway_seat *seat, | ||
314 | struct wlr_pointer_pinch_update_event *event); | ||
315 | void seatop_pinch_end(struct sway_seat *seat, | ||
316 | struct wlr_pointer_pinch_end_event *event); | ||
317 | |||
318 | void seatop_swipe_begin(struct sway_seat *seat, | ||
319 | struct wlr_pointer_swipe_begin_event *event); | ||
320 | void seatop_swipe_update(struct sway_seat *seat, | ||
321 | struct wlr_pointer_swipe_update_event *event); | ||
322 | void seatop_swipe_end(struct sway_seat *seat, | ||
323 | struct wlr_pointer_swipe_end_event *event); | ||
324 | |||
283 | void seatop_rebase(struct sway_seat *seat, uint32_t time_msec); | 325 | void seatop_rebase(struct sway_seat *seat, uint32_t time_msec); |
284 | 326 | ||
285 | /** | 327 | /** |
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 | ||
6 | struct sway_switch { | 6 | struct 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..c0a5aff7 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; |
diff --git a/include/sway/input/text_input.h b/include/sway/input/text_input.h index 6cf9bdb3..c70fd935 100644 --- a/include/sway/input/text_input.h +++ b/include/sway/input/text_input.h | |||
@@ -3,7 +3,7 @@ | |||
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" | 7 | #include "sway/input/seat.h" |
8 | 8 | ||
9 | /** | 9 | /** |
@@ -28,7 +28,10 @@ struct sway_input_method_relay { | |||
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_grab_keyboard; | ||
31 | struct wl_listener input_method_destroy; | 32 | struct wl_listener input_method_destroy; |
33 | |||
34 | struct wl_listener input_method_keyboard_grab_destroy; | ||
32 | }; | 35 | }; |
33 | 36 | ||
34 | struct sway_text_input { | 37 | struct sway_text_input { |
diff --git a/include/sway/layers.h b/include/sway/layers.h index 457634c2..f8508493 100644 --- a/include/sway/layers.h +++ b/include/sway/layers.h | |||
@@ -1,8 +1,7 @@ | |||
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_box.h> | 4 | #include <wlr/types/wlr_compositor.h> |
5 | #include <wlr/types/wlr_surface.h> | ||
6 | #include <wlr/types/wlr_layer_shell_v1.h> | 5 | #include <wlr/types/wlr_layer_shell_v1.h> |
7 | 6 | ||
8 | enum layer_parent { | 7 | enum layer_parent { |
@@ -23,7 +22,11 @@ struct sway_layer_surface { | |||
23 | struct wl_listener new_subsurface; | 22 | struct wl_listener new_subsurface; |
24 | 23 | ||
25 | struct wlr_box geo; | 24 | struct wlr_box geo; |
25 | bool mapped; | ||
26 | struct wlr_box extent; | ||
26 | enum zwlr_layer_shell_v1_layer layer; | 27 | enum zwlr_layer_shell_v1_layer layer; |
28 | |||
29 | struct wl_list subsurfaces; | ||
27 | }; | 30 | }; |
28 | 31 | ||
29 | struct sway_layer_popup { | 32 | struct sway_layer_popup { |
@@ -43,6 +46,7 @@ struct sway_layer_popup { | |||
43 | struct sway_layer_subsurface { | 46 | struct sway_layer_subsurface { |
44 | struct wlr_subsurface *wlr_subsurface; | 47 | struct wlr_subsurface *wlr_subsurface; |
45 | struct sway_layer_surface *layer_surface; | 48 | struct sway_layer_surface *layer_surface; |
49 | struct wl_list link; | ||
46 | 50 | ||
47 | struct wl_listener map; | 51 | struct wl_listener map; |
48 | struct wl_listener unmap; | 52 | struct wl_listener unmap; |
diff --git a/include/sway/output.h b/include/sway/output.h index 96986700..6d8319bf 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -3,7 +3,6 @@ | |||
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_box.h> | ||
7 | #include <wlr/types/wlr_output.h> | 6 | #include <wlr/types/wlr_output.h> |
8 | #include "config.h" | 7 | #include "config.h" |
9 | #include "sway/tree/node.h" | 8 | #include "sway/tree/node.h" |
@@ -33,7 +32,7 @@ struct sway_output { | |||
33 | int width, height; // transformed buffer size | 32 | int width, height; // transformed buffer size |
34 | enum wl_output_subpixel detected_subpixel; | 33 | enum wl_output_subpixel detected_subpixel; |
35 | enum scale_filter_mode scale_filter; | 34 | enum scale_filter_mode scale_filter; |
36 | // last applied mode when the output is DPMS'ed | 35 | // last applied mode when the output is powered off |
37 | struct wlr_output_mode *current_mode; | 36 | struct wlr_output_mode *current_mode; |
38 | 37 | ||
39 | bool enabling, enabled; | 38 | bool enabling, enabled; |
@@ -49,7 +48,7 @@ struct sway_output { | |||
49 | struct wl_listener damage_frame; | 48 | struct wl_listener damage_frame; |
50 | 49 | ||
51 | struct { | 50 | struct { |
52 | struct wl_signal destroy; | 51 | struct wl_signal disable; |
53 | } events; | 52 | } events; |
54 | 53 | ||
55 | struct timespec last_presentation; | 54 | struct timespec last_presentation; |
@@ -72,8 +71,8 @@ struct sway_output *output_get_in_direction(struct sway_output *reference, | |||
72 | void output_add_workspace(struct sway_output *output, | 71 | void output_add_workspace(struct sway_output *output, |
73 | struct sway_workspace *workspace); | 72 | struct sway_workspace *workspace); |
74 | 73 | ||
75 | typedef void (*sway_surface_iterator_func_t)(struct sway_output *output, struct sway_view *view, | 74 | typedef void (*sway_surface_iterator_func_t)(struct sway_output *output, |
76 | struct wlr_surface *surface, struct wlr_box *box, float rotation, | 75 | struct sway_view *view, struct wlr_surface *surface, struct wlr_box *box, |
77 | void *user_data); | 76 | void *user_data); |
78 | 77 | ||
79 | void output_damage_whole(struct sway_output *output); | 78 | void output_damage_whole(struct sway_output *output); |
diff --git a/include/sway/server.h b/include/sway/server.h index 0f5e3ab2..4cce17cc 100644 --- a/include/sway/server.h +++ b/include/sway/server.h | |||
@@ -4,16 +4,19 @@ | |||
4 | #include <wayland-server-core.h> | 4 | #include <wayland-server-core.h> |
5 | #include <wlr/backend.h> | 5 | #include <wlr/backend.h> |
6 | #include <wlr/backend/session.h> | 6 | #include <wlr/backend/session.h> |
7 | #include <wlr/render/allocator.h> | ||
7 | #include <wlr/render/wlr_renderer.h> | 8 | #include <wlr/render/wlr_renderer.h> |
8 | #include <wlr/types/wlr_compositor.h> | 9 | #include <wlr/types/wlr_compositor.h> |
9 | #include <wlr/types/wlr_data_device.h> | 10 | #include <wlr/types/wlr_data_device.h> |
10 | #include <wlr/types/wlr_input_method_v2.h> | 11 | #include <wlr/types/wlr_input_method_v2.h> |
11 | #include <wlr/types/wlr_foreign_toplevel_management_v1.h> | 12 | #include <wlr/types/wlr_foreign_toplevel_management_v1.h> |
13 | #include <wlr/types/wlr_drm_lease_v1.h> | ||
12 | #include <wlr/types/wlr_layer_shell_v1.h> | 14 | #include <wlr/types/wlr_layer_shell_v1.h> |
13 | #include <wlr/types/wlr_output_management_v1.h> | 15 | #include <wlr/types/wlr_output_management_v1.h> |
14 | #include <wlr/types/wlr_output_power_management_v1.h> | 16 | #include <wlr/types/wlr_output_power_management_v1.h> |
15 | #include <wlr/types/wlr_presentation_time.h> | 17 | #include <wlr/types/wlr_presentation_time.h> |
16 | #include <wlr/types/wlr_relative_pointer_v1.h> | 18 | #include <wlr/types/wlr_relative_pointer_v1.h> |
19 | #include <wlr/types/wlr_session_lock_v1.h> | ||
17 | #include <wlr/types/wlr_server_decoration.h> | 20 | #include <wlr/types/wlr_server_decoration.h> |
18 | #include <wlr/types/wlr_text_input_v3.h> | 21 | #include <wlr/types/wlr_text_input_v3.h> |
19 | #include <wlr/types/wlr_xdg_shell.h> | 22 | #include <wlr/types/wlr_xdg_shell.h> |
@@ -23,19 +26,24 @@ | |||
23 | #include "sway/xwayland.h" | 26 | #include "sway/xwayland.h" |
24 | #endif | 27 | #endif |
25 | 28 | ||
29 | struct sway_transaction; | ||
30 | |||
26 | struct sway_server { | 31 | struct sway_server { |
27 | struct wl_display *wl_display; | 32 | struct wl_display *wl_display; |
28 | struct wl_event_loop *wl_event_loop; | 33 | struct wl_event_loop *wl_event_loop; |
29 | const char *socket; | 34 | const char *socket; |
30 | 35 | ||
31 | struct wlr_backend *backend; | 36 | struct wlr_backend *backend; |
32 | struct wlr_backend *noop_backend; | ||
33 | // secondary headless backend used for creating virtual outputs on-the-fly | 37 | // secondary headless backend used for creating virtual outputs on-the-fly |
34 | struct wlr_backend *headless_backend; | 38 | struct wlr_backend *headless_backend; |
39 | struct wlr_renderer *renderer; | ||
40 | struct wlr_allocator *allocator; | ||
35 | 41 | ||
36 | struct wlr_compositor *compositor; | 42 | struct wlr_compositor *compositor; |
37 | struct wl_listener compositor_new_surface; | 43 | struct wl_listener compositor_new_surface; |
38 | 44 | ||
45 | struct wlr_linux_dmabuf_v1 *linux_dmabuf_v1; | ||
46 | |||
39 | struct wlr_data_device_manager *data_device_manager; | 47 | struct wlr_data_device_manager *data_device_manager; |
40 | 48 | ||
41 | struct sway_input_manager *input; | 49 | struct sway_input_manager *input; |
@@ -70,6 +78,9 @@ struct sway_server { | |||
70 | struct wl_listener xdg_decoration; | 78 | struct wl_listener xdg_decoration; |
71 | struct wl_list xdg_decorations; // sway_xdg_decoration::link | 79 | struct wl_list xdg_decorations; // sway_xdg_decoration::link |
72 | 80 | ||
81 | struct wlr_drm_lease_v1_manager *drm_lease_manager; | ||
82 | struct wl_listener drm_lease_request; | ||
83 | |||
73 | struct wlr_presentation *presentation; | 84 | struct wlr_presentation *presentation; |
74 | 85 | ||
75 | struct wlr_pointer_constraints_v1 *pointer_constraints; | 86 | struct wlr_pointer_constraints_v1 *pointer_constraints; |
@@ -79,14 +90,44 @@ struct sway_server { | |||
79 | struct wl_listener output_manager_apply; | 90 | struct wl_listener output_manager_apply; |
80 | struct wl_listener output_manager_test; | 91 | struct wl_listener output_manager_test; |
81 | 92 | ||
93 | struct { | ||
94 | bool locked; | ||
95 | struct wlr_session_lock_manager_v1 *manager; | ||
96 | |||
97 | struct wlr_session_lock_v1 *lock; | ||
98 | struct wl_listener lock_new_surface; | ||
99 | struct wl_listener lock_unlock; | ||
100 | struct wl_listener lock_destroy; | ||
101 | |||
102 | struct wl_listener new_lock; | ||
103 | struct wl_listener manager_destroy; | ||
104 | } session_lock; | ||
105 | |||
82 | struct wlr_output_power_manager_v1 *output_power_manager_v1; | 106 | struct wlr_output_power_manager_v1 *output_power_manager_v1; |
83 | struct wl_listener output_power_manager_set_mode; | 107 | struct wl_listener output_power_manager_set_mode; |
84 | struct wlr_input_method_manager_v2 *input_method; | 108 | struct wlr_input_method_manager_v2 *input_method; |
85 | struct wlr_text_input_manager_v3 *text_input; | 109 | struct wlr_text_input_manager_v3 *text_input; |
86 | struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager; | 110 | struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager; |
87 | 111 | ||
112 | struct wlr_xdg_activation_v1 *xdg_activation_v1; | ||
113 | struct wl_listener xdg_activation_v1_request_activate; | ||
114 | |||
115 | // The timeout for transactions, after which a transaction is applied | ||
116 | // regardless of readiness. | ||
88 | size_t txn_timeout_ms; | 117 | size_t txn_timeout_ms; |
89 | list_t *transactions; | 118 | |
119 | // Stores a transaction after it has been committed, but is waiting for | ||
120 | // views to ack the new dimensions before being applied. A queued | ||
121 | // transaction is frozen and must not have new instructions added to it. | ||
122 | struct sway_transaction *queued_transaction; | ||
123 | |||
124 | // Stores a pending transaction that will be committed once the existing | ||
125 | // queued transaction is applied and freed. The pending transaction can be | ||
126 | // updated with new instructions as needed. | ||
127 | struct sway_transaction *pending_transaction; | ||
128 | |||
129 | // Stores the nodes that have been marked as "dirty" and will be put into | ||
130 | // the pending transaction. | ||
90 | list_t *dirty_nodes; | 131 | list_t *dirty_nodes; |
91 | }; | 132 | }; |
92 | 133 | ||
@@ -96,6 +137,7 @@ struct sway_debug { | |||
96 | bool noatomic; // Ignore atomic layout updates | 137 | bool noatomic; // Ignore atomic layout updates |
97 | bool txn_timings; // Log verbose messages about transactions | 138 | bool txn_timings; // Log verbose messages about transactions |
98 | bool txn_wait; // Always wait for the timeout before applying | 139 | bool txn_wait; // Always wait for the timeout before applying |
140 | bool noscanout; // Disable direct scan-out | ||
99 | 141 | ||
100 | enum { | 142 | enum { |
101 | DAMAGE_DEFAULT, // Default behaviour | 143 | DAMAGE_DEFAULT, // Default behaviour |
@@ -106,18 +148,19 @@ struct sway_debug { | |||
106 | 148 | ||
107 | extern struct sway_debug debug; | 149 | extern struct sway_debug debug; |
108 | 150 | ||
109 | /* Prepares an unprivileged server_init by performing all privileged operations in advance */ | ||
110 | bool server_privileged_prepare(struct sway_server *server); | ||
111 | bool server_init(struct sway_server *server); | 151 | bool server_init(struct sway_server *server); |
112 | void server_fini(struct sway_server *server); | 152 | void server_fini(struct sway_server *server); |
113 | bool server_start(struct sway_server *server); | 153 | bool server_start(struct sway_server *server); |
114 | void server_run(struct sway_server *server); | 154 | void server_run(struct sway_server *server); |
115 | 155 | ||
156 | void restore_nofile_limit(void); | ||
157 | |||
116 | void handle_compositor_new_surface(struct wl_listener *listener, void *data); | 158 | void handle_compositor_new_surface(struct wl_listener *listener, void *data); |
117 | void handle_new_output(struct wl_listener *listener, void *data); | 159 | void handle_new_output(struct wl_listener *listener, void *data); |
118 | 160 | ||
119 | void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data); | 161 | void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data); |
120 | void handle_layer_shell_surface(struct wl_listener *listener, void *data); | 162 | void handle_layer_shell_surface(struct wl_listener *listener, void *data); |
163 | void sway_session_lock_init(void); | ||
121 | void handle_xdg_shell_surface(struct wl_listener *listener, void *data); | 164 | void handle_xdg_shell_surface(struct wl_listener *listener, void *data); |
122 | #if HAVE_XWAYLAND | 165 | #if HAVE_XWAYLAND |
123 | void handle_xwayland_surface(struct wl_listener *listener, void *data); | 166 | void handle_xwayland_surface(struct wl_listener *listener, void *data); |
@@ -125,5 +168,9 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data); | |||
125 | void handle_server_decoration(struct wl_listener *listener, void *data); | 168 | void handle_server_decoration(struct wl_listener *listener, void *data); |
126 | void handle_xdg_decoration(struct wl_listener *listener, void *data); | 169 | void handle_xdg_decoration(struct wl_listener *listener, void *data); |
127 | void handle_pointer_constraint(struct wl_listener *listener, void *data); | 170 | void handle_pointer_constraint(struct wl_listener *listener, void *data); |
171 | void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, | ||
172 | void *data); | ||
173 | |||
174 | void set_rr_scheduling(void); | ||
128 | 175 | ||
129 | #endif | 176 | #endif |
diff --git a/include/sway/surface.h b/include/sway/surface.h index 4da96c02..fb1cd775 100644 --- a/include/sway/surface.h +++ b/include/sway/surface.h | |||
@@ -1,6 +1,6 @@ | |||
1 | #ifndef _SWAY_SURFACE_H | 1 | #ifndef _SWAY_SURFACE_H |
2 | #define _SWAY_SURFACE_H | 2 | #define _SWAY_SURFACE_H |
3 | #include <wlr/types/wlr_surface.h> | 3 | #include <wlr/types/wlr_compositor.h> |
4 | 4 | ||
5 | struct sway_surface { | 5 | struct sway_surface { |
6 | struct wlr_surface *wlr_surface; | 6 | struct wlr_surface *wlr_surface; |
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 7e9df59f..751612e2 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -2,8 +2,7 @@ | |||
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_box.h> | 5 | #include <wlr/types/wlr_compositor.h> |
6 | #include <wlr/types/wlr_surface.h> | ||
7 | #include "list.h" | 6 | #include "list.h" |
8 | #include "sway/tree/node.h" | 7 | #include "sway/tree/node.h" |
9 | 8 | ||
@@ -46,9 +45,9 @@ struct sway_container_state { | |||
46 | 45 | ||
47 | enum sway_fullscreen_mode fullscreen_mode; | 46 | enum sway_fullscreen_mode fullscreen_mode; |
48 | 47 | ||
49 | struct sway_workspace *workspace; | 48 | struct sway_workspace *workspace; // NULL when hidden in the scratchpad |
50 | struct sway_container *parent; | 49 | struct sway_container *parent; // NULL if container in root of workspace |
51 | list_t *children; | 50 | list_t *children; // struct sway_container |
52 | 51 | ||
53 | struct sway_container *focused_inactive_child; | 52 | struct sway_container *focused_inactive_child; |
54 | bool focused; | 53 | bool focused; |
@@ -60,6 +59,7 @@ struct sway_container_state { | |||
60 | bool border_left; | 59 | bool border_left; |
61 | bool border_right; | 60 | bool border_right; |
62 | 61 | ||
62 | // These are in layout coordinates. | ||
63 | double content_x, content_y; | 63 | double content_x, content_y; |
64 | double content_width, content_height; | 64 | double content_width, content_height; |
65 | }; | 65 | }; |
@@ -68,14 +68,12 @@ struct sway_container { | |||
68 | struct sway_node node; | 68 | struct sway_node node; |
69 | struct sway_view *view; | 69 | struct sway_view *view; |
70 | 70 | ||
71 | // The pending state is the main container properties, and the current state is in the below struct. | ||
72 | // This means most places of the code can refer to the main variables (pending state) and it'll just work. | ||
73 | struct sway_container_state current; | 71 | struct sway_container_state current; |
72 | struct sway_container_state pending; | ||
74 | 73 | ||
75 | char *title; // The view's title (unformatted) | 74 | char *title; // The view's title (unformatted) |
76 | char *formatted_title; // The title displayed in the title bar | 75 | char *formatted_title; // The title displayed in the title bar |
77 | 76 | ||
78 | enum sway_container_layout layout; | ||
79 | enum sway_container_layout prev_split_layout; | 77 | enum sway_container_layout prev_split_layout; |
80 | 78 | ||
81 | // Whether stickiness has been enabled on this container. Use | 79 | // Whether stickiness has been enabled on this container. Use |
@@ -86,11 +84,13 @@ struct sway_container { | |||
86 | // For C_ROOT, this has no meaning | 84 | // For C_ROOT, this has no meaning |
87 | // For other types, this is the position in layout coordinates | 85 | // For other types, this is the position in layout coordinates |
88 | // Includes borders | 86 | // Includes borders |
89 | double x, y; | ||
90 | double width, height; | ||
91 | double saved_x, saved_y; | 87 | double saved_x, saved_y; |
92 | double saved_width, saved_height; | 88 | double saved_width, saved_height; |
93 | 89 | ||
90 | // Used when the view changes to CSD unexpectedly. This will be a non-B_CSD | ||
91 | // border which we use to restore when the view returns to SSD. | ||
92 | enum sway_container_border saved_border; | ||
93 | |||
94 | // The share of the space of parent container this container occupies | 94 | // The share of the space of parent container this container occupies |
95 | double width_fraction; | 95 | double width_fraction; |
96 | double height_fraction; | 96 | double height_fraction; |
@@ -100,33 +100,11 @@ struct sway_container { | |||
100 | double child_total_width; | 100 | double child_total_width; |
101 | double child_total_height; | 101 | double child_total_height; |
102 | 102 | ||
103 | // These are in layout coordinates. | ||
104 | double content_x, content_y; | ||
105 | int content_width, content_height; | ||
106 | |||
107 | // In most cases this is the same as the content x and y, but if the view | 103 | // In most cases this is the same as the content x and y, but if the view |
108 | // refuses to resize to the content dimensions then it can be smaller. | 104 | // refuses to resize to the content dimensions then it can be smaller. |
109 | // These are in layout coordinates. | 105 | // These are in layout coordinates. |
110 | double surface_x, surface_y; | 106 | double surface_x, surface_y; |
111 | 107 | ||
112 | enum sway_fullscreen_mode fullscreen_mode; | ||
113 | |||
114 | enum sway_container_border border; | ||
115 | |||
116 | // Used when the view changes to CSD unexpectedly. This will be a non-B_CSD | ||
117 | // border which we use to restore when the view returns to SSD. | ||
118 | enum sway_container_border saved_border; | ||
119 | |||
120 | int border_thickness; | ||
121 | bool border_top; | ||
122 | bool border_bottom; | ||
123 | bool border_left; | ||
124 | bool border_right; | ||
125 | |||
126 | struct sway_workspace *workspace; // NULL when hidden in the scratchpad | ||
127 | struct sway_container *parent; // NULL if container in root of workspace | ||
128 | list_t *children; // struct sway_container | ||
129 | |||
130 | // Outputs currently being intersected | 108 | // Outputs currently being intersected |
131 | list_t *outputs; // struct sway_output | 109 | list_t *outputs; // struct sway_output |
132 | 110 | ||
@@ -139,14 +117,14 @@ struct sway_container { | |||
139 | 117 | ||
140 | struct wlr_texture *title_focused; | 118 | struct wlr_texture *title_focused; |
141 | struct wlr_texture *title_focused_inactive; | 119 | struct wlr_texture *title_focused_inactive; |
120 | struct wlr_texture *title_focused_tab_title; | ||
142 | struct wlr_texture *title_unfocused; | 121 | struct wlr_texture *title_unfocused; |
143 | struct wlr_texture *title_urgent; | 122 | struct wlr_texture *title_urgent; |
144 | size_t title_height; | ||
145 | size_t title_baseline; | ||
146 | 123 | ||
147 | list_t *marks; // char * | 124 | list_t *marks; // char * |
148 | struct wlr_texture *marks_focused; | 125 | struct wlr_texture *marks_focused; |
149 | struct wlr_texture *marks_focused_inactive; | 126 | struct wlr_texture *marks_focused_inactive; |
127 | struct wlr_texture *marks_focused_tab_title; | ||
150 | struct wlr_texture *marks_unfocused; | 128 | struct wlr_texture *marks_unfocused; |
151 | struct wlr_texture *marks_urgent; | 129 | struct wlr_texture *marks_urgent; |
152 | 130 | ||
@@ -185,6 +163,11 @@ void container_for_each_child(struct sway_container *container, | |||
185 | void (*f)(struct sway_container *container, void *data), void *data); | 163 | void (*f)(struct sway_container *container, void *data), void *data); |
186 | 164 | ||
187 | /** | 165 | /** |
166 | * Returns the fullscreen container obstructing this container if it exists. | ||
167 | */ | ||
168 | struct sway_container *container_obstructing_fullscreen_container(struct sway_container *container); | ||
169 | |||
170 | /** | ||
188 | * Returns true if the given container is an ancestor of this container. | 171 | * Returns true if the given container is an ancestor of this container. |
189 | */ | 172 | */ |
190 | bool container_has_ancestor(struct sway_container *container, | 173 | bool container_has_ancestor(struct sway_container *container, |
@@ -200,11 +183,6 @@ struct sway_container *container_flatten(struct sway_container *container); | |||
200 | 183 | ||
201 | void container_update_title_textures(struct sway_container *container); | 184 | void container_update_title_textures(struct sway_container *container); |
202 | 185 | ||
203 | /** | ||
204 | * Calculate the container's title_height property. | ||
205 | */ | ||
206 | void container_calculate_title_height(struct sway_container *container); | ||
207 | |||
208 | size_t container_build_representation(enum sway_container_layout layout, | 186 | size_t container_build_representation(enum sway_container_layout layout, |
209 | list_t *children, char *buffer); | 187 | list_t *children, char *buffer); |
210 | 188 | ||
@@ -231,10 +209,17 @@ void container_set_geometry_from_content(struct sway_container *con); | |||
231 | /** | 209 | /** |
232 | * Determine if the given container is itself floating. | 210 | * Determine if the given container is itself floating. |
233 | * This will return false for any descendants of a floating container. | 211 | * This will return false for any descendants of a floating container. |
212 | * | ||
213 | * Uses pending container state. | ||
234 | */ | 214 | */ |
235 | bool container_is_floating(struct sway_container *container); | 215 | bool container_is_floating(struct sway_container *container); |
236 | 216 | ||
237 | /** | 217 | /** |
218 | * Same as above, but for current container state. | ||
219 | */ | ||
220 | bool container_is_current_floating(struct sway_container *container); | ||
221 | |||
222 | /** | ||
238 | * Get a container's box in layout coordinates. | 223 | * Get a container's box in layout coordinates. |
239 | */ | 224 | */ |
240 | void container_get_box(struct sway_container *container, struct wlr_box *box); | 225 | void container_get_box(struct sway_container *container, struct wlr_box *box); |
@@ -299,6 +284,7 @@ bool container_is_fullscreen_or_child(struct sway_container *container); | |||
299 | /** | 284 | /** |
300 | * Return the output which will be used for scale purposes. | 285 | * Return the output which will be used for scale purposes. |
301 | * This is the most recently entered output. | 286 | * This is the most recently entered output. |
287 | * If the container is not on any output, return NULL. | ||
302 | */ | 288 | */ |
303 | struct sway_output *container_get_effective_output(struct sway_container *con); | 289 | struct sway_output *container_get_effective_output(struct sway_container *con); |
304 | 290 | ||
@@ -378,7 +364,7 @@ bool container_is_sticky_or_child(struct sway_container *con); | |||
378 | * This will destroy pairs of redundant H/V splits | 364 | * This will destroy pairs of redundant H/V splits |
379 | * e.g. H[V[H[app app]] app] -> H[app app app] | 365 | * e.g. H[V[H[app app]] app] -> H[app app app] |
380 | * The middle "V[H[" are eliminated by a call to container_squash | 366 | * The middle "V[H[" are eliminated by a call to container_squash |
381 | * on the V[ con. It's grandchildren are added to it's parent. | 367 | * on the V[ con. It's grandchildren are added to its parent. |
382 | * | 368 | * |
383 | * This function is roughly equivalent to i3's tree_flatten here: | 369 | * This function is roughly equivalent to i3's tree_flatten here: |
384 | * https://github.com/i3/i3/blob/1f0c628cde40cf87371481041b7197344e0417c6/src/tree.c#L651 | 370 | * https://github.com/i3/i3/blob/1f0c628cde40cf87371481041b7197344e0417c6/src/tree.c#L651 |
diff --git a/include/sway/tree/root.h b/include/sway/tree/root.h index e8f4d573..5d4a2f2d 100644 --- a/include/sway/tree/root.h +++ b/include/sway/tree/root.h | |||
@@ -31,7 +31,7 @@ struct sway_root { | |||
31 | list_t *scratchpad; // struct sway_container | 31 | list_t *scratchpad; // struct sway_container |
32 | 32 | ||
33 | // For when there's no connected outputs | 33 | // For when there's no connected outputs |
34 | struct sway_output *noop_output; | 34 | struct sway_output *fallback_output; |
35 | 35 | ||
36 | struct sway_container *fullscreen_global; | 36 | struct sway_container *fullscreen_global; |
37 | 37 | ||
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index e071e6c9..0dcbf1aa 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef _SWAY_VIEW_H | 1 | #ifndef _SWAY_VIEW_H |
2 | #define _SWAY_VIEW_H | 2 | #define _SWAY_VIEW_H |
3 | #include <wayland-server-core.h> | 3 | #include <wayland-server-core.h> |
4 | #include <wlr/types/wlr_surface.h> | 4 | #include <wlr/types/wlr_compositor.h> |
5 | #include "config.h" | 5 | #include "config.h" |
6 | #if HAVE_XWAYLAND | 6 | #if HAVE_XWAYLAND |
7 | #include <wlr/xwayland.h> | 7 | #include <wlr/xwayland.h> |
@@ -108,11 +108,10 @@ struct sway_view { | |||
108 | list_t *executed_criteria; // struct criteria * | 108 | list_t *executed_criteria; // struct criteria * |
109 | 109 | ||
110 | union { | 110 | union { |
111 | struct wlr_xdg_surface *wlr_xdg_surface; | 111 | struct wlr_xdg_toplevel *wlr_xdg_toplevel; |
112 | #if HAVE_XWAYLAND | 112 | #if HAVE_XWAYLAND |
113 | struct wlr_xwayland_surface *wlr_xwayland_surface; | 113 | struct wlr_xwayland_surface *wlr_xwayland_surface; |
114 | #endif | 114 | #endif |
115 | struct wlr_wl_shell_surface *wlr_wl_shell_surface; | ||
116 | }; | 115 | }; |
117 | 116 | ||
118 | struct { | 117 | struct { |
@@ -171,6 +170,7 @@ struct sway_xwayland_unmanaged { | |||
171 | 170 | ||
172 | int lx, ly; | 171 | int lx, ly; |
173 | 172 | ||
173 | struct wl_listener request_activate; | ||
174 | struct wl_listener request_configure; | 174 | struct wl_listener request_configure; |
175 | struct wl_listener request_fullscreen; | 175 | struct wl_listener request_fullscreen; |
176 | struct wl_listener commit; | 176 | struct wl_listener commit; |
@@ -184,7 +184,7 @@ struct sway_xwayland_unmanaged { | |||
184 | struct sway_view_child; | 184 | struct sway_view_child; |
185 | 185 | ||
186 | struct sway_view_child_impl { | 186 | struct sway_view_child_impl { |
187 | void (*get_root_coords)(struct sway_view_child *child, int *sx, int *sy); | 187 | void (*get_view_coords)(struct sway_view_child *child, int *sx, int *sy); |
188 | void (*destroy)(struct sway_view_child *child); | 188 | void (*destroy)(struct sway_view_child *child); |
189 | }; | 189 | }; |
190 | 190 | ||
@@ -218,7 +218,7 @@ struct sway_subsurface { | |||
218 | struct sway_xdg_popup { | 218 | struct sway_xdg_popup { |
219 | struct sway_view_child child; | 219 | struct sway_view_child child; |
220 | 220 | ||
221 | struct wlr_xdg_surface *wlr_xdg_surface; | 221 | struct wlr_xdg_popup *wlr_xdg_popup; |
222 | 222 | ||
223 | struct wl_listener new_popup; | 223 | struct wl_listener new_popup; |
224 | struct wl_listener destroy; | 224 | struct wl_listener destroy; |
@@ -311,12 +311,22 @@ void view_destroy(struct sway_view *view); | |||
311 | 311 | ||
312 | void view_begin_destroy(struct sway_view *view); | 312 | void view_begin_destroy(struct sway_view *view); |
313 | 313 | ||
314 | /** | ||
315 | * Map a view, ie. make it visible in the tree. | ||
316 | * | ||
317 | * `fullscreen` should be set to true (and optionally `fullscreen_output` | ||
318 | * should be populated) if the view should be made fullscreen immediately. | ||
319 | * | ||
320 | * `decoration` should be set to true if the client prefers CSD. The client's | ||
321 | * preference may be ignored. | ||
322 | */ | ||
314 | void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, | 323 | void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, |
315 | bool fullscreen, struct wlr_output *fullscreen_output, bool decoration); | 324 | bool fullscreen, struct wlr_output *fullscreen_output, bool decoration); |
316 | 325 | ||
317 | void view_unmap(struct sway_view *view); | 326 | void view_unmap(struct sway_view *view); |
318 | 327 | ||
319 | void view_update_size(struct sway_view *view, int width, int height); | 328 | void view_update_size(struct sway_view *view); |
329 | void view_center_surface(struct sway_view *view); | ||
320 | 330 | ||
321 | void view_child_init(struct sway_view_child *child, | 331 | void view_child_init(struct sway_view_child *child, |
322 | const struct sway_view_child_impl *impl, struct sway_view *view, | 332 | const struct sway_view_child_impl *impl, struct sway_view *view, |
diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index fdd92f64..b3d93a81 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h | |||
@@ -60,20 +60,20 @@ void workspace_consider_destroy(struct sway_workspace *ws); | |||
60 | 60 | ||
61 | char *workspace_next_name(const char *output_name); | 61 | char *workspace_next_name(const char *output_name); |
62 | 62 | ||
63 | bool workspace_switch(struct sway_workspace *workspace, | 63 | struct sway_workspace *workspace_auto_back_and_forth( |
64 | bool no_auto_back_and_forth); | 64 | struct sway_workspace *workspace); |
65 | |||
66 | bool workspace_switch(struct sway_workspace *workspace); | ||
65 | 67 | ||
66 | struct sway_workspace *workspace_by_number(const char* name); | 68 | struct sway_workspace *workspace_by_number(const char* name); |
67 | 69 | ||
68 | struct sway_workspace *workspace_by_name(const char*); | 70 | struct sway_workspace *workspace_by_name(const char*); |
69 | 71 | ||
70 | struct sway_workspace *workspace_output_next( | 72 | struct sway_workspace *workspace_output_next(struct sway_workspace *current); |
71 | struct sway_workspace *current, bool create); | ||
72 | 73 | ||
73 | struct sway_workspace *workspace_next(struct sway_workspace *current); | 74 | struct sway_workspace *workspace_next(struct sway_workspace *current); |
74 | 75 | ||
75 | struct sway_workspace *workspace_output_prev( | 76 | struct sway_workspace *workspace_output_prev(struct sway_workspace *current); |
76 | struct sway_workspace *current, bool create); | ||
77 | 77 | ||
78 | struct sway_workspace *workspace_prev(struct sway_workspace *current); | 78 | struct sway_workspace *workspace_prev(struct sway_workspace *current); |
79 | 79 | ||
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 545a66a8..3ad0bdf3 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h | |||
@@ -58,7 +58,6 @@ struct swaybar_output { | |||
58 | struct zxdg_output_v1 *xdg_output; | 58 | struct zxdg_output_v1 *xdg_output; |
59 | struct wl_surface *surface; | 59 | struct wl_surface *surface; |
60 | struct zwlr_layer_surface_v1 *layer_surface; | 60 | struct zwlr_layer_surface_v1 *layer_surface; |
61 | struct wl_region *input_region; | ||
62 | uint32_t wl_name; | 61 | uint32_t wl_name; |
63 | 62 | ||
64 | struct wl_list workspaces; // swaybar_workspace::link | 63 | struct wl_list workspaces; // swaybar_workspace::link |
diff --git a/include/swaybar/config.h b/include/swaybar/config.h index 4cacd21a..361acd99 100644 --- a/include/swaybar/config.h +++ b/include/swaybar/config.h | |||
@@ -6,6 +6,7 @@ | |||
6 | #include "../include/config.h" | 6 | #include "../include/config.h" |
7 | #include "list.h" | 7 | #include "list.h" |
8 | #include "util.h" | 8 | #include "util.h" |
9 | #include <pango/pangocairo.h> | ||
9 | 10 | ||
10 | struct box_colors { | 11 | struct box_colors { |
11 | uint32_t border; | 12 | uint32_t border; |
@@ -28,7 +29,7 @@ struct swaybar_config { | |||
28 | char *status_command; | 29 | char *status_command; |
29 | bool pango_markup; | 30 | bool pango_markup; |
30 | uint32_t position; // zwlr_layer_surface_v1_anchor | 31 | uint32_t position; // zwlr_layer_surface_v1_anchor |
31 | char *font; | 32 | PangoFontDescription *font_description; |
32 | char *sep_symbol; | 33 | char *sep_symbol; |
33 | char *mode; | 34 | char *mode; |
34 | char *hidden_state; | 35 | char *hidden_state; |
diff --git a/include/swaybar/i3bar.h b/include/swaybar/i3bar.h index df8cdd09..1aec6d6c 100644 --- a/include/swaybar/i3bar.h +++ b/include/swaybar/i3bar.h | |||
@@ -19,6 +19,7 @@ struct i3bar_block { | |||
19 | // Airblader features | 19 | // Airblader features |
20 | uint32_t background; | 20 | uint32_t background; |
21 | uint32_t border; | 21 | uint32_t border; |
22 | bool border_set; | ||
22 | int border_top; | 23 | int border_top; |
23 | int border_bottom; | 24 | int border_bottom; |
24 | int border_left; | 25 | int border_left; |
diff --git a/include/swaynag/swaynag.h b/include/swaynag/swaynag.h index 9e39e716..2d68b6c9 100644 --- a/include/swaynag/swaynag.h +++ b/include/swaynag/swaynag.h | |||
@@ -5,7 +5,6 @@ | |||
5 | #include "list.h" | 5 | #include "list.h" |
6 | #include "pool-buffer.h" | 6 | #include "pool-buffer.h" |
7 | #include "swaynag/types.h" | 7 | #include "swaynag/types.h" |
8 | #include "xdg-output-unstable-v1-client-protocol.h" | ||
9 | 8 | ||
10 | #define SWAYNAG_MAX_HEIGHT 500 | 9 | #define SWAYNAG_MAX_HEIGHT 500 |
11 | 10 | ||
@@ -68,20 +67,18 @@ struct swaynag_details { | |||
68 | int offset; | 67 | int offset; |
69 | int visible_lines; | 68 | int visible_lines; |
70 | int total_lines; | 69 | int total_lines; |
71 | struct swaynag_button *button_details; | 70 | struct swaynag_button button_details; |
72 | struct swaynag_button button_up; | 71 | struct swaynag_button button_up; |
73 | struct swaynag_button button_down; | 72 | struct swaynag_button button_down; |
74 | }; | 73 | }; |
75 | 74 | ||
76 | struct swaynag { | 75 | struct swaynag { |
77 | bool run_display; | 76 | bool run_display; |
78 | int querying_outputs; | ||
79 | 77 | ||
80 | struct wl_display *display; | 78 | struct wl_display *display; |
81 | struct wl_compositor *compositor; | 79 | struct wl_compositor *compositor; |
82 | struct wl_seat *seat; | 80 | struct wl_seat *seat; |
83 | struct wl_shm *shm; | 81 | struct wl_shm *shm; |
84 | struct zxdg_output_manager_v1 *xdg_output_manager; | ||
85 | struct wl_list outputs; // swaynag_output::link | 82 | struct wl_list outputs; // swaynag_output::link |
86 | struct wl_list seats; // swaynag_seat::link | 83 | struct wl_list seats; // swaynag_seat::link |
87 | struct swaynag_output *output; | 84 | struct swaynag_output *output; |
diff --git a/include/swaynag/types.h b/include/swaynag/types.h index 24da9418..18f218e0 100644 --- a/include/swaynag/types.h +++ b/include/swaynag/types.h | |||
@@ -4,9 +4,11 @@ | |||
4 | struct swaynag_type { | 4 | struct swaynag_type { |
5 | char *name; | 5 | char *name; |
6 | 6 | ||
7 | char *font; | 7 | char *font; // Used for debugging. |
8 | PangoFontDescription *font_description; | ||
8 | char *output; | 9 | char *output; |
9 | uint32_t anchors; | 10 | uint32_t anchors; |
11 | int32_t layer; // enum zwlr_layer_shell_v1_layer or -1 if unset | ||
10 | 12 | ||
11 | // Colors | 13 | // Colors |
12 | uint32_t button_text; | 14 | uint32_t button_text; |
diff --git a/include/util.h b/include/util.h index c80da1cb..f887d489 100644 --- a/include/util.h +++ b/include/util.h | |||
@@ -30,12 +30,6 @@ int parse_movement_amount(int argc, char **argv, | |||
30 | struct movement_amount *amount); | 30 | struct movement_amount *amount); |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * Get the current time, in milliseconds. | ||
34 | */ | ||
35 | |||
36 | uint32_t get_current_time_msec(void); | ||
37 | |||
38 | /** | ||
39 | * Wrap i into the range [0, max] | 33 | * Wrap i into the range [0, max] |
40 | */ | 34 | */ |
41 | int wrap(int i, int max); | 35 | int wrap(int i, int max); |