feat: add option hotarea_corner

This commit is contained in:
DreamMaoMao 2026-01-27 19:02:16 +08:00
parent 2e6e23633e
commit 30692f6da0
3 changed files with 61 additions and 11 deletions

View file

@ -232,6 +232,7 @@ typedef struct {
int32_t center_when_single_stack;
uint32_t hotarea_size;
uint32_t hotarea_corner;
uint32_t enable_hotarea;
uint32_t ov_tab_mode;
int32_t overviewgappi;
@ -1452,6 +1453,8 @@ void parse_option(Config *config, char *key, char *value) {
config->center_when_single_stack = atoi(value);
} else if (strcmp(key, "hotarea_size") == 0) {
config->hotarea_size = atoi(value);
} else if (strcmp(key, "hotarea_corner") == 0) {
config->hotarea_corner = atoi(value);
} else if (strcmp(key, "enable_hotarea") == 0) {
config->enable_hotarea = atoi(value);
} else if (strcmp(key, "ov_tab_mode") == 0) {
@ -2739,6 +2742,7 @@ void override_config(void) {
// 概述模式设置
hotarea_size = CLAMP_INT(config.hotarea_size, 1, 1000);
hotarea_corner = CLAMP_INT(config.hotarea_corner, 0, 3);
enable_hotarea = CLAMP_INT(config.enable_hotarea, 0, 1);
ov_tab_mode = CLAMP_INT(config.ov_tab_mode, 0, 1);
overviewgappi = CLAMP_INT(config.overviewgappi, 0, 1000);
@ -2901,8 +2905,9 @@ void set_value_default() {
config.numlockon = numlockon; // 是否打开右边小键盘
config.ov_tab_mode = ov_tab_mode; // alt tab切换模式
config.hotarea_size = hotarea_size; // 热区大小,10x10
config.ov_tab_mode = ov_tab_mode; // alt tab切换模式
config.hotarea_size = hotarea_size; // 热区大小,10x10
config.hotarea_corner = hotarea_corner;
config.enable_hotarea = enable_hotarea; // 是否启用鼠标热区
config.smartgaps =
smartgaps; /* 1 means no outer gap when there is only one window */

View file

@ -47,8 +47,9 @@ int32_t log_level = WLR_ERROR;
uint32_t numlockon = 0; // 是否打开右边小键盘
uint32_t capslock = 0; // 是否启用快捷键
uint32_t ov_tab_mode = 0; // alt tab切换模式
uint32_t hotarea_size = 10; // 热区大小,10x10
uint32_t ov_tab_mode = 0; // alt tab切换模式
uint32_t hotarea_size = 10; // 热区大小,10x10
uint32_t hotarea_corner = BOTTOM_LEFT;
uint32_t enable_hotarea = 1; // 是否启用鼠标热区
int32_t smartgaps = 0; /* 1 means no outer gap when there is only one window */
int32_t sloppyfocus = 1; /* focus follows mouse */

View file

@ -143,6 +143,8 @@
#define BAKED_POINTS_COUNT 256
/* enums */
enum { TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT };
enum { VERTICAL, HORIZONTAL };
enum { SWIPE_UP, SWIPE_DOWN, SWIPE_LEFT, SWIPE_RIGHT };
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
@ -1215,17 +1217,59 @@ void toggle_hotarea(int32_t x_root, int32_t y_root) {
if (grabc)
return;
unsigned hx = selmon->m.x + hotarea_size;
unsigned hy = selmon->m.y + selmon->m.height - hotarea_size;
// 根据热角位置计算不同的热区坐标
unsigned hx, hy;
if (enable_hotarea == 1 && selmon->is_in_hotarea == 0 && y_root > hy &&
x_root < hx && x_root >= selmon->m.x &&
y_root <= (selmon->m.y + selmon->m.height)) {
switch (hotarea_corner) {
case BOTTOM_RIGHT: // 右下角
hx = selmon->m.x + selmon->m.width - hotarea_size;
hy = selmon->m.y + selmon->m.height - hotarea_size;
break;
case TOP_LEFT: // 左上角
hx = selmon->m.x + hotarea_size;
hy = selmon->m.y + hotarea_size;
break;
case TOP_RIGHT: // 右上角
hx = selmon->m.x + selmon->m.width - hotarea_size;
hy = selmon->m.y + hotarea_size;
break;
case BOTTOM_LEFT: // 左下角(默认)
default:
hx = selmon->m.x + hotarea_size;
hy = selmon->m.y + selmon->m.height - hotarea_size;
break;
}
// 判断鼠标是否在热区内
int in_hotarea = 0;
switch (hotarea_corner) {
case BOTTOM_RIGHT: // 右下角
in_hotarea = (y_root > hy && x_root > hx &&
x_root <= (selmon->m.x + selmon->m.width) &&
y_root <= (selmon->m.y + selmon->m.height));
break;
case TOP_LEFT: // 左上角
in_hotarea = (y_root < hy && x_root < hx && x_root >= selmon->m.x &&
y_root >= selmon->m.y);
break;
case TOP_RIGHT: // 右上角
in_hotarea = (y_root < hy && x_root > hx &&
x_root <= (selmon->m.x + selmon->m.width) &&
y_root >= selmon->m.y);
break;
case BOTTOM_LEFT: // 左下角(默认)
default:
in_hotarea = (y_root > hy && x_root < hx && x_root >= selmon->m.x &&
y_root <= (selmon->m.y + selmon->m.height));
break;
}
if (enable_hotarea == 1 && selmon->is_in_hotarea == 0 && in_hotarea) {
toggleoverview(&arg);
selmon->is_in_hotarea = 1;
} else if (enable_hotarea == 1 && selmon->is_in_hotarea == 1 &&
(y_root <= hy || x_root >= hx || x_root < selmon->m.x ||
y_root > (selmon->m.y + selmon->m.height))) {
!in_hotarea) {
selmon->is_in_hotarea = 0;
}
}