aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-12-27 00:32:15 -0500
committerLibravatar emersion <contact@emersion.fr>2018-12-30 14:17:24 +0100
commit4d88c957905e7f6b2c8188d218ca22b3e6986fe4 (patch)
tree5f34ad1667607315cfbcb786ce71845a36595d82 /sway
parentVerify seat fallback settings on reload (diff)
downloadsway-4d88c957905e7f6b2c8188d218ca22b3e6986fe4.tar.gz
sway-4d88c957905e7f6b2c8188d218ca22b3e6986fe4.tar.zst
sway-4d88c957905e7f6b2c8188d218ca22b3e6986fe4.zip
hide_cursor: change to a seat subcommand
This makes hide_cursor a seat subcommand, which allows for seat specific timeouts.
Diffstat (limited to 'sway')
-rw-r--r--sway/commands.c1
-rw-r--r--sway/commands/seat.c1
-rw-r--r--sway/commands/seat/hide_cursor.c (renamed from sway/commands/hide_cursor.c)14
-rw-r--r--sway/config.c2
-rw-r--r--sway/config/seat.c5
-rw-r--r--sway/input/cursor.c22
-rw-r--r--sway/input/seat.c14
-rw-r--r--sway/meson.build2
-rw-r--r--sway/sway-input.5.scd6
-rw-r--r--sway/sway.5.scd6
10 files changed, 47 insertions, 26 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 51bfe13a..927434bc 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -71,7 +71,6 @@ static struct cmd_handler handlers[] = {
71 { "force_focus_wrapping", cmd_force_focus_wrapping }, 71 { "force_focus_wrapping", cmd_force_focus_wrapping },
72 { "fullscreen", cmd_fullscreen }, 72 { "fullscreen", cmd_fullscreen },
73 { "gaps", cmd_gaps }, 73 { "gaps", cmd_gaps },
74 { "hide_cursor", cmd_hide_cursor },
75 { "hide_edge_borders", cmd_hide_edge_borders }, 74 { "hide_edge_borders", cmd_hide_edge_borders },
76 { "include", cmd_include }, 75 { "include", cmd_include },
77 { "input", cmd_input }, 76 { "input", cmd_input },
diff --git a/sway/commands/seat.c b/sway/commands/seat.c
index 56acd204..3e7ffed9 100644
--- a/sway/commands/seat.c
+++ b/sway/commands/seat.c
@@ -10,6 +10,7 @@ static struct cmd_handler seat_handlers[] = {
10 { "attach", seat_cmd_attach }, 10 { "attach", seat_cmd_attach },
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}; 14};
14 15
15struct cmd_results *cmd_seat(int argc, char **argv) { 16struct cmd_results *cmd_seat(int argc, char **argv) {
diff --git a/sway/commands/hide_cursor.c b/sway/commands/seat/hide_cursor.c
index 3778fcff..343573b5 100644
--- a/sway/commands/hide_cursor.c
+++ b/sway/commands/seat/hide_cursor.c
@@ -2,15 +2,17 @@
2#include <string.h> 2#include <string.h>
3#include "sway/commands.h" 3#include "sway/commands.h"
4#include "sway/config.h" 4#include "sway/config.h"
5#include "sway/input/cursor.h"
6#include "sway/input/seat.h" 5#include "sway/input/seat.h"
7#include "stringop.h" 6#include "stringop.h"
8 7
9struct cmd_results *cmd_hide_cursor(int argc, char **argv) { 8struct cmd_results *seat_cmd_hide_cursor(int argc, char **argv) {
10 struct cmd_results *error = NULL; 9 struct cmd_results *error = NULL;
11 if ((error = checkarg(argc, "hide_cursor", EXPECTED_EQUAL_TO, 1))) { 10 if ((error = checkarg(argc, "hide_cursor", EXPECTED_EQUAL_TO, 1))) {
12 return error; 11 return error;
13 } 12 }
13 if (!config->handler_context.seat_config) {
14 return cmd_results_new(CMD_FAILURE, "hide_cursor", "No seat defined");
15 }
14 16
15 char *end; 17 char *end;
16 int timeout = strtol(argv[0], &end, 10); 18 int timeout = strtol(argv[0], &end, 10);
@@ -21,13 +23,7 @@ struct cmd_results *cmd_hide_cursor(int argc, char **argv) {
21 if (timeout < 100 && timeout != 0) { 23 if (timeout < 100 && timeout != 0) {
22 timeout = 100; 24 timeout = 100;
23 } 25 }
24 config->hide_cursor_timeout = timeout; 26 config->handler_context.seat_config->hide_cursor_timeout = timeout;
25
26 struct sway_seat *seat;
27 wl_list_for_each(seat, &server.input->seats, link) {
28 wl_event_source_timer_update(seat->cursor->hide_source,
29 config->hide_cursor_timeout);
30 }
31 27
32 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 28 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
33} 29}
diff --git a/sway/config.c b/sway/config.c
index 303774b4..bb7f796d 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -257,8 +257,6 @@ static void config_defaults(struct sway_config *config) {
257 config->hide_edge_borders = E_NONE; 257 config->hide_edge_borders = E_NONE;
258 config->saved_edge_borders = E_NONE; 258 config->saved_edge_borders = E_NONE;
259 259
260 config->hide_cursor_timeout = 0;
261
262 // border colors 260 // border colors
263 set_color(config->border_colors.focused.border, 0x4C7899); 261 set_color(config->border_colors.focused.border, 0x4C7899);
264 set_color(config->border_colors.focused.background, 0x285577); 262 set_color(config->border_colors.focused.background, 0x285577);
diff --git a/sway/config/seat.c b/sway/config/seat.c
index c248990a..d7316c68 100644
--- a/sway/config/seat.c
+++ b/sway/config/seat.c
@@ -25,6 +25,7 @@ struct seat_config *new_seat_config(const char* name) {
25 free(seat); 25 free(seat);
26 return NULL; 26 return NULL;
27 } 27 }
28 seat->hide_cursor_timeout = -1;
28 29
29 return seat; 30 return seat;
30} 31}
@@ -137,6 +138,10 @@ void merge_seat_config(struct seat_config *dest, struct seat_config *source) {
137 } 138 }
138 } 139 }
139 } 140 }
141
142 if (source->hide_cursor_timeout != -1) {
143 dest->hide_cursor_timeout = source->hide_cursor_timeout;
144 }
140} 145}
141 146
142struct seat_config *copy_seat_config(struct seat_config *seat) { 147struct seat_config *copy_seat_config(struct seat_config *seat) {
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 22c5b075..f8302ddf 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -597,9 +597,17 @@ static int hide_notify(void *data) {
597 return 1; 597 return 1;
598} 598}
599 599
600static void handle_activity(struct sway_cursor *cursor) { 600void cursor_handle_activity(struct sway_cursor *cursor) {
601 wl_event_source_timer_update(cursor->hide_source, 601 struct seat_config *sc = seat_get_config(cursor->seat);
602 config->hide_cursor_timeout); 602 if (!sc) {
603 sc = seat_get_config_by_name("*");
604 }
605 int timeout = sc ? sc->hide_cursor_timeout : 0;
606 if (timeout < 0) {
607 timeout = 0;
608 }
609 wl_event_source_timer_update(cursor->hide_source, timeout);
610
603 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat); 611 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
604 if (cursor->hidden) { 612 if (cursor->hidden) {
605 cursor->hidden = false; 613 cursor->hidden = false;
@@ -709,7 +717,7 @@ static void handle_cursor_motion(struct wl_listener *listener, void *data) {
709 wlr_cursor_move(cursor->cursor, event->device, 717 wlr_cursor_move(cursor->cursor, event->device,
710 event->delta_x, event->delta_y); 718 event->delta_x, event->delta_y);
711 cursor_send_pointer_motion(cursor, event->time_msec); 719 cursor_send_pointer_motion(cursor, event->time_msec);
712 handle_activity(cursor); 720 cursor_handle_activity(cursor);
713 transaction_commit_dirty(); 721 transaction_commit_dirty();
714} 722}
715 723
@@ -720,7 +728,7 @@ static void handle_cursor_motion_absolute(
720 struct wlr_event_pointer_motion_absolute *event = data; 728 struct wlr_event_pointer_motion_absolute *event = data;
721 wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y); 729 wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y);
722 cursor_send_pointer_motion(cursor, event->time_msec); 730 cursor_send_pointer_motion(cursor, event->time_msec);
723 handle_activity(cursor); 731 cursor_handle_activity(cursor);
724 transaction_commit_dirty(); 732 transaction_commit_dirty();
725} 733}
726 734
@@ -1009,7 +1017,7 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) {
1009 struct wlr_event_pointer_button *event = data; 1017 struct wlr_event_pointer_button *event = data;
1010 dispatch_cursor_button(cursor, event->device, 1018 dispatch_cursor_button(cursor, event->device,
1011 event->time_msec, event->button, event->state); 1019 event->time_msec, event->button, event->state);
1012 handle_activity(cursor); 1020 cursor_handle_activity(cursor);
1013 transaction_commit_dirty(); 1021 transaction_commit_dirty();
1014} 1022}
1015 1023
@@ -1119,7 +1127,7 @@ static void handle_cursor_axis(struct wl_listener *listener, void *data) {
1119 struct sway_cursor *cursor = wl_container_of(listener, cursor, axis); 1127 struct sway_cursor *cursor = wl_container_of(listener, cursor, axis);
1120 struct wlr_event_pointer_axis *event = data; 1128 struct wlr_event_pointer_axis *event = data;
1121 dispatch_cursor_axis(cursor, event); 1129 dispatch_cursor_axis(cursor, event);
1122 handle_activity(cursor); 1130 cursor_handle_activity(cursor);
1123 transaction_commit_dirty(); 1131 transaction_commit_dirty();
1124} 1132}
1125 1133
diff --git a/sway/input/seat.c b/sway/input/seat.c
index e0f0db1d..fa82c9ce 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -995,6 +995,8 @@ void seat_apply_config(struct sway_seat *seat,
995 wl_list_for_each(seat_device, &seat->devices, link) { 995 wl_list_for_each(seat_device, &seat->devices, link) {
996 seat_configure_device(seat, seat_device->input_device); 996 seat_configure_device(seat, seat_device->input_device);
997 } 997 }
998
999 cursor_handle_activity(seat->cursor);
998} 1000}
999 1001
1000struct seat_config *seat_get_config(struct sway_seat *seat) { 1002struct seat_config *seat_get_config(struct sway_seat *seat) {
@@ -1009,6 +1011,18 @@ struct seat_config *seat_get_config(struct sway_seat *seat) {
1009 return NULL; 1011 return NULL;
1010} 1012}
1011 1013
1014struct seat_config *seat_get_config_by_name(const char *name) {
1015 struct seat_config *seat_config = NULL;
1016 for (int i = 0; i < config->seat_configs->length; ++i ) {
1017 seat_config = config->seat_configs->items[i];
1018 if (strcmp(name, seat_config->name) == 0) {
1019 return seat_config;
1020 }
1021 }
1022
1023 return NULL;
1024}
1025
1012void seat_begin_down(struct sway_seat *seat, struct sway_container *con, 1026void seat_begin_down(struct sway_seat *seat, struct sway_container *con,
1013 uint32_t button, double sx, double sy) { 1027 uint32_t button, double sx, double sy) {
1014 seat->operation = OP_DOWN; 1028 seat->operation = OP_DOWN;
diff --git a/sway/meson.build b/sway/meson.build
index 48ce6b45..6d446acb 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -56,7 +56,6 @@ sway_sources = files(
56 'commands/force_focus_wrapping.c', 56 'commands/force_focus_wrapping.c',
57 'commands/fullscreen.c', 57 'commands/fullscreen.c',
58 'commands/gaps.c', 58 'commands/gaps.c',
59 'commands/hide_cursor.c',
60 'commands/hide_edge_borders.c', 59 'commands/hide_edge_borders.c',
61 'commands/kill.c', 60 'commands/kill.c',
62 'commands/mark.c', 61 'commands/mark.c',
@@ -79,6 +78,7 @@ sway_sources = files(
79 'commands/seat/attach.c', 78 'commands/seat/attach.c',
80 'commands/seat/cursor.c', 79 'commands/seat/cursor.c',
81 'commands/seat/fallback.c', 80 'commands/seat/fallback.c',
81 'commands/seat/hide_cursor.c',
82 'commands/set.c', 82 'commands/set.c',
83 'commands/show_marks.c', 83 'commands/show_marks.c',
84 'commands/smart_borders.c', 84 'commands/smart_borders.c',
diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd
index 45994644..820194a9 100644
--- a/sway/sway-input.5.scd
+++ b/sway/sway-input.5.scd
@@ -145,6 +145,12 @@ in their own "seat").
145 Set this seat as the fallback seat. A fallback seat will attach any device 145 Set this seat as the fallback seat. A fallback seat will attach any device
146 not explicitly attached to another seat (similar to a "default" seat). 146 not explicitly attached to another seat (similar to a "default" seat).
147 147
148*seat* <name> hide\_cursor <timeout>
149 Hides the cursor image after the specified _timeout_ (in milliseconds)
150 has elapsed with no activity on that cursor. A timeout of 0 (default)
151 disables hiding the cursor. The minimal timeout is 100 and any value less
152 than that (aside from 0), will be increased to 100.
153
148# SEE ALSO 154# SEE ALSO
149 155
150*sway*(5) *sway-output*(5) 156*sway*(5) *sway-output*(5)
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index 2befcfac..e6abef56 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -477,12 +477,6 @@ The default colors are:
477 This affects new workspaces only, and is used when the workspace doesn't 477 This affects new workspaces only, and is used when the workspace doesn't
478 have its own gaps settings (see: workspace <ws> gaps ...). 478 have its own gaps settings (see: workspace <ws> gaps ...).
479 479
480*hide\_cursor* <timeout>
481 Hides the cursor image after the specified _timeout_ (in milliseconds)
482 has elapsed with no activity on that cursor. A timeout of 0 (default)
483 disables hiding the cursor. The minimal timeout is 100 and any value less
484 than that (aside from 0), will be increased to 100.
485
486*hide\_edge\_borders* none|vertical|horizontal|both|smart|smart\_no\_gaps 480*hide\_edge\_borders* none|vertical|horizontal|both|smart|smart\_no\_gaps
487 Hides window borders adjacent to the screen edges. Default is _none_. 481 Hides window borders adjacent to the screen edges. Default is _none_.
488 482