Compare commits

...

37 Commits

Author SHA1 Message Date
DreamMaoMao
2f9cabe4b2 fix: sloppyfocus not work when move cursor slowly 2025-11-27 22:40:41 +08:00
DreamMaoMao
e2ee985b8f bump version to 0.10.6 2025-11-26 10:09:06 +08:00
DreamMaoMao
4280f8e0bf Merge pull request #442 from xdavidel/fix_nixos_portals
add portals.conf file
2025-11-24 11:43:14 +08:00
David Delarosa
c004f7460c nix: add portals.conf file 2025-11-24 11:43:14 +08:00
DreamMaoMao
03ee277ef6 opt: allow init focus to on-demand-focus layer 2025-11-21 14:50:27 +08:00
DreamMaoMao
a0824c05df opt: optimize scroll judge when open new client 2025-11-20 22:47:12 +08:00
DreamMaoMao
e7cb4f77f3 fix: wrong scroll judge when disable animaitons 2025-11-20 21:21:29 +08:00
DreamMaoMao
e22cf99e74 feat: support relative path for source keyword 2025-11-20 10:34:32 +08:00
DreamMaoMao
8e4d3b7aac update readme 2025-11-19 12:45:04 +08:00
DreamMaoMao
58d5938e14 opt: support hot reload cursor config 2025-11-19 12:41:03 +08:00
DreamMaoMao
4fda32bf1f Merge pull request #406 from jorritvanderheide/main
fix: nixos example
2025-11-19 12:41:03 +08:00
DreamMaoMao
d941e0078e fix: fullscreen and maximize window overflow screen 2025-11-19 12:41:03 +08:00
Jorrit van der Heide
9c8f9e3b38 fix: nixos example 2025-11-19 12:41:03 +08:00
DreamMaoMao
cdcc64ab5f feat: support scroll maximize and fullscreen window 2025-11-19 12:41:03 +08:00
DreamMaoMao
ecab47fe92 update readme 2025-11-19 12:41:03 +08:00
DreamMaoMao
fce47b37d9 opt: optimize init focus for x11 window 2025-11-19 12:41:03 +08:00
DreamMaoMao
f2b9835243 opt: remove useless code 2025-11-19 12:41:03 +08:00
DreamMaoMao
407c9d74a4 feat: add windowrule option scroller_proportion_single 2025-11-19 12:41:03 +08:00
DreamMaoMao
8875156760 feat: support nofucs rule for some special window 2025-11-19 12:41:03 +08:00
DreamMaoMao
514c916678 opt: optimize code struct 2025-11-19 12:41:03 +08:00
DreamMaoMao
f542d5d5e6 opt: disable switch proportion action in some case 2025-11-19 12:41:03 +08:00
DreamMaoMao
d85f4375c8 fix: fix border color change when swithc mon focus 2025-11-19 12:41:03 +08:00
DreamMaoMao
33a0fe2485 opt: not resizewin in overview 2025-11-19 12:41:03 +08:00
DreamMaoMao
16296898ce fix: tagrule not apply correctly 2025-11-19 12:41:03 +08:00
DreamMaoMao
5ba7da0570 opt: remove increase_proportion dispatch
should use resizewin to replace it
2025-11-19 12:41:03 +08:00
DreamMaoMao
17f1ae2463 opt: optmize restore_minimized size and not restore namedscratchpad 2025-11-19 12:41:03 +08:00
DreamMaoMao
64dc30dc31 opt: disable resize scroller window when it force to default single size 2025-11-19 12:41:03 +08:00
DreamMaoMao
0501719604 opt: spawn_on_empty and toggle_named_scratchapd use spawn_shell 2025-11-19 12:41:03 +08:00
DreamMaoMao
6010cea805 opt: optimize shadow node and blur node enable 2025-11-19 12:41:03 +08:00
DreamMaoMao
e09748764d opt: remove useless normalize keysym convert 2025-11-19 12:41:03 +08:00
DreamMaoMao
5774df00e0 opt:optimize code struct 2025-11-19 12:41:03 +08:00
DreamMaoMao
d32fecfd23 fix: crash in some crossmon dispatch 2025-11-19 12:41:03 +08:00
DreamMaoMao
18ad32384b feat: add global option scroller_ignore_proportion_single 2025-11-19 12:41:03 +08:00
DreamMaoMao
9d6436cf42 feat: support keyboard shortcut inhibitor 2025-11-19 12:41:03 +08:00
DreamMaoMao
08097b0991 Merge pull request #399 from the-eater/fix-segfault-on-exit
check is drm_release_manager is set before cleaning up to avoid segfault
2025-11-19 12:41:03 +08:00
DreamMaoMao
e0bc7fb5e4 fix: crash when click waybar overview button 2025-11-19 12:41:03 +08:00
eater
1029936b18 check is drm_release_manager is set before cleaning up to avoid segfault 2025-11-19 12:41:03 +08:00
16 changed files with 572 additions and 260 deletions

View File

@@ -101,12 +101,12 @@ emerge --ask --verbose gui-wm/mangowc
## Other ## Other
```bash ```bash
git clone -b 0.19.1 https://gitlab.freedesktop.org/wlroots/wlroots.git git clone -b 0.19.2 https://gitlab.freedesktop.org/wlroots/wlroots.git
cd wlroots cd wlroots
meson build -Dprefix=/usr meson build -Dprefix=/usr
sudo ninja -C build install sudo ninja -C build install
git clone https://github.com/wlrfx/scenefx.git git clone -b 0.4.1 https://github.com/wlrfx/scenefx.git
cd scenefx cd scenefx
meson build -Dprefix=/usr meson build -Dprefix=/usr
sudo ninja -C build install sudo ninja -C build install
@@ -119,7 +119,7 @@ sudo ninja -C build install
## Suggested Tools ## Suggested Tools
### integrated component ### Hybrid component
- [dms-shell](https://github.com/AvengeMedia/DankMaterialShell) - [dms-shell](https://github.com/AvengeMedia/DankMaterialShell)
### Independent component ### Independent component
@@ -189,7 +189,10 @@ Here's an example of using the modules in a flake:
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.url = "github:hercules-ci/flake-parts";
mango.url = "github:DreamMaoMao/mango"; mango = {
url = "github:DreamMaoMao/mango";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = outputs =
inputs@{ self, flake-parts, ... }: inputs@{ self, flake-parts, ... }:

View File

@@ -1,5 +1,5 @@
project('mango', ['c', 'cpp'], project('mango', ['c', 'cpp'],
version : '0.10.5', version : '0.10.6',
) )
subdir('protocols') subdir('protocols')

View File

@@ -26,6 +26,25 @@ in {
xdg.portal = { xdg.portal = {
enable = lib.mkDefault true; enable = lib.mkDefault true;
config = {
mango = {
default = [
"gtk"
];
# except those
"org.freedesktop.impl.portal.Secret" = ["gnome-keyring"];
"org.freedesktop.impl.portal.ScreenCast" = ["wlr"];
"org.freedesktop.impl.portal.ScreenShot" = ["wlr"];
# wlr does not have this interface
"org.freedesktop.impl.portal.Inhibit" = [];
};
};
extraPortals = with pkgs; [
xdg-desktop-portal-wlr
xdg-desktop-portal-gtk
];
wlr.enable = lib.mkDefault true; wlr.enable = lib.mkDefault true;
configPackages = [cfg.package]; configPackages = [cfg.package];

View File

@@ -255,8 +255,12 @@ void client_draw_shadow(Client *c) {
return; return;
if (!shadows || (!c->isfloating && shadow_only_floating)) { if (!shadows || (!c->isfloating && shadow_only_floating)) {
wlr_scene_shadow_set_size(c->shadow, 0, 0); if (c->shadow->node.enabled)
wlr_scene_node_set_enabled(&c->shadow->node, false);
return; return;
} else {
if (c->scene_surface->node.enabled && !c->shadow->node.enabled)
wlr_scene_node_set_enabled(&c->shadow->node, true);
} }
bool hit_no_border = check_hit_no_border(c); bool hit_no_border = check_hit_no_border(c);
@@ -442,7 +446,7 @@ struct ivec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
int offsetx = 0, offsety = 0, offsetw = 0, offseth = 0; int offsetx = 0, offsety = 0, offsetw = 0, offseth = 0;
struct ivec2 offset = {0, 0, 0, 0}; struct ivec2 offset = {0, 0, 0, 0};
if (!ISTILED(c) && !c->animation.tagining && !c->animation.tagouted && if (!ISSCROLLTILED(c) && !c->animation.tagining && !c->animation.tagouted &&
!c->animation.tagouting) !c->animation.tagouting)
return offset; return offset;
@@ -463,7 +467,7 @@ struct ivec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
需要主要border超出屏幕的时候不计算如偏差之内而是 需要主要border超出屏幕的时候不计算如偏差之内而是
要等窗口表面超出才开始计算偏差 要等窗口表面超出才开始计算偏差
*/ */
if (ISTILED(c) || c->animation.tagining || c->animation.tagouted || if (ISSCROLLTILED(c) || c->animation.tagining || c->animation.tagouted ||
c->animation.tagouting) { c->animation.tagouting) {
if (left_out_offset > 0) { if (left_out_offset > 0) {
offsetx = GEZERO(left_out_offset - bw); offsetx = GEZERO(left_out_offset - bw);
@@ -491,7 +495,7 @@ struct ivec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
offset.height = offseth; offset.height = offseth;
if ((clip_box->width + bw <= 0 || clip_box->height + bw <= 0) && if ((clip_box->width + bw <= 0 || clip_box->height + bw <= 0) &&
(ISTILED(c) || c->animation.tagouting || c->animation.tagining)) { (ISSCROLLTILED(c) || c->animation.tagouting || c->animation.tagining)) {
c->is_clip_to_hide = true; c->is_clip_to_hide = true;
wlr_scene_node_set_enabled(&c->scene->node, false); wlr_scene_node_set_enabled(&c->scene->node, false);
} else if (c->is_clip_to_hide && VISIBLEON(c, c->mon)) { } else if (c->is_clip_to_hide && VISIBLEON(c, c->mon)) {
@@ -1056,7 +1060,7 @@ void client_set_focused_opacity_animation(Client *c) {
c->opacity_animation.running = true; c->opacity_animation.running = true;
} }
void cleint_set_unfocused_opacity_animation(Client *c) { void client_set_unfocused_opacity_animation(Client *c) {
// Start border color animation to unfocused // Start border color animation to unfocused
float *border_color = get_border_color(c); float *border_color = get_border_color(c);

View File

@@ -69,6 +69,7 @@ typedef struct {
int isunglobal; int isunglobal;
int isglobal; int isglobal;
int isoverlay; int isoverlay;
int allow_shortcuts_inhibit;
int ignore_maximize; int ignore_maximize;
int ignore_minimize; int ignore_minimize;
int isnosizehint; int isnosizehint;
@@ -77,6 +78,7 @@ typedef struct {
int offsety; int offsety;
int width; int width;
int height; int height;
int nofocus;
int nofadein; int nofadein;
int nofadeout; int nofadeout;
int no_force_center; int no_force_center;
@@ -88,6 +90,7 @@ typedef struct {
int noblur; int noblur;
float focused_opacity; float focused_opacity;
float unfocused_opacity; float unfocused_opacity;
float scroller_proportion_single;
uint32_t passmod; uint32_t passmod;
xkb_keysym_t keysym; xkb_keysym_t keysym;
KeyBinding globalkeybinding; KeyBinding globalkeybinding;
@@ -193,6 +196,7 @@ typedef struct {
int scroller_structs; int scroller_structs;
float scroller_default_proportion; float scroller_default_proportion;
float scroller_default_proportion_single; float scroller_default_proportion_single;
int scroller_ignore_proportion_single;
int scroller_focus_center; int scroller_focus_center;
int scroller_prefer_center; int scroller_prefer_center;
int edge_scroller_pointer_focus; int edge_scroller_pointer_focus;
@@ -334,6 +338,7 @@ typedef struct {
int syncobj_enable; int syncobj_enable;
int adaptive_sync; int adaptive_sync;
int allow_tearing; int allow_tearing;
int allow_shortcuts_inhibit;
struct xkb_rule_names xkb_rules; struct xkb_rule_names xkb_rules;
@@ -513,61 +518,6 @@ long int parse_color(const char *hex_str) {
return hex_num; return hex_num;
} }
xkb_keysym_t normalize_keysym(xkb_keysym_t sym) {
// 首先转换为小写(主要影响字母键)
sym = xkb_keysym_to_lower(sym);
// 将数字小键盘键转换为普通数字键
switch (sym) {
// 小键盘数字转换
case XKB_KEY_KP_0:
return XKB_KEY_0;
case XKB_KEY_KP_1:
return XKB_KEY_1;
case XKB_KEY_KP_2:
return XKB_KEY_2;
case XKB_KEY_KP_3:
return XKB_KEY_3;
case XKB_KEY_KP_4:
return XKB_KEY_4;
case XKB_KEY_KP_5:
return XKB_KEY_5;
case XKB_KEY_KP_6:
return XKB_KEY_6;
case XKB_KEY_KP_7:
return XKB_KEY_7;
case XKB_KEY_KP_8:
return XKB_KEY_8;
case XKB_KEY_KP_9:
return XKB_KEY_9;
// 将 Shift+数字 的符号转换回基础数字
case XKB_KEY_exclam:
return XKB_KEY_1; // !
case XKB_KEY_at:
return XKB_KEY_2; // @
case XKB_KEY_numbersign:
return XKB_KEY_3; // #
case XKB_KEY_dollar:
return XKB_KEY_4; // $
case XKB_KEY_percent:
return XKB_KEY_5; // %
case XKB_KEY_asciicircum:
return XKB_KEY_6; // ^
case XKB_KEY_ampersand:
return XKB_KEY_7; // &
case XKB_KEY_asterisk:
return XKB_KEY_8; // *
case XKB_KEY_parenleft:
return XKB_KEY_9; // (
case XKB_KEY_parenright:
return XKB_KEY_0; // )
default:
return sym;
}
}
// 辅助函数:检查字符串是否以指定的前缀开头(忽略大小写) // 辅助函数:检查字符串是否以指定的前缀开头(忽略大小写)
static bool starts_with_ignore_case(const char *str, const char *prefix) { static bool starts_with_ignore_case(const char *str, const char *prefix) {
while (*prefix) { while (*prefix) {
@@ -886,9 +836,6 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
} else if (strcmp(func_name, "set_proportion") == 0) { } else if (strcmp(func_name, "set_proportion") == 0) {
func = set_proportion; func = set_proportion;
(*arg).f = atof(arg_value); (*arg).f = atof(arg_value);
} else if (strcmp(func_name, "increase_proportion") == 0) {
func = increase_proportion;
(*arg).f = atof(arg_value);
} else if (strcmp(func_name, "switch_proportion_preset") == 0) { } else if (strcmp(func_name, "switch_proportion_preset") == 0) {
func = switch_proportion_preset; func = switch_proportion_preset;
} else if (strcmp(func_name, "viewtoleft") == 0) { } else if (strcmp(func_name, "viewtoleft") == 0) {
@@ -1210,6 +1157,8 @@ void parse_option(Config *config, char *key, char *value) {
config->scroller_default_proportion = atof(value); config->scroller_default_proportion = atof(value);
} else if (strcmp(key, "scroller_default_proportion_single") == 0) { } else if (strcmp(key, "scroller_default_proportion_single") == 0) {
config->scroller_default_proportion_single = atof(value); config->scroller_default_proportion_single = atof(value);
} else if (strcmp(key, "scroller_ignore_proportion_single") == 0) {
config->scroller_ignore_proportion_single = atoi(value);
} else if (strcmp(key, "scroller_focus_center") == 0) { } else if (strcmp(key, "scroller_focus_center") == 0) {
config->scroller_focus_center = atoi(value); config->scroller_focus_center = atoi(value);
} else if (strcmp(key, "scroller_prefer_center") == 0) { } else if (strcmp(key, "scroller_prefer_center") == 0) {
@@ -1270,6 +1219,8 @@ void parse_option(Config *config, char *key, char *value) {
config->adaptive_sync = atoi(value); config->adaptive_sync = atoi(value);
} else if (strcmp(key, "allow_tearing") == 0) { } else if (strcmp(key, "allow_tearing") == 0) {
config->allow_tearing = atoi(value); config->allow_tearing = atoi(value);
} else if (strcmp(key, "allow_shortcuts_inhibit") == 0) {
config->allow_shortcuts_inhibit = atoi(value);
} else if (strcmp(key, "no_border_when_single") == 0) { } else if (strcmp(key, "no_border_when_single") == 0) {
config->no_border_when_single = atoi(value); config->no_border_when_single = atoi(value);
} else if (strcmp(key, "no_radius_when_single") == 0) { } else if (strcmp(key, "no_radius_when_single") == 0) {
@@ -1707,6 +1658,7 @@ void parse_option(Config *config, char *key, char *value) {
rule->isunglobal = -1; rule->isunglobal = -1;
rule->isglobal = -1; rule->isglobal = -1;
rule->isoverlay = -1; rule->isoverlay = -1;
rule->allow_shortcuts_inhibit = -1;
rule->ignore_maximize = -1; rule->ignore_maximize = -1;
rule->ignore_minimize = -1; rule->ignore_minimize = -1;
rule->isnosizehint = -1; rule->isnosizehint = -1;
@@ -1716,6 +1668,7 @@ void parse_option(Config *config, char *key, char *value) {
rule->force_tearing = -1; rule->force_tearing = -1;
rule->noswallow = -1; rule->noswallow = -1;
rule->noblur = -1; rule->noblur = -1;
rule->nofocus = -1;
rule->nofadein = -1; rule->nofadein = -1;
rule->nofadeout = -1; rule->nofadeout = -1;
rule->no_force_center = -1; rule->no_force_center = -1;
@@ -1727,6 +1680,7 @@ void parse_option(Config *config, char *key, char *value) {
// float rule value, relay to a client property // float rule value, relay to a client property
rule->focused_opacity = 0; rule->focused_opacity = 0;
rule->unfocused_opacity = 0; rule->unfocused_opacity = 0;
rule->scroller_proportion_single = 0.0f;
rule->scroller_proportion = 0; rule->scroller_proportion = 0;
// special rule value,not directly set to client property // special rule value,not directly set to client property
@@ -1770,6 +1724,8 @@ void parse_option(Config *config, char *key, char *value) {
rule->offsetx = atoi(val); rule->offsetx = atoi(val);
} else if (strcmp(key, "offsety") == 0) { } else if (strcmp(key, "offsety") == 0) {
rule->offsety = atoi(val); rule->offsety = atoi(val);
} else if (strcmp(key, "nofocus") == 0) {
rule->nofocus = atoi(val);
} else if (strcmp(key, "nofadein") == 0) { } else if (strcmp(key, "nofadein") == 0) {
rule->nofadein = atoi(val); rule->nofadein = atoi(val);
} else if (strcmp(key, "nofadeout") == 0) { } else if (strcmp(key, "nofadeout") == 0) {
@@ -1796,12 +1752,16 @@ void parse_option(Config *config, char *key, char *value) {
rule->isunglobal = atoi(val); rule->isunglobal = atoi(val);
} else if (strcmp(key, "isglobal") == 0) { } else if (strcmp(key, "isglobal") == 0) {
rule->isglobal = atoi(val); rule->isglobal = atoi(val);
} else if (strcmp(key, "scroller_proportion_single") == 0) {
rule->scroller_proportion_single = atof(val);
} else if (strcmp(key, "unfocused_opacity") == 0) { } else if (strcmp(key, "unfocused_opacity") == 0) {
rule->unfocused_opacity = atof(val); rule->unfocused_opacity = atof(val);
} else if (strcmp(key, "focused_opacity") == 0) { } else if (strcmp(key, "focused_opacity") == 0) {
rule->focused_opacity = atof(val); rule->focused_opacity = atof(val);
} else if (strcmp(key, "isoverlay") == 0) { } else if (strcmp(key, "isoverlay") == 0) {
rule->isoverlay = atoi(val); rule->isoverlay = atoi(val);
} else if (strcmp(key, "allow_shortcuts_inhibit") == 0) {
rule->allow_shortcuts_inhibit = atoi(val);
} else if (strcmp(key, "ignore_maximize") == 0) { } else if (strcmp(key, "ignore_maximize") == 0) {
rule->ignore_maximize = atoi(val); rule->ignore_maximize = atoi(val);
} else if (strcmp(key, "ignore_minimize") == 0) { } else if (strcmp(key, "ignore_minimize") == 0) {
@@ -2314,35 +2274,53 @@ void parse_config_line(Config *config, const char *line) {
void parse_config_file(Config *config, const char *file_path) { void parse_config_file(Config *config, const char *file_path) {
FILE *file; FILE *file;
// 检查路径是否以 ~/ 开头 char full_path[1024];
if (file_path[0] == '~' && (file_path[1] == '/' || file_path[1] == '\0')) {
if (file_path[0] == '.' && file_path[1] == '/') {
// Relative path
const char *mangoconfig = getenv("MANGOCONFIG");
if (mangoconfig && mangoconfig[0] != '\0') {
snprintf(full_path, sizeof(full_path), "%s/%s", mangoconfig,
file_path + 1);
} else {
const char *home = getenv("HOME"); const char *home = getenv("HOME");
if (!home) { if (!home) {
fprintf(stderr, "Error: HOME environment variable not set.\n"); fprintf(stderr, "Error: HOME environment variable not set.\n");
return; return;
} }
snprintf(full_path, sizeof(full_path), "%s/.config/mango/%s", home,
// 构建完整路径(家目录 + / + 原路径去掉 ~ file_path + 1);
char full_path[1024]; }
snprintf(full_path, sizeof(full_path), "%s%s", home, file_path + 1);
file = fopen(full_path, "r"); file = fopen(full_path, "r");
if (!file) {
perror("Error opening file"); } else if (file_path[0] == '~' &&
(file_path[1] == '/' || file_path[1] == '\0')) {
// Home directory
const char *home = getenv("HOME");
if (!home) {
fprintf(stderr, "Error: HOME environment variable not set.\n");
return; return;
} }
snprintf(full_path, sizeof(full_path), "%s%s", home, file_path + 1);
file = fopen(full_path, "r");
} else { } else {
// Absolute path
file = fopen(file_path, "r"); file = fopen(file_path, "r");
}
if (!file) { if (!file) {
perror("Error opening file"); perror("Error opening file");
return; return;
} }
}
char line[512]; char line[512];
while (fgets(line, sizeof(line), file)) { while (fgets(line, sizeof(line), file)) {
if (line[0] == '#' || line[0] == '\n') if (line[0] == '#' || line[0] == '\n') {
continue; continue;
}
parse_config_line(config, line); parse_config_line(config, line);
} }
@@ -2665,6 +2643,8 @@ void override_config(void) {
CLAMP_FLOAT(config.scroller_default_proportion, 0.1f, 1.0f); CLAMP_FLOAT(config.scroller_default_proportion, 0.1f, 1.0f);
scroller_default_proportion_single = scroller_default_proportion_single =
CLAMP_FLOAT(config.scroller_default_proportion_single, 0.1f, 1.0f); CLAMP_FLOAT(config.scroller_default_proportion_single, 0.1f, 1.0f);
scroller_ignore_proportion_single =
CLAMP_INT(config.scroller_ignore_proportion_single, 0, 1);
scroller_focus_center = CLAMP_INT(config.scroller_focus_center, 0, 1); scroller_focus_center = CLAMP_INT(config.scroller_focus_center, 0, 1);
scroller_prefer_center = CLAMP_INT(config.scroller_prefer_center, 0, 1); scroller_prefer_center = CLAMP_INT(config.scroller_prefer_center, 0, 1);
edge_scroller_pointer_focus = edge_scroller_pointer_focus =
@@ -2690,6 +2670,7 @@ void override_config(void) {
syncobj_enable = CLAMP_INT(config.syncobj_enable, 0, 1); syncobj_enable = CLAMP_INT(config.syncobj_enable, 0, 1);
adaptive_sync = CLAMP_INT(config.adaptive_sync, 0, 1); adaptive_sync = CLAMP_INT(config.adaptive_sync, 0, 1);
allow_tearing = CLAMP_INT(config.allow_tearing, 0, 2); allow_tearing = CLAMP_INT(config.allow_tearing, 0, 2);
allow_shortcuts_inhibit = CLAMP_INT(config.allow_shortcuts_inhibit, 0, 1);
axis_bind_apply_timeout = axis_bind_apply_timeout =
CLAMP_INT(config.axis_bind_apply_timeout, 0, 1000); CLAMP_INT(config.axis_bind_apply_timeout, 0, 1000);
focus_on_activate = CLAMP_INT(config.focus_on_activate, 0, 1); focus_on_activate = CLAMP_INT(config.focus_on_activate, 0, 1);
@@ -2852,6 +2833,8 @@ void set_value_default() {
config.scroller_default_proportion = scroller_default_proportion; config.scroller_default_proportion = scroller_default_proportion;
config.scroller_default_proportion_single = config.scroller_default_proportion_single =
scroller_default_proportion_single; scroller_default_proportion_single;
config.scroller_ignore_proportion_single =
scroller_ignore_proportion_single;
config.scroller_focus_center = scroller_focus_center; config.scroller_focus_center = scroller_focus_center;
config.scroller_prefer_center = scroller_prefer_center; config.scroller_prefer_center = scroller_prefer_center;
config.edge_scroller_pointer_focus = edge_scroller_pointer_focus; config.edge_scroller_pointer_focus = edge_scroller_pointer_focus;
@@ -2865,6 +2848,7 @@ void set_value_default() {
config.syncobj_enable = syncobj_enable; config.syncobj_enable = syncobj_enable;
config.adaptive_sync = adaptive_sync; config.adaptive_sync = adaptive_sync;
config.allow_tearing = allow_tearing; config.allow_tearing = allow_tearing;
config.allow_shortcuts_inhibit = allow_shortcuts_inhibit;
config.no_border_when_single = no_border_when_single; config.no_border_when_single = no_border_when_single;
config.no_radius_when_single = no_radius_when_single; config.no_radius_when_single = no_radius_when_single;
config.snap_distance = snap_distance; config.snap_distance = snap_distance;
@@ -3144,6 +3128,12 @@ void reapply_monitor_rules(void) {
} }
} }
void reapply_cursor_style(void) {
if (cursor_mgr)
wlr_xcursor_manager_destroy(cursor_mgr);
cursor_mgr = wlr_xcursor_manager_create(config.cursor_theme, cursor_size);
}
void reapply_border(void) { void reapply_border(void) {
Client *c = NULL; Client *c = NULL;
@@ -3203,33 +3193,37 @@ void reapply_master(void) {
} }
} }
void parse_tagrule(Monitor *m) {
int i, jk;
ConfigTagRule tr;
for (i = 0; i < config.tag_rules_count; i++) {
tr = config.tag_rules[i];
if (config.tag_rules_count > 0 &&
(!tr.monitor_name ||
regex_match(tr.monitor_name, m->wlr_output->name))) {
for (jk = 0; jk < LENGTH(layouts); jk++) {
if (tr.layout_name &&
strcmp(layouts[jk].name, tr.layout_name) == 0) {
m->pertag->ltidxs[tr.id] = &layouts[jk];
}
}
m->pertag->no_hide[tr.id] = tr.no_hide;
}
}
}
void reapply_tagrule(void) { void reapply_tagrule(void) {
Monitor *m = NULL; Monitor *m = NULL;
int i, jk;
char *rule_monitor_name = NULL;
wl_list_for_each(m, &mons, link) { wl_list_for_each(m, &mons, link) {
if (!m->wlr_output->enabled) { if (!m->wlr_output->enabled) {
continue; continue;
} }
parse_tagrule(m);
// apply tag rule
for (i = 1; i <= config.tag_rules_count; i++) {
rule_monitor_name = config.tag_rules[i - 1].monitor_name;
if (regex_match(rule_monitor_name, m->wlr_output->name) ||
!rule_monitor_name) {
for (jk = 0; jk < LENGTH(layouts); jk++) {
if (config.tag_rules_count > 0 &&
config.tag_rules[i - 1].layout_name &&
strcmp(layouts[jk].name,
config.tag_rules[i - 1].layout_name) == 0) {
m->pertag->ltidxs[config.tag_rules[i - 1].id] =
&layouts[jk];
m->pertag->no_hide[config.tag_rules[i - 1].id] =
config.tag_rules[i - 1].no_hide;
}
}
}
}
} }
} }
@@ -3241,6 +3235,7 @@ void reset_option(void) {
set_env(); set_env();
run_exec(); run_exec();
reapply_cursor_style();
reapply_border(); reapply_border();
reapply_keyboard(); reapply_keyboard();
reapply_pointer(); reapply_pointer();

View File

@@ -60,6 +60,7 @@ float scratchpad_height_ratio = 0.9;
int scroller_structs = 20; int scroller_structs = 20;
float scroller_default_proportion = 0.9; float scroller_default_proportion = 0.9;
float scroller_default_proportion_single = 1.0; float scroller_default_proportion_single = 1.0;
int scroller_ignore_proportion_single = 0;
int scroller_focus_center = 0; int scroller_focus_center = 0;
int scroller_prefer_center = 0; int scroller_prefer_center = 0;
int focus_cross_monitor = 0; int focus_cross_monitor = 0;
@@ -104,6 +105,7 @@ int syncobj_enable = 0;
int adaptive_sync = 0; int adaptive_sync = 0;
double drag_refresh_interval = 30.0; double drag_refresh_interval = 30.0;
int allow_tearing = TEARING_DISABLED; int allow_tearing = TEARING_DISABLED;
int allow_shortcuts_inhibit = SHORTCUTS_INHIBIT_ENABLE;
/* keyboard */ /* keyboard */

View File

@@ -4,7 +4,6 @@ int toggle_scratchpad(const Arg *arg);
int focusdir(const Arg *arg); int focusdir(const Arg *arg);
int toggleoverview(const Arg *arg); int toggleoverview(const Arg *arg);
int set_proportion(const Arg *arg); int set_proportion(const Arg *arg);
int increase_proportion(const Arg *arg);
int switch_proportion_preset(const Arg *arg); int switch_proportion_preset(const Arg *arg);
int zoom(const Arg *arg); int zoom(const Arg *arg);
int tagsilent(const Arg *arg); int tagsilent(const Arg *arg);

View File

@@ -80,8 +80,12 @@ int defaultgaps(const Arg *arg) {
int exchange_client(const Arg *arg) { int exchange_client(const Arg *arg) {
Client *c = selmon->sel; Client *c = selmon->sel;
if (!c || c->isfloating || c->isfullscreen || c->ismaximizescreen) if (!c || c->isfloating)
return 0; return 0;
if ((c->isfullscreen || c->ismaximizescreen) && !is_scroller_layout(c->mon))
return 0;
exchange_two_client(c, direction_select(arg)); exchange_two_client(c, direction_select(arg));
return 0; return 0;
} }
@@ -202,7 +206,7 @@ int focusmon(const Arg *arg) {
focusclient(c, 1); focusclient(c, 1);
if (old_selmon_sel) { if (old_selmon_sel) {
setborder_color(old_selmon_sel); client_set_unfocused_opacity_animation(old_selmon_sel);
} }
return 0; return 0;
} }
@@ -281,18 +285,6 @@ int incovgaps(const Arg *arg) {
return 0; return 0;
} }
int increase_proportion(const Arg *arg) {
if (selmon->sel) {
unsigned int max_client_width =
selmon->w.width - 2 * scroller_structs - gappih;
selmon->sel->scroller_proportion =
MIN(MAX(arg->f + selmon->sel->scroller_proportion, 0.1), 1.0);
selmon->sel->geom.width = max_client_width * arg->f;
arrange(selmon, false);
}
return 0;
}
int setmfact(const Arg *arg) { int setmfact(const Arg *arg) {
float f; float f;
Client *c = NULL; Client *c = NULL;
@@ -488,7 +480,7 @@ int restore_minimized(const Arg *arg) {
} }
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (c->isminied) { if (c->isminied && !c->isnamedscratchpad) {
c->is_scratchpad_show = 0; c->is_scratchpad_show = 0;
c->is_in_scratchpad = 0; c->is_in_scratchpad = 0;
c->isnamedscratchpad = 0; c->isnamedscratchpad = 0;
@@ -509,7 +501,7 @@ int setlayout(const Arg *arg) {
for (jk = 0; jk < LENGTH(layouts); jk++) { for (jk = 0; jk < LENGTH(layouts); jk++) {
if (strcmp(layouts[jk].name, arg->v) == 0) { if (strcmp(layouts[jk].name, arg->v) == 0) {
selmon->pertag->ltidxs[selmon->pertag->curtag] = &layouts[jk]; selmon->pertag->ltidxs[selmon->pertag->curtag] = &layouts[jk];
clear_fullscreen_and_maximized_state(selmon);
arrange(selmon, false); arrange(selmon, false);
printstatus(); printstatus();
return 0; return 0;
@@ -530,6 +522,14 @@ int setkeymode(const Arg *arg) {
} }
int set_proportion(const Arg *arg) { int set_proportion(const Arg *arg) {
if (selmon->isoverview || !is_scroller_layout(selmon))
return 0;
if (selmon->visible_tiling_clients == 1 &&
!scroller_ignore_proportion_single)
return 0;
if (selmon->sel) { if (selmon->sel) {
unsigned int max_client_width = unsigned int max_client_width =
selmon->w.width - 2 * scroller_structs - gappih; selmon->w.width - 2 * scroller_structs - gappih;
@@ -809,7 +809,7 @@ int spawn_on_empty(const Arg *arg) {
return 0; return 0;
} else { } else {
view(arg, true); view(arg, true);
spawn(arg); spawn_shell(arg);
} }
return 0; return 0;
} }
@@ -905,7 +905,7 @@ int switch_layout(const Arg *arg) {
break; break;
} }
} }
clear_fullscreen_and_maximized_state(selmon);
arrange(selmon, false); arrange(selmon, false);
printstatus(); printstatus();
return 0; return 0;
@@ -916,6 +916,7 @@ int switch_layout(const Arg *arg) {
selmon->pertag->ltidxs[selmon->pertag->curtag]->name) == 0) { selmon->pertag->ltidxs[selmon->pertag->curtag]->name) == 0) {
selmon->pertag->ltidxs[selmon->pertag->curtag] = selmon->pertag->ltidxs[selmon->pertag->curtag] =
jk == LENGTH(layouts) - 1 ? &layouts[0] : &layouts[jk + 1]; jk == LENGTH(layouts) - 1 ? &layouts[0] : &layouts[jk + 1];
clear_fullscreen_and_maximized_state(selmon);
arrange(selmon, false); arrange(selmon, false);
printstatus(); printstatus();
return 0; return 0;
@@ -931,6 +932,13 @@ int switch_proportion_preset(const Arg *arg) {
return 0; return 0;
} }
if (selmon->isoverview || !is_scroller_layout(selmon))
return 0;
if (selmon->visible_tiling_clients == 1 &&
!scroller_ignore_proportion_single)
return 0;
if (selmon->sel) { if (selmon->sel) {
for (int i = 0; i < config.scroller_proportion_preset_count; i++) { for (int i = 0; i < config.scroller_proportion_preset_count; i++) {
@@ -968,7 +976,7 @@ int tag(const Arg *arg) {
} }
int tagmon(const Arg *arg) { int tagmon(const Arg *arg) {
Monitor *m = NULL; Monitor *m = NULL, *cm = NULL;
Client *c = focustop(selmon); Client *c = focustop(selmon);
if (!c) if (!c)
@@ -977,11 +985,12 @@ int tagmon(const Arg *arg) {
if (arg->i != UNDIR) { if (arg->i != UNDIR) {
m = dirtomon(arg->i); m = dirtomon(arg->i);
} else if (arg->v) { } else if (arg->v) {
wl_list_for_each(m, &mons, link) { wl_list_for_each(cm, &mons, link) {
if (!m->wlr_output->enabled) { if (!cm->wlr_output->enabled) {
continue; continue;
} }
if (regex_match(arg->v, m->wlr_output->name)) { if (regex_match(arg->v, cm->wlr_output->name)) {
m = cm;
break; break;
} }
} }
@@ -1084,7 +1093,7 @@ int toggle_named_scratchpad(const Arg *arg) {
if (!target_client && arg->v3) { if (!target_client && arg->v3) {
Arg arg_spawn = {.v = arg->v3}; Arg arg_spawn = {.v = arg->v3};
spawn(&arg_spawn); spawn_shell(&arg_spawn);
return 0; return 0;
} }

View File

@@ -258,6 +258,7 @@ void dwl_ipc_output_set_layout(struct wl_client *client,
index = 0; index = 0;
monitor->pertag->ltidxs[monitor->pertag->curtag] = &layouts[index]; monitor->pertag->ltidxs[monitor->pertag->curtag] = &layouts[index];
clear_fullscreen_and_maximized_state(monitor);
arrange(monitor, false); arrange(monitor, false);
printstatus(); printstatus();
} }

View File

@@ -47,6 +47,11 @@ static void handle_ext_workspace_activate(struct wl_listener *listener,
void *data) { void *data) {
struct workspace *workspace = struct workspace *workspace =
wl_container_of(listener, workspace, activate); wl_container_of(listener, workspace, activate);
if (workspace->m->isoverview) {
return;
}
goto_workspace(workspace); goto_workspace(workspace);
wlr_log(WLR_INFO, "ext activating workspace %d", workspace->tag); wlr_log(WLR_INFO, "ext activating workspace %d", workspace->tag);
} }
@@ -55,6 +60,11 @@ static void handle_ext_workspace_deactivate(struct wl_listener *listener,
void *data) { void *data) {
struct workspace *workspace = struct workspace *workspace =
wl_container_of(listener, workspace, deactivate); wl_container_of(listener, workspace, deactivate);
if (workspace->m->isoverview) {
return;
}
toggle_workspace(workspace); toggle_workspace(workspace);
wlr_log(WLR_INFO, "ext deactivating workspace %d", workspace->tag); wlr_log(WLR_INFO, "ext deactivating workspace %d", workspace->tag);
} }

View File

@@ -142,7 +142,7 @@ Client *center_tiled_select(Monitor *m) {
return target_c; return target_c;
} }
Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
bool align) { bool ignore_align) {
Client *c = NULL; Client *c = NULL;
Client **tempClients = NULL; // 初始化为 NULL Client **tempClients = NULL; // 初始化为 NULL
int last = -1; int last = -1;
@@ -185,6 +185,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
switch (arg->i) { switch (arg->i) {
case UP: case UP:
if (!ignore_align) {
for (int _i = 0; _i <= last; _i++) { for (int _i = 0; _i <= last; _i++) {
if (tempClients[_i]->geom.y < sel_y && if (tempClients[_i]->geom.y < sel_y &&
tempClients[_i]->geom.x == sel_x && tempClients[_i]->geom.x == sel_x &&
@@ -199,7 +200,8 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
} }
} }
} }
if (!tempFocusClients && !align) { }
if (!tempFocusClients) {
for (int _i = 0; _i <= last; _i++) { for (int _i = 0; _i <= last; _i++) {
if (tempClients[_i]->geom.y < sel_y) { if (tempClients[_i]->geom.y < sel_y) {
int dis_x = tempClients[_i]->geom.x - sel_x; int dis_x = tempClients[_i]->geom.x - sel_x;
@@ -215,6 +217,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
} }
break; break;
case DOWN: case DOWN:
if (!ignore_align) {
for (int _i = 0; _i <= last; _i++) { for (int _i = 0; _i <= last; _i++) {
if (tempClients[_i]->geom.y > sel_y && if (tempClients[_i]->geom.y > sel_y &&
tempClients[_i]->geom.x == sel_x && tempClients[_i]->geom.x == sel_x &&
@@ -229,7 +232,8 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
} }
} }
} }
if (!tempFocusClients && !align) { }
if (!tempFocusClients) {
for (int _i = 0; _i <= last; _i++) { for (int _i = 0; _i <= last; _i++) {
if (tempClients[_i]->geom.y > sel_y) { if (tempClients[_i]->geom.y > sel_y) {
int dis_x = tempClients[_i]->geom.x - sel_x; int dis_x = tempClients[_i]->geom.x - sel_x;
@@ -245,6 +249,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
} }
break; break;
case LEFT: case LEFT:
if (!ignore_align) {
for (int _i = 0; _i <= last; _i++) { for (int _i = 0; _i <= last; _i++) {
if (tempClients[_i]->geom.x < sel_x && if (tempClients[_i]->geom.x < sel_x &&
tempClients[_i]->geom.y == sel_y && tempClients[_i]->geom.y == sel_y &&
@@ -259,7 +264,8 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
} }
} }
} }
if (!tempFocusClients && !align) { }
if (!tempFocusClients) {
for (int _i = 0; _i <= last; _i++) { for (int _i = 0; _i <= last; _i++) {
if (tempClients[_i]->geom.x < sel_x) { if (tempClients[_i]->geom.x < sel_x) {
int dis_x = tempClients[_i]->geom.x - sel_x; int dis_x = tempClients[_i]->geom.x - sel_x;
@@ -275,6 +281,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
} }
break; break;
case RIGHT: case RIGHT:
if (!ignore_align) {
for (int _i = 0; _i <= last; _i++) { for (int _i = 0; _i <= last; _i++) {
if (tempClients[_i]->geom.x > sel_x && if (tempClients[_i]->geom.x > sel_x &&
tempClients[_i]->geom.y == sel_y && tempClients[_i]->geom.y == sel_y &&
@@ -289,7 +296,8 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
} }
} }
} }
if (!tempFocusClients && !align) { }
if (!tempFocusClients) {
for (int _i = 0; _i <= last; _i++) { for (int _i = 0; _i <= last; _i++) {
if (tempClients[_i]->geom.x > sel_x) { if (tempClients[_i]->geom.x > sel_x) {
int dis_x = tempClients[_i]->geom.x - sel_x; int dis_x = tempClients[_i]->geom.x - sel_x;
@@ -317,12 +325,13 @@ Client *direction_select(const Arg *arg) {
if (!tc) if (!tc)
return NULL; return NULL;
if (tc && (tc->isfullscreen || tc->ismaximizescreen)) { if (tc && (tc->isfullscreen || tc->ismaximizescreen) &&
// 不支持全屏窗口的焦点切换 (!is_scroller_layout(selmon) || tc->isfloating)) {
return NULL; return NULL;
} }
return find_client_by_direction(tc, arg, true, false); return find_client_by_direction(
tc, arg, true, is_scroller_layout(selmon) && !selmon->isoverview);
} }
/* We probably should change the name of this, it sounds like /* We probably should change the name of this, it sounds like
@@ -374,7 +383,10 @@ Client *get_next_stack_client(Client *c, bool reverse) {
} }
float *get_border_color(Client *c) { float *get_border_color(Client *c) {
if (c->isurgent) {
if (c->mon != selmon) {
return bordercolor;
} else if (c->isurgent) {
return urgentcolor; return urgentcolor;
} else if (c->is_in_scratchpad && selmon && c == selmon->sel) { } else if (c->is_in_scratchpad && selmon && c == selmon->sel) {
return scratchpadcolor; return scratchpadcolor;

View File

@@ -115,6 +115,10 @@ void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
surface = wlr_scene_surface_try_from_buffer( surface = wlr_scene_surface_try_from_buffer(
wlr_scene_buffer_from_node(node)) wlr_scene_buffer_from_node(node))
->surface; ->surface;
else if (node->type == WLR_SCENE_NODE_RECT) {
surface = NULL;
break;
}
/* start from the topmost layer, /* start from the topmost layer,
find a sureface that can be focused by pointer, find a sureface that can be focused by pointer,

View File

@@ -374,6 +374,10 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int offsetx, int offsety,
float delta_x, delta_y; float delta_x, delta_y;
float new_scroller_proportion; float new_scroller_proportion;
if (grabc && grabc->mon->visible_tiling_clients == 1 &&
!scroller_ignore_proportion_single)
return;
if (!start_drag_window && isdrag) { if (!start_drag_window && isdrag) {
drag_begin_cursorx = cursor->x; drag_begin_cursorx = cursor->x;
drag_begin_cursory = cursor->y; drag_begin_cursory = cursor->y;
@@ -475,6 +479,9 @@ void resize_tile_client(Client *grabc, bool isdrag, int offsetx, int offsety,
if (!grabc || grabc->isfullscreen || grabc->ismaximizescreen) if (!grabc || grabc->isfullscreen || grabc->ismaximizescreen)
return; return;
if (grabc->mon->isoverview)
return;
const Layout *current_layout = const Layout *current_layout =
grabc->mon->pertag->ltidxs[grabc->mon->pertag->curtag]; grabc->mon->pertag->ltidxs[grabc->mon->pertag->curtag];
if (current_layout->id == TILE || current_layout->id == DECK || if (current_layout->id == TILE || current_layout->id == DECK ||
@@ -592,6 +599,7 @@ arrange(Monitor *m, bool want_animation) {
return; return;
m->visible_clients = 0; m->visible_clients = 0;
m->visible_tiling_clients = 0; m->visible_tiling_clients = 0;
m->visible_scroll_tiling_clients = 0;
m->has_visible_fullscreen_client = false; m->has_visible_fullscreen_client = false;
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
@@ -612,6 +620,10 @@ arrange(Monitor *m, bool want_animation) {
if (ISTILED(c)) { if (ISTILED(c)) {
m->visible_tiling_clients++; m->visible_tiling_clients++;
} }
if (ISSCROLLTILED(c)) {
m->visible_scroll_tiling_clients++;
}
} }
} }

View File

@@ -189,9 +189,42 @@ void deck(Monitor *m) {
} }
} }
void horizontal_scroll_adjust_fullandmax(Client *c,
struct wlr_box *target_geom) {
Monitor *m = c->mon;
unsigned int cur_gappih = enablegaps ? m->gappih : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
cur_gappih =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappoh =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappov;
if (c->isfullscreen) {
target_geom->height = m->m.height;
target_geom->width = m->m.width;
target_geom->y = m->m.y;
return;
}
if (c->ismaximizescreen) {
target_geom->height = m->w.height - 2 * cur_gappov;
target_geom->width = m->w.width - 2 * cur_gappoh;
target_geom->y = m->w.y + cur_gappov;
return;
}
target_geom->height = m->w.height - 2 * cur_gappov;
target_geom->y = m->w.y + (m->w.height - target_geom->height) / 2;
}
// 滚动布局 // 滚动布局
void scroller(Monitor *m) { void scroller(Monitor *m) {
unsigned int i, n, j; unsigned int i, n, j;
float single_proportion = 1.0;
Client *c = NULL, *root_client = NULL; Client *c = NULL, *root_client = NULL;
Client **tempClients = NULL; // 初始化为 NULL Client **tempClients = NULL; // 初始化为 NULL
@@ -202,14 +235,17 @@ void scroller(Monitor *m) {
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0; unsigned int cur_gappov = enablegaps ? m->gappov : 0;
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih; cur_gappih =
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; cur_gappoh =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappov;
unsigned int max_client_width = unsigned int max_client_width =
m->w.width - 2 * scroller_structs - cur_gappih; m->w.width - 2 * scroller_structs - cur_gappih;
n = m->visible_tiling_clients; n = m->visible_scroll_tiling_clients;
if (n == 0) { if (n == 0) {
return; // 没有需要处理的客户端,直接返回 return; // 没有需要处理的客户端,直接返回
@@ -225,17 +261,22 @@ void scroller(Monitor *m) {
// 第二次遍历,填充 tempClients // 第二次遍历,填充 tempClients
j = 0; j = 0;
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (VISIBLEON(c, m) && ISTILED(c)) { if (VISIBLEON(c, m) && ISSCROLLTILED(c)) {
tempClients[j] = c; tempClients[j] = c;
j++; j++;
} }
} }
if (n == 1) { if (n == 1 && !scroller_ignore_proportion_single &&
!tempClients[0]->isfullscreen && !tempClients[0]->ismaximizescreen) {
c = tempClients[0]; c = tempClients[0];
single_proportion = c->scroller_proportion_single > 0.0f
? c->scroller_proportion_single
: scroller_default_proportion_single;
target_geom.height = m->w.height - 2 * cur_gappov; target_geom.height = m->w.height - 2 * cur_gappov;
target_geom.width = target_geom.width = (m->w.width - 2 * cur_gappoh) * single_proportion;
(m->w.width - 2 * cur_gappoh) * scroller_default_proportion_single;
target_geom.x = m->w.x + (m->w.width - target_geom.width) / 2; target_geom.x = m->w.x + (m->w.width - target_geom.width) / 2;
target_geom.y = m->w.y + (m->w.height - target_geom.height) / 2; target_geom.y = m->w.y + (m->w.height - target_geom.height) / 2;
resize(c, target_geom, 0); resize(c, target_geom, 0);
@@ -243,11 +284,10 @@ void scroller(Monitor *m) {
return; return;
} }
if (m->sel && !client_is_unmanaged(m->sel) && !m->sel->isfloating && if (m->sel && !client_is_unmanaged(m->sel) && !m->sel->isfloating) {
!m->sel->ismaximizescreen && !m->sel->isfullscreen) {
root_client = m->sel; root_client = m->sel;
} else if (m->prevsel && ISTILED(m->prevsel) && VISIBLEON(m->prevsel, m) && } else if (m->prevsel && ISSCROLLTILED(m->prevsel) &&
!client_is_unmanaged(m->prevsel)) { VISIBLEON(m->prevsel, m) && !client_is_unmanaged(m->prevsel)) {
root_client = m->prevsel; root_client = m->prevsel;
} else { } else {
root_client = center_tiled_select(m); root_client = center_tiled_select(m);
@@ -261,8 +301,7 @@ void scroller(Monitor *m) {
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
c = tempClients[i]; c = tempClients[i];
if (root_client == c) { if (root_client == c) {
if (!c->is_pending_open_animation && if (c->geom.x >= m->w.x + scroller_structs &&
c->geom.x >= m->w.x + scroller_structs &&
c->geom.x + c->geom.width <= c->geom.x + c->geom.width <=
m->w.x + m->w.width - scroller_structs) { m->w.x + m->w.width - scroller_structs) {
need_scroller = false; need_scroller = false;
@@ -274,17 +313,28 @@ void scroller(Monitor *m) {
} }
} }
if (n == 1 && scroller_ignore_proportion_single) {
need_scroller = true;
}
if (start_drag_window) if (start_drag_window)
need_scroller = false; need_scroller = false;
target_geom.height = m->w.height - 2 * cur_gappov; target_geom.height = m->w.height - 2 * cur_gappov;
target_geom.width = max_client_width * c->scroller_proportion; target_geom.width = max_client_width * c->scroller_proportion;
target_geom.y = m->w.y + (m->w.height - target_geom.height) / 2; target_geom.y = m->w.y + (m->w.height - target_geom.height) / 2;
horizontal_scroll_adjust_fullandmax(tempClients[focus_client_index],
if (need_scroller) { &target_geom);
if (tempClients[focus_client_index]->isfullscreen) {
target_geom.x = m->m.x;
resize(tempClients[focus_client_index], target_geom, 0);
} else if (tempClients[focus_client_index]->ismaximizescreen) {
target_geom.x = m->w.x + cur_gappoh;
resize(tempClients[focus_client_index], target_geom, 0);
} else if (need_scroller) {
if (scroller_focus_center || if (scroller_focus_center ||
((!m->prevsel || ((!m->prevsel ||
(ISTILED(m->prevsel) && (ISSCROLLTILED(m->prevsel) &&
(m->prevsel->scroller_proportion * max_client_width) + (m->prevsel->scroller_proportion * max_client_width) +
(root_client->scroller_proportion * max_client_width) > (root_client->scroller_proportion * max_client_width) >
m->w.width - 2 * scroller_structs - cur_gappih)) && m->w.width - 2 * scroller_structs - cur_gappih)) &&
@@ -307,14 +357,17 @@ void scroller(Monitor *m) {
for (i = 1; i <= focus_client_index; i++) { for (i = 1; i <= focus_client_index; i++) {
c = tempClients[focus_client_index - i]; c = tempClients[focus_client_index - i];
target_geom.width = max_client_width * c->scroller_proportion; target_geom.width = max_client_width * c->scroller_proportion;
horizontal_scroll_adjust_fullandmax(c, &target_geom);
target_geom.x = tempClients[focus_client_index - i + 1]->geom.x - target_geom.x = tempClients[focus_client_index - i + 1]->geom.x -
cur_gappih - target_geom.width; cur_gappih - target_geom.width;
resize(c, target_geom, 0); resize(c, target_geom, 0);
} }
for (i = 1; i < n - focus_client_index; i++) { for (i = 1; i < n - focus_client_index; i++) {
c = tempClients[focus_client_index + i]; c = tempClients[focus_client_index + i];
target_geom.width = max_client_width * c->scroller_proportion; target_geom.width = max_client_width * c->scroller_proportion;
horizontal_scroll_adjust_fullandmax(c, &target_geom);
target_geom.x = tempClients[focus_client_index + i - 1]->geom.x + target_geom.x = tempClients[focus_client_index + i - 1]->geom.x +
cur_gappih + cur_gappih +
tempClients[focus_client_index + i - 1]->geom.width; tempClients[focus_client_index + i - 1]->geom.width;

View File

@@ -155,8 +155,42 @@ void vertical_deck(Monitor *m) {
} }
} }
void vertical_scroll_adjust_fullandmax(Client *c, struct wlr_box *target_geom) {
Monitor *m = c->mon;
unsigned int cur_gappiv = enablegaps ? m->gappiv : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappiv =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappov =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappoh =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappoh;
if (c->isfullscreen) {
target_geom->width = m->m.width;
target_geom->height = m->m.height;
target_geom->x = m->m.x;
return;
}
if (c->ismaximizescreen) {
target_geom->width = m->w.width - 2 * cur_gappoh;
target_geom->height = m->w.height - 2 * cur_gappov;
target_geom->x = m->w.x + cur_gappoh;
return;
}
target_geom->width = m->w.width - 2 * cur_gappoh;
target_geom->x = m->w.x + (m->w.width - target_geom->width) / 2;
}
// 竖屏滚动布局
void vertical_scroller(Monitor *m) { void vertical_scroller(Monitor *m) {
unsigned int i, n, j; unsigned int i, n, j;
float single_proportion = 1.0;
Client *c = NULL, *root_client = NULL; Client *c = NULL, *root_client = NULL;
Client **tempClients = NULL; Client **tempClients = NULL;
struct wlr_box target_geom; struct wlr_box target_geom;
@@ -166,14 +200,17 @@ void vertical_scroller(Monitor *m) {
unsigned int cur_gappov = enablegaps ? m->gappov : 0; unsigned int cur_gappov = enablegaps ? m->gappov : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv; cur_gappiv =
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; cur_gappov =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappoh =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappoh;
unsigned int max_client_height = unsigned int max_client_height =
m->w.height - 2 * scroller_structs - cur_gappiv; m->w.height - 2 * scroller_structs - cur_gappiv;
n = m->visible_tiling_clients; n = m->visible_scroll_tiling_clients;
if (n == 0) { if (n == 0) {
return; return;
@@ -186,29 +223,33 @@ void vertical_scroller(Monitor *m) {
j = 0; j = 0;
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (VISIBLEON(c, m) && ISTILED(c)) { if (VISIBLEON(c, m) && ISSCROLLTILED(c)) {
tempClients[j] = c; tempClients[j] = c;
j++; j++;
} }
} }
if (n == 1) { if (n == 1 && !scroller_ignore_proportion_single &&
!tempClients[0]->isfullscreen && !tempClients[0]->ismaximizescreen) {
c = tempClients[0]; c = tempClients[0];
single_proportion = c->scroller_proportion_single > 0.0f
? c->scroller_proportion_single
: scroller_default_proportion_single;
target_geom.width = m->w.width - 2 * cur_gappoh; target_geom.width = m->w.width - 2 * cur_gappoh;
target_geom.height = target_geom.height = (m->w.height - 2 * cur_gappov) * single_proportion;
(m->w.height - 2 * cur_gappov) * scroller_default_proportion_single;
target_geom.x = m->w.x + (m->w.width - target_geom.width) / 2;
target_geom.y = m->w.y + (m->w.height - target_geom.height) / 2; target_geom.y = m->w.y + (m->w.height - target_geom.height) / 2;
target_geom.x = m->w.x + (m->w.width - target_geom.width) / 2;
resize(c, target_geom, 0); resize(c, target_geom, 0);
free(tempClients); free(tempClients);
return; return;
} }
if (m->sel && !client_is_unmanaged(m->sel) && !m->sel->isfloating && if (m->sel && !client_is_unmanaged(m->sel) && !m->sel->isfloating) {
!m->sel->ismaximizescreen && !m->sel->isfullscreen) {
root_client = m->sel; root_client = m->sel;
} else if (m->prevsel && ISTILED(m->prevsel) && VISIBLEON(m->prevsel, m) && } else if (m->prevsel && ISSCROLLTILED(m->prevsel) &&
!client_is_unmanaged(m->prevsel)) { VISIBLEON(m->prevsel, m) && !client_is_unmanaged(m->prevsel)) {
root_client = m->prevsel; root_client = m->prevsel;
} else { } else {
root_client = center_tiled_select(m); root_client = center_tiled_select(m);
@@ -222,8 +263,7 @@ void vertical_scroller(Monitor *m) {
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
c = tempClients[i]; c = tempClients[i];
if (root_client == c) { if (root_client == c) {
if (!c->is_pending_open_animation && if (c->geom.y >= m->w.y + scroller_structs &&
c->geom.y >= m->w.y + scroller_structs &&
c->geom.y + c->geom.height <= c->geom.y + c->geom.height <=
m->w.y + m->w.height - scroller_structs) { m->w.y + m->w.height - scroller_structs) {
need_scroller = false; need_scroller = false;
@@ -235,14 +275,29 @@ void vertical_scroller(Monitor *m) {
} }
} }
if (n == 1 && scroller_ignore_proportion_single) {
need_scroller = true;
}
if (start_drag_window)
need_scroller = false;
target_geom.width = m->w.width - 2 * cur_gappoh; target_geom.width = m->w.width - 2 * cur_gappoh;
target_geom.height = max_client_height * c->scroller_proportion; target_geom.height = max_client_height * c->scroller_proportion;
target_geom.x = m->w.x + (m->w.width - target_geom.width) / 2; target_geom.x = m->w.x + (m->w.width - target_geom.width) / 2;
vertical_scroll_adjust_fullandmax(tempClients[focus_client_index],
&target_geom);
if (need_scroller) { if (tempClients[focus_client_index]->isfullscreen) {
target_geom.y = m->m.y;
resize(tempClients[focus_client_index], target_geom, 0);
} else if (tempClients[focus_client_index]->ismaximizescreen) {
target_geom.y = m->w.y + cur_gappov;
resize(tempClients[focus_client_index], target_geom, 0);
} else if (need_scroller) {
if (scroller_focus_center || if (scroller_focus_center ||
((!m->prevsel || ((!m->prevsel ||
(ISTILED(m->prevsel) && (ISSCROLLTILED(m->prevsel) &&
(m->prevsel->scroller_proportion * max_client_height) + (m->prevsel->scroller_proportion * max_client_height) +
(root_client->scroller_proportion * max_client_height) > (root_client->scroller_proportion * max_client_height) >
m->w.height - 2 * scroller_structs - cur_gappiv)) && m->w.height - 2 * scroller_structs - cur_gappiv)) &&
@@ -265,14 +320,17 @@ void vertical_scroller(Monitor *m) {
for (i = 1; i <= focus_client_index; i++) { for (i = 1; i <= focus_client_index; i++) {
c = tempClients[focus_client_index - i]; c = tempClients[focus_client_index - i];
target_geom.height = max_client_height * c->scroller_proportion; target_geom.height = max_client_height * c->scroller_proportion;
vertical_scroll_adjust_fullandmax(c, &target_geom);
target_geom.y = tempClients[focus_client_index - i + 1]->geom.y - target_geom.y = tempClients[focus_client_index - i + 1]->geom.y -
cur_gappiv - target_geom.height; cur_gappiv - target_geom.height;
resize(c, target_geom, 0); resize(c, target_geom, 0);
} }
for (i = 1; i < n - focus_client_index; i++) { for (i = 1; i < n - focus_client_index; i++) {
c = tempClients[focus_client_index + i]; c = tempClients[focus_client_index + i];
target_geom.height = max_client_height * c->scroller_proportion; target_geom.height = max_client_height * c->scroller_proportion;
vertical_scroll_adjust_fullandmax(c, &target_geom);
target_geom.y = tempClients[focus_client_index + i - 1]->geom.y + target_geom.y = tempClients[focus_client_index + i - 1]->geom.y +
cur_gappiv + cur_gappiv +
tempClients[focus_client_index + i - 1]->geom.height; tempClients[focus_client_index + i - 1]->geom.height;

View File

@@ -48,6 +48,7 @@
#include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_keyboard.h> #include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_keyboard_group.h> #include <wlr/types/wlr_keyboard_group.h>
#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h>
#include <wlr/types/wlr_layer_shell_v1.h> #include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h> #include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_linux_drm_syncobj_v1.h> #include <wlr/types/wlr_linux_drm_syncobj_v1.h>
@@ -103,6 +104,9 @@
#define ISTILED(A) \ #define ISTILED(A) \
(A && !(A)->isfloating && !(A)->isminied && !(A)->iskilling && \ (A && !(A)->isfloating && !(A)->isminied && !(A)->iskilling && \
!(A)->ismaximizescreen && !(A)->isfullscreen && !(A)->isunglobal) !(A)->ismaximizescreen && !(A)->isfullscreen && !(A)->isunglobal)
#define ISSCROLLTILED(A) \
(A && !(A)->isfloating && !(A)->isminied && !(A)->iskilling && \
!(A)->isunglobal)
#define VISIBLEON(C, M) \ #define VISIBLEON(C, M) \
((C) && (M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags])) ((C) && (M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
#define LENGTH(X) (sizeof X / sizeof X[0]) #define LENGTH(X) (sizeof X / sizeof X[0])
@@ -172,6 +176,11 @@ enum tearing_mode {
TEARING_FULLSCREEN_ONLY, TEARING_FULLSCREEN_ONLY,
}; };
enum seat_config_shortcuts_inhibit {
SHORTCUTS_INHIBIT_DISABLE,
SHORTCUTS_INHIBIT_ENABLE,
};
typedef struct Pertag Pertag; typedef struct Pertag Pertag;
typedef struct Monitor Monitor; typedef struct Monitor Monitor;
typedef struct Client Client; typedef struct Client Client;
@@ -352,6 +361,7 @@ struct Client {
bool drag_to_tile; bool drag_to_tile;
bool scratchpad_switching_mon; bool scratchpad_switching_mon;
bool fake_no_border; bool fake_no_border;
int nofocus;
int nofadein; int nofadein;
int nofadeout; int nofadeout;
int no_force_center; int no_force_center;
@@ -368,6 +378,8 @@ struct Client {
bool isleftstack; bool isleftstack;
int tearing_hint; int tearing_hint;
int force_tearing; int force_tearing;
int allow_shortcuts_inhibit;
float scroller_proportion_single;
}; };
typedef struct { typedef struct {
@@ -397,6 +409,12 @@ typedef struct {
struct wl_listener destroy; struct wl_listener destroy;
} KeyboardGroup; } KeyboardGroup;
typedef struct {
struct wlr_keyboard_shortcuts_inhibitor_v1 *inhibitor;
struct wl_listener destroy;
struct wl_list link;
} KeyboardShortcutsInhibitor;
typedef struct { typedef struct {
/* Must keep these three elements in this order */ /* Must keep these three elements in this order */
unsigned int type; /* LayerShell */ unsigned int type; /* LayerShell */
@@ -464,6 +482,7 @@ struct Monitor {
int asleep; int asleep;
unsigned int visible_clients; unsigned int visible_clients;
unsigned int visible_tiling_clients; unsigned int visible_tiling_clients;
unsigned int visible_scroll_tiling_clients;
bool has_visible_fullscreen_client; bool has_visible_fullscreen_client;
struct wlr_scene_optimized_blur *blur; struct wlr_scene_optimized_blur *blur;
char last_surface_ws_name[256]; char last_surface_ws_name[256];
@@ -621,7 +640,9 @@ static void urgent(struct wl_listener *listener, void *data);
static void view(const Arg *arg, bool want_animation); static void view(const Arg *arg, bool want_animation);
static void handlesig(int signo); static void handlesig(int signo);
static void
handle_keyboard_shortcuts_inhibit_new_inhibitor(struct wl_listener *listener,
void *data);
static void virtualkeyboard(struct wl_listener *listener, void *data); static void virtualkeyboard(struct wl_listener *listener, void *data);
static void virtualpointer(struct wl_listener *listener, void *data); static void virtualpointer(struct wl_listener *listener, void *data);
static void warp_cursor(const Client *c); static void warp_cursor(const Client *c);
@@ -716,6 +737,7 @@ static void refresh_monitors_workspaces_status(Monitor *m);
static void init_client_properties(Client *c); static void init_client_properties(Client *c);
static float *get_border_color(Client *c); static float *get_border_color(Client *c);
static void request_fresh_all_monitors(void); static void request_fresh_all_monitors(void);
static void clear_fullscreen_and_maximized_state(Monitor *m);
#include "data/static_keymap.h" #include "data/static_keymap.h"
#include "dispatch/bind_declare.h" #include "dispatch/bind_declare.h"
@@ -749,6 +771,8 @@ static struct wlr_idle_inhibit_manager_v1 *idle_inhibit_mgr;
static struct wlr_layer_shell_v1 *layer_shell; static struct wlr_layer_shell_v1 *layer_shell;
static struct wlr_output_manager_v1 *output_mgr; static struct wlr_output_manager_v1 *output_mgr;
static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr; static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
static struct wlr_keyboard_shortcuts_inhibit_manager_v1
*keyboard_shortcuts_inhibit;
static struct wlr_virtual_pointer_manager_v1 *virtual_pointer_mgr; static struct wlr_virtual_pointer_manager_v1 *virtual_pointer_mgr;
static struct wlr_output_power_manager_v1 *power_mgr; static struct wlr_output_power_manager_v1 *power_mgr;
static struct wlr_pointer_gestures_v1 *pointer_gestures; static struct wlr_pointer_gestures_v1 *pointer_gestures;
@@ -772,6 +796,7 @@ static struct wlr_pointer_constraint_v1 *active_constraint;
static struct wlr_seat *seat; static struct wlr_seat *seat;
static KeyboardGroup *kb_group; static KeyboardGroup *kb_group;
static struct wl_list inputdevices; static struct wl_list inputdevices;
static struct wl_list keyboard_shortcut_inhibitors;
static unsigned int cursor_mode; static unsigned int cursor_mode;
static Client *grabc; static Client *grabc;
static int grabcx, grabcy; /* client-relative */ static int grabcx, grabcy; /* client-relative */
@@ -858,6 +883,8 @@ static struct wl_listener request_start_drag = {.notify = requeststartdrag};
static struct wl_listener start_drag = {.notify = startdrag}; static struct wl_listener start_drag = {.notify = startdrag};
static struct wl_listener new_session_lock = {.notify = locksession}; static struct wl_listener new_session_lock = {.notify = locksession};
static struct wl_listener drm_lease_request = {.notify = requestdrmlease}; static struct wl_listener drm_lease_request = {.notify = requestdrmlease};
static struct wl_listener keyboard_shortcuts_inhibit_new_inhibitor = {
.notify = handle_keyboard_shortcuts_inhibit_new_inhibitor};
#ifdef XWAYLAND #ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data); static void activatex11(struct wl_listener *listener, void *data);
@@ -908,8 +935,26 @@ void applybounds(Client *c, struct wlr_box *bbox) {
c->geom.y = bbox->y; c->geom.y = bbox->y;
} }
void clear_fullscreen_and_maximized_state(Monitor *m) {
Client *fc = NULL;
wl_list_for_each(fc, &clients, link) {
if (fc && VISIBLEON(fc, m) && ISFULLSCREEN(fc)) {
clear_fullscreen_flag(fc);
}
}
}
/*清除全屏标志,还原全屏时清0的border*/ /*清除全屏标志,还原全屏时清0的border*/
void clear_fullscreen_flag(Client *c) { void clear_fullscreen_flag(Client *c) {
if ((c->mon->pertag->ltidxs[get_tags_first_tag_num(c->tags)]->id ==
SCROLLER ||
c->mon->pertag->ltidxs[get_tags_first_tag_num(c->tags)]->id ==
VERTICAL_SCROLLER) &&
!c->isfloating) {
return;
}
if (c->isfullscreen) { if (c->isfullscreen) {
setfullscreen(c, false); setfullscreen(c, false);
} }
@@ -1130,6 +1175,7 @@ static void apply_rule_properties(Client *c, const ConfigWinRule *r) {
APPLY_INT_PROP(c, r, force_maximize); APPLY_INT_PROP(c, r, force_maximize);
APPLY_INT_PROP(c, r, force_tearing); APPLY_INT_PROP(c, r, force_tearing);
APPLY_INT_PROP(c, r, noswallow); APPLY_INT_PROP(c, r, noswallow);
APPLY_INT_PROP(c, r, nofocus);
APPLY_INT_PROP(c, r, nofadein); APPLY_INT_PROP(c, r, nofadein);
APPLY_INT_PROP(c, r, nofadeout); APPLY_INT_PROP(c, r, nofadeout);
APPLY_INT_PROP(c, r, no_force_center); APPLY_INT_PROP(c, r, no_force_center);
@@ -1148,8 +1194,10 @@ static void apply_rule_properties(Client *c, const ConfigWinRule *r) {
APPLY_INT_PROP(c, r, isnosizehint); APPLY_INT_PROP(c, r, isnosizehint);
APPLY_INT_PROP(c, r, isunglobal); APPLY_INT_PROP(c, r, isunglobal);
APPLY_INT_PROP(c, r, noblur); APPLY_INT_PROP(c, r, noblur);
APPLY_INT_PROP(c, r, allow_shortcuts_inhibit);
APPLY_FLOAT_PROP(c, r, scroller_proportion); APPLY_FLOAT_PROP(c, r, scroller_proportion);
APPLY_FLOAT_PROP(c, r, scroller_proportion_single);
APPLY_FLOAT_PROP(c, r, focused_opacity); APPLY_FLOAT_PROP(c, r, focused_opacity);
APPLY_FLOAT_PROP(c, r, unfocused_opacity); APPLY_FLOAT_PROP(c, r, unfocused_opacity);
@@ -1243,11 +1291,16 @@ void applyrules(Client *c) {
const char *appid, *title; const char *appid, *title;
unsigned int i, newtags = 0; unsigned int i, newtags = 0;
const ConfigWinRule *r; const ConfigWinRule *r;
Monitor *mon = selmon, *m = NULL; Monitor *m = NULL;
Client *fc = NULL; Client *fc = NULL;
bool hit_rule_pos = false; bool hit_rule_pos = false;
Client *parent = NULL;
c->isfloating = client_is_float_type(c); parent = client_get_parent(c);
Monitor *mon = parent && parent->mon ? parent->mon : selmon;
c->isfloating = client_is_float_type(c) || parent;
if (!(appid = client_get_appid(c))) if (!(appid = client_get_appid(c)))
appid = broken; appid = broken;
if (!(title = client_get_title(c))) if (!(title = client_get_title(c)))
@@ -1264,8 +1317,12 @@ void applyrules(Client *c) {
// set general properties // set general properties
apply_rule_properties(c, r); apply_rule_properties(c, r);
// set tags // // set tags
newtags |= (r->tags > 0) ? r->tags : 0; if (r->tags > 0) {
newtags |= r->tags;
} else if (parent) {
newtags = parent->tags;
}
// set monitor of client // set monitor of client
wl_list_for_each(m, &mons, link) { wl_list_for_each(m, &mons, link) {
@@ -1334,7 +1391,9 @@ void applyrules(Client *c) {
int fullscreen_state_backup = c->isfullscreen || client_wants_fullscreen(c); int fullscreen_state_backup = c->isfullscreen || client_wants_fullscreen(c);
setmon(c, mon, newtags, setmon(c, mon, newtags,
!c->isopensilent && (!c->istagsilent || !newtags || !c->isopensilent &&
!(client_is_x11_popup(c) && client_should_ignore_focus(c)) &&
(!c->istagsilent || !newtags ||
newtags & mon->tagset[mon->seltags])); newtags & mon->tagset[mon->seltags]));
if (c->mon && if (c->mon &&
@@ -1964,8 +2023,11 @@ void cleanuplisteners(void) {
wl_list_remove(&request_start_drag.link); wl_list_remove(&request_start_drag.link);
wl_list_remove(&start_drag.link); wl_list_remove(&start_drag.link);
wl_list_remove(&new_session_lock.link); wl_list_remove(&new_session_lock.link);
wl_list_remove(&drm_lease_request.link);
wl_list_remove(&tearing_new_object.link); wl_list_remove(&tearing_new_object.link);
wl_list_remove(&keyboard_shortcuts_inhibit_new_inhibitor.link);
if (drm_lease_manager) {
wl_list_remove(&drm_lease_request.link);
}
#ifdef XWAYLAND #ifdef XWAYLAND
wl_list_remove(&new_xwayland_surface.link); wl_list_remove(&new_xwayland_surface.link);
wl_list_remove(&xwayland_ready.link); wl_list_remove(&xwayland_ready.link);
@@ -2148,6 +2210,15 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) {
} }
// 刷新布局让窗口能感应到exclude_zone变化以及设置独占表面 // 刷新布局让窗口能感应到exclude_zone变化以及设置独占表面
arrangelayers(l->mon); arrangelayers(l->mon);
// 按需交互layer需要像正常窗口一样抢占非独占layer的焦点
if (!exclusive_focus &&
l->layer_surface->current.keyboard_interactive ==
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND) {
focusclient(NULL, 0);
client_notify_enter(l->layer_surface->surface,
wlr_seat_get_keyboard(seat));
}
} }
void commitlayersurfacenotify(struct wl_listener *listener, void *data) { void commitlayersurfacenotify(struct wl_listener *listener, void *data) {
@@ -2658,18 +2729,7 @@ void createmon(struct wl_listener *listener, void *data) {
} }
// apply tag rule // apply tag rule
for (i = 1; i <= config.tag_rules_count; i++) { parse_tagrule(m);
for (jk = 0; jk < LENGTH(layouts); jk++) {
if (config.tag_rules_count > 0 &&
config.tag_rules[i - 1].layout_name &&
strcmp(layouts[jk].name, config.tag_rules[i - 1].layout_name) ==
0) {
m->pertag->ltidxs[config.tag_rules[i - 1].id] = &layouts[jk];
m->pertag->no_hide[config.tag_rules[i - 1].id] =
config.tag_rules[i - 1].no_hide;
}
}
}
/* The xdg-protocol specifies: /* The xdg-protocol specifies:
* *
@@ -3067,6 +3127,9 @@ void destroykeyboardgroup(struct wl_listener *listener, void *data) {
} }
void focusclient(Client *c, int lift) { void focusclient(Client *c, int lift) {
Client *last_focus_client = NULL;
struct wlr_surface *old_keyboard_focus_surface = struct wlr_surface *old_keyboard_focus_surface =
seat->keyboard_state.focused_surface; seat->keyboard_state.focused_surface;
@@ -3082,6 +3145,9 @@ void focusclient(Client *c, int lift) {
if (c && client_should_ignore_focus(c) && client_is_x11_popup(c)) if (c && client_should_ignore_focus(c) && client_is_x11_popup(c))
return; return;
if (c && c->nofocus)
return;
/* Raise client in stacking order if requested */ /* Raise client in stacking order if requested */
if (c && lift) if (c && lift)
wlr_scene_node_raise_to_top(&c->scene->node); // 将视图提升到顶层 wlr_scene_node_raise_to_top(&c->scene->node); // 将视图提升到顶层
@@ -3098,12 +3164,14 @@ void focusclient(Client *c, int lift) {
if (c && !c->iskilling && !client_is_unmanaged(c) && c->mon) { if (c && !c->iskilling && !client_is_unmanaged(c) && c->mon) {
last_focus_client = selmon->sel;
selmon = c->mon; selmon = c->mon;
selmon->prevsel = selmon->sel; selmon->prevsel = selmon->sel;
selmon->sel = c; selmon->sel = c;
if (selmon->prevsel && !selmon->prevsel->iskilling) { if (last_focus_client && !last_focus_client->iskilling &&
cleint_set_unfocused_opacity_animation(selmon->prevsel); last_focus_client != c) {
client_set_unfocused_opacity_animation(last_focus_client);
} }
client_set_focused_opacity_animation(c); client_set_focused_opacity_animation(c);
@@ -3113,7 +3181,6 @@ void focusclient(Client *c, int lift) {
if (c && selmon->prevsel && if (c && selmon->prevsel &&
(selmon->prevsel->tags & selmon->tagset[selmon->seltags]) && (selmon->prevsel->tags & selmon->tagset[selmon->seltags]) &&
(c->tags & selmon->tagset[selmon->seltags]) && !c->isfloating && (c->tags & selmon->tagset[selmon->seltags]) && !c->isfloating &&
!c->isfullscreen && !c->ismaximizescreen &&
is_scroller_layout(selmon)) { is_scroller_layout(selmon)) {
arrange(selmon, false); arrange(selmon, false);
} }
@@ -3249,6 +3316,17 @@ int keyrepeat(void *data) {
return 0; return 0;
} }
bool is_keyboard_shortcut_inhibitor(struct wlr_surface *surface) {
KeyboardShortcutsInhibitor *kbsinhibitor;
wl_list_for_each(kbsinhibitor, &keyboard_shortcut_inhibitors, link) {
if (kbsinhibitor->inhibitor->surface == surface) {
return true;
}
}
return false;
}
int // 17 int // 17
keybinding(unsigned int state, bool locked, unsigned int mods, xkb_keysym_t sym, keybinding(unsigned int state, bool locked, unsigned int mods, xkb_keysym_t sym,
unsigned int keycode) { unsigned int keycode) {
@@ -3267,6 +3345,10 @@ keybinding(unsigned int state, bool locked, unsigned int mods, xkb_keysym_t sym,
keycode == 62 || keycode == 108 || keycode == 105 || keycode == 134) keycode == 62 || keycode == 108 || keycode == 105 || keycode == 134)
return false; return false;
if (is_keyboard_shortcut_inhibitor(seat->keyboard_state.focused_surface)) {
return false;
}
for (ji = 0; ji < config.key_bindings_count; ji++) { for (ji = 0; ji < config.key_bindings_count; ji++) {
if (config.key_bindings_count < 1) if (config.key_bindings_count < 1)
break; break;
@@ -3291,8 +3373,8 @@ keybinding(unsigned int state, bool locked, unsigned int mods, xkb_keysym_t sym,
(strcmp(keymode.mode, k->mode) == 0)) && (strcmp(keymode.mode, k->mode) == 0)) &&
CLEANMASK(mods) == CLEANMASK(k->mod) && CLEANMASK(mods) == CLEANMASK(k->mod) &&
((k->keysymcode.type == KEY_TYPE_SYM && ((k->keysymcode.type == KEY_TYPE_SYM &&
normalize_keysym(sym) == xkb_keysym_to_lower(sym) ==
normalize_keysym(k->keysymcode.keysym)) || xkb_keysym_to_lower(k->keysymcode.keysym)) ||
(k->keysymcode.type == KEY_TYPE_CODE && (k->keysymcode.type == KEY_TYPE_CODE &&
(keycode == k->keysymcode.keycode.keycode1 || (keycode == k->keysymcode.keycode.keycode1 ||
keycode == k->keysymcode.keycode.keycode2 || keycode == k->keysymcode.keycode.keycode2 ||
@@ -3558,6 +3640,7 @@ void init_client_properties(Client *c) {
c->fake_no_border = false; c->fake_no_border = false;
c->focused_opacity = focused_opacity; c->focused_opacity = focused_opacity;
c->unfocused_opacity = unfocused_opacity; c->unfocused_opacity = unfocused_opacity;
c->nofocus = 0;
c->nofadein = 0; c->nofadein = 0;
c->nofadeout = 0; c->nofadeout = 0;
c->no_force_center = 0; c->no_force_center = 0;
@@ -3573,12 +3656,13 @@ void init_client_properties(Client *c) {
c->allow_csd = 0; c->allow_csd = 0;
c->force_maximize = 0; c->force_maximize = 0;
c->force_tearing = 0; c->force_tearing = 0;
c->allow_shortcuts_inhibit = SHORTCUTS_INHIBIT_ENABLE;
c->scroller_proportion_single = 0.0f;
} }
void // old fix to 0.5 void // old fix to 0.5
mapnotify(struct wl_listener *listener, void *data) { mapnotify(struct wl_listener *listener, void *data) {
/* Called when the surface is mapped, or ready to display on-screen. */ /* Called when the surface is mapped, or ready to display on-screen. */
Client *p = NULL;
Client *at_client = NULL; Client *at_client = NULL;
Client *c = wl_container_of(listener, c, map); Client *c = wl_container_of(listener, c, map);
/* Create scene tree for this client and its border */ /* Create scene tree for this client and its border */
@@ -3649,9 +3733,9 @@ mapnotify(struct wl_listener *listener, void *data) {
// tile at the top // tile at the top
wl_list_insert(&clients, &c->link); // 新窗口是master,头部入栈 wl_list_insert(&clients, &c->link); // 新窗口是master,头部入栈
else if (selmon && is_scroller_layout(selmon) && else if (selmon && is_scroller_layout(selmon) &&
selmon->visible_tiling_clients > 0) { selmon->visible_scroll_tiling_clients > 0) {
if (selmon->sel && ISTILED(selmon->sel) && if (selmon->sel && ISSCROLLTILED(selmon->sel) &&
VISIBLEON(selmon->sel, selmon)) { VISIBLEON(selmon->sel, selmon)) {
at_client = selmon->sel; at_client = selmon->sel;
} else { } else {
@@ -3670,16 +3754,7 @@ mapnotify(struct wl_listener *listener, void *data) {
wl_list_insert(clients.prev, &c->link); // 尾部入栈 wl_list_insert(clients.prev, &c->link); // 尾部入栈
wl_list_insert(&fstack, &c->flink); wl_list_insert(&fstack, &c->flink);
/* Set initial monitor, tags, floating status, and focus:
* we always consider floating, clients that have parent and thus
* we set the same tags and monitor than its parent, if not
* try to apply rules for them */
if ((p = client_get_parent(c))) {
c->isfloating = 1;
setmon(c, p->mon, p->tags, true);
} else {
applyrules(c); applyrules(c);
}
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
WLR_EDGE_RIGHT); WLR_EDGE_RIGHT);
@@ -4492,6 +4567,7 @@ void setmaximizescreen(Client *c, int maximizescreen) {
maximizescreen_box.width = c->mon->w.width - 2 * gappoh; maximizescreen_box.width = c->mon->w.width - 2 * gappoh;
maximizescreen_box.height = c->mon->w.height - 2 * gappov; maximizescreen_box.height = c->mon->w.height - 2 * gappov;
wlr_scene_node_raise_to_top(&c->scene->node); // 将视图提升到顶层 wlr_scene_node_raise_to_top(&c->scene->node); // 将视图提升到顶层
if (!is_scroller_layout(c->mon) || c->isfloating)
resize(c, maximizescreen_box, 0); resize(c, maximizescreen_box, 0);
c->ismaximizescreen = 1; c->ismaximizescreen = 1;
} else { } else {
@@ -4501,9 +4577,8 @@ void setmaximizescreen(Client *c, int maximizescreen) {
setfloating(c, 1); setfloating(c, 1);
} }
wlr_scene_node_reparent(&c->scene->node, layers[maximizescreen ? LyrTile wlr_scene_node_reparent(&c->scene->node,
: c->isfloating ? LyrTop layers[c->isfloating ? LyrTop : LyrTile]);
: LyrTile]);
if (!c->ismaximizescreen) { if (!c->ismaximizescreen) {
set_size_per(c->mon, c); set_size_per(c->mon, c);
} }
@@ -4549,6 +4624,7 @@ void setfullscreen(Client *c, int fullscreen) // 用自定义全屏代理自带
c->bw = 0; c->bw = 0;
wlr_scene_node_raise_to_top(&c->scene->node); // 将视图提升到顶层 wlr_scene_node_raise_to_top(&c->scene->node); // 将视图提升到顶层
if (!is_scroller_layout(c->mon) || c->isfloating)
resize(c, c->mon->m, 1); resize(c, c->mon->m, 1);
c->isfullscreen = 1; c->isfullscreen = 1;
} else { } else {
@@ -4747,8 +4823,11 @@ void setsel(struct wl_listener *listener, void *data) {
} }
void show_hide_client(Client *c) { void show_hide_client(Client *c) {
unsigned int target = 1;
set_size_per(c->mon, c);
target = get_tags_first_tag(c->oldtags);
unsigned int target = get_tags_first_tag(c->oldtags);
if (!c->is_in_scratchpad) { if (!c->is_in_scratchpad) {
tag_client(&(Arg){.ui = target}, c); tag_client(&(Arg){.ui = target}, c);
} else { } else {
@@ -4995,6 +5074,7 @@ void setup(void) {
* to let us know when new input devices are available on the backend. * to let us know when new input devices are available on the backend.
*/ */
wl_list_init(&inputdevices); wl_list_init(&inputdevices);
wl_list_init(&keyboard_shortcut_inhibitors);
wl_signal_add(&backend->events.new_input, &new_input_device); wl_signal_add(&backend->events.new_input, &new_input_device);
virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy); virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy);
wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard, wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard,
@@ -5024,6 +5104,10 @@ void setup(void) {
kb_group = createkeyboardgroup(); kb_group = createkeyboardgroup();
wl_list_init(&kb_group->destroy.link); wl_list_init(&kb_group->destroy.link);
keyboard_shortcuts_inhibit = wlr_keyboard_shortcuts_inhibit_v1_create(dpy);
wl_signal_add(&keyboard_shortcuts_inhibit->events.new_inhibitor,
&keyboard_shortcuts_inhibit_new_inhibitor);
output_mgr = wlr_output_manager_v1_create(dpy); output_mgr = wlr_output_manager_v1_create(dpy);
wl_signal_add(&output_mgr->events.apply, &output_mgr_apply); wl_signal_add(&output_mgr->events.apply, &output_mgr_apply);
wl_signal_add(&output_mgr->events.test, &output_mgr_test); wl_signal_add(&output_mgr->events.test, &output_mgr_test);
@@ -5116,7 +5200,11 @@ unsigned int want_restore_fullscreen(Client *target_client) {
Client *c = NULL; Client *c = NULL;
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (c && c != target_client && c->tags == target_client->tags && if (c && c != target_client && c->tags == target_client->tags &&
c == selmon->sel) { c == selmon->sel &&
c->mon->pertag->ltidxs[get_tags_first_tag_num(c->tags)]->id !=
SCROLLER &&
c->mon->pertag->ltidxs[get_tags_first_tag_num(c->tags)]->id !=
VERTICAL_SCROLLER) {
return 0; return 0;
} }
} }
@@ -5551,6 +5639,49 @@ void view(const Arg *arg, bool want_animation) {
} }
} }
static void
handle_keyboard_shortcuts_inhibitor_destroy(struct wl_listener *listener,
void *data) {
KeyboardShortcutsInhibitor *inhibitor =
wl_container_of(listener, inhibitor, destroy);
wlr_log(WLR_DEBUG, "Removing keyboard shortcuts inhibitor");
wl_list_remove(&inhibitor->link);
wl_list_remove(&inhibitor->destroy.link);
free(inhibitor);
}
void handle_keyboard_shortcuts_inhibit_new_inhibitor(
struct wl_listener *listener, void *data) {
struct wlr_keyboard_shortcuts_inhibitor_v1 *inhibitor = data;
if (allow_shortcuts_inhibit == SHORTCUTS_INHIBIT_DISABLE) {
return;
}
// per-view, seat-agnostic config via criteria
Client *c = get_client_from_surface(inhibitor->surface);
if (c && !c->allow_shortcuts_inhibit) {
return;
}
wlr_log(WLR_DEBUG, "Adding keyboard shortcuts inhibitor");
KeyboardShortcutsInhibitor *kbsinhibitor =
calloc(1, sizeof(KeyboardShortcutsInhibitor));
kbsinhibitor->inhibitor = inhibitor;
kbsinhibitor->destroy.notify = handle_keyboard_shortcuts_inhibitor_destroy;
wl_signal_add(&inhibitor->events.destroy, &kbsinhibitor->destroy);
wl_list_insert(&keyboard_shortcut_inhibitors, &kbsinhibitor->link);
wlr_keyboard_shortcuts_inhibitor_v1_activate(inhibitor);
}
void virtualkeyboard(struct wl_listener *listener, void *data) { void virtualkeyboard(struct wl_listener *listener, void *data) {
struct wlr_virtual_keyboard_v1 *kb = data; struct wlr_virtual_keyboard_v1 *kb = data;
/* virtual keyboards shouldn't share keyboard group */ /* virtual keyboards shouldn't share keyboard group */