diff options
Diffstat (limited to 'include')
47 files changed, 863 insertions, 521 deletions
diff --git a/include/background-image.h b/include/background-image.h deleted file mode 100644 index 15935ffd..00000000 --- a/include/background-image.h +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | #ifndef _SWAY_BACKGROUND_IMAGE_H | ||
2 | #define _SWAY_BACKGROUND_IMAGE_H | ||
3 | #include "cairo.h" | ||
4 | |||
5 | enum background_mode { | ||
6 | BACKGROUND_MODE_STRETCH, | ||
7 | BACKGROUND_MODE_FILL, | ||
8 | BACKGROUND_MODE_FIT, | ||
9 | BACKGROUND_MODE_CENTER, | ||
10 | BACKGROUND_MODE_TILE, | ||
11 | BACKGROUND_MODE_SOLID_COLOR, | ||
12 | BACKGROUND_MODE_INVALID, | ||
13 | }; | ||
14 | |||
15 | enum background_mode parse_background_mode(const char *mode); | ||
16 | cairo_surface_t *load_background_image(const char *path); | ||
17 | void render_background_image(cairo_t *cairo, cairo_surface_t *image, | ||
18 | enum background_mode mode, int buffer_width, int buffer_height); | ||
19 | |||
20 | #endif | ||
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..228e39cf 100644 --- a/include/pango.h +++ b/include/pango.h | |||
@@ -3,8 +3,9 @@ | |||
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 | #include "stringop.h" | ||
8 | 9 | ||
9 | /** | 10 | /** |
10 | * Utility function which escape characters a & < > ' ". | 11 | * Utility function which escape characters a & < > ' ". |
@@ -13,11 +14,12 @@ | |||
13 | * escaped string to dest if provided. | 14 | * escaped string to dest if provided. |
14 | */ | 15 | */ |
15 | size_t escape_markup_text(const char *src, char *dest); | 16 | size_t escape_markup_text(const char *src, char *dest); |
16 | PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, | 17 | PangoLayout *get_pango_layout(cairo_t *cairo, const PangoFontDescription *desc, |
17 | const char *text, double scale, bool markup); | 18 | const char *text, double scale, bool markup); |
18 | void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, | 19 | void get_text_size(cairo_t *cairo, const PangoFontDescription *desc, int *width, int *height, |
19 | int *baseline, double scale, bool markup, const char *fmt, ...); | 20 | int *baseline, double scale, bool markup, const char *fmt, ...) _SWAY_ATTRIB_PRINTF(8, 9); |
20 | void pango_printf(cairo_t *cairo, const char *font, | 21 | void get_text_metrics(const PangoFontDescription *desc, int *height, int *baseline); |
21 | double scale, bool markup, const char *fmt, ...); | 22 | void render_text(cairo_t *cairo, PangoFontDescription *desc, |
23 | double scale, bool markup, const char *fmt, ...) _SWAY_ATTRIB_PRINTF(5, 6); | ||
22 | 24 | ||
23 | #endif | 25 | #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..19a50f23 100644 --- a/include/stringop.h +++ b/include/stringop.h | |||
@@ -2,8 +2,15 @@ | |||
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 | ||
8 | #ifdef __GNUC__ | ||
9 | #define _SWAY_ATTRIB_PRINTF(start, end) __attribute__((format(printf, start, end))) | ||
10 | #else | ||
11 | #define _SWAY_ATTRIB_PRINTF(start, end) | ||
12 | #endif | ||
13 | |||
7 | void strip_whitespace(char *str); | 14 | void strip_whitespace(char *str); |
8 | void strip_quotes(char *str); | 15 | void strip_quotes(char *str); |
9 | 16 | ||
@@ -30,4 +37,7 @@ char *argsep(char **stringp, const char *delim, char *matched_delim); | |||
30 | // Expand a path using shell replacements such as $HOME and ~ | 37 | // Expand a path using shell replacements such as $HOME and ~ |
31 | bool expand_path(char **path); | 38 | bool expand_path(char **path); |
32 | 39 | ||
40 | char *vformat_str(const char *fmt, va_list args) _SWAY_ATTRIB_PRINTF(1, 0); | ||
41 | char *format_str(const char *fmt, ...) _SWAY_ATTRIB_PRINTF(1, 2); | ||
42 | |||
33 | #endif | 43 | #endif |
diff --git a/include/sway/commands.h b/include/sway/commands.h index 964b3661..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 | ||
7 | struct sway_container; | 8 | struct sway_container; |
8 | 9 | ||
9 | typedef struct cmd_results *sway_cmd(int argc, char **argv); | 10 | typedef struct cmd_results *sway_cmd(int argc, char **argv); |
10 | 11 | ||
11 | struct cmd_handler { | 12 | struct cmd_handler { |
12 | char *command; | 13 | const char *command; |
13 | sway_cmd *handle; | 14 | sway_cmd *handle; |
14 | }; | 15 | }; |
15 | 16 | ||
@@ -46,8 +47,8 @@ enum expected_args { | |||
46 | struct cmd_results *checkarg(int argc, const char *name, | 47 | struct cmd_results *checkarg(int argc, const char *name, |
47 | enum expected_args type, int val); | 48 | enum expected_args type, int val); |
48 | 49 | ||
49 | struct cmd_handler *find_handler(char *line, struct cmd_handler *cmd_handlers, | 50 | const struct cmd_handler *find_handler(const char *line, |
50 | size_t handlers_size); | 51 | const struct cmd_handler *cmd_handlers, size_t handlers_size); |
51 | 52 | ||
52 | /** | 53 | /** |
53 | * Parse and executes a command. | 54 | * Parse and executes a command. |
@@ -68,7 +69,7 @@ struct cmd_results *config_command(char *command, char **new_block); | |||
68 | * Parse and handle a sub command | 69 | * Parse and handle a sub command |
69 | */ | 70 | */ |
70 | struct cmd_results *config_subcommand(char **argv, int argc, | 71 | struct cmd_results *config_subcommand(char **argv, int argc, |
71 | struct cmd_handler *handlers, size_t handlers_size); | 72 | const struct cmd_handler *handlers, size_t handlers_size); |
72 | /* | 73 | /* |
73 | * Parses a command policy rule. | 74 | * Parses a command policy rule. |
74 | */ | 75 | */ |
@@ -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 | */ |
79 | struct cmd_results *cmd_results_new(enum cmd_status status, const char *error, ...); | 80 | struct 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; | |||
106 | sway_cmd cmd_assign; | 107 | sway_cmd cmd_assign; |
107 | sway_cmd cmd_bar; | 108 | sway_cmd cmd_bar; |
108 | sway_cmd cmd_bindcode; | 109 | sway_cmd cmd_bindcode; |
110 | sway_cmd cmd_bindgesture; | ||
109 | sway_cmd cmd_bindswitch; | 111 | sway_cmd cmd_bindswitch; |
110 | sway_cmd cmd_bindsym; | 112 | sway_cmd cmd_bindsym; |
111 | sway_cmd cmd_border; | 113 | sway_cmd cmd_border; |
112 | sway_cmd cmd_client_noop; | 114 | sway_cmd cmd_client_noop; |
113 | sway_cmd cmd_client_focused; | 115 | sway_cmd cmd_client_focused; |
114 | sway_cmd cmd_client_focused_inactive; | 116 | sway_cmd cmd_client_focused_inactive; |
117 | sway_cmd cmd_client_focused_tab_title; | ||
115 | sway_cmd cmd_client_unfocused; | 118 | sway_cmd cmd_client_unfocused; |
116 | sway_cmd cmd_client_urgent; | 119 | sway_cmd cmd_client_urgent; |
117 | sway_cmd cmd_client_placeholder; | 120 | sway_cmd cmd_client_placeholder; |
@@ -157,12 +160,11 @@ sway_cmd cmd_new_float; | |||
157 | sway_cmd cmd_new_window; | 160 | sway_cmd cmd_new_window; |
158 | sway_cmd cmd_nop; | 161 | sway_cmd cmd_nop; |
159 | sway_cmd cmd_opacity; | 162 | sway_cmd cmd_opacity; |
160 | sway_cmd cmd_new_float; | ||
161 | sway_cmd cmd_new_window; | ||
162 | sway_cmd cmd_no_focus; | 163 | sway_cmd cmd_no_focus; |
163 | sway_cmd cmd_output; | 164 | sway_cmd cmd_output; |
164 | sway_cmd cmd_permit; | 165 | sway_cmd cmd_permit; |
165 | sway_cmd cmd_popup_during_fullscreen; | 166 | sway_cmd cmd_popup_during_fullscreen; |
167 | sway_cmd cmd_primary_selection; | ||
166 | sway_cmd cmd_reject; | 168 | sway_cmd cmd_reject; |
167 | sway_cmd cmd_reload; | 169 | sway_cmd cmd_reload; |
168 | sway_cmd cmd_rename; | 170 | sway_cmd cmd_rename; |
@@ -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; |
@@ -249,6 +252,7 @@ sway_cmd input_cmd_click_method; | |||
249 | sway_cmd input_cmd_drag; | 252 | sway_cmd input_cmd_drag; |
250 | sway_cmd input_cmd_drag_lock; | 253 | sway_cmd input_cmd_drag_lock; |
251 | sway_cmd input_cmd_dwt; | 254 | sway_cmd input_cmd_dwt; |
255 | sway_cmd input_cmd_dwtp; | ||
252 | sway_cmd input_cmd_events; | 256 | sway_cmd input_cmd_events; |
253 | sway_cmd input_cmd_left_handed; | 257 | sway_cmd input_cmd_left_handed; |
254 | sway_cmd input_cmd_map_from_region; | 258 | sway_cmd input_cmd_map_from_region; |
@@ -257,10 +261,12 @@ sway_cmd input_cmd_map_to_region; | |||
257 | sway_cmd input_cmd_middle_emulation; | 261 | sway_cmd input_cmd_middle_emulation; |
258 | sway_cmd input_cmd_natural_scroll; | 262 | sway_cmd input_cmd_natural_scroll; |
259 | sway_cmd input_cmd_pointer_accel; | 263 | sway_cmd input_cmd_pointer_accel; |
264 | sway_cmd input_cmd_rotation_angle; | ||
260 | sway_cmd input_cmd_scroll_factor; | 265 | sway_cmd input_cmd_scroll_factor; |
261 | sway_cmd input_cmd_repeat_delay; | 266 | sway_cmd input_cmd_repeat_delay; |
262 | sway_cmd input_cmd_repeat_rate; | 267 | sway_cmd input_cmd_repeat_rate; |
263 | sway_cmd input_cmd_scroll_button; | 268 | sway_cmd input_cmd_scroll_button; |
269 | sway_cmd input_cmd_scroll_button_lock; | ||
264 | sway_cmd input_cmd_scroll_method; | 270 | sway_cmd input_cmd_scroll_method; |
265 | sway_cmd input_cmd_tap; | 271 | sway_cmd input_cmd_tap; |
266 | sway_cmd input_cmd_tap_button_map; | 272 | sway_cmd input_cmd_tap_button_map; |
@@ -282,12 +288,16 @@ sway_cmd output_cmd_dpms; | |||
282 | sway_cmd output_cmd_enable; | 288 | sway_cmd output_cmd_enable; |
283 | sway_cmd output_cmd_max_render_time; | 289 | sway_cmd output_cmd_max_render_time; |
284 | sway_cmd output_cmd_mode; | 290 | sway_cmd output_cmd_mode; |
291 | sway_cmd output_cmd_modeline; | ||
285 | sway_cmd output_cmd_position; | 292 | sway_cmd output_cmd_position; |
293 | sway_cmd output_cmd_power; | ||
294 | sway_cmd output_cmd_render_bit_depth; | ||
286 | sway_cmd output_cmd_scale; | 295 | sway_cmd output_cmd_scale; |
287 | sway_cmd output_cmd_scale_filter; | 296 | sway_cmd output_cmd_scale_filter; |
288 | sway_cmd output_cmd_subpixel; | 297 | sway_cmd output_cmd_subpixel; |
289 | sway_cmd output_cmd_toggle; | 298 | sway_cmd output_cmd_toggle; |
290 | sway_cmd output_cmd_transform; | 299 | sway_cmd output_cmd_transform; |
300 | sway_cmd output_cmd_unplug; | ||
291 | 301 | ||
292 | sway_cmd seat_cmd_attach; | 302 | sway_cmd seat_cmd_attach; |
293 | sway_cmd seat_cmd_cursor; | 303 | sway_cmd seat_cmd_cursor; |
diff --git a/include/sway/config.h b/include/sway/config.h index 59f22ae2..0be1cd22 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -5,16 +5,20 @@ | |||
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" |
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 | ||
37 | enum binding_flags { | 42 | enum 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 | */ |
52 | struct sway_binding { | 58 | struct 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 | /** | 70 | enum sway_switch_trigger { |
65 | * A mouse binding and an associated command. | 71 | SWAY_SWITCH_TRIGGER_OFF, |
66 | */ | 72 | SWAY_SWITCH_TRIGGER_ON, |
67 | struct 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 | */ |
75 | struct sway_switch_binding { | 79 | struct 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 | */ | ||
89 | struct 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 | */ |
85 | enum sway_fowa { | 99 | enum 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 | ||
236 | enum config_dpms { | ||
237 | DPMS_IGNORE, | ||
238 | DPMS_ON, | ||
239 | DPMS_OFF, | ||
240 | }; | ||
241 | |||
242 | enum scale_filter_mode { | 254 | enum 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 | ||
261 | enum 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 { | |||
254 | struct output_config { | 272 | struct 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 | */ | ||
297 | struct 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 | ||
312 | enum 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. |
@@ -292,6 +326,12 @@ struct workspace_config { | |||
292 | struct side_gaps gaps_outer; | 326 | struct side_gaps gaps_outer; |
293 | }; | 327 | }; |
294 | 328 | ||
329 | enum pango_markup_config { | ||
330 | PANGO_MARKUP_DISABLED = false, | ||
331 | PANGO_MARKUP_ENABLED = true, | ||
332 | PANGO_MARKUP_DEFAULT // The default is font dependent ("pango:" prefix) | ||
333 | }; | ||
334 | |||
295 | struct bar_config { | 335 | struct bar_config { |
296 | char *swaybar_command; | 336 | char *swaybar_command; |
297 | struct wl_client *client; | 337 | struct wl_client *client; |
@@ -323,7 +363,7 @@ struct bar_config { | |||
323 | char *position; | 363 | char *position; |
324 | list_t *bindings; | 364 | list_t *bindings; |
325 | char *status_command; | 365 | char *status_command; |
326 | bool pango_markup; | 366 | enum pango_markup_config pango_markup; |
327 | char *font; | 367 | char *font; |
328 | int height; // -1 not defined | 368 | int height; // -1 not defined |
329 | bool workspace_buttons; | 369 | bool workspace_buttons; |
@@ -410,14 +450,6 @@ enum sway_popup_during_fullscreen { | |||
410 | POPUP_LEAVE, | 450 | POPUP_LEAVE, |
411 | }; | 451 | }; |
412 | 452 | ||
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 { | 453 | enum focus_follows_mouse_mode { |
422 | FOLLOWS_NO, | 454 | FOLLOWS_NO, |
423 | FOLLOWS_YES, | 455 | FOLLOWS_YES, |
@@ -479,9 +511,10 @@ struct sway_config { | |||
479 | char *floating_scroll_right_cmd; | 511 | char *floating_scroll_right_cmd; |
480 | enum sway_container_layout default_orientation; | 512 | enum sway_container_layout default_orientation; |
481 | enum sway_container_layout default_layout; | 513 | enum sway_container_layout default_layout; |
482 | char *font; | 514 | char *font; // Used for IPC. |
483 | size_t font_height; | 515 | PangoFontDescription *font_description; // Used internally for rendering and validating. |
484 | size_t font_baseline; | 516 | int font_height; |
517 | int font_baseline; | ||
485 | bool pango_markup; | 518 | bool pango_markup; |
486 | int titlebar_border_thickness; | 519 | int titlebar_border_thickness; |
487 | int titlebar_h_padding; | 520 | int titlebar_h_padding; |
@@ -508,11 +541,12 @@ struct sway_config { | |||
508 | bool auto_back_and_forth; | 541 | bool auto_back_and_forth; |
509 | bool show_marks; | 542 | bool show_marks; |
510 | enum alignment title_align; | 543 | enum alignment title_align; |
544 | bool primary_selection; | ||
511 | 545 | ||
512 | bool tiling_drag; | 546 | bool tiling_drag; |
513 | int tiling_drag_threshold; | 547 | int tiling_drag_threshold; |
514 | 548 | ||
515 | bool smart_gaps; | 549 | enum smart_gaps_mode smart_gaps; |
516 | int gaps_inner; | 550 | int gaps_inner; |
517 | struct side_gaps gaps_outer; | 551 | struct side_gaps gaps_outer; |
518 | 552 | ||
@@ -535,12 +569,15 @@ struct sway_config { | |||
535 | struct { | 569 | struct { |
536 | struct border_colors focused; | 570 | struct border_colors focused; |
537 | struct border_colors focused_inactive; | 571 | struct border_colors focused_inactive; |
572 | struct border_colors focused_tab_title; | ||
538 | struct border_colors unfocused; | 573 | struct border_colors unfocused; |
539 | struct border_colors urgent; | 574 | struct border_colors urgent; |
540 | struct border_colors placeholder; | 575 | struct border_colors placeholder; |
541 | float background[4]; | 576 | float background[4]; |
542 | } border_colors; | 577 | } border_colors; |
543 | 578 | ||
579 | bool has_focused_tab_title; | ||
580 | |||
544 | // floating view | 581 | // floating view |
545 | int32_t floating_maximum_width; | 582 | int32_t floating_maximum_width; |
546 | int32_t floating_maximum_height; | 583 | int32_t floating_maximum_height; |
@@ -559,7 +596,7 @@ struct sway_config { | |||
559 | struct sway_node *node; | 596 | struct sway_node *node; |
560 | struct sway_container *container; | 597 | struct sway_container *container; |
561 | struct sway_workspace *workspace; | 598 | struct sway_workspace *workspace; |
562 | bool using_criteria; | 599 | bool node_overridden; // True if the node is selected by means other than focus |
563 | struct { | 600 | struct { |
564 | int argc; | 601 | int argc; |
565 | char **argv; | 602 | char **argv; |
@@ -598,7 +635,7 @@ void run_deferred_bindings(void); | |||
598 | /** | 635 | /** |
599 | * Adds a warning entry to the swaynag instance used for errors. | 636 | * Adds a warning entry to the swaynag instance used for errors. |
600 | */ | 637 | */ |
601 | void config_add_swaynag_warning(char *fmt, ...); | 638 | void config_add_swaynag_warning(char *fmt, ...) _SWAY_ATTRIB_PRINTF(1, 2); |
602 | 639 | ||
603 | /** | 640 | /** |
604 | * Free config struct | 641 | * Free config struct |
@@ -651,20 +688,22 @@ const char *sway_output_scale_filter_to_string(enum scale_filter_mode scale_filt | |||
651 | 688 | ||
652 | struct output_config *new_output_config(const char *name); | 689 | struct output_config *new_output_config(const char *name); |
653 | 690 | ||
654 | void merge_output_config(struct output_config *dst, struct output_config *src); | 691 | bool apply_output_configs(struct matched_output_config *configs, |
692 | size_t configs_len, bool test_only); | ||
655 | 693 | ||
656 | bool apply_output_config(struct output_config *oc, struct sway_output *output); | 694 | void apply_all_output_configs(void); |
657 | 695 | ||
658 | bool test_output_config(struct output_config *oc, struct sway_output *output); | 696 | /** |
659 | 697 | * store_output_config stores a new output config. An output may be matched by | |
660 | struct output_config *store_output_config(struct output_config *oc); | 698 | * three different config types, in order of precedence: Identifier, name and |
699 | * wildcard. When storing a config type of lower precedence, assume that the | ||
700 | * user wants the config to take immediate effect by superseding (clearing) the | ||
701 | * same values from higher presedence configuration. | ||
702 | */ | ||
703 | void store_output_config(struct output_config *oc); | ||
661 | 704 | ||
662 | struct output_config *find_output_config(struct sway_output *output); | 705 | struct output_config *find_output_config(struct sway_output *output); |
663 | 706 | ||
664 | void apply_output_config_to_outputs(struct output_config *oc); | ||
665 | |||
666 | void reset_outputs(void); | ||
667 | |||
668 | void free_output_config(struct output_config *oc); | 707 | void free_output_config(struct output_config *oc); |
669 | 708 | ||
670 | bool spawn_swaybg(void); | 709 | bool spawn_swaybg(void); |
@@ -675,6 +714,8 @@ void free_sway_binding(struct sway_binding *sb); | |||
675 | 714 | ||
676 | void free_switch_binding(struct sway_switch_binding *binding); | 715 | void free_switch_binding(struct sway_switch_binding *binding); |
677 | 716 | ||
717 | void free_gesture_binding(struct sway_gesture_binding *binding); | ||
718 | |||
678 | void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding); | 719 | void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding); |
679 | 720 | ||
680 | void load_swaybar(struct bar_config *bar); | 721 | void load_swaybar(struct bar_config *bar); |
@@ -690,14 +731,13 @@ void free_bar_binding(struct bar_binding *binding); | |||
690 | void free_workspace_config(struct workspace_config *wsc); | 731 | void free_workspace_config(struct workspace_config *wsc); |
691 | 732 | ||
692 | /** | 733 | /** |
693 | * Updates the value of config->font_height based on the max title height | 734 | * 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 | 735 | * font as reported by pango. |
695 | * recalculate their heights before reporting. | ||
696 | * | 736 | * |
697 | * If the height has changed, all containers will be rearranged to take on the | 737 | * If the height has changed, all containers will be rearranged to take on the |
698 | * new size. | 738 | * new size. |
699 | */ | 739 | */ |
700 | void config_update_font_height(bool recalculate); | 740 | void config_update_font_height(void); |
701 | 741 | ||
702 | /** | 742 | /** |
703 | * Convert bindsym into bindcode using the first configured layout. | 743 | * Convert bindsym into bindcode using the first configured layout. |
diff --git a/include/sway/criteria.h b/include/sway/criteria.h index ad8610cd..8da345ea 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 { |
@@ -42,6 +43,7 @@ struct criteria { | |||
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 | |||
3 | struct sway_container; | ||
4 | struct sway_view; | ||
5 | |||
6 | void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly, | ||
7 | bool whole); | ||
8 | |||
9 | void desktop_damage_whole_container(struct sway_container *con); | ||
10 | |||
11 | void desktop_damage_box(struct wlr_box *box); | ||
12 | |||
13 | void 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 0adafdb9..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 | ||
7 | enum sway_idle_inhibit_mode { | 5 | enum 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,10 @@ 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 | ||
23 | struct sway_idle_inhibitor_v1 { | 19 | struct sway_idle_inhibitor_v1 { |
24 | struct sway_idle_inhibit_manager_v1 *manager; | 20 | struct wlr_idle_inhibitor_v1 *wlr_inhibitor; |
25 | struct sway_view *view; | 21 | struct sway_view *view; |
26 | enum sway_idle_inhibit_mode mode; | 22 | enum sway_idle_inhibit_mode mode; |
27 | 23 | ||
@@ -32,8 +28,7 @@ struct sway_idle_inhibitor_v1 { | |||
32 | bool sway_idle_inhibit_v1_is_active( | 28 | bool sway_idle_inhibit_v1_is_active( |
33 | struct sway_idle_inhibitor_v1 *inhibitor); | 29 | struct sway_idle_inhibitor_v1 *inhibitor); |
34 | 30 | ||
35 | void sway_idle_inhibit_v1_check_active( | 31 | void sway_idle_inhibit_v1_check_active(void); |
36 | struct sway_idle_inhibit_manager_v1 *manager); | ||
37 | 32 | ||
38 | void sway_idle_inhibit_v1_user_inhibitor_register(struct sway_view *view, | 33 | void sway_idle_inhibit_v1_user_inhibitor_register(struct sway_view *view, |
39 | enum sway_idle_inhibit_mode mode); | 34 | enum sway_idle_inhibit_mode mode); |
@@ -47,6 +42,6 @@ struct sway_idle_inhibitor_v1 *sway_idle_inhibit_v1_application_inhibitor_for_vi | |||
47 | void sway_idle_inhibit_v1_user_inhibitor_destroy( | 42 | void sway_idle_inhibit_v1_user_inhibitor_destroy( |
48 | struct sway_idle_inhibitor_v1 *inhibitor); | 43 | struct sway_idle_inhibitor_v1 *inhibitor); |
49 | 44 | ||
50 | struct sway_idle_inhibit_manager_v1 *sway_idle_inhibit_manager_v1_create( | 45 | bool sway_idle_inhibit_manager_v1_init(void); |
51 | struct wl_display *wl_display, struct wlr_idle *idle); | 46 | |
52 | #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 | |||
8 | struct 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 | |||
25 | struct launcher_ctx *launcher_ctx_find_pid(pid_t pid); | ||
26 | |||
27 | struct sway_workspace *launcher_ctx_get_workspace(struct launcher_ctx *ctx); | ||
28 | |||
29 | void launcher_ctx_consume(struct launcher_ctx *ctx); | ||
30 | |||
31 | void launcher_ctx_destroy(struct launcher_ctx *ctx); | ||
32 | |||
33 | struct launcher_ctx *launcher_ctx_create_internal(void); | ||
34 | |||
35 | struct launcher_ctx *launcher_ctx_create( | ||
36 | struct wlr_xdg_activation_token_v1 *token, struct sway_node *node); | ||
37 | |||
38 | const 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 175489c5..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. |
@@ -28,12 +30,21 @@ struct sway_view; | |||
28 | */ | 30 | */ |
29 | void transaction_commit_dirty(void); | 31 | void transaction_commit_dirty(void); |
30 | 32 | ||
33 | /* | ||
34 | * Same as transaction_commit_dirty, but signalling that this is a | ||
35 | * client-initiated change has already taken effect. | ||
36 | */ | ||
37 | void transaction_commit_dirty_client(void); | ||
38 | |||
31 | /** | 39 | /** |
32 | * 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. |
33 | * | 41 | * |
34 | * 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. | ||
35 | */ | 46 | */ |
36 | void transaction_notify_view_ready_by_serial(struct sway_view *view, | 47 | bool transaction_notify_view_ready_by_serial(struct sway_view *view, |
37 | uint32_t serial); | 48 | uint32_t serial); |
38 | 49 | ||
39 | /** | 50 | /** |
@@ -41,14 +52,13 @@ void transaction_notify_view_ready_by_serial(struct sway_view *view, | |||
41 | * identifying the instruction by geometry rather than by serial. | 52 | * identifying the instruction by geometry rather than by serial. |
42 | * | 53 | * |
43 | * 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. | ||
44 | */ | 58 | */ |
45 | void transaction_notify_view_ready_by_geometry(struct sway_view *view, | 59 | bool transaction_notify_view_ready_by_geometry(struct sway_view *view, |
46 | double x, double y, int width, int height); | 60 | double x, double y, int width, int height); |
47 | 61 | ||
48 | /** | 62 | void arrange_popups(struct wlr_scene_tree *popups); |
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 | 63 | ||
54 | #endif | 64 | #endif |
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 6a38190b..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,8 +52,11 @@ 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; |
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; |
@@ -60,6 +64,7 @@ struct sway_cursor { | |||
60 | struct wl_listener tool_proximity; | 64 | struct wl_listener tool_proximity; |
61 | struct wl_listener tool_button; | 65 | struct wl_listener tool_button; |
62 | bool simulating_pointer_from_tool_tip; | 66 | bool simulating_pointer_from_tool_tip; |
67 | bool simulating_pointer_from_tool_button; | ||
63 | uint32_t tool_buttons; | 68 | uint32_t tool_buttons; |
64 | 69 | ||
65 | struct wl_listener request_set_cursor; | 70 | struct wl_listener request_set_cursor; |
@@ -103,12 +108,16 @@ void cursor_unhide(struct sway_cursor *cursor); | |||
103 | int cursor_get_timeout(struct sway_cursor *cursor); | 108 | int cursor_get_timeout(struct sway_cursor *cursor); |
104 | void cursor_notify_key_press(struct sway_cursor *cursor); | 109 | void cursor_notify_key_press(struct sway_cursor *cursor); |
105 | 110 | ||
111 | void 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 | |||
106 | void dispatch_cursor_button(struct sway_cursor *cursor, | 115 | void dispatch_cursor_button(struct sway_cursor *cursor, |
107 | 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, |
108 | enum wlr_button_state state); | 117 | enum wl_pointer_button_state state); |
109 | 118 | ||
110 | void dispatch_cursor_axis(struct sway_cursor *cursor, | 119 | void dispatch_cursor_axis(struct sway_cursor *cursor, |
111 | struct wlr_event_pointer_axis *event); | 120 | struct wlr_pointer_axis_event *event); |
112 | 121 | ||
113 | void cursor_set_image(struct sway_cursor *cursor, const char *image, | 122 | void cursor_set_image(struct sway_cursor *cursor, const char *image, |
114 | struct wl_client *client); | 123 | struct wl_client *client); |
@@ -136,4 +145,6 @@ uint32_t get_mouse_button(const char *name, char **error); | |||
136 | 145 | ||
137 | const char *get_mouse_button_name(uint32_t button); | 146 | const char *get_mouse_button_name(uint32_t button); |
138 | 147 | ||
148 | void handle_request_set_cursor_shape(struct wl_listener *listener, void *data); | ||
149 | |||
139 | #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 | ||
37 | struct sway_input_manager *input_manager_create(struct sway_server *server); | 39 | struct sway_input_manager *input_manager_create(struct sway_server *server); |
@@ -44,7 +46,7 @@ void input_manager_configure_xcursor(void); | |||
44 | 46 | ||
45 | void input_manager_apply_input_config(struct input_config *input_config); | 47 | void input_manager_apply_input_config(struct input_config *input_config); |
46 | 48 | ||
47 | void input_manager_configure_all_inputs(void); | 49 | void input_manager_configure_all_input_mappings(void); |
48 | 50 | ||
49 | void input_manager_reset_input(struct sway_input_device *input_device); | 51 | void 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 | ||
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..1f84a8e3 100644 --- a/include/sway/input/libinput.h +++ b/include/sway/input/libinput.h | |||
@@ -2,8 +2,13 @@ | |||
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 | ||
5 | void sway_input_configure_libinput_device(struct sway_input_device *device); | 5 | bool sway_input_configure_libinput_device(struct sway_input_device *device); |
6 | |||
7 | void sway_input_configure_libinput_device_send_events( | ||
8 | struct sway_input_device *device); | ||
6 | 9 | ||
7 | void sway_input_reset_libinput_device(struct sway_input_device *device); | 10 | void sway_input_reset_libinput_device(struct sway_input_device *device); |
8 | 11 | ||
12 | bool sway_libinput_device_is_builtin(struct sway_input_device *device); | ||
13 | |||
9 | #endif | 14 | #endif |
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; | |||
15 | struct sway_seatop_impl { | 17 | struct 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 | ||
53 | struct 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 | |||
66 | struct sway_drag { | 77 | struct 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, | |||
141 | void seat_configure_device(struct sway_seat *seat, | 160 | void seat_configure_device(struct sway_seat *seat, |
142 | struct sway_input_device *device); | 161 | struct sway_input_device *device); |
143 | 162 | ||
163 | void seat_configure_device_mapping(struct sway_seat *seat, | ||
164 | struct sway_input_device *input_device); | ||
165 | |||
144 | void seat_reset_device(struct sway_seat *seat, | 166 | void 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, | |||
171 | void seat_set_focus_layer(struct sway_seat *seat, | 193 | void seat_set_focus_layer(struct sway_seat *seat, |
172 | struct wlr_layer_surface_v1 *layer); | 194 | struct wlr_layer_surface_v1 *layer); |
173 | 195 | ||
174 | void seat_set_exclusive_client(struct sway_seat *seat, | 196 | void seat_unfocus_unless_client(struct sway_seat *seat, struct wl_client *client); |
175 | struct wl_client *client); | ||
176 | 197 | ||
177 | struct sway_node *seat_get_focus(struct sway_seat *seat); | 198 | struct 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 | ||
232 | bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface); | 253 | bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface); |
233 | 254 | ||
234 | void drag_icon_update_position(struct sway_drag_icon *icon); | 255 | void drag_icons_update_position(struct sway_seat *seat); |
235 | 256 | ||
236 | enum wlr_edges find_resize_edge(struct sway_container *cont, | 257 | enum 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, | |||
239 | void seatop_begin_default(struct sway_seat *seat); | 260 | void seatop_begin_default(struct sway_seat *seat); |
240 | 261 | ||
241 | void seatop_begin_down(struct sway_seat *seat, struct sway_container *con, | 262 | void 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 | |||
265 | void seatop_begin_down_on_surface(struct sway_seat *seat, | ||
266 | struct wlr_surface *surface, double sx, double sy); | ||
267 | |||
268 | void 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 | ||
244 | void seatop_begin_move_floating(struct sway_seat *seat, | 271 | void 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 | ||
262 | void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec, | 289 | void 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 | ||
265 | void seat_consider_warp_to_focus(struct sway_seat *seat); | 292 | void seat_consider_warp_to_focus(struct sway_seat *seat); |
266 | 293 | ||
267 | void seatop_button(struct sway_seat *seat, uint32_t time_msec, | 294 | void 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 | ||
271 | void seatop_pointer_motion(struct sway_seat *seat, uint32_t time_msec); | 298 | void seatop_pointer_motion(struct sway_seat *seat, uint32_t time_msec); |
272 | 299 | ||
273 | void seatop_pointer_axis(struct sway_seat *seat, | 300 | void seatop_pointer_axis(struct sway_seat *seat, |
274 | struct wlr_event_pointer_axis *event); | 301 | struct wlr_pointer_axis_event *event); |
275 | 302 | ||
276 | void seatop_tablet_tool_tip(struct sway_seat *seat, | 303 | void 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, | |||
280 | void seatop_tablet_tool_motion(struct sway_seat *seat, | 307 | void 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 | ||
310 | void seatop_hold_begin(struct sway_seat *seat, | ||
311 | struct wlr_pointer_hold_begin_event *event); | ||
312 | void seatop_hold_end(struct sway_seat *seat, | ||
313 | struct wlr_pointer_hold_end_event *event); | ||
314 | |||
315 | void seatop_pinch_begin(struct sway_seat *seat, | ||
316 | struct wlr_pointer_pinch_begin_event *event); | ||
317 | void seatop_pinch_update(struct sway_seat *seat, | ||
318 | struct wlr_pointer_pinch_update_event *event); | ||
319 | void seatop_pinch_end(struct sway_seat *seat, | ||
320 | struct wlr_pointer_pinch_end_event *event); | ||
321 | |||
322 | void seatop_swipe_begin(struct sway_seat *seat, | ||
323 | struct wlr_pointer_swipe_begin_event *event); | ||
324 | void seatop_swipe_update(struct sway_seat *seat, | ||
325 | struct wlr_pointer_swipe_update_event *event); | ||
326 | void seatop_swipe_end(struct sway_seat *seat, | ||
327 | struct wlr_pointer_swipe_end_event *event); | ||
328 | |||
329 | void seatop_touch_motion(struct sway_seat *seat, | ||
330 | struct wlr_touch_motion_event *event, double lx, double ly); | ||
331 | |||
332 | void seatop_touch_up(struct sway_seat *seat, | ||
333 | struct wlr_touch_up_event *event); | ||
334 | |||
335 | void seatop_touch_down(struct sway_seat *seat, | ||
336 | struct wlr_touch_down_event *event, double lx, double ly); | ||
337 | |||
338 | void seatop_touch_cancel(struct sway_seat *seat, | ||
339 | struct wlr_touch_cancel_event *event); | ||
340 | |||
283 | void seatop_rebase(struct sway_seat *seat, uint32_t time_msec); | 341 | void 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 | */ |
295 | void seatop_unref(struct sway_seat *seat, struct sway_container *con); | 353 | void 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 | */ | ||
301 | void seatop_render(struct sway_seat *seat, struct sway_output *output, | ||
302 | pixman_region32_t *damage); | ||
303 | |||
304 | bool seatop_allows_set_cursor(struct sway_seat *seat); | 355 | bool 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 | ||
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..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 | ||
63 | void sway_tablet_pad_destroy(struct sway_tablet_pad *tablet_pad); | 64 | void sway_tablet_pad_destroy(struct sway_tablet_pad *tablet_pad); |
64 | 65 | ||
65 | void sway_tablet_pad_notify_enter(struct sway_tablet_pad *tablet_pad, | 66 | void 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 6cf9bdb3..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,15 +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; | ||
32 | struct wl_listener input_method_grab_keyboard; | ||
31 | struct wl_listener input_method_destroy; | 33 | struct wl_listener input_method_destroy; |
34 | |||
35 | struct wl_listener input_method_keyboard_grab_destroy; | ||
32 | }; | 36 | }; |
33 | 37 | ||
38 | |||
34 | struct sway_text_input { | 39 | struct sway_text_input { |
35 | struct sway_input_method_relay *relay; | 40 | struct sway_input_method_relay *relay; |
36 | 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 | |||
6 | struct 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); | |||
9 | json_object *ipc_json_get_binding_mode(void); | 10 | json_object *ipc_json_get_binding_mode(void); |
10 | 11 | ||
11 | json_object *ipc_json_describe_disabled_output(struct sway_output *o); | 12 | json_object *ipc_json_describe_disabled_output(struct sway_output *o); |
13 | json_object *ipc_json_describe_non_desktop_output(struct sway_output_non_desktop *o); | ||
12 | json_object *ipc_json_describe_node(struct sway_node *node); | 14 | json_object *ipc_json_describe_node(struct sway_node *node); |
13 | json_object *ipc_json_describe_node_recursive(struct sway_node *node); | 15 | json_object *ipc_json_describe_node_recursive(struct sway_node *node); |
14 | json_object *ipc_json_describe_input(struct sway_input_device *device); | 16 | json_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); | |||
21 | void ipc_event_shutdown(const char *reason); | 21 | void ipc_event_shutdown(const char *reason); |
22 | void ipc_event_binding(struct sway_binding *binding); | 22 | void ipc_event_binding(struct sway_binding *binding); |
23 | void ipc_event_input(const char *change, struct sway_input_device *device); | 23 | void ipc_event_input(const char *change, struct sway_input_device *device); |
24 | void ipc_event_output(void); | ||
24 | 25 | ||
25 | #endif | 26 | #endif |
diff --git a/include/sway/layers.h b/include/sway/layers.h index 457634c2..fd6384e0 100644 --- a/include/sway/layers.h +++ b/include/sway/layers.h | |||
@@ -1,59 +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_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 | #include "sway/tree/view.h" | |
8 | enum layer_parent { | ||
9 | LAYER_PARENT_LAYER, | ||
10 | LAYER_PARENT_POPUP, | ||
11 | }; | ||
12 | 7 | ||
13 | struct sway_layer_surface { | 8 | struct sway_layer_surface { |
14 | struct wlr_layer_surface_v1 *layer_surface; | ||
15 | struct wl_list link; | ||
16 | |||
17 | struct wl_listener destroy; | ||
18 | struct wl_listener map; | 9 | struct wl_listener map; |
19 | struct wl_listener unmap; | 10 | struct wl_listener unmap; |
20 | struct wl_listener surface_commit; | 11 | struct wl_listener surface_commit; |
21 | struct wl_listener output_destroy; | 12 | struct wl_listener output_destroy; |
13 | struct wl_listener node_destroy; | ||
22 | struct wl_listener new_popup; | 14 | struct wl_listener new_popup; |
23 | struct wl_listener new_subsurface; | ||
24 | 15 | ||
25 | struct wlr_box geo; | 16 | bool mapped; |
26 | 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; | ||
27 | }; | 25 | }; |
28 | 26 | ||
29 | struct sway_layer_popup { | 27 | struct sway_layer_popup { |
30 | struct wlr_xdg_popup *wlr_popup; | 28 | struct wlr_xdg_popup *wlr_popup; |
31 | enum layer_parent parent_type; | 29 | struct wlr_scene_tree *scene; |
32 | union { | 30 | struct sway_layer_surface *toplevel; |
33 | struct sway_layer_surface *parent_layer; | ||
34 | struct sway_layer_popup *parent_popup; | ||
35 | }; | ||
36 | struct wl_listener map; | ||
37 | struct wl_listener unmap; | ||
38 | struct wl_listener destroy; | ||
39 | struct wl_listener commit; | ||
40 | struct wl_listener new_popup; | ||
41 | }; | ||
42 | 31 | ||
43 | struct sway_layer_subsurface { | ||
44 | struct wlr_subsurface *wlr_subsurface; | ||
45 | struct sway_layer_surface *layer_surface; | ||
46 | |||
47 | struct wl_listener map; | ||
48 | struct wl_listener unmap; | ||
49 | struct wl_listener destroy; | 32 | struct wl_listener destroy; |
33 | struct wl_listener new_popup; | ||
50 | struct wl_listener commit; | 34 | struct wl_listener commit; |
51 | }; | 35 | }; |
52 | 36 | ||
53 | struct sway_output; | 37 | struct sway_output; |
54 | void arrange_layers(struct sway_output *output); | ||
55 | 38 | ||
56 | struct sway_layer_surface *layer_from_wlr_layer_surface_v1( | 39 | struct wlr_layer_surface_v1 *toplevel_layer_surface_from_surface( |
57 | struct wlr_layer_surface_v1 *layer_surface); | 40 | struct wlr_surface *surface); |
41 | |||
42 | void arrange_layers(struct sway_output *output); | ||
58 | 43 | ||
59 | #endif | 44 | #endif |
diff --git a/include/sway/output.h b/include/sway/output.h index 96986700..d546d488 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -3,8 +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_box.h> | 6 | #include <wlr/types/wlr_damage_ring.h> |
7 | #include <wlr/types/wlr_output.h> | 7 | #include <wlr/types/wlr_output.h> |
8 | #include <wlr/types/wlr_scene.h> | ||
8 | #include "config.h" | 9 | #include "config.h" |
9 | #include "sway/tree/node.h" | 10 | #include "sway/tree/node.h" |
10 | #include "sway/tree/view.h" | 11 | #include "sway/tree/view.h" |
@@ -19,43 +20,63 @@ struct sway_output_state { | |||
19 | 20 | ||
20 | struct sway_output { | 21 | struct sway_output { |
21 | 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 | |||
22 | struct wlr_output *wlr_output; | 41 | struct wlr_output *wlr_output; |
42 | struct wlr_scene_output *scene_output; | ||
23 | struct sway_server *server; | 43 | struct sway_server *server; |
24 | struct wl_list link; | 44 | struct wl_list link; |
25 | 45 | ||
26 | struct wl_list layers[4]; // sway_layer_surface::link | ||
27 | struct wlr_box usable_area; | 46 | struct wlr_box usable_area; |
28 | 47 | ||
29 | struct timespec last_frame; | ||
30 | struct wlr_output_damage *damage; | ||
31 | |||
32 | int lx, ly; // layout coords | 48 | int lx, ly; // layout coords |
33 | int width, height; // transformed buffer size | 49 | int width, height; // transformed buffer size |
34 | enum wl_output_subpixel detected_subpixel; | 50 | enum wl_output_subpixel detected_subpixel; |
35 | enum scale_filter_mode scale_filter; | 51 | enum scale_filter_mode scale_filter; |
36 | // last applied mode when the output is DPMS'ed | ||
37 | struct wlr_output_mode *current_mode; | ||
38 | 52 | ||
39 | bool enabling, enabled; | 53 | bool enabled; |
40 | list_t *workspaces; | 54 | list_t *workspaces; |
41 | 55 | ||
42 | struct sway_output_state current; | 56 | struct sway_output_state current; |
43 | 57 | ||
58 | struct wl_listener layout_destroy; | ||
44 | struct wl_listener destroy; | 59 | struct wl_listener destroy; |
45 | struct wl_listener commit; | 60 | struct wl_listener commit; |
46 | struct wl_listener mode; | ||
47 | struct wl_listener present; | 61 | struct wl_listener present; |
48 | struct wl_listener damage_destroy; | 62 | struct wl_listener frame; |
49 | struct wl_listener damage_frame; | 63 | struct wl_listener request_state; |
50 | 64 | ||
51 | struct { | 65 | struct { |
52 | struct wl_signal destroy; | 66 | struct wl_signal disable; |
53 | } events; | 67 | } events; |
54 | 68 | ||
55 | struct timespec last_presentation; | 69 | struct timespec last_presentation; |
56 | uint32_t refresh_nsec; | 70 | uint32_t refresh_nsec; |
57 | int max_render_time; // In milliseconds | 71 | int max_render_time; // In milliseconds |
58 | struct wl_event_source *repaint_timer; | 72 | struct wl_event_source *repaint_timer; |
73 | bool gamma_lut_changed; | ||
74 | }; | ||
75 | |||
76 | struct sway_output_non_desktop { | ||
77 | struct wlr_output *wlr_output; | ||
78 | |||
79 | struct wl_listener destroy; | ||
59 | }; | 80 | }; |
60 | 81 | ||
61 | struct sway_output *output_create(struct wlr_output *wlr_output); | 82 | struct sway_output *output_create(struct wlr_output *wlr_output); |
@@ -72,22 +93,12 @@ struct sway_output *output_get_in_direction(struct sway_output *reference, | |||
72 | void output_add_workspace(struct sway_output *output, | 93 | void output_add_workspace(struct sway_output *output, |
73 | struct sway_workspace *workspace); | 94 | struct sway_workspace *workspace); |
74 | 95 | ||
75 | typedef void (*sway_surface_iterator_func_t)(struct sway_output *output, struct sway_view *view, | 96 | typedef void (*sway_surface_iterator_func_t)(struct sway_output *output, |
76 | struct wlr_surface *surface, struct wlr_box *box, float rotation, | 97 | struct sway_view *view, struct wlr_surface *surface, struct wlr_box *box, |
77 | void *user_data); | 98 | void *user_data); |
78 | 99 | ||
79 | void output_damage_whole(struct sway_output *output); | 100 | bool output_match_name_or_id(struct sway_output *output, |
80 | 101 | const char *name_or_id); | |
81 | void output_damage_surface(struct sway_output *output, double ox, double oy, | ||
82 | struct wlr_surface *surface, bool whole); | ||
83 | |||
84 | void output_damage_from_view(struct sway_output *output, | ||
85 | struct sway_view *view); | ||
86 | |||
87 | void output_damage_box(struct sway_output *output, struct wlr_box *box); | ||
88 | |||
89 | void output_damage_whole_container(struct sway_output *output, | ||
90 | struct sway_container *con); | ||
91 | 102 | ||
92 | // this ONLY includes the enabled outputs | 103 | // this ONLY includes the enabled outputs |
93 | struct sway_output *output_by_name_or_id(const char *name_or_id); | 104 | struct sway_output *output_by_name_or_id(const char *name_or_id); |
@@ -101,47 +112,8 @@ void output_enable(struct sway_output *output); | |||
101 | 112 | ||
102 | void output_disable(struct sway_output *output); | 113 | void output_disable(struct sway_output *output); |
103 | 114 | ||
104 | bool output_has_opaque_overlay_layer_surface(struct sway_output *output); | ||
105 | |||
106 | struct sway_workspace *output_get_active_workspace(struct sway_output *output); | 115 | struct sway_workspace *output_get_active_workspace(struct sway_output *output); |
107 | 116 | ||
108 | void output_render(struct sway_output *output, struct timespec *when, | ||
109 | pixman_region32_t *damage); | ||
110 | |||
111 | void output_surface_for_each_surface(struct sway_output *output, | ||
112 | struct wlr_surface *surface, double ox, double oy, | ||
113 | sway_surface_iterator_func_t iterator, void *user_data); | ||
114 | |||
115 | void output_view_for_each_surface(struct sway_output *output, | ||
116 | struct sway_view *view, sway_surface_iterator_func_t iterator, | ||
117 | void *user_data); | ||
118 | |||
119 | void output_view_for_each_popup_surface(struct sway_output *output, | ||
120 | struct sway_view *view, sway_surface_iterator_func_t iterator, | ||
121 | void *user_data); | ||
122 | |||
123 | void output_layer_for_each_surface(struct sway_output *output, | ||
124 | struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator, | ||
125 | void *user_data); | ||
126 | |||
127 | void output_layer_for_each_toplevel_surface(struct sway_output *output, | ||
128 | struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator, | ||
129 | void *user_data); | ||
130 | |||
131 | void output_layer_for_each_popup_surface(struct sway_output *output, | ||
132 | struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator, | ||
133 | void *user_data); | ||
134 | |||
135 | #if HAVE_XWAYLAND | ||
136 | void output_unmanaged_for_each_surface(struct sway_output *output, | ||
137 | struct wl_list *unmanaged, sway_surface_iterator_func_t iterator, | ||
138 | void *user_data); | ||
139 | #endif | ||
140 | |||
141 | void output_drag_icons_for_each_surface(struct sway_output *output, | ||
142 | struct wl_list *drag_icons, sway_surface_iterator_func_t iterator, | ||
143 | void *user_data); | ||
144 | |||
145 | void output_for_each_workspace(struct sway_output *output, | 117 | void output_for_each_workspace(struct sway_output *output, |
146 | void (*f)(struct sway_workspace *ws, void *data), void *data); | 118 | void (*f)(struct sway_workspace *ws, void *data), void *data); |
147 | 119 | ||
@@ -159,18 +131,12 @@ void output_get_box(struct sway_output *output, struct wlr_box *box); | |||
159 | enum sway_container_layout output_get_default_layout( | 131 | enum sway_container_layout output_get_default_layout( |
160 | struct sway_output *output); | 132 | struct sway_output *output); |
161 | 133 | ||
162 | void render_rect(struct sway_output *output, | ||
163 | pixman_region32_t *output_damage, const struct wlr_box *_box, | ||
164 | float color[static 4]); | ||
165 | |||
166 | void premultiply_alpha(float color[4], float opacity); | ||
167 | |||
168 | void scale_box(struct wlr_box *box, float scale); | ||
169 | |||
170 | enum wlr_direction opposite_direction(enum wlr_direction d); | 134 | enum wlr_direction opposite_direction(enum wlr_direction d); |
171 | 135 | ||
172 | void handle_output_layout_change(struct wl_listener *listener, void *data); | 136 | void handle_output_layout_change(struct wl_listener *listener, void *data); |
173 | 137 | ||
138 | void handle_gamma_control_set_gamma(struct wl_listener *listener, void *data); | ||
139 | |||
174 | void handle_output_manager_apply(struct wl_listener *listener, void *data); | 140 | void handle_output_manager_apply(struct wl_listener *listener, void *data); |
175 | 141 | ||
176 | void handle_output_manager_test(struct wl_listener *listener, void *data); | 142 | void handle_output_manager_test(struct wl_listener *listener, void *data); |
@@ -178,4 +144,6 @@ void handle_output_manager_test(struct wl_listener *listener, void *data); | |||
178 | void handle_output_power_manager_set_mode(struct wl_listener *listener, | 144 | void handle_output_power_manager_set_mode(struct wl_listener *listener, |
179 | void *data); | 145 | void *data); |
180 | 146 | ||
147 | struct sway_output_non_desktop *output_non_desktop_create(struct wlr_output *wlr_output); | ||
148 | |||
181 | #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 | |||
13 | enum 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 | |||
24 | bool scene_descriptor_assign(struct wlr_scene_node *node, | ||
25 | enum sway_scene_descriptor_type type, void *data); | ||
26 | |||
27 | void *scene_descriptor_try_get(struct wlr_scene_node *node, | ||
28 | enum sway_scene_descriptor_type type); | ||
29 | |||
30 | void 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 0f5e3ab2..c71851f6 100644 --- a/include/sway/server.h +++ b/include/sway/server.h | |||
@@ -2,39 +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" |
7 | #include "sway/desktop/idle_inhibit_v1.h" | ||
22 | #if HAVE_XWAYLAND | 8 | #if HAVE_XWAYLAND |
23 | #include "sway/xwayland.h" | 9 | #include "sway/xwayland.h" |
24 | #endif | 10 | #endif |
25 | 11 | ||
12 | struct sway_transaction; | ||
13 | |||
14 | struct 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 | |||
26 | struct sway_server { | 27 | struct sway_server { |
27 | struct wl_display *wl_display; | 28 | struct wl_display *wl_display; |
28 | struct wl_event_loop *wl_event_loop; | 29 | struct wl_event_loop *wl_event_loop; |
29 | const char *socket; | 30 | const char *socket; |
30 | 31 | ||
31 | struct wlr_backend *backend; | 32 | struct wlr_backend *backend; |
32 | struct wlr_backend *noop_backend; | 33 | struct wlr_session *session; |
33 | // secondary headless backend used for creating virtual outputs on-the-fly | 34 | // secondary headless backend used for creating virtual outputs on-the-fly |
34 | struct wlr_backend *headless_backend; | 35 | struct wlr_backend *headless_backend; |
36 | struct wlr_renderer *renderer; | ||
37 | struct wlr_allocator *allocator; | ||
35 | 38 | ||
36 | struct wlr_compositor *compositor; | 39 | struct wlr_compositor *compositor; |
37 | struct wl_listener compositor_new_surface; | 40 | |
41 | struct wlr_linux_dmabuf_v1 *linux_dmabuf_v1; | ||
38 | 42 | ||
39 | struct wlr_data_device_manager *data_device_manager; | 43 | struct wlr_data_device_manager *data_device_manager; |
40 | 44 | ||
@@ -42,15 +46,16 @@ struct sway_server { | |||
42 | 46 | ||
43 | struct wl_listener new_output; | 47 | struct wl_listener new_output; |
44 | struct wl_listener output_layout_change; | 48 | struct wl_listener output_layout_change; |
49 | struct wl_listener renderer_lost; | ||
45 | 50 | ||
46 | struct wlr_idle *idle; | 51 | struct wlr_idle_notifier_v1 *idle_notifier_v1; |
47 | struct sway_idle_inhibit_manager_v1 *idle_inhibit_manager_v1; | 52 | struct sway_idle_inhibit_manager_v1 idle_inhibit_manager_v1; |
48 | 53 | ||
49 | struct wlr_layer_shell_v1 *layer_shell; | 54 | struct wlr_layer_shell_v1 *layer_shell; |
50 | struct wl_listener layer_shell_surface; | 55 | struct wl_listener layer_shell_surface; |
51 | 56 | ||
52 | struct wlr_xdg_shell *xdg_shell; | 57 | struct wlr_xdg_shell *xdg_shell; |
53 | struct wl_listener xdg_shell_surface; | 58 | struct wl_listener xdg_shell_toplevel; |
54 | 59 | ||
55 | struct wlr_tablet_manager_v2 *tablet_v2; | 60 | struct wlr_tablet_manager_v2 *tablet_v2; |
56 | 61 | ||
@@ -70,7 +75,8 @@ struct sway_server { | |||
70 | struct wl_listener xdg_decoration; | 75 | struct wl_listener xdg_decoration; |
71 | struct wl_list xdg_decorations; // sway_xdg_decoration::link | 76 | struct wl_list xdg_decorations; // sway_xdg_decoration::link |
72 | 77 | ||
73 | struct wlr_presentation *presentation; | 78 | struct wlr_drm_lease_v1_manager *drm_lease_manager; |
79 | struct wl_listener drm_lease_request; | ||
74 | 80 | ||
75 | struct wlr_pointer_constraints_v1 *pointer_constraints; | 81 | struct wlr_pointer_constraints_v1 *pointer_constraints; |
76 | struct wl_listener pointer_constraint; | 82 | struct wl_listener pointer_constraint; |
@@ -79,14 +85,53 @@ struct sway_server { | |||
79 | struct wl_listener output_manager_apply; | 85 | struct wl_listener output_manager_apply; |
80 | struct wl_listener output_manager_test; | 86 | struct wl_listener output_manager_test; |
81 | 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 | |||
82 | struct wlr_output_power_manager_v1 *output_power_manager_v1; | 99 | struct wlr_output_power_manager_v1 *output_power_manager_v1; |
83 | struct wl_listener output_power_manager_set_mode; | 100 | struct wl_listener output_power_manager_set_mode; |
84 | struct wlr_input_method_manager_v2 *input_method; | 101 | struct wlr_input_method_manager_v2 *input_method; |
85 | 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; | ||
86 | 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; | ||
110 | |||
111 | struct wlr_xdg_activation_v1 *xdg_activation_v1; | ||
112 | struct wl_listener xdg_activation_v1_request_activate; | ||
113 | struct wl_listener xdg_activation_v1_new_token; | ||
87 | 114 | ||
115 | struct wl_listener request_set_cursor_shape; | ||
116 | |||
117 | struct wl_list pending_launcher_ctxs; // launcher_ctx::link | ||
118 | |||
119 | // The timeout for transactions, after which a transaction is applied | ||
120 | // regardless of readiness. | ||
88 | size_t txn_timeout_ms; | 121 | size_t txn_timeout_ms; |
89 | list_t *transactions; | 122 | |
123 | // Stores a transaction after it has been committed, but is waiting for | ||
124 | // views to ack the new dimensions before being applied. A queued | ||
125 | // transaction is frozen and must not have new instructions added to it. | ||
126 | struct sway_transaction *queued_transaction; | ||
127 | |||
128 | // Stores a pending transaction that will be committed once the existing | ||
129 | // queued transaction is applied and freed. The pending transaction can be | ||
130 | // updated with new instructions as needed. | ||
131 | struct sway_transaction *pending_transaction; | ||
132 | |||
133 | // Stores the nodes that have been marked as "dirty" and will be put into | ||
134 | // the pending transaction. | ||
90 | list_t *dirty_nodes; | 135 | list_t *dirty_nodes; |
91 | }; | 136 | }; |
92 | 137 | ||
@@ -96,34 +141,41 @@ struct sway_debug { | |||
96 | bool noatomic; // Ignore atomic layout updates | 141 | bool noatomic; // Ignore atomic layout updates |
97 | bool txn_timings; // Log verbose messages about transactions | 142 | bool txn_timings; // Log verbose messages about transactions |
98 | bool txn_wait; // Always wait for the timeout before applying | 143 | bool txn_wait; // Always wait for the timeout before applying |
99 | 144 | bool legacy_wl_drm; // Enable the legacy wl_drm interface | |
100 | enum { | ||
101 | DAMAGE_DEFAULT, // Default behaviour | ||
102 | DAMAGE_HIGHLIGHT, // Highlight regions of the screen being damaged | ||
103 | DAMAGE_RERENDER, // Render the full output when any damage occurs | ||
104 | } damage; | ||
105 | }; | 145 | }; |
106 | 146 | ||
107 | extern struct sway_debug debug; | 147 | extern struct sway_debug debug; |
108 | 148 | ||
109 | /* Prepares an unprivileged server_init by performing all privileged operations in advance */ | 149 | extern bool allow_unsupported_gpu; |
110 | bool server_privileged_prepare(struct sway_server *server); | 150 | |
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 | ||
116 | void handle_compositor_new_surface(struct wl_listener *listener, void *data); | 156 | void restore_nofile_limit(void); |
157 | |||
117 | void handle_new_output(struct wl_listener *listener, void *data); | 158 | void handle_new_output(struct wl_listener *listener, void *data); |
118 | 159 | ||
119 | void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data); | 160 | void handle_idle_inhibitor_v1(struct wl_listener *listener, void *data); |
120 | void handle_layer_shell_surface(struct wl_listener *listener, void *data); | 161 | void handle_layer_shell_surface(struct wl_listener *listener, void *data); |
121 | void handle_xdg_shell_surface(struct wl_listener *listener, void *data); | 162 | void sway_session_lock_init(void); |
163 | void sway_session_lock_add_output(struct sway_session_lock *lock, | ||
164 | struct sway_output *output); | ||
165 | bool sway_session_lock_has_surface(struct sway_session_lock *lock, | ||
166 | struct wlr_surface *surface); | ||
167 | void handle_xdg_shell_toplevel(struct wl_listener *listener, void *data); | ||
122 | #if HAVE_XWAYLAND | 168 | #if HAVE_XWAYLAND |
123 | void handle_xwayland_surface(struct wl_listener *listener, void *data); | 169 | void handle_xwayland_surface(struct wl_listener *listener, void *data); |
124 | #endif | 170 | #endif |
125 | void handle_server_decoration(struct wl_listener *listener, void *data); | 171 | void handle_server_decoration(struct wl_listener *listener, void *data); |
126 | void handle_xdg_decoration(struct wl_listener *listener, void *data); | 172 | void handle_xdg_decoration(struct wl_listener *listener, void *data); |
127 | void handle_pointer_constraint(struct wl_listener *listener, void *data); | 173 | void handle_pointer_constraint(struct wl_listener *listener, void *data); |
174 | void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, | ||
175 | void *data); | ||
176 | void xdg_activation_v1_handle_new_token(struct wl_listener *listener, | ||
177 | void *data); | ||
178 | |||
179 | void set_rr_scheduling(void); | ||
128 | 180 | ||
129 | #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 | |||
5 | struct 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 | |||
5 | struct 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 | |||
17 | struct sway_text_node *sway_text_node_create(struct wlr_scene_tree *parent, | ||
18 | char *text, float color[4], bool pango_markup); | ||
19 | |||
20 | void sway_text_node_set_color(struct sway_text_node *node, float color[4]); | ||
21 | |||
22 | void sway_text_node_set_text(struct sway_text_node *node, char *text); | ||
23 | |||
24 | void sway_text_node_set_max_width(struct sway_text_node *node, int max_width); | ||
25 | |||
26 | void 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 | ||
5 | struct swaynag_instance { | 6 | struct 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. |
23 | void swaynag_log(const char *swaynag_command, struct swaynag_instance *swaynag, | 24 | void 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 |
27 | void swaynag_show(struct swaynag_instance *swaynag); | 28 | void swaynag_show(struct swaynag_instance *swaynag); |
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 7e9df59f..93f6bfbb 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -2,8 +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_box.h> | 5 | #include <wlr/types/wlr_compositor.h> |
6 | #include <wlr/types/wlr_surface.h> | 6 | #include <wlr/types/wlr_scene.h> |
7 | #include "list.h" | 7 | #include "list.h" |
8 | #include "sway/tree/node.h" | 8 | #include "sway/tree/node.h" |
9 | 9 | ||
@@ -46,9 +46,9 @@ struct sway_container_state { | |||
46 | 46 | ||
47 | enum sway_fullscreen_mode fullscreen_mode; | 47 | enum sway_fullscreen_mode fullscreen_mode; |
48 | 48 | ||
49 | struct sway_workspace *workspace; | 49 | struct sway_workspace *workspace; // NULL when hidden in the scratchpad |
50 | struct sway_container *parent; | 50 | struct sway_container *parent; // NULL if container in root of workspace |
51 | list_t *children; | 51 | list_t *children; // struct sway_container |
52 | 52 | ||
53 | struct sway_container *focused_inactive_child; | 53 | struct sway_container *focused_inactive_child; |
54 | bool focused; | 54 | bool focused; |
@@ -60,6 +60,7 @@ struct sway_container_state { | |||
60 | bool border_left; | 60 | bool border_left; |
61 | bool border_right; | 61 | bool border_right; |
62 | 62 | ||
63 | // These are in layout coordinates. | ||
63 | double content_x, content_y; | 64 | double content_x, content_y; |
64 | double content_width, content_height; | 65 | double content_width, content_height; |
65 | }; | 66 | }; |
@@ -68,14 +69,40 @@ 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 | ||
71 | // The pending state is the main container properties, and the current state is in the below struct. | 72 | struct wlr_scene_tree *scene_tree; |
72 | // This means most places of the code can refer to the main variables (pending state) and it'll just work. | 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 | |||
73 | struct sway_container_state current; | 99 | struct sway_container_state current; |
100 | struct sway_container_state pending; | ||
74 | 101 | ||
75 | char *title; // The view's title (unformatted) | 102 | char *title; // The view's title (unformatted) |
76 | 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; | ||
77 | 105 | ||
78 | enum sway_container_layout layout; | ||
79 | enum sway_container_layout prev_split_layout; | 106 | enum sway_container_layout prev_split_layout; |
80 | 107 | ||
81 | // Whether stickiness has been enabled on this container. Use | 108 | // Whether stickiness has been enabled on this container. Use |
@@ -86,11 +113,13 @@ struct sway_container { | |||
86 | // For C_ROOT, this has no meaning | 113 | // For C_ROOT, this has no meaning |
87 | // For other types, this is the position in layout coordinates | 114 | // For other types, this is the position in layout coordinates |
88 | // Includes borders | 115 | // Includes borders |
89 | double x, y; | ||
90 | double width, height; | ||
91 | double saved_x, saved_y; | 116 | double saved_x, saved_y; |
92 | double saved_width, saved_height; | 117 | double saved_width, saved_height; |
93 | 118 | ||
119 | // Used when the view changes to CSD unexpectedly. This will be a non-B_CSD | ||
120 | // border which we use to restore when the view returns to SSD. | ||
121 | enum sway_container_border saved_border; | ||
122 | |||
94 | // The share of the space of parent container this container occupies | 123 | // The share of the space of parent container this container occupies |
95 | double width_fraction; | 124 | double width_fraction; |
96 | double height_fraction; | 125 | double height_fraction; |
@@ -100,55 +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 | // 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 | ||
108 | // refuses to resize to the content dimensions then it can be smaller. | ||
109 | // These are in layout coordinates. | ||
110 | double surface_x, surface_y; | ||
111 | |||
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 | ||
131 | list_t *outputs; // struct sway_output | ||
132 | |||
133 | // Indicates that the container is a scratchpad container. | 132 | // Indicates that the container is a scratchpad container. |
134 | // Both hidden and visible scratchpad containers have scratchpad=true. | 133 | // Both hidden and visible scratchpad containers have scratchpad=true. |
135 | // Hidden scratchpad containers have a NULL parent. | 134 | // Hidden scratchpad containers have a NULL parent. |
136 | bool scratchpad; | 135 | bool scratchpad; |
137 | 136 | ||
138 | 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; | ||
139 | 141 | ||
140 | struct wlr_texture *title_focused; | 142 | float alpha; |
141 | struct wlr_texture *title_focused_inactive; | ||
142 | struct wlr_texture *title_unfocused; | ||
143 | struct wlr_texture *title_urgent; | ||
144 | size_t title_height; | ||
145 | size_t title_baseline; | ||
146 | 143 | ||
147 | list_t *marks; // char * | 144 | list_t *marks; // char * |
148 | struct wlr_texture *marks_focused; | ||
149 | struct wlr_texture *marks_focused_inactive; | ||
150 | struct wlr_texture *marks_unfocused; | ||
151 | struct wlr_texture *marks_urgent; | ||
152 | 145 | ||
153 | struct { | 146 | struct { |
154 | struct wl_signal destroy; | 147 | struct wl_signal destroy; |
@@ -168,23 +161,15 @@ void container_begin_destroy(struct sway_container *con); | |||
168 | struct sway_container *container_find_child(struct sway_container *container, | 161 | struct sway_container *container_find_child(struct sway_container *container, |
169 | bool (*test)(struct sway_container *view, void *data), void *data); | 162 | bool (*test)(struct sway_container *view, void *data), void *data); |
170 | 163 | ||
171 | /** | ||
172 | * Find a container at the given coordinates. Returns the surface and | ||
173 | * surface-local coordinates of the given layout coordinates if the container | ||
174 | * is a view and the view contains a surface at those coordinates. | ||
175 | */ | ||
176 | struct sway_container *container_at(struct sway_workspace *workspace, | ||
177 | double lx, double ly, struct wlr_surface **surface, | ||
178 | double *sx, double *sy); | ||
179 | |||
180 | struct sway_container *tiling_container_at( | ||
181 | struct sway_node *parent, double lx, double ly, | ||
182 | struct wlr_surface **surface, double *sx, double *sy); | ||
183 | |||
184 | void container_for_each_child(struct sway_container *container, | 164 | void container_for_each_child(struct sway_container *container, |
185 | void (*f)(struct sway_container *container, void *data), void *data); | 165 | void (*f)(struct sway_container *container, void *data), void *data); |
186 | 166 | ||
187 | /** | 167 | /** |
168 | * Returns the fullscreen container obstructing this container if it exists. | ||
169 | */ | ||
170 | struct sway_container *container_obstructing_fullscreen_container(struct sway_container *container); | ||
171 | |||
172 | /** | ||
188 | * Returns true if the given container is an ancestor of this container. | 173 | * Returns true if the given container is an ancestor of this container. |
189 | */ | 174 | */ |
190 | bool container_has_ancestor(struct sway_container *container, | 175 | bool container_has_ancestor(struct sway_container *container, |
@@ -192,18 +177,13 @@ bool container_has_ancestor(struct sway_container *container, | |||
192 | 177 | ||
193 | void container_update_textures_recursive(struct sway_container *con); | 178 | void container_update_textures_recursive(struct sway_container *con); |
194 | 179 | ||
195 | void container_damage_whole(struct sway_container *container); | ||
196 | |||
197 | void container_reap_empty(struct sway_container *con); | 180 | void container_reap_empty(struct sway_container *con); |
198 | 181 | ||
199 | struct sway_container *container_flatten(struct sway_container *container); | 182 | 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_bar(struct sway_container *container); |
202 | 185 | ||
203 | /** | 186 | void container_update_marks(struct sway_container *container); |
204 | * Calculate the container's title_height property. | ||
205 | */ | ||
206 | void container_calculate_title_height(struct sway_container *container); | ||
207 | 187 | ||
208 | size_t container_build_representation(enum sway_container_layout layout, | 188 | size_t container_build_representation(enum sway_container_layout layout, |
209 | list_t *children, char *buffer); | 189 | list_t *children, char *buffer); |
@@ -218,6 +198,9 @@ size_t container_titlebar_height(void); | |||
218 | void floating_calculate_constraints(int *min_width, int *max_width, | 198 | void floating_calculate_constraints(int *min_width, int *max_width, |
219 | int *min_height, int *max_height); | 199 | int *min_height, int *max_height); |
220 | 200 | ||
201 | void floating_fix_coordinates(struct sway_container *con, | ||
202 | struct wlr_box *old, struct wlr_box *new); | ||
203 | |||
221 | void container_floating_resize_and_center(struct sway_container *con); | 204 | void container_floating_resize_and_center(struct sway_container *con); |
222 | 205 | ||
223 | void container_floating_set_default_size(struct sway_container *con); | 206 | void container_floating_set_default_size(struct sway_container *con); |
@@ -231,6 +214,8 @@ void container_set_geometry_from_content(struct sway_container *con); | |||
231 | /** | 214 | /** |
232 | * Determine if the given container is itself floating. | 215 | * Determine if the given container is itself floating. |
233 | * This will return false for any descendants of a floating container. | 216 | * This will return false for any descendants of a floating container. |
217 | * | ||
218 | * Uses pending container state. | ||
234 | */ | 219 | */ |
235 | bool container_is_floating(struct sway_container *container); | 220 | bool container_is_floating(struct sway_container *container); |
236 | 221 | ||
@@ -296,25 +281,12 @@ bool container_is_floating_or_child(struct sway_container *container); | |||
296 | */ | 281 | */ |
297 | bool container_is_fullscreen_or_child(struct sway_container *container); | 282 | bool container_is_fullscreen_or_child(struct sway_container *container); |
298 | 283 | ||
299 | /** | ||
300 | * Return the output which will be used for scale purposes. | ||
301 | * This is the most recently entered output. | ||
302 | */ | ||
303 | struct sway_output *container_get_effective_output(struct sway_container *con); | ||
304 | |||
305 | void container_discover_outputs(struct sway_container *con); | ||
306 | |||
307 | enum sway_container_layout container_parent_layout(struct sway_container *con); | 284 | enum sway_container_layout container_parent_layout(struct sway_container *con); |
308 | 285 | ||
309 | enum sway_container_layout container_current_parent_layout( | ||
310 | struct sway_container *con); | ||
311 | |||
312 | list_t *container_get_siblings(struct sway_container *container); | 286 | list_t *container_get_siblings(struct sway_container *container); |
313 | 287 | ||
314 | int container_sibling_index(struct sway_container *child); | 288 | int container_sibling_index(struct sway_container *child); |
315 | 289 | ||
316 | list_t *container_get_current_siblings(struct sway_container *container); | ||
317 | |||
318 | void container_handle_fullscreen_reparent(struct sway_container *con); | 290 | void container_handle_fullscreen_reparent(struct sway_container *con); |
319 | 291 | ||
320 | void container_add_child(struct sway_container *parent, | 292 | void container_add_child(struct sway_container *parent, |
@@ -362,8 +334,6 @@ bool container_has_mark(struct sway_container *container, char *mark); | |||
362 | 334 | ||
363 | void container_add_mark(struct sway_container *container, char *mark); | 335 | void container_add_mark(struct sway_container *container, char *mark); |
364 | 336 | ||
365 | void container_update_marks_textures(struct sway_container *container); | ||
366 | |||
367 | void container_raise_floating(struct sway_container *con); | 337 | void container_raise_floating(struct sway_container *con); |
368 | 338 | ||
369 | bool container_is_scratchpad_hidden(struct sway_container *con); | 339 | bool container_is_scratchpad_hidden(struct sway_container *con); |
@@ -378,7 +348,7 @@ bool container_is_sticky_or_child(struct sway_container *con); | |||
378 | * This will destroy pairs of redundant H/V splits | 348 | * This will destroy pairs of redundant H/V splits |
379 | * 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] |
380 | * 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 |
381 | * 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. |
382 | * | 352 | * |
383 | * This function is roughly equivalent to i3's tree_flatten here: | 353 | * This function is roughly equivalent to i3's tree_flatten here: |
384 | * https://github.com/i3/i3/blob/1f0c628cde40cf87371481041b7197344e0417c6/src/tree.c#L651 | 354 | * https://github.com/i3/i3/blob/1f0c628cde40cf87371481041b7197344e0417c6/src/tree.c#L651 |
@@ -387,4 +357,10 @@ bool container_is_sticky_or_child(struct sway_container *con); | |||
387 | */ | 357 | */ |
388 | int container_squash(struct sway_container *con); | 358 | int container_squash(struct sway_container *con); |
389 | 359 | ||
360 | void container_arrange_title_bar(struct sway_container *con); | ||
361 | |||
362 | void container_update(struct sway_container *con); | ||
363 | |||
364 | void container_update_itself_and_parents(struct sway_container *con); | ||
365 | |||
390 | #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 | ||
75 | bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor); | 77 | bool 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. | ||
82 | void 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. | ||
87 | struct 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..15df0f55 100644 --- a/include/sway/tree/root.h +++ b/include/sway/tree/root.h | |||
@@ -3,6 +3,7 @@ | |||
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/types/wlr_output_layout.h> | 5 | #include <wlr/types/wlr_output_layout.h> |
6 | #include <wlr/types/wlr_scene.h> | ||
6 | #include <wlr/render/wlr_texture.h> | 7 | #include <wlr/render/wlr_texture.h> |
7 | #include "sway/tree/container.h" | 8 | #include "sway/tree/container.h" |
8 | #include "sway/tree/node.h" | 9 | #include "sway/tree/node.h" |
@@ -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; |
20 | |||
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; | ||
19 | #if HAVE_XWAYLAND | 50 | #if HAVE_XWAYLAND |
20 | struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link | 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 | ||
43 | struct sway_root *root_create(void); | 79 | struct sway_root *root_create(struct wl_display *display); |
44 | 80 | ||
45 | void root_destroy(struct sway_root *root); | 81 | void root_destroy(struct sway_root *root); |
46 | 82 | ||
@@ -68,12 +104,6 @@ void root_scratchpad_show(struct sway_container *con); | |||
68 | */ | 104 | */ |
69 | void root_scratchpad_hide(struct sway_container *con); | 105 | void root_scratchpad_hide(struct sway_container *con); |
70 | 106 | ||
71 | struct sway_workspace *root_workspace_for_pid(pid_t pid); | ||
72 | |||
73 | void root_record_workspace_pid(pid_t pid); | ||
74 | |||
75 | void root_remove_workspace_pid(pid_t pid); | ||
76 | |||
77 | void root_for_each_workspace(void (*f)(struct sway_workspace *ws, void *data), | 107 | void 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 | ||
92 | void root_get_box(struct sway_root *root, struct wlr_box *box); | 122 | void root_get_box(struct sway_root *root, struct wlr_box *box); |
93 | 123 | ||
94 | void 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 e071e6c9..7faacdcc 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -1,8 +1,9 @@ | |||
1 | #ifndef _SWAY_VIEW_H | 1 | #ifndef _SWAY_VIEW_H |
2 | #define _SWAY_VIEW_H | 2 | #define _SWAY_VIEW_H |
3 | #include <wayland-server-core.h> | 3 | #include <wayland-server-core.h> |
4 | #include <wlr/types/wlr_surface.h> | 4 | #include <wlr/types/wlr_compositor.h> |
5 | #include "config.h" | 5 | #include <wlr/types/wlr_scene.h> |
6 | #include "sway/config.h" | ||
6 | #if HAVE_XWAYLAND | 7 | #if HAVE_XWAYLAND |
7 | #include <wlr/xwayland.h> | 8 | #include <wlr/xwayland.h> |
8 | #endif | 9 | #endif |
@@ -45,10 +46,6 @@ struct sway_view_impl { | |||
45 | void (*set_fullscreen)(struct sway_view *view, bool fullscreen); | 46 | void (*set_fullscreen)(struct sway_view *view, bool fullscreen); |
46 | void (*set_resizing)(struct sway_view *view, bool resizing); | 47 | void (*set_resizing)(struct sway_view *view, bool resizing); |
47 | bool (*wants_floating)(struct sway_view *view); | 48 | bool (*wants_floating)(struct sway_view *view); |
48 | void (*for_each_surface)(struct sway_view *view, | ||
49 | wlr_surface_iterator_func_t iterator, void *user_data); | ||
50 | void (*for_each_popup_surface)(struct sway_view *view, | ||
51 | wlr_surface_iterator_func_t iterator, void *user_data); | ||
52 | bool (*is_transient_for)(struct sway_view *child, | 49 | bool (*is_transient_for)(struct sway_view *child, |
53 | struct sway_view *ancestor); | 50 | struct sway_view *ancestor); |
54 | void (*close)(struct sway_view *view); | 51 | void (*close)(struct sway_view *view); |
@@ -56,24 +53,20 @@ struct sway_view_impl { | |||
56 | void (*destroy)(struct sway_view *view); | 53 | void (*destroy)(struct sway_view *view); |
57 | }; | 54 | }; |
58 | 55 | ||
59 | struct 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 | |||
68 | struct sway_view { | 56 | struct sway_view { |
69 | enum sway_view_type type; | 57 | enum sway_view_type type; |
70 | const struct sway_view_impl *impl; | 58 | const struct sway_view_impl *impl; |
71 | 59 | ||
60 | struct wlr_scene_tree *scene_tree; | ||
61 | struct wlr_scene_tree *content_tree; | ||
62 | struct wlr_scene_tree *saved_surface_tree; | ||
63 | |||
72 | struct sway_container *container; // NULL if unmapped and transactions finished | 64 | struct sway_container *container; // NULL if unmapped and transactions finished |
73 | struct wlr_surface *surface; // NULL for unmapped views | 65 | struct wlr_surface *surface; // NULL for unmapped views |
74 | struct sway_xdg_decoration *xdg_decoration; | 66 | struct sway_xdg_decoration *xdg_decoration; |
75 | 67 | ||
76 | pid_t pid; | 68 | pid_t pid; |
69 | struct launcher_ctx *ctx; | ||
77 | 70 | ||
78 | // The size the view would want to be if it weren't tiled. | 71 | // The size the view would want to be if it weren't tiled. |
79 | // Used when changing a view from tiled to floating. | 72 | // Used when changing a view from tiled to floating. |
@@ -87,15 +80,11 @@ struct sway_view { | |||
87 | bool allow_request_urgent; | 80 | bool allow_request_urgent; |
88 | struct wl_event_source *urgent_timer; | 81 | struct wl_event_source *urgent_timer; |
89 | 82 | ||
90 | struct wl_list saved_buffers; // sway_saved_buffer::link | ||
91 | |||
92 | // The geometry for whatever the client is committing, regardless of | 83 | // The geometry for whatever the client is committing, regardless of |
93 | // transaction state. Updated on every commit. | 84 | // transaction state. Updated on every commit. |
94 | struct wlr_box geometry; | 85 | struct wlr_box geometry; |
95 | 86 | ||
96 | // The "old" geometry during a transaction. Used to damage the old location | 87 | struct wlr_ext_foreign_toplevel_handle_v1 *ext_foreign_toplevel; |
97 | // when a transaction is applied. | ||
98 | struct wlr_box saved_geometry; | ||
99 | 88 | ||
100 | struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel; | 89 | struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel; |
101 | struct wl_listener foreign_activate_request; | 90 | struct wl_listener foreign_activate_request; |
@@ -108,19 +97,16 @@ struct sway_view { | |||
108 | list_t *executed_criteria; // struct criteria * | 97 | list_t *executed_criteria; // struct criteria * |
109 | 98 | ||
110 | union { | 99 | union { |
111 | struct wlr_xdg_surface *wlr_xdg_surface; | 100 | struct wlr_xdg_toplevel *wlr_xdg_toplevel; |
112 | #if HAVE_XWAYLAND | 101 | #if HAVE_XWAYLAND |
113 | struct wlr_xwayland_surface *wlr_xwayland_surface; | 102 | struct wlr_xwayland_surface *wlr_xwayland_surface; |
114 | #endif | 103 | #endif |
115 | struct wlr_wl_shell_surface *wlr_wl_shell_surface; | ||
116 | }; | 104 | }; |
117 | 105 | ||
118 | struct { | 106 | struct { |
119 | struct wl_signal unmap; | 107 | struct wl_signal unmap; |
120 | } events; | 108 | } events; |
121 | 109 | ||
122 | struct wl_listener surface_new_subsurface; | ||
123 | |||
124 | int max_render_time; // In milliseconds | 110 | int max_render_time; // In milliseconds |
125 | 111 | ||
126 | enum seat_config_shortcuts_inhibit shortcuts_inhibit; | 112 | enum seat_config_shortcuts_inhibit shortcuts_inhibit; |
@@ -145,6 +131,8 @@ struct sway_xdg_shell_view { | |||
145 | struct sway_xwayland_view { | 131 | struct sway_xwayland_view { |
146 | struct sway_view view; | 132 | struct sway_view view; |
147 | 133 | ||
134 | struct wlr_scene_tree *surface_tree; | ||
135 | |||
148 | struct wl_listener commit; | 136 | struct wl_listener commit; |
149 | struct wl_listener request_move; | 137 | struct wl_listener request_move; |
150 | struct wl_listener request_resize; | 138 | struct wl_listener request_resize; |
@@ -156,71 +144,55 @@ struct sway_xwayland_view { | |||
156 | struct wl_listener set_title; | 144 | struct wl_listener set_title; |
157 | struct wl_listener set_class; | 145 | struct wl_listener set_class; |
158 | struct wl_listener set_role; | 146 | struct wl_listener set_role; |
147 | struct wl_listener set_startup_id; | ||
159 | struct wl_listener set_window_type; | 148 | struct wl_listener set_window_type; |
160 | struct wl_listener set_hints; | 149 | struct wl_listener set_hints; |
161 | struct wl_listener set_decorations; | 150 | struct wl_listener set_decorations; |
151 | struct wl_listener associate; | ||
152 | struct wl_listener dissociate; | ||
162 | struct wl_listener map; | 153 | struct wl_listener map; |
163 | struct wl_listener unmap; | 154 | struct wl_listener unmap; |
164 | struct wl_listener destroy; | 155 | struct wl_listener destroy; |
165 | struct wl_listener override_redirect; | 156 | struct wl_listener override_redirect; |
157 | |||
158 | struct wl_listener surface_tree_destroy; | ||
166 | }; | 159 | }; |
167 | 160 | ||
168 | struct sway_xwayland_unmanaged { | 161 | struct sway_xwayland_unmanaged { |
169 | struct wlr_xwayland_surface *wlr_xwayland_surface; | 162 | struct wlr_xwayland_surface *wlr_xwayland_surface; |
170 | struct wl_list link; | ||
171 | 163 | ||
172 | int lx, ly; | 164 | struct wlr_scene_surface *surface_scene; |
173 | 165 | ||
166 | struct wl_listener request_activate; | ||
174 | struct wl_listener request_configure; | 167 | struct wl_listener request_configure; |
175 | struct wl_listener request_fullscreen; | 168 | struct wl_listener request_fullscreen; |
176 | struct wl_listener commit; | ||
177 | struct wl_listener set_geometry; | 169 | struct wl_listener set_geometry; |
170 | struct wl_listener associate; | ||
171 | struct wl_listener dissociate; | ||
178 | struct wl_listener map; | 172 | struct wl_listener map; |
179 | struct wl_listener unmap; | 173 | struct wl_listener unmap; |
180 | struct wl_listener destroy; | 174 | struct wl_listener destroy; |
181 | struct wl_listener override_redirect; | 175 | struct wl_listener override_redirect; |
182 | }; | 176 | }; |
183 | #endif | 177 | #endif |
184 | struct sway_view_child; | ||
185 | |||
186 | struct sway_view_child_impl { | ||
187 | void (*get_root_coords)(struct sway_view_child *child, int *sx, int *sy); | ||
188 | void (*destroy)(struct sway_view_child *child); | ||
189 | }; | ||
190 | |||
191 | /** | ||
192 | * A view child is a surface in the view tree, such as a subsurface or a popup. | ||
193 | */ | ||
194 | struct sway_view_child { | ||
195 | const struct sway_view_child_impl *impl; | ||
196 | struct wl_list link; | ||
197 | 178 | ||
179 | struct sway_popup_desc { | ||
180 | struct wlr_scene_node *relative; | ||
198 | struct sway_view *view; | 181 | struct sway_view *view; |
199 | struct sway_view_child *parent; | ||
200 | struct wl_list children; // sway_view_child::link | ||
201 | struct wlr_surface *surface; | ||
202 | bool mapped; | ||
203 | |||
204 | struct wl_listener surface_commit; | ||
205 | struct wl_listener surface_new_subsurface; | ||
206 | struct wl_listener surface_map; | ||
207 | struct wl_listener surface_unmap; | ||
208 | struct wl_listener surface_destroy; | ||
209 | struct wl_listener view_unmap; | ||
210 | }; | ||
211 | |||
212 | struct sway_subsurface { | ||
213 | struct sway_view_child child; | ||
214 | |||
215 | struct wl_listener destroy; | ||
216 | }; | 182 | }; |
217 | 183 | ||
218 | struct sway_xdg_popup { | 184 | struct sway_xdg_popup { |
219 | struct sway_view_child child; | 185 | struct sway_view *view; |
186 | |||
187 | struct wlr_scene_tree *scene_tree; | ||
188 | struct wlr_scene_tree *xdg_surface_tree; | ||
189 | struct wlr_xdg_popup *wlr_xdg_popup; | ||
220 | 190 | ||
221 | struct wlr_xdg_surface *wlr_xdg_surface; | 191 | struct sway_popup_desc desc; |
222 | 192 | ||
193 | struct wl_listener surface_commit; | ||
223 | struct wl_listener new_popup; | 194 | struct wl_listener new_popup; |
195 | struct wl_listener reposition; | ||
224 | struct wl_listener destroy; | 196 | struct wl_listener destroy; |
225 | }; | 197 | }; |
226 | 198 | ||
@@ -269,7 +241,12 @@ void view_set_activated(struct sway_view *view, bool activated); | |||
269 | /** | 241 | /** |
270 | * Called when the view requests to be focused. | 242 | * Called when the view requests to be focused. |
271 | */ | 243 | */ |
272 | void view_request_activate(struct sway_view *view); | 244 | void view_request_activate(struct sway_view *view, struct sway_seat *seat); |
245 | |||
246 | /* | ||
247 | * Called when the view requests urgent state | ||
248 | */ | ||
249 | void view_request_urgent(struct sway_view *view); | ||
273 | 250 | ||
274 | /** | 251 | /** |
275 | * If possible, instructs the client to change their decoration mode. | 252 | * If possible, instructs the client to change their decoration mode. |
@@ -288,42 +265,31 @@ void view_close(struct sway_view *view); | |||
288 | 265 | ||
289 | void view_close_popups(struct sway_view *view); | 266 | void view_close_popups(struct sway_view *view); |
290 | 267 | ||
291 | void view_damage_from(struct sway_view *view); | ||
292 | |||
293 | /** | ||
294 | * Iterate all surfaces of a view (toplevels + popups). | ||
295 | */ | ||
296 | void view_for_each_surface(struct sway_view *view, | ||
297 | wlr_surface_iterator_func_t iterator, void *user_data); | ||
298 | |||
299 | /** | ||
300 | * Iterate all popup surfaces of a view. | ||
301 | */ | ||
302 | void view_for_each_popup_surface(struct sway_view *view, | ||
303 | wlr_surface_iterator_func_t iterator, void *user_data); | ||
304 | |||
305 | // view implementation | 268 | // view implementation |
306 | 269 | ||
307 | void view_init(struct sway_view *view, enum sway_view_type type, | 270 | bool view_init(struct sway_view *view, enum sway_view_type type, |
308 | const struct sway_view_impl *impl); | 271 | const struct sway_view_impl *impl); |
309 | 272 | ||
310 | void view_destroy(struct sway_view *view); | 273 | void view_destroy(struct sway_view *view); |
311 | 274 | ||
312 | void view_begin_destroy(struct sway_view *view); | 275 | void view_begin_destroy(struct sway_view *view); |
313 | 276 | ||
277 | /** | ||
278 | * Map a view, ie. make it visible in the tree. | ||
279 | * | ||
280 | * `fullscreen` should be set to true (and optionally `fullscreen_output` | ||
281 | * should be populated) if the view should be made fullscreen immediately. | ||
282 | * | ||
283 | * `decoration` should be set to true if the client prefers CSD. The client's | ||
284 | * preference may be ignored. | ||
285 | */ | ||
314 | void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, | 286 | void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, |
315 | bool fullscreen, struct wlr_output *fullscreen_output, bool decoration); | 287 | bool fullscreen, struct wlr_output *fullscreen_output, bool decoration); |
316 | 288 | ||
317 | void view_unmap(struct sway_view *view); | 289 | void view_unmap(struct sway_view *view); |
318 | 290 | ||
319 | void view_update_size(struct sway_view *view, int width, int height); | 291 | void view_update_size(struct sway_view *view); |
320 | 292 | void view_center_and_clip_surface(struct sway_view *view); | |
321 | void 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 | |||
325 | void view_child_destroy(struct sway_view_child *child); | ||
326 | |||
327 | 293 | ||
328 | struct sway_view *view_from_wlr_xdg_surface( | 294 | struct sway_view *view_from_wlr_xdg_surface( |
329 | struct wlr_xdg_surface *xdg_surface); | 295 | struct wlr_xdg_surface *xdg_surface); |
@@ -333,6 +299,8 @@ struct sway_view *view_from_wlr_xwayland_surface( | |||
333 | #endif | 299 | #endif |
334 | struct sway_view *view_from_wlr_surface(struct wlr_surface *surface); | 300 | struct sway_view *view_from_wlr_surface(struct wlr_surface *surface); |
335 | 301 | ||
302 | void view_update_app_id(struct sway_view *view); | ||
303 | |||
336 | /** | 304 | /** |
337 | * Re-read the view's title property and update any relevant title bars. | 305 | * Re-read the view's title property and update any relevant title bars. |
338 | * The force argument makes it recreate the title bars even if the title hasn't | 306 | * The force argument makes it recreate the title bars even if the title hasn't |
@@ -362,4 +330,8 @@ void view_save_buffer(struct sway_view *view); | |||
362 | 330 | ||
363 | bool view_is_transient_for(struct sway_view *child, struct sway_view *ancestor); | 331 | bool view_is_transient_for(struct sway_view *child, struct sway_view *ancestor); |
364 | 332 | ||
333 | void view_assign_ctx(struct sway_view *view, struct launcher_ctx *ctx); | ||
334 | |||
335 | void view_send_frame_done(struct sway_view *view); | ||
336 | |||
365 | #endif | 337 | #endif |
diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index fdd92f64..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 | ||
23 | struct sway_workspace { | 25 | struct 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; |
@@ -60,20 +68,20 @@ void workspace_consider_destroy(struct sway_workspace *ws); | |||
60 | 68 | ||
61 | char *workspace_next_name(const char *output_name); | 69 | char *workspace_next_name(const char *output_name); |
62 | 70 | ||
63 | bool workspace_switch(struct sway_workspace *workspace, | 71 | struct sway_workspace *workspace_auto_back_and_forth( |
64 | bool no_auto_back_and_forth); | 72 | struct sway_workspace *workspace); |
73 | |||
74 | bool workspace_switch(struct sway_workspace *workspace); | ||
65 | 75 | ||
66 | struct sway_workspace *workspace_by_number(const char* name); | 76 | struct sway_workspace *workspace_by_number(const char* name); |
67 | 77 | ||
68 | struct sway_workspace *workspace_by_name(const char*); | 78 | struct sway_workspace *workspace_by_name(const char*); |
69 | 79 | ||
70 | struct sway_workspace *workspace_output_next( | 80 | struct sway_workspace *workspace_output_next(struct sway_workspace *current); |
71 | struct sway_workspace *current, bool create); | ||
72 | 81 | ||
73 | struct sway_workspace *workspace_next(struct sway_workspace *current); | 82 | struct sway_workspace *workspace_next(struct sway_workspace *current); |
74 | 83 | ||
75 | struct sway_workspace *workspace_output_prev( | 84 | struct sway_workspace *workspace_output_prev(struct sway_workspace *current); |
76 | struct sway_workspace *current, bool create); | ||
77 | 85 | ||
78 | struct sway_workspace *workspace_prev(struct sway_workspace *current); | 86 | struct sway_workspace *workspace_prev(struct sway_workspace *current); |
79 | 87 | ||
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 { | |||
16 | struct sway_xdg_decoration *xdg_decoration_from_surface( | 16 | struct sway_xdg_decoration *xdg_decoration_from_surface( |
17 | struct wlr_surface *surface); | 17 | struct wlr_surface *surface); |
18 | 18 | ||
19 | void set_xdg_decoration_mode(struct sway_xdg_decoration *deco); | ||
20 | |||
19 | #endif | 21 | #endif |
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 545a66a8..197d2190 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include "config.h" | 4 | #include "config.h" |
5 | #include "input.h" | 5 | #include "input.h" |
6 | #include "pool-buffer.h" | 6 | #include "pool-buffer.h" |
7 | #include "cursor-shape-v1-client-protocol.h" | ||
7 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" | 8 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" |
8 | #include "xdg-output-unstable-v1-client-protocol.h" | 9 | #include "xdg-output-unstable-v1-client-protocol.h" |
9 | 10 | ||
@@ -30,6 +31,7 @@ struct swaybar { | |||
30 | struct wl_compositor *compositor; | 31 | struct wl_compositor *compositor; |
31 | struct zwlr_layer_shell_v1 *layer_shell; | 32 | struct zwlr_layer_shell_v1 *layer_shell; |
32 | struct zxdg_output_manager_v1 *xdg_output_manager; | 33 | struct zxdg_output_manager_v1 *xdg_output_manager; |
34 | struct wp_cursor_shape_manager_v1 *cursor_shape_manager; | ||
33 | struct wl_shm *shm; | 35 | struct wl_shm *shm; |
34 | 36 | ||
35 | struct swaybar_config *config; | 37 | struct swaybar_config *config; |
@@ -58,7 +60,6 @@ struct swaybar_output { | |||
58 | struct zxdg_output_v1 *xdg_output; | 60 | struct zxdg_output_v1 *xdg_output; |
59 | struct wl_surface *surface; | 61 | struct wl_surface *surface; |
60 | struct zwlr_layer_surface_v1 *layer_surface; | 62 | struct zwlr_layer_surface_v1 *layer_surface; |
61 | struct wl_region *input_region; | ||
62 | uint32_t wl_name; | 63 | uint32_t wl_name; |
63 | 64 | ||
64 | struct wl_list workspaces; // swaybar_workspace::link | 65 | 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..dced2a6c 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; |
@@ -29,6 +30,6 @@ void i3bar_block_unref(struct i3bar_block *block); | |||
29 | bool i3bar_handle_readable(struct status_line *status); | 30 | bool i3bar_handle_readable(struct status_line *status); |
30 | enum hotspot_event_handling i3bar_block_send_click(struct status_line *status, | 31 | enum hotspot_event_handling i3bar_block_send_click(struct status_line *status, |
31 | struct i3bar_block *block, double x, double y, double rx, double ry, | 32 | struct i3bar_block *block, double x, double y, double rx, double ry, |
32 | double w, double h, int scale, uint32_t button); | 33 | double w, double h, int scale, uint32_t button, bool released); |
33 | 34 | ||
34 | #endif | 35 | #endif |
diff --git a/include/swaybar/image.h b/include/swaybar/image.h new file mode 100644 index 00000000..53a210dd --- /dev/null +++ b/include/swaybar/image.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef _SWAYBAR_IMAGE_H | ||
2 | #define _SWAYBAR_IMAGE_H | ||
3 | #include <cairo.h> | ||
4 | |||
5 | cairo_surface_t *load_image(const char *path); | ||
6 | |||
7 | #endif | ||
diff --git a/include/swaybar/input.h b/include/swaybar/input.h index e8735d88..8ea88a69 100644 --- a/include/swaybar/input.h +++ b/include/swaybar/input.h | |||
@@ -49,7 +49,7 @@ struct swaybar_hotspot { | |||
49 | int x, y, width, height; | 49 | int x, y, width, height; |
50 | enum hotspot_event_handling (*callback)(struct swaybar_output *output, | 50 | enum hotspot_event_handling (*callback)(struct swaybar_output *output, |
51 | struct swaybar_hotspot *hotspot, double x, double y, uint32_t button, | 51 | struct swaybar_hotspot *hotspot, double x, double y, uint32_t button, |
52 | void *data); | 52 | bool released, void *data); |
53 | void (*destroy)(void *data); | 53 | void (*destroy)(void *data); |
54 | void *data; | 54 | void *data; |
55 | }; | 55 | }; |
diff --git a/include/swaybar/tray/item.h b/include/swaybar/tray/item.h index c02a5582..73937a0c 100644 --- a/include/swaybar/tray/item.h +++ b/include/swaybar/tray/item.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <cairo.h> | 4 | #include <cairo.h> |
5 | #include <stdbool.h> | 5 | #include <stdbool.h> |
6 | #include <stdint.h> | 6 | #include <stdint.h> |
7 | #include <wayland-util.h> | ||
7 | #include "swaybar/tray/tray.h" | 8 | #include "swaybar/tray/tray.h" |
8 | #include "list.h" | 9 | #include "list.h" |
9 | 10 | ||
diff --git a/include/swaynag/swaynag.h b/include/swaynag/swaynag.h index 9e39e716..fb9e9c21 100644 --- a/include/swaynag/swaynag.h +++ b/include/swaynag/swaynag.h | |||
@@ -4,8 +4,9 @@ | |||
4 | #include <strings.h> | 4 | #include <strings.h> |
5 | #include "list.h" | 5 | #include "list.h" |
6 | #include "pool-buffer.h" | 6 | #include "pool-buffer.h" |
7 | #include "cursor-shape-v1-client-protocol.h" | ||
8 | |||
7 | #include "swaynag/types.h" | 9 | #include "swaynag/types.h" |
8 | #include "xdg-output-unstable-v1-client-protocol.h" | ||
9 | 10 | ||
10 | #define SWAYNAG_MAX_HEIGHT 500 | 11 | #define SWAYNAG_MAX_HEIGHT 500 |
11 | 12 | ||
@@ -59,6 +60,7 @@ struct swaynag_button { | |||
59 | struct swaynag_details { | 60 | struct swaynag_details { |
60 | bool visible; | 61 | bool visible; |
61 | char *message; | 62 | char *message; |
63 | char *details_text; | ||
62 | 64 | ||
63 | int x; | 65 | int x; |
64 | int y; | 66 | int y; |
@@ -75,18 +77,17 @@ struct swaynag_details { | |||
75 | 77 | ||
76 | struct swaynag { | 78 | struct swaynag { |
77 | bool run_display; | 79 | bool run_display; |
78 | int querying_outputs; | ||
79 | 80 | ||
80 | struct wl_display *display; | 81 | struct wl_display *display; |
81 | struct wl_compositor *compositor; | 82 | struct wl_compositor *compositor; |
82 | struct wl_seat *seat; | 83 | struct wl_seat *seat; |
83 | struct wl_shm *shm; | 84 | struct wl_shm *shm; |
84 | struct zxdg_output_manager_v1 *xdg_output_manager; | ||
85 | struct wl_list outputs; // swaynag_output::link | 85 | struct wl_list outputs; // swaynag_output::link |
86 | struct wl_list seats; // swaynag_seat::link | 86 | struct wl_list seats; // swaynag_seat::link |
87 | struct swaynag_output *output; | 87 | struct swaynag_output *output; |
88 | struct zwlr_layer_shell_v1 *layer_shell; | 88 | struct zwlr_layer_shell_v1 *layer_shell; |
89 | struct zwlr_layer_surface_v1 *layer_surface; | 89 | struct zwlr_layer_surface_v1 *layer_surface; |
90 | struct wp_cursor_shape_manager_v1 *cursor_shape_manager; | ||
90 | struct wl_surface *surface; | 91 | struct wl_surface *surface; |
91 | 92 | ||
92 | uint32_t width; | 93 | uint32_t width; |
diff --git a/include/swaynag/types.h b/include/swaynag/types.h index 24da9418..9c3c50db 100644 --- a/include/swaynag/types.h +++ b/include/swaynag/types.h | |||
@@ -1,12 +1,17 @@ | |||
1 | #ifndef _SWAYNAG_TYPES_H | 1 | #ifndef _SWAYNAG_TYPES_H |
2 | #define _SWAYNAG_TYPES_H | 2 | #define _SWAYNAG_TYPES_H |
3 | 3 | ||
4 | #include <stdint.h> | ||
5 | #include <pango/pangocairo.h> | ||
6 | #include "list.h" | ||
7 | |||
4 | struct swaynag_type { | 8 | struct swaynag_type { |
5 | char *name; | 9 | char *name; |
6 | 10 | ||
7 | char *font; | 11 | PangoFontDescription *font_description; |
8 | char *output; | 12 | char *output; |
9 | uint32_t anchors; | 13 | uint32_t anchors; |
14 | int32_t layer; // enum zwlr_layer_shell_v1_layer or -1 if unset | ||
10 | 15 | ||
11 | // Colors | 16 | // Colors |
12 | uint32_t button_text; | 17 | 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); |