diff --git a/docs/configuration/miscellaneous.md b/docs/configuration/miscellaneous.md index 1001c4c1..cd8d167d 100644 --- a/docs/configuration/miscellaneous.md +++ b/docs/configuration/miscellaneous.md @@ -21,6 +21,7 @@ description: Advanced settings for XWayland, focus behavior, and system integrat | `sloppyfocus` | `1` | Focus follows the mouse cursor. | | `warpcursor` | `1` | Warp the cursor to the center of the window when focus changes via keyboard. | | `cursor_hide_timeout` | `0` | Hide the cursor after `N` seconds of inactivity (`0` to disable). | +| `cursor_hide_on_keypress` | `0` | Hide the cursor on keypress. | | `drag_tile_to_tile` | `0` | Allow dragging a tiled window onto another to swap their positions. | | `drag_tile_small` | `1` | Allow dragging a tiled window temporarily to small size.| | `drag_corner` | `3` | Corner for drag-to-tile detection (0: none, 1–3: corners, 4: auto-detect). | @@ -48,4 +49,4 @@ description: Advanced settings for XWayland, focus behavior, and system integrat | `idleinhibit_ignore_visible` | `0` | Allow invisible clients (e.g., background audio players) to inhibit idle. | | `tag_carousel` | `0` | Enable tag carousel (cycling through tags). | | `drag_tile_refresh_interval` | `8.0` | Interval (1.0–16.0) to refresh tiled window resize during drag. Too small may cause application lag. | -| `drag_floating_refresh_interval` | `8.0` | Interval (1.0–16.0) to refresh floating window resize during drag. Too small may cause application lag. | \ No newline at end of file +| `drag_floating_refresh_interval` | `8.0` | Interval (1.0–16.0) to refresh floating window resize during drag. Too small may cause application lag. | diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 5379ddca..72196c5f 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -261,6 +261,7 @@ typedef struct { int32_t overviewgappi; int32_t overviewgappo; uint32_t cursor_hide_timeout; + uint32_t cursor_hide_on_keypress; uint32_t axis_bind_apply_timeout; uint32_t focus_on_activate; @@ -1714,6 +1715,8 @@ bool parse_option(Config *config, char *key, char *value) { config->overviewgappo = atoi(value); } else if (strcmp(key, "cursor_hide_timeout") == 0) { config->cursor_hide_timeout = atoi(value); + } else if (strcmp(key, "cursor_hide_on_keypress") == 0) { + config->cursor_hide_on_keypress = atoi(value); } else if (strcmp(key, "axis_bind_apply_timeout") == 0) { config->axis_bind_apply_timeout = atoi(value); } else if (strcmp(key, "focus_on_activate") == 0) { @@ -3346,6 +3349,8 @@ void override_config(void) { CLAMP_INT(config.no_radius_when_single, 0, 1); config.cursor_hide_timeout = CLAMP_INT(config.cursor_hide_timeout, 0, 36000); + config.cursor_hide_on_keypress = + CLAMP_INT(config.cursor_hide_on_keypress, 0, 1); config.single_scratchpad = CLAMP_INT(config.single_scratchpad, 0, 1); config.repeat_rate = CLAMP_INT(config.repeat_rate, 1, 1000); config.repeat_delay = CLAMP_INT(config.repeat_delay, 1, 20000); @@ -3507,6 +3512,7 @@ void set_value_default() { config.overviewgappi = 5; config.overviewgappo = 30; config.cursor_hide_timeout = 0; + config.cursor_hide_on_keypress = 0; config.warpcursor = 1; config.drag_corner = 3; diff --git a/src/mango.c b/src/mango.c index 268ab33f..ee64a551 100644 --- a/src/mango.c +++ b/src/mango.c @@ -4205,6 +4205,11 @@ void keypress(struct wl_listener *listener, void *data) { } } + if (config.cursor_hide_on_keypress && !cursor_hidden && + event->state == WL_KEYBOARD_KEY_STATE_PRESSED) { + hidecursor(NULL); + } + /* On _press_ if there is no active screen locker, * attempt to process a compositor keybinding. */ for (i = 0; i < nsyms; i++)