summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--include/sway/commands.h2
-rw-r--r--include/sway/config.h8
-rw-r--r--include/swaybar/i3bar.h2
-rw-r--r--sway/commands.c1
-rw-r--r--sway/commands/seat.c1
-rw-r--r--sway/commands/seat/pointer_constraint.c (renamed from sway/commands/pointer_constraint.c)23
-rw-r--r--sway/config/seat.c6
-rw-r--r--sway/input/cursor.c2
-rw-r--r--sway/meson.build2
-rw-r--r--sway/sway-bar.5.scd2
-rw-r--r--sway/sway-input.5.scd5
-rw-r--r--sway/sway.5.scd28
-rw-r--r--swaybar/i3bar.c3
-rw-r--r--swaybar/render.c6
15 files changed, 65 insertions, 28 deletions
diff --git a/README.md b/README.md
index b4e65e4d..239e7e3e 100644
--- a/README.md
+++ b/README.md
@@ -40,7 +40,7 @@ Install dependencies:
40* pango 40* pango
41* cairo 41* cairo
42* gdk-pixbuf2 \*\* 42* gdk-pixbuf2 \*\*
43* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) >= 1.8.0 (optional: man pages) \* 43* [scdoc](https://git.sr.ht/~sircmpwn/scdoc) >= 1.8.1 (optional: man pages) \*
44* git \* 44* git \*
45 45
46_\*Compile-time dep_ 46_\*Compile-time dep_
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 2877c370..3ed00763 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -153,7 +153,6 @@ sway_cmd cmd_new_window;
153sway_cmd cmd_no_focus; 153sway_cmd cmd_no_focus;
154sway_cmd cmd_output; 154sway_cmd cmd_output;
155sway_cmd cmd_permit; 155sway_cmd cmd_permit;
156sway_cmd cmd_pointer_constraint;
157sway_cmd cmd_popup_during_fullscreen; 156sway_cmd cmd_popup_during_fullscreen;
158sway_cmd cmd_reject; 157sway_cmd cmd_reject;
159sway_cmd cmd_reload; 158sway_cmd cmd_reload;
@@ -268,6 +267,7 @@ sway_cmd seat_cmd_attach;
268sway_cmd seat_cmd_cursor; 267sway_cmd seat_cmd_cursor;
269sway_cmd seat_cmd_fallback; 268sway_cmd seat_cmd_fallback;
270sway_cmd seat_cmd_hide_cursor; 269sway_cmd seat_cmd_hide_cursor;
270sway_cmd seat_cmd_pointer_constraint;
271 271
272sway_cmd cmd_ipc_cmd; 272sway_cmd cmd_ipc_cmd;
273sway_cmd cmd_ipc_events; 273sway_cmd cmd_ipc_events;
diff --git a/include/sway/config.h b/include/sway/config.h
index e63b9895..43ea7778 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -135,6 +135,12 @@ struct seat_attachment_config {
135 // TODO other things are configured here for some reason 135 // TODO other things are configured here for some reason
136}; 136};
137 137
138enum seat_config_allow_constrain {
139 CONSTRAIN_DEFAULT, // the default is currently enabled
140 CONSTRAIN_ENABLE,
141 CONSTRAIN_DISABLE
142};
143
138/** 144/**
139 * Options for multiseat and other misc device configurations 145 * Options for multiseat and other misc device configurations
140 */ 146 */
@@ -143,7 +149,7 @@ struct seat_config {
143 int fallback; // -1 means not set 149 int fallback; // -1 means not set
144 list_t *attachments; // list of seat_attachment configs 150 list_t *attachments; // list of seat_attachment configs
145 int hide_cursor_timeout; 151 int hide_cursor_timeout;
146 bool allow_constrain; 152 enum seat_config_allow_constrain allow_constrain;
147}; 153};
148 154
149enum config_dpms { 155enum config_dpms {
diff --git a/include/swaybar/i3bar.h b/include/swaybar/i3bar.h
index aa4415ff..5b6001ce 100644
--- a/include/swaybar/i3bar.h
+++ b/include/swaybar/i3bar.h
@@ -7,7 +7,7 @@
7struct i3bar_block { 7struct i3bar_block {
8 struct wl_list link; // status_link::blocks 8 struct wl_list link; // status_link::blocks
9 int ref_count; 9 int ref_count;
10 char *full_text, *short_text, *align; 10 char *full_text, *short_text, *align, *min_width_str;
11 bool urgent; 11 bool urgent;
12 uint32_t *color; 12 uint32_t *color;
13 int min_width; 13 int min_width;
diff --git a/sway/commands.c b/sway/commands.c
index 425897fb..dd994fa1 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -81,7 +81,6 @@ static struct cmd_handler handlers[] = {
81 { "no_focus", cmd_no_focus }, 81 { "no_focus", cmd_no_focus },
82 { "output", cmd_output }, 82 { "output", cmd_output },
83 { "popup_during_fullscreen", cmd_popup_during_fullscreen }, 83 { "popup_during_fullscreen", cmd_popup_during_fullscreen },
84 { "pointer_constraint", cmd_pointer_constraint },
85 { "seat", cmd_seat }, 84 { "seat", cmd_seat },
86 { "set", cmd_set }, 85 { "set", cmd_set },
87 { "show_marks", cmd_show_marks }, 86 { "show_marks", cmd_show_marks },
diff --git a/sway/commands/seat.c b/sway/commands/seat.c
index 69000b57..81bb5f5d 100644
--- a/sway/commands/seat.c
+++ b/sway/commands/seat.c
@@ -11,6 +11,7 @@ static struct cmd_handler seat_handlers[] = {
11 { "cursor", seat_cmd_cursor }, 11 { "cursor", seat_cmd_cursor },
12 { "fallback", seat_cmd_fallback }, 12 { "fallback", seat_cmd_fallback },
13 { "hide_cursor", seat_cmd_hide_cursor }, 13 { "hide_cursor", seat_cmd_hide_cursor },
14 { "pointer_constraint", seat_cmd_pointer_constraint },
14}; 15};
15 16
16struct cmd_results *cmd_seat(int argc, char **argv) { 17struct cmd_results *cmd_seat(int argc, char **argv) {
diff --git a/sway/commands/pointer_constraint.c b/sway/commands/seat/pointer_constraint.c
index 2dda0776..3890ebde 100644
--- a/sway/commands/pointer_constraint.c
+++ b/sway/commands/seat/pointer_constraint.c
@@ -12,11 +12,14 @@ enum operation {
12}; 12};
13 13
14// pointer_constraint [enable|disable|escape] 14// pointer_constraint [enable|disable|escape]
15struct cmd_results *cmd_pointer_constraint(int argc, char **argv) { 15struct cmd_results *seat_cmd_pointer_constraint(int argc, char **argv) {
16 struct cmd_results *error = NULL; 16 struct cmd_results *error = NULL;
17 if ((error = checkarg(argc, "pointer_constraint", EXPECTED_EQUAL_TO, 1))) { 17 if ((error = checkarg(argc, "pointer_constraint", EXPECTED_EQUAL_TO, 1))) {
18 return error; 18 return error;
19 } 19 }
20 if (!config->handler_context.seat_config) {
21 return cmd_results_new(CMD_FAILURE, "No seat defined");
22 }
20 23
21 enum operation op; 24 enum operation op;
22 if (strcmp(argv[0], "enable") == 0) { 25 if (strcmp(argv[0], "enable") == 0) {
@@ -33,19 +36,23 @@ struct cmd_results *cmd_pointer_constraint(int argc, char **argv) {
33 return cmd_results_new(CMD_FAILURE, "Can only escape at runtime."); 36 return cmd_results_new(CMD_FAILURE, "Can only escape at runtime.");
34 } 37 }
35 38
36 struct sway_cursor *cursor = config->handler_context.seat->cursor; 39 struct seat_config *seat_config = config->handler_context.seat_config;
37 struct seat_config *seat_config = seat_get_config(cursor->seat);
38 switch (op) { 40 switch (op) {
39 case OP_ENABLE: 41 case OP_ENABLE:
40 seat_config->allow_constrain = true; 42 seat_config->allow_constrain = CONSTRAIN_ENABLE;
41 break; 43 break;
42 case OP_DISABLE: 44 case OP_DISABLE:
43 seat_config->allow_constrain = false; 45 seat_config->allow_constrain = CONSTRAIN_DISABLE;
44 /* fallthrough */ 46 /* fallthrough */
45 case OP_ESCAPE: 47 case OP_ESCAPE:;
46 sway_cursor_constrain(cursor, NULL); 48 bool wildcard = !strcmp(seat_config->name, "*");
49 struct sway_seat *seat = NULL;
50 wl_list_for_each(seat, &server.input->seats, link) {
51 if (wildcard || !strcmp(seat->wlr_seat->name, seat_config->name)) {
52 sway_cursor_constrain(seat->cursor, NULL);
53 }
54 }
47 break; 55 break;
48 } 56 }
49
50 return cmd_results_new(CMD_SUCCESS, NULL); 57 return cmd_results_new(CMD_SUCCESS, NULL);
51} 58}
diff --git a/sway/config/seat.c b/sway/config/seat.c
index 541c4f99..04a44e3a 100644
--- a/sway/config/seat.c
+++ b/sway/config/seat.c
@@ -26,7 +26,7 @@ struct seat_config *new_seat_config(const char* name) {
26 return NULL; 26 return NULL;
27 } 27 }
28 seat->hide_cursor_timeout = -1; 28 seat->hide_cursor_timeout = -1;
29 seat->allow_constrain = true; 29 seat->allow_constrain = CONSTRAIN_DEFAULT;
30 30
31 return seat; 31 return seat;
32} 32}
@@ -143,6 +143,10 @@ void merge_seat_config(struct seat_config *dest, struct seat_config *source) {
143 if (source->hide_cursor_timeout != -1) { 143 if (source->hide_cursor_timeout != -1) {
144 dest->hide_cursor_timeout = source->hide_cursor_timeout; 144 dest->hide_cursor_timeout = source->hide_cursor_timeout;
145 } 145 }
146
147 if (source->allow_constrain != CONSTRAIN_DEFAULT) {
148 dest->allow_constrain = source->allow_constrain;
149 }
146} 150}
147 151
148struct seat_config *copy_seat_config(struct seat_config *seat) { 152struct seat_config *copy_seat_config(struct seat_config *seat) {
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index e8674490..c38d8d3a 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -1459,7 +1459,7 @@ void handle_pointer_constraint(struct wl_listener *listener, void *data) {
1459void sway_cursor_constrain(struct sway_cursor *cursor, 1459void sway_cursor_constrain(struct sway_cursor *cursor,
1460 struct wlr_pointer_constraint_v1 *constraint) { 1460 struct wlr_pointer_constraint_v1 *constraint) {
1461 struct seat_config *config = seat_get_config(cursor->seat); 1461 struct seat_config *config = seat_get_config(cursor->seat);
1462 if (!config->allow_constrain) { 1462 if (config->allow_constrain == CONSTRAIN_DISABLE) {
1463 return; 1463 return;
1464 } 1464 }
1465 1465
diff --git a/sway/meson.build b/sway/meson.build
index b3837e21..293a4ed2 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -75,7 +75,6 @@ sway_sources = files(
75 'commands/nop.c', 75 'commands/nop.c',
76 'commands/output.c', 76 'commands/output.c',
77 'commands/popup_during_fullscreen.c', 77 'commands/popup_during_fullscreen.c',
78 'commands/pointer_constraint.c',
79 'commands/reload.c', 78 'commands/reload.c',
80 'commands/rename.c', 79 'commands/rename.c',
81 'commands/resize.c', 80 'commands/resize.c',
@@ -85,6 +84,7 @@ sway_sources = files(
85 'commands/seat/cursor.c', 84 'commands/seat/cursor.c',
86 'commands/seat/fallback.c', 85 'commands/seat/fallback.c',
87 'commands/seat/hide_cursor.c', 86 'commands/seat/hide_cursor.c',
87 'commands/seat/pointer_constraint.c',
88 'commands/set.c', 88 'commands/set.c',
89 'commands/show_marks.c', 89 'commands/show_marks.c',
90 'commands/smart_borders.c', 90 'commands/smart_borders.c',
diff --git a/sway/sway-bar.5.scd b/sway/sway-bar.5.scd
index 5c8b9417..13827e5e 100644
--- a/sway/sway-bar.5.scd
+++ b/sway/sway-bar.5.scd
@@ -18,7 +18,7 @@ Sway allows configuring swaybar in the sway configuration file.
18 https://i3wm.org/docs/i3bar-protocol.html 18 https://i3wm.org/docs/i3bar-protocol.html
19 19
20 If running this command via IPC, you can disable a running status command by 20 If running this command via IPC, you can disable a running status command by
21 setting the command to a single dash: _swaybar bar bar-0 status_command -_ 21 setting the command to a single dash: _swaybar bar bar-0 status\_command -_
22 22
23*pango_markup* enabled|disabled 23*pango_markup* enabled|disabled
24 Enables or disables pango markup for status lines. This has no effect on 24 Enables or disables pango markup for status lines. This has no effect on
diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd
index 4b14ef14..88b4347a 100644
--- a/sway/sway-input.5.scd
+++ b/sway/sway-input.5.scd
@@ -172,6 +172,11 @@ in their own "seat").
172 disables hiding the cursor. The minimal timeout is 100 and any value less 172 disables hiding the cursor. The minimal timeout is 100 and any value less
173 than that (aside from 0), will be increased to 100. 173 than that (aside from 0), will be increased to 100.
174 174
175*seat* <name> pointer_constraint enable|disable|escape
176 Enables or disables the ability for clients to capture the cursor (enabled
177 by default) for the seat. This is primarily useful for video games. The
178 "escape" command can be used at runtime to escape from a captured client.
179
175# SEE ALSO 180# SEE ALSO
176 181
177*sway*(5) *sway-output*(5) 182*sway*(5) *sway-output*(5)
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index e04c5fbf..fd0a22dc 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -72,7 +72,7 @@ The following commands may only be used in the configuration file.
72 *sway-output*(5) for more information. 72 *sway-output*(5) for more information.
73 73
74 It can be disabled by setting the command to a single dash: 74 It can be disabled by setting the command to a single dash:
75 _swaybg_command -_ 75 _swaybg\_command -_
76 76
77*swaynag_command* <command> 77*swaynag_command* <command>
78 Executes custom command for _swaynag_. Default is _swaynag_. Additional 78 Executes custom command for _swaynag_. Default is _swaynag_. Additional
@@ -82,7 +82,7 @@ The following commands may only be used in the configuration file.
82 results. 82 results.
83 83
84 It can be disabled by setting the command to a single dash: 84 It can be disabled by setting the command to a single dash:
85 _swaynag_command -_ 85 _swaynag\_command -_
86 86
87*xwayland* enable|disable 87*xwayland* enable|disable
88 Enables or disables Xwayland support, which allows X11 applications to be 88 Enables or disables Xwayland support, which allows X11 applications to be
@@ -282,7 +282,7 @@ runtime.
282 282
283 for_window <criteria> move container to output <output> 283 for_window <criteria> move container to output <output>
284 284
285*bindsym* [--release|--locked] [--input-device=<device>] [--no-warn] <key combo> <command> 285*bindsym* [--whole-window] [--border] [--exclude-titlebar] [--release] [--locked] [--input-device=<device>] [--no-warn] <key combo> <command>
286 Binds _key combo_ to execute the sway command _command_ when pressed. You 286 Binds _key combo_ to execute the sway command _command_ when pressed. You
287 may use XKB key names here (*xev*(1) is a good tool for discovering these). 287 may use XKB key names here (*xev*(1) is a good tool for discovering these).
288 With the flag _--release_, the command is executed when the key combo is 288 With the flag _--release_, the command is executed when the key combo is
@@ -294,11 +294,24 @@ runtime.
294 the _--no-warn_ flag. 294 the _--no-warn_ flag.
295 295
296 Mouse buttons can either be specified in the form _button[1-9]_ or by using 296 Mouse buttons can either be specified in the form _button[1-9]_ or by using
297 the name of the event code (ex _BTN_LEFT_ or _BTN_RIGHT_). For the former 297 the name of the event code (ex _BTN\_LEFT_ or _BTN\_RIGHT_). For the former
298 option, the buttons will be mapped to their values in X11 (1=left, 2=middle, 298 option, the buttons will be mapped to their values in X11 (1=left, 2=middle,
299 3=right, 4=scroll up, 5=scroll down, 6=scroll left, 7=scroll right, 8=back, 299 3=right, 4=scroll up, 5=scroll down, 6=scroll left, 7=scroll right, 8=back,
300 9=forward). For the latter option, you can find the event names using 300 9=forward). For the latter option, you can find the event names using
301 _libinput debug-events_. 301 _libinput debug-events_.
302
303 _--whole-window_, _--border_, and _--exclude-titlebar_ are mouse-only options
304 which affect the region in which the mouse bindings can be triggered. By
305 default, mouse bindings are only triggered when over the title bar. With the
306 _--border_ option, the border of the window will be included in this region.
307 With the _--whole-window_ option, the cursor can be anywhere over a window
308 including the title, border, and content. _--exclude-titlebar_ can be used in
309 conjunction with any other option to specify that the titlebar should be
310 excluded from the region of consideration.
311
312 There is currently, however, no way to execute a mouse binding over a layer
313 surface (which includes the background of an empty workspace). This behaviour
314 is carried over from i3.
302 315
303 Example: 316 Example:
304``` 317```
@@ -306,7 +319,7 @@ runtime.
306 bindsym Mod1+Shift+f exec firefox 319 bindsym Mod1+Shift+f exec firefox
307``` 320```
308 321
309 *bindcode* [--release|--locked] [--input-device=<device>] [--no-warn] <code> <command> 322 *bindcode* [--whole-window] [--border] [--exclude-titlebar] [--release] [--locked] [--input-device=<device>] [--no-warn] <code> <command>
310 is also available for binding with key/button codes instead of key/button names. 323 is also available for binding with key/button codes instead of key/button names.
311 324
312*client.<class>* <border> <background> <text> <indicator> <child_border> 325*client.<class>* <border> <background> <text> <indicator> <child_border>
@@ -539,11 +552,6 @@ The default colors are:
539 \* may be used in lieu of a specific output name to configure all outputs. 552 \* may be used in lieu of a specific output name to configure all outputs.
540 A list of output names may be obtained via *swaymsg -t get_outputs*. 553 A list of output names may be obtained via *swaymsg -t get_outputs*.
541 554
542*pointer_constraint* enable|disable|escape
543 Enables or disables the ability for clients to capture the cursor (enabled
544 by default). This is primarily useful for video games. The "escape" command
545 can be used at runtime to escape from a captured client.
546
547*popup_during_fullscreen* smart|ignore|leave_fullscreen 555*popup_during_fullscreen* smart|ignore|leave_fullscreen
548 Determines what to do when a fullscreen view opens a dialog. 556 Determines what to do when a fullscreen view opens a dialog.
549 If _smart_ (the default), the dialog will be displayed. If _ignore_, the 557 If _smart_ (the default), the dialog will be displayed. If _ignore_, the
diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c
index da93a132..43e2fe2d 100644
--- a/swaybar/i3bar.c
+++ b/swaybar/i3bar.c
@@ -21,6 +21,7 @@ void i3bar_block_unref(struct i3bar_block *block) {
21 free(block->full_text); 21 free(block->full_text);
22 free(block->short_text); 22 free(block->short_text);
23 free(block->align); 23 free(block->align);
24 free(block->min_width_str);
24 free(block->name); 25 free(block->name);
25 free(block->instance); 26 free(block->instance);
26 free(block->color); 27 free(block->color);
@@ -78,7 +79,7 @@ static void i3bar_parse_json(struct status_line *status,
78 block->min_width = json_object_get_int(min_width); 79 block->min_width = json_object_get_int(min_width);
79 } else if (type == json_type_string) { 80 } else if (type == json_type_string) {
80 /* the width will be calculated when rendering */ 81 /* the width will be calculated when rendering */
81 block->min_width = 0; 82 block->min_width_str = strdup(json_object_get_string(min_width));
82 } 83 }
83 } 84 }
84 block->align = strdup(align ? json_object_get_string(align) : "left"); 85 block->align = strdup(align ? json_object_get_string(align) : "left");
diff --git a/swaybar/render.c b/swaybar/render.c
index e27f7d4c..116cc595 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -159,6 +159,12 @@ static uint32_t render_status_block(cairo_t *cairo,
159 double ws_vertical_padding = config->status_padding * output->scale; 159 double ws_vertical_padding = config->status_padding * output->scale;
160 160
161 int width = text_width; 161 int width = text_width;
162 if (block->min_width_str) {
163 int w;
164 get_text_size(cairo, config->font, &w, NULL, NULL,
165 output->scale, block->markup, "%s", block->min_width_str);
166 block->min_width = w;
167 }
162 if (width < block->min_width) { 168 if (width < block->min_width) {
163 width = block->min_width; 169 width = block->min_width;
164 } 170 }