summaryrefslogtreecommitdiffstats
path: root/include/sway/config.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sway/config.h')
-rw-r--r--include/sway/config.h159
1 files changed, 107 insertions, 52 deletions
diff --git a/include/sway/config.h b/include/sway/config.h
index a05d5ede..ed49fbbd 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -1,18 +1,18 @@
1#ifndef _SWAY_CONFIG_H 1#ifndef _SWAY_CONFIG_H
2#define _SWAY_CONFIG_H 2#define _SWAY_CONFIG_H
3
4#define PID_WORKSPACE_TIMEOUT 60 3#define PID_WORKSPACE_TIMEOUT 60
5
6#include <libinput.h> 4#include <libinput.h>
7#include <stdint.h> 5#include <stdint.h>
8#include <wlc/geometry.h> 6#include <string.h>
9#include <wlc/wlc.h>
10#include <xkbcommon/xkbcommon.h>
11#include <time.h> 7#include <time.h>
12#include "wayland-desktop-shell-server-protocol.h" 8#include <wlr/types/wlr_box.h>
9#include <xkbcommon/xkbcommon.h>
13#include "list.h" 10#include "list.h"
14#include "layout.h" 11#include "tree/layout.h"
15#include "container.h" 12#include "tree/container.h"
13#include "wlr-layer-shell-unstable-v1-protocol.h"
14
15// TODO: Refactor this shit
16 16
17/** 17/**
18 * Describes a variable created via the `set` command. 18 * Describes a variable created via the `set` command.
@@ -47,11 +47,12 @@ struct sway_mouse_binding {
47 */ 47 */
48struct sway_mode { 48struct sway_mode {
49 char *name; 49 char *name;
50 list_t *bindings; 50 list_t *keysym_bindings;
51 list_t *keycode_bindings;
51}; 52};
52 53
53/** 54/**
54 * libinput options for input devices 55 * options for input devices
55 */ 56 */
56struct input_config { 57struct input_config {
57 char *identifier; 58 char *identifier;
@@ -68,8 +69,33 @@ struct input_config {
68 int send_events; 69 int send_events;
69 int tap; 70 int tap;
70 71
72 char *xkb_layout;
73 char *xkb_model;
74 char *xkb_options;
75 char *xkb_rules;
76 char *xkb_variant;
77
78 char *mapped_output;
79
71 bool capturable; 80 bool capturable;
72 struct wlc_geometry region; 81 struct wlr_box region;
82};
83
84/**
85 * Options for misc device configurations that happen in the seat block
86 */
87struct seat_attachment_config {
88 char *identifier;
89 // TODO other things are configured here for some reason
90};
91
92/**
93 * Options for multiseat and other misc device configurations
94 */
95struct seat_config {
96 char *name;
97 int fallback; // -1 means not set
98 list_t *attachments; // list of seat_attachment configs
73}; 99};
74 100
75/** 101/**
@@ -81,8 +107,11 @@ struct output_config {
81 char *name; 107 char *name;
82 int enabled; 108 int enabled;
83 int width, height; 109 int width, height;
110 float refresh_rate;
84 int x, y; 111 int x, y;
85 int scale; 112 float scale;
113 int32_t transform;
114
86 char *background; 115 char *background;
87 char *background_option; 116 char *background_option;
88}; 117};
@@ -126,24 +155,13 @@ struct bar_config {
126 char *id; 155 char *id;
127 uint32_t modifier; 156 uint32_t modifier;
128 list_t *outputs; 157 list_t *outputs;
129 enum desktop_shell_panel_position position; 158 char *position;
130 list_t *bindings; 159 list_t *bindings;
131 char *status_command; 160 char *status_command;
132 bool pango_markup; 161 bool pango_markup;
133 char *swaybar_command; 162 char *swaybar_command;
134 char *font; 163 char *font;
135 int height; // -1 not defined 164 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; 165 bool workspace_buttons;
148 bool wrap_scroll; 166 bool wrap_scroll;
149 char *separator_symbol; 167 char *separator_symbol;
@@ -260,11 +278,13 @@ struct sway_config {
260 list_t *pid_workspaces; 278 list_t *pid_workspaces;
261 list_t *output_configs; 279 list_t *output_configs;
262 list_t *input_configs; 280 list_t *input_configs;
281 list_t *seat_configs;
263 list_t *criteria; 282 list_t *criteria;
264 list_t *no_focus; 283 list_t *no_focus;
265 list_t *active_bar_modifiers; 284 list_t *active_bar_modifiers;
266 struct sway_mode *current_mode; 285 struct sway_mode *current_mode;
267 struct bar_config *current_bar; 286 struct bar_config *current_bar;
287 char *swaybg_command;
268 uint32_t floating_mod; 288 uint32_t floating_mod;
269 uint32_t dragging_key; 289 uint32_t dragging_key;
270 uint32_t resizing_key; 290 uint32_t resizing_key;
@@ -272,8 +292,8 @@ struct sway_config {
272 char *floating_scroll_down_cmd; 292 char *floating_scroll_down_cmd;
273 char *floating_scroll_left_cmd; 293 char *floating_scroll_left_cmd;
274 char *floating_scroll_right_cmd; 294 char *floating_scroll_right_cmd;
275 enum swayc_layouts default_orientation; 295 enum sway_container_layout default_orientation;
276 enum swayc_layouts default_layout; 296 enum sway_container_layout default_layout;
277 char *font; 297 char *font;
278 int font_height; 298 int font_height;
279 299
@@ -286,7 +306,6 @@ struct sway_config {
286 bool reloading; 306 bool reloading;
287 bool reading; 307 bool reading;
288 bool auto_back_and_forth; 308 bool auto_back_and_forth;
289 bool seamless_mouse;
290 bool show_marks; 309 bool show_marks;
291 310
292 bool edge_gaps; 311 bool edge_gaps;
@@ -297,8 +316,8 @@ struct sway_config {
297 list_t *config_chain; 316 list_t *config_chain;
298 const char *current_config; 317 const char *current_config;
299 318
300 enum swayc_border_types border; 319 enum sway_container_border border;
301 enum swayc_border_types floating_border; 320 enum sway_container_border floating_border;
302 int border_thickness; 321 int border_thickness;
303 int floating_border_thickness; 322 int floating_border_thickness;
304 enum edge_border_types hide_edge_borders; 323 enum edge_border_types hide_edge_borders;
@@ -323,6 +342,14 @@ struct sway_config {
323 list_t *command_policies; 342 list_t *command_policies;
324 list_t *feature_policies; 343 list_t *feature_policies;
325 list_t *ipc_policies; 344 list_t *ipc_policies;
345
346 // Context for command handlers
347 struct {
348 struct input_config *input_config;
349 struct seat_config *seat_config;
350 struct sway_seat *seat;
351 struct sway_container *current_container;
352 } handler_context;
326}; 353};
327 354
328void pid_workspace_add(struct pid_workspace *pw); 355void pid_workspace_add(struct pid_workspace *pw);
@@ -348,6 +375,11 @@ bool read_config(FILE *file, struct sway_config *config);
348 * Free config struct 375 * Free config struct
349 */ 376 */
350void free_config(struct sway_config *config); 377void free_config(struct sway_config *config);
378
379void config_clear_handler_context(struct sway_config *config);
380
381void free_sway_variable(struct sway_variable *var);
382
351/** 383/**
352 * Does variable replacement for a string based on the config's currently loaded variables. 384 * Does variable replacement for a string based on the config's currently loaded variables.
353 */ 385 */
@@ -356,51 +388,74 @@ char *do_var_replacement(char *str);
356struct cmd_results *check_security_config(); 388struct cmd_results *check_security_config();
357 389
358int input_identifier_cmp(const void *item, const void *data); 390int input_identifier_cmp(const void *item, const void *data);
391
392struct input_config *new_input_config(const char* identifier);
393
359void merge_input_config(struct input_config *dst, struct input_config *src); 394void merge_input_config(struct input_config *dst, struct input_config *src);
360void apply_input_config(struct input_config *ic, struct libinput_device *dev); 395
396struct input_config *copy_input_config(struct input_config *ic);
397
361void free_input_config(struct input_config *ic); 398void free_input_config(struct input_config *ic);
362 399
400void apply_input_config(struct input_config *input);
401
402int seat_name_cmp(const void *item, const void *data);
403
404struct seat_config *new_seat_config(const char* name);
405
406void merge_seat_config(struct seat_config *dst, struct seat_config *src);
407
408struct seat_config *copy_seat_config(struct seat_config *seat);
409
410void free_seat_config(struct seat_config *ic);
411
412struct seat_attachment_config *seat_attachment_config_new();
413
414struct seat_attachment_config *seat_config_get_attachment(
415 struct seat_config *seat_config, char *identifier);
416
417void apply_seat_config(struct seat_config *seat);
418
363int output_name_cmp(const void *item, const void *data); 419int output_name_cmp(const void *item, const void *data);
420
421void output_get_identifier(char *identifier, size_t len,
422 struct sway_output *output);
423
424struct output_config *new_output_config(const char *name);
425
364void merge_output_config(struct output_config *dst, struct output_config *src); 426void 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 427
370/** 428void apply_output_config(struct output_config *oc,
371 * Updates the list of active bar modifiers 429 struct sway_container *output);
372 */ 430
373void update_active_bar_modifiers(void); 431void free_output_config(struct output_config *oc);
374 432
375int workspace_output_cmp_workspace(const void *a, const void *b); 433int workspace_output_cmp_workspace(const void *a, const void *b);
376 434
377int sway_binding_cmp(const void *a, const void *b); 435int sway_binding_cmp(const void *a, const void *b);
436
378int sway_binding_cmp_qsort(const void *a, const void *b); 437int sway_binding_cmp_qsort(const void *a, const void *b);
438
379int sway_binding_cmp_keys(const void *a, const void *b); 439int sway_binding_cmp_keys(const void *a, const void *b);
440
380void free_sway_binding(struct sway_binding *sb); 441void free_sway_binding(struct sway_binding *sb);
381struct sway_binding *sway_binding_dup(struct sway_binding *sb);
382 442
383int sway_mouse_binding_cmp(const void *a, const void *b); 443struct sway_binding *sway_binding_dup(struct sway_binding *sb);
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 444
388void load_swaybars(); 445void load_swaybars();
446
447void invoke_swaybar(struct bar_config *bar);
448
389void terminate_swaybg(pid_t pid); 449void terminate_swaybg(pid_t pid);
390 450
391/**
392 * Allocate and initialize default bar configuration.
393 */
394struct bar_config *default_bar_config(void); 451struct bar_config *default_bar_config(void);
395 452
396/** 453void free_bar_config(struct bar_config *bar);
397 * Global config singleton. 454
398 */ 455/* Global config singleton. */
399extern struct sway_config *config; 456extern struct sway_config *config;
400 457
401/** 458/* Config file currently being read */
402 * Config file currently being read.
403 */
404extern const char *current_config_path; 459extern const char *current_config_path;
405 460
406#endif 461#endif