diff options
Diffstat (limited to 'include/sway')
-rw-r--r-- | include/sway/border.h | 28 | ||||
-rw-r--r-- | include/sway/commands.h | 64 | ||||
-rw-r--r-- | include/sway/config.h | 320 | ||||
-rw-r--r-- | include/sway/container.h | 312 | ||||
-rw-r--r-- | include/sway/criteria.h | 36 | ||||
-rw-r--r-- | include/sway/extensions.h | 49 | ||||
-rw-r--r-- | include/sway/focus.h | 43 | ||||
-rw-r--r-- | include/sway/handlers.h | 11 | ||||
-rw-r--r-- | include/sway/input.h | 23 | ||||
-rw-r--r-- | include/sway/input_state.h | 102 | ||||
-rw-r--r-- | include/sway/ipc-json.h | 14 | ||||
-rw-r--r-- | include/sway/ipc-server.h | 41 | ||||
-rw-r--r-- | include/sway/layout.h | 78 | ||||
-rw-r--r-- | include/sway/output.h | 24 | ||||
-rw-r--r-- | include/sway/resize.h | 14 | ||||
-rw-r--r-- | include/sway/workspace.h | 22 |
16 files changed, 1181 insertions, 0 deletions
diff --git a/include/sway/border.h b/include/sway/border.h new file mode 100644 index 00000000..c30c9da3 --- /dev/null +++ b/include/sway/border.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef _SWAY_BORDER_H | ||
2 | #define _SWAY_BORDER_H | ||
3 | #include <wlc/wlc.h> | ||
4 | #include "container.h" | ||
5 | |||
6 | /** | ||
7 | * Border pixel buffer and corresponding geometry. | ||
8 | */ | ||
9 | struct border { | ||
10 | unsigned char *buffer; | ||
11 | struct wlc_geometry geometry; | ||
12 | }; | ||
13 | |||
14 | /** | ||
15 | * Clear border buffer. | ||
16 | */ | ||
17 | void border_clear(struct border *border); | ||
18 | |||
19 | /** | ||
20 | * Recursively update all of the borders within a container. | ||
21 | */ | ||
22 | void update_container_border(swayc_t *container); | ||
23 | |||
24 | void render_view_borders(wlc_handle view); | ||
25 | int get_font_text_height(const char *font); | ||
26 | bool should_hide_top_border(swayc_t *con, double y); | ||
27 | |||
28 | #endif | ||
diff --git a/include/sway/commands.h b/include/sway/commands.h new file mode 100644 index 00000000..cd0610f4 --- /dev/null +++ b/include/sway/commands.h | |||
@@ -0,0 +1,64 @@ | |||
1 | #ifndef _SWAY_COMMANDS_H | ||
2 | #define _SWAY_COMMANDS_H | ||
3 | #include <stdbool.h> | ||
4 | #include <json-c/json.h> | ||
5 | #include <wlc/wlc.h> | ||
6 | #include "config.h" | ||
7 | |||
8 | /** | ||
9 | * Indicates the result of a command's execution. | ||
10 | */ | ||
11 | enum cmd_status { | ||
12 | CMD_SUCCESS, /**< The command was successful */ | ||
13 | CMD_FAILURE, /**< The command resulted in an error */ | ||
14 | CMD_INVALID, /**< Unknown command or parser error */ | ||
15 | CMD_DEFER, /**< Command execution deferred */ | ||
16 | // Config Blocks | ||
17 | CMD_BLOCK_END, | ||
18 | CMD_BLOCK_MODE, | ||
19 | CMD_BLOCK_BAR, | ||
20 | CMD_BLOCK_BAR_COLORS, | ||
21 | CMD_BLOCK_INPUT | ||
22 | }; | ||
23 | |||
24 | /** | ||
25 | * Stores the result of executing a command. | ||
26 | */ | ||
27 | struct cmd_results { | ||
28 | enum cmd_status status; | ||
29 | char *input; | ||
30 | /** | ||
31 | * Human friendly error message, or NULL on success | ||
32 | */ | ||
33 | char *error; | ||
34 | }; | ||
35 | |||
36 | /** | ||
37 | * Parse and handles a command. | ||
38 | */ | ||
39 | struct cmd_results *handle_command(char *command); | ||
40 | /** | ||
41 | * Parse and handles a command during config file loading. | ||
42 | * | ||
43 | * Do not use this under normal conditions. | ||
44 | */ | ||
45 | struct cmd_results *config_command(char *command, enum cmd_status block); | ||
46 | |||
47 | /** | ||
48 | * Allocates a cmd_results object. | ||
49 | */ | ||
50 | struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, const char *error, ...); | ||
51 | /** | ||
52 | * Frees a cmd_results object. | ||
53 | */ | ||
54 | void free_cmd_results(struct cmd_results *results); | ||
55 | /** | ||
56 | * Serializes cmd_results to a JSON string. | ||
57 | * | ||
58 | * Free the JSON string later on. | ||
59 | */ | ||
60 | const char *cmd_results_to_json(struct cmd_results *results); | ||
61 | |||
62 | void remove_view_from_scratchpad(swayc_t *); | ||
63 | |||
64 | #endif | ||
diff --git a/include/sway/config.h b/include/sway/config.h new file mode 100644 index 00000000..56deaf01 --- /dev/null +++ b/include/sway/config.h | |||
@@ -0,0 +1,320 @@ | |||
1 | #ifndef _SWAY_CONFIG_H | ||
2 | #define _SWAY_CONFIG_H | ||
3 | |||
4 | #define PID_WORKSPACE_TIMEOUT 60 | ||
5 | |||
6 | #include <libinput.h> | ||
7 | #include <stdint.h> | ||
8 | #include <wlc/geometry.h> | ||
9 | #include <wlc/wlc.h> | ||
10 | #include <xkbcommon/xkbcommon.h> | ||
11 | #include <time.h> | ||
12 | #include "wayland-desktop-shell-server-protocol.h" | ||
13 | #include "list.h" | ||
14 | #include "layout.h" | ||
15 | #include "container.h" | ||
16 | |||
17 | /** | ||
18 | * Describes a variable created via the `set` command. | ||
19 | */ | ||
20 | struct sway_variable { | ||
21 | char *name; | ||
22 | char *value; | ||
23 | }; | ||
24 | |||
25 | /** | ||
26 | * A key binding and an associated command. | ||
27 | */ | ||
28 | struct sway_binding { | ||
29 | int order; | ||
30 | bool release; | ||
31 | bool bindcode; | ||
32 | list_t *keys; | ||
33 | uint32_t modifiers; | ||
34 | char *command; | ||
35 | }; | ||
36 | |||
37 | /** | ||
38 | * A mouse binding and an associated command. | ||
39 | */ | ||
40 | struct sway_mouse_binding { | ||
41 | uint32_t button; | ||
42 | char *command; | ||
43 | }; | ||
44 | |||
45 | /** | ||
46 | * A "mode" of keybindings created via the `mode` command. | ||
47 | */ | ||
48 | struct sway_mode { | ||
49 | char *name; | ||
50 | list_t *bindings; | ||
51 | }; | ||
52 | |||
53 | /** | ||
54 | * libinput options for input devices | ||
55 | */ | ||
56 | struct input_config { | ||
57 | char *identifier; | ||
58 | |||
59 | int accel_profile; | ||
60 | int click_method; | ||
61 | int drag_lock; | ||
62 | int dwt; | ||
63 | int middle_emulation; | ||
64 | int natural_scroll; | ||
65 | float pointer_accel; | ||
66 | int scroll_method; | ||
67 | int send_events; | ||
68 | int tap; | ||
69 | |||
70 | bool capturable; | ||
71 | struct wlc_geometry region; | ||
72 | }; | ||
73 | |||
74 | /** | ||
75 | * Size and position configuration for a particular output. | ||
76 | * | ||
77 | * This is set via the `output` command. | ||
78 | */ | ||
79 | struct output_config { | ||
80 | char *name; | ||
81 | int enabled; | ||
82 | int width, height; | ||
83 | int x, y; | ||
84 | int scale; | ||
85 | char *background; | ||
86 | char *background_option; | ||
87 | }; | ||
88 | |||
89 | /** | ||
90 | * Maps a workspace name to an output name. | ||
91 | * | ||
92 | * Set via `workspace <x> output <y>` | ||
93 | */ | ||
94 | struct workspace_output { | ||
95 | char *output; | ||
96 | char *workspace; | ||
97 | }; | ||
98 | |||
99 | struct pid_workspace { | ||
100 | pid_t *pid; | ||
101 | char *workspace; | ||
102 | time_t *time_added; | ||
103 | }; | ||
104 | |||
105 | void pid_workspace_add(struct pid_workspace *pw); | ||
106 | void free_pid_workspace(struct pid_workspace *pw); | ||
107 | |||
108 | struct bar_config { | ||
109 | /** | ||
110 | * One of "dock", "hide", "invisible" | ||
111 | * | ||
112 | * Always visible in dock mode. Visible only when modifier key is held in hide mode. | ||
113 | * Never visible in invisible mode. | ||
114 | */ | ||
115 | char *mode; | ||
116 | /** | ||
117 | * One of "show" or "hide". | ||
118 | * | ||
119 | * In "show" mode, it will always be shown on top of the active workspace. | ||
120 | */ | ||
121 | char *hidden_state; | ||
122 | /** | ||
123 | * Id name used to identify the bar through IPC. | ||
124 | * | ||
125 | * Defaults to bar-x, where x corresponds to the position of the | ||
126 | * embedding bar block in the config file (bar-0, bar-1, ...). | ||
127 | */ | ||
128 | char *id; | ||
129 | uint32_t modifier; | ||
130 | list_t *outputs; | ||
131 | enum desktop_shell_panel_position position; | ||
132 | list_t *bindings; | ||
133 | char *status_command; | ||
134 | bool pango_markup; | ||
135 | char *swaybar_command; | ||
136 | char *font; | ||
137 | int height; // -1 not defined | ||
138 | int tray_padding; | ||
139 | bool workspace_buttons; | ||
140 | bool wrap_scroll; | ||
141 | char *separator_symbol; | ||
142 | bool strip_workspace_numbers; | ||
143 | bool binding_mode_indicator; | ||
144 | bool verbose; | ||
145 | pid_t pid; | ||
146 | struct { | ||
147 | char background[10]; | ||
148 | char statusline[10]; | ||
149 | char separator[10]; | ||
150 | char focused_workspace_border[10]; | ||
151 | char focused_workspace_bg[10]; | ||
152 | char focused_workspace_text[10]; | ||
153 | char active_workspace_border[10]; | ||
154 | char active_workspace_bg[10]; | ||
155 | char active_workspace_text[10]; | ||
156 | char inactive_workspace_border[10]; | ||
157 | char inactive_workspace_bg[10]; | ||
158 | char inactive_workspace_text[10]; | ||
159 | char urgent_workspace_border[10]; | ||
160 | char urgent_workspace_bg[10]; | ||
161 | char urgent_workspace_text[10]; | ||
162 | char binding_mode_border[10]; | ||
163 | char binding_mode_bg[10]; | ||
164 | char binding_mode_text[10]; | ||
165 | } colors; | ||
166 | }; | ||
167 | |||
168 | struct border_colors { | ||
169 | uint32_t border; | ||
170 | uint32_t background; | ||
171 | uint32_t text; | ||
172 | uint32_t indicator; | ||
173 | uint32_t child_border; | ||
174 | }; | ||
175 | |||
176 | enum edge_border_types { | ||
177 | E_NONE, /**< Don't hide edge borders */ | ||
178 | E_VERTICAL, /**< hide vertical edge borders */ | ||
179 | E_HORIZONTAL, /**< hide horizontal edge borders */ | ||
180 | E_BOTH /**< hide vertical and horizontal edge borders */ | ||
181 | }; | ||
182 | |||
183 | /** | ||
184 | * The configuration struct. The result of loading a config file. | ||
185 | */ | ||
186 | struct sway_config { | ||
187 | list_t *symbols; | ||
188 | list_t *modes; | ||
189 | list_t *bars; | ||
190 | list_t *cmd_queue; | ||
191 | list_t *workspace_outputs; | ||
192 | list_t *pid_workspaces; | ||
193 | list_t *output_configs; | ||
194 | list_t *input_configs; | ||
195 | list_t *criteria; | ||
196 | list_t *active_bar_modifiers; | ||
197 | struct sway_mode *current_mode; | ||
198 | struct bar_config *current_bar; | ||
199 | uint32_t floating_mod; | ||
200 | uint32_t dragging_key; | ||
201 | uint32_t resizing_key; | ||
202 | char *floating_scroll_up_cmd; | ||
203 | char *floating_scroll_down_cmd; | ||
204 | char *floating_scroll_left_cmd; | ||
205 | char *floating_scroll_right_cmd; | ||
206 | enum swayc_layouts default_orientation; | ||
207 | enum swayc_layouts default_layout; | ||
208 | char *font; | ||
209 | int font_height; | ||
210 | |||
211 | // Flags | ||
212 | bool focus_follows_mouse; | ||
213 | bool mouse_warping; | ||
214 | bool active; | ||
215 | bool failed; | ||
216 | bool reloading; | ||
217 | bool reading; | ||
218 | bool auto_back_and_forth; | ||
219 | bool seamless_mouse; | ||
220 | |||
221 | bool edge_gaps; | ||
222 | bool smart_gaps; | ||
223 | int gaps_inner; | ||
224 | int gaps_outer; | ||
225 | |||
226 | list_t *config_chain; | ||
227 | const char *current_config; | ||
228 | |||
229 | enum swayc_border_types border; | ||
230 | enum swayc_border_types floating_border; | ||
231 | int border_thickness; | ||
232 | int floating_border_thickness; | ||
233 | enum edge_border_types hide_edge_borders; | ||
234 | |||
235 | // border colors | ||
236 | struct { | ||
237 | struct border_colors focused; | ||
238 | struct border_colors focused_inactive; | ||
239 | struct border_colors unfocused; | ||
240 | struct border_colors urgent; | ||
241 | struct border_colors placeholder; | ||
242 | uint32_t background; | ||
243 | } border_colors; | ||
244 | |||
245 | // floating view | ||
246 | int32_t floating_maximum_width; | ||
247 | int32_t floating_maximum_height; | ||
248 | int32_t floating_minimum_width; | ||
249 | int32_t floating_minimum_height; | ||
250 | }; | ||
251 | |||
252 | /** | ||
253 | * Loads the main config from the given path. is_active should be true when | ||
254 | * reloading the config. | ||
255 | */ | ||
256 | bool load_main_config(const char *path, bool is_active); | ||
257 | |||
258 | /** | ||
259 | * Loads an included config. Can only be used after load_main_config. | ||
260 | */ | ||
261 | bool load_include_configs(const char *path, struct sway_config *config); | ||
262 | |||
263 | /** | ||
264 | * Reads the config from the given FILE. | ||
265 | */ | ||
266 | bool read_config(FILE *file, struct sway_config *config); | ||
267 | |||
268 | /** | ||
269 | * Free config struct | ||
270 | */ | ||
271 | void free_config(struct sway_config *config); | ||
272 | /** | ||
273 | * Does variable replacement for a string based on the config's currently loaded variables. | ||
274 | */ | ||
275 | char *do_var_replacement(char *str); | ||
276 | |||
277 | int input_identifier_cmp(const void *item, const void *data); | ||
278 | void merge_input_config(struct input_config *dst, struct input_config *src); | ||
279 | void apply_input_config(struct input_config *ic, struct libinput_device *dev); | ||
280 | void free_input_config(struct input_config *ic); | ||
281 | |||
282 | int output_name_cmp(const void *item, const void *data); | ||
283 | void merge_output_config(struct output_config *dst, struct output_config *src); | ||
284 | /** Sets up a WLC output handle based on a given output_config. | ||
285 | */ | ||
286 | void apply_output_config(struct output_config *oc, swayc_t *output); | ||
287 | void free_output_config(struct output_config *oc); | ||
288 | |||
289 | /** | ||
290 | * Updates the list of active bar modifiers | ||
291 | */ | ||
292 | void update_active_bar_modifiers(void); | ||
293 | |||
294 | int workspace_output_cmp_workspace(const void *a, const void *b); | ||
295 | |||
296 | int sway_binding_cmp(const void *a, const void *b); | ||
297 | int sway_binding_cmp_qsort(const void *a, const void *b); | ||
298 | int sway_binding_cmp_keys(const void *a, const void *b); | ||
299 | void free_sway_binding(struct sway_binding *sb); | ||
300 | struct sway_binding *sway_binding_dup(struct sway_binding *sb); | ||
301 | |||
302 | int sway_mouse_binding_cmp(const void *a, const void *b); | ||
303 | int sway_mouse_binding_cmp_qsort(const void *a, const void *b); | ||
304 | int sway_mouse_binding_cmp_buttons(const void *a, const void *b); | ||
305 | void free_sway_mouse_binding(struct sway_mouse_binding *smb); | ||
306 | |||
307 | void load_swaybars(); | ||
308 | void terminate_swaybg(pid_t pid); | ||
309 | |||
310 | /** | ||
311 | * Allocate and initialize default bar configuration. | ||
312 | */ | ||
313 | struct bar_config *default_bar_config(void); | ||
314 | |||
315 | /** | ||
316 | * Global config singleton. | ||
317 | */ | ||
318 | extern struct sway_config *config; | ||
319 | |||
320 | #endif | ||
diff --git a/include/sway/container.h b/include/sway/container.h new file mode 100644 index 00000000..4dd7f3a0 --- /dev/null +++ b/include/sway/container.h | |||
@@ -0,0 +1,312 @@ | |||
1 | #ifndef _SWAY_CONTAINER_H | ||
2 | #define _SWAY_CONTAINER_H | ||
3 | #include <sys/types.h> | ||
4 | #include <wlc/wlc.h> | ||
5 | |||
6 | #include "list.h" | ||
7 | |||
8 | typedef struct sway_container swayc_t; | ||
9 | |||
10 | extern swayc_t root_container; | ||
11 | |||
12 | /** | ||
13 | * Different kinds of containers. | ||
14 | * | ||
15 | * This enum is in order. A container will never be inside of a container below | ||
16 | * it on this list. | ||
17 | */ | ||
18 | enum swayc_types { | ||
19 | C_ROOT, /**< The root container. Only one of these ever exists. */ | ||
20 | C_OUTPUT, /**< An output (aka monitor, head, etc). */ | ||
21 | C_WORKSPACE, /**< A workspace. */ | ||
22 | C_CONTAINER, /**< A manually created container. */ | ||
23 | C_VIEW, /**< A view (aka window). */ | ||
24 | // Keep last | ||
25 | C_TYPES, | ||
26 | }; | ||
27 | |||
28 | /** | ||
29 | * Different ways to arrange a container. | ||
30 | */ | ||
31 | enum swayc_layouts { | ||
32 | L_NONE, /**< Used for containers that have no layout (views, root) */ | ||
33 | L_HORIZ, | ||
34 | L_VERT, | ||
35 | L_STACKED, | ||
36 | L_TABBED, | ||
37 | L_FLOATING, /**< A psuedo-container, removed from the tree, to hold floating windows */ | ||
38 | // Keep last | ||
39 | L_LAYOUTS, | ||
40 | }; | ||
41 | |||
42 | enum swayc_border_types { | ||
43 | B_NONE, /**< No border */ | ||
44 | B_PIXEL, /**< 1px border */ | ||
45 | B_NORMAL /**< Normal border with title bar */ | ||
46 | }; | ||
47 | |||
48 | /** | ||
49 | * Stores information about a container. | ||
50 | * | ||
51 | * The tree is made of these. Views are containers that cannot have children. | ||
52 | */ | ||
53 | struct sway_container { | ||
54 | /** | ||
55 | * If this container maps to a WLC object, this is set to that object's | ||
56 | * handle. Otherwise, NULL. | ||
57 | */ | ||
58 | wlc_handle handle; | ||
59 | |||
60 | enum swayc_types type; | ||
61 | enum swayc_layouts layout; | ||
62 | enum swayc_layouts prev_layout; | ||
63 | |||
64 | /** | ||
65 | * Width and height of this container, without borders or gaps. | ||
66 | */ | ||
67 | double width, height; | ||
68 | |||
69 | /** | ||
70 | * Views may request geometry, which is stored in this and ignored until | ||
71 | * the views are floated. | ||
72 | */ | ||
73 | int desired_width, desired_height; | ||
74 | |||
75 | /** | ||
76 | * The coordinates that this view appear at, relative to the output they | ||
77 | * are located on (output containers have absolute coordinates). | ||
78 | */ | ||
79 | double x, y; | ||
80 | |||
81 | /** | ||
82 | * Cached geometry used to store view/container geometry when switching | ||
83 | * between tabbed/stacked and horizontal/vertical layouts. | ||
84 | */ | ||
85 | struct wlc_geometry cached_geometry; | ||
86 | |||
87 | /** | ||
88 | * False if this view is invisible. It could be in the scratchpad or on a | ||
89 | * workspace that is not shown. | ||
90 | */ | ||
91 | bool visible; | ||
92 | bool is_floating; | ||
93 | bool is_focused; | ||
94 | bool sticky; // floating view always visible on its output | ||
95 | |||
96 | // Attributes that mostly views have. | ||
97 | char *name; | ||
98 | char *class; | ||
99 | char *app_id; | ||
100 | |||
101 | // Used by output containers to keep track of swaybg child processes. | ||
102 | pid_t bg_pid; | ||
103 | |||
104 | int gaps; | ||
105 | |||
106 | list_t *children; | ||
107 | /** | ||
108 | * Children of this container that are floated. | ||
109 | */ | ||
110 | list_t *floating; | ||
111 | /** | ||
112 | * Unmanaged view handles in this container. | ||
113 | */ | ||
114 | list_t *unmanaged; | ||
115 | |||
116 | /** | ||
117 | * The parent of this container. NULL for the root container. | ||
118 | */ | ||
119 | struct sway_container *parent; | ||
120 | /** | ||
121 | * Which of this container's children has focus. | ||
122 | */ | ||
123 | struct sway_container *focused; | ||
124 | /** | ||
125 | * If this container's children include a fullscreen view, this is that view. | ||
126 | */ | ||
127 | struct sway_container *fullscreen; | ||
128 | /** | ||
129 | * If this container is a view, this may be set to the window's decoration | ||
130 | * buffer (or NULL). | ||
131 | */ | ||
132 | struct border *border; | ||
133 | enum swayc_border_types border_type; | ||
134 | struct wlc_geometry border_geometry; | ||
135 | struct wlc_geometry title_bar_geometry; | ||
136 | struct wlc_geometry actual_geometry; | ||
137 | int border_thickness; | ||
138 | }; | ||
139 | |||
140 | enum visibility_mask { | ||
141 | VISIBLE = true | ||
142 | } visible; | ||
143 | |||
144 | /** | ||
145 | * Allocates a new output container. | ||
146 | */ | ||
147 | swayc_t *new_output(wlc_handle handle); | ||
148 | /** | ||
149 | * Allocates a new workspace container. | ||
150 | */ | ||
151 | swayc_t *new_workspace(swayc_t *output, const char *name); | ||
152 | /** | ||
153 | * Allocates a new container and places a child into it. | ||
154 | * | ||
155 | * This is used from the split command, which creates a new container with the | ||
156 | * requested layout and replaces the focused container in the tree with the new | ||
157 | * one. Then the removed container is added as a child of the new container. | ||
158 | */ | ||
159 | swayc_t *new_container(swayc_t *child, enum swayc_layouts layout); | ||
160 | /** | ||
161 | * Allocates a new view container. | ||
162 | * | ||
163 | * Pass in a sibling view, or a workspace to become this container's parent. | ||
164 | */ | ||
165 | swayc_t *new_view(swayc_t *sibling, wlc_handle handle); | ||
166 | /** | ||
167 | * Allocates a new floating view in the active workspace. | ||
168 | */ | ||
169 | swayc_t *new_floating_view(wlc_handle handle); | ||
170 | |||
171 | void floating_view_sane_size(swayc_t *view); | ||
172 | |||
173 | /** | ||
174 | * Frees an output's container. | ||
175 | */ | ||
176 | swayc_t *destroy_output(swayc_t *output); | ||
177 | /** | ||
178 | * Destroys a workspace container and returns the parent pointer, or NULL. | ||
179 | */ | ||
180 | swayc_t *destroy_workspace(swayc_t *workspace); | ||
181 | /** | ||
182 | * Destroys a container and all empty parents. Returns the topmost non-empty | ||
183 | * parent container, or NULL. | ||
184 | */ | ||
185 | swayc_t *destroy_container(swayc_t *container); | ||
186 | /** | ||
187 | * Destroys a view container and all empty parents. Returns the topmost | ||
188 | * non-empty parent container, or NULL. | ||
189 | */ | ||
190 | swayc_t *destroy_view(swayc_t *view); | ||
191 | |||
192 | /** | ||
193 | * Finds a container based on test criteria. Returns the first container that | ||
194 | * passes the test. | ||
195 | */ | ||
196 | swayc_t *swayc_by_test(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data); | ||
197 | /** | ||
198 | * Finds a parent container with the given swayc_type. | ||
199 | */ | ||
200 | swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types); | ||
201 | /** | ||
202 | * Finds a parent with the given swayc_layout. | ||
203 | */ | ||
204 | swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts); | ||
205 | /** | ||
206 | * Finds the bottom-most focused container of a type. | ||
207 | */ | ||
208 | swayc_t *swayc_focus_by_type(swayc_t *container, enum swayc_types); | ||
209 | /** | ||
210 | * Finds the bottom-most focused container of a layout. | ||
211 | */ | ||
212 | swayc_t *swayc_focus_by_layout(swayc_t *container, enum swayc_layouts); | ||
213 | |||
214 | /** | ||
215 | * Gets the swayc_t associated with a wlc_handle. | ||
216 | */ | ||
217 | swayc_t *swayc_by_handle(wlc_handle handle); | ||
218 | /** | ||
219 | * Gets the named swayc_t. | ||
220 | */ | ||
221 | swayc_t *swayc_by_name(const char *name); | ||
222 | /** | ||
223 | * Gets the active output's container. | ||
224 | */ | ||
225 | swayc_t *swayc_active_output(void); | ||
226 | /** | ||
227 | * Gets the active workspace's container. | ||
228 | */ | ||
229 | swayc_t *swayc_active_workspace(void); | ||
230 | /** | ||
231 | * Gets the workspace for the given view container. | ||
232 | */ | ||
233 | swayc_t *swayc_active_workspace_for(swayc_t *view); | ||
234 | /** | ||
235 | * Finds the container currently underneath the pointer. | ||
236 | */ | ||
237 | swayc_t *container_under_pointer(void); | ||
238 | |||
239 | /** | ||
240 | * Returns true if a container is fullscreen. | ||
241 | */ | ||
242 | bool swayc_is_fullscreen(swayc_t *view); | ||
243 | /** | ||
244 | * Returns true if this view is focused. | ||
245 | */ | ||
246 | bool swayc_is_active(swayc_t *view); | ||
247 | /** | ||
248 | * Returns true if the parent is an ancestor of the child. | ||
249 | */ | ||
250 | bool swayc_is_parent_of(swayc_t *parent, swayc_t *child); | ||
251 | /** | ||
252 | * Returns true if the child is a desecendant of the parent. | ||
253 | */ | ||
254 | bool swayc_is_child_of(swayc_t *child, swayc_t *parent); | ||
255 | |||
256 | /** | ||
257 | * Returns true if this container is an empty workspace. | ||
258 | */ | ||
259 | bool swayc_is_empty_workspace(swayc_t *container); | ||
260 | |||
261 | /** | ||
262 | * Returns the top most tabbed or stacked parent container. Returns NULL if | ||
263 | * view is not in a tabbed/stacked layout. | ||
264 | */ | ||
265 | swayc_t *swayc_tabbed_stacked_ancestor(swayc_t *view); | ||
266 | |||
267 | /** | ||
268 | * Returns the immediate tabbed or stacked parent container. Returns NULL if | ||
269 | * view is not directly in a tabbed/stacked layout. | ||
270 | */ | ||
271 | swayc_t *swayc_tabbed_stacked_parent(swayc_t *view); | ||
272 | |||
273 | /** | ||
274 | * Returns the gap (padding) of the container. | ||
275 | * | ||
276 | * This returns the inner gaps for a view, the outer gaps for a workspace, and | ||
277 | * 0 otherwise. | ||
278 | */ | ||
279 | int swayc_gap(swayc_t *container); | ||
280 | |||
281 | /** | ||
282 | * Maps a container's children over a function. | ||
283 | */ | ||
284 | void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *); | ||
285 | |||
286 | /** | ||
287 | * Set a view as visible or invisible. | ||
288 | * | ||
289 | * This will perform the required wlc calls as well; it is not sufficient to | ||
290 | * simply toggle the boolean in swayc_t. | ||
291 | */ | ||
292 | void set_view_visibility(swayc_t *view, void *data); | ||
293 | /** | ||
294 | * Set the gaps value for a view. | ||
295 | */ | ||
296 | void set_gaps(swayc_t *view, void *amount); | ||
297 | /** | ||
298 | * Add to the gaps value for a view. | ||
299 | */ | ||
300 | void add_gaps(swayc_t *view, void *amount); | ||
301 | |||
302 | /** | ||
303 | * Issue wlc calls to make the visibility of a container consistent. | ||
304 | */ | ||
305 | void update_visibility(swayc_t *container); | ||
306 | |||
307 | /** | ||
308 | * Close all child views of container | ||
309 | */ | ||
310 | void close_views(swayc_t *container); | ||
311 | |||
312 | #endif | ||
diff --git a/include/sway/criteria.h b/include/sway/criteria.h new file mode 100644 index 00000000..5c71d172 --- /dev/null +++ b/include/sway/criteria.h | |||
@@ -0,0 +1,36 @@ | |||
1 | #ifndef _SWAY_CRITERIA_H | ||
2 | #define _SWAY_CRITERIA_H | ||
3 | |||
4 | #include "container.h" | ||
5 | #include "list.h" | ||
6 | |||
7 | /** | ||
8 | * Maps criteria (as a list of criteria tokens) to a command list. | ||
9 | * | ||
10 | * A list of tokens together represent a single criteria string (e.g. | ||
11 | * '[class="abc" title="xyz"]' becomes two criteria tokens). | ||
12 | * | ||
13 | * for_window: Views matching all criteria will have the bound command list | ||
14 | * executed on them. | ||
15 | * | ||
16 | * Set via `for_window <criteria> <cmd list>`. | ||
17 | */ | ||
18 | struct criteria { | ||
19 | list_t *tokens; // struct crit_token, contains compiled regex. | ||
20 | char *crit_raw; // entire criteria string (for logging) | ||
21 | |||
22 | char *cmdlist; | ||
23 | }; | ||
24 | |||
25 | int criteria_cmp(const void *item, const void *data); | ||
26 | void free_criteria(struct criteria *crit); | ||
27 | |||
28 | // Pouplate list with crit_tokens extracted from criteria string, returns error | ||
29 | // string or NULL if successful. | ||
30 | char *extract_crit_tokens(list_t *tokens, const char *criteria); | ||
31 | |||
32 | // Returns list of criteria that match given container. These criteria have | ||
33 | // been set with `for_window` commands and have an associated cmdlist. | ||
34 | list_t *criteria_for(swayc_t *cont); | ||
35 | |||
36 | #endif | ||
diff --git a/include/sway/extensions.h b/include/sway/extensions.h new file mode 100644 index 00000000..f6b0c00e --- /dev/null +++ b/include/sway/extensions.h | |||
@@ -0,0 +1,49 @@ | |||
1 | #ifndef _SWAY_EXTENSIONS_H | ||
2 | #define _SWAY_EXTENSIONS_H | ||
3 | |||
4 | #include <wayland-server.h> | ||
5 | #include <wlc/wlc-wayland.h> | ||
6 | #include "wayland-desktop-shell-server-protocol.h" | ||
7 | #include "list.h" | ||
8 | |||
9 | struct background_config { | ||
10 | wlc_handle output; | ||
11 | wlc_resource surface; | ||
12 | // we need the wl_resource of the surface in the destructor | ||
13 | struct wl_resource *wl_surface_res; | ||
14 | struct wl_client *client; | ||
15 | wlc_handle handle; | ||
16 | }; | ||
17 | |||
18 | struct panel_config { | ||
19 | // wayland resource used in callbacks, is used to track this panel | ||
20 | struct wl_resource *wl_resource; | ||
21 | wlc_handle output; | ||
22 | wlc_resource surface; | ||
23 | // we need the wl_resource of the surface in the destructor | ||
24 | struct wl_resource *wl_surface_res; | ||
25 | enum desktop_shell_panel_position panel_position; | ||
26 | // used to determine if client is a panel | ||
27 | struct wl_client *client; | ||
28 | // wlc handle for this panel's surface, not set until panel is created | ||
29 | wlc_handle handle; | ||
30 | }; | ||
31 | |||
32 | struct desktop_shell_state { | ||
33 | list_t *backgrounds; | ||
34 | list_t *panels; | ||
35 | list_t *lock_surfaces; | ||
36 | bool is_locked; | ||
37 | }; | ||
38 | |||
39 | struct swaylock_state { | ||
40 | bool active; | ||
41 | wlc_handle output; | ||
42 | wlc_resource surface; | ||
43 | }; | ||
44 | |||
45 | extern struct desktop_shell_state desktop_shell; | ||
46 | |||
47 | void register_extensions(void); | ||
48 | |||
49 | #endif | ||
diff --git a/include/sway/focus.h b/include/sway/focus.h new file mode 100644 index 00000000..b532edc2 --- /dev/null +++ b/include/sway/focus.h | |||
@@ -0,0 +1,43 @@ | |||
1 | #ifndef _SWAY_FOCUS_H | ||
2 | #define _SWAY_FOCUS_H | ||
3 | enum movement_direction { | ||
4 | MOVE_LEFT, | ||
5 | MOVE_RIGHT, | ||
6 | MOVE_UP, | ||
7 | MOVE_DOWN, | ||
8 | MOVE_PARENT, | ||
9 | MOVE_CHILD | ||
10 | }; | ||
11 | |||
12 | #include "container.h" | ||
13 | |||
14 | // focused_container - the container found by following the `focused` pointer | ||
15 | // from a given container to a container with `is_focused` boolean set | ||
16 | // --- | ||
17 | // focused_view - the container found by following the `focused` pointer from a | ||
18 | // given container to a view. | ||
19 | // --- | ||
20 | |||
21 | swayc_t *get_focused_container(swayc_t *parent); | ||
22 | swayc_t *get_focused_view(swayc_t *parent); | ||
23 | swayc_t *get_focused_float(swayc_t *ws); | ||
24 | |||
25 | // a special-case function to get the focused view, regardless | ||
26 | // of whether it's tiled or floating | ||
27 | swayc_t *get_focused_view_include_floating(swayc_t *parent); | ||
28 | |||
29 | bool set_focused_container(swayc_t *container); | ||
30 | bool set_focused_container_for(swayc_t *ancestor, swayc_t *container); | ||
31 | |||
32 | // lock focused container/view. locked by windows with OVERRIDE attribute | ||
33 | // and unlocked when they are destroyed | ||
34 | |||
35 | extern bool locked_container_focus; | ||
36 | |||
37 | // Prevents wss from being destroyed on focus switch | ||
38 | extern bool suspend_workspace_cleanup; | ||
39 | |||
40 | bool move_focus(enum movement_direction direction); | ||
41 | |||
42 | #endif | ||
43 | |||
diff --git a/include/sway/handlers.h b/include/sway/handlers.h new file mode 100644 index 00000000..956b98f4 --- /dev/null +++ b/include/sway/handlers.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifndef _SWAY_HANDLERS_H | ||
2 | #define _SWAY_HANDLERS_H | ||
3 | #include "container.h" | ||
4 | #include <stdbool.h> | ||
5 | #include <wlc/wlc.h> | ||
6 | |||
7 | void register_wlc_handlers(); | ||
8 | |||
9 | extern uint32_t keys_pressed[32]; | ||
10 | |||
11 | #endif | ||
diff --git a/include/sway/input.h b/include/sway/input.h new file mode 100644 index 00000000..4ed9bffe --- /dev/null +++ b/include/sway/input.h | |||
@@ -0,0 +1,23 @@ | |||
1 | #ifndef _SWAY_INPUT_H | ||
2 | #define _SWAY_INPUT_H | ||
3 | |||
4 | #include <libinput.h> | ||
5 | #include "config.h" | ||
6 | #include "list.h" | ||
7 | |||
8 | struct input_config *new_input_config(const char* identifier); | ||
9 | |||
10 | char* libinput_dev_unique_id(struct libinput_device *dev); | ||
11 | |||
12 | /** | ||
13 | * Global input device list. | ||
14 | */ | ||
15 | extern list_t *input_devices; | ||
16 | |||
17 | /** | ||
18 | * Pointer used when reading input blocked. | ||
19 | * Shared so that it can be cleared from commands.c when closing the block | ||
20 | */ | ||
21 | extern struct input_config *current_input_config; | ||
22 | |||
23 | #endif | ||
diff --git a/include/sway/input_state.h b/include/sway/input_state.h new file mode 100644 index 00000000..903301fb --- /dev/null +++ b/include/sway/input_state.h | |||
@@ -0,0 +1,102 @@ | |||
1 | #ifndef _SWAY_KEY_STATE_H | ||
2 | #define _SWAY_KEY_STATE_H | ||
3 | #include <stdbool.h> | ||
4 | #include <stdint.h> | ||
5 | #include "container.h" | ||
6 | |||
7 | /* Keyboard state */ | ||
8 | |||
9 | // returns true if key has been pressed, otherwise false | ||
10 | bool check_key(uint32_t key_sym, uint32_t key_code); | ||
11 | |||
12 | // returns true if key_sym matches latest released key. | ||
13 | bool check_released_key(uint32_t key_sym); | ||
14 | |||
15 | // sets a key as pressed | ||
16 | void press_key(uint32_t key_sym, uint32_t key_code); | ||
17 | |||
18 | // unsets a key as pressed | ||
19 | void release_key(uint32_t key_sym, uint32_t key_code); | ||
20 | |||
21 | |||
22 | /* Pointer state */ | ||
23 | |||
24 | enum pointer_values { | ||
25 | M_LEFT_CLICK = 272, | ||
26 | M_RIGHT_CLICK = 273, | ||
27 | M_SCROLL_CLICK = 274, | ||
28 | M_SCROLL_UP = 275, | ||
29 | M_SCROLL_DOWN = 276, | ||
30 | }; | ||
31 | |||
32 | enum pointer_mode { | ||
33 | // Target | ||
34 | M_FLOATING = 1, | ||
35 | M_TILING = 2, | ||
36 | // Action | ||
37 | M_DRAGGING = 4, | ||
38 | M_RESIZING = 8, | ||
39 | }; | ||
40 | |||
41 | struct pointer_button_state { | ||
42 | bool held; | ||
43 | // state at the point it was pressed | ||
44 | int x, y; | ||
45 | swayc_t *view; | ||
46 | }; | ||
47 | |||
48 | extern struct pointer_state { | ||
49 | // mouse clicks | ||
50 | struct pointer_button_state left; | ||
51 | struct pointer_button_state right; | ||
52 | struct pointer_button_state scroll; | ||
53 | |||
54 | // change in pointer position | ||
55 | struct { | ||
56 | int x, y; | ||
57 | } delta; | ||
58 | |||
59 | // view pointer is currently over | ||
60 | swayc_t *view; | ||
61 | |||
62 | // Pointer mode | ||
63 | int mode; | ||
64 | } pointer_state; | ||
65 | |||
66 | enum modifier_state { | ||
67 | MOD_STATE_UNCHANGED = 0, | ||
68 | MOD_STATE_PRESSED = 1, | ||
69 | MOD_STATE_RELEASED = 2 | ||
70 | }; | ||
71 | |||
72 | void pointer_position_set(struct wlc_origin *new_origin, bool force_focus); | ||
73 | void center_pointer_on(swayc_t *view); | ||
74 | |||
75 | // on button release unset mode depending on the button. | ||
76 | // on button press set mode conditionally depending on the button | ||
77 | void pointer_mode_set(uint32_t button, bool condition); | ||
78 | |||
79 | // Update mode in mouse motion | ||
80 | void pointer_mode_update(void); | ||
81 | |||
82 | // Reset mode on any keypress; | ||
83 | void pointer_mode_reset(void); | ||
84 | |||
85 | void input_init(void); | ||
86 | |||
87 | /** | ||
88 | * Check if state of mod changed from current state to new_state. | ||
89 | * | ||
90 | * Returns MOD_STATE_UNCHANGED if the state didn't change, MOD_STATE_PRESSED if | ||
91 | * the state changed to pressed and MOD_STATE_RELEASED if the state changed to | ||
92 | * released. | ||
93 | */ | ||
94 | uint32_t modifier_state_changed(uint32_t new_state, uint32_t mod); | ||
95 | |||
96 | /** | ||
97 | * Update the current modifiers state to new_state. | ||
98 | */ | ||
99 | void modifiers_state_update(uint32_t new_state); | ||
100 | |||
101 | #endif | ||
102 | |||
diff --git a/include/sway/ipc-json.h b/include/sway/ipc-json.h new file mode 100644 index 00000000..02b07a23 --- /dev/null +++ b/include/sway/ipc-json.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef _SWAY_IPC_JSON_H | ||
2 | #define _SWAY_IPC_JSON_H | ||
3 | |||
4 | #include <json-c/json.h> | ||
5 | #include "config.h" | ||
6 | #include "container.h" | ||
7 | |||
8 | json_object *ipc_json_get_version(); | ||
9 | json_object *ipc_json_describe_bar_config(struct bar_config *bar); | ||
10 | json_object *ipc_json_describe_container(swayc_t *c); | ||
11 | json_object *ipc_json_describe_container_recursive(swayc_t *c); | ||
12 | json_object *ipc_json_describe_window(swayc_t *c); | ||
13 | |||
14 | #endif | ||
diff --git a/include/sway/ipc-server.h b/include/sway/ipc-server.h new file mode 100644 index 00000000..1d199134 --- /dev/null +++ b/include/sway/ipc-server.h | |||
@@ -0,0 +1,41 @@ | |||
1 | #ifndef _SWAY_IPC_SERVER_H | ||
2 | #define _SWAY_IPC_SERVER_H | ||
3 | |||
4 | #include <wlc/wlc.h> | ||
5 | |||
6 | #include "container.h" | ||
7 | #include "config.h" | ||
8 | #include "ipc.h" | ||
9 | |||
10 | void ipc_init(void); | ||
11 | void ipc_terminate(void); | ||
12 | struct sockaddr_un *ipc_user_sockaddr(void); | ||
13 | |||
14 | void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change); | ||
15 | void ipc_event_barconfig_update(struct bar_config *bar); | ||
16 | /** | ||
17 | * Send IPC mode event to all listening clients | ||
18 | */ | ||
19 | void ipc_event_mode(const char *mode); | ||
20 | /** | ||
21 | * Send IPC window change event | ||
22 | */ | ||
23 | void ipc_event_window(swayc_t *window, const char *change); | ||
24 | /** | ||
25 | * Sends an IPC modifier event to all listening clients. The modifier event | ||
26 | * includes a key 'change' with the value of state and a key 'modifier' with | ||
27 | * the name of that modifier. | ||
28 | */ | ||
29 | void ipc_event_modifier(uint32_t modifier, const char *state); | ||
30 | /** | ||
31 | * Send IPC keyboard binding event. | ||
32 | */ | ||
33 | void ipc_event_binding_keyboard(struct sway_binding *sb); | ||
34 | const char *swayc_type_string(enum swayc_types type); | ||
35 | |||
36 | /** | ||
37 | * Send pixel data to registered clients. | ||
38 | */ | ||
39 | void ipc_get_pixels(wlc_handle output); | ||
40 | |||
41 | #endif | ||
diff --git a/include/sway/layout.h b/include/sway/layout.h new file mode 100644 index 00000000..b982365c --- /dev/null +++ b/include/sway/layout.h | |||
@@ -0,0 +1,78 @@ | |||
1 | #ifndef _SWAY_LAYOUT_H | ||
2 | #define _SWAY_LAYOUT_H | ||
3 | |||
4 | #include <wlc/wlc.h> | ||
5 | #include "log.h" | ||
6 | #include "list.h" | ||
7 | #include "container.h" | ||
8 | #include "focus.h" | ||
9 | |||
10 | extern list_t *scratchpad; | ||
11 | |||
12 | extern int min_sane_w; | ||
13 | extern int min_sane_h; | ||
14 | |||
15 | // Set initial values for root_container | ||
16 | void init_layout(void); | ||
17 | |||
18 | // Returns the index of child for its parent | ||
19 | int index_child(const swayc_t *child); | ||
20 | |||
21 | // Adds child to parent, if parent has no focus, it is set to child | ||
22 | // parent must be of type C_WORKSPACE or C_CONTAINER | ||
23 | void add_child(swayc_t *parent, swayc_t *child); | ||
24 | |||
25 | // Adds child to parent at index, if parent has no focus, it is set to child | ||
26 | // parent must be of type C_WORKSPACE or C_CONTAINER | ||
27 | void insert_child(swayc_t *parent, swayc_t *child, int index); | ||
28 | |||
29 | // Adds child as floating window to ws, if there is no focus it is set to child. | ||
30 | // ws must be of type C_WORKSPACE | ||
31 | void add_floating(swayc_t *ws, swayc_t *child); | ||
32 | |||
33 | // insert child after sibling in parents children. | ||
34 | swayc_t *add_sibling(swayc_t *sibling, swayc_t *child); | ||
35 | |||
36 | // Replace child with new_child in parents children | ||
37 | // new_child will inherit childs geometry, childs geometry will be reset | ||
38 | // if parents focus is on child, it will be changed to new_child | ||
39 | swayc_t *replace_child(swayc_t *child, swayc_t *new_child); | ||
40 | |||
41 | // Remove child from its parent, if focus is on child, focus will be changed to | ||
42 | // a sibling, or to a floating window, or NULL | ||
43 | swayc_t *remove_child(swayc_t *child); | ||
44 | |||
45 | // 2 containers are swapped, they inherit eachothers focus | ||
46 | void swap_container(swayc_t *a, swayc_t *b); | ||
47 | |||
48 | // 2 Containers geometry are swapped, used with `swap_container` | ||
49 | void swap_geometry(swayc_t *a, swayc_t *b); | ||
50 | |||
51 | void move_container(swayc_t* container, enum movement_direction direction); | ||
52 | void move_container_to(swayc_t* container, swayc_t* destination); | ||
53 | void move_workspace_to(swayc_t* workspace, swayc_t* destination); | ||
54 | |||
55 | // Layout | ||
56 | /** | ||
57 | * Update child container geometries when switching between layouts. | ||
58 | */ | ||
59 | void update_layout_geometry(swayc_t *parent, enum swayc_layouts prev_layout); | ||
60 | void update_geometry(swayc_t *view); | ||
61 | void arrange_windows(swayc_t *container, double width, double height); | ||
62 | void arrange_backgrounds(void); | ||
63 | |||
64 | swayc_t *get_focused_container(swayc_t *parent); | ||
65 | swayc_t *get_swayc_in_direction(swayc_t *container, enum movement_direction dir); | ||
66 | swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_direction dir, swayc_t *limit); | ||
67 | |||
68 | void recursive_resize(swayc_t *container, double amount, enum wlc_resize_edge edge); | ||
69 | |||
70 | void layout_log(const swayc_t *c, int depth); | ||
71 | void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, ...) __attribute__((format(printf,3,4))); | ||
72 | |||
73 | /** | ||
74 | * Get default layout. | ||
75 | */ | ||
76 | enum swayc_layouts default_layout(swayc_t *output); | ||
77 | |||
78 | #endif | ||
diff --git a/include/sway/output.h b/include/sway/output.h new file mode 100644 index 00000000..e8afd5ed --- /dev/null +++ b/include/sway/output.h | |||
@@ -0,0 +1,24 @@ | |||
1 | #ifndef _SWAY_OUTPUT_H | ||
2 | #define _SWAY_OUTPUT_H | ||
3 | |||
4 | #include "container.h" | ||
5 | #include "focus.h" | ||
6 | |||
7 | // Position is absolute coordinates on the edge where the adjacent output | ||
8 | // should be searched for. | ||
9 | swayc_t *output_by_name(const char* name, const struct wlc_point *abs_pos); | ||
10 | swayc_t *swayc_adjacent_output(swayc_t *output, enum movement_direction dir, const struct wlc_point *abs_pos, bool pick_closest); | ||
11 | |||
12 | // Place absolute coordinates for given container into given wlc_point. | ||
13 | void get_absolute_position(swayc_t *container, struct wlc_point *point); | ||
14 | |||
15 | // Place absolute coordinates for the center point of given container into | ||
16 | // given wlc_point. | ||
17 | void get_absolute_center_position(swayc_t *container, struct wlc_point *point); | ||
18 | |||
19 | // stable sort workspaces on this output | ||
20 | void sort_workspaces(swayc_t *output); | ||
21 | |||
22 | void output_get_scaled_size(wlc_handle handle, struct wlc_size *size); | ||
23 | |||
24 | #endif | ||
diff --git a/include/sway/resize.h b/include/sway/resize.h new file mode 100644 index 00000000..0d382994 --- /dev/null +++ b/include/sway/resize.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef _SWAY_RESIZE_H | ||
2 | #define _SWAY_RESIZE_H | ||
3 | #include <stdbool.h> | ||
4 | |||
5 | enum resize_dim_types { | ||
6 | RESIZE_DIM_PX, | ||
7 | RESIZE_DIM_PPT, | ||
8 | RESIZE_DIM_DEFAULT, | ||
9 | }; | ||
10 | |||
11 | bool set_size(int dimension, bool use_width); | ||
12 | bool resize(int dimension, bool use_width, enum resize_dim_types dim_type); | ||
13 | |||
14 | #endif | ||
diff --git a/include/sway/workspace.h b/include/sway/workspace.h new file mode 100644 index 00000000..c268fafa --- /dev/null +++ b/include/sway/workspace.h | |||
@@ -0,0 +1,22 @@ | |||
1 | #ifndef _SWAY_WORKSPACE_H | ||
2 | #define _SWAY_WORKSPACE_H | ||
3 | |||
4 | #include <wlc/wlc.h> | ||
5 | #include <unistd.h> | ||
6 | #include "list.h" | ||
7 | #include "layout.h" | ||
8 | |||
9 | extern char *prev_workspace_name; | ||
10 | |||
11 | char *workspace_next_name(const char *output_name); | ||
12 | swayc_t *workspace_create(const char*); | ||
13 | swayc_t *workspace_by_name(const char*); | ||
14 | swayc_t *workspace_by_number(const char*); | ||
15 | bool workspace_switch(swayc_t*); | ||
16 | swayc_t *workspace_output_next(); | ||
17 | swayc_t *workspace_next(); | ||
18 | swayc_t *workspace_output_prev(); | ||
19 | swayc_t *workspace_prev(); | ||
20 | swayc_t *workspace_for_pid(pid_t pid); | ||
21 | |||
22 | #endif | ||