diff options
-rw-r--r-- | include/sway/commands.h | 2 | ||||
-rw-r--r-- | include/sway/config.h | 8 | ||||
-rw-r--r-- | sway/commands.c | 1 | ||||
-rw-r--r-- | sway/commands/seat.c | 1 | ||||
-rw-r--r-- | sway/commands/seat/pointer_constraint.c (renamed from sway/commands/pointer_constraint.c) | 23 | ||||
-rw-r--r-- | sway/config/seat.c | 6 | ||||
-rw-r--r-- | sway/input/cursor.c | 2 | ||||
-rw-r--r-- | sway/meson.build | 2 | ||||
-rw-r--r-- | sway/sway-input.5.scd | 5 | ||||
-rw-r--r-- | sway/sway.5.scd | 5 |
10 files changed, 36 insertions, 19 deletions
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; | |||
153 | sway_cmd cmd_no_focus; | 153 | sway_cmd cmd_no_focus; |
154 | sway_cmd cmd_output; | 154 | sway_cmd cmd_output; |
155 | sway_cmd cmd_permit; | 155 | sway_cmd cmd_permit; |
156 | sway_cmd cmd_pointer_constraint; | ||
157 | sway_cmd cmd_popup_during_fullscreen; | 156 | sway_cmd cmd_popup_during_fullscreen; |
158 | sway_cmd cmd_reject; | 157 | sway_cmd cmd_reject; |
159 | sway_cmd cmd_reload; | 158 | sway_cmd cmd_reload; |
@@ -268,6 +267,7 @@ sway_cmd seat_cmd_attach; | |||
268 | sway_cmd seat_cmd_cursor; | 267 | sway_cmd seat_cmd_cursor; |
269 | sway_cmd seat_cmd_fallback; | 268 | sway_cmd seat_cmd_fallback; |
270 | sway_cmd seat_cmd_hide_cursor; | 269 | sway_cmd seat_cmd_hide_cursor; |
270 | sway_cmd seat_cmd_pointer_constraint; | ||
271 | 271 | ||
272 | sway_cmd cmd_ipc_cmd; | 272 | sway_cmd cmd_ipc_cmd; |
273 | sway_cmd cmd_ipc_events; | 273 | sway_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 | ||
138 | enum 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 | ||
149 | enum config_dpms { | 155 | enum config_dpms { |
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 | ||
16 | struct cmd_results *cmd_seat(int argc, char **argv) { | 17 | struct 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] |
15 | struct cmd_results *cmd_pointer_constraint(int argc, char **argv) { | 15 | struct 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 | ||
148 | struct seat_config *copy_seat_config(struct seat_config *seat) { | 152 | struct seat_config *copy_seat_config(struct seat_config *seat) { |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index e51d3e38..106b1910 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -1458,7 +1458,7 @@ void handle_pointer_constraint(struct wl_listener *listener, void *data) { | |||
1458 | void sway_cursor_constrain(struct sway_cursor *cursor, | 1458 | void sway_cursor_constrain(struct sway_cursor *cursor, |
1459 | struct wlr_pointer_constraint_v1 *constraint) { | 1459 | struct wlr_pointer_constraint_v1 *constraint) { |
1460 | struct seat_config *config = seat_get_config(cursor->seat); | 1460 | struct seat_config *config = seat_get_config(cursor->seat); |
1461 | if (!config->allow_constrain) { | 1461 | if (config->allow_constrain == CONSTRAIN_DISABLE) { |
1462 | return; | 1462 | return; |
1463 | } | 1463 | } |
1464 | 1464 | ||
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-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 1ffb0e50..fd0a22dc 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd | |||
@@ -552,11 +552,6 @@ The default colors are: | |||
552 | \* 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. |
553 | 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*. |
554 | 554 | ||
555 | *pointer_constraint* enable|disable|escape | ||
556 | Enables or disables the ability for clients to capture the cursor (enabled | ||
557 | by default). This is primarily useful for video games. The "escape" command | ||
558 | can be used at runtime to escape from a captured client. | ||
559 | |||
560 | *popup_during_fullscreen* smart|ignore|leave_fullscreen | 555 | *popup_during_fullscreen* smart|ignore|leave_fullscreen |
561 | Determines what to do when a fullscreen view opens a dialog. | 556 | Determines what to do when a fullscreen view opens a dialog. |
562 | 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 |