diff options
Diffstat (limited to 'include/sway/config.h')
-rw-r--r-- | include/sway/config.h | 130 |
1 files changed, 85 insertions, 45 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index 59f22ae2..0be1cd22 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 | ||
37 | enum binding_flags { | 42 | enum 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 | */ |
52 | struct sway_binding { | 58 | struct 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 | /** | 70 | enum sway_switch_trigger { |
65 | * A mouse binding and an associated command. | 71 | SWAY_SWITCH_TRIGGER_OFF, |
66 | */ | 72 | SWAY_SWITCH_TRIGGER_ON, |
67 | struct 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 | */ |
75 | struct sway_switch_binding { | 79 | struct 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 | */ | ||
89 | struct 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 | */ |
85 | enum sway_fowa { | 99 | enum 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 | ||
236 | enum config_dpms { | ||
237 | DPMS_IGNORE, | ||
238 | DPMS_ON, | ||
239 | DPMS_OFF, | ||
240 | }; | ||
241 | |||
242 | enum scale_filter_mode { | 254 | enum 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 | ||
261 | enum 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 { | |||
254 | struct output_config { | 272 | struct 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 | */ | ||
297 | struct 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 | ||
312 | enum 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. |
@@ -292,6 +326,12 @@ struct workspace_config { | |||
292 | struct side_gaps gaps_outer; | 326 | struct side_gaps gaps_outer; |
293 | }; | 327 | }; |
294 | 328 | ||
329 | enum pango_markup_config { | ||
330 | PANGO_MARKUP_DISABLED = false, | ||
331 | PANGO_MARKUP_ENABLED = true, | ||
332 | PANGO_MARKUP_DEFAULT // The default is font dependent ("pango:" prefix) | ||
333 | }; | ||
334 | |||
295 | struct bar_config { | 335 | struct bar_config { |
296 | char *swaybar_command; | 336 | char *swaybar_command; |
297 | struct wl_client *client; | 337 | struct wl_client *client; |
@@ -323,7 +363,7 @@ struct bar_config { | |||
323 | char *position; | 363 | char *position; |
324 | list_t *bindings; | 364 | list_t *bindings; |
325 | char *status_command; | 365 | char *status_command; |
326 | bool pango_markup; | 366 | enum pango_markup_config pango_markup; |
327 | char *font; | 367 | char *font; |
328 | int height; // -1 not defined | 368 | int height; // -1 not defined |
329 | bool workspace_buttons; | 369 | bool workspace_buttons; |
@@ -410,14 +450,6 @@ enum sway_popup_during_fullscreen { | |||
410 | POPUP_LEAVE, | 450 | POPUP_LEAVE, |
411 | }; | 451 | }; |
412 | 452 | ||
413 | enum 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 | |||
421 | enum focus_follows_mouse_mode { | 453 | enum focus_follows_mouse_mode { |
422 | FOLLOWS_NO, | 454 | FOLLOWS_NO, |
423 | FOLLOWS_YES, | 455 | FOLLOWS_YES, |
@@ -479,9 +511,10 @@ struct sway_config { | |||
479 | char *floating_scroll_right_cmd; | 511 | char *floating_scroll_right_cmd; |
480 | enum sway_container_layout default_orientation; | 512 | enum sway_container_layout default_orientation; |
481 | enum sway_container_layout default_layout; | 513 | enum sway_container_layout default_layout; |
482 | char *font; | 514 | char *font; // Used for IPC. |
483 | size_t font_height; | 515 | PangoFontDescription *font_description; // Used internally for rendering and validating. |
484 | size_t font_baseline; | 516 | int font_height; |
517 | int font_baseline; | ||
485 | bool pango_markup; | 518 | bool pango_markup; |
486 | int titlebar_border_thickness; | 519 | int titlebar_border_thickness; |
487 | int titlebar_h_padding; | 520 | int titlebar_h_padding; |
@@ -508,11 +541,12 @@ struct sway_config { | |||
508 | bool auto_back_and_forth; | 541 | bool auto_back_and_forth; |
509 | bool show_marks; | 542 | bool show_marks; |
510 | enum alignment title_align; | 543 | enum alignment title_align; |
544 | bool primary_selection; | ||
511 | 545 | ||
512 | bool tiling_drag; | 546 | bool tiling_drag; |
513 | int tiling_drag_threshold; | 547 | int tiling_drag_threshold; |
514 | 548 | ||
515 | bool smart_gaps; | 549 | enum smart_gaps_mode smart_gaps; |
516 | int gaps_inner; | 550 | int gaps_inner; |
517 | struct side_gaps gaps_outer; | 551 | struct side_gaps gaps_outer; |
518 | 552 | ||
@@ -535,12 +569,15 @@ struct sway_config { | |||
535 | struct { | 569 | struct { |
536 | struct border_colors focused; | 570 | struct border_colors focused; |
537 | struct border_colors focused_inactive; | 571 | struct border_colors focused_inactive; |
572 | struct border_colors focused_tab_title; | ||
538 | struct border_colors unfocused; | 573 | struct border_colors unfocused; |
539 | struct border_colors urgent; | 574 | struct border_colors urgent; |
540 | struct border_colors placeholder; | 575 | struct border_colors placeholder; |
541 | float background[4]; | 576 | float background[4]; |
542 | } border_colors; | 577 | } border_colors; |
543 | 578 | ||
579 | bool has_focused_tab_title; | ||
580 | |||
544 | // floating view | 581 | // floating view |
545 | int32_t floating_maximum_width; | 582 | int32_t floating_maximum_width; |
546 | int32_t floating_maximum_height; | 583 | int32_t floating_maximum_height; |
@@ -559,7 +596,7 @@ struct sway_config { | |||
559 | struct sway_node *node; | 596 | struct sway_node *node; |
560 | struct sway_container *container; | 597 | struct sway_container *container; |
561 | struct sway_workspace *workspace; | 598 | struct sway_workspace *workspace; |
562 | bool using_criteria; | 599 | bool node_overridden; // True if the node is selected by means other than focus |
563 | struct { | 600 | struct { |
564 | int argc; | 601 | int argc; |
565 | char **argv; | 602 | char **argv; |
@@ -598,7 +635,7 @@ void run_deferred_bindings(void); | |||
598 | /** | 635 | /** |
599 | * Adds a warning entry to the swaynag instance used for errors. | 636 | * Adds a warning entry to the swaynag instance used for errors. |
600 | */ | 637 | */ |
601 | void config_add_swaynag_warning(char *fmt, ...); | 638 | void config_add_swaynag_warning(char *fmt, ...) _SWAY_ATTRIB_PRINTF(1, 2); |
602 | 639 | ||
603 | /** | 640 | /** |
604 | * Free config struct | 641 | * Free config struct |
@@ -651,20 +688,22 @@ const char *sway_output_scale_filter_to_string(enum scale_filter_mode scale_filt | |||
651 | 688 | ||
652 | struct output_config *new_output_config(const char *name); | 689 | struct output_config *new_output_config(const char *name); |
653 | 690 | ||
654 | void merge_output_config(struct output_config *dst, struct output_config *src); | 691 | bool apply_output_configs(struct matched_output_config *configs, |
692 | size_t configs_len, bool test_only); | ||
655 | 693 | ||
656 | bool apply_output_config(struct output_config *oc, struct sway_output *output); | 694 | void apply_all_output_configs(void); |
657 | 695 | ||
658 | bool test_output_config(struct output_config *oc, struct sway_output *output); | 696 | /** |
659 | 697 | * store_output_config stores a new output config. An output may be matched by | |
660 | struct output_config *store_output_config(struct output_config *oc); | 698 | * three different config types, in order of precedence: Identifier, name and |
699 | * wildcard. When storing a config type of lower precedence, assume that the | ||
700 | * user wants the config to take immediate effect by superseding (clearing) the | ||
701 | * same values from higher presedence configuration. | ||
702 | */ | ||
703 | void store_output_config(struct output_config *oc); | ||
661 | 704 | ||
662 | struct output_config *find_output_config(struct sway_output *output); | 705 | struct output_config *find_output_config(struct sway_output *output); |
663 | 706 | ||
664 | void apply_output_config_to_outputs(struct output_config *oc); | ||
665 | |||
666 | void reset_outputs(void); | ||
667 | |||
668 | void free_output_config(struct output_config *oc); | 707 | void free_output_config(struct output_config *oc); |
669 | 708 | ||
670 | bool spawn_swaybg(void); | 709 | bool spawn_swaybg(void); |
@@ -675,6 +714,8 @@ void free_sway_binding(struct sway_binding *sb); | |||
675 | 714 | ||
676 | void free_switch_binding(struct sway_switch_binding *binding); | 715 | void free_switch_binding(struct sway_switch_binding *binding); |
677 | 716 | ||
717 | void free_gesture_binding(struct sway_gesture_binding *binding); | ||
718 | |||
678 | void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding); | 719 | void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding); |
679 | 720 | ||
680 | void load_swaybar(struct bar_config *bar); | 721 | void load_swaybar(struct bar_config *bar); |
@@ -690,14 +731,13 @@ void free_bar_binding(struct bar_binding *binding); | |||
690 | void free_workspace_config(struct workspace_config *wsc); | 731 | void free_workspace_config(struct workspace_config *wsc); |
691 | 732 | ||
692 | /** | 733 | /** |
693 | * Updates the value of config->font_height based on the max title height | 734 | * 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 | 735 | * font as reported by pango. |
695 | * recalculate their heights before reporting. | ||
696 | * | 736 | * |
697 | * If the height has changed, all containers will be rearranged to take on the | 737 | * If the height has changed, all containers will be rearranged to take on the |
698 | * new size. | 738 | * new size. |
699 | */ | 739 | */ |
700 | void config_update_font_height(bool recalculate); | 740 | void config_update_font_height(void); |
701 | 741 | ||
702 | /** | 742 | /** |
703 | * Convert bindsym into bindcode using the first configured layout. | 743 | * Convert bindsym into bindcode using the first configured layout. |