Compare commits

...

94 Commits

Author SHA1 Message Date
rasmusq
9d04eff5ea Merge branch 'main' into feature/dual-row-scroller 2025-12-10 22:05:56 +01:00
DreamMaoMao
f771e56c31 opt: optimize handle foreign toplevel
Some checks failed
Close manually marked stale issues / close-issues (push) Has been cancelled
Lock Threads / lock (push) Has been cancelled
2025-12-10 22:35:45 +08:00
DreamMaoMao
64d350ee9b feat: add bing flag p 2025-12-10 20:11:55 +08:00
DreamMaoMao
4e296671c2 feat: handle foreign toplevel minimize and maximize request 2025-12-10 19:36:32 +08:00
DreamMaoMao
31d29fb48c opt: format code 2025-12-10 18:32:06 +08:00
DreamMaoMao
2aa7e58d7c opt: optimize get client from surface 2025-12-10 18:30:45 +08:00
DreamMaoMao
01e957f2ae opt: allow layershell surface toggle shortcut inhibit 2025-12-10 18:29:16 +08:00
DreamMaoMao
318dc85b22 opt: eliminate the positional deviation in master layout 2025-12-09 20:49:28 +08:00
DreamMaoMao
dfb59d12c2 fix: excrescent border in grid layout 2025-12-09 09:40:22 +08:00
DreamMaoMao
c3253af75d Merge pull request #490 from Mental-Vortex/main
feat: Move window to center when in scroller layout
2025-12-08 22:15:40 +08:00
Mental-Vortex
9a2d2397c1 feat: support centerwin in scroller window 2025-12-08 22:14:14 +08:00
DreamMaoMao
dd72e472bf update readme 2025-12-08 09:42:18 +08:00
DreamMaoMao
f3f3215791 fix: nmaster num caculate error in master layout 2025-12-07 21:34:05 +08:00
DreamMaoMao
1e8e4677dd Merge pull request #488 from Owen-sz/main
doc: add Fedora install instructions
2025-12-07 10:12:00 +08:00
Owen-sz
6086507c5a doc: add Fedora install instructions
Signed-off-by: Owen-sz <owen@fyralabs.com>
2025-12-06 14:50:54 -06:00
rasmusq
178fa5220e Merge branch 'main' into feature/dual-row-scroller 2025-12-04 16:26:20 +01:00
DreamMaoMao
0e59209d2b opt: focusdir use same monitor client first
Some checks failed
Close manually marked stale issues / close-issues (push) Has been cancelled
Lock Threads / lock (push) Has been cancelled
2025-12-04 17:41:25 +08:00
DreamMaoMao
e602605fa4 opt: optimize focus change when change monitor 2025-12-04 09:58:16 +08:00
DreamMaoMao
1b739a1c7e update readme 2025-12-04 09:22:42 +08:00
DreamMaoMao
11b425faad opt: avoid unnecessary focus animations 2025-12-03 22:06:17 +08:00
DreamMaoMao
44c271ee52 opt: optimize border color set when change monitor 2025-12-03 21:58:46 +08:00
DreamMaoMao
2258574e25 bump version to 0.10.7 2025-12-03 18:15:56 +08:00
DreamMaoMao
02377e2867 fix: change u_int32_t to uint32_t 2025-12-03 18:15:35 +08:00
DreamMaoMao
4277159219 opt: add some usage message 2025-12-03 18:15:35 +08:00
DreamMaoMao
e965264f3b fix: dont use evenmask 2025-12-03 17:22:27 +08:00
DreamMaoMao
5c314be8c6 break change: remove autostar.sh and MANGOCONFIG env 2025-12-03 16:22:13 +08:00
DreamMaoMao
1ffdc1ef38 feat: support -c option to specified config file 2025-12-03 16:12:05 +08:00
DreamMaoMao
a2902a469b opt: optimize code struct 2025-12-03 13:47:47 +08:00
DreamMaoMao
068ec120de fix: curtag overflow when view arg is -1 in view dispatch 2025-12-03 09:29:14 +08:00
DreamMaoMao
559de3c66b feat: support view multi tag in view dispatch 2025-12-03 09:11:17 +08:00
DreamMaoMao
bfcde37aba opt: optimize namedscratchpad when swallow 2025-12-03 08:18:35 +08:00
DreamMaoMao
88e868caf8 opt: simple printstatus signal 2025-12-02 18:41:12 +08:00
DreamMaoMao
b9952f03b5 opt: change unsigned int to uint32_t 2025-12-02 16:57:24 +08:00
DreamMaoMao
9196e2a50b opt: use event mask to decide whether print ipc message 2025-12-02 16:46:11 +08:00
DreamMaoMao
075d4979b6 opt: use signal to handle printstauts 2025-12-02 16:19:31 +08:00
DreamMaoMao
e0c80af6b1 update readme 2025-12-01 11:23:18 +08:00
DreamMaoMao
1b7e998b67 opt: optimize scroller layout center client judge 2025-11-30 13:40:48 +08:00
DreamMaoMao
992822e309 opt: not handle virtual group keyborad ov_tab_mode detect 2025-11-30 13:40:48 +08:00
DreamMaoMao
113e73fe4a opt: avoid toggle overview when setfullscreen and setmaximziescreen 2025-11-30 13:40:48 +08:00
rasmusq
40948d22ba Merge branch 'main' into feature/dual-row-scroller-clean 2025-11-29 20:18:53 +01:00
DreamMaoMao
c0eceeb3bf fix: avoid toggle overview when setfullscreen and setmaximziescreen
Some checks failed
Close manually marked stale issues / close-issues (push) Has been cancelled
Lock Threads / lock (push) Has been cancelled
2025-11-29 22:46:47 +08:00
DreamMaoMao
09c1920515 opt: correct var isminized to isminimized 2025-11-29 17:33:57 +08:00
DreamMaoMao
b3ccf43453 opt: not swallow the isminied window 2025-11-29 17:30:22 +08:00
DreamMaoMao
7c7a9437e6 opt: optimize option name transparent_wlr_lock to allow_lock_transparent 2025-11-29 16:31:09 +08:00
DreamMaoMao
66bf6d5cff Merge pull request #448 from Rexcrazy804/xray-lockscreen
feat: support transparent wlr session lock
2025-11-29 16:23:42 +08:00
Rexiel Scarlet
006cf46c52 feat: support transparent wlr session lock 2025-11-29 16:22:19 +08:00
DreamMaoMao
16368a8781 opt: optimize code struct
Some checks failed
Close manually marked stale issues / close-issues (push) Has been cancelled
Lock Threads / lock (push) Has been cancelled
2025-11-28 12:49:06 +08:00
DreamMaoMao
b768f72eaa opt: allow ime in on-demand layer 2025-11-28 12:42:18 +08:00
DreamMaoMao
28ab0e6343 opt: re-judge the focus strategy of the layer when re-arrangelayer 2025-11-28 12:15:47 +08:00
rasmusq
94a051e266 add: configuration options and keybinds for the dual-scroller layout 2025-11-27 20:57:20 +01:00
dd6223d383 fix do not scroll to index zero when no window in row is focused 2025-11-27 20:57:20 +01:00
f7d4420685 update use dedicated row identifiers 2025-11-27 20:57:20 +01:00
09847dd09e add only respect scroller centering on bottom row 2025-11-27 20:57:20 +01:00
50b24942e7 fix row consistent movement and focus 2025-11-27 20:57:20 +01:00
8994b4cee2 fix rows keep their position when left 2025-11-27 20:57:20 +01:00
5089995cfa fix overlapping tiles 2025-11-27 20:57:20 +01:00
9db45cbb52 add first running version 2025-11-27 20:57:20 +01:00
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
27 changed files with 1614 additions and 819 deletions

View File

@@ -71,6 +71,8 @@ https://github.com/user-attachments/assets/014c893f-115c-4ae9-8342-f9ae3e9a0df0
- hwdata - hwdata
- seatd - seatd
- pcre2 - pcre2
- xorg-xwayland
- libxcb
## Arch Linux ## Arch Linux
The package is in the Arch User Repository and is availble for manual download [here](https://aur.archlinux.org/packages/mangowc-git) or through a AUR helper like yay: The package is in the Arch User Repository and is availble for manual download [here](https://aur.archlinux.org/packages/mangowc-git) or through a AUR helper like yay:
@@ -80,7 +82,6 @@ yay -S mangowc-git
``` ```
## Gentoo Linux ## Gentoo Linux
The package is in the community-maintained repository called GURU. The package is in the community-maintained repository called GURU.
First, add GURU repository: First, add GURU repository:
@@ -98,15 +99,25 @@ Finally, install the package:
emerge --ask --verbose gui-wm/mangowc emerge --ask --verbose gui-wm/mangowc
``` ```
## Fedora Linux
The package is in the third-party Terra repository.
First, add the [Terra Repository](https://terra.fyralabs.com/).
Then, install the package:
```bash
dnf install 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 +130,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
@@ -170,7 +181,9 @@ git clone https://github.com/DreamMaoMao/mango-config.git ~/.config/mango
## Config Documentation ## Config Documentation
Refer to the [wiki](https://github.com/DreamMaoMao/mango/wiki/) Refer to the repo wiki [wiki](https://github.com/DreamMaoMao/mango/wiki/)
or the website docs [docs](https://mangowc.vercel.app/docs)
# NixOS + Home-manager # NixOS + Home-manager
@@ -189,7 +202,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, ... }:
@@ -245,14 +261,6 @@ Here's an example of using the modules in a flake:
} }
``` ```
# Sponsor
My current device is a bit outdated and doesn't support certain features like HDR or VRR. If you'd like to support this project, here's how you can help. Thanks!
![Screenshot_2025-10-13-20-06-49-26_ee1cec40dcf6eb3](https://github.com/user-attachments/assets/240a0727-9eb5-4212-a84c-10fa9f093147)
# Packaging mango # Packaging mango
To package mango for other distributions, you can check the reference setup for: To package mango for other distributions, you can check the reference setup for:

View File

@@ -57,6 +57,7 @@ scroller_prefer_center=0
edge_scroller_pointer_focus=1 edge_scroller_pointer_focus=1
scroller_default_proportion_single=1.0 scroller_default_proportion_single=1.0
scroller_proportion_preset=0.5,0.8,1.0 scroller_proportion_preset=0.5,0.8,1.0
dual_scroller_default_split_ratio=0.3
# Master-Stack Layout Setting # Master-Stack Layout Setting
new_is_master=1 new_is_master=1
@@ -237,6 +238,10 @@ bind=CTRL+ALT,Down,resizewin,+0,+50
bind=CTRL+ALT,Left,resizewin,-50,+0 bind=CTRL+ALT,Left,resizewin,-50,+0
bind=CTRL+ALT,Right,resizewin,+50,+0 bind=CTRL+ALT,Right,resizewin,+50,+0
# dual-scroller split adjustment (increase/decrease top row height)
# bind=SUPER+SHIFT,Equal,adjust_dual_scroller_split,0.05
# bind=SUPER+SHIFT,Minus,adjust_dual_scroller_split,-0.05
# Mouse Button Bindings # Mouse Button Bindings
# NONE mode key only work in ov mode # NONE mode key only work in ov mode
mousebind=SUPER,btn_left,moveresize,curmove mousebind=SUPER,btn_left,moveresize,curmove

View File

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

View File

@@ -86,7 +86,7 @@ static void noop_description(void *data, struct wl_output *wl_output,
const char *description) {} const char *description) {}
// 将 n 转换为 9 位二进制字符串,结果存入 buf至少长度 10 // 将 n 转换为 9 位二进制字符串,结果存入 buf至少长度 10
void bin_str_9bits(char *buf, unsigned int n) { void bin_str_9bits(char *buf, uint32_t n) {
for (int i = 8; i >= 0; i--) { for (int i = 8; i >= 0; i--) {
*buf++ = ((n >> i) & 1) ? '1' : '0'; *buf++ = ((n >> i) & 1) ? '1' : '0';
} }
@@ -268,7 +268,7 @@ static void dwl_ipc_output_kb_layout(void *data,
static void static void
dwl_ipc_output_scalefactor(void *data, dwl_ipc_output_scalefactor(void *data,
struct zdwl_ipc_output_v2 *dwl_ipc_output, struct zdwl_ipc_output_v2 *dwl_ipc_output,
const unsigned int scalefactor) { const uint32_t scalefactor) {
if (!Aflag) if (!Aflag)
return; return;
char *output_name = data; char *output_name = data;

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

@@ -1,4 +1,4 @@
void client_actual_size(Client *c, unsigned int *width, unsigned int *height) { void client_actual_size(Client *c, uint32_t *width, uint32_t *height) {
*width = c->animation.current.width - c->bw; *width = c->animation.current.width - c->bw;
*height = c->animation.current.height - c->bw; *height = c->animation.current.height - c->bw;
@@ -183,8 +183,8 @@ void scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, int sy,
if (buffer_data->should_scale) { if (buffer_data->should_scale) {
unsigned int surface_width = surface->current.width; uint32_t surface_width = surface->current.width;
unsigned int surface_height = surface->current.height; uint32_t surface_height = surface->current.height;
surface_width = buffer_data->width_scale < 1 surface_width = buffer_data->width_scale < 1
? surface_width ? surface_width
@@ -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);
@@ -266,7 +270,7 @@ void client_draw_shadow(Client *c) {
? CORNER_LOCATION_NONE ? CORNER_LOCATION_NONE
: CORNER_LOCATION_ALL; : CORNER_LOCATION_ALL;
unsigned int bwoffset = c->bw != 0 && hit_no_border ? c->bw : 0; uint32_t bwoffset = c->bw != 0 && hit_no_border ? c->bw : 0;
uint32_t width, height; uint32_t width, height;
client_actual_size(c, &width, &height); client_actual_size(c, &width, &height);
@@ -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)) {
@@ -542,7 +546,7 @@ void client_apply_clip(Client *c, float factor) {
} }
// 获取窗口动画实时位置矩形 // 获取窗口动画实时位置矩形
unsigned int width, height; uint32_t width, height;
client_actual_size(c, &width, &height); client_actual_size(c, &width, &height);
// 计算出除了边框的窗口实际剪切大小 // 计算出除了边框的窗口实际剪切大小
@@ -626,17 +630,16 @@ void fadeout_client_animation_next_tick(Client *c) {
int type = c->animation.action = c->animation.action; int type = c->animation.action = c->animation.action;
double factor = find_animation_curve_at(animation_passed, type); double factor = find_animation_curve_at(animation_passed, type);
unsigned int width = uint32_t width = c->animation.initial.width +
c->animation.initial.width + (c->current.width - c->animation.initial.width) * factor;
(c->current.width - c->animation.initial.width) * factor; uint32_t height =
unsigned int height =
c->animation.initial.height + c->animation.initial.height +
(c->current.height - c->animation.initial.height) * factor; (c->current.height - c->animation.initial.height) * factor;
unsigned int x = c->animation.initial.x + uint32_t x = c->animation.initial.x +
(c->current.x - c->animation.initial.x) * factor; (c->current.x - c->animation.initial.x) * factor;
unsigned int y = c->animation.initial.y + uint32_t y = c->animation.initial.y +
(c->current.y - c->animation.initial.y) * factor; (c->current.y - c->animation.initial.y) * factor;
wlr_scene_node_set_position(&c->scene->node, x, y); wlr_scene_node_set_position(&c->scene->node, x, y);
@@ -692,17 +695,16 @@ void client_animation_next_tick(Client *c) {
double sx = 0, sy = 0; double sx = 0, sy = 0;
struct wlr_surface *surface = NULL; struct wlr_surface *surface = NULL;
unsigned int width = uint32_t width = c->animation.initial.width +
c->animation.initial.width + (c->current.width - c->animation.initial.width) * factor;
(c->current.width - c->animation.initial.width) * factor; uint32_t height =
unsigned int height =
c->animation.initial.height + c->animation.initial.height +
(c->current.height - c->animation.initial.height) * factor; (c->current.height - c->animation.initial.height) * factor;
unsigned int x = c->animation.initial.x + uint32_t x = c->animation.initial.x +
(c->current.x - c->animation.initial.x) * factor; (c->current.x - c->animation.initial.x) * factor;
unsigned int y = c->animation.initial.y + uint32_t y = c->animation.initial.y +
(c->current.y - c->animation.initial.y) * factor; (c->current.y - c->animation.initial.y) * factor;
wlr_scene_node_set_position(&c->scene->node, x, y); wlr_scene_node_set_position(&c->scene->node, x, y);
c->animation.current = (struct wlr_box){ c->animation.current = (struct wlr_box){
@@ -1056,7 +1058,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

@@ -33,33 +33,33 @@ void init_baked_points(void) {
baked_points_focus = baked_points_focus =
calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_focus)); calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_focus));
for (unsigned int i = 0; i < BAKED_POINTS_COUNT; i++) { for (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
baked_points_move[i] = calculate_animation_curve_at( baked_points_move[i] = calculate_animation_curve_at(
(double)i / (BAKED_POINTS_COUNT - 1), MOVE); (double)i / (BAKED_POINTS_COUNT - 1), MOVE);
} }
for (unsigned int i = 0; i < BAKED_POINTS_COUNT; i++) { for (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
baked_points_open[i] = calculate_animation_curve_at( baked_points_open[i] = calculate_animation_curve_at(
(double)i / (BAKED_POINTS_COUNT - 1), OPEN); (double)i / (BAKED_POINTS_COUNT - 1), OPEN);
} }
for (unsigned int i = 0; i < BAKED_POINTS_COUNT; i++) { for (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
baked_points_tag[i] = calculate_animation_curve_at( baked_points_tag[i] = calculate_animation_curve_at(
(double)i / (BAKED_POINTS_COUNT - 1), TAG); (double)i / (BAKED_POINTS_COUNT - 1), TAG);
} }
for (unsigned int i = 0; i < BAKED_POINTS_COUNT; i++) { for (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
baked_points_close[i] = calculate_animation_curve_at( baked_points_close[i] = calculate_animation_curve_at(
(double)i / (BAKED_POINTS_COUNT - 1), CLOSE); (double)i / (BAKED_POINTS_COUNT - 1), CLOSE);
} }
for (unsigned int i = 0; i < BAKED_POINTS_COUNT; i++) { for (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
baked_points_focus[i] = calculate_animation_curve_at( baked_points_focus[i] = calculate_animation_curve_at(
(double)i / (BAKED_POINTS_COUNT - 1), FOCUS); (double)i / (BAKED_POINTS_COUNT - 1), FOCUS);
} }
} }
double find_animation_curve_at(double t, int type) { double find_animation_curve_at(double t, int type) {
unsigned int down = 0; uint32_t down = 0;
unsigned int up = BAKED_POINTS_COUNT - 1; uint32_t up = BAKED_POINTS_COUNT - 1;
unsigned int middle = (up + down) / 2; uint32_t middle = (up + down) / 2;
struct dvec2 *baked_points; struct dvec2 *baked_points;
if (type == MOVE) { if (type == MOVE) {
baked_points = baked_points_move; baked_points = baked_points_move;

View File

@@ -1,5 +1,4 @@
void layer_actual_size(LayerSurface *l, unsigned int *width, void layer_actual_size(LayerSurface *l, uint32_t *width, uint32_t *height) {
unsigned int *height) {
struct wlr_box box; struct wlr_box box;
if (l->animation.running) { if (l->animation.running) {
@@ -213,9 +212,8 @@ void layer_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx,
struct wlr_surface *surface = scene_surface->surface; struct wlr_surface *surface = scene_surface->surface;
unsigned int surface_width = uint32_t surface_width = surface->current.width * buffer_data->width_scale;
surface->current.width * buffer_data->width_scale; uint32_t surface_height =
unsigned int surface_height =
surface->current.height * buffer_data->height_scale; surface->current.height * buffer_data->height_scale;
if (surface_height > 0 && surface_width > 0) { if (surface_height > 0 && surface_width > 0) {
@@ -245,17 +243,16 @@ void fadeout_layer_animation_next_tick(LayerSurface *l) {
int type = l->animation.action = l->animation.action; int type = l->animation.action = l->animation.action;
double factor = find_animation_curve_at(animation_passed, type); double factor = find_animation_curve_at(animation_passed, type);
unsigned int width = uint32_t width = l->animation.initial.width +
l->animation.initial.width + (l->current.width - l->animation.initial.width) * factor;
(l->current.width - l->animation.initial.width) * factor; uint32_t height =
unsigned int height =
l->animation.initial.height + l->animation.initial.height +
(l->current.height - l->animation.initial.height) * factor; (l->current.height - l->animation.initial.height) * factor;
unsigned int x = l->animation.initial.x + uint32_t x = l->animation.initial.x +
(l->current.x - l->animation.initial.x) * factor; (l->current.x - l->animation.initial.x) * factor;
unsigned int y = l->animation.initial.y + uint32_t y = l->animation.initial.y +
(l->current.y - l->animation.initial.y) * factor; (l->current.y - l->animation.initial.y) * factor;
wlr_scene_node_set_position(&l->scene->node, x, y); wlr_scene_node_set_position(&l->scene->node, x, y);
@@ -310,17 +307,16 @@ void layer_animation_next_tick(LayerSurface *l) {
int type = l->animation.action == NONE ? MOVE : l->animation.action; int type = l->animation.action == NONE ? MOVE : l->animation.action;
double factor = find_animation_curve_at(animation_passed, type); double factor = find_animation_curve_at(animation_passed, type);
unsigned int width = uint32_t width = l->animation.initial.width +
l->animation.initial.width + (l->current.width - l->animation.initial.width) * factor;
(l->current.width - l->animation.initial.width) * factor; uint32_t height =
unsigned int height =
l->animation.initial.height + l->animation.initial.height +
(l->current.height - l->animation.initial.height) * factor; (l->current.height - l->animation.initial.height) * factor;
unsigned int x = l->animation.initial.x + uint32_t x = l->animation.initial.x +
(l->current.x - l->animation.initial.x) * factor; (l->current.x - l->animation.initial.x) * factor;
unsigned int y = l->animation.initial.y + uint32_t y = l->animation.initial.y +
(l->current.y - l->animation.initial.y) * factor; (l->current.y - l->animation.initial.y) * factor;
double opacity = MIN(fadein_begin_opacity + double opacity = MIN(fadein_begin_opacity +
animation_passed * (1.0 - fadein_begin_opacity), animation_passed * (1.0 - fadein_begin_opacity),

View File

@@ -153,20 +153,6 @@ static inline void client_get_geometry(Client *c, struct wlr_box *geom) {
*geom = c->surface.xdg->geometry; *geom = c->surface.xdg->geometry;
} }
static inline Client *get_client_from_surface(struct wlr_surface *surface) {
if (!surface)
return NULL;
// 从 surface 的 data 指针获取 scene tree
struct wlr_scene_tree *scene_tree = surface->data;
if (!scene_tree)
return NULL;
// 从 scene tree 的 node data 获取 Client
Client *c = scene_tree->node.data;
return c;
}
static inline Client *client_get_parent(Client *c) { static inline Client *client_get_parent(Client *c) {
Client *p = NULL; Client *p = NULL;
#ifdef XWAYLAND #ifdef XWAYLAND
@@ -526,16 +512,16 @@ static inline void client_set_size_bound(Client *c) {
if (!size_hints) if (!size_hints)
return; return;
if ((unsigned int)c->geom.width - 2 * c->bw < size_hints->min_width && if ((uint32_t)c->geom.width - 2 * c->bw < size_hints->min_width &&
size_hints->min_width > 0) size_hints->min_width > 0)
c->geom.width = size_hints->min_width + 2 * c->bw; c->geom.width = size_hints->min_width + 2 * c->bw;
if ((unsigned int)c->geom.height - 2 * c->bw < size_hints->min_height && if ((uint32_t)c->geom.height - 2 * c->bw < size_hints->min_height &&
size_hints->min_height > 0) size_hints->min_height > 0)
c->geom.height = size_hints->min_height + 2 * c->bw; c->geom.height = size_hints->min_height + 2 * c->bw;
if ((unsigned int)c->geom.width - 2 * c->bw > size_hints->max_width && if ((uint32_t)c->geom.width - 2 * c->bw > size_hints->max_width &&
size_hints->max_width > 0) size_hints->max_width > 0)
c->geom.width = size_hints->max_width + 2 * c->bw; c->geom.width = size_hints->max_width + 2 * c->bw;
if ((unsigned int)c->geom.height - 2 * c->bw > size_hints->max_height && if ((uint32_t)c->geom.height - 2 * c->bw > size_hints->max_height &&
size_hints->max_height > 0) size_hints->max_height > 0)
c->geom.height = size_hints->max_height + 2 * c->bw; c->geom.height = size_hints->max_height + 2 * c->bw;
return; return;
@@ -544,19 +530,19 @@ static inline void client_set_size_bound(Client *c) {
toplevel = c->surface.xdg->toplevel; toplevel = c->surface.xdg->toplevel;
state = toplevel->current; state = toplevel->current;
if ((unsigned int)c->geom.width - 2 * c->bw < state.min_width && if ((uint32_t)c->geom.width - 2 * c->bw < state.min_width &&
state.min_width > 0) { state.min_width > 0) {
c->geom.width = state.min_width + 2 * c->bw; c->geom.width = state.min_width + 2 * c->bw;
} }
if ((unsigned int)c->geom.height - 2 * c->bw < state.min_height && if ((uint32_t)c->geom.height - 2 * c->bw < state.min_height &&
state.min_height > 0) { state.min_height > 0) {
c->geom.height = state.min_height + 2 * c->bw; c->geom.height = state.min_height + 2 * c->bw;
} }
if ((unsigned int)c->geom.width - 2 * c->bw > state.max_width && if ((uint32_t)c->geom.width - 2 * c->bw > state.max_width &&
state.max_width > 0) { state.max_width > 0) {
c->geom.width = state.max_width + 2 * c->bw; c->geom.width = state.max_width + 2 * c->bw;
} }
if ((unsigned int)c->geom.height - 2 * c->bw > state.max_height && if ((uint32_t)c->geom.height - 2 * c->bw > state.max_height &&
state.max_height > 0) { state.max_height > 0) {
c->geom.height = state.max_height + 2 * c->bw; c->geom.height = state.max_height + 2 * c->bw;
} }

View File

@@ -82,14 +82,13 @@ void wl_list_append(struct wl_list *list, struct wl_list *object) {
wl_list_insert(list->prev, object); wl_list_insert(list->prev, object);
} }
unsigned int get_now_in_ms(void) { uint32_t get_now_in_ms(void) {
struct timespec now; struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now); clock_gettime(CLOCK_MONOTONIC, &now);
return timespec_to_ms(&now); return timespec_to_ms(&now);
} }
unsigned int timespec_to_ms(struct timespec *ts) { uint32_t timespec_to_ms(struct timespec *ts) {
return (unsigned int)ts->tv_sec * 1000 + return (uint32_t)ts->tv_sec * 1000 + (uint32_t)ts->tv_nsec / 1000000;
(unsigned int)ts->tv_nsec / 1000000;
} }

View File

@@ -6,5 +6,5 @@ void *ecalloc(size_t nmemb, size_t size);
int fd_set_nonblock(int fd); int fd_set_nonblock(int fd);
int regex_match(const char *pattern_mb, const char *str_mb); int regex_match(const char *pattern_mb, const char *str_mb);
void wl_list_append(struct wl_list *list, struct wl_list *object); void wl_list_append(struct wl_list *list, struct wl_list *object);
unsigned int get_now_in_ms(void); uint32_t get_now_in_ms(void);
unsigned int timespec_to_ms(struct timespec *ts); uint32_t timespec_to_ms(struct timespec *ts);

View File

@@ -1,4 +1,5 @@
#include <ctype.h> #include <ctype.h>
#include <libgen.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
@@ -42,6 +43,7 @@ typedef struct {
bool isdefaultmode; bool isdefaultmode;
bool islockapply; bool islockapply;
bool isreleaseapply; bool isreleaseapply;
bool ispassapply;
} KeyBinding; } KeyBinding;
typedef struct { typedef struct {
@@ -52,7 +54,7 @@ typedef struct {
typedef struct { typedef struct {
const char *id; const char *id;
const char *title; const char *title;
unsigned int tags; uint32_t tags;
int isfloating; int isfloating;
int isfullscreen; int isfullscreen;
float scroller_proportion; float scroller_proportion;
@@ -69,6 +71,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 +80,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 +92,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;
@@ -121,29 +126,29 @@ KeyBinding default_key_bindings[] = {CHVT(1), CHVT(2), CHVT(3), CHVT(4),
CHVT(9), CHVT(10), CHVT(11), CHVT(12)}; CHVT(9), CHVT(10), CHVT(11), CHVT(12)};
typedef struct { typedef struct {
unsigned int mod; uint32_t mod;
unsigned int button; uint32_t button;
int (*func)(const Arg *); int (*func)(const Arg *);
Arg arg; Arg arg;
} MouseBinding; } MouseBinding;
typedef struct { typedef struct {
unsigned int mod; uint32_t mod;
unsigned int dir; uint32_t dir;
int (*func)(const Arg *); int (*func)(const Arg *);
Arg arg; Arg arg;
} AxisBinding; } AxisBinding;
typedef struct { typedef struct {
unsigned int fold; uint32_t fold;
int (*func)(const Arg *); int (*func)(const Arg *);
Arg arg; Arg arg;
} SwitchBinding; } SwitchBinding;
typedef struct { typedef struct {
unsigned int mod; uint32_t mod;
unsigned int motion; uint32_t motion;
unsigned int fingers_count; uint32_t fingers_count;
int (*func)(const Arg *); int (*func)(const Arg *);
Arg arg; Arg arg;
} GestureBinding; } GestureBinding;
@@ -193,9 +198,11 @@ 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;
float dual_scroller_default_split_ratio;
int focus_cross_monitor; int focus_cross_monitor;
int exchange_cross_monitor; int exchange_cross_monitor;
int scratchpad_cross_monitor; int scratchpad_cross_monitor;
@@ -206,7 +213,7 @@ typedef struct {
int snap_distance; int snap_distance;
int enable_floating_snap; int enable_floating_snap;
int drag_tile_to_tile; int drag_tile_to_tile;
unsigned int swipe_min_threshold; uint32_t swipe_min_threshold;
float focused_opacity; float focused_opacity;
float unfocused_opacity; float unfocused_opacity;
float *scroller_proportion_preset; float *scroller_proportion_preset;
@@ -215,21 +222,21 @@ typedef struct {
char **circle_layout; char **circle_layout;
int circle_layout_count; int circle_layout_count;
unsigned int new_is_master; uint32_t new_is_master;
float default_mfact; float default_mfact;
unsigned int default_nmaster; uint32_t default_nmaster;
int center_master_overspread; int center_master_overspread;
int center_when_single_stack; int center_when_single_stack;
unsigned int hotarea_size; uint32_t hotarea_size;
unsigned int enable_hotarea; uint32_t enable_hotarea;
unsigned int ov_tab_mode; uint32_t ov_tab_mode;
int overviewgappi; int overviewgappi;
int overviewgappo; int overviewgappo;
unsigned int cursor_hide_timeout; uint32_t cursor_hide_timeout;
unsigned int axis_bind_apply_timeout; uint32_t axis_bind_apply_timeout;
unsigned int focus_on_activate; uint32_t focus_on_activate;
int inhibit_regardless_of_visibility; int inhibit_regardless_of_visibility;
int sloppyfocus; int sloppyfocus;
int warpcursor; int warpcursor;
@@ -237,7 +244,7 @@ typedef struct {
/* keyboard */ /* keyboard */
int repeat_rate; int repeat_rate;
int repeat_delay; int repeat_delay;
unsigned int numlockon; uint32_t numlockon;
/* Trackpad */ /* Trackpad */
int disable_trackpad; int disable_trackpad;
@@ -249,13 +256,13 @@ typedef struct {
int disable_while_typing; int disable_while_typing;
int left_handed; int left_handed;
int middle_button_emulation; int middle_button_emulation;
unsigned int accel_profile; uint32_t accel_profile;
double accel_speed; double accel_speed;
unsigned int scroll_method; uint32_t scroll_method;
unsigned int scroll_button; uint32_t scroll_button;
unsigned int click_method; uint32_t click_method;
unsigned int send_events_mode; uint32_t send_events_mode;
unsigned int button_map; uint32_t button_map;
int blur; int blur;
int blur_layer; int blur_layer;
@@ -265,18 +272,18 @@ typedef struct {
int shadows; int shadows;
int shadow_only_floating; int shadow_only_floating;
int layer_shadows; int layer_shadows;
unsigned int shadows_size; uint32_t shadows_size;
float shadows_blur; float shadows_blur;
int shadows_position_x; int shadows_position_x;
int shadows_position_y; int shadows_position_y;
float shadowscolor[4]; float shadowscolor[4];
int smartgaps; int smartgaps;
unsigned int gappih; uint32_t gappih;
unsigned int gappiv; uint32_t gappiv;
unsigned int gappoh; uint32_t gappoh;
unsigned int gappov; uint32_t gappov;
unsigned int borderpx; uint32_t borderpx;
float scratchpad_width_ratio; float scratchpad_width_ratio;
float scratchpad_height_ratio; float scratchpad_height_ratio;
float rootcolor[4]; float rootcolor[4];
@@ -327,13 +334,15 @@ typedef struct {
int exec_once_count; int exec_once_count;
char *cursor_theme; char *cursor_theme;
unsigned int cursor_size; uint32_t cursor_size;
int single_scratchpad; int single_scratchpad;
int xwayland_persistence; int xwayland_persistence;
int syncobj_enable; int syncobj_enable;
int adaptive_sync; int adaptive_sync;
int allow_tearing; int allow_tearing;
int allow_shortcuts_inhibit;
int allow_lock_transparent;
struct xkb_rule_names xkb_rules; struct xkb_rule_names xkb_rules;
@@ -436,6 +445,9 @@ void parse_bind_flags(const char *str, KeyBinding *kb) {
case 'r': case 'r':
kb->isreleaseapply = true; kb->isreleaseapply = true;
break; break;
case 'p':
kb->ispassapply = true;
break;
default: default:
// 忽略其他字符或可根据需要处理错误 // 忽略其他字符或可根据需要处理错误
break; break;
@@ -513,61 +525,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) {
@@ -838,7 +795,7 @@ void convert_hex_to_rgba(float *color, unsigned long int hex) {
color[3] = (hex & 0xFF) / 255.0f; color[3] = (hex & 0xFF) / 255.0f;
} }
unsigned int parse_num_type(char *str) { uint32_t parse_num_type(char *str) {
switch (str[0]) { switch (str[0]) {
case '-': case '-':
return NUM_TYPE_MINUS; return NUM_TYPE_MINUS;
@@ -864,12 +821,17 @@ 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);
} else if (strcmp(func_name, "setmfact") == 0) { } else if (strcmp(func_name, "setmfact") == 0) {
func = setmfact; func = setmfact;
(*arg).f = atof(arg_value); (*arg).f = atof(arg_value);
} else if (strcmp(func_name, "adjust_dual_scroller_split") == 0) {
func = adjust_dual_scroller_split;
(*arg).f = atof(arg_value);
} else if (strcmp(func_name, "zoom") == 0) { } else if (strcmp(func_name, "zoom") == 0) {
func = zoom; func = zoom;
} else if (strcmp(func_name, "exchange_client") == 0) { } else if (strcmp(func_name, "exchange_client") == 0) {
@@ -886,9 +848,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) {
@@ -1040,7 +999,31 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
(*arg).i = atoi(arg_value2); (*arg).i = atoi(arg_value2);
} else if (strcmp(func_name, "view") == 0) { } else if (strcmp(func_name, "view") == 0) {
func = bind_to_view; func = bind_to_view;
(*arg).ui = 1 << (atoi(arg_value) - 1);
uint32_t mask = 0;
char *token;
char *arg_copy = strdup(arg_value);
if (arg_copy != NULL) {
char *saveptr = NULL;
token = strtok_r(arg_copy, "|", &saveptr);
while (token != NULL) {
int num = atoi(token);
if (num > 0 && num <= LENGTH(tags)) {
mask |= (1 << (num - 1));
}
token = strtok_r(NULL, "|", &saveptr);
}
free(arg_copy);
}
if (mask) {
(*arg).ui = mask;
} else {
(*arg).ui = atoi(arg_value);
}
(*arg).i = atoi(arg_value2); (*arg).i = atoi(arg_value2);
} else if (strcmp(func_name, "viewcrossmon") == 0) { } else if (strcmp(func_name, "viewcrossmon") == 0) {
func = viewcrossmon; func = viewcrossmon;
@@ -1210,12 +1193,16 @@ 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) {
config->scroller_prefer_center = atoi(value); config->scroller_prefer_center = atoi(value);
} else if (strcmp(key, "edge_scroller_pointer_focus") == 0) { } else if (strcmp(key, "edge_scroller_pointer_focus") == 0) {
config->edge_scroller_pointer_focus = atoi(value); config->edge_scroller_pointer_focus = atoi(value);
} else if (strcmp(key, "dual_scroller_default_split_ratio") == 0) {
config->dual_scroller_default_split_ratio = atof(value);
} else if (strcmp(key, "focus_cross_monitor") == 0) { } else if (strcmp(key, "focus_cross_monitor") == 0) {
config->focus_cross_monitor = atoi(value); config->focus_cross_monitor = atoi(value);
} else if (strcmp(key, "exchange_cross_monitor") == 0) { } else if (strcmp(key, "exchange_cross_monitor") == 0) {
@@ -1270,6 +1257,10 @@ 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, "allow_lock_transparent") == 0) {
config->allow_lock_transparent = 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 +1698,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 +1708,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 +1720,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 +1764,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 +1792,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) {
@@ -1968,7 +1968,7 @@ void parse_option(Config *config, char *key, char *value) {
config->exec_once_count++; config->exec_once_count++;
} else if (regex_match("^bind[s|l|r]*$", key)) { } else if (regex_match("^bind[s|l|r|p]*$", key)) {
config->key_bindings = config->key_bindings =
realloc(config->key_bindings, realloc(config->key_bindings,
(config->key_bindings_count + 1) * sizeof(KeyBinding)); (config->key_bindings_count + 1) * sizeof(KeyBinding));
@@ -2314,35 +2314,55 @@ 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
if (cli_config_path) {
char *config_path = strdup(cli_config_path);
char *config_dir = dirname(config_path);
snprintf(full_path, sizeof(full_path), "%s/%s", config_dir,
file_path + 1);
free(config_path);
} else {
const char *home = getenv("HOME");
if (!home) {
fprintf(stderr, "Error: HOME environment variable not set.\n");
return;
}
snprintf(full_path, sizeof(full_path), "%s/.config/mango/%s", home,
file_path + 1);
}
file = fopen(full_path, "r");
} else if (file_path[0] == '~' &&
(file_path[1] == '/' || file_path[1] == '\0')) {
// Home directory
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;
} }
// 构建完整路径(家目录 + / + 原路径去掉 ~
char full_path[1024];
snprintf(full_path, sizeof(full_path), "%s%s", home, file_path + 1); 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");
return;
}
} else { } else {
// Absolute path
file = fopen(file_path, "r"); file = fopen(file_path, "r");
if (!file) { }
perror("Error opening file");
return; if (!file) {
} perror("Error opening file");
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,11 +2685,15 @@ 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 =
CLAMP_INT(config.edge_scroller_pointer_focus, 0, 1); CLAMP_INT(config.edge_scroller_pointer_focus, 0, 1);
scroller_structs = CLAMP_INT(config.scroller_structs, 0, 1000); scroller_structs = CLAMP_INT(config.scroller_structs, 0, 1000);
dual_scroller_default_split_ratio =
CLAMP_FLOAT(config.dual_scroller_default_split_ratio, 0.1f, 0.9f);
// 主从布局设置 // 主从布局设置
default_mfact = CLAMP_FLOAT(config.default_mfact, 0.1f, 0.9f); default_mfact = CLAMP_FLOAT(config.default_mfact, 0.1f, 0.9f);
@@ -2690,6 +2714,8 @@ 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);
allow_lock_transparent = CLAMP_INT(config.allow_lock_transparent, 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,9 +2878,12 @@ 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;
config.dual_scroller_default_split_ratio = dual_scroller_default_split_ratio;
config.focus_cross_monitor = focus_cross_monitor; config.focus_cross_monitor = focus_cross_monitor;
config.exchange_cross_monitor = exchange_cross_monitor; config.exchange_cross_monitor = exchange_cross_monitor;
config.scratchpad_cross_monitor = scratchpad_cross_monitor; config.scratchpad_cross_monitor = scratchpad_cross_monitor;
@@ -2865,6 +2894,8 @@ 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.allow_lock_transparent = allow_lock_transparent;
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;
@@ -3023,11 +3054,9 @@ void parse_config(void) {
create_config_keymap(); create_config_keymap();
// 获取 MANGOCONFIG 环境变量 if (cli_config_path) {
const char *mangoconfig = getenv("MANGOCONFIG"); snprintf(filename, sizeof(filename), "%s", cli_config_path);
} else {
// 如果 MANGOCONFIG 环境变量不存在或为空,则使用 HOME 环境变量
if (!mangoconfig || mangoconfig[0] == '\0') {
// 获取当前用户家目录 // 获取当前用户家目录
const char *homedir = getenv("HOME"); const char *homedir = getenv("HOME");
if (!homedir) { if (!homedir) {
@@ -3044,9 +3073,6 @@ void parse_config(void) {
snprintf(filename, sizeof(filename), "%s/mango/config.conf", snprintf(filename, sizeof(filename), "%s/mango/config.conf",
SYSCONFDIR); SYSCONFDIR);
} }
} else {
// 使用 MANGOCONFIG 环境变量作为配置文件夹路径
snprintf(filename, sizeof(filename), "%s/config.conf", mangoconfig);
} }
set_value_default(); set_value_default();
@@ -3144,6 +3170,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 +3235,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 +3277,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

@@ -33,35 +33,37 @@ double animation_curve_close[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
double animation_curve_focus[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线 double animation_curve_focus[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
/* appearance */ /* appearance */
unsigned int axis_bind_apply_timeout = 100; // 滚轮绑定动作的触发的时间间隔 uint32_t axis_bind_apply_timeout = 100; // 滚轮绑定动作的触发的时间间隔
unsigned int focus_on_activate = 1; // 收到窗口激活请求是否自动跳转聚焦 uint32_t focus_on_activate = 1; // 收到窗口激活请求是否自动跳转聚焦
unsigned int new_is_master = 1; // 新窗口是否插在头部 uint32_t new_is_master = 1; // 新窗口是否插在头部
double default_mfact = 0.55f; // master 窗口比例 double default_mfact = 0.55f; // master 窗口比例
unsigned int default_nmaster = 1; // 默认master数量 uint32_t default_nmaster = 1; // 默认master数量
int center_master_overspread = 0; // 中心master时是否铺满 int center_master_overspread = 0; // 中心master时是否铺满
int center_when_single_stack = 1; // 单个stack时是否居中 int center_when_single_stack = 1; // 单个stack时是否居中
/* logging */ /* logging */
int log_level = WLR_ERROR; int log_level = WLR_ERROR;
unsigned int numlockon = 0; // 是否打开右边小键盘 uint32_t numlockon = 0; // 是否打开右边小键盘
unsigned int capslock = 0; // 是否启用快捷键 uint32_t capslock = 0; // 是否启用快捷键
unsigned int ov_tab_mode = 0; // alt tab切换模式 uint32_t ov_tab_mode = 0; // alt tab切换模式
unsigned int hotarea_size = 10; // 热区大小,10x10 uint32_t hotarea_size = 10; // 热区大小,10x10
unsigned int enable_hotarea = 1; // 是否启用鼠标热区 uint32_t enable_hotarea = 1; // 是否启用鼠标热区
int smartgaps = 0; /* 1 means no outer gap when there is only one window */ int smartgaps = 0; /* 1 means no outer gap when there is only one window */
int sloppyfocus = 1; /* focus follows mouse */ int sloppyfocus = 1; /* focus follows mouse */
unsigned int gappih = 5; /* horiz inner gap between windows */ uint32_t gappih = 5; /* horiz inner gap between windows */
unsigned int gappiv = 5; /* vert inner gap between windows */ uint32_t gappiv = 5; /* vert inner gap between windows */
unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ uint32_t gappoh = 10; /* horiz outer gap between windows and screen edge */
unsigned int gappov = 10; /* vert outer gap between windows and screen edge */ uint32_t gappov = 10; /* vert outer gap between windows and screen edge */
float scratchpad_width_ratio = 0.8; float scratchpad_width_ratio = 0.8;
float scratchpad_height_ratio = 0.9; 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;
float dual_scroller_default_split_ratio = 0.3;
int focus_cross_monitor = 0; int focus_cross_monitor = 0;
int focus_cross_tag = 0; int focus_cross_tag = 0;
int exchange_cross_monitor = 0; int exchange_cross_monitor = 0;
@@ -72,15 +74,15 @@ int no_radius_when_single = 0;
int snap_distance = 30; int snap_distance = 30;
int enable_floating_snap = 0; int enable_floating_snap = 0;
int drag_tile_to_tile = 0; int drag_tile_to_tile = 0;
unsigned int cursor_size = 24; uint32_t cursor_size = 24;
unsigned int cursor_hide_timeout = 0; uint32_t cursor_hide_timeout = 0;
unsigned int swipe_min_threshold = 1; uint32_t swipe_min_threshold = 1;
int inhibit_regardless_of_visibility = int inhibit_regardless_of_visibility =
0; /* 1 means idle inhibitors will disable idle tracking even if it's 0; /* 1 means idle inhibitors will disable idle tracking even if it's
surface isn't visible */ surface isn't visible */
unsigned int borderpx = 4; /* border pixel of windows */ uint32_t borderpx = 4; /* border pixel of windows */
float rootcolor[] = COLOR(0x323232ff); float rootcolor[] = COLOR(0x323232ff);
float bordercolor[] = COLOR(0x444444ff); float bordercolor[] = COLOR(0x444444ff);
float focuscolor[] = COLOR(0xc66b25ff); float focuscolor[] = COLOR(0xc66b25ff);
@@ -102,8 +104,10 @@ int warpcursor = 1; /* Warp cursor to focused client */
int xwayland_persistence = 1; /* xwayland persistence */ int xwayland_persistence = 1; /* xwayland persistence */
int syncobj_enable = 0; int syncobj_enable = 0;
int adaptive_sync = 0; int adaptive_sync = 0;
int allow_lock_transparent = 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 */
@@ -163,7 +167,7 @@ LIBINPUT_CONFIG_SCROLL_EDGE
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN
*/ */
enum libinput_config_scroll_method scroll_method = LIBINPUT_CONFIG_SCROLL_2FG; enum libinput_config_scroll_method scroll_method = LIBINPUT_CONFIG_SCROLL_2FG;
unsigned int scroll_button = 274; uint32_t scroll_button = 274;
/* You can choose between: /* You can choose between:
LIBINPUT_CONFIG_CLICK_METHOD_NONE LIBINPUT_CONFIG_CLICK_METHOD_NONE
@@ -221,7 +225,7 @@ float blur_params_saturation = 1.2;
int shadows = 0; int shadows = 0;
int shadow_only_floating = 1; int shadow_only_floating = 1;
int layer_shadows = 0; int layer_shadows = 0;
unsigned int shadows_size = 10; uint32_t shadows_size = 10;
double shadows_blur = 15; double shadows_blur = 15;
int shadows_position_x = 0; int shadows_position_x = 0;
int shadows_position_y = 0; int shadows_position_y = 0;

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);
@@ -29,6 +29,7 @@ int switch_keyboard_layout(const Arg *arg);
int setlayout(const Arg *arg); int setlayout(const Arg *arg);
int switch_layout(const Arg *arg); int switch_layout(const Arg *arg);
int setmfact(const Arg *arg); int setmfact(const Arg *arg);
int adjust_dual_scroller_split(const Arg *arg);
int quit(const Arg *arg); int quit(const Arg *arg);
int moveresize(const Arg *arg); int moveresize(const Arg *arg);
int exchange_client(const Arg *arg); int exchange_client(const Arg *arg);

View File

@@ -1,6 +1,6 @@
int bind_to_view(const Arg *arg) { int bind_to_view(const Arg *arg) {
unsigned int target = arg->ui; uint32_t target = arg->ui;
if (view_current_to_back && selmon->pertag->curtag && if (view_current_to_back && selmon->pertag->curtag &&
(target & TAGMASK) == (selmon->tagset[selmon->seltags])) { (target & TAGMASK) == (selmon->tagset[selmon->seltags])) {
@@ -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;
} }
@@ -121,15 +125,38 @@ 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;
Client *tc = NULL; Client *tc = NULL;
bool begin = false; bool begin = false;
unsigned int target = 0; uint32_t target = 0;
wl_list_for_each(c, &fstack, flink) { wl_list_for_each(c, &fstack, flink) {
if (c->iskilling || c->isminied || c->isunglobal || if (c->iskilling || c->isminimized || c->isunglobal ||
!client_surface(c)->mapped || client_is_unmanaged(c) || !client_surface(c)->mapped || client_is_unmanaged(c) ||
client_is_x11_popup(c)) client_is_x11_popup(c))
continue; continue;
@@ -167,7 +194,7 @@ int toggle_trackpad_enable(const Arg *arg) {
} }
int focusmon(const Arg *arg) { int focusmon(const Arg *arg) {
Client *c = NULL, *old_selmon_sel = NULL; Client *c = NULL;
Monitor *m = NULL; Monitor *m = NULL;
if (arg->i != UNDIR) { if (arg->i != UNDIR) {
@@ -188,7 +215,6 @@ int focusmon(const Arg *arg) {
if (!m || !m->wlr_output->enabled || m == selmon) if (!m || !m->wlr_output->enabled || m == selmon)
return 0; return 0;
old_selmon_sel = selmon->sel;
selmon = m; selmon = m;
if (warpcursor) { if (warpcursor) {
warp_cursor_to_selmon(selmon); warp_cursor_to_selmon(selmon);
@@ -198,12 +224,10 @@ int focusmon(const Arg *arg) {
selmon->sel = NULL; selmon->sel = NULL;
wlr_seat_pointer_notify_clear_focus(seat); wlr_seat_pointer_notify_clear_focus(seat);
wlr_seat_keyboard_notify_clear_focus(seat); wlr_seat_keyboard_notify_clear_focus(seat);
focusclient(NULL, 0);
} else } else
focusclient(c, 1); focusclient(c, 1);
if (old_selmon_sel) {
setborder_color(old_selmon_sel);
}
return 0; return 0;
} }
@@ -281,18 +305,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;
@@ -315,6 +327,28 @@ int setmfact(const Arg *arg) {
return 0; return 0;
} }
int adjust_dual_scroller_split(const Arg *arg) {
float new_ratio;
if (!arg || !selmon)
return 0;
// Check if we're in a dual-scroller layout
if (!is_row_layout(selmon))
return 0;
// Calculate new ratio: if arg->f < 1.0, treat as relative adjustment, otherwise as absolute value
new_ratio = arg->f < 1.0 ? dual_scroller_default_split_ratio + arg->f : arg->f - 1.0;
// Clamp the ratio between 0.1 and 0.9
if (new_ratio < 0.1 || new_ratio > 0.9)
return 0;
dual_scroller_default_split_ratio = new_ratio;
arrange(selmon, false);
return 0;
}
int killclient(const Arg *arg) { int killclient(const Arg *arg) {
Client *c = NULL; Client *c = NULL;
c = selmon->sel; c = selmon->sel;
@@ -479,7 +513,7 @@ int restore_minimized(const Arg *arg) {
if (selmon && selmon->sel && selmon->sel->is_in_scratchpad && if (selmon && selmon->sel && selmon->sel->is_in_scratchpad &&
selmon->sel->is_scratchpad_show) { selmon->sel->is_scratchpad_show) {
selmon->sel->isminied = 0; selmon->sel->isminimized = 0;
selmon->sel->is_scratchpad_show = 0; selmon->sel->is_scratchpad_show = 0;
selmon->sel->is_in_scratchpad = 0; selmon->sel->is_in_scratchpad = 0;
selmon->sel->isnamedscratchpad = 0; selmon->sel->isnamedscratchpad = 0;
@@ -488,7 +522,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->isminimized && !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 +543,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,8 +564,16 @@ 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 = uint32_t max_client_width =
selmon->w.width - 2 * scroller_structs - gappih; selmon->w.width - 2 * scroller_structs - gappih;
selmon->sel->scroller_proportion = arg->f; selmon->sel->scroller_proportion = arg->f;
selmon->sel->geom.width = max_client_width * arg->f; selmon->sel->geom.width = max_client_width * arg->f;
@@ -716,14 +758,26 @@ int centerwin(const Arg *arg) {
Client *c = NULL; Client *c = NULL;
c = selmon->sel; c = selmon->sel;
if (!c || c->isfullscreen) if (!c || c->isfullscreen || c->ismaximizescreen)
return 0; return 0;
if (!c->isfloating)
setfloating(c, true);
c->float_geom = setclient_coordinate_center(c, c->geom, 0, 0); if (c->isfloating) {
c->iscustomsize = 1; c->float_geom = setclient_coordinate_center(c, c->geom, 0, 0);
resize(c, c->float_geom, 1); c->iscustomsize = 1;
resize(c, c->float_geom, 1);
return 0;
}
if (!is_scroller_layout(selmon))
return 0;
if (selmon->pertag->ltidxs[selmon->pertag->curtag]->id == SCROLLER) {
c->geom.x = selmon->w.x + (selmon->w.width - c->geom.width) / 2;
} else {
c->geom.y = selmon->w.y + (selmon->w.height - c->geom.height) / 2;
}
arrange(selmon, false);
return 0; return 0;
} }
@@ -809,7 +863,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;
} }
@@ -837,9 +891,9 @@ int switch_keyboard_layout(const Arg *arg) {
xkb_layout_index_t next = (current + 1) % num_layouts; xkb_layout_index_t next = (current + 1) % num_layouts;
// 6. 应用新 keymap // 6. 应用新 keymap
unsigned int depressed = keyboard->modifiers.depressed; uint32_t depressed = keyboard->modifiers.depressed;
unsigned int latched = keyboard->modifiers.latched; uint32_t latched = keyboard->modifiers.latched;
unsigned int locked = keyboard->modifiers.locked; uint32_t locked = keyboard->modifiers.locked;
wlr_keyboard_set_keymap(keyboard, keyboard->keymap); wlr_keyboard_set_keymap(keyboard, keyboard->keymap);
wlr_keyboard_notify_modifiers(keyboard, depressed, latched, locked, next); wlr_keyboard_notify_modifiers(keyboard, depressed, latched, locked, next);
@@ -874,7 +928,7 @@ int switch_layout(const Arg *arg) {
int jk, ji; int jk, ji;
char *target_layout_name = NULL; char *target_layout_name = NULL;
unsigned int len; uint32_t len;
if (config.circle_layout_count != 0) { if (config.circle_layout_count != 0) {
for (jk = 0; jk < config.circle_layout_count; jk++) { for (jk = 0; jk < config.circle_layout_count; jk++) {
@@ -905,7 +959,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 +970,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 +986,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++) {
@@ -951,7 +1013,7 @@ int switch_proportion_preset(const Arg *arg) {
target_proportion = config.scroller_proportion_preset[0]; target_proportion = config.scroller_proportion_preset[0];
} }
unsigned int max_client_width = uint32_t max_client_width =
selmon->w.width - 2 * scroller_structs - gappih; selmon->w.width - 2 * scroller_structs - gappih;
selmon->sel->scroller_proportion = target_proportion; selmon->sel->scroller_proportion = target_proportion;
selmon->sel->geom.width = max_client_width * target_proportion; selmon->sel->geom.width = max_client_width * target_proportion;
@@ -968,7 +1030,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 +1039,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;
} }
} }
@@ -992,8 +1055,8 @@ int tagmon(const Arg *arg) {
if (!m || !m->wlr_output->enabled) if (!m || !m->wlr_output->enabled)
return 0; return 0;
unsigned int newtags = arg->ui ? arg->ui : arg->i2 ? c->tags : 0; uint32_t newtags = arg->ui ? arg->ui : arg->i2 ? c->tags : 0;
unsigned int target; uint32_t target;
if (c->mon == m) { if (c->mon == m) {
view(&(Arg){.ui = newtags}, true); view(&(Arg){.ui = newtags}, true);
@@ -1084,7 +1147,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;
} }
@@ -1113,7 +1176,7 @@ int toggle_scratchpad(const Arg *arg) {
continue; continue;
} }
if (single_scratchpad && c->isnamedscratchpad && !c->isminied) { if (single_scratchpad && c->isnamedscratchpad && !c->isminimized) {
set_minimized(c); set_minimized(c);
continue; continue;
} }
@@ -1233,7 +1296,7 @@ int toggleoverlay(const Arg *arg) {
} }
int toggletag(const Arg *arg) { int toggletag(const Arg *arg) {
unsigned int newtags; uint32_t newtags;
Client *sel = focustop(selmon); Client *sel = focustop(selmon);
if (!sel) if (!sel)
return 0; return 0;
@@ -1256,8 +1319,8 @@ int toggletag(const Arg *arg) {
} }
int toggleview(const Arg *arg) { int toggleview(const Arg *arg) {
unsigned int newtagset; uint32_t newtagset;
unsigned int target; uint32_t target;
target = arg->ui == 0 ? ~0 & TAGMASK : arg->ui; target = arg->ui == 0 ? ~0 & TAGMASK : arg->ui;
@@ -1274,7 +1337,7 @@ int toggleview(const Arg *arg) {
} }
int viewtoleft(const Arg *arg) { int viewtoleft(const Arg *arg) {
unsigned int target = selmon->tagset[selmon->seltags]; uint32_t target = selmon->tagset[selmon->seltags];
if (selmon->isoverview || selmon->pertag->curtag == 0) { if (selmon->isoverview || selmon->pertag->curtag == 0) {
return 0; return 0;
@@ -1297,7 +1360,7 @@ int viewtoright(const Arg *arg) {
if (selmon->isoverview || selmon->pertag->curtag == 0) { if (selmon->isoverview || selmon->pertag->curtag == 0) {
return 0; return 0;
} }
unsigned int target = selmon->tagset[selmon->seltags]; uint32_t target = selmon->tagset[selmon->seltags];
target <<= 1; target <<= 1;
if (!selmon || (target) == selmon->tagset[selmon->seltags]) if (!selmon || (target) == selmon->tagset[selmon->seltags])
@@ -1311,9 +1374,8 @@ int viewtoright(const Arg *arg) {
} }
int viewtoleft_have_client(const Arg *arg) { int viewtoleft_have_client(const Arg *arg) {
unsigned int n; uint32_t n;
unsigned int current = uint32_t current = get_tags_first_tag_num(selmon->tagset[selmon->seltags]);
get_tags_first_tag_num(selmon->tagset[selmon->seltags]);
bool found = false; bool found = false;
if (selmon->isoverview) { if (selmon->isoverview) {
@@ -1336,9 +1398,8 @@ int viewtoleft_have_client(const Arg *arg) {
} }
int viewtoright_have_client(const Arg *arg) { int viewtoright_have_client(const Arg *arg) {
unsigned int n; uint32_t n;
unsigned int current = uint32_t current = get_tags_first_tag_num(selmon->tagset[selmon->seltags]);
get_tags_first_tag_num(selmon->tagset[selmon->seltags]);
bool found = false; bool found = false;
if (selmon->isoverview) { if (selmon->isoverview) {
@@ -1375,7 +1436,7 @@ int tagcrossmon(const Arg *arg) {
} }
int comboview(const Arg *arg) { int comboview(const Arg *arg) {
unsigned int newtags = arg->ui & TAGMASK; uint32_t newtags = arg->ui & TAGMASK;
if (!newtags || !selmon) if (!newtags || !selmon)
return 0; return 0;
@@ -1438,7 +1499,7 @@ int minimized(const Arg *arg) {
if (selmon && selmon->isoverview) if (selmon && selmon->isoverview)
return 0; return 0;
if (selmon->sel && !selmon->sel->isminied) { if (selmon->sel && !selmon->sel->isminimized) {
set_minimized(selmon->sel); set_minimized(selmon->sel);
} }
return 0; return 0;
@@ -1453,14 +1514,14 @@ int toggleoverview(const Arg *arg) {
} }
selmon->isoverview ^= 1; selmon->isoverview ^= 1;
unsigned int target; uint32_t target;
unsigned int visible_client_number = 0; uint32_t visible_client_number = 0;
if (selmon->isoverview) { if (selmon->isoverview) {
wl_list_for_each(c, &clients, link) if (c && c->mon == selmon && wl_list_for_each(c, &clients, link) if (c && c->mon == selmon &&
!client_is_unmanaged(c) && !client_is_unmanaged(c) &&
!client_is_x11_popup(c) && !client_is_x11_popup(c) &&
!c->isminied && !c->isminimized &&
!c->isunglobal) { !c->isunglobal) {
visible_client_number++; visible_client_number++;
} }
@@ -1545,4 +1606,4 @@ int toggle_monitor(const Arg *arg) {
} }
} }
return 0; return 0;
} }

View File

@@ -1,12 +1,11 @@
#include "dwl-ipc-unstable-v2-protocol.h" #include "dwl-ipc-unstable-v2-protocol.h"
static void dwl_ipc_manager_bind(struct wl_client *client, void *data, static void dwl_ipc_manager_bind(struct wl_client *client, void *data,
unsigned int version, unsigned int id); uint32_t version, uint32_t id);
static void dwl_ipc_manager_destroy(struct wl_resource *resource); static void dwl_ipc_manager_destroy(struct wl_resource *resource);
static void dwl_ipc_manager_get_output(struct wl_client *client, static void dwl_ipc_manager_get_output(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
unsigned int id, uint32_t id, struct wl_resource *output);
struct wl_resource *output);
static void dwl_ipc_manager_release(struct wl_client *client, static void dwl_ipc_manager_release(struct wl_client *client,
struct wl_resource *resource); struct wl_resource *resource);
static void dwl_ipc_output_destroy(struct wl_resource *resource); static void dwl_ipc_output_destroy(struct wl_resource *resource);
@@ -14,15 +13,14 @@ static void dwl_ipc_output_printstatus(Monitor *monitor);
static void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output); static void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output);
static void dwl_ipc_output_set_client_tags(struct wl_client *client, static void dwl_ipc_output_set_client_tags(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
unsigned int and_tags, uint32_t and_tags,
unsigned int xor_tags); uint32_t xor_tags);
static void dwl_ipc_output_set_layout(struct wl_client *client, static void dwl_ipc_output_set_layout(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
unsigned int index); uint32_t index);
static void dwl_ipc_output_set_tags(struct wl_client *client, static void dwl_ipc_output_set_tags(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
unsigned int tagmask, uint32_t tagmask, uint32_t toggle_tagset);
unsigned int toggle_tagset);
static void dwl_ipc_output_quit(struct wl_client *client, static void dwl_ipc_output_quit(struct wl_client *client,
struct wl_resource *resource); struct wl_resource *resource);
static void dwl_ipc_output_dispatch(struct wl_client *client, static void dwl_ipc_output_dispatch(struct wl_client *client,
@@ -46,7 +44,7 @@ static struct zdwl_ipc_output_v2_interface dwl_output_implementation = {
.set_client_tags = dwl_ipc_output_set_client_tags}; .set_client_tags = dwl_ipc_output_set_client_tags};
void dwl_ipc_manager_bind(struct wl_client *client, void *data, void dwl_ipc_manager_bind(struct wl_client *client, void *data,
unsigned int version, unsigned int id) { uint32_t version, uint32_t id) {
struct wl_resource *manager_resource = struct wl_resource *manager_resource =
wl_resource_create(client, &zdwl_ipc_manager_v2_interface, version, id); wl_resource_create(client, &zdwl_ipc_manager_v2_interface, version, id);
if (!manager_resource) { if (!manager_resource) {
@@ -59,7 +57,7 @@ void dwl_ipc_manager_bind(struct wl_client *client, void *data,
zdwl_ipc_manager_v2_send_tags(manager_resource, LENGTH(tags)); zdwl_ipc_manager_v2_send_tags(manager_resource, LENGTH(tags));
for (unsigned int i = 0; i < LENGTH(layouts); i++) for (uint32_t i = 0; i < LENGTH(layouts); i++)
zdwl_ipc_manager_v2_send_layout(manager_resource, layouts[i].symbol); zdwl_ipc_manager_v2_send_layout(manager_resource, layouts[i].symbol);
} }
@@ -68,7 +66,7 @@ void dwl_ipc_manager_destroy(struct wl_resource *resource) {
} }
void dwl_ipc_manager_get_output(struct wl_client *client, void dwl_ipc_manager_get_output(struct wl_client *client,
struct wl_resource *resource, unsigned int id, struct wl_resource *resource, uint32_t id,
struct wl_resource *output) { struct wl_resource *output) {
DwlIpcOutput *ipc_output; DwlIpcOutput *ipc_output;
struct wlr_output *op = wlr_output_from_resource(output); struct wlr_output *op = wlr_output_from_resource(output);
@@ -101,12 +99,14 @@ static void dwl_ipc_output_destroy(struct wl_resource *resource) {
free(ipc_output); free(ipc_output);
} }
// 修改IPC输出函数接受掩码参数
void dwl_ipc_output_printstatus(Monitor *monitor) { void dwl_ipc_output_printstatus(Monitor *monitor) {
DwlIpcOutput *ipc_output; DwlIpcOutput *ipc_output;
wl_list_for_each(ipc_output, &monitor->dwl_ipc_outputs, link) wl_list_for_each(ipc_output, &monitor->dwl_ipc_outputs, link)
dwl_ipc_output_printstatus_to(ipc_output); dwl_ipc_output_printstatus_to(ipc_output);
} }
// 修改主IPC输出函数根据掩码发送相应事件
void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) { void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) {
Monitor *monitor = ipc_output->mon; Monitor *monitor = ipc_output->mon;
Client *c = NULL, *focused = NULL; Client *c = NULL, *focused = NULL;
@@ -216,12 +216,11 @@ void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) {
void dwl_ipc_output_set_client_tags(struct wl_client *client, void dwl_ipc_output_set_client_tags(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
unsigned int and_tags, uint32_t and_tags, uint32_t xor_tags) {
unsigned int xor_tags) {
DwlIpcOutput *ipc_output; DwlIpcOutput *ipc_output;
Monitor *monitor = NULL; Monitor *monitor = NULL;
Client *selected_client = NULL; Client *selected_client = NULL;
unsigned int newtags = 0; uint32_t newtags = 0;
ipc_output = wl_resource_get_user_data(resource); ipc_output = wl_resource_get_user_data(resource);
if (!ipc_output) if (!ipc_output)
@@ -244,8 +243,7 @@ void dwl_ipc_output_set_client_tags(struct wl_client *client,
} }
void dwl_ipc_output_set_layout(struct wl_client *client, void dwl_ipc_output_set_layout(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource, uint32_t index) {
unsigned int index) {
DwlIpcOutput *ipc_output; DwlIpcOutput *ipc_output;
Monitor *monitor = NULL; Monitor *monitor = NULL;
@@ -258,16 +256,17 @@ 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();
} }
void dwl_ipc_output_set_tags(struct wl_client *client, void dwl_ipc_output_set_tags(struct wl_client *client,
struct wl_resource *resource, unsigned int tagmask, struct wl_resource *resource, uint32_t tagmask,
unsigned int toggle_tagset) { uint32_t toggle_tagset) {
DwlIpcOutput *ipc_output; DwlIpcOutput *ipc_output;
Monitor *monitor = NULL; Monitor *monitor = NULL;
unsigned int newtags = tagmask & TAGMASK; uint32_t newtags = tagmask & TAGMASK;
ipc_output = wl_resource_get_user_data(resource); ipc_output = wl_resource_get_user_data(resource);
if (!ipc_output) if (!ipc_output)

View File

@@ -8,7 +8,7 @@ typedef struct Monitor Monitor;
struct workspace { struct workspace {
struct wl_list link; // Link in global workspaces list struct wl_list link; // Link in global workspaces list
unsigned int tag; // Numeric identifier (1-9, 0=overview) uint32_t tag; // Numeric identifier (1-9, 0=overview)
Monitor *m; // Associated monitor Monitor *m; // Associated monitor
struct wlr_ext_workspace_handle_v1 *ext_workspace; // Protocol object struct wlr_ext_workspace_handle_v1 *ext_workspace; // Protocol object
/* Event listeners */ /* Event listeners */
@@ -22,7 +22,7 @@ struct wlr_ext_workspace_manager_v1 *ext_manager;
struct wl_list workspaces; struct wl_list workspaces;
void goto_workspace(struct workspace *target) { void goto_workspace(struct workspace *target) {
unsigned int tag; uint32_t tag;
tag = 1 << (target->tag - 1); tag = 1 << (target->tag - 1);
if (target->tag == 0) { if (target->tag == 0) {
toggleoverview(&(Arg){.i = -1}); toggleoverview(&(Arg){.i = -1});
@@ -33,7 +33,7 @@ void goto_workspace(struct workspace *target) {
} }
void toggle_workspace(struct workspace *target) { void toggle_workspace(struct workspace *target) {
unsigned int tag; uint32_t tag;
tag = 1 << (target->tag - 1); tag = 1 << (target->tag - 1);
if (target->tag == 0) { if (target->tag == 0) {
toggleview(&(Arg){.i = -1}); toggleview(&(Arg){.i = -1});
@@ -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,11 +60,16 @@ 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);
} }
static const char *get_name_from_tag(unsigned int tag) { static const char *get_name_from_tag(uint32_t tag) {
static const char *names[] = {"overview", "1", "2", "3", "4", static const char *names[] = {"overview", "1", "2", "3", "4",
"5", "6", "7", "8", "9"}; "5", "6", "7", "8", "9"};
return (tag < sizeof(names) / sizeof(names[0])) ? names[tag] : NULL; return (tag < sizeof(names) / sizeof(names[0])) ? names[tag] : NULL;
@@ -82,7 +92,7 @@ void cleanup_workspaces_by_monitor(Monitor *m) {
} }
} }
static void remove_workspace_by_tag(unsigned int tag, Monitor *m) { static void remove_workspace_by_tag(uint32_t tag, Monitor *m) {
struct workspace *workspace, *tmp; struct workspace *workspace, *tmp;
wl_list_for_each_safe(workspace, tmp, &workspaces, link) { wl_list_for_each_safe(workspace, tmp, &workspaces, link) {
if (workspace->tag == tag && workspace->m == m) { if (workspace->tag == tag && workspace->m == m) {
@@ -117,7 +127,7 @@ static void add_workspace_by_tag(int tag, Monitor *m) {
void dwl_ext_workspace_printstatus(Monitor *m) { void dwl_ext_workspace_printstatus(Monitor *m) {
struct workspace *w; struct workspace *w;
unsigned int tag_status = 0; uint32_t tag_status = 0;
wl_list_for_each(w, &workspaces, link) { wl_list_for_each(w, &workspaces, link) {
if (w && w->m == m) { if (w && w->m == m) {

View File

@@ -4,17 +4,12 @@ static struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager;
void handle_foreign_activate_request(struct wl_listener *listener, void *data) { void handle_foreign_activate_request(struct wl_listener *listener, void *data) {
Client *c = wl_container_of(listener, c, foreign_activate_request); Client *c = wl_container_of(listener, c, foreign_activate_request);
unsigned int target; uint32_t target;
if (c && c->swallowing) if (c->swallowing)
return; return;
if (c && !c->isminied && c == selmon->sel) { if (c->isminimized) {
set_minimized(c);
return;
}
if (c->isminied) {
c->is_in_scratchpad = 0; c->is_in_scratchpad = 0;
c->isnamedscratchpad = 0; c->isnamedscratchpad = 0;
c->is_scratchpad_show = 0; c->is_scratchpad_show = 0;
@@ -27,29 +22,82 @@ void handle_foreign_activate_request(struct wl_listener *listener, void *data) {
target = get_tags_first_tag(c->tags); target = get_tags_first_tag(c->tags);
view_in_mon(&(Arg){.ui = target}, true, c->mon, true); view_in_mon(&(Arg){.ui = target}, true, c->mon, true);
focusclient(c, 1); focusclient(c, 1);
wlr_foreign_toplevel_handle_v1_set_activated(c->foreign_toplevel, true); }
void handle_foreign_maximize_request(struct wl_listener *listener, void *data) {
Client *c = wl_container_of(listener, c, foreign_maximize_request);
struct wlr_foreign_toplevel_handle_v1_maximized_event *event = data;
if (c->swallowing)
return;
if (c->ismaximizescreen && !event->maximized) {
setmaximizescreen(c, 0);
return;
}
if (!c->ismaximizescreen && event->maximized) {
setmaximizescreen(c, 1);
return;
}
}
void handle_foreign_minimize_request(struct wl_listener *listener, void *data) {
Client *c = wl_container_of(listener, c, foreign_minimize_request);
struct wlr_foreign_toplevel_handle_v1_minimized_event *event = data;
if (c->swallowing)
return;
if (!c->isminimized && event->minimized) {
set_minimized(c);
return;
}
if (c->isminimized && !event->minimized) {
c->is_in_scratchpad = 0;
c->isnamedscratchpad = 0;
c->is_scratchpad_show = 0;
setborder_color(c);
show_hide_client(c);
arrange(c->mon, true);
return;
}
} }
void handle_foreign_fullscreen_request(struct wl_listener *listener, void handle_foreign_fullscreen_request(struct wl_listener *listener,
void *data) { void *data) {
return;
Client *c = wl_container_of(listener, c, foreign_fullscreen_request);
struct wlr_foreign_toplevel_handle_v1_fullscreen_event *event = data;
if (c->swallowing)
return;
if (c->isfullscreen && !event->fullscreen) {
setfullscreen(c, 0);
return;
}
if (!c->isfullscreen && event->fullscreen) {
setfullscreen(c, 1);
return;
}
} }
void handle_foreign_close_request(struct wl_listener *listener, void *data) { void handle_foreign_close_request(struct wl_listener *listener, void *data) {
Client *c = wl_container_of(listener, c, foreign_close_request); Client *c = wl_container_of(listener, c, foreign_close_request);
if (c) { pending_kill_client(c);
pending_kill_client(c);
}
} }
void handle_foreign_destroy(struct wl_listener *listener, void *data) { void handle_foreign_destroy(struct wl_listener *listener, void *data) {
Client *c = wl_container_of(listener, c, foreign_destroy); Client *c = wl_container_of(listener, c, foreign_destroy);
if (c) { wl_list_remove(&c->foreign_activate_request.link);
wl_list_remove(&c->foreign_activate_request.link); wl_list_remove(&c->foreign_minimize_request.link);
wl_list_remove(&c->foreign_fullscreen_request.link); wl_list_remove(&c->foreign_maximize_request.link);
wl_list_remove(&c->foreign_close_request.link); wl_list_remove(&c->foreign_fullscreen_request.link);
wl_list_remove(&c->foreign_destroy.link); wl_list_remove(&c->foreign_close_request.link);
} wl_list_remove(&c->foreign_destroy.link);
} }
void remove_foreign_topleve(Client *c) { void remove_foreign_topleve(Client *c) {
@@ -67,6 +115,10 @@ void add_foreign_toplevel(Client *c) {
if (c->foreign_toplevel) { if (c->foreign_toplevel) {
LISTEN(&(c->foreign_toplevel->events.request_activate), LISTEN(&(c->foreign_toplevel->events.request_activate),
&c->foreign_activate_request, handle_foreign_activate_request); &c->foreign_activate_request, handle_foreign_activate_request);
LISTEN(&(c->foreign_toplevel->events.request_minimize),
&c->foreign_minimize_request, handle_foreign_minimize_request);
LISTEN(&(c->foreign_toplevel->events.request_maximize),
&c->foreign_maximize_request, handle_foreign_maximize_request);
LISTEN(&(c->foreign_toplevel->events.request_fullscreen), LISTEN(&(c->foreign_toplevel->events.request_fullscreen),
&c->foreign_fullscreen_request, &c->foreign_fullscreen_request,
handle_foreign_fullscreen_request); handle_foreign_fullscreen_request);

View File

@@ -13,7 +13,10 @@ static void handle_controller_set_hint(struct wl_listener *listener,
void *data) { void *data) {
struct tearing_controller *controller = struct tearing_controller *controller =
wl_container_of(listener, controller, set_hint); wl_container_of(listener, controller, set_hint);
Client *c = get_client_from_surface(controller->tearing_control->surface); Client *c = NULL;
toplevel_from_wlr_surface(controller->tearing_control->surface, &c, NULL);
if (c) { if (c) {
/* /*
* tearing_control->current is actually an enum: * tearing_control->current is actually an enum:

View File

@@ -41,10 +41,21 @@ Client *get_client_by_id_or_title(const char *arg_id, const char *arg_title) {
continue; continue;
} }
if (!(appid = client_get_appid(c))) if (c->swallowedby) {
appid = client_get_appid(c->swallowedby);
title = client_get_title(c->swallowedby);
} else {
appid = client_get_appid(c);
title = client_get_title(c);
}
if (!appid) {
appid = broken; appid = broken;
if (!(title = client_get_title(c))) }
if (!title) {
title = broken; title = broken;
}
if (arg_id && strncmp(arg_id, "none", 4) == 0) if (arg_id && strncmp(arg_id, "none", 4) == 0)
arg_id = NULL; arg_id = NULL;
@@ -70,7 +81,7 @@ setclient_coordinate_center(Client *c, struct wlr_box geom, int offsetx,
int len = 0; int len = 0;
Monitor *m = c->mon ? c->mon : selmon; Monitor *m = c->mon ? c->mon : selmon;
unsigned int cbw = check_hit_no_border(c) ? c->bw : 0; uint32_t cbw = check_hit_no_border(c) ? c->bw : 0;
if (!c->no_force_center) { if (!c->no_force_center) {
tempbox.x = m->w.x + (m->w.width - geom.width) / 2; tempbox.x = m->w.x + (m->w.width - geom.width) / 2;
@@ -128,8 +139,9 @@ Client *center_tiled_select(Monitor *m) {
int dirx, diry; int dirx, diry;
long int distance; long int distance;
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (c && VISIBLEON(c, m) && ISTILED(c) && client_surface(c)->mapped && if (c && VISIBLEON(c, m) && ISSCROLLTILED(c) &&
!c->isfloating && !client_is_unmanaged(c)) { client_surface(c)->mapped && !c->isfloating &&
!client_is_unmanaged(c)) {
dirx = c->geom.x + c->geom.width / 2 - (m->w.x + m->w.width / 2); dirx = c->geom.x + c->geom.width / 2 - (m->w.x + m->w.width / 2);
diry = c->geom.y + c->geom.height / 2 - (m->w.y + m->w.height / 2); diry = c->geom.y + c->geom.height / 2 - (m->w.y + m->w.height / 2);
distance = dirx * dirx + diry * diry; distance = dirx * dirx + diry * diry;
@@ -142,10 +154,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) {
@@ -181,25 +194,29 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
int sel_x = tc->geom.x; int sel_x = tc->geom.x;
int sel_y = tc->geom.y; int sel_y = tc->geom.y;
long long int distance = LLONG_MAX; long long int distance = LLONG_MAX;
long long int same_monitor_distance = LLONG_MAX;
Client *tempFocusClients = NULL; Client *tempFocusClients = NULL;
Client *tempSameMonitorFocusClients = NULL;
switch (arg->i) { switch (arg->i) {
case UP: case UP:
for (int _i = 0; _i <= last; _i++) { if (!ignore_align) {
if (tempClients[_i]->geom.y < sel_y && for (int _i = 0; _i <= last; _i++) {
tempClients[_i]->geom.x == sel_x && if (tempClients[_i]->geom.y < sel_y &&
tempClients[_i]->mon == tc->mon) { tempClients[_i]->geom.x == sel_x &&
int dis_x = tempClients[_i]->geom.x - sel_x; tempClients[_i]->mon == tc->mon) {
int dis_y = tempClients[_i]->geom.y - sel_y; int dis_x = tempClients[_i]->geom.x - sel_x;
long long int tmp_distance = int dis_y = tempClients[_i]->geom.y - sel_y;
dis_x * dis_x + dis_y * dis_y; // 计算距离 long long int tmp_distance =
if (tmp_distance < distance) { dis_x * dis_x + dis_y * dis_y; // 计算距离
distance = tmp_distance; if (tmp_distance < distance) {
tempFocusClients = tempClients[_i]; distance = tmp_distance;
tempFocusClients = tempClients[_i];
}
} }
} }
} }
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;
@@ -210,26 +227,33 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
distance = tmp_distance; distance = tmp_distance;
tempFocusClients = tempClients[_i]; tempFocusClients = tempClients[_i];
} }
if (tempClients[_i]->mon == tc->mon &&
tmp_distance < same_monitor_distance) {
same_monitor_distance = tmp_distance;
tempSameMonitorFocusClients = tempClients[_i];
}
} }
} }
} }
break; break;
case DOWN: case DOWN:
for (int _i = 0; _i <= last; _i++) { if (!ignore_align) {
if (tempClients[_i]->geom.y > sel_y && for (int _i = 0; _i <= last; _i++) {
tempClients[_i]->geom.x == sel_x && if (tempClients[_i]->geom.y > sel_y &&
tempClients[_i]->mon == tc->mon) { tempClients[_i]->geom.x == sel_x &&
int dis_x = tempClients[_i]->geom.x - sel_x; tempClients[_i]->mon == tc->mon) {
int dis_y = tempClients[_i]->geom.y - sel_y; int dis_x = tempClients[_i]->geom.x - sel_x;
long long int tmp_distance = int dis_y = tempClients[_i]->geom.y - sel_y;
dis_x * dis_x + dis_y * dis_y; // 计算距离 long long int tmp_distance =
if (tmp_distance < distance) { dis_x * dis_x + dis_y * dis_y; // 计算距离
distance = tmp_distance; if (tmp_distance < distance) {
tempFocusClients = tempClients[_i]; distance = tmp_distance;
tempFocusClients = tempClients[_i];
}
} }
} }
} }
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;
@@ -240,26 +264,33 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
distance = tmp_distance; distance = tmp_distance;
tempFocusClients = tempClients[_i]; tempFocusClients = tempClients[_i];
} }
if (tempClients[_i]->mon == tc->mon &&
tmp_distance < same_monitor_distance) {
same_monitor_distance = tmp_distance;
tempSameMonitorFocusClients = tempClients[_i];
}
} }
} }
} }
break; break;
case LEFT: case LEFT:
for (int _i = 0; _i <= last; _i++) { if (!ignore_align || constrain_to_row) {
if (tempClients[_i]->geom.x < sel_x && for (int _i = 0; _i <= last; _i++) {
tempClients[_i]->geom.y == sel_y && if (tempClients[_i]->geom.x < sel_x &&
tempClients[_i]->mon == tc->mon) { tempClients[_i]->geom.y == sel_y &&
int dis_x = tempClients[_i]->geom.x - sel_x; tempClients[_i]->mon == tc->mon) {
int dis_y = tempClients[_i]->geom.y - sel_y; int dis_x = tempClients[_i]->geom.x - sel_x;
long long int tmp_distance = int dis_y = tempClients[_i]->geom.y - sel_y;
dis_x * dis_x + dis_y * dis_y; // 计算距离 long long int tmp_distance =
if (tmp_distance < distance) { dis_x * dis_x + dis_y * dis_y; // 计算距离
distance = tmp_distance; if (tmp_distance < distance) {
tempFocusClients = tempClients[_i]; distance = tmp_distance;
tempFocusClients = tempClients[_i];
}
} }
} }
} }
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;
@@ -270,28 +301,21 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
distance = tmp_distance; distance = tmp_distance;
tempFocusClients = tempClients[_i]; tempFocusClients = tempClients[_i];
} }
if (tempClients[_i]->mon == tc->mon &&
tmp_distance < same_monitor_distance) {
same_monitor_distance = tmp_distance;
tempSameMonitorFocusClients = tempClients[_i];
}
} }
} }
} }
break; break;
case RIGHT: case RIGHT:
for (int _i = 0; _i <= last; _i++) { if (!ignore_align || constrain_to_row) {
if (tempClients[_i]->geom.x > sel_x &&
tempClients[_i]->geom.y == sel_y &&
tempClients[_i]->mon == tc->mon) {
int dis_x = tempClients[_i]->geom.x - sel_x;
int dis_y = tempClients[_i]->geom.y - sel_y;
long long int tmp_distance =
dis_x * dis_x + dis_y * dis_y; // 计算距离
if (tmp_distance < distance) {
distance = tmp_distance;
tempFocusClients = tempClients[_i];
}
}
}
if (!tempFocusClients && !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]->mon == tc->mon) {
int dis_x = tempClients[_i]->geom.x - sel_x; int dis_x = tempClients[_i]->geom.x - sel_x;
int dis_y = tempClients[_i]->geom.y - sel_y; int dis_y = tempClients[_i]->geom.y - sel_y;
long long int tmp_distance = long long int tmp_distance =
@@ -303,11 +327,34 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
} }
} }
} }
if (!tempFocusClients && !constrain_to_row) {
for (int _i = 0; _i <= last; _i++) {
if (tempClients[_i]->geom.x > sel_x) {
int dis_x = tempClients[_i]->geom.x - sel_x;
int dis_y = tempClients[_i]->geom.y - sel_y;
long long int tmp_distance =
dis_x * dis_x + dis_y * dis_y; // 计算距离
if (tmp_distance < distance) {
distance = tmp_distance;
tempFocusClients = tempClients[_i];
}
if (tempClients[_i]->mon == tc->mon &&
tmp_distance < same_monitor_distance) {
same_monitor_distance = tmp_distance;
tempSameMonitorFocusClients = tempClients[_i];
}
}
}
}
break; break;
} }
free(tempClients); // 释放内存 free(tempClients); // 释放内存
return tempFocusClients; if (tempSameMonitorFocusClients) {
return tempSameMonitorFocusClients;
} else {
return tempFocusClients;
}
} }
Client *direction_select(const Arg *arg) { Client *direction_select(const Arg *arg) {
@@ -317,12 +364,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 +422,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

@@ -1,5 +1,5 @@
pid_t getparentprocess(pid_t p) { pid_t getparentprocess(pid_t p) {
unsigned int v = 0; uint32_t v = 0;
FILE *f; FILE *f;
char buf[256]; char buf[256];
@@ -26,24 +26,6 @@ int isdescprocess(pid_t p, pid_t c) {
return (int)c; return (int)c;
} }
char *get_autostart_path(char *autostart_path, unsigned int buf_size) {
const char *mangoconfig = getenv("MANGOCONFIG");
if (mangoconfig && mangoconfig[0] != '\0') {
snprintf(autostart_path, buf_size, "%s/autostart.sh", mangoconfig);
} else {
const char *homedir = getenv("HOME");
if (!homedir) {
fprintf(stderr, "Error: HOME environment variable not set.\n");
return NULL;
}
snprintf(autostart_path, buf_size, "%s/.config/mango/autostart.sh",
homedir);
}
return autostart_path;
}
void get_layout_abbr(char *abbr, const char *full_name) { void get_layout_abbr(char *abbr, const char *full_name) {
// 清空输出缓冲区 // 清空输出缓冲区
abbr[0] = '\0'; abbr[0] = '\0';
@@ -60,10 +42,10 @@ void get_layout_abbr(char *abbr, const char *full_name) {
const char *open = strrchr(full_name, '('); const char *open = strrchr(full_name, '(');
const char *close = strrchr(full_name, ')'); const char *close = strrchr(full_name, ')');
if (open && close && close > open) { if (open && close && close > open) {
unsigned int len = close - open - 1; uint32_t len = close - open - 1;
if (len > 0 && len <= 4) { if (len > 0 && len <= 4) {
// 提取并转换为小写 // 提取并转换为小写
for (unsigned int j = 0; j < len; j++) { for (uint32_t j = 0; j < len; j++) {
abbr[j] = tolower(open[j + 1]); abbr[j] = tolower(open[j + 1]);
} }
abbr[len] = '\0'; abbr[len] = '\0';
@@ -72,8 +54,8 @@ void get_layout_abbr(char *abbr, const char *full_name) {
} }
// 3. 提取前2-3个字母并转换为小写 // 3. 提取前2-3个字母并转换为小写
unsigned int j = 0; uint32_t j = 0;
for (unsigned int i = 0; full_name[i] != '\0' && j < 3; i++) { for (uint32_t i = 0; full_name[i] != '\0' && j < 3; i++) {
if (isalpha(full_name[i])) { if (isalpha(full_name[i])) {
abbr[j++] = tolower(full_name[i]); abbr[j++] = tolower(full_name[i]);
} }
@@ -115,6 +97,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

@@ -23,12 +23,25 @@ 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; return false;
} }
unsigned int get_tag_status(unsigned int tag, Monitor *m) { 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;
}
uint32_t get_tag_status(uint32_t tag, Monitor *m) {
Client *c = NULL; Client *c = NULL;
unsigned int status = 0; uint32_t status = 0;
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (c->mon == m && c->tags & 1 << (tag - 1) & TAGMASK) { if (c->mon == m && c->tags & 1 << (tag - 1) & TAGMASK) {
if (c->isurgent) { if (c->isurgent) {
@@ -41,8 +54,8 @@ unsigned int get_tag_status(unsigned int tag, Monitor *m) {
return status; return status;
} }
unsigned int get_tags_first_tag_num(unsigned int source_tags) { uint32_t get_tags_first_tag_num(uint32_t source_tags) {
unsigned int i, tag; uint32_t i, tag;
tag = 0; tag = 0;
if (!source_tags) { if (!source_tags) {
@@ -63,8 +76,8 @@ unsigned int get_tags_first_tag_num(unsigned int source_tags) {
} }
// 获取tags中最前面的tag的tagmask // 获取tags中最前面的tag的tagmask
unsigned int get_tags_first_tag(unsigned int source_tags) { uint32_t get_tags_first_tag(uint32_t source_tags) {
unsigned int i, tag; uint32_t i, tag;
tag = 0; tag = 0;
if (!source_tags) { if (!source_tags) {

View File

@@ -19,7 +19,7 @@ void set_size_per(Monitor *m, Client *c) {
} }
void resize_tile_master_horizontal(Client *grabc, bool isdrag, int offsetx, void resize_tile_master_horizontal(Client *grabc, bool isdrag, int offsetx,
int offsety, unsigned int time, int type) { int offsety, uint32_t time, int type) {
Client *tc = NULL; Client *tc = NULL;
float delta_x, delta_y; float delta_x, delta_y;
Client *next = NULL; Client *next = NULL;
@@ -213,7 +213,7 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int offsetx,
} }
void resize_tile_master_vertical(Client *grabc, bool isdrag, int offsetx, void resize_tile_master_vertical(Client *grabc, bool isdrag, int offsetx,
int offsety, unsigned int time, int type) { int offsety, uint32_t time, int type) {
Client *tc = NULL; Client *tc = NULL;
float delta_x, delta_y; float delta_x, delta_y;
Client *next = NULL; Client *next = NULL;
@@ -370,10 +370,14 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int offsetx,
} }
void resize_tile_scroller(Client *grabc, bool isdrag, int offsetx, int offsety, void resize_tile_scroller(Client *grabc, bool isdrag, int offsetx, int offsety,
unsigned int time, bool isvertical) { uint32_t time, bool isvertical) {
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;
@@ -470,11 +474,14 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int offsetx, int offsety,
} }
void resize_tile_client(Client *grabc, bool isdrag, int offsetx, int offsety, void resize_tile_client(Client *grabc, bool isdrag, int offsetx, int offsety,
unsigned int time) { uint32_t time) {
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);
} }
} }
@@ -502,24 +511,22 @@ void reset_size_per_mon(Monitor *m, int tile_cilent_num,
int stack_num) { int stack_num) {
Client *c = NULL; Client *c = NULL;
int i = 0; int i = 0;
unsigned int stack_index = 0; uint32_t stack_index = 0;
unsigned int nmasters = m->pertag->nmasters[m->pertag->curtag]; uint32_t nmasters = m->pertag->nmasters[m->pertag->curtag];
if (m->pertag->ltidxs[m->pertag->curtag]->id != CENTER_TILE) { if (m->pertag->ltidxs[m->pertag->curtag]->id != CENTER_TILE) {
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (VISIBLEON(c, m) && ISTILED(c)) { if (VISIBLEON(c, m) && ISTILED(c)) {
if (total_master_inner_percent > 0.0 && i < nmasters) {
if (total_master_inner_percent <= 0.0)
return;
if (i < m->pertag->nmasters[m->pertag->curtag]) {
c->ismaster = true; c->ismaster = true;
c->stack_innder_per = stack_num ? 1.0f / stack_num : 1.0f; c->stack_innder_per = stack_num ? 1.0f / stack_num : 1.0f;
c->master_inner_per = c->master_inner_per =
c->master_inner_per / total_master_inner_percent; c->master_inner_per / total_master_inner_percent;
} else { } else {
c->ismaster = false; c->ismaster = false;
c->master_inner_per = 1.0f / master_num; c->master_inner_per =
master_num > 0 ? 1.0f / master_num : 1.0f;
c->stack_innder_per = c->stack_innder_per =
total_stack_hight_percent total_stack_hight_percent
? c->stack_innder_per / total_stack_hight_percent ? c->stack_innder_per / total_stack_hight_percent
@@ -531,10 +538,7 @@ void reset_size_per_mon(Monitor *m, int tile_cilent_num,
} else { } else {
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (VISIBLEON(c, m) && ISTILED(c)) { if (VISIBLEON(c, m) && ISTILED(c)) {
if (total_master_inner_percent > 0.0 && i < nmasters) {
if (total_master_inner_percent <= 0.0)
return;
if (i < m->pertag->nmasters[m->pertag->curtag]) {
c->ismaster = true; c->ismaster = true;
if ((stack_index % 2) ^ (tile_cilent_num % 2 == 0)) { if ((stack_index % 2) ^ (tile_cilent_num % 2 == 0)) {
c->stack_innder_per = c->stack_innder_per =
@@ -551,7 +555,8 @@ void reset_size_per_mon(Monitor *m, int tile_cilent_num,
stack_index = i - nmasters; stack_index = i - nmasters;
c->ismaster = false; c->ismaster = false;
c->master_inner_per = 1.0f / master_num; c->master_inner_per =
master_num > 0 ? 1.0f / master_num : 1.0f;
if ((stack_index % 2) ^ (tile_cilent_num % 2 == 0)) { if ((stack_index % 2) ^ (tile_cilent_num % 2 == 0)) {
c->stack_innder_per = c->stack_innder_per =
total_right_stack_hight_percent total_right_stack_hight_percent
@@ -592,6 +597,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 +618,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++;
}
} }
} }
@@ -625,7 +635,7 @@ arrange(Monitor *m, bool want_animation) {
if (VISIBLEON(c, m)) { if (VISIBLEON(c, m)) {
if (ISTILED(c)) { if (ISTILED(c)) {
if (i < m->pertag->nmasters[m->pertag->curtag]) { if (i < nmasters) {
master_num++; master_num++;
total_master_inner_percent += c->master_inner_per; total_master_inner_percent += c->master_inner_per;
} else { } else {
@@ -674,4 +684,6 @@ arrange(Monitor *m, bool want_animation) {
motionnotify(0, NULL, 0, 0, 0, 0); motionnotify(0, NULL, 0, 0, 0, 0);
checkidleinhibitor(NULL); checkidleinhibitor(NULL);
} }
printstatus();
} }

View File

@@ -1,9 +1,9 @@
// 网格布局窗口大小和位置计算 // 网格布局窗口大小和位置计算
void grid(Monitor *m) { void grid(Monitor *m) {
unsigned int i, n; uint32_t i, n;
unsigned int cx, cy, cw, ch; uint32_t cx, cy, cw, ch;
unsigned int dx; uint32_t dx;
unsigned int cols, rows, overcols; uint32_t cols, rows, overcols;
Client *c = NULL; Client *c = NULL;
n = 0; n = 0;
int target_gappo = enablegaps ? m->isoverview ? overviewgappo : gappoh : 0; int target_gappo = enablegaps ? m->isoverview ? overviewgappo : gappoh : 0;
@@ -23,10 +23,6 @@ void grid(Monitor *m) {
if (c->mon != m) if (c->mon != m)
continue; continue;
c->bw = m->visible_tiling_clients == 1 && no_border_when_single &&
smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal && if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) { ((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
cw = (m->w.width - 2 * target_gappo) * single_width_ratio; cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
@@ -49,10 +45,6 @@ void grid(Monitor *m) {
if (c->mon != m) if (c->mon != m)
continue; continue;
c->bw = m->visible_tiling_clients == 1 && no_border_when_single &&
smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal && if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) { ((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
if (i == 0) { if (i == 0) {
@@ -99,10 +91,7 @@ void grid(Monitor *m) {
if (c->mon != m) if (c->mon != m)
continue; continue;
c->bw =
m->visible_tiling_clients == 1 && no_border_when_single && smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal && if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) { ((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
cx = m->w.x + (i % cols) * (cw + target_gappi); cx = m->w.x + (i % cols) * (cw + target_gappi);
@@ -121,15 +110,15 @@ void grid(Monitor *m) {
} }
void deck(Monitor *m) { void deck(Monitor *m) {
unsigned int mw, my; uint32_t mw, my;
int i, n = 0; int i, n = 0;
Client *c = NULL; Client *c = NULL;
Client *fc = NULL; Client *fc = NULL;
float mfact; float mfact;
unsigned int cur_gappih = enablegaps ? m->gappih : 0; uint32_t cur_gappih = enablegaps ? m->gappih : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0; uint32_t cur_gappov = enablegaps ? m->gappov : 0;
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih; cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
@@ -189,27 +178,62 @@ void deck(Monitor *m) {
} }
} }
void horizontal_scroll_adjust_fullandmax(Client *c,
struct wlr_box *target_geom) {
Monitor *m = c->mon;
uint32_t cur_gappih = enablegaps ? m->gappih : 0;
uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
uint32_t 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; uint32_t 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
struct wlr_box target_geom; struct wlr_box target_geom;
int focus_client_index = 0; int focus_client_index = 0;
bool need_scroller = false; bool need_scroller = false;
unsigned int cur_gappih = enablegaps ? m->gappih : 0; uint32_t cur_gappih = enablegaps ? m->gappih : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0; uint32_t 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 = uint32_t 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 +249,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 +272,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) && ISSCROLLTILED(m->sel)) {
!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 +289,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 +301,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 +345,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,8 +365,214 @@ 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 using configurable split ratio
unsigned int top_row_height = (unsigned int)((m->w.height - 2 * cur_gappov - cur_gappiv) * dual_scroller_default_split_ratio);
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; uint32_t i, n = 0, h, r, ie = enablegaps, mw, mx, my, oty, ety, tw;
Client *c = NULL; Client *c = NULL;
Client *fc = NULL; Client *fc = NULL;
double mfact = 0; double mfact = 0;
@@ -334,6 +581,8 @@ void center_tile(Monitor *m) {
n = m->visible_tiling_clients; n = m->visible_tiling_clients;
master_num = m->pertag->nmasters[m->pertag->curtag]; master_num = m->pertag->nmasters[m->pertag->curtag];
master_num = n > master_num ? master_num : n;
stack_num = n - master_num; stack_num = n - master_num;
if (n == 0) if (n == 0)
@@ -346,10 +595,10 @@ void center_tile(Monitor *m) {
} }
// 间隙参数处理 // 间隙参数处理
unsigned int cur_gappiv = enablegaps ? m->gappiv : 0; // 内部垂直间隙 uint32_t cur_gappiv = enablegaps ? m->gappiv : 0; // 内部垂直间隙
unsigned int cur_gappih = enablegaps ? m->gappih : 0; // 内部水平间隙 uint32_t cur_gappih = enablegaps ? m->gappih : 0; // 内部水平间隙
unsigned int cur_gappov = enablegaps ? m->gappov : 0; // 外部垂直间隙 uint32_t cur_gappov = enablegaps ? m->gappov : 0; // 外部垂直间隙
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; // 外部水平间隙 uint32_t cur_gappoh = enablegaps ? m->gappoh : 0; // 外部水平间隙
// 智能间隙处理 // 智能间隙处理
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv; cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
@@ -357,7 +606,7 @@ void center_tile(Monitor *m) {
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
unsigned int nmasters = m->pertag->nmasters[m->pertag->curtag]; uint32_t nmasters = m->pertag->nmasters[m->pertag->curtag];
mfact = fc->master_mfact_per > 0.0f ? fc->master_mfact_per mfact = fc->master_mfact_per > 0.0f ? fc->master_mfact_per
: m->pertag->mfacts[m->pertag->curtag]; : m->pertag->mfacts[m->pertag->curtag];
@@ -370,6 +619,19 @@ void center_tile(Monitor *m) {
// 判断是否需要主区域铺满 // 判断是否需要主区域铺满
int should_overspread = center_master_overspread && (n <= nmasters); int should_overspread = center_master_overspread && (n <= nmasters);
uint32_t master_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (master_num - 1));
float master_surplus_ratio = 1.0;
uint32_t slave_left_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (stack_num / 2 - 1));
float slave_left_surplus_ratio = 1.0;
uint32_t slave_right_surplus_height =
(m->w.height - 2 * cur_gappov -
cur_gappiv * ie * ((stack_num + 1) / 2 - 1));
float slave_right_surplus_ratio = 1.0;
if (n > nmasters || !should_overspread) { if (n > nmasters || !should_overspread) {
// 计算主区域宽度(居中模式) // 计算主区域宽度(居中模式)
mw = nmasters ? (m->w.width - 2 * cur_gappoh - cur_gappih * ie) * mfact mw = nmasters ? (m->w.width - 2 * cur_gappoh - cur_gappih * ie) * mfact
@@ -414,9 +676,11 @@ void center_tile(Monitor *m) {
// 主区域窗口 // 主区域窗口
r = MIN(n, nmasters) - i; r = MIN(n, nmasters) - i;
if (c->master_inner_per > 0.0f) { if (c->master_inner_per > 0.0f) {
h = (m->w.height - 2 * cur_gappov - h = master_surplus_height * c->master_inner_per /
cur_gappiv * ie * (master_num - 1)) * master_surplus_ratio;
c->master_inner_per; master_surplus_height = master_surplus_height - h;
master_surplus_ratio =
master_surplus_ratio - c->master_inner_per;
c->master_mfact_per = mfact; c->master_mfact_per = mfact;
} else { } else {
h = (m->w.height - my - cur_gappov - h = (m->w.height - my - cur_gappov -
@@ -436,7 +700,7 @@ void center_tile(Monitor *m) {
my += c->geom.height + cur_gappiv * ie; my += c->geom.height + cur_gappiv * ie;
} else { } else {
// 堆叠区域窗口 // 堆叠区域窗口
unsigned int stack_index = i - nmasters; uint32_t stack_index = i - nmasters;
if (n - nmasters == 1) { if (n - nmasters == 1) {
// 单个堆叠窗口 // 单个堆叠窗口
@@ -478,9 +742,12 @@ void center_tile(Monitor *m) {
if ((stack_index % 2) ^ (n % 2 == 0)) { if ((stack_index % 2) ^ (n % 2 == 0)) {
// 右侧堆叠窗口 // 右侧堆叠窗口
if (c->stack_innder_per > 0.0f) { if (c->stack_innder_per > 0.0f) {
h = (m->w.height - 2 * cur_gappov - h = slave_right_surplus_height * c->stack_innder_per /
cur_gappiv * ie * ((stack_num + 1) / 2 - 1)) * slave_right_surplus_ratio;
c->stack_innder_per; slave_right_surplus_height =
slave_right_surplus_height - h;
slave_right_surplus_ratio =
slave_right_surplus_ratio - c->stack_innder_per;
c->master_mfact_per = mfact; c->master_mfact_per = mfact;
} else { } else {
h = (m->w.height - ety - cur_gappov - h = (m->w.height - ety - cur_gappov -
@@ -504,9 +771,12 @@ void center_tile(Monitor *m) {
} else { } else {
// 左侧堆叠窗口 // 左侧堆叠窗口
if (c->stack_innder_per > 0.0f) { if (c->stack_innder_per > 0.0f) {
h = (m->w.height - 2 * cur_gappov - h = slave_left_surplus_height * c->stack_innder_per /
cur_gappiv * ie * (stack_num / 2 - 1)) * slave_left_surplus_ratio;
c->stack_innder_per; slave_left_surplus_height =
slave_left_surplus_height - h;
slave_left_surplus_ratio =
slave_left_surplus_ratio - c->stack_innder_per;
c->master_mfact_per = mfact; c->master_mfact_per = mfact;
} else { } else {
h = (m->w.height - oty - cur_gappov - h = (m->w.height - oty - cur_gappov -
@@ -534,7 +804,7 @@ void center_tile(Monitor *m) {
} }
void tile(Monitor *m) { void tile(Monitor *m) {
unsigned int i, n = 0, h, r, ie = enablegaps, mw, my, ty; uint32_t i, n = 0, h, r, ie = enablegaps, mw, my, ty;
Client *c = NULL; Client *c = NULL;
Client *fc = NULL; Client *fc = NULL;
double mfact = 0; double mfact = 0;
@@ -543,15 +813,16 @@ void tile(Monitor *m) {
n = m->visible_tiling_clients; n = m->visible_tiling_clients;
master_num = m->pertag->nmasters[m->pertag->curtag]; master_num = m->pertag->nmasters[m->pertag->curtag];
master_num = n > master_num ? master_num : n;
stack_num = n - master_num; stack_num = n - master_num;
if (n == 0) if (n == 0)
return; return;
unsigned int cur_gappiv = enablegaps ? m->gappiv : 0; uint32_t cur_gappiv = enablegaps ? m->gappiv : 0;
unsigned int cur_gappih = enablegaps ? m->gappih : 0; uint32_t cur_gappih = enablegaps ? m->gappih : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0; uint32_t cur_gappov = enablegaps ? m->gappov : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv; cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih; cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
@@ -575,15 +846,26 @@ void tile(Monitor *m) {
mw = m->w.width - 2 * cur_gappoh + cur_gappih * ie; mw = m->w.width - 2 * cur_gappoh + cur_gappih * ie;
i = 0; i = 0;
my = ty = cur_gappov; my = ty = cur_gappov;
uint32_t master_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (master_num - 1));
float master_surplus_ratio = 1.0;
uint32_t slave_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (stack_num - 1));
float slave_surplus_ratio = 1.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) || !ISTILED(c))
continue; continue;
if (i < m->pertag->nmasters[m->pertag->curtag]) { if (i < m->pertag->nmasters[m->pertag->curtag]) {
r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i; r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i;
if (c->master_inner_per > 0.0f) { if (c->master_inner_per > 0.0f) {
h = (m->w.height - 2 * cur_gappov - h = master_surplus_height * c->master_inner_per /
cur_gappiv * ie * (master_num - 1)) * master_surplus_ratio;
c->master_inner_per; master_surplus_height = master_surplus_height - h;
master_surplus_ratio =
master_surplus_ratio - c->master_inner_per;
c->master_mfact_per = mfact; c->master_mfact_per = mfact;
} else { } else {
h = (m->w.height - my - cur_gappov - h = (m->w.height - my - cur_gappov -
@@ -603,9 +885,10 @@ void tile(Monitor *m) {
} else { } else {
r = n - i; r = n - i;
if (c->stack_innder_per > 0.0f) { if (c->stack_innder_per > 0.0f) {
h = (m->w.height - 2 * cur_gappov - h = slave_surplus_height * c->stack_innder_per /
cur_gappiv * ie * (stack_num - 1)) * slave_surplus_ratio;
c->stack_innder_per; slave_surplus_height = slave_surplus_height - h;
slave_surplus_ratio = slave_surplus_ratio - c->stack_innder_per;
c->master_mfact_per = mfact; c->master_mfact_per = mfact;
} else { } else {
h = (m->w.height - ty - cur_gappov - h = (m->w.height - ty - cur_gappov -
@@ -631,7 +914,7 @@ void tile(Monitor *m) {
} }
void right_tile(Monitor *m) { void right_tile(Monitor *m) {
unsigned int i, n = 0, h, r, ie = enablegaps, mw, my, ty; uint32_t i, n = 0, h, r, ie = enablegaps, mw, my, ty;
Client *c = NULL; Client *c = NULL;
Client *fc = NULL; Client *fc = NULL;
double mfact = 0; double mfact = 0;
@@ -640,15 +923,16 @@ void right_tile(Monitor *m) {
n = m->visible_tiling_clients; n = m->visible_tiling_clients;
master_num = m->pertag->nmasters[m->pertag->curtag]; master_num = m->pertag->nmasters[m->pertag->curtag];
master_num = n > master_num ? master_num : n;
stack_num = n - master_num; stack_num = n - master_num;
if (n == 0) if (n == 0)
return; return;
unsigned int cur_gappiv = enablegaps ? m->gappiv : 0; uint32_t cur_gappiv = enablegaps ? m->gappiv : 0;
unsigned int cur_gappih = enablegaps ? m->gappih : 0; uint32_t cur_gappih = enablegaps ? m->gappih : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0; uint32_t cur_gappov = enablegaps ? m->gappov : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv; cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih; cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
@@ -672,15 +956,26 @@ void right_tile(Monitor *m) {
mw = m->w.width - 2 * cur_gappoh + cur_gappih * ie; mw = m->w.width - 2 * cur_gappoh + cur_gappih * ie;
i = 0; i = 0;
my = ty = cur_gappov; my = ty = cur_gappov;
uint32_t master_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (master_num - 1));
float master_surplus_ratio = 1.0;
uint32_t slave_surplus_height =
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (stack_num - 1));
float slave_surplus_ratio = 1.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) || !ISTILED(c))
continue; continue;
if (i < m->pertag->nmasters[m->pertag->curtag]) { if (i < m->pertag->nmasters[m->pertag->curtag]) {
r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i; r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i;
if (c->master_inner_per > 0.0f) { if (c->master_inner_per > 0.0f) {
h = (m->w.height - 2 * cur_gappov - h = master_surplus_height * c->master_inner_per /
cur_gappiv * ie * (master_num - 1)) * master_surplus_ratio;
c->master_inner_per; master_surplus_height = master_surplus_height - h;
master_surplus_ratio =
master_surplus_ratio - c->master_inner_per;
c->master_mfact_per = mfact; c->master_mfact_per = mfact;
} else { } else {
h = (m->w.height - my - cur_gappov - h = (m->w.height - my - cur_gappov -
@@ -701,9 +996,10 @@ void right_tile(Monitor *m) {
} else { } else {
r = n - i; r = n - i;
if (c->stack_innder_per > 0.0f) { if (c->stack_innder_per > 0.0f) {
h = (m->w.height - 2 * cur_gappov - h = slave_surplus_height * c->stack_innder_per /
cur_gappiv * ie * (stack_num - 1)) * slave_surplus_ratio;
c->stack_innder_per; slave_surplus_height = slave_surplus_height - h;
slave_surplus_ratio = slave_surplus_ratio - c->stack_innder_per;
c->master_mfact_per = mfact; c->master_mfact_per = mfact;
} else { } else {
h = (m->w.height - ty - cur_gappov - h = (m->w.height - ty - cur_gappov -
@@ -733,8 +1029,8 @@ monocle(Monitor *m) {
Client *c = NULL; Client *c = NULL;
struct wlr_box geom; struct wlr_box geom;
unsigned int cur_gappov = enablegaps ? m->gappov : 0; uint32_t cur_gappov = enablegaps ? m->gappov : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
@@ -750,4 +1046,4 @@ monocle(Monitor *m) {
} }
if ((c = focustop(m))) if ((c = focustop(m)))
wlr_scene_node_raise_to_top(&c->scene->node); wlr_scene_node_raise_to_top(&c->scene->node);
} }

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

@@ -1,5 +1,5 @@
void vertical_tile(Monitor *m) { void vertical_tile(Monitor *m) {
unsigned int i, n = 0, w, r, ie = enablegaps, mh, mx, tx; uint32_t i, n = 0, w, r, ie = enablegaps, mh, mx, tx;
Client *c = NULL; Client *c = NULL;
Client *fc = NULL; Client *fc = NULL;
double mfact = 0; double mfact = 0;
@@ -8,15 +8,16 @@ void vertical_tile(Monitor *m) {
n = m->visible_tiling_clients; n = m->visible_tiling_clients;
master_num = m->pertag->nmasters[m->pertag->curtag]; master_num = m->pertag->nmasters[m->pertag->curtag];
master_num = n > master_num ? master_num : n;
stack_num = n - master_num; stack_num = n - master_num;
if (n == 0) if (n == 0)
return; return;
unsigned int cur_gapih = enablegaps ? m->gappih : 0; uint32_t cur_gapih = enablegaps ? m->gappih : 0;
unsigned int cur_gapiv = enablegaps ? m->gappiv : 0; uint32_t cur_gapiv = enablegaps ? m->gappiv : 0;
unsigned int cur_gapoh = enablegaps ? m->gappoh : 0; uint32_t cur_gapoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gapov = enablegaps ? m->gappov : 0; uint32_t cur_gapov = enablegaps ? m->gappov : 0;
cur_gapih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapih; cur_gapih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapih;
cur_gapiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapiv; cur_gapiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapiv;
@@ -40,15 +41,26 @@ void vertical_tile(Monitor *m) {
i = 0; i = 0;
mx = tx = cur_gapih; mx = tx = cur_gapih;
uint32_t master_surplus_width =
(m->w.width - 2 * cur_gapih - cur_gapih * ie * (master_num - 1));
float master_surplus_ratio = 1.0;
uint32_t slave_surplus_width =
(m->w.width - 2 * cur_gapih - cur_gapih * ie * (stack_num - 1));
float slave_surplus_ratio = 1.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) || !ISTILED(c))
continue; continue;
if (i < m->pertag->nmasters[m->pertag->curtag]) { if (i < m->pertag->nmasters[m->pertag->curtag]) {
r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i; r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i;
if (c->master_inner_per > 0.0f) { if (c->master_inner_per > 0.0f) {
w = (m->w.width - 2 * cur_gapih - w = master_surplus_width * c->master_inner_per /
cur_gapih * ie * (master_num - 1)) * master_surplus_ratio;
c->master_inner_per; master_surplus_width = master_surplus_width - w;
master_surplus_ratio =
master_surplus_ratio - c->master_inner_per;
c->master_mfact_per = mfact; c->master_mfact_per = mfact;
} else { } else {
w = (m->w.width - mx - cur_gapih - cur_gapih * ie * (r - 1)) / w = (m->w.width - mx - cur_gapih - cur_gapih * ie * (r - 1)) /
@@ -67,9 +79,10 @@ void vertical_tile(Monitor *m) {
} else { } else {
r = n - i; r = n - i;
if (c->stack_innder_per > 0.0f) { if (c->stack_innder_per > 0.0f) {
w = (m->w.width - 2 * cur_gapih - w = slave_surplus_width * c->stack_innder_per /
cur_gapih * ie * (stack_num - 1)) * slave_surplus_ratio;
c->stack_innder_per; slave_surplus_width = slave_surplus_width - w;
slave_surplus_ratio = slave_surplus_ratio - c->stack_innder_per;
c->master_mfact_per = mfact; c->master_mfact_per = mfact;
} else { } else {
w = (m->w.width - tx - cur_gapih - cur_gapih * ie * (r - 1)) / w = (m->w.width - tx - cur_gapih - cur_gapih * ie * (r - 1)) /
@@ -92,15 +105,15 @@ void vertical_tile(Monitor *m) {
} }
void vertical_deck(Monitor *m) { void vertical_deck(Monitor *m) {
unsigned int mh, mx; uint32_t mh, mx;
int i, n = 0; int i, n = 0;
Client *c = NULL; Client *c = NULL;
Client *fc = NULL; Client *fc = NULL;
float mfact; float mfact;
unsigned int cur_gappiv = enablegaps ? m->gappiv : 0; uint32_t cur_gappiv = enablegaps ? m->gappiv : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; uint32_t cur_gappoh = enablegaps ? m->gappoh : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0; uint32_t cur_gappov = enablegaps ? m->gappov : 0;
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv; cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
@@ -155,25 +168,62 @@ void vertical_deck(Monitor *m) {
} }
} }
void vertical_scroll_adjust_fullandmax(Client *c, struct wlr_box *target_geom) {
Monitor *m = c->mon;
uint32_t cur_gappiv = enablegaps ? m->gappiv : 0;
uint32_t cur_gappov = enablegaps ? m->gappov : 0;
uint32_t 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; uint32_t 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;
int focus_client_index = 0; int focus_client_index = 0;
bool need_scroller = false; bool need_scroller = false;
unsigned int cur_gappiv = enablegaps ? m->gappiv : 0; uint32_t cur_gappiv = enablegaps ? m->gappiv : 0;
unsigned int cur_gappov = enablegaps ? m->gappov : 0; uint32_t cur_gappov = enablegaps ? m->gappov : 0;
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; uint32_t 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 = uint32_t 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 +236,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) && ISSCROLLTILED(m->sel)) {
!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 +276,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 +288,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 +333,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;
@@ -283,10 +354,10 @@ void vertical_scroller(Monitor *m) {
} }
void vertical_grid(Monitor *m) { void vertical_grid(Monitor *m) {
unsigned int i, n; uint32_t i, n;
unsigned int cx, cy, cw, ch; uint32_t cx, cy, cw, ch;
unsigned int dy; uint32_t dy;
unsigned int rows, cols, overrows; uint32_t rows, cols, overrows;
Client *c = NULL; Client *c = NULL;
int target_gappo = enablegaps ? m->isoverview ? overviewgappo : gappov : 0; int target_gappo = enablegaps ? m->isoverview ? overviewgappo : gappov : 0;
int target_gappi = enablegaps ? m->isoverview ? overviewgappi : gappiv : 0; int target_gappi = enablegaps ? m->isoverview ? overviewgappi : gappiv : 0;
@@ -305,10 +376,6 @@ void vertical_grid(Monitor *m) {
if (c->mon != m) if (c->mon != m)
continue; continue;
c->bw = m->visible_tiling_clients == 1 && no_border_when_single &&
smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal && if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) { ((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
ch = (m->w.height - 2 * target_gappo) * single_height_ratio; ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
@@ -332,10 +399,6 @@ void vertical_grid(Monitor *m) {
if (c->mon != m) if (c->mon != m)
continue; continue;
c->bw = m->visible_tiling_clients == 1 && no_border_when_single &&
smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal && if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) { ((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
if (i == 0) { if (i == 0) {
@@ -378,10 +441,6 @@ void vertical_grid(Monitor *m) {
if (c->mon != m) if (c->mon != m)
continue; continue;
c->bw =
m->visible_tiling_clients == 1 && no_border_when_single && smartgaps
? 0
: borderpx;
if (VISIBLEON(c, m) && !c->isunglobal && if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) { ((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
cx = m->w.x + (i / rows) * (cw + target_gappi); cx = m->w.x + (i / rows) * (cw + target_gappi);

File diff suppressed because it is too large Load Diff