aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/old/border.h28
-rw-r--r--include/sway/old/commands.h214
-rw-r--r--include/sway/old/config.h406
-rw-r--r--include/sway/old/container.h362
-rw-r--r--include/sway/old/criteria.h42
-rw-r--r--include/sway/old/focus.h45
-rw-r--r--include/sway/old/input.h24
-rw-r--r--include/sway/old/input_state.h102
-rw-r--r--include/sway/old/ipc-json.h15
-rw-r--r--include/sway/old/ipc-server.h33
-rw-r--r--include/sway/old/layout.h85
-rw-r--r--include/sway/old/output.h36
-rw-r--r--include/sway/old/workspace.h22
13 files changed, 0 insertions, 1414 deletions
diff --git a/include/sway/old/border.h b/include/sway/old/border.h
deleted file mode 100644
index c30c9da3..00000000
--- a/include/sway/old/border.h
+++ /dev/null
@@ -1,28 +0,0 @@
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 */
9struct border {
10 unsigned char *buffer;
11 struct wlc_geometry geometry;
12};
13
14/**
15 * Clear border buffer.
16 */
17void border_clear(struct border *border);
18
19/**
20 * Recursively update all of the borders within a container.
21 */
22void update_container_border(swayc_t *container);
23
24void render_view_borders(wlc_handle view);
25int get_font_text_height(const char *font);
26bool should_hide_top_border(swayc_t *con, double y);
27
28#endif
diff --git a/include/sway/old/commands.h b/include/sway/old/commands.h
deleted file mode 100644
index 660da2c2..00000000
--- a/include/sway/old/commands.h
+++ /dev/null
@@ -1,214 +0,0 @@
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// Container that a called command should act upon. Only valid in command functions.
9extern swayc_t *current_container;
10
11/**
12 * Indicates the result of a command's execution.
13 */
14enum cmd_status {
15 CMD_SUCCESS, /**< The command was successful */
16 CMD_FAILURE, /**< The command resulted in an error */
17 CMD_INVALID, /**< Unknown command or parser error */
18 CMD_DEFER, /**< Command execution deferred */
19 // Config Blocks
20 CMD_BLOCK_END,
21 CMD_BLOCK_MODE,
22 CMD_BLOCK_BAR,
23 CMD_BLOCK_BAR_COLORS,
24 CMD_BLOCK_INPUT,
25 CMD_BLOCK_COMMANDS,
26 CMD_BLOCK_IPC,
27 CMD_BLOCK_IPC_EVENTS,
28};
29
30/**
31 * Stores the result of executing a command.
32 */
33struct cmd_results {
34 enum cmd_status status;
35 char *input;
36 /**
37 * Human friendly error message, or NULL on success
38 */
39 char *error;
40};
41
42enum expected_args {
43 EXPECTED_MORE_THAN,
44 EXPECTED_AT_LEAST,
45 EXPECTED_LESS_THAN,
46 EXPECTED_EQUAL_TO
47};
48
49struct cmd_results *checkarg(int argc, const char *name, enum expected_args type, int val);
50struct cmd_results *add_color(const char*, char*, const char*);
51void input_cmd_apply(struct input_config *input);
52void hide_view_in_scratchpad(swayc_t *sp_view);
53
54swayc_t *sp_view;
55int sp_index;
56
57/**
58 * Parse and handles a command.
59 */
60struct cmd_results *handle_command(char *command, enum command_context context);
61/**
62 * Parse and handles a command during config file loading.
63 *
64 * Do not use this under normal conditions.
65 */
66struct cmd_results *config_command(char *command, enum cmd_status block);
67/*
68 * Parses a command policy rule.
69 */
70struct cmd_results *config_commands_command(char *exec);
71
72/**
73 * Allocates a cmd_results object.
74 */
75struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, const char *error, ...);
76/**
77 * Frees a cmd_results object.
78 */
79void free_cmd_results(struct cmd_results *results);
80/**
81 * Serializes cmd_results to a JSON string.
82 *
83 * Free the JSON string later on.
84 */
85const char *cmd_results_to_json(struct cmd_results *results);
86
87void remove_view_from_scratchpad(swayc_t *);
88
89/**
90 * Actual command function signatures for individual .c files in commands/ directory.
91 */
92
93typedef struct cmd_results *sway_cmd(int argc, char **argv);
94
95sway_cmd cmd_assign;
96sway_cmd cmd_bar;
97sway_cmd cmd_bindcode;
98sway_cmd cmd_bindsym;
99sway_cmd cmd_border;
100sway_cmd cmd_client_focused;
101sway_cmd cmd_client_focused_inactive;
102sway_cmd cmd_client_unfocused;
103sway_cmd cmd_client_urgent;
104sway_cmd cmd_client_placeholder;
105sway_cmd cmd_client_background;
106sway_cmd cmd_clipboard;
107sway_cmd cmd_commands;
108sway_cmd cmd_debuglog;
109sway_cmd cmd_default_border;
110sway_cmd cmd_default_floating_border;
111sway_cmd cmd_exec;
112sway_cmd cmd_exec_always;
113sway_cmd cmd_exit;
114sway_cmd cmd_floating;
115sway_cmd cmd_floating_maximum_size;
116sway_cmd cmd_floating_minimum_size;
117sway_cmd cmd_floating_mod;
118sway_cmd cmd_floating_scroll;
119sway_cmd cmd_focus;
120sway_cmd cmd_focus_follows_mouse;
121sway_cmd cmd_font;
122sway_cmd cmd_for_window;
123sway_cmd cmd_force_focus_wrapping;
124sway_cmd cmd_fullscreen;
125sway_cmd cmd_gaps;
126sway_cmd cmd_hide_edge_borders;
127sway_cmd cmd_include;
128sway_cmd cmd_input;
129sway_cmd cmd_ipc;
130sway_cmd cmd_kill;
131sway_cmd cmd_layout;
132sway_cmd cmd_log_colors;
133sway_cmd cmd_mark;
134sway_cmd cmd_mode;
135sway_cmd cmd_mouse_warping;
136sway_cmd cmd_move;
137sway_cmd cmd_new_float;
138sway_cmd cmd_new_window;
139sway_cmd cmd_no_focus;
140sway_cmd cmd_orientation;
141sway_cmd cmd_output;
142sway_cmd cmd_permit;
143sway_cmd cmd_reject;
144sway_cmd cmd_reload;
145sway_cmd cmd_resize;
146sway_cmd cmd_scratchpad;
147sway_cmd cmd_seamless_mouse;
148sway_cmd cmd_set;
149sway_cmd cmd_show_marks;
150sway_cmd cmd_smart_gaps;
151sway_cmd cmd_split;
152sway_cmd cmd_splith;
153sway_cmd cmd_splitt;
154sway_cmd cmd_splitv;
155sway_cmd cmd_sticky;
156sway_cmd cmd_unmark;
157sway_cmd cmd_workspace;
158sway_cmd cmd_ws_auto_back_and_forth;
159sway_cmd cmd_workspace_layout;
160
161sway_cmd bar_cmd_activate_button;
162sway_cmd bar_cmd_binding_mode_indicator;
163sway_cmd bar_cmd_bindsym;
164sway_cmd bar_cmd_colors;
165sway_cmd bar_cmd_context_button;
166sway_cmd bar_cmd_font;
167sway_cmd bar_cmd_mode;
168sway_cmd bar_cmd_modifier;
169sway_cmd bar_cmd_output;
170sway_cmd bar_cmd_height;
171sway_cmd bar_cmd_hidden_state;
172sway_cmd bar_cmd_icon_theme;
173sway_cmd bar_cmd_id;
174sway_cmd bar_cmd_position;
175sway_cmd bar_cmd_secondary_button;
176sway_cmd bar_cmd_separator_symbol;
177sway_cmd bar_cmd_status_command;
178sway_cmd bar_cmd_pango_markup;
179sway_cmd bar_cmd_strip_workspace_numbers;
180sway_cmd bar_cmd_swaybar_command;
181sway_cmd bar_cmd_tray_output;
182sway_cmd bar_cmd_tray_padding;
183sway_cmd bar_cmd_wrap_scroll;
184sway_cmd bar_cmd_workspace_buttons;
185
186sway_cmd bar_colors_cmd_active_workspace;
187sway_cmd bar_colors_cmd_background;
188sway_cmd bar_colors_cmd_focused_background;
189sway_cmd bar_colors_cmd_binding_mode;
190sway_cmd bar_colors_cmd_focused_workspace;
191sway_cmd bar_colors_cmd_inactive_workspace;
192sway_cmd bar_colors_cmd_separator;
193sway_cmd bar_colors_cmd_focused_separator;
194sway_cmd bar_colors_cmd_statusline;
195sway_cmd bar_colors_cmd_focused_statusline;
196sway_cmd bar_colors_cmd_urgent_workspace;
197
198sway_cmd input_cmd_accel_profile;
199sway_cmd input_cmd_click_method;
200sway_cmd input_cmd_drag_lock;
201sway_cmd input_cmd_dwt;
202sway_cmd input_cmd_events;
203sway_cmd input_cmd_left_handed;
204sway_cmd input_cmd_middle_emulation;
205sway_cmd input_cmd_natural_scroll;
206sway_cmd input_cmd_pointer_accel;
207sway_cmd input_cmd_scroll_method;
208sway_cmd input_cmd_tap;
209
210sway_cmd cmd_ipc_cmd;
211sway_cmd cmd_ipc_events;
212sway_cmd cmd_ipc_event_cmd;
213
214#endif
diff --git a/include/sway/old/config.h b/include/sway/old/config.h
deleted file mode 100644
index a05d5ede..00000000
--- a/include/sway/old/config.h
+++ /dev/null
@@ -1,406 +0,0 @@
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 */
20struct sway_variable {
21 char *name;
22 char *value;
23};
24
25/**
26 * A key binding and an associated command.
27 */
28struct 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 */
40struct sway_mouse_binding {
41 uint32_t button;
42 char *command;
43};
44
45/**
46 * A "mode" of keybindings created via the `mode` command.
47 */
48struct sway_mode {
49 char *name;
50 list_t *bindings;
51};
52
53/**
54 * libinput options for input devices
55 */
56struct input_config {
57 char *identifier;
58
59 int accel_profile;
60 int click_method;
61 int drag_lock;
62 int dwt;
63 int left_handed;
64 int middle_emulation;
65 int natural_scroll;
66 float pointer_accel;
67 int scroll_method;
68 int send_events;
69 int tap;
70
71 bool capturable;
72 struct wlc_geometry region;
73};
74
75/**
76 * Size and position configuration for a particular output.
77 *
78 * This is set via the `output` command.
79 */
80struct output_config {
81 char *name;
82 int enabled;
83 int width, height;
84 int x, y;
85 int scale;
86 char *background;
87 char *background_option;
88};
89
90/**
91 * Maps a workspace name to an output name.
92 *
93 * Set via `workspace <x> output <y>`
94 */
95struct workspace_output {
96 char *output;
97 char *workspace;
98};
99
100struct pid_workspace {
101 pid_t *pid;
102 char *workspace;
103 time_t *time_added;
104};
105
106struct bar_config {
107 /**
108 * One of "dock", "hide", "invisible"
109 *
110 * Always visible in dock mode. Visible only when modifier key is held in hide mode.
111 * Never visible in invisible mode.
112 */
113 char *mode;
114 /**
115 * One of "show" or "hide".
116 *
117 * In "show" mode, it will always be shown on top of the active workspace.
118 */
119 char *hidden_state;
120 /**
121 * Id name used to identify the bar through IPC.
122 *
123 * Defaults to bar-x, where x corresponds to the position of the
124 * embedding bar block in the config file (bar-0, bar-1, ...).
125 */
126 char *id;
127 uint32_t modifier;
128 list_t *outputs;
129 enum desktop_shell_panel_position position;
130 list_t *bindings;
131 char *status_command;
132 bool pango_markup;
133 char *swaybar_command;
134 char *font;
135 int height; // -1 not defined
136
137#ifdef ENABLE_TRAY
138 // Tray
139 char *tray_output;
140 char *icon_theme;
141 uint32_t tray_padding;
142 uint32_t activate_button;
143 uint32_t context_button;
144 uint32_t secondary_button;
145#endif
146
147 bool workspace_buttons;
148 bool wrap_scroll;
149 char *separator_symbol;
150 bool strip_workspace_numbers;
151 bool binding_mode_indicator;
152 bool verbose;
153 pid_t pid;
154 struct {
155 char *background;
156 char *statusline;
157 char *separator;
158 char *focused_background;
159 char *focused_statusline;
160 char *focused_separator;
161 char *focused_workspace_border;
162 char *focused_workspace_bg;
163 char *focused_workspace_text;
164 char *active_workspace_border;
165 char *active_workspace_bg;
166 char *active_workspace_text;
167 char *inactive_workspace_border;
168 char *inactive_workspace_bg;
169 char *inactive_workspace_text;
170 char *urgent_workspace_border;
171 char *urgent_workspace_bg;
172 char *urgent_workspace_text;
173 char *binding_mode_border;
174 char *binding_mode_bg;
175 char *binding_mode_text;
176 } colors;
177};
178
179struct border_colors {
180 uint32_t border;
181 uint32_t background;
182 uint32_t text;
183 uint32_t indicator;
184 uint32_t child_border;
185};
186
187enum edge_border_types {
188 E_NONE, /**< Don't hide edge borders */
189 E_VERTICAL, /**< hide vertical edge borders */
190 E_HORIZONTAL, /**< hide horizontal edge borders */
191 E_BOTH, /**< hide vertical and horizontal edge borders */
192 E_SMART /**< hide both if precisely one window is present in workspace */
193};
194
195enum command_context {
196 CONTEXT_CONFIG = 1,
197 CONTEXT_BINDING = 2,
198 CONTEXT_IPC = 4,
199 CONTEXT_CRITERIA = 8,
200 CONTEXT_ALL = 0xFFFFFFFF,
201};
202
203struct command_policy {
204 char *command;
205 uint32_t context;
206};
207
208enum secure_feature {
209 FEATURE_LOCK = 1,
210 FEATURE_PANEL = 2,
211 FEATURE_BACKGROUND = 4,
212 FEATURE_SCREENSHOT = 8,
213 FEATURE_FULLSCREEN = 16,
214 FEATURE_KEYBOARD = 32,
215 FEATURE_MOUSE = 64,
216};
217
218struct feature_policy {
219 char *program;
220 uint32_t features;
221};
222
223enum ipc_feature {
224 IPC_FEATURE_COMMAND = 1,
225 IPC_FEATURE_GET_WORKSPACES = 2,
226 IPC_FEATURE_GET_OUTPUTS = 4,
227 IPC_FEATURE_GET_TREE = 8,
228 IPC_FEATURE_GET_MARKS = 16,
229 IPC_FEATURE_GET_BAR_CONFIG = 32,
230 IPC_FEATURE_GET_VERSION = 64,
231 IPC_FEATURE_GET_INPUTS = 128,
232 IPC_FEATURE_EVENT_WORKSPACE = 256,
233 IPC_FEATURE_EVENT_OUTPUT = 512,
234 IPC_FEATURE_EVENT_MODE = 1024,
235 IPC_FEATURE_EVENT_WINDOW = 2048,
236 IPC_FEATURE_EVENT_BINDING = 4096,
237 IPC_FEATURE_EVENT_INPUT = 8192,
238 IPC_FEATURE_GET_CLIPBOARD = 16384,
239
240 IPC_FEATURE_ALL_COMMANDS = 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 16384,
241 IPC_FEATURE_ALL_EVENTS = 256 | 512 | 1024 | 2048 | 4096 | 8192,
242
243 IPC_FEATURE_ALL = IPC_FEATURE_ALL_COMMANDS | IPC_FEATURE_ALL_EVENTS,
244};
245
246struct ipc_policy {
247 char *program;
248 uint32_t features;
249};
250
251/**
252 * The configuration struct. The result of loading a config file.
253 */
254struct sway_config {
255 list_t *symbols;
256 list_t *modes;
257 list_t *bars;
258 list_t *cmd_queue;
259 list_t *workspace_outputs;
260 list_t *pid_workspaces;
261 list_t *output_configs;
262 list_t *input_configs;
263 list_t *criteria;
264 list_t *no_focus;
265 list_t *active_bar_modifiers;
266 struct sway_mode *current_mode;
267 struct bar_config *current_bar;
268 uint32_t floating_mod;
269 uint32_t dragging_key;
270 uint32_t resizing_key;
271 char *floating_scroll_up_cmd;
272 char *floating_scroll_down_cmd;
273 char *floating_scroll_left_cmd;
274 char *floating_scroll_right_cmd;
275 enum swayc_layouts default_orientation;
276 enum swayc_layouts default_layout;
277 char *font;
278 int font_height;
279
280 // Flags
281 bool focus_follows_mouse;
282 bool mouse_warping;
283 bool force_focus_wrapping;
284 bool active;
285 bool failed;
286 bool reloading;
287 bool reading;
288 bool auto_back_and_forth;
289 bool seamless_mouse;
290 bool show_marks;
291
292 bool edge_gaps;
293 bool smart_gaps;
294 int gaps_inner;
295 int gaps_outer;
296
297 list_t *config_chain;
298 const char *current_config;
299
300 enum swayc_border_types border;
301 enum swayc_border_types floating_border;
302 int border_thickness;
303 int floating_border_thickness;
304 enum edge_border_types hide_edge_borders;
305
306 // border colors
307 struct {
308 struct border_colors focused;
309 struct border_colors focused_inactive;
310 struct border_colors unfocused;
311 struct border_colors urgent;
312 struct border_colors placeholder;
313 uint32_t background;
314 } border_colors;
315
316 // floating view
317 int32_t floating_maximum_width;
318 int32_t floating_maximum_height;
319 int32_t floating_minimum_width;
320 int32_t floating_minimum_height;
321
322 // Security
323 list_t *command_policies;
324 list_t *feature_policies;
325 list_t *ipc_policies;
326};
327
328void pid_workspace_add(struct pid_workspace *pw);
329void free_pid_workspace(struct pid_workspace *pw);
330
331/**
332 * Loads the main config from the given path. is_active should be true when
333 * reloading the config.
334 */
335bool load_main_config(const char *path, bool is_active);
336
337/**
338 * Loads an included config. Can only be used after load_main_config.
339 */
340bool load_include_configs(const char *path, struct sway_config *config);
341
342/**
343 * Reads the config from the given FILE.
344 */
345bool read_config(FILE *file, struct sway_config *config);
346
347/**
348 * Free config struct
349 */
350void free_config(struct sway_config *config);
351/**
352 * Does variable replacement for a string based on the config's currently loaded variables.
353 */
354char *do_var_replacement(char *str);
355
356struct cmd_results *check_security_config();
357
358int input_identifier_cmp(const void *item, const void *data);
359void merge_input_config(struct input_config *dst, struct input_config *src);
360void apply_input_config(struct input_config *ic, struct libinput_device *dev);
361void free_input_config(struct input_config *ic);
362
363int output_name_cmp(const void *item, const void *data);
364void merge_output_config(struct output_config *dst, struct output_config *src);
365/** Sets up a WLC output handle based on a given output_config.
366 */
367void apply_output_config(struct output_config *oc, swayc_t *output);
368void free_output_config(struct output_config *oc);
369
370/**
371 * Updates the list of active bar modifiers
372 */
373void update_active_bar_modifiers(void);
374
375int workspace_output_cmp_workspace(const void *a, const void *b);
376
377int sway_binding_cmp(const void *a, const void *b);
378int sway_binding_cmp_qsort(const void *a, const void *b);
379int sway_binding_cmp_keys(const void *a, const void *b);
380void free_sway_binding(struct sway_binding *sb);
381struct sway_binding *sway_binding_dup(struct sway_binding *sb);
382
383int sway_mouse_binding_cmp(const void *a, const void *b);
384int sway_mouse_binding_cmp_qsort(const void *a, const void *b);
385int sway_mouse_binding_cmp_buttons(const void *a, const void *b);
386void free_sway_mouse_binding(struct sway_mouse_binding *smb);
387
388void load_swaybars();
389void terminate_swaybg(pid_t pid);
390
391/**
392 * Allocate and initialize default bar configuration.
393 */
394struct bar_config *default_bar_config(void);
395
396/**
397 * Global config singleton.
398 */
399extern struct sway_config *config;
400
401/**
402 * Config file currently being read.
403 */
404extern const char *current_config_path;
405
406#endif
diff --git a/include/sway/old/container.h b/include/sway/old/container.h
deleted file mode 100644
index d46ffa63..00000000
--- a/include/sway/old/container.h
+++ /dev/null
@@ -1,362 +0,0 @@
1#ifndef _SWAY_CONTAINER_H
2#define _SWAY_CONTAINER_H
3#include <sys/types.h>
4#include <wlc/wlc.h>
5#include <wlr/types/wlr_output.h>
6#include <stdint.h>
7#include "list.h"
8
9typedef struct sway_container swayc_t;
10
11extern swayc_t root_container;
12extern swayc_t *current_focus;
13
14struct sway_view;
15
16/**
17 * Different kinds of containers.
18 *
19 * This enum is in order. A container will never be inside of a container below
20 * it on this list.
21 */
22enum swayc_types {
23 C_ROOT, /**< The root container. Only one of these ever exists. */
24 C_OUTPUT, /**< An output (aka monitor, head, etc). */
25 C_WORKSPACE, /**< A workspace. */
26 C_CONTAINER, /**< A manually created container. */
27 C_VIEW, /**< A view (aka window). */
28 // Keep last
29 C_TYPES,
30};
31
32/**
33 * Different ways to arrange a container.
34 */
35enum swayc_layouts {
36 L_NONE, /**< Used for containers that have no layout (views, root) */
37 L_HORIZ,
38 L_VERT,
39 L_STACKED,
40 L_TABBED,
41 L_FLOATING, /**< A psuedo-container, removed from the tree, to hold floating windows */
42
43 /* Awesome/Monad style auto layouts */
44 L_AUTO_LEFT,
45 L_AUTO_RIGHT,
46 L_AUTO_TOP,
47 L_AUTO_BOTTOM,
48
49 L_AUTO_FIRST = L_AUTO_LEFT,
50 L_AUTO_LAST = L_AUTO_BOTTOM,
51
52 // Keep last
53 L_LAYOUTS,
54};
55
56enum swayc_border_types {
57 B_NONE, /**< No border */
58 B_PIXEL, /**< 1px border */
59 B_NORMAL /**< Normal border with title bar */
60};
61
62/**
63 * Stores information about a container.
64 *
65 * The tree is made of these. Views are containers that cannot have children.
66 */
67struct sway_container {
68 // TODO WLR: reconcile these
69 wlc_handle handle;
70
71 union {
72 struct sway_output *output;
73 struct sway_view *view;
74 } _handle;
75
76 /**
77 * A unique ID to identify this container. Primarily used in the
78 * get_tree JSON output.
79 */
80 size_t id;
81
82 enum swayc_types type;
83 enum swayc_layouts layout;
84 enum swayc_layouts prev_layout;
85 enum swayc_layouts workspace_layout;
86
87 /**
88 * Width and height of this container, without borders or gaps.
89 */
90 double width, height;
91
92 /**
93 * Views may request geometry, which is stored in this and ignored until
94 * the views are floated.
95 */
96 int desired_width, desired_height;
97
98 /**
99 * The coordinates that this view appear at, relative to the output they
100 * are located on (output containers have absolute coordinates).
101 */
102 double x, y;
103
104 /**
105 * Cached geometry used to store view/container geometry when switching
106 * between tabbed/stacked and horizontal/vertical layouts.
107 */
108 struct wlc_geometry cached_geometry;
109
110 /**
111 * False if this view is invisible. It could be in the scratchpad or on a
112 * workspace that is not shown.
113 */
114 bool visible;
115 bool is_floating;
116 bool is_focused;
117 bool sticky; // floating view always visible on its output
118
119 // Attributes that mostly views have.
120 char *name;
121 char *class;
122 char *instance;
123 char *app_id;
124
125 // Used by output containers to keep track of swaybg child processes.
126 pid_t bg_pid;
127
128 int gaps;
129
130 list_t *children;
131 /**
132 * Children of this container that are floated.
133 */
134 list_t *floating;
135 /**
136 * Unmanaged view handles in this container.
137 */
138 list_t *unmanaged;
139
140 /**
141 * The parent of this container. NULL for the root container.
142 */
143 struct sway_container *parent;
144 /**
145 * Which of this container's children has focus.
146 */
147 struct sway_container *focused;
148 /**
149 * If this container's children include a fullscreen view, this is that view.
150 */
151 struct sway_container *fullscreen;
152 /**
153 * If this container is a view, this may be set to the window's decoration
154 * buffer (or NULL).
155 */
156 struct border *border;
157 enum swayc_border_types border_type;
158 struct wlc_geometry border_geometry;
159 struct wlc_geometry title_bar_geometry;
160 struct wlc_geometry actual_geometry;
161 int border_thickness;
162
163 /**
164 * Number of master views in auto layouts.
165 */
166 size_t nb_master;
167
168 /**
169 * Number of slave groups (e.g. columns) in auto layouts.
170 */
171 size_t nb_slave_groups;
172
173 /**
174 * Marks applied to the container, list_t of char*.
175 */
176 list_t *marks;
177};
178
179enum visibility_mask {
180 VISIBLE = true
181} visible;
182
183struct sway_output;
184/**
185 * Allocates a new output container.
186 */
187swayc_t *new_output(struct sway_output *sway_output);
188/**
189 * Allocates a new workspace container.
190 */
191swayc_t *new_workspace(swayc_t *output, const char *name);
192/**
193 * Allocates a new container and places a child into it.
194 *
195 * This is used from the split command, which creates a new container with the
196 * requested layout and replaces the focused container in the tree with the new
197 * one. Then the removed container is added as a child of the new container.
198 */
199swayc_t *new_container(swayc_t *child, enum swayc_layouts layout);
200/**
201 * Allocates a new view container.
202 *
203 * Pass in a sibling view, or a workspace to become this container's parent.
204 */
205swayc_t *new_view(swayc_t *sibling, struct sway_view *view);
206/**
207 * Allocates a new floating view in the active workspace.
208 */
209swayc_t *new_floating_view(wlc_handle handle);
210
211void floating_view_sane_size(swayc_t *view);
212
213/**
214 * Frees an output's container.
215 */
216swayc_t *destroy_output(swayc_t *output);
217/**
218 * Destroys a workspace container and returns the parent pointer, or NULL.
219 */
220swayc_t *destroy_workspace(swayc_t *workspace);
221/**
222 * Destroys a container and all empty parents. Returns the topmost non-empty
223 * parent container, or NULL.
224 */
225swayc_t *destroy_container(swayc_t *container);
226/**
227 * Destroys a view container and all empty parents. Returns the topmost
228 * non-empty parent container, or NULL.
229 */
230swayc_t *destroy_view(swayc_t *view);
231
232/**
233 * Finds a container based on test criteria. Returns the first container that
234 * passes the test.
235 */
236swayc_t *swayc_by_test(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data);
237/**
238 * Finds a parent container with the given swayc_type.
239 */
240swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types);
241/**
242 * Finds a parent with the given swayc_layout.
243 */
244swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts);
245/**
246 * Finds the bottom-most focused container of a type.
247 */
248swayc_t *swayc_focus_by_type(swayc_t *container, enum swayc_types);
249/**
250 * Finds the bottom-most focused container of a layout.
251 */
252swayc_t *swayc_focus_by_layout(swayc_t *container, enum swayc_layouts);
253
254/**
255 * Gets the swayc_t associated with a wlc_handle.
256 */
257swayc_t *swayc_by_handle(wlc_handle handle);
258/**
259 * Gets the named swayc_t.
260 */
261swayc_t *swayc_by_name(const char *name);
262/**
263 * Gets the active output's container.
264 */
265swayc_t *swayc_active_output(void);
266/**
267 * Gets the active workspace's container.
268 */
269swayc_t *swayc_active_workspace(void);
270/**
271 * Gets the workspace for the given view container.
272 */
273swayc_t *swayc_active_workspace_for(swayc_t *view);
274/**
275 * Finds the container currently underneath the pointer.
276 */
277swayc_t *container_under_pointer(void);
278/**
279 * Finds the first container following a callback.
280 */
281swayc_t *container_find(swayc_t *container, bool (*f)(swayc_t *, const void *), const void *data);
282
283/**
284 * Returns true if a container is fullscreen.
285 */
286bool swayc_is_fullscreen(swayc_t *view);
287/**
288 * Returns true if this view is focused.
289 */
290bool swayc_is_active(swayc_t *view);
291/**
292 * Returns true if the parent is an ancestor of the child.
293 */
294bool swayc_is_parent_of(swayc_t *parent, swayc_t *child);
295/**
296 * Returns true if the child is a desecendant of the parent.
297 */
298bool swayc_is_child_of(swayc_t *child, swayc_t *parent);
299
300/**
301 * Returns true if this container is an empty workspace.
302 */
303bool swayc_is_empty_workspace(swayc_t *container);
304
305/**
306 * Returns the top most tabbed or stacked parent container. Returns NULL if
307 * view is not in a tabbed/stacked layout.
308 */
309swayc_t *swayc_tabbed_stacked_ancestor(swayc_t *view);
310
311/**
312 * Returns the immediate tabbed or stacked parent container. Returns NULL if
313 * view is not directly in a tabbed/stacked layout.
314 */
315swayc_t *swayc_tabbed_stacked_parent(swayc_t *view);
316
317/**
318 * Returns the gap (padding) of the container.
319 *
320 * This returns the inner gaps for a view, the outer gaps for a workspace, and
321 * 0 otherwise.
322 */
323int swayc_gap(swayc_t *container);
324
325/**
326 * Maps a container's children over a function.
327 */
328void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *);
329
330/**
331 * Set a view as visible or invisible.
332 *
333 * This will perform the required wlc calls as well; it is not sufficient to
334 * simply toggle the boolean in swayc_t.
335 */
336void set_view_visibility(swayc_t *view, void *data);
337/**
338 * Set the gaps value for a view.
339 */
340void set_gaps(swayc_t *view, void *amount);
341/**
342 * Add to the gaps value for a view.
343 */
344void add_gaps(swayc_t *view, void *amount);
345
346/**
347 * Issue wlc calls to make the visibility of a container consistent.
348 */
349void update_visibility(swayc_t *container);
350
351/**
352 * Close all child views of container
353 */
354void close_views(swayc_t *container);
355
356/**
357 * Assign layout to a container. Needed due to workspace container specifics.
358 * Workspace should always have either L_VERT or L_HORIZ layout.
359 */
360swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout);
361
362#endif
diff --git a/include/sway/old/criteria.h b/include/sway/old/criteria.h
deleted file mode 100644
index c5ed9857..00000000
--- a/include/sway/old/criteria.h
+++ /dev/null
@@ -1,42 +0,0 @@
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 */
18struct 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
25int criteria_cmp(const void *item, const void *data);
26void free_criteria(struct criteria *crit);
27
28// Pouplate list with crit_tokens extracted from criteria string, returns error
29// string or NULL if successful.
30char *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.
34list_t *criteria_for(swayc_t *cont);
35
36// Returns a list of all containers that match the given list of tokens.
37list_t *container_for(list_t *tokens);
38
39// Returns true if any criteria in the given list matches this container
40bool criteria_any(swayc_t *cont, list_t *criteria);
41
42#endif
diff --git a/include/sway/old/focus.h b/include/sway/old/focus.h
deleted file mode 100644
index 652cdccc..00000000
--- a/include/sway/old/focus.h
+++ /dev/null
@@ -1,45 +0,0 @@
1#ifndef _SWAY_FOCUS_H
2#define _SWAY_FOCUS_H
3enum movement_direction {
4 MOVE_LEFT,
5 MOVE_RIGHT,
6 MOVE_UP,
7 MOVE_DOWN,
8 MOVE_PARENT,
9 MOVE_CHILD,
10 MOVE_NEXT,
11 MOVE_PREV,
12 MOVE_FIRST
13};
14
15#include "container.h"
16
17// focused_container - the container found by following the `focused` pointer
18// from a given container to a container with `is_focused` boolean set
19// ---
20// focused_view - the container found by following the `focused` pointer from a
21// given container to a view.
22// ---
23
24swayc_t *get_focused_container(swayc_t *parent);
25swayc_t *get_focused_view(swayc_t *parent);
26swayc_t *get_focused_float(swayc_t *ws);
27
28// a special-case function to get the focused view, regardless
29// of whether it's tiled or floating
30swayc_t *get_focused_view_include_floating(swayc_t *parent);
31
32bool set_focused_container(swayc_t *container);
33bool set_focused_container_for(swayc_t *ancestor, swayc_t *container);
34
35// lock focused container/view. locked by windows with OVERRIDE attribute
36// and unlocked when they are destroyed
37
38extern bool locked_container_focus;
39
40// Prevents wss from being destroyed on focus switch
41extern bool suspend_workspace_cleanup;
42
43bool move_focus(enum movement_direction direction);
44
45#endif
diff --git a/include/sway/old/input.h b/include/sway/old/input.h
deleted file mode 100644
index eb92e470..00000000
--- a/include/sway/old/input.h
+++ /dev/null
@@ -1,24 +0,0 @@
1#ifndef _SWAY_INPUT_H
2#define _SWAY_INPUT_H
3#include <libinput.h>
4#include "sway/server.h"
5#include "config.h"
6#include "list.h"
7
8struct sway_input {
9 list_t *input_devices;
10};
11
12struct input_config *new_input_config(const char* identifier);
13
14char* libinput_dev_unique_id(struct libinput_device *dev);
15
16struct sway_input *sway_input_create(struct sway_server *server);
17
18/**
19 * Pointer used when reading input blocked.
20 * Shared so that it can be cleared from commands.c when closing the block
21 */
22extern struct input_config *current_input_config;
23
24#endif
diff --git a/include/sway/old/input_state.h b/include/sway/old/input_state.h
deleted file mode 100644
index fd5a3a25..00000000
--- a/include/sway/old/input_state.h
+++ /dev/null
@@ -1,102 +0,0 @@
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
10bool check_key(uint32_t key_sym, uint32_t key_code);
11
12// returns true if key_sym matches latest released key.
13bool check_released_key(uint32_t key_sym);
14
15// sets a key as pressed
16void press_key(uint32_t key_sym, uint32_t key_code);
17
18// unsets a key as pressed
19void release_key(uint32_t key_sym, uint32_t key_code);
20
21
22/* Pointer state */
23
24enum 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
32enum pointer_mode {
33 // Target
34 M_FLOATING = 1,
35 M_TILING = 2,
36 // Action
37 M_DRAGGING = 4,
38 M_RESIZING = 8,
39};
40
41struct pointer_button_state {
42 bool held;
43 // state at the point it was pressed
44 int x, y;
45 swayc_t *view;
46};
47
48extern 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
66enum modifier_state {
67 MOD_STATE_UNCHANGED = 0,
68 MOD_STATE_PRESSED = 1,
69 MOD_STATE_RELEASED = 2
70};
71
72void pointer_position_set(double new_x, double new_y, bool force_focus);
73void 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
77void pointer_mode_set(uint32_t button, bool condition);
78
79// Update mode in mouse motion
80void pointer_mode_update(void);
81
82// Reset mode on any keypress;
83void pointer_mode_reset(void);
84
85void 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 */
94uint32_t modifier_state_changed(uint32_t new_state, uint32_t mod);
95
96/**
97 * Update the current modifiers state to new_state.
98 */
99void modifiers_state_update(uint32_t new_state);
100
101#endif
102
diff --git a/include/sway/old/ipc-json.h b/include/sway/old/ipc-json.h
deleted file mode 100644
index 3a5af0f5..00000000
--- a/include/sway/old/ipc-json.h
+++ /dev/null
@@ -1,15 +0,0 @@
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
8json_object *ipc_json_get_version();
9json_object *ipc_json_describe_bar_config(struct bar_config *bar);
10json_object *ipc_json_describe_container(swayc_t *c);
11json_object *ipc_json_describe_container_recursive(swayc_t *c);
12json_object *ipc_json_describe_window(swayc_t *c);
13json_object *ipc_json_describe_input(struct libinput_device *device);
14
15#endif
diff --git a/include/sway/old/ipc-server.h b/include/sway/old/ipc-server.h
deleted file mode 100644
index 0cc26d99..00000000
--- a/include/sway/old/ipc-server.h
+++ /dev/null
@@ -1,33 +0,0 @@
1#ifndef _SWAY_IPC_SERVER_H
2#define _SWAY_IPC_SERVER_H
3#include "container.h"
4#include "config.h"
5#include "ipc.h"
6
7void ipc_init(void);
8void ipc_terminate(void);
9struct sockaddr_un *ipc_user_sockaddr(void);
10
11void ipc_event_workspace(swayc_t *old, swayc_t *new, const char *change);
12void ipc_event_barconfig_update(struct bar_config *bar);
13/**
14 * Send IPC mode event to all listening clients
15 */
16void ipc_event_mode(const char *mode);
17/**
18 * Send IPC window change event
19 */
20void ipc_event_window(swayc_t *window, const char *change);
21/**
22 * Sends an IPC modifier event to all listening clients. The modifier event
23 * includes a key 'change' with the value of state and a key 'modifier' with
24 * the name of that modifier.
25 */
26void ipc_event_modifier(uint32_t modifier, const char *state);
27/**
28 * Send IPC keyboard binding event.
29 */
30void ipc_event_binding_keyboard(struct sway_binding *sb);
31const char *swayc_type_string(enum swayc_types type);
32
33#endif
diff --git a/include/sway/old/layout.h b/include/sway/old/layout.h
deleted file mode 100644
index f0791588..00000000
--- a/include/sway/old/layout.h
+++ /dev/null
@@ -1,85 +0,0 @@
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
10extern list_t *scratchpad;
11
12extern int min_sane_w;
13extern int min_sane_h;
14
15// Set initial values for root_container
16void init_layout(void);
17
18// Returns the index of child for its parent
19int 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
23void 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
27void 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
31void add_floating(swayc_t *ws, swayc_t *child);
32
33// insert child after sibling in parents children.
34swayc_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
39swayc_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
43swayc_t *remove_child(swayc_t *child);
44
45// 2 containers are swapped, they inherit eachothers focus
46void swap_container(swayc_t *a, swayc_t *b);
47
48// 2 Containers geometry are swapped, used with `swap_container`
49void swap_geometry(swayc_t *a, swayc_t *b);
50
51void move_container(swayc_t* container, enum movement_direction direction, int move_amt);
52void move_container_to(swayc_t* container, swayc_t* destination);
53void move_workspace_to(swayc_t* workspace, swayc_t* destination);
54
55// Layout
56/**
57 * Update child container geometries when switching between layouts.
58 */
59void update_layout_geometry(swayc_t *parent, enum swayc_layouts prev_layout);
60void update_geometry(swayc_t *view);
61void arrange_windows(swayc_t *container, double width, double height);
62void arrange_backgrounds(void);
63
64swayc_t *get_focused_container(swayc_t *parent);
65swayc_t *get_swayc_in_direction(swayc_t *container, enum movement_direction dir);
66swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_direction dir, swayc_t *limit);
67
68void recursive_resize(swayc_t *container, double amount, enum wlc_resize_edge edge);
69
70void layout_log(const swayc_t *c, int depth);
71void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, ...) __attribute__((format(printf,3,4)));
72
73/**
74 * Get default layout.
75 */
76enum swayc_layouts default_layout(swayc_t *output);
77
78bool is_auto_layout(enum swayc_layouts layout);
79int auto_group_start_index(const swayc_t *container, int index);
80int auto_group_end_index(const swayc_t *container, int index);
81size_t auto_group_count(const swayc_t *container);
82size_t auto_group_index(const swayc_t *container, int index);
83bool auto_group_bounds(const swayc_t *container, size_t group_index, int *start, int *end);
84
85#endif
diff --git a/include/sway/old/output.h b/include/sway/old/output.h
deleted file mode 100644
index 2a222238..00000000
--- a/include/sway/old/output.h
+++ /dev/null
@@ -1,36 +0,0 @@
1#ifndef _SWAY_OUTPUT_H
2#define _SWAY_OUTPUT_H
3#include <time.h>
4#include <wayland-server.h>
5#include <wlr/types/wlr_output.h>
6#include "container.h"
7#include "focus.h"
8
9struct sway_server;
10
11struct sway_output {
12 struct wlr_output *wlr_output;
13 struct wl_listener frame;
14 struct sway_server *server;
15 struct timespec last_frame;
16};
17
18// Position is absolute coordinates on the edge where the adjacent output
19// should be searched for.
20swayc_t *output_by_name(const char* name, const struct wlc_point *abs_pos);
21swayc_t *swayc_opposite_output(enum movement_direction dir, const struct wlc_point *abs_pos);
22swayc_t *swayc_adjacent_output(swayc_t *output, enum movement_direction dir, const struct wlc_point *abs_pos, bool pick_closest);
23
24// Place absolute coordinates for given container into given wlc_point.
25void get_absolute_position(swayc_t *container, struct wlc_point *point);
26
27// Place absolute coordinates for the center point of given container into
28// given wlc_point.
29void get_absolute_center_position(swayc_t *container, struct wlc_point *point);
30
31// stable sort workspaces on this output
32void sort_workspaces(swayc_t *output);
33
34void output_get_scaled_size(wlc_handle handle, struct wlc_size *size);
35
36#endif
diff --git a/include/sway/old/workspace.h b/include/sway/old/workspace.h
deleted file mode 100644
index c268fafa..00000000
--- a/include/sway/old/workspace.h
+++ /dev/null
@@ -1,22 +0,0 @@
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
9extern char *prev_workspace_name;
10
11char *workspace_next_name(const char *output_name);
12swayc_t *workspace_create(const char*);
13swayc_t *workspace_by_name(const char*);
14swayc_t *workspace_by_number(const char*);
15bool workspace_switch(swayc_t*);
16swayc_t *workspace_output_next();
17swayc_t *workspace_next();
18swayc_t *workspace_output_prev();
19swayc_t *workspace_prev();
20swayc_t *workspace_for_pid(pid_t pid);
21
22#endif