Compare commits

35 Commits

Author SHA1 Message Date
be6ed1764f fix do not scroll to index zero when no window in row is focused 2025-11-16 02:00:42 +01:00
3de0ce410a update use dedicated row identifiers 2025-11-16 01:19:44 +01:00
deae7862e3 add only respect scroller centering on bottom row 2025-11-16 00:57:12 +01:00
ccb2a99bfb fix row consistent movement and focus 2025-11-16 00:29:13 +01:00
7641a65a89 fix rows keep their position when left 2025-11-16 00:08:10 +01:00
6b75a50ed5 fix overlapping tiles 2025-11-16 00:00:08 +01:00
f18e43c2c6 add first running version 2025-11-15 23:52:02 +01:00
DreamMaoMao
8ab59c1aca feat: support scroll maximize and fullscreen window
Some checks failed
Close manually marked stale issues / close-issues (push) Has been cancelled
Lock Threads / lock (push) Has been cancelled
2025-11-15 00:08:57 +08:00
DreamMaoMao
b3578344dc opt: optimize init focus for x11 window 2025-11-14 17:13:26 +08:00
DreamMaoMao
389f417a3b feat: add windowrule option scroller_proportion_single 2025-11-14 15:39:04 +08:00
DreamMaoMao
d2e0df024d opt: optimize code struct 2025-11-14 12:32:07 +08:00
DreamMaoMao
bd6a71f05e fix: fix border color change when swithc mon focus 2025-11-14 12:21:06 +08:00
DreamMaoMao
cfb66111de fix: tagrule not apply correctly 2025-11-14 11:53:41 +08:00
DreamMaoMao
94e47bc3b0 opt: optmize restore_minimized size and not restore namedscratchpad 2025-11-13 10:59:04 +08:00
DreamMaoMao
43424152f3 opt: spawn_on_empty and toggle_named_scratchapd use spawn_shell 2025-11-13 10:49:44 +08:00
DreamMaoMao
0ff4d94365 opt: remove useless normalize keysym convert 2025-11-13 10:42:35 +08:00
DreamMaoMao
ade00f88f0 fix: crash in some crossmon dispatch 2025-11-12 23:10:09 +08:00
DreamMaoMao
7ed12cf921 feat: support keyboard shortcut inhibitor 2025-11-12 18:11:44 +08:00
DreamMaoMao
64d8764f58 update readme 2025-11-10 14:30:20 +08:00
DreamMaoMao
d0a51f4785 opt: remove useless code 2025-11-09 23:19:49 +08:00
DreamMaoMao
7552e77781 Merge pull request #403 from Yappaholic/main
nix: bump scenefx flake and fix build
2025-11-09 18:13:28 +08:00
DreamMaoMao
c206693257 feat: support nofucs rule for some special window 2025-11-09 17:53:18 +08:00
DreamMaoMao
11dfab478a opt: disable switch proportion action in some case 2025-11-09 09:45:55 +08:00
DreamMaoMao
3cfcaa21c0 opt: not resizewin in overview 2025-11-08 22:48:53 +08:00
DreamMaoMao
276560840b opt: remove increase_proportion dispatch
should use resizewin to replace it
2025-11-08 22:47:18 +08:00
Yappaholic
ee789613ff nix: bump scenefx flake and fix build 2025-11-08 16:43:20 +03:00
DreamMaoMao
8ac331aa64 opt: disable resize scroller window when it force to default single size 2025-11-08 20:35:06 +08:00
DreamMaoMao
e59b9c10b5 opt: optimize shadow node and blur node enable 2025-11-08 20:27:29 +08:00
DreamMaoMao
9fecdb6c3a fix: blur node size and position are wrong 2025-11-08 19:59:05 +08:00
DreamMaoMao
c51cf7d6cc opt:optimize code struct 2025-11-08 12:39:41 +08:00
DreamMaoMao
a42939f0c2 feat: add global option scroller_ignore_proportion_single 2025-11-08 10:35:16 +08:00
DreamMaoMao
fbdf7fdb34 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-07 22:49:35 +08:00
eater
16dc4fa9cd check is drm_release_manager is set before cleaning up to avoid segfault 2025-11-07 15:44:47 +01:00
DreamMaoMao
9b97d11c83 fix: crash when click waybar overview button 2025-11-07 21:56:25 +08:00
DreamMaoMao
58790c0e53 fix: adjust scenefx blur node feature 2025-11-07 14:29:56 +08:00
18 changed files with 822 additions and 256 deletions

View File

@@ -101,7 +101,7 @@ 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
@@ -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

46
flake.lock generated
View File

@@ -18,6 +18,27 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils": {
"inputs": {
"systems": [
"scenefx",
"systems"
]
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1750386251, "lastModified": 1750386251,
@@ -58,16 +79,18 @@
}, },
"scenefx": { "scenefx": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ],
"systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1750785057, "lastModified": 1762447505,
"narHash": "sha256-tGX6j4W91rcb+glXJo43sjPI9zQvPotonknG1BdihR4=", "narHash": "sha256-VEBQ8KXkSS4c+kdAhmvq06lEd9WNeCXdRK1U+qSilFw=",
"owner": "wlrfx", "owner": "wlrfx",
"repo": "scenefx", "repo": "scenefx",
"rev": "3a6cfb12e4ba97b43326357d14f7b3e40897adfc", "rev": "7f9e7409f6169fa637f1265895c121a8f8b70272",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -75,6 +98,21 @@
"repo": "scenefx", "repo": "scenefx",
"type": "github" "type": "github"
} }
},
"systems": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View File

@@ -25,12 +25,13 @@
perSystem = { perSystem = {
config, config,
system,
pkgs, pkgs,
... ...
}: let }: let
inherit (pkgs) callPackage; inherit (pkgs) callPackage;
mango = callPackage ./nix { mango = callPackage ./nix {
inherit (inputs.scenefx.packages.${pkgs.stdenv.hostPlatform.system}) scenefx; scenefx = inputs.scenefx.packages.${system}.default;
}; };
shellOverride = old: { shellOverride = old: {
nativeBuildInputs = old.nativeBuildInputs ++ []; nativeBuildInputs = old.nativeBuildInputs ++ [];

View File

@@ -245,6 +245,10 @@ void buffer_set_effect(Client *c, BufferData data) {
data.corner_location = CORNER_LOCATION_NONE; data.corner_location = CORNER_LOCATION_NONE;
} }
if (blur && !c->noblur) {
wlr_scene_blur_set_corner_radius(c->blur, border_radius,
data.corner_location);
}
wlr_scene_node_for_each_buffer(&c->scene_surface->node, wlr_scene_node_for_each_buffer(&c->scene_surface->node,
scene_buffer_apply_effect, &data); scene_buffer_apply_effect, &data);
} }
@@ -255,8 +259,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);
@@ -345,6 +353,19 @@ void client_draw_shadow(Client *c) {
wlr_scene_shadow_set_clipped_region(c->shadow, clipped_region); wlr_scene_shadow_set_clipped_region(c->shadow, clipped_region);
} }
void client_draw_blur(Client *c, struct wlr_box clip_box, struct ivec2 offset) {
if (blur && !c->noblur) {
if (c->scene_surface->node.enabled && !c->blur->node.enabled)
wlr_scene_node_set_enabled(&c->blur->node, true);
wlr_scene_node_set_position(&c->blur->node, offset.x, offset.y);
wlr_scene_blur_set_size(c->blur, clip_box.width - c->bw,
clip_box.height - c->bw);
} else {
if (c->blur->node.enabled)
wlr_scene_node_set_enabled(&c->blur->node, false);
}
}
void apply_border(Client *c) { void apply_border(Client *c) {
if (!c || c->iskilling || !client_surface(c)->mapped) if (!c || c->iskilling || !client_surface(c)->mapped)
return; return;
@@ -529,12 +550,14 @@ void client_apply_clip(Client *c, float factor) {
apply_border(c); apply_border(c);
client_draw_shadow(c); client_draw_shadow(c);
client_draw_blur(c, clip_box, offset);
if (clip_box.width <= 0 || clip_box.height <= 0) { if (clip_box.width <= 0 || clip_box.height <= 0) {
return; return;
} }
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box); wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box);
buffer_set_effect(c, (BufferData){1.0f, 1.0f, clip_box.width, buffer_set_effect(c, (BufferData){1.0f, 1.0f, clip_box.width,
clip_box.height, clip_box.height,
current_corner_location, true}); current_corner_location, true});
@@ -566,6 +589,7 @@ void client_apply_clip(Client *c, float factor) {
// 应用窗口装饰 // 应用窗口装饰
apply_border(c); apply_border(c);
client_draw_shadow(c); client_draw_shadow(c);
client_draw_blur(c, clip_box, offset);
// 如果窗口剪切区域已经剪切到0则不渲染窗口表面 // 如果窗口剪切区域已经剪切到0则不渲染窗口表面
if (clip_box.width <= 0 || clip_box.height <= 0) { if (clip_box.width <= 0 || clip_box.height <= 0) {
@@ -987,6 +1011,10 @@ void resize(Client *c, struct wlr_box geo, int interact) {
apply_border(c); apply_border(c);
client_get_clip(c, &clip); client_get_clip(c, &clip);
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip); wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
if (blur && !c->noblur)
wlr_scene_blur_set_size(c->blur,
c->animation.current.width - 2 * c->bw,
c->animation.current.height - 2 * c->bw);
return; return;
} }
// 如果不是工作区切换时划出去的窗口,就让动画的结束位置,就是上面的真实位置和大小 // 如果不是工作区切换时划出去的窗口,就让动画的结束位置,就是上面的真实位置和大小
@@ -1056,7 +1084,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

@@ -158,12 +158,6 @@ static bool scene_node_snapshot(struct wlr_scene_node *node, int lx, int ly,
scene_buffer->corner_radius, scene_buffer->corner_radius,
scene_buffer->corners); scene_buffer->corners);
// wlr_scene_buffer_set_backdrop_blur_optimized(
// snapshot_buffer, scene_buffer->backdrop_blur_optimized);
// wlr_scene_buffer_set_backdrop_blur_ignore_transparent(
// snapshot_buffer, scene_buffer->backdrop_blur_ignore_transparent);
wlr_scene_buffer_set_backdrop_blur(snapshot_buffer, false);
snapshot_buffer->node.data = scene_buffer->node.data; snapshot_buffer->node.data = scene_buffer->node.data;
struct wlr_scene_surface *scene_surface = struct wlr_scene_surface *scene_surface =
@@ -198,6 +192,8 @@ static bool scene_node_snapshot(struct wlr_scene_node *node, int lx, int ly,
break; break;
} }
case WLR_SCENE_NODE_BLUR:
break;
case WLR_SCENE_NODE_OPTIMIZED_BLUR: case WLR_SCENE_NODE_OPTIMIZED_BLUR:
return true; return true;
} }

View File

@@ -356,6 +356,10 @@ void layer_animation_next_tick(LayerSurface *l) {
.height = height, .height = height,
}; };
if (blur && blur_layer && !l->noblur && l->blur)
wlr_scene_blur_set_size(l->blur, l->animation.current.width,
l->animation.current.height);
if (animation_passed >= 1.0) { if (animation_passed >= 1.0) {
l->animation.running = false; l->animation.running = false;
l->need_output_flush = false; l->need_output_flush = false;

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) {
@@ -864,6 +814,8 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
} else if (strcmp(func_name, "focusdir") == 0) { } else if (strcmp(func_name, "focusdir") == 0) {
func = focusdir; func = focusdir;
(*arg).i = parse_direction(arg_value); (*arg).i = parse_direction(arg_value);
} else if (strcmp(func_name, "togglerow") == 0) {
func = togglerow;
} else if (strcmp(func_name, "incnmaster") == 0) { } else if (strcmp(func_name, "incnmaster") == 0) {
func = incnmaster; func = incnmaster;
(*arg).i = atoi(arg_value); (*arg).i = atoi(arg_value);
@@ -886,9 +838,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 +1159,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 +1221,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 +1660,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 +1670,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 +1682,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 +1726,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 +1754,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) {
@@ -2665,6 +2627,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 +2654,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 +2817,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 +2832,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;
@@ -3203,33 +3171,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;
}
}
}
}
} }
} }

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

@@ -2,9 +2,9 @@ int minimized(const Arg *arg);
int restore_minimized(const Arg *arg); int restore_minimized(const Arg *arg);
int toggle_scratchpad(const Arg *arg); int toggle_scratchpad(const Arg *arg);
int focusdir(const Arg *arg); int focusdir(const Arg *arg);
int togglerow(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

@@ -121,6 +121,29 @@ int focusdir(const Arg *arg) {
return 0; return 0;
} }
int togglerow(const Arg *arg) {
// Toggle between top and bottom row in dual-scroller layout
if (!selmon || !selmon->sel || !is_row_layout(selmon))
return 0;
Client *c = selmon->sel;
// Only toggle for tiled windows
if (c->isfloating || !ISSCROLLTILED(c) || !VISIBLEON(c, selmon))
return 0;
// Toggle the row (0 <-> 1)
if (c->dual_scroller_row == 0) {
c->dual_scroller_row = 1;
} else {
c->dual_scroller_row = 0;
}
// Trigger a relayout
arrange(selmon, false);
return 0;
}
int focuslast(const Arg *arg) { int focuslast(const Arg *arg) {
Client *c = NULL; Client *c = NULL;
@@ -202,7 +225,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 +304,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 +499,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;
@@ -530,6 +541,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 +828,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;
} }
@@ -931,6 +950,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 +994,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 +1003,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 +1111,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

@@ -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,10 +142,11 @@ 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;
bool constrain_to_row = tc->mon && is_row_layout(tc->mon);
// 第一次遍历,计算客户端数量 // 第一次遍历,计算客户端数量
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
@@ -185,6 +186,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 +201,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 +218,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 +233,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 +250,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
} }
break; break;
case LEFT: case LEFT:
if (!ignore_align || constrain_to_row) {
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 +265,8 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
} }
} }
} }
if (!tempFocusClients && !align) { }
if (!tempFocusClients && !constrain_to_row) {
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 +282,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
} }
break; break;
case RIGHT: case RIGHT:
if (!ignore_align || constrain_to_row) {
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 +297,8 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
} }
} }
} }
if (!tempFocusClients && !align) { }
if (!tempFocusClients && !constrain_to_row) {
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 +326,12 @@ 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)) {
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));
} }
/* 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

@@ -23,6 +23,19 @@ bool is_scroller_layout(Monitor *m) {
if (m->pertag->ltidxs[m->pertag->curtag]->id == VERTICAL_SCROLLER) if (m->pertag->ltidxs[m->pertag->curtag]->id == VERTICAL_SCROLLER)
return true; return true;
if (m->pertag->ltidxs[m->pertag->curtag]->id == DUAL_SCROLLER)
return true;
return false;
}
bool is_row_layout(Monitor *m) {
// Layout has independent horizontal rows where navigation should be constrained
// LEFT/RIGHT: stay within same row (same Y)
// UP/DOWN: move between rows
if (m->pertag->ltidxs[m->pertag->curtag]->id == DUAL_SCROLLER)
return true;
return false; return false;
} }

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 ||
@@ -491,6 +498,8 @@ void resize_tile_client(Client *grabc, bool isdrag, int offsetx, int offsety,
resize_tile_scroller(grabc, isdrag, offsetx, offsety, time, false); resize_tile_scroller(grabc, isdrag, offsetx, offsety, time, false);
} else if (current_layout->id == VERTICAL_SCROLLER) { } else if (current_layout->id == VERTICAL_SCROLLER) {
resize_tile_scroller(grabc, isdrag, offsetx, offsety, time, true); resize_tile_scroller(grabc, isdrag, offsetx, offsety, time, true);
} else if (current_layout->id == DUAL_SCROLLER) {
resize_tile_scroller(grabc, isdrag, offsetx, offsety, time, false);
} }
} }
@@ -592,6 +601,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 +622,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);
@@ -274,17 +314,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 +358,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;
@@ -324,6 +378,212 @@ void scroller(Monitor *m) {
free(tempClients); // 最后释放内存 free(tempClients); // 最后释放内存
} }
// Dual-row scroller layout with independent scrolling
// Top row: 30% of screen height, Bottom row: 70% of screen height
void dual_scroller(Monitor *m) {
unsigned int i, n_top = 0, n_bottom = 0, n_total = 0;
Client *c = NULL;
Client **top_row_clients = NULL;
Client **bottom_row_clients = NULL;
struct wlr_box target_geom;
unsigned int cur_gappih = enablegaps ? m->gappih : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
unsigned int cur_gappiv = enablegaps ? m->gappiv : 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;
cur_gappiv =
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappiv;
unsigned int max_client_width =
m->w.width - 2 * scroller_structs - cur_gappih;
n_total = m->visible_scroll_tiling_clients;
if (n_total == 0) {
return;
}
// First pass: count clients per row and assign unassigned clients
wl_list_for_each(c, &clients, link) {
if (VISIBLEON(c, m) && ISSCROLLTILED(c)) {
// Assign to bottom row by default if not assigned
if (c->dual_scroller_row == -1) {
c->dual_scroller_row = 1; // Default to bottom row
}
if (c->dual_scroller_row == 0) {
n_top++;
} else {
n_bottom++;
}
}
}
// Allocate arrays for each row
if (n_top > 0) {
top_row_clients = malloc(n_top * sizeof(Client *));
if (!top_row_clients) {
return;
}
}
if (n_bottom > 0) {
bottom_row_clients = malloc(n_bottom * sizeof(Client *));
if (!bottom_row_clients) {
free(top_row_clients);
return;
}
}
// Fill row arrays
unsigned int top_idx = 0, bottom_idx = 0;
wl_list_for_each(c, &clients, link) {
if (VISIBLEON(c, m) && ISSCROLLTILED(c)) {
if (c->dual_scroller_row == 0) {
top_row_clients[top_idx++] = c;
} else {
bottom_row_clients[bottom_idx++] = c;
}
}
}
// Calculate row heights (30% top, 70% bottom)
unsigned int top_row_height = (unsigned int)((m->w.height - 2 * cur_gappov - cur_gappiv) * 0.3);
unsigned int bottom_row_height = m->w.height - 2 * cur_gappov - cur_gappiv - top_row_height;
unsigned int top_row_y = m->w.y + cur_gappov;
unsigned int bottom_row_y = top_row_y + top_row_height + cur_gappiv;
// Helper function to layout a single row
void layout_row(Client **row_clients, unsigned int n_row, unsigned int row_y,
unsigned int row_height, bool is_top_row) {
if (n_row == 0) return;
Client *root_client = NULL;
int focus_index = -1;
bool need_scroller = false;
// Find focused client in this row
for (i = 0; i < n_row; i++) {
if (row_clients[i] == m->sel) {
root_client = row_clients[i];
focus_index = i;
break;
}
}
// If no focused client in this row, keep current scroll position
if (!root_client && n_row > 0) {
return;
}
// Check if scrolling is needed
if (root_client && !root_client->is_pending_open_animation &&
root_client->geom.x >= m->w.x + scroller_structs &&
root_client->geom.x + root_client->geom.width <=
m->w.x + m->w.width - scroller_structs) {
need_scroller = false;
} else {
need_scroller = true;
}
if (start_drag_window)
need_scroller = false;
// Layout focused client
if (focus_index >= 0 && root_client) {
target_geom.height = row_height;
target_geom.width = max_client_width * root_client->scroller_proportion;
target_geom.y = row_y;
// Handle fullscreen and maximize
if (root_client->isfullscreen) {
target_geom.height = m->m.height;
target_geom.width = m->m.width;
target_geom.y = m->m.y;
target_geom.x = m->m.x;
resize(root_client, target_geom, 0);
} else if (root_client->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;
target_geom.x = m->w.x + cur_gappoh;
resize(root_client, target_geom, 0);
} else if (need_scroller) {
// Determine if we should center
bool should_center = (scroller_focus_center ||
((!m->prevsel ||
(ISSCROLLTILED(m->prevsel) &&
(m->prevsel->scroller_proportion * max_client_width) +
(root_client->scroller_proportion * max_client_width) >
m->w.width - 2 * scroller_structs - cur_gappih)) &&
scroller_prefer_center));
// Top row: never center
if (is_top_row) {
should_center = false;
}
if (should_center) {
target_geom.x = m->w.x + (m->w.width - target_geom.width) / 2;
} else {
target_geom.x = root_client->geom.x > m->w.x + (m->w.width) / 2
? m->w.x + (m->w.width -
root_client->scroller_proportion *
max_client_width -
scroller_structs)
: m->w.x + scroller_structs;
}
resize(root_client, target_geom, 0);
} else {
target_geom.x = root_client->geom.x;
resize(root_client, target_geom, 0);
}
}
// Layout clients to the left of focused
for (i = focus_index - 1; i >= 0 && i < n_row; i--) {
c = row_clients[i];
target_geom.width = max_client_width * c->scroller_proportion;
target_geom.height = row_height;
target_geom.y = row_y;
if (!c->isfullscreen && !c->ismaximizescreen) {
target_geom.x = row_clients[i + 1]->geom.x - cur_gappih - target_geom.width;
resize(c, target_geom, 0);
}
}
// Layout clients to the right of focused
for (i = focus_index + 1; i < n_row; i++) {
c = row_clients[i];
target_geom.width = max_client_width * c->scroller_proportion;
target_geom.height = row_height;
target_geom.y = row_y;
if (!c->isfullscreen && !c->ismaximizescreen) {
target_geom.x = row_clients[i - 1]->geom.x + cur_gappih + row_clients[i - 1]->geom.width;
resize(c, target_geom, 0);
}
}
}
// Layout both rows independently
layout_row(top_row_clients, n_top, top_row_y, top_row_height, true);
layout_row(bottom_row_clients, n_bottom, bottom_row_y, bottom_row_height, false);
// Cleanup
free(top_row_clients);
free(bottom_row_clients);
}
void center_tile(Monitor *m) { void center_tile(Monitor *m) {
unsigned int i, n = 0, h, r, ie = enablegaps, mw, mx, my, oty, ety, tw; unsigned int i, n = 0, h, r, ie = enablegaps, mw, mx, my, oty, ety, tw;
Client *c = NULL; Client *c = NULL;

View File

@@ -11,6 +11,7 @@ static void vertical_overview(Monitor *m);
static void vertical_grid(Monitor *m); static void vertical_grid(Monitor *m);
static void vertical_scroller(Monitor *m); static void vertical_scroller(Monitor *m);
static void vertical_deck(Monitor *mon); static void vertical_deck(Monitor *mon);
static void dual_scroller(Monitor *mon);
/* layout(s) */ /* layout(s) */
Layout overviewlayout = {"󰃇", overview, "overview"}; Layout overviewlayout = {"󰃇", overview, "overview"};
@@ -27,6 +28,7 @@ enum {
VERTICAL_GRID, VERTICAL_GRID,
VERTICAL_DECK, VERTICAL_DECK,
RIGHT_TILE, RIGHT_TILE,
DUAL_SCROLLER,
}; };
Layout layouts[] = { Layout layouts[] = {
@@ -44,4 +46,5 @@ Layout layouts[] = {
{"VT", vertical_tile, "vertical_tile", VERTICAL_TILE}, // 垂直平铺布局 {"VT", vertical_tile, "vertical_tile", VERTICAL_TILE}, // 垂直平铺布局
{"VG", vertical_grid, "vertical_grid", VERTICAL_GRID}, // 垂直格子布局 {"VG", vertical_grid, "vertical_grid", VERTICAL_GRID}, // 垂直格子布局
{"VK", vertical_deck, "vertical_deck", VERTICAL_DECK}, // 垂直卡片布局 {"VK", vertical_deck, "vertical_deck", VERTICAL_DECK}, // 垂直卡片布局
{"DS", dual_scroller, "dual_scroller", DUAL_SCROLLER}, // 双行滚动布局
}; };

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);
@@ -235,14 +276,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 +321,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;
@@ -276,6 +285,7 @@ struct Client {
struct wlr_scene_tree *scene; struct wlr_scene_tree *scene;
struct wlr_scene_rect *border; /* top, bottom, left, right */ struct wlr_scene_rect *border; /* top, bottom, left, right */
struct wlr_scene_shadow *shadow; struct wlr_scene_shadow *shadow;
struct wlr_scene_blur *blur;
struct wlr_scene_tree *scene_surface; struct wlr_scene_tree *scene_surface;
struct wl_list link; struct wl_list link;
struct wl_list flink; struct wl_list flink;
@@ -352,6 +362,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;
@@ -364,10 +375,13 @@ struct Client {
double old_master_mfact_per, old_master_inner_per, old_stack_innder_per; double old_master_mfact_per, old_master_inner_per, old_stack_innder_per;
double old_scroller_pproportion; double old_scroller_pproportion;
bool ismaster; bool ismaster;
int dual_scroller_row; // 0 = top row, 1 = bottom row, -1 = not set
bool cursor_in_upper_half, cursor_in_left_half; bool cursor_in_upper_half, cursor_in_left_half;
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 +411,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 */
@@ -405,6 +425,7 @@ typedef struct {
struct wlr_scene_tree *scene; struct wlr_scene_tree *scene;
struct wlr_scene_tree *popups; struct wlr_scene_tree *popups;
struct wlr_scene_shadow *shadow; struct wlr_scene_shadow *shadow;
struct wlr_scene_blur *blur;
struct wlr_scene_layer_surface_v1 *scene_layer; struct wlr_scene_layer_surface_v1 *scene_layer;
struct wl_list link; struct wl_list link;
struct wl_list fadeout_link; struct wl_list fadeout_link;
@@ -464,6 +485,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 +643,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);
@@ -698,6 +722,7 @@ static struct wlr_scene_tree *
wlr_scene_tree_snapshot(struct wlr_scene_node *node, wlr_scene_tree_snapshot(struct wlr_scene_node *node,
struct wlr_scene_tree *parent); struct wlr_scene_tree *parent);
static bool is_scroller_layout(Monitor *m); static bool is_scroller_layout(Monitor *m);
static bool is_row_layout(Monitor *m);
static void create_output(struct wlr_backend *backend, void *data); static void create_output(struct wlr_backend *backend, void *data);
static void get_layout_abbr(char *abbr, const char *full_name); static void get_layout_abbr(char *abbr, const char *full_name);
static void apply_named_scratchpad(Client *target_client); static void apply_named_scratchpad(Client *target_client);
@@ -749,6 +774,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 +799,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 +886,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);
@@ -910,6 +940,10 @@ void applybounds(Client *c, struct wlr_box *bbox) {
/*清除全屏标志,还原全屏时清0的border*/ /*清除全屏标志,还原全屏时清0的border*/
void clear_fullscreen_flag(Client *c) { void clear_fullscreen_flag(Client *c) {
if (is_scroller_layout(c->mon))
return;
if (c->isfullscreen) { if (c->isfullscreen) {
setfullscreen(c, false); setfullscreen(c, false);
} }
@@ -1130,6 +1164,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 +1183,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 +1280,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 +1306,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 +1380,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 +2012,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);
@@ -2081,12 +2132,16 @@ static void iter_layer_scene_buffers(struct wlr_scene_buffer *buffer, int sx,
return; return;
} }
wlr_scene_buffer_set_backdrop_blur(buffer, true); LayerSurface *l = (LayerSurface *)user_data;
wlr_scene_buffer_set_backdrop_blur_ignore_transparent(buffer, true);
wlr_scene_node_set_enabled(&l->blur->node, true);
wlr_scene_blur_set_transparency_mask_source(l->blur, buffer);
wlr_scene_blur_set_size(l->blur, l->geom.width, l->geom.height);
if (blur_optimized) { if (blur_optimized) {
wlr_scene_buffer_set_backdrop_blur_optimized(buffer, true); wlr_scene_blur_set_should_only_blur_bottom_layer(l->blur, true);
} else { } else {
wlr_scene_buffer_set_backdrop_blur_optimized(buffer, false); wlr_scene_blur_set_should_only_blur_bottom_layer(l->blur, false);
} }
} }
@@ -2131,15 +2186,19 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) {
} }
// 初始化阴影 // 初始化阴影
if (layer_surface->current.exclusive_zone == 0 && if (layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM &&
layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM &&
layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) { layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) {
if (layer_surface->current.exclusive_zone == 0) {
l->shadow = wlr_scene_shadow_create(l->scene, 0, 0, border_radius, l->shadow = wlr_scene_shadow_create(l->scene, 0, 0, border_radius,
shadows_blur, shadowscolor); shadows_blur, shadowscolor);
wlr_scene_node_lower_to_bottom(&l->shadow->node); wlr_scene_node_lower_to_bottom(&l->shadow->node);
wlr_scene_node_set_enabled(&l->shadow->node, true); wlr_scene_node_set_enabled(&l->shadow->node, true);
} }
l->blur = wlr_scene_blur_create(l->scene, 0, 0);
wlr_scene_node_lower_to_bottom(&l->blur->node);
}
// 初始化动画 // 初始化动画
if (animations && layer_animations && !l->noanim) { if (animations && layer_animations && !l->noanim) {
l->animation.duration = animation_duration_open; l->animation.duration = animation_duration_open;
@@ -2194,7 +2253,8 @@ void commitlayersurfacenotify(struct wl_listener *listener, void *data) {
if (!l->noblur && if (!l->noblur &&
layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM && layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM &&
layer_surface->current.layer != layer_surface->current.layer !=
ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) { ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND &&
l->blur) {
wlr_scene_node_for_each_buffer(&l->scene->node, wlr_scene_node_for_each_buffer(&l->scene->node,
iter_layer_scene_buffers, l); iter_layer_scene_buffers, l);
@@ -2658,18 +2718,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:
* *
@@ -2724,6 +2773,7 @@ createnotify(struct wl_listener *listener, void *data) {
c = toplevel->base->data = ecalloc(1, sizeof(*c)); c = toplevel->base->data = ecalloc(1, sizeof(*c));
c->surface.xdg = toplevel->base; c->surface.xdg = toplevel->base;
c->bw = borderpx; c->bw = borderpx;
c->dual_scroller_row = -1; // Not assigned to a row yet
LISTEN(&toplevel->base->surface->events.commit, &c->commit, commitnotify); LISTEN(&toplevel->base->surface->events.commit, &c->commit, commitnotify);
LISTEN(&toplevel->base->surface->events.map, &c->map, mapnotify); LISTEN(&toplevel->base->surface->events.map, &c->map, mapnotify);
@@ -3067,6 +3117,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 +3135,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 +3154,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 +3171,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 +3306,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 +3335,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 +3363,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 ||
@@ -3521,15 +3593,15 @@ static void iter_xdg_scene_buffers(struct wlr_scene_buffer *buffer, int sx,
return; return;
if (blur && c && !c->noblur) { if (blur && c && !c->noblur) {
wlr_scene_buffer_set_backdrop_blur(buffer, true); wlr_scene_node_set_enabled(&c->blur->node, true);
wlr_scene_buffer_set_backdrop_blur_ignore_transparent(buffer, false); // wlr_scene_blur_set_transparency_mask_source(c->blur, buffer);
if (blur_optimized) { if (blur_optimized) {
wlr_scene_buffer_set_backdrop_blur_optimized(buffer, true); wlr_scene_blur_set_should_only_blur_bottom_layer(c->blur, true);
} else { } else {
wlr_scene_buffer_set_backdrop_blur_optimized(buffer, false); wlr_scene_blur_set_should_only_blur_bottom_layer(c->blur, false);
} }
} else { } else {
wlr_scene_buffer_set_backdrop_blur(buffer, false); wlr_scene_node_set_enabled(&c->blur->node, false);
} }
} }
@@ -3558,6 +3630,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 +3646,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 */
@@ -3642,6 +3716,9 @@ mapnotify(struct wl_listener *listener, void *data) {
c->shadow = wlr_scene_shadow_create(c->scene, 0, 0, border_radius, c->shadow = wlr_scene_shadow_create(c->scene, 0, 0, border_radius,
shadows_blur, shadowscolor); shadows_blur, shadowscolor);
c->blur = wlr_scene_blur_create(c->scene_surface, 0, 0);
wlr_scene_node_lower_to_bottom(&c->blur->node);
wlr_scene_node_lower_to_bottom(&c->shadow->node); wlr_scene_node_lower_to_bottom(&c->shadow->node);
wlr_scene_node_set_enabled(&c->shadow->node, true); wlr_scene_node_set_enabled(&c->shadow->node, true);
@@ -3651,7 +3728,7 @@ mapnotify(struct wl_listener *listener, void *data) {
else if (selmon && is_scroller_layout(selmon) && else if (selmon && is_scroller_layout(selmon) &&
selmon->visible_tiling_clients > 0) { selmon->visible_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 {
@@ -3659,6 +3736,11 @@ mapnotify(struct wl_listener *listener, void *data) {
} }
if (at_client) { if (at_client) {
// For row-based layouts, assign new client to same row as focused client
if (is_row_layout(selmon) && at_client->dual_scroller_row >= 0) {
c->dual_scroller_row = at_client->dual_scroller_row;
}
at_client->link.next->prev = &c->link; at_client->link.next->prev = &c->link;
c->link.prev = &at_client->link; c->link.prev = &at_client->link;
c->link.next = at_client->link.next; c->link.next = at_client->link.next;
@@ -3670,16 +3752,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 +4565,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))
resize(c, maximizescreen_box, 0); resize(c, maximizescreen_box, 0);
c->ismaximizescreen = 1; c->ismaximizescreen = 1;
} else { } else {
@@ -4549,6 +4623,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))
resize(c, c->mon->m, 1); resize(c, c->mon->m, 1);
c->isfullscreen = 1; c->isfullscreen = 1;
} else { } else {
@@ -4747,8 +4822,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 +5073,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 +5103,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);
@@ -5551,6 +5634,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 */
@@ -5671,6 +5797,7 @@ void createnotifyx11(struct wl_listener *listener, void *data) {
c = xsurface->data = ecalloc(1, sizeof(*c)); c = xsurface->data = ecalloc(1, sizeof(*c));
c->surface.xwayland = xsurface; c->surface.xwayland = xsurface;
c->type = X11; c->type = X11;
c->dual_scroller_row = -1; // Not assigned to a row yet
/* Listen to the various events it can emit */ /* Listen to the various events it can emit */
LISTEN(&xsurface->events.associate, &c->associate, associatex11); LISTEN(&xsurface->events.associate, &c->associate, associatex11);
LISTEN(&xsurface->events.destroy, &c->destroy, destroynotify); LISTEN(&xsurface->events.destroy, &c->destroy, destroynotify);