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.h102
1 files changed, 66 insertions, 36 deletions
diff --git a/include/sway/config.h b/include/sway/config.h
index 59f22ae2..f9da1967 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -5,16 +5,20 @@
5#include <string.h> 5#include <string.h>
6#include <time.h> 6#include <time.h>
7#include <wlr/interfaces/wlr_switch.h> 7#include <wlr/interfaces/wlr_switch.h>
8#include <wlr/types/wlr_box.h>
9#include <wlr/types/wlr_tablet_tool.h> 8#include <wlr/types/wlr_tablet_tool.h>
9#include <wlr/util/box.h>
10#include <xkbcommon/xkbcommon.h> 10#include <xkbcommon/xkbcommon.h>
11#include <xf86drmMode.h>
11#include "../include/config.h" 12#include "../include/config.h"
13#include "gesture.h"
12#include "list.h" 14#include "list.h"
15#include "stringop.h"
13#include "swaynag.h" 16#include "swaynag.h"
14#include "tree/container.h" 17#include "tree/container.h"
15#include "sway/input/tablet.h" 18#include "sway/input/tablet.h"
16#include "sway/tree/root.h" 19#include "sway/tree/root.h"
17#include "wlr-layer-shell-unstable-v1-protocol.h" 20#include "wlr-layer-shell-unstable-v1-protocol.h"
21#include <pango/pangocairo.h>
18 22
19// TODO: Refactor this shit 23// TODO: Refactor this shit
20 24
@@ -31,7 +35,8 @@ enum binding_input_type {
31 BINDING_KEYSYM, 35 BINDING_KEYSYM,
32 BINDING_MOUSECODE, 36 BINDING_MOUSECODE,
33 BINDING_MOUSESYM, 37 BINDING_MOUSESYM,
34 BINDING_SWITCH 38 BINDING_SWITCH, // dummy, only used to call seat_execute_command
39 BINDING_GESTURE // dummy, only used to call seat_execute_command
35}; 40};
36 41
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,11 @@ 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;
272}; 292};
273 293
274/** 294/**
@@ -281,6 +301,12 @@ struct side_gaps {
281 int left; 301 int left;
282}; 302};
283 303
304enum smart_gaps_mode {
305 SMART_GAPS_OFF,
306 SMART_GAPS_ON,
307 SMART_GAPS_INVERSE_OUTER,
308};
309
284/** 310/**
285 * Stores configuration for a workspace, regardless of whether the workspace 311 * Stores configuration for a workspace, regardless of whether the workspace
286 * exists. 312 * exists.
@@ -292,6 +318,12 @@ struct workspace_config {
292 struct side_gaps gaps_outer; 318 struct side_gaps gaps_outer;
293}; 319};
294 320
321enum pango_markup_config {
322 PANGO_MARKUP_DISABLED = false,
323 PANGO_MARKUP_ENABLED = true,
324 PANGO_MARKUP_DEFAULT // The default is font dependent ("pango:" prefix)
325};
326
295struct bar_config { 327struct bar_config {
296 char *swaybar_command; 328 char *swaybar_command;
297 struct wl_client *client; 329 struct wl_client *client;
@@ -323,7 +355,7 @@ struct bar_config {
323 char *position; 355 char *position;
324 list_t *bindings; 356 list_t *bindings;
325 char *status_command; 357 char *status_command;
326 bool pango_markup; 358 enum pango_markup_config pango_markup;
327 char *font; 359 char *font;
328 int height; // -1 not defined 360 int height; // -1 not defined
329 bool workspace_buttons; 361 bool workspace_buttons;
@@ -410,14 +442,6 @@ enum sway_popup_during_fullscreen {
410 POPUP_LEAVE, 442 POPUP_LEAVE,
411}; 443};
412 444
413enum command_context {
414 CONTEXT_CONFIG = 1 << 0,
415 CONTEXT_BINDING = 1 << 1,
416 CONTEXT_IPC = 1 << 2,
417 CONTEXT_CRITERIA = 1 << 3,
418 CONTEXT_ALL = 0xFFFFFFFF,
419};
420
421enum focus_follows_mouse_mode { 445enum focus_follows_mouse_mode {
422 FOLLOWS_NO, 446 FOLLOWS_NO,
423 FOLLOWS_YES, 447 FOLLOWS_YES,
@@ -479,9 +503,10 @@ struct sway_config {
479 char *floating_scroll_right_cmd; 503 char *floating_scroll_right_cmd;
480 enum sway_container_layout default_orientation; 504 enum sway_container_layout default_orientation;
481 enum sway_container_layout default_layout; 505 enum sway_container_layout default_layout;
482 char *font; 506 char *font; // Used for IPC.
483 size_t font_height; 507 PangoFontDescription *font_description; // Used internally for rendering and validating.
484 size_t font_baseline; 508 int font_height;
509 int font_baseline;
485 bool pango_markup; 510 bool pango_markup;
486 int titlebar_border_thickness; 511 int titlebar_border_thickness;
487 int titlebar_h_padding; 512 int titlebar_h_padding;
@@ -508,11 +533,12 @@ struct sway_config {
508 bool auto_back_and_forth; 533 bool auto_back_and_forth;
509 bool show_marks; 534 bool show_marks;
510 enum alignment title_align; 535 enum alignment title_align;
536 bool primary_selection;
511 537
512 bool tiling_drag; 538 bool tiling_drag;
513 int tiling_drag_threshold; 539 int tiling_drag_threshold;
514 540
515 bool smart_gaps; 541 enum smart_gaps_mode smart_gaps;
516 int gaps_inner; 542 int gaps_inner;
517 struct side_gaps gaps_outer; 543 struct side_gaps gaps_outer;
518 544
@@ -535,12 +561,15 @@ struct sway_config {
535 struct { 561 struct {
536 struct border_colors focused; 562 struct border_colors focused;
537 struct border_colors focused_inactive; 563 struct border_colors focused_inactive;
564 struct border_colors focused_tab_title;
538 struct border_colors unfocused; 565 struct border_colors unfocused;
539 struct border_colors urgent; 566 struct border_colors urgent;
540 struct border_colors placeholder; 567 struct border_colors placeholder;
541 float background[4]; 568 float background[4];
542 } border_colors; 569 } border_colors;
543 570
571 bool has_focused_tab_title;
572
544 // floating view 573 // floating view
545 int32_t floating_maximum_width; 574 int32_t floating_maximum_width;
546 int32_t floating_maximum_height; 575 int32_t floating_maximum_height;
@@ -559,7 +588,7 @@ struct sway_config {
559 struct sway_node *node; 588 struct sway_node *node;
560 struct sway_container *container; 589 struct sway_container *container;
561 struct sway_workspace *workspace; 590 struct sway_workspace *workspace;
562 bool using_criteria; 591 bool node_overridden; // True if the node is selected by means other than focus
563 struct { 592 struct {
564 int argc; 593 int argc;
565 char **argv; 594 char **argv;
@@ -598,7 +627,7 @@ void run_deferred_bindings(void);
598/** 627/**
599 * Adds a warning entry to the swaynag instance used for errors. 628 * Adds a warning entry to the swaynag instance used for errors.
600 */ 629 */
601void config_add_swaynag_warning(char *fmt, ...); 630void config_add_swaynag_warning(char *fmt, ...) _SWAY_ATTRIB_PRINTF(1, 2);
602 631
603/** 632/**
604 * Free config struct 633 * Free config struct
@@ -675,6 +704,8 @@ void free_sway_binding(struct sway_binding *sb);
675 704
676void free_switch_binding(struct sway_switch_binding *binding); 705void free_switch_binding(struct sway_switch_binding *binding);
677 706
707void free_gesture_binding(struct sway_gesture_binding *binding);
708
678void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding); 709void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding);
679 710
680void load_swaybar(struct bar_config *bar); 711void load_swaybar(struct bar_config *bar);
@@ -690,14 +721,13 @@ void free_bar_binding(struct bar_binding *binding);
690void free_workspace_config(struct workspace_config *wsc); 721void free_workspace_config(struct workspace_config *wsc);
691 722
692/** 723/**
693 * Updates the value of config->font_height based on the max title height 724 * Updates the value of config->font_height based on the metrics for title's
694 * reported by each container. If recalculate is true, the containers will 725 * font as reported by pango.
695 * recalculate their heights before reporting.
696 * 726 *
697 * If the height has changed, all containers will be rearranged to take on the 727 * If the height has changed, all containers will be rearranged to take on the
698 * new size. 728 * new size.
699 */ 729 */
700void config_update_font_height(bool recalculate); 730void config_update_font_height(void);
701 731
702/** 732/**
703 * Convert bindsym into bindcode using the first configured layout. 733 * Convert bindsym into bindcode using the first configured layout.