mirror of
https://github.com/swaywm/sway.git
synced 2024-11-29 11:21:28 +00:00
hide_cursor: change to a seat subcommand
This makes hide_cursor a seat subcommand, which allows for seat specific timeouts.
This commit is contained in:
parent
09bb71f650
commit
4d88c95790
|
@ -133,7 +133,6 @@ sway_cmd cmd_force_display_urgency_hint;
|
|||
sway_cmd cmd_force_focus_wrapping;
|
||||
sway_cmd cmd_fullscreen;
|
||||
sway_cmd cmd_gaps;
|
||||
sway_cmd cmd_hide_cursor;
|
||||
sway_cmd cmd_hide_edge_borders;
|
||||
sway_cmd cmd_include;
|
||||
sway_cmd cmd_input;
|
||||
|
@ -260,8 +259,9 @@ sway_cmd output_cmd_scale;
|
|||
sway_cmd output_cmd_transform;
|
||||
|
||||
sway_cmd seat_cmd_attach;
|
||||
sway_cmd seat_cmd_fallback;
|
||||
sway_cmd seat_cmd_cursor;
|
||||
sway_cmd seat_cmd_fallback;
|
||||
sway_cmd seat_cmd_hide_cursor;
|
||||
|
||||
sway_cmd cmd_ipc_cmd;
|
||||
sway_cmd cmd_ipc_events;
|
||||
|
|
|
@ -140,6 +140,7 @@ struct seat_config {
|
|||
char *name;
|
||||
int fallback; // -1 means not set
|
||||
list_t *attachments; // list of seat_attachment configs
|
||||
int hide_cursor_timeout;
|
||||
};
|
||||
|
||||
enum config_dpms {
|
||||
|
@ -436,8 +437,6 @@ struct sway_config {
|
|||
enum edge_border_types hide_edge_borders;
|
||||
enum edge_border_types saved_edge_borders;
|
||||
|
||||
int hide_cursor_timeout;
|
||||
|
||||
// border colors
|
||||
struct {
|
||||
struct border_colors focused;
|
||||
|
|
|
@ -60,6 +60,8 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat);
|
|||
*/
|
||||
void cursor_rebase(struct sway_cursor *cursor);
|
||||
|
||||
void cursor_handle_activity(struct sway_cursor *cursor);
|
||||
|
||||
/**
|
||||
* Like cursor_rebase, but also allows focus to change when the cursor enters a
|
||||
* new container.
|
||||
|
|
|
@ -174,6 +174,8 @@ void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config);
|
|||
|
||||
struct seat_config *seat_get_config(struct sway_seat *seat);
|
||||
|
||||
struct seat_config *seat_get_config_by_name(const char *name);
|
||||
|
||||
bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface);
|
||||
|
||||
void drag_icon_update_position(struct sway_drag_icon *icon);
|
||||
|
|
|
@ -71,7 +71,6 @@ static struct cmd_handler handlers[] = {
|
|||
{ "force_focus_wrapping", cmd_force_focus_wrapping },
|
||||
{ "fullscreen", cmd_fullscreen },
|
||||
{ "gaps", cmd_gaps },
|
||||
{ "hide_cursor", cmd_hide_cursor },
|
||||
{ "hide_edge_borders", cmd_hide_edge_borders },
|
||||
{ "include", cmd_include },
|
||||
{ "input", cmd_input },
|
||||
|
|
|
@ -10,6 +10,7 @@ static struct cmd_handler seat_handlers[] = {
|
|||
{ "attach", seat_cmd_attach },
|
||||
{ "cursor", seat_cmd_cursor },
|
||||
{ "fallback", seat_cmd_fallback },
|
||||
{ "hide_cursor", seat_cmd_hide_cursor },
|
||||
};
|
||||
|
||||
struct cmd_results *cmd_seat(int argc, char **argv) {
|
||||
|
|
|
@ -2,15 +2,17 @@
|
|||
#include <string.h>
|
||||
#include "sway/commands.h"
|
||||
#include "sway/config.h"
|
||||
#include "sway/input/cursor.h"
|
||||
#include "sway/input/seat.h"
|
||||
#include "stringop.h"
|
||||
|
||||
struct cmd_results *cmd_hide_cursor(int argc, char **argv) {
|
||||
struct cmd_results *seat_cmd_hide_cursor(int argc, char **argv) {
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "hide_cursor", EXPECTED_EQUAL_TO, 1))) {
|
||||
return error;
|
||||
}
|
||||
if (!config->handler_context.seat_config) {
|
||||
return cmd_results_new(CMD_FAILURE, "hide_cursor", "No seat defined");
|
||||
}
|
||||
|
||||
char *end;
|
||||
int timeout = strtol(argv[0], &end, 10);
|
||||
|
@ -21,13 +23,7 @@ struct cmd_results *cmd_hide_cursor(int argc, char **argv) {
|
|||
if (timeout < 100 && timeout != 0) {
|
||||
timeout = 100;
|
||||
}
|
||||
config->hide_cursor_timeout = timeout;
|
||||
|
||||
struct sway_seat *seat;
|
||||
wl_list_for_each(seat, &server.input->seats, link) {
|
||||
wl_event_source_timer_update(seat->cursor->hide_source,
|
||||
config->hide_cursor_timeout);
|
||||
}
|
||||
config->handler_context.seat_config->hide_cursor_timeout = timeout;
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||
}
|
|
@ -257,8 +257,6 @@ static void config_defaults(struct sway_config *config) {
|
|||
config->hide_edge_borders = E_NONE;
|
||||
config->saved_edge_borders = E_NONE;
|
||||
|
||||
config->hide_cursor_timeout = 0;
|
||||
|
||||
// border colors
|
||||
set_color(config->border_colors.focused.border, 0x4C7899);
|
||||
set_color(config->border_colors.focused.background, 0x285577);
|
||||
|
|
|
@ -25,6 +25,7 @@ struct seat_config *new_seat_config(const char* name) {
|
|||
free(seat);
|
||||
return NULL;
|
||||
}
|
||||
seat->hide_cursor_timeout = -1;
|
||||
|
||||
return seat;
|
||||
}
|
||||
|
@ -137,6 +138,10 @@ void merge_seat_config(struct seat_config *dest, struct seat_config *source) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (source->hide_cursor_timeout != -1) {
|
||||
dest->hide_cursor_timeout = source->hide_cursor_timeout;
|
||||
}
|
||||
}
|
||||
|
||||
struct seat_config *copy_seat_config(struct seat_config *seat) {
|
||||
|
|
|
@ -597,9 +597,17 @@ static int hide_notify(void *data) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void handle_activity(struct sway_cursor *cursor) {
|
||||
wl_event_source_timer_update(cursor->hide_source,
|
||||
config->hide_cursor_timeout);
|
||||
void cursor_handle_activity(struct sway_cursor *cursor) {
|
||||
struct seat_config *sc = seat_get_config(cursor->seat);
|
||||
if (!sc) {
|
||||
sc = seat_get_config_by_name("*");
|
||||
}
|
||||
int timeout = sc ? sc->hide_cursor_timeout : 0;
|
||||
if (timeout < 0) {
|
||||
timeout = 0;
|
||||
}
|
||||
wl_event_source_timer_update(cursor->hide_source, timeout);
|
||||
|
||||
wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
|
||||
if (cursor->hidden) {
|
||||
cursor->hidden = false;
|
||||
|
@ -709,7 +717,7 @@ static void handle_cursor_motion(struct wl_listener *listener, void *data) {
|
|||
wlr_cursor_move(cursor->cursor, event->device,
|
||||
event->delta_x, event->delta_y);
|
||||
cursor_send_pointer_motion(cursor, event->time_msec);
|
||||
handle_activity(cursor);
|
||||
cursor_handle_activity(cursor);
|
||||
transaction_commit_dirty();
|
||||
}
|
||||
|
||||
|
@ -720,7 +728,7 @@ static void handle_cursor_motion_absolute(
|
|||
struct wlr_event_pointer_motion_absolute *event = data;
|
||||
wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y);
|
||||
cursor_send_pointer_motion(cursor, event->time_msec);
|
||||
handle_activity(cursor);
|
||||
cursor_handle_activity(cursor);
|
||||
transaction_commit_dirty();
|
||||
}
|
||||
|
||||
|
@ -1009,7 +1017,7 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) {
|
|||
struct wlr_event_pointer_button *event = data;
|
||||
dispatch_cursor_button(cursor, event->device,
|
||||
event->time_msec, event->button, event->state);
|
||||
handle_activity(cursor);
|
||||
cursor_handle_activity(cursor);
|
||||
transaction_commit_dirty();
|
||||
}
|
||||
|
||||
|
@ -1119,7 +1127,7 @@ static void handle_cursor_axis(struct wl_listener *listener, void *data) {
|
|||
struct sway_cursor *cursor = wl_container_of(listener, cursor, axis);
|
||||
struct wlr_event_pointer_axis *event = data;
|
||||
dispatch_cursor_axis(cursor, event);
|
||||
handle_activity(cursor);
|
||||
cursor_handle_activity(cursor);
|
||||
transaction_commit_dirty();
|
||||
}
|
||||
|
||||
|
|
|
@ -995,6 +995,8 @@ void seat_apply_config(struct sway_seat *seat,
|
|||
wl_list_for_each(seat_device, &seat->devices, link) {
|
||||
seat_configure_device(seat, seat_device->input_device);
|
||||
}
|
||||
|
||||
cursor_handle_activity(seat->cursor);
|
||||
}
|
||||
|
||||
struct seat_config *seat_get_config(struct sway_seat *seat) {
|
||||
|
@ -1009,6 +1011,18 @@ struct seat_config *seat_get_config(struct sway_seat *seat) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct seat_config *seat_get_config_by_name(const char *name) {
|
||||
struct seat_config *seat_config = NULL;
|
||||
for (int i = 0; i < config->seat_configs->length; ++i ) {
|
||||
seat_config = config->seat_configs->items[i];
|
||||
if (strcmp(name, seat_config->name) == 0) {
|
||||
return seat_config;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void seat_begin_down(struct sway_seat *seat, struct sway_container *con,
|
||||
uint32_t button, double sx, double sy) {
|
||||
seat->operation = OP_DOWN;
|
||||
|
|
|
@ -56,7 +56,6 @@ sway_sources = files(
|
|||
'commands/force_focus_wrapping.c',
|
||||
'commands/fullscreen.c',
|
||||
'commands/gaps.c',
|
||||
'commands/hide_cursor.c',
|
||||
'commands/hide_edge_borders.c',
|
||||
'commands/kill.c',
|
||||
'commands/mark.c',
|
||||
|
@ -79,6 +78,7 @@ sway_sources = files(
|
|||
'commands/seat/attach.c',
|
||||
'commands/seat/cursor.c',
|
||||
'commands/seat/fallback.c',
|
||||
'commands/seat/hide_cursor.c',
|
||||
'commands/set.c',
|
||||
'commands/show_marks.c',
|
||||
'commands/smart_borders.c',
|
||||
|
|
|
@ -145,6 +145,12 @@ in their own "seat").
|
|||
Set this seat as the fallback seat. A fallback seat will attach any device
|
||||
not explicitly attached to another seat (similar to a "default" seat).
|
||||
|
||||
*seat* <name> hide\_cursor <timeout>
|
||||
Hides the cursor image after the specified _timeout_ (in milliseconds)
|
||||
has elapsed with no activity on that cursor. A timeout of 0 (default)
|
||||
disables hiding the cursor. The minimal timeout is 100 and any value less
|
||||
than that (aside from 0), will be increased to 100.
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
*sway*(5) *sway-output*(5)
|
||||
|
|
|
@ -477,12 +477,6 @@ The default colors are:
|
|||
This affects new workspaces only, and is used when the workspace doesn't
|
||||
have its own gaps settings (see: workspace <ws> gaps ...).
|
||||
|
||||
*hide\_cursor* <timeout>
|
||||
Hides the cursor image after the specified _timeout_ (in milliseconds)
|
||||
has elapsed with no activity on that cursor. A timeout of 0 (default)
|
||||
disables hiding the cursor. The minimal timeout is 100 and any value less
|
||||
than that (aside from 0), will be increased to 100.
|
||||
|
||||
*hide\_edge\_borders* none|vertical|horizontal|both|smart|smart\_no\_gaps
|
||||
Hides window borders adjacent to the screen edges. Default is _none_.
|
||||
|
||||
|
|
Loading…
Reference in a new issue