aboutsummaryrefslogtreecommitdiffstats
path: root/include/sway/config.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sway/config.h')
-rw-r--r--include/sway/config.h119
1 files changed, 78 insertions, 41 deletions
diff --git a/include/sway/config.h b/include/sway/config.h
index b8327e9c..5ccc3e77 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -8,13 +8,17 @@
8#include <wlr/types/wlr_tablet_tool.h> 8#include <wlr/types/wlr_tablet_tool.h>
9#include <wlr/util/box.h> 9#include <wlr/util/box.h>
10#include <xkbcommon/xkbcommon.h> 10#include <xkbcommon/xkbcommon.h>
11#include <xf86drmMode.h>
11#include "../include/config.h" 12#include "../include/config.h"
13#include "gesture.h"
12#include "list.h" 14#include "list.h"
15#include "stringop.h"
13#include "swaynag.h" 16#include "swaynag.h"
14#include "tree/container.h" 17#include "tree/container.h"
15#include "sway/input/tablet.h" 18#include "sway/input/tablet.h"
16#include "sway/tree/root.h" 19#include "sway/tree/root.h"
17#include "wlr-layer-shell-unstable-v1-protocol.h" 20#include "wlr-layer-shell-unstable-v1-protocol.h"
21#include <pango/pangocairo.h>
18 22
19// TODO: Refactor this shit 23// TODO: Refactor this shit
20 24
@@ -31,7 +35,8 @@ enum binding_input_type {
31 BINDING_KEYSYM, 35 BINDING_KEYSYM,
32 BINDING_MOUSECODE, 36 BINDING_MOUSECODE,
33 BINDING_MOUSESYM, 37 BINDING_MOUSESYM,
34 BINDING_SWITCH 38 BINDING_SWITCH, // dummy, only used to call seat_execute_command
39 BINDING_GESTURE // dummy, only used to call seat_execute_command
35}; 40};
36 41
37enum binding_flags { 42enum binding_flags {
@@ -44,10 +49,11 @@ enum binding_flags {
44 BINDING_RELOAD = 1 << 6, // switch only; (re)trigger binding on reload 49 BINDING_RELOAD = 1 << 6, // switch only; (re)trigger binding on reload
45 BINDING_INHIBITED = 1 << 7, // keyboard only: ignore shortcut inhibitor 50 BINDING_INHIBITED = 1 << 7, // keyboard only: ignore shortcut inhibitor
46 BINDING_NOREPEAT = 1 << 8, // keyboard only; do not trigger when repeating a held key 51 BINDING_NOREPEAT = 1 << 8, // keyboard only; do not trigger when repeating a held key
52 BINDING_EXACT = 1 << 9, // gesture only; only trigger on exact match
47}; 53};
48 54
49/** 55/**
50 * A key binding and an associated command. 56 * A key (or mouse) binding and an associated command.
51 */ 57 */
52struct sway_binding { 58struct sway_binding {
53 enum binding_input_type type; 59 enum binding_input_type type;
@@ -61,12 +67,10 @@ struct sway_binding {
61 char *command; 67 char *command;
62}; 68};
63 69
64/** 70enum sway_switch_trigger {
65 * A mouse binding and an associated command. 71 SWAY_SWITCH_TRIGGER_OFF,
66 */ 72 SWAY_SWITCH_TRIGGER_ON,
67struct sway_mouse_binding { 73 SWAY_SWITCH_TRIGGER_TOGGLE,
68 uint32_t button;
69 char *command;
70}; 74};
71 75
72/** 76/**
@@ -74,12 +78,22 @@ struct sway_mouse_binding {
74 */ 78 */
75struct sway_switch_binding { 79struct sway_switch_binding {
76 enum wlr_switch_type type; 80 enum wlr_switch_type type;
77 enum wlr_switch_state state; 81 enum sway_switch_trigger trigger;
78 uint32_t flags; 82 uint32_t flags;
79 char *command; 83 char *command;
80}; 84};
81 85
82/** 86/**
87 * A gesture binding and an associated command.
88 */
89struct sway_gesture_binding {
90 char *input;
91 uint32_t flags;
92 struct gesture gesture;
93 char *command;
94};
95
96/**
83 * Focus on window activation. 97 * Focus on window activation.
84 */ 98 */
85enum sway_fowa { 99enum sway_fowa {
@@ -98,6 +112,7 @@ struct sway_mode {
98 list_t *keycode_bindings; 112 list_t *keycode_bindings;
99 list_t *mouse_bindings; 113 list_t *mouse_bindings;
100 list_t *switch_bindings; 114 list_t *switch_bindings;
115 list_t *gesture_bindings;
101 bool pango; 116 bool pango;
102}; 117};
103 118
@@ -136,14 +151,17 @@ struct input_config {
136 int drag; 151 int drag;
137 int drag_lock; 152 int drag_lock;
138 int dwt; 153 int dwt;
154 int dwtp;
139 int left_handed; 155 int left_handed;
140 int middle_emulation; 156 int middle_emulation;
141 int natural_scroll; 157 int natural_scroll;
142 float pointer_accel; 158 float pointer_accel;
159 float rotation_angle;
143 float scroll_factor; 160 float scroll_factor;
144 int repeat_delay; 161 int repeat_delay;
145 int repeat_rate; 162 int repeat_rate;
146 int scroll_button; 163 int scroll_button;
164 int scroll_button_lock;
147 int scroll_method; 165 int scroll_method;
148 int send_events; 166 int send_events;
149 int tap; 167 int tap;
@@ -233,12 +251,6 @@ struct seat_config {
233 } xcursor_theme; 251 } xcursor_theme;
234}; 252};
235 253
236enum config_dpms {
237 DPMS_IGNORE,
238 DPMS_ON,
239 DPMS_OFF,
240};
241
242enum scale_filter_mode { 254enum scale_filter_mode {
243 SCALE_FILTER_DEFAULT, // the default is currently smart 255 SCALE_FILTER_DEFAULT, // the default is currently smart
244 SCALE_FILTER_LINEAR, 256 SCALE_FILTER_LINEAR,
@@ -246,6 +258,12 @@ enum scale_filter_mode {
246 SCALE_FILTER_SMART, 258 SCALE_FILTER_SMART,
247}; 259};
248 260
261enum render_bit_depth {
262 RENDER_BIT_DEPTH_DEFAULT, // the default is currently 8
263 RENDER_BIT_DEPTH_8,
264 RENDER_BIT_DEPTH_10,
265};
266
249/** 267/**
250 * Size and position configuration for a particular output. 268 * Size and position configuration for a particular output.
251 * 269 *
@@ -254,9 +272,11 @@ enum scale_filter_mode {
254struct output_config { 272struct output_config {
255 char *name; 273 char *name;
256 int enabled; 274 int enabled;
275 int power;
257 int width, height; 276 int width, height;
258 float refresh_rate; 277 float refresh_rate;
259 int custom_mode; 278 int custom_mode;
279 drmModeModeInfo drm_mode;
260 int x, y; 280 int x, y;
261 float scale; 281 float scale;
262 enum scale_filter_mode scale_filter; 282 enum scale_filter_mode scale_filter;
@@ -264,11 +284,19 @@ struct output_config {
264 enum wl_output_subpixel subpixel; 284 enum wl_output_subpixel subpixel;
265 int max_render_time; // In milliseconds 285 int max_render_time; // In milliseconds
266 int adaptive_sync; 286 int adaptive_sync;
287 enum render_bit_depth render_bit_depth;
267 288
268 char *background; 289 char *background;
269 char *background_option; 290 char *background_option;
270 char *background_fallback; 291 char *background_fallback;
271 enum config_dpms dpms_state; 292};
293
294/**
295 * An output config pre-matched to an output
296 */
297struct matched_output_config {
298 struct sway_output *output;
299 struct output_config *config;
272}; 300};
273 301
274/** 302/**
@@ -281,6 +309,12 @@ struct side_gaps {
281 int left; 309 int left;
282}; 310};
283 311
312enum smart_gaps_mode {
313 SMART_GAPS_OFF,
314 SMART_GAPS_ON,
315 SMART_GAPS_INVERSE_OUTER,
316};
317
284/** 318/**
285 * Stores configuration for a workspace, regardless of whether the workspace 319 * Stores configuration for a workspace, regardless of whether the workspace
286 * exists. 320 * exists.
@@ -416,14 +450,6 @@ enum sway_popup_during_fullscreen {
416 POPUP_LEAVE, 450 POPUP_LEAVE,
417}; 451};
418 452
419enum command_context {
420 CONTEXT_CONFIG = 1 << 0,
421 CONTEXT_BINDING = 1 << 1,
422 CONTEXT_IPC = 1 << 2,
423 CONTEXT_CRITERIA = 1 << 3,
424 CONTEXT_ALL = 0xFFFFFFFF,
425};
426
427enum focus_follows_mouse_mode { 453enum focus_follows_mouse_mode {
428 FOLLOWS_NO, 454 FOLLOWS_NO,
429 FOLLOWS_YES, 455 FOLLOWS_YES,
@@ -485,9 +511,10 @@ struct sway_config {
485 char *floating_scroll_right_cmd; 511 char *floating_scroll_right_cmd;
486 enum sway_container_layout default_orientation; 512 enum sway_container_layout default_orientation;
487 enum sway_container_layout default_layout; 513 enum sway_container_layout default_layout;
488 char *font; 514 char *font; // Used for IPC.
489 size_t font_height; 515 PangoFontDescription *font_description; // Used internally for rendering and validating.
490 size_t font_baseline; 516 int font_height;
517 int font_baseline;
491 bool pango_markup; 518 bool pango_markup;
492 int titlebar_border_thickness; 519 int titlebar_border_thickness;
493 int titlebar_h_padding; 520 int titlebar_h_padding;
@@ -514,11 +541,12 @@ struct sway_config {
514 bool auto_back_and_forth; 541 bool auto_back_and_forth;
515 bool show_marks; 542 bool show_marks;
516 enum alignment title_align; 543 enum alignment title_align;
544 bool primary_selection;
517 545
518 bool tiling_drag; 546 bool tiling_drag;
519 int tiling_drag_threshold; 547 int tiling_drag_threshold;
520 548
521 bool smart_gaps; 549 enum smart_gaps_mode smart_gaps;
522 int gaps_inner; 550 int gaps_inner;
523 struct side_gaps gaps_outer; 551 struct side_gaps gaps_outer;
524 552
@@ -541,12 +569,15 @@ struct sway_config {
541 struct { 569 struct {
542 struct border_colors focused; 570 struct border_colors focused;
543 struct border_colors focused_inactive; 571 struct border_colors focused_inactive;
572 struct border_colors focused_tab_title;
544 struct border_colors unfocused; 573 struct border_colors unfocused;
545 struct border_colors urgent; 574 struct border_colors urgent;
546 struct border_colors placeholder; 575 struct border_colors placeholder;
547 float background[4]; 576 float background[4];
548 } border_colors; 577 } border_colors;
549 578
579 bool has_focused_tab_title;
580
550 // floating view 581 // floating view
551 int32_t floating_maximum_width; 582 int32_t floating_maximum_width;
552 int32_t floating_maximum_height; 583 int32_t floating_maximum_height;
@@ -604,7 +635,7 @@ void run_deferred_bindings(void);
604/** 635/**
605 * Adds a warning entry to the swaynag instance used for errors. 636 * Adds a warning entry to the swaynag instance used for errors.
606 */ 637 */
607void config_add_swaynag_warning(char *fmt, ...); 638void config_add_swaynag_warning(char *fmt, ...) _SWAY_ATTRIB_PRINTF(1, 2);
608 639
609/** 640/**
610 * Free config struct 641 * Free config struct
@@ -657,20 +688,25 @@ const char *sway_output_scale_filter_to_string(enum scale_filter_mode scale_filt
657 688
658struct output_config *new_output_config(const char *name); 689struct output_config *new_output_config(const char *name);
659 690
660void merge_output_config(struct output_config *dst, struct output_config *src); 691bool apply_output_configs(struct matched_output_config *configs,
692 size_t configs_len, bool test_only, bool degrade_to_off);
661 693
662bool apply_output_config(struct output_config *oc, struct sway_output *output); 694void apply_all_output_configs(void);
663 695
664bool test_output_config(struct output_config *oc, struct sway_output *output); 696void sort_output_configs_by_priority(struct matched_output_config *configs,
697 size_t configs_len);
665 698
666struct output_config *store_output_config(struct output_config *oc); 699/**
700 * store_output_config stores a new output config. An output may be matched by
701 * three different config types, in order of precedence: Identifier, name and
702 * wildcard. When storing a config type of lower precedence, assume that the
703 * user wants the config to take immediate effect by superseding (clearing) the
704 * same values from higher presedence configuration.
705 */
706void store_output_config(struct output_config *oc);
667 707
668struct output_config *find_output_config(struct sway_output *output); 708struct output_config *find_output_config(struct sway_output *output);
669 709
670void apply_output_config_to_outputs(struct output_config *oc);
671
672void reset_outputs(void);
673
674void free_output_config(struct output_config *oc); 710void free_output_config(struct output_config *oc);
675 711
676bool spawn_swaybg(void); 712bool spawn_swaybg(void);
@@ -681,6 +717,8 @@ void free_sway_binding(struct sway_binding *sb);
681 717
682void free_switch_binding(struct sway_switch_binding *binding); 718void free_switch_binding(struct sway_switch_binding *binding);
683 719
720void free_gesture_binding(struct sway_gesture_binding *binding);
721
684void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding); 722void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding);
685 723
686void load_swaybar(struct bar_config *bar); 724void load_swaybar(struct bar_config *bar);
@@ -696,14 +734,13 @@ void free_bar_binding(struct bar_binding *binding);
696void free_workspace_config(struct workspace_config *wsc); 734void free_workspace_config(struct workspace_config *wsc);
697 735
698/** 736/**
699 * Updates the value of config->font_height based on the max title height 737 * Updates the value of config->font_height based on the metrics for title's
700 * reported by each container. If recalculate is true, the containers will 738 * font as reported by pango.
701 * recalculate their heights before reporting.
702 * 739 *
703 * If the height has changed, all containers will be rearranged to take on the 740 * If the height has changed, all containers will be rearranged to take on the
704 * new size. 741 * new size.
705 */ 742 */
706void config_update_font_height(bool recalculate); 743void config_update_font_height(void);
707 744
708/** 745/**
709 * Convert bindsym into bindcode using the first configured layout. 746 * Convert bindsym into bindcode using the first configured layout.