summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/commands.h1
-rw-r--r--include/sway/config.h1
-rw-r--r--include/sway/debug.h8
-rw-r--r--sway/commands/input.c1
-rw-r--r--sway/commands/input/tap_button_map.c33
-rw-r--r--sway/config/input.c4
-rw-r--r--sway/desktop/render.c4
-rw-r--r--sway/desktop/transaction.c16
-rw-r--r--sway/input/input-manager.c6
-rw-r--r--sway/main.c16
-rw-r--r--sway/meson.build1
-rw-r--r--sway/server.c2
-rw-r--r--sway/sway-input.5.scd6
13 files changed, 86 insertions, 13 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 32d6cefd..3ebd0002 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -210,6 +210,7 @@ sway_cmd input_cmd_repeat_rate;
210sway_cmd input_cmd_scroll_button; 210sway_cmd input_cmd_scroll_button;
211sway_cmd input_cmd_scroll_method; 211sway_cmd input_cmd_scroll_method;
212sway_cmd input_cmd_tap; 212sway_cmd input_cmd_tap;
213sway_cmd input_cmd_tap_button_map;
213sway_cmd input_cmd_xkb_layout; 214sway_cmd input_cmd_xkb_layout;
214sway_cmd input_cmd_xkb_model; 215sway_cmd input_cmd_xkb_model;
215sway_cmd input_cmd_xkb_options; 216sway_cmd input_cmd_xkb_options;
diff --git a/include/sway/config.h b/include/sway/config.h
index 75acd4f2..f660a269 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -79,6 +79,7 @@ struct input_config {
79 int scroll_method; 79 int scroll_method;
80 int send_events; 80 int send_events;
81 int tap; 81 int tap;
82 int tap_button_map;
82 83
83 char *xkb_layout; 84 char *xkb_layout;
84 char *xkb_model; 85 char *xkb_model;
diff --git a/include/sway/debug.h b/include/sway/debug.h
index 2430d319..38d4eccd 100644
--- a/include/sway/debug.h
+++ b/include/sway/debug.h
@@ -1,7 +1,15 @@
1#ifndef SWAY_DEBUG_H 1#ifndef SWAY_DEBUG_H
2#define SWAY_DEBUG_H 2#define SWAY_DEBUG_H
3 3
4// Tree
4extern bool enable_debug_tree; 5extern bool enable_debug_tree;
5void update_debug_tree(); 6void update_debug_tree();
6 7
8// Damage
9extern const char *damage_debug;
10
11// Transactions
12extern int txn_timeout_ms;
13extern bool txn_debug;
14
7#endif 15#endif
diff --git a/sway/commands/input.c b/sway/commands/input.c
index e7906b0e..5b203ea0 100644
--- a/sway/commands/input.c
+++ b/sway/commands/input.c
@@ -23,6 +23,7 @@ static struct cmd_handler input_handlers[] = {
23 { "scroll_button", input_cmd_scroll_button }, 23 { "scroll_button", input_cmd_scroll_button },
24 { "scroll_method", input_cmd_scroll_method }, 24 { "scroll_method", input_cmd_scroll_method },
25 { "tap", input_cmd_tap }, 25 { "tap", input_cmd_tap },
26 { "tap_button_map", input_cmd_tap_button_map },
26 { "xkb_layout", input_cmd_xkb_layout }, 27 { "xkb_layout", input_cmd_xkb_layout },
27 { "xkb_model", input_cmd_xkb_model }, 28 { "xkb_model", input_cmd_xkb_model },
28 { "xkb_options", input_cmd_xkb_options }, 29 { "xkb_options", input_cmd_xkb_options },
diff --git a/sway/commands/input/tap_button_map.c b/sway/commands/input/tap_button_map.c
new file mode 100644
index 00000000..bdbba472
--- /dev/null
+++ b/sway/commands/input/tap_button_map.c
@@ -0,0 +1,33 @@
1#include <string.h>
2#include <strings.h>
3#include "sway/config.h"
4#include "sway/commands.h"
5#include "sway/input/input-manager.h"
6
7struct cmd_results *input_cmd_tap_button_map(int argc, char **argv) {
8 struct cmd_results *error = NULL;
9 if ((error = checkarg(argc, "tap_button_map", EXPECTED_AT_LEAST, 1))) {
10 return error;
11 }
12 struct input_config *current_input_config =
13 config->handler_context.input_config;
14 if (!current_input_config) {
15 return cmd_results_new(CMD_FAILURE, "tap_button_map",
16 "No input device defined.");
17 }
18 struct input_config *new_config =
19 new_input_config(current_input_config->identifier);
20
21 if (strcasecmp(argv[0], "lrm") == 0) {
22 new_config->tap_button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
23 } else if (strcasecmp(argv[0], "lmr") == 0) {
24 new_config->tap_button_map = LIBINPUT_CONFIG_TAP_MAP_LMR;
25 } else {
26 free_input_config(new_config);
27 return cmd_results_new(CMD_INVALID, "tap_button_map",
28 "Expected 'tap_button_map <lrm|lmr>'");
29 }
30
31 apply_input_config(new_config);
32 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
33}
diff --git a/sway/config/input.c b/sway/config/input.c
index cbd7d5f0..8d687a6d 100644
--- a/sway/config/input.c
+++ b/sway/config/input.c
@@ -19,6 +19,7 @@ struct input_config *new_input_config(const char* identifier) {
19 } 19 }
20 20
21 input->tap = INT_MIN; 21 input->tap = INT_MIN;
22 input->tap_button_map = INT_MIN;
22 input->drag_lock = INT_MIN; 23 input->drag_lock = INT_MIN;
23 input->dwt = INT_MIN; 24 input->dwt = INT_MIN;
24 input->send_events = INT_MIN; 25 input->send_events = INT_MIN;
@@ -80,6 +81,9 @@ void merge_input_config(struct input_config *dst, struct input_config *src) {
80 if (src->tap != INT_MIN) { 81 if (src->tap != INT_MIN) {
81 dst->tap = src->tap; 82 dst->tap = src->tap;
82 } 83 }
84 if (src->tap_button_map != INT_MIN) {
85 dst->tap_button_map = src->tap_button_map;
86 }
83 if (src->xkb_layout) { 87 if (src->xkb_layout) {
84 free(dst->xkb_layout); 88 free(dst->xkb_layout);
85 dst->xkb_layout = strdup(src->xkb_layout); 89 dst->xkb_layout = strdup(src->xkb_layout);
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index b370f8a2..4bfc573b 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -15,6 +15,7 @@
15#include <wlr/util/region.h> 15#include <wlr/util/region.h>
16#include "log.h" 16#include "log.h"
17#include "sway/config.h" 17#include "sway/config.h"
18#include "sway/debug.h"
18#include "sway/input/input-manager.h" 19#include "sway/input/input-manager.h"
19#include "sway/input/seat.h" 20#include "sway/input/seat.h"
20#include "sway/layers.h" 21#include "sway/layers.h"
@@ -786,6 +787,8 @@ static void render_floating(struct sway_output *soutput,
786 } 787 }
787} 788}
788 789
790const char *damage_debug = NULL;
791
789void output_render(struct sway_output *output, struct timespec *when, 792void output_render(struct sway_output *output, struct timespec *when,
790 pixman_region32_t *damage) { 793 pixman_region32_t *damage) {
791 struct wlr_output *wlr_output = output->wlr_output; 794 struct wlr_output *wlr_output = output->wlr_output;
@@ -805,7 +808,6 @@ void output_render(struct sway_output *output, struct timespec *when,
805 goto renderer_end; 808 goto renderer_end;
806 } 809 }
807 810
808 const char *damage_debug = getenv("SWAY_DAMAGE_DEBUG");
809 if (damage_debug != NULL) { 811 if (damage_debug != NULL) {
810 if (strcmp(damage_debug, "highlight") == 0) { 812 if (strcmp(damage_debug, "highlight") == 0) {
811 wlr_renderer_clear(renderer, (float[]){1, 1, 0, 1}); 813 wlr_renderer_clear(renderer, (float[]){1, 1, 0, 1});
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index e8222b32..0ae042db 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -19,14 +19,14 @@
19 * How long we should wait for views to respond to the configure before giving 19 * How long we should wait for views to respond to the configure before giving
20 * up and applying the transaction anyway. 20 * up and applying the transaction anyway.
21 */ 21 */
22#define TIMEOUT_MS 200 22int txn_timeout_ms = 200;
23 23
24/** 24/**
25 * If enabled, sway will always wait for the transaction timeout before 25 * If enabled, sway will always wait for the transaction timeout before
26 * applying it, rather than applying it when the views are ready. This allows us 26 * applying it, rather than applying it when the views are ready. This allows us
27 * to observe the rendered state while a transaction is in progress. 27 * to observe the rendered state while a transaction is in progress.
28 */ 28 */
29#define TRANSACTION_DEBUG false 29bool txn_debug = false;
30 30
31struct sway_transaction { 31struct sway_transaction {
32 struct wl_event_source *timer; 32 struct wl_event_source *timer;
@@ -315,7 +315,7 @@ static void transaction_commit(struct sway_transaction *transaction) {
315 // Set up a timer which the views must respond within 315 // Set up a timer which the views must respond within
316 transaction->timer = wl_event_loop_add_timer(server.wl_event_loop, 316 transaction->timer = wl_event_loop_add_timer(server.wl_event_loop,
317 handle_timeout, transaction); 317 handle_timeout, transaction);
318 wl_event_source_timer_update(transaction->timer, TIMEOUT_MS); 318 wl_event_source_timer_update(transaction->timer, txn_timeout_ms);
319 } 319 }
320 320
321 // The debug tree shows the pending/live tree. Here is a good place to 321 // The debug tree shows the pending/live tree. Here is a good place to
@@ -346,11 +346,11 @@ static void set_instruction_ready(
346 // If all views are ready, apply the transaction. 346 // If all views are ready, apply the transaction.
347 // If the transaction has timed out then its num_waiting will be 0 already. 347 // If the transaction has timed out then its num_waiting will be 0 already.
348 if (transaction->num_waiting > 0 && --transaction->num_waiting == 0) { 348 if (transaction->num_waiting > 0 && --transaction->num_waiting == 0) {
349#if !TRANSACTION_DEBUG 349 if (!txn_debug) {
350 wlr_log(WLR_DEBUG, "Transaction %p is ready", transaction); 350 wlr_log(WLR_DEBUG, "Transaction %p is ready", transaction);
351 wl_event_source_timer_update(transaction->timer, 0); 351 wl_event_source_timer_update(transaction->timer, 0);
352 transaction_progress_queue(); 352 transaction_progress_queue();
353#endif 353 }
354 } 354 }
355} 355}
356 356
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index b18989d0..0b7cb766 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -181,6 +181,12 @@ static void input_manager_libinput_config_pointer(
181 ic->identifier, ic->tap); 181 ic->identifier, ic->tap);
182 libinput_device_config_tap_set_enabled(libinput_device, ic->tap); 182 libinput_device_config_tap_set_enabled(libinput_device, ic->tap);
183 } 183 }
184 if (ic->tap_button_map != INT_MIN) {
185 wlr_log(WLR_DEBUG, "libinput_config_pointer(%s) tap_set_button_map(%d)",
186 ic->identifier, ic->tap);
187 libinput_device_config_tap_set_button_map(libinput_device,
188 ic->tap_button_map);
189 }
184} 190}
185 191
186static void handle_device_destroy(struct wl_listener *listener, void *data) { 192static void handle_device_destroy(struct wl_listener *listener, void *data) {
diff --git a/sway/main.c b/sway/main.c
index c6453226..1d772b48 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -251,6 +251,18 @@ static void drop_permissions(bool keep_caps) {
251#endif 251#endif
252} 252}
253 253
254void enable_debug_flag(const char *flag) {
255 if (strcmp(flag, "render-tree") == 0) {
256 enable_debug_tree = true;
257 } else if (strncmp(flag, "damage=", 7) == 0) {
258 damage_debug = &flag[7];
259 } else if (strcmp(flag, "txn-debug") == 0) {
260 txn_debug = true;
261 } else if (strncmp(flag, "txn-timeout=", 12) == 0) {
262 txn_timeout_ms = atoi(&flag[12]);
263 }
264}
265
254int main(int argc, char **argv) { 266int main(int argc, char **argv) {
255 static int verbose = 0, debug = 0, validate = 0; 267 static int verbose = 0, debug = 0, validate = 0;
256 268
@@ -290,7 +302,7 @@ int main(int argc, char **argv) {
290 int c; 302 int c;
291 while (1) { 303 while (1) {
292 int option_index = 0; 304 int option_index = 0;
293 c = getopt_long(argc, argv, "hCdDvVc:", long_options, &option_index); 305 c = getopt_long(argc, argv, "hCdD:vVc:", long_options, &option_index);
294 if (c == -1) { 306 if (c == -1) {
295 break; 307 break;
296 } 308 }
@@ -309,7 +321,7 @@ int main(int argc, char **argv) {
309 debug = 1; 321 debug = 1;
310 break; 322 break;
311 case 'D': // extended debug options 323 case 'D': // extended debug options
312 enable_debug_tree = true; 324 enable_debug_flag(optarg);
313 break; 325 break;
314 case 'v': // version 326 case 'v': // version
315 fprintf(stdout, "sway version " SWAY_VERSION "\n"); 327 fprintf(stdout, "sway version " SWAY_VERSION "\n");
diff --git a/sway/meson.build b/sway/meson.build
index 6fc78db3..f878450d 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -121,6 +121,7 @@ sway_sources = files(
121 'commands/input/scroll_button.c', 121 'commands/input/scroll_button.c',
122 'commands/input/scroll_method.c', 122 'commands/input/scroll_method.c',
123 'commands/input/tap.c', 123 'commands/input/tap.c',
124 'commands/input/tap_button_map.c',
124 'commands/input/xkb_layout.c', 125 'commands/input/xkb_layout.c',
125 'commands/input/xkb_model.c', 126 'commands/input/xkb_model.c',
126 'commands/input/xkb_options.c', 127 'commands/input/xkb_options.c',
diff --git a/sway/server.c b/sway/server.c
index 8566d512..f904b177 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -14,7 +14,6 @@
14#include <wlr/types/wlr_linux_dmabuf.h> 14#include <wlr/types/wlr_linux_dmabuf.h>
15#include <wlr/types/wlr_primary_selection.h> 15#include <wlr/types/wlr_primary_selection.h>
16#include <wlr/types/wlr_screencopy_v1.h> 16#include <wlr/types/wlr_screencopy_v1.h>
17#include <wlr/types/wlr_screenshooter.h>
18#include <wlr/types/wlr_server_decoration.h> 17#include <wlr/types/wlr_server_decoration.h>
19#include <wlr/types/wlr_xcursor_manager.h> 18#include <wlr/types/wlr_xcursor_manager.h>
20#include <wlr/types/wlr_xdg_output.h> 19#include <wlr/types/wlr_xdg_output.h>
@@ -53,7 +52,6 @@ bool server_init(struct sway_server *server) {
53 server->data_device_manager = 52 server->data_device_manager =
54 wlr_data_device_manager_create(server->wl_display); 53 wlr_data_device_manager_create(server->wl_display);
55 54
56 wlr_screenshooter_create(server->wl_display);
57 wlr_gamma_control_manager_create(server->wl_display); 55 wlr_gamma_control_manager_create(server->wl_display);
58 wlr_primary_selection_device_manager_create(server->wl_display); 56 wlr_primary_selection_device_manager_create(server->wl_display);
59 57
diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd
index 4bc66394..b6391431 100644
--- a/sway/sway-input.5.scd
+++ b/sway/sway-input.5.scd
@@ -100,6 +100,12 @@ For more information on these xkb configuration options, see
100*input* <identifier> tap enabled|disabled 100*input* <identifier> tap enabled|disabled
101 Enables or disables tap for specified input device. 101 Enables or disables tap for specified input device.
102 102
103*input* <identifier> tap_button_map lrm|lmr
104 Specifies which button mapping to use for tapping. _lrm_ treats 1 finger as
105 left click, 2 fingers as right click, and 3 fingers as middle click. _lmr_
106 treats 1 finger as left click, 2 fingers as middle click, and 3 fingers as
107 right click.
108
103## SEAT CONFIGURATION 109## SEAT CONFIGURATION
104 110
105Configure options for multiseat mode. sway-seat commands must be used inside a 111Configure options for multiseat mode. sway-seat commands must be used inside a