Merge branch 'upstream' into minor-backup-of-when-it-worked
59
README.md
|
|
@ -1,6 +1,6 @@
|
||||||
# MangoWC
|
# MangoWC
|
||||||
|
|
||||||
<img width="255" height="256" alt="mango-transparency-256" src="https://github.com/user-attachments/assets/54caff2c-932f-4998-a090-2a5292ebbfa4" />
|
<img width="255" height="256" alt="mango-transparency-256" src="https://github.com/DreamMaoMao/mangowc/blob/main/assets/mango-transparency-256.png" />
|
||||||
|
|
||||||
|
|
||||||
This project's development is based on [dwl](https://codeberg.org/dwl/dwl/).
|
This project's development is based on [dwl](https://codeberg.org/dwl/dwl/).
|
||||||
|
|
@ -32,11 +32,14 @@ Scroller Layout
|
||||||
|
|
||||||
https://github.com/user-attachments/assets/c9bf9415-fad1-4400-bcdc-3ad2d76de85a
|
https://github.com/user-attachments/assets/c9bf9415-fad1-4400-bcdc-3ad2d76de85a
|
||||||
|
|
||||||
Layer animaiton
|
Layer animation
|
||||||
|
|
||||||
https://github.com/user-attachments/assets/014c893f-115c-4ae9-8342-f9ae3e9a0df0
|
https://github.com/user-attachments/assets/014c893f-115c-4ae9-8342-f9ae3e9a0df0
|
||||||
|
|
||||||
|
|
||||||
|
# Our discord
|
||||||
|
[mangowc](https://discord.gg/CPjbDxesh5)
|
||||||
|
|
||||||
# Supported layouts
|
# Supported layouts
|
||||||
|
|
||||||
- tile
|
- tile
|
||||||
|
|
@ -68,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:
|
||||||
|
|
@ -77,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:
|
||||||
|
|
||||||
|
|
@ -95,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
|
||||||
|
|
@ -116,6 +130,10 @@ sudo ninja -C build install
|
||||||
|
|
||||||
## Suggested Tools
|
## Suggested Tools
|
||||||
|
|
||||||
|
### Hybrid component
|
||||||
|
- [dms-shell](https://github.com/AvengeMedia/DankMaterialShell)
|
||||||
|
|
||||||
|
### Independent component
|
||||||
- Application launcher (rofi, bemenu, wmenu, fuzzel)
|
- Application launcher (rofi, bemenu, wmenu, fuzzel)
|
||||||
- Terminal emulator (foot, wezterm, alacritty, kitty, ghostty)
|
- Terminal emulator (foot, wezterm, alacritty, kitty, ghostty)
|
||||||
- Status bar (waybar, eww, quickshell, ags), waybar is preferred
|
- Status bar (waybar, eww, quickshell, ags), waybar is preferred
|
||||||
|
|
@ -136,13 +154,25 @@ sudo ninja -C build install
|
||||||
|
|
||||||
## My Dotfiles
|
## My Dotfiles
|
||||||
|
|
||||||
|
### Daily
|
||||||
- Dependencies
|
- Dependencies
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yay -S rofi foot xdg-desktop-portal-wlr swaybg waybar wl-clip-persist cliphist wl-clipboard wlsunset xfce-polkit swaync pamixer wlr-dpms sway-audio-idle-inhibit-git swayidle dimland-git brightnessctl swayosd wlr-randr grim slurp satty swaylock-effects-git wlogout sox
|
yay -S rofi foot xdg-desktop-portal-wlr swaybg waybar wl-clip-persist cliphist wl-clipboard wlsunset xfce-polkit swaync pamixer wlr-dpms sway-audio-idle-inhibit-git swayidle dimland-git brightnessctl swayosd wlr-randr grim slurp satty swaylock-effects-git wlogout sox
|
||||||
```
|
```
|
||||||
|
|
||||||
- use my config
|
### Dms
|
||||||
|
- Dependencies
|
||||||
|
```bash
|
||||||
|
yay -S foot xdg-desktop-portal-wlr swaybg wl-clip-persist cliphist wl-clipboard sway-audio-idle-inhibit-git brightnessctl grim slurp satty matugen-bin dms-shell-git
|
||||||
|
|
||||||
|
```
|
||||||
|
- use my dms config
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone -b dms https://github.com/DreamMaoMao/mango-config.git ~/.config/mango
|
||||||
|
```
|
||||||
|
- use my daily config
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/DreamMaoMao/mango-config.git ~/.config/mango
|
git clone https://github.com/DreamMaoMao/mango-config.git ~/.config/mango
|
||||||
|
|
@ -151,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
|
||||||
|
|
||||||
|
|
@ -170,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, ... }:
|
||||||
|
|
@ -226,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!
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
# 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:
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 8 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 128 KiB |
BIN
assets/mango.png
|
Before Width: | Height: | Size: 290 KiB After Width: | Height: | Size: 39 KiB |
16
config.conf
|
|
@ -42,10 +42,14 @@ animation_duration_move=500
|
||||||
animation_duration_open=400
|
animation_duration_open=400
|
||||||
animation_duration_tag=350
|
animation_duration_tag=350
|
||||||
animation_duration_close=800
|
animation_duration_close=800
|
||||||
|
animation_duration_focus=0
|
||||||
animation_curve_open=0.46,1.0,0.29,1
|
animation_curve_open=0.46,1.0,0.29,1
|
||||||
animation_curve_move=0.46,1.0,0.29,1
|
animation_curve_move=0.46,1.0,0.29,1
|
||||||
animation_curve_tag=0.46,1.0,0.29,1
|
animation_curve_tag=0.46,1.0,0.29,1
|
||||||
animation_curve_close=0.08,0.92,0,1
|
animation_curve_close=0.08,0.92,0,1
|
||||||
|
animation_curve_focus=0.46,1.0,0.29,1
|
||||||
|
animation_curve_opafadeout=0.5,0.5,0.5,0.5
|
||||||
|
animation_curve_opafadein=0.46,1.0,0.29,1
|
||||||
|
|
||||||
# Scroller Layout Setting
|
# Scroller Layout Setting
|
||||||
scroller_structs=20
|
scroller_structs=20
|
||||||
|
|
@ -73,7 +77,7 @@ overviewgappo=30
|
||||||
no_border_when_single=0
|
no_border_when_single=0
|
||||||
axis_bind_apply_timeout=100
|
axis_bind_apply_timeout=100
|
||||||
focus_on_activate=1
|
focus_on_activate=1
|
||||||
inhibit_regardless_of_visibility=0
|
idleinhibit_ignore_visible=0
|
||||||
sloppyfocus=1
|
sloppyfocus=1
|
||||||
warpcursor=1
|
warpcursor=1
|
||||||
focus_cross_monitor=0
|
focus_cross_monitor=0
|
||||||
|
|
@ -86,7 +90,7 @@ drag_tile_to_tile=1
|
||||||
# keyboard
|
# keyboard
|
||||||
repeat_rate=25
|
repeat_rate=25
|
||||||
repeat_delay=600
|
repeat_delay=600
|
||||||
numlockon=1
|
numlockon=0
|
||||||
xkb_rules_layout=us
|
xkb_rules_layout=us
|
||||||
|
|
||||||
# Trackpad
|
# Trackpad
|
||||||
|
|
@ -116,7 +120,7 @@ borderpx=4
|
||||||
rootcolor=0x201b14ff
|
rootcolor=0x201b14ff
|
||||||
bordercolor=0x444444ff
|
bordercolor=0x444444ff
|
||||||
focuscolor=0xc9b890ff
|
focuscolor=0xc9b890ff
|
||||||
maxmizescreencolor=0x89aa61ff
|
maximizescreencolor=0x89aa61ff
|
||||||
urgentcolor=0xad401fff
|
urgentcolor=0xad401fff
|
||||||
scratchpadcolor=0x516c93ff
|
scratchpadcolor=0x516c93ff
|
||||||
globalcolor=0xb153a7ff
|
globalcolor=0xb153a7ff
|
||||||
|
|
@ -166,7 +170,7 @@ bind=SUPER+SHIFT,Right,exchange_client,right
|
||||||
bind=SUPER,g,toggleglobal,
|
bind=SUPER,g,toggleglobal,
|
||||||
bind=ALT,Tab,toggleoverview,
|
bind=ALT,Tab,toggleoverview,
|
||||||
bind=ALT,backslash,togglefloating,
|
bind=ALT,backslash,togglefloating,
|
||||||
bind=ALT,a,togglemaxmizescreen,
|
bind=ALT,a,togglemaximizescreen,
|
||||||
bind=ALT,f,togglefullscreen,
|
bind=ALT,f,togglefullscreen,
|
||||||
bind=ALT+SHIFT,f,togglefakefullscreen,
|
bind=ALT+SHIFT,f,togglefakefullscreen,
|
||||||
bind=SUPER,i,minimized,
|
bind=SUPER,i,minimized,
|
||||||
|
|
@ -238,9 +242,9 @@ bind=CTRL+ALT,Right,resizewin,+50,+0
|
||||||
# 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
|
||||||
mousebind=NONE,btn_middle,togglemaxmizescreen,0
|
mousebind=NONE,btn_middle,togglemaximizescreen,0
|
||||||
mousebind=SUPER,btn_right,moveresize,curresize
|
mousebind=SUPER,btn_right,moveresize,curresize
|
||||||
mousebind=NONE,btn_left,toggleoverview,-1
|
mousebind=NONE,btn_left,toggleoverview,1
|
||||||
mousebind=NONE,btn_right,killclient,0
|
mousebind=NONE,btn_right,killclient,0
|
||||||
|
|
||||||
# Axis Bindings
|
# Axis Bindings
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
}: let
|
}: let
|
||||||
inherit (pkgs) callPackage ;
|
inherit (pkgs) callPackage ;
|
||||||
mango = callPackage ./nix {
|
mango = callPackage ./nix {
|
||||||
inherit (inputs.scenefx.packages.${pkgs.system}) scenefx;
|
inherit (inputs.scenefx.packages.${pkgs.stdenv.hostPlatform.system}) scenefx;
|
||||||
};
|
};
|
||||||
shellOverride = old: {
|
shellOverride = old: {
|
||||||
nativeBuildInputs = old.nativeBuildInputs ++ [];
|
nativeBuildInputs = old.nativeBuildInputs ++ [];
|
||||||
|
|
|
||||||
64
mangowc.scm
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
(define-module (mangowc)
|
||||||
|
#:use-module (guix download)
|
||||||
|
#:use-module (guix git-download)
|
||||||
|
#:use-module (guix gexp)
|
||||||
|
#:use-module (guix packages)
|
||||||
|
#:use-module (guix utils)
|
||||||
|
#:use-module (gnu packages wm)
|
||||||
|
#:use-module (gnu packages freedesktop)
|
||||||
|
#:use-module (gnu packages xdisorg)
|
||||||
|
#:use-module (gnu packages pciutils)
|
||||||
|
#:use-module (gnu packages admin)
|
||||||
|
#:use-module (gnu packages pcre)
|
||||||
|
#:use-module (gnu packages xorg)
|
||||||
|
#:use-module (gnu packages build-tools)
|
||||||
|
#:use-module (gnu packages ninja)
|
||||||
|
#:use-module (gnu packages pkg-config)
|
||||||
|
#:use-module (guix build-system meson)
|
||||||
|
#:use-module (guix licenses))
|
||||||
|
|
||||||
|
|
||||||
|
(define-public mangowc-git
|
||||||
|
(package
|
||||||
|
(name "mangowc")
|
||||||
|
(version "git")
|
||||||
|
(source (local-file "." "mangowc-checkout"
|
||||||
|
#:recursive? #t
|
||||||
|
#:select? (or (git-predicate (current-source-directory))
|
||||||
|
(const #t))))
|
||||||
|
(build-system meson-build-system)
|
||||||
|
(arguments
|
||||||
|
(list
|
||||||
|
#:configure-flags
|
||||||
|
#~(list (string-append "-Dsysconfdir=" #$output "/etc"))
|
||||||
|
#:phases
|
||||||
|
#~(modify-phases %standard-phases
|
||||||
|
(add-before 'configure 'patch-meson
|
||||||
|
(lambda _
|
||||||
|
(substitute* "meson.build"
|
||||||
|
(("'-DSYSCONFDIR=\\\"@0@\\\"'.format\\('/etc'\\)")
|
||||||
|
"'-DSYSCONFDIR=\"@0@\"'.format(sysconfdir)")
|
||||||
|
(("sysconfdir = sysconfdir.substring\\(prefix.length\\(\\)\\)")
|
||||||
|
"")))))))
|
||||||
|
(inputs (list wayland
|
||||||
|
libinput
|
||||||
|
libdrm
|
||||||
|
libxkbcommon
|
||||||
|
pixman
|
||||||
|
libdisplay-info
|
||||||
|
libliftoff
|
||||||
|
hwdata
|
||||||
|
seatd
|
||||||
|
pcre2
|
||||||
|
libxcb
|
||||||
|
xcb-util-wm
|
||||||
|
wlroots
|
||||||
|
scenefx))
|
||||||
|
(native-inputs (list pkg-config wayland-protocols))
|
||||||
|
(home-page "https://github.com/DreamMaoMao/mangowc")
|
||||||
|
(synopsis "Wayland compositor based on wlroots and scenefx")
|
||||||
|
(description "A Wayland compositor based on wlroots and scenefx,
|
||||||
|
inspired by dwl but aiming to be more feature-rich.")
|
||||||
|
(license gpl3)))
|
||||||
|
|
||||||
|
mangowc-git
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
project('mango', ['c', 'cpp'],
|
project('mango', ['c', 'cpp'],
|
||||||
version : '0.10.2',
|
version : '0.10.8',
|
||||||
)
|
)
|
||||||
|
|
||||||
subdir('protocols')
|
subdir('protocols')
|
||||||
|
|
@ -32,10 +32,10 @@ cc = meson.get_compiler('c')
|
||||||
libm = cc.find_library('m')
|
libm = cc.find_library('m')
|
||||||
xcb = dependency('xcb', required : get_option('xwayland'))
|
xcb = dependency('xcb', required : get_option('xwayland'))
|
||||||
xlibs = dependency('xcb-icccm', required : get_option('xwayland'))
|
xlibs = dependency('xcb-icccm', required : get_option('xwayland'))
|
||||||
wayland_server_dep = dependency('wayland-server')
|
wayland_server_dep = dependency('wayland-server',version: '>=1.23.1')
|
||||||
wlroots_dep = dependency('wlroots-0.19',version: '>=0.19.0')
|
wlroots_dep = dependency('wlroots-0.19',version: '>=0.19.0')
|
||||||
xkbcommon_dep = dependency('xkbcommon')
|
xkbcommon_dep = dependency('xkbcommon')
|
||||||
libinput_dep = dependency('libinput')
|
libinput_dep = dependency('libinput',version: '>=1.27.1')
|
||||||
libwayland_client_dep = dependency('wayland-client')
|
libwayland_client_dep = dependency('wayland-client')
|
||||||
pcre2_dep = dependency('libpcre2-8')
|
pcre2_dep = dependency('libpcre2-8')
|
||||||
libscenefx_dep = dependency('scenefx-0.4',version: '>=0.4.1')
|
libscenefx_dep = dependency('scenefx-0.4',version: '>=0.4.1')
|
||||||
|
|
|
||||||
31
mmsg/mmsg.c
|
|
@ -6,6 +6,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-util.h>
|
#include <wayland-util.h>
|
||||||
|
|
||||||
|
|
@ -40,6 +41,7 @@ static int xflag;
|
||||||
static int eflag;
|
static int eflag;
|
||||||
static int kflag;
|
static int kflag;
|
||||||
static int bflag;
|
static int bflag;
|
||||||
|
static int Aflag;
|
||||||
|
|
||||||
static uint32_t occ, seltags, total_clients, urg;
|
static uint32_t occ, seltags, total_clients, urg;
|
||||||
|
|
||||||
|
|
@ -84,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';
|
||||||
}
|
}
|
||||||
|
|
@ -263,6 +265,18 @@ static void dwl_ipc_output_kb_layout(void *data,
|
||||||
printf("kb_layout %s\n", kb_layout);
|
printf("kb_layout %s\n", kb_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dwl_ipc_output_scalefactor(void *data,
|
||||||
|
struct zdwl_ipc_output_v2 *dwl_ipc_output,
|
||||||
|
const uint32_t scalefactor) {
|
||||||
|
if (!Aflag)
|
||||||
|
return;
|
||||||
|
char *output_name = data;
|
||||||
|
if (output_name)
|
||||||
|
printf("%s ", output_name);
|
||||||
|
printf("scale_factor %f\n", scalefactor / 100.0f);
|
||||||
|
}
|
||||||
|
|
||||||
static void dwl_ipc_output_keymode(void *data,
|
static void dwl_ipc_output_keymode(void *data,
|
||||||
struct zdwl_ipc_output_v2 *dwl_ipc_output,
|
struct zdwl_ipc_output_v2 *dwl_ipc_output,
|
||||||
const char *keymode) {
|
const char *keymode) {
|
||||||
|
|
@ -373,6 +387,7 @@ static void dwl_ipc_output_frame(void *data,
|
||||||
dispatch_arg3, dispatch_arg4, dispatch_arg5);
|
dispatch_arg3, dispatch_arg4, dispatch_arg5);
|
||||||
}
|
}
|
||||||
wl_display_flush(display);
|
wl_display_flush(display);
|
||||||
|
usleep(1000);
|
||||||
exit(0);
|
exit(0);
|
||||||
} else {
|
} else {
|
||||||
if (tflag) {
|
if (tflag) {
|
||||||
|
|
@ -411,6 +426,7 @@ static const struct zdwl_ipc_output_v2_listener dwl_ipc_output_listener = {
|
||||||
.last_layer = dwl_ipc_output_last_layer,
|
.last_layer = dwl_ipc_output_last_layer,
|
||||||
.kb_layout = dwl_ipc_output_kb_layout,
|
.kb_layout = dwl_ipc_output_kb_layout,
|
||||||
.keymode = dwl_ipc_output_keymode,
|
.keymode = dwl_ipc_output_keymode,
|
||||||
|
.scalefactor = dwl_ipc_output_scalefactor,
|
||||||
.frame = dwl_ipc_output_frame,
|
.frame = dwl_ipc_output_frame,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -488,7 +504,7 @@ static void usage(void) {
|
||||||
"\t%s [-OTLq]\n"
|
"\t%s [-OTLq]\n"
|
||||||
"\t%s [-o <output>] -s [-t <tags>] [-l <layout>] [-c <tags>] [-d "
|
"\t%s [-o <output>] -s [-t <tags>] [-l <layout>] [-c <tags>] [-d "
|
||||||
"<cmd>,<arg1>,<arg2>,<arg3>,<arg4>,<arg5>]\n"
|
"<cmd>,<arg1>,<arg2>,<arg3>,<arg4>,<arg5>]\n"
|
||||||
"\t%s [-o <output>] (-g | -w) [-Ootlcvmfxekb]\n",
|
"\t%s [-o <output>] (-g | -w) [-OotlcvmfxekbA]\n",
|
||||||
argv0, argv0, argv0);
|
argv0, argv0, argv0);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
@ -730,6 +746,12 @@ int main(int argc, char *argv[]) {
|
||||||
usage();
|
usage();
|
||||||
mode |= GET;
|
mode |= GET;
|
||||||
break;
|
break;
|
||||||
|
case 'A':
|
||||||
|
Aflag = 1;
|
||||||
|
if (mode == SET)
|
||||||
|
usage();
|
||||||
|
mode |= GET;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "bad option %c\n", ARGC());
|
fprintf(stderr, "bad option %c\n", ARGC());
|
||||||
usage();
|
usage();
|
||||||
|
|
@ -739,9 +761,10 @@ int main(int argc, char *argv[]) {
|
||||||
usage();
|
usage();
|
||||||
if (mode & GET && !output_name &&
|
if (mode & GET && !output_name &&
|
||||||
!(oflag || tflag || lflag || Oflag || Tflag || Lflag || cflag ||
|
!(oflag || tflag || lflag || Oflag || Tflag || Lflag || cflag ||
|
||||||
vflag || mflag || fflag || xflag || eflag || kflag || bflag || dflag))
|
vflag || mflag || fflag || xflag || eflag || kflag || bflag ||
|
||||||
|
Aflag || dflag))
|
||||||
oflag = tflag = lflag = cflag = vflag = mflag = fflag = xflag = eflag =
|
oflag = tflag = lflag = cflag = vflag = mflag = fflag = xflag = eflag =
|
||||||
kflag = bflag = 1;
|
kflag = bflag = Aflag = 1;
|
||||||
|
|
||||||
display = wl_display_connect(NULL);
|
display = wl_display_connect(NULL);
|
||||||
if (!display)
|
if (!display)
|
||||||
|
|
|
||||||
|
|
@ -13,60 +13,64 @@
|
||||||
wayland-scanner,
|
wayland-scanner,
|
||||||
xcbutilwm,
|
xcbutilwm,
|
||||||
xwayland,
|
xwayland,
|
||||||
enableXWayland ? true,
|
|
||||||
meson,
|
meson,
|
||||||
ninja,
|
ninja,
|
||||||
scenefx,
|
scenefx,
|
||||||
wlroots_0_19,
|
wlroots_0_19,
|
||||||
libGL,
|
libGL,
|
||||||
}: let
|
enableXWayland ? true,
|
||||||
|
debug ? false,
|
||||||
|
}:
|
||||||
|
stdenv.mkDerivation {
|
||||||
pname = "mango";
|
pname = "mango";
|
||||||
in
|
version = "nightly";
|
||||||
stdenv.mkDerivation {
|
|
||||||
inherit pname;
|
|
||||||
version = "nightly";
|
|
||||||
|
|
||||||
src = builtins.path {
|
src = builtins.path {
|
||||||
path = ../.;
|
path = ../.;
|
||||||
name = "source";
|
name = "source";
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [
|
mesonFlags = [
|
||||||
meson
|
(lib.mesonEnable "xwayland" enableXWayland)
|
||||||
ninja
|
(lib.mesonBool "asan" debug)
|
||||||
pkg-config
|
];
|
||||||
wayland-scanner
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
meson
|
||||||
|
ninja
|
||||||
|
pkg-config
|
||||||
|
wayland-scanner
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs =
|
||||||
|
[
|
||||||
|
libinput
|
||||||
|
libxcb
|
||||||
|
libxkbcommon
|
||||||
|
pcre2
|
||||||
|
pixman
|
||||||
|
wayland
|
||||||
|
wayland-protocols
|
||||||
|
wlroots_0_19
|
||||||
|
scenefx
|
||||||
|
libGL
|
||||||
|
]
|
||||||
|
++ lib.optionals enableXWayland [
|
||||||
|
libX11
|
||||||
|
xcbutilwm
|
||||||
|
xwayland
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs =
|
passthru = {
|
||||||
[
|
providedSessions = ["mango"];
|
||||||
libinput
|
};
|
||||||
libxcb
|
|
||||||
libxkbcommon
|
|
||||||
pcre2
|
|
||||||
pixman
|
|
||||||
wayland
|
|
||||||
wayland-protocols
|
|
||||||
wlroots_0_19
|
|
||||||
scenefx
|
|
||||||
libGL
|
|
||||||
]
|
|
||||||
++ lib.optionals enableXWayland [
|
|
||||||
libX11
|
|
||||||
xcbutilwm
|
|
||||||
xwayland
|
|
||||||
];
|
|
||||||
|
|
||||||
passthru = {
|
meta = {
|
||||||
providedSessions = ["mango"];
|
mainProgram = "mango";
|
||||||
};
|
description = "A streamlined but feature-rich Wayland compositor";
|
||||||
|
homepage = "https://github.com/DreamMaoMao/mango";
|
||||||
meta = {
|
license = lib.licenses.gpl3Plus;
|
||||||
mainProgram = "mango";
|
maintainers = [];
|
||||||
description = "A streamlined but feature-rich Wayland compositor";
|
platforms = lib.platforms.unix;
|
||||||
homepage = "https://github.com/DreamMaoMao/mango";
|
};
|
||||||
license = lib.licenses.gpl3Plus;
|
}
|
||||||
maintainers = [];
|
|
||||||
platforms = lib.platforms.unix;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ in {
|
||||||
};
|
};
|
||||||
package = lib.mkOption {
|
package = lib.mkOption {
|
||||||
type = lib.types.package;
|
type = lib.types.package;
|
||||||
default = self.packages.${pkgs.system}.mango;
|
default = self.packages.${pkgs.stdenv.hostPlatform.system}.mango;
|
||||||
description = "The mango package to use";
|
description = "The mango package to use";
|
||||||
};
|
};
|
||||||
systemd = {
|
systemd = {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ in {
|
||||||
enable = lib.mkEnableOption "mango, a wayland compositor based on dwl";
|
enable = lib.mkEnableOption "mango, a wayland compositor based on dwl";
|
||||||
package = lib.mkOption {
|
package = lib.mkOption {
|
||||||
type = lib.types.package;
|
type = lib.types.package;
|
||||||
default = self.packages.${pkgs.system}.mango;
|
default = self.packages.${pkgs.stdenv.hostPlatform.system}.mango;
|
||||||
description = "The mango package to use";
|
description = "The mango package to use";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -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];
|
||||||
|
|
|
||||||
|
|
@ -241,6 +241,13 @@ I would probably just submit raphi's patchset but I don't think that would be po
|
||||||
<arg name="keymode" type="string" summary="current keybind mode."/>
|
<arg name="keymode" type="string" summary="current keybind mode."/>
|
||||||
</event>
|
</event>
|
||||||
|
|
||||||
|
<event name="scalefactor" since="2">
|
||||||
|
<description summary="scale factor of monitor.">
|
||||||
|
scale factor of monitor.
|
||||||
|
</description>
|
||||||
|
<arg name="scalefactor" type="uint" summary="scale factor of monitor."/>
|
||||||
|
</event>
|
||||||
|
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
</protocol>
|
</protocol>
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ wayland_xmls = [
|
||||||
wl_protocol_dir + '/staging/ext-image-capture-source/ext-image-capture-source-v1.xml',
|
wl_protocol_dir + '/staging/ext-image-capture-source/ext-image-capture-source-v1.xml',
|
||||||
wl_protocol_dir + '/staging/ext-foreign-toplevel-list/ext-foreign-toplevel-list-v1.xml',
|
wl_protocol_dir + '/staging/ext-foreign-toplevel-list/ext-foreign-toplevel-list-v1.xml',
|
||||||
wl_protocol_dir + '/staging/ext-workspace/ext-workspace-v1.xml',
|
wl_protocol_dir + '/staging/ext-workspace/ext-workspace-v1.xml',
|
||||||
|
wl_protocol_dir + '/staging/tearing-control/tearing-control-v1.xml',
|
||||||
'wlr-foreign-toplevel-management-unstable-v1.xml',
|
'wlr-foreign-toplevel-management-unstable-v1.xml',
|
||||||
'dwl-ipc-unstable-v2.xml',
|
'dwl-ipc-unstable-v2.xml',
|
||||||
'wlr-layer-shell-unstable-v1.xml',
|
'wlr-layer-shell-unstable-v1.xml',
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -225,12 +225,6 @@ void scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, int sy,
|
||||||
|
|
||||||
wlr_scene_buffer_set_corner_radius(buffer, border_radius,
|
wlr_scene_buffer_set_corner_radius(buffer, border_radius,
|
||||||
buffer_data->corner_location);
|
buffer_data->corner_location);
|
||||||
|
|
||||||
float target_opacity = buffer_data->percent + fadein_begin_opacity;
|
|
||||||
if (target_opacity > buffer_data->opacity) {
|
|
||||||
target_opacity = buffer_data->opacity;
|
|
||||||
}
|
|
||||||
wlr_scene_buffer_set_opacity(buffer, target_opacity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void buffer_set_effect(Client *c, BufferData data) {
|
void buffer_set_effect(Client *c, BufferData data) {
|
||||||
|
|
@ -246,8 +240,9 @@ void buffer_set_effect(Client *c, BufferData data) {
|
||||||
if (c == grabc)
|
if (c == grabc)
|
||||||
data.should_scale = false;
|
data.should_scale = false;
|
||||||
|
|
||||||
if (c->isfullscreen || (no_radius_when_single && c->mon &&
|
if (c->isnoradius || c->isfullscreen ||
|
||||||
c->mon->visible_tiling_clients == 1)) {
|
(no_radius_when_single && c->mon &&
|
||||||
|
c->mon->visible_tiling_clients == 1)) {
|
||||||
data.corner_location = CORNER_LOCATION_NONE;
|
data.corner_location = CORNER_LOCATION_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,12 +252,16 @@ void buffer_set_effect(Client *c, BufferData data) {
|
||||||
|
|
||||||
void client_draw_shadow(Client *c) {
|
void client_draw_shadow(Client *c) {
|
||||||
|
|
||||||
if (c->iskilling || !client_surface(c)->mapped)
|
if (c->iskilling || !client_surface(c)->mapped || c->isnoshadow)
|
||||||
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);
|
||||||
|
|
@ -272,7 +271,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);
|
||||||
|
|
@ -356,11 +355,13 @@ void apply_border(Client *c) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool hit_no_border = check_hit_no_border(c);
|
bool hit_no_border = check_hit_no_border(c);
|
||||||
enum corner_location current_corner_location =
|
enum corner_location current_corner_location;
|
||||||
c->isfullscreen || (no_radius_when_single && c->mon &&
|
if (c->isfullscreen || (no_radius_when_single && c->mon &&
|
||||||
c->mon->visible_tiling_clients == 1)
|
c->mon->visible_tiling_clients == 1)) {
|
||||||
? CORNER_LOCATION_NONE
|
current_corner_location = CORNER_LOCATION_NONE;
|
||||||
: CORNER_LOCATION_ALL;
|
} else {
|
||||||
|
current_corner_location = set_client_corner_location(c);
|
||||||
|
}
|
||||||
|
|
||||||
// Handle no-border cases
|
// Handle no-border cases
|
||||||
if (hit_no_border && smartgaps) {
|
if (hit_no_border && smartgaps) {
|
||||||
|
|
@ -448,7 +449,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;
|
||||||
|
|
||||||
|
|
@ -469,7 +470,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);
|
||||||
|
|
@ -497,7 +498,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)) {
|
||||||
|
|
@ -517,7 +518,6 @@ void client_apply_clip(Client *c, float factor) {
|
||||||
bool should_render_client_surface = false;
|
bool should_render_client_surface = false;
|
||||||
struct ivec2 offset;
|
struct ivec2 offset;
|
||||||
BufferData buffer_data;
|
BufferData buffer_data;
|
||||||
float opacity, percent;
|
|
||||||
|
|
||||||
enum corner_location current_corner_location =
|
enum corner_location current_corner_location =
|
||||||
set_client_corner_location(c);
|
set_client_corner_location(c);
|
||||||
|
|
@ -537,31 +537,19 @@ void client_apply_clip(Client *c, float factor) {
|
||||||
apply_border(c);
|
apply_border(c);
|
||||||
client_draw_shadow(c);
|
client_draw_shadow(c);
|
||||||
|
|
||||||
opacity = c->isfullscreen ? 1
|
|
||||||
: c == selmon->sel ? c->focused_opacity
|
|
||||||
: c->unfocused_opacity;
|
|
||||||
|
|
||||||
if (clip_box.width <= 0 || clip_box.height <= 0) {
|
if (clip_box.width <= 0 || clip_box.height <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box);
|
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box);
|
||||||
buffer_set_effect(c, (BufferData){1.0f, 1.0f, clip_box.width,
|
buffer_set_effect(c, (BufferData){1.0f, 1.0f, clip_box.width,
|
||||||
clip_box.height, opacity, opacity,
|
clip_box.height,
|
||||||
current_corner_location, true});
|
current_corner_location, true});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
percent =
|
|
||||||
c->animation.action == OPEN && animation_fade_in && !c->nofadein
|
|
||||||
? (double)c->animation.passed_frames / c->animation.total_frames
|
|
||||||
: 1.0;
|
|
||||||
opacity = c->isfullscreen ? 1
|
|
||||||
: c == selmon->sel ? c->focused_opacity
|
|
||||||
: c->unfocused_opacity;
|
|
||||||
|
|
||||||
// 获取窗口动画实时位置矩形
|
// 获取窗口动画实时位置矩形
|
||||||
unsigned int width, height;
|
uint32_t width, height;
|
||||||
client_actual_size(c, &width, &height);
|
client_actual_size(c, &width, &height);
|
||||||
|
|
||||||
// 计算出除了边框的窗口实际剪切大小
|
// 计算出除了边框的窗口实际剪切大小
|
||||||
|
|
@ -614,8 +602,6 @@ void client_apply_clip(Client *c, float factor) {
|
||||||
buffer_data.width = clip_box.width;
|
buffer_data.width = clip_box.width;
|
||||||
buffer_data.height = clip_box.height;
|
buffer_data.height = clip_box.height;
|
||||||
buffer_data.corner_location = current_corner_location;
|
buffer_data.corner_location = current_corner_location;
|
||||||
buffer_data.percent = percent;
|
|
||||||
buffer_data.opacity = opacity;
|
|
||||||
|
|
||||||
if (factor == 1.0) {
|
if (factor == 1.0) {
|
||||||
buffer_data.width_scale = 1.0;
|
buffer_data.width_scale = 1.0;
|
||||||
|
|
@ -636,23 +622,28 @@ void fadeout_client_animation_next_tick(Client *c) {
|
||||||
|
|
||||||
BufferData buffer_data;
|
BufferData buffer_data;
|
||||||
|
|
||||||
|
struct timespec now;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
uint32_t passed_time = timespec_to_ms(&now) - c->animation.time_started;
|
||||||
double animation_passed =
|
double animation_passed =
|
||||||
c->animation.total_frames
|
c->animation.duration
|
||||||
? (double)c->animation.passed_frames / c->animation.total_frames
|
? (double)passed_time / (double)c->animation.duration
|
||||||
: 1.0;
|
: 1.0;
|
||||||
|
|
||||||
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 =
|
|
||||||
c->animation.initial.width +
|
uint32_t width = c->animation.initial.width +
|
||||||
(c->current.width - c->animation.initial.width) * factor;
|
(c->current.width - c->animation.initial.width) * factor;
|
||||||
unsigned int height =
|
uint32_t 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);
|
||||||
|
|
||||||
|
|
@ -663,7 +654,13 @@ void fadeout_client_animation_next_tick(Client *c) {
|
||||||
.height = height,
|
.height = height,
|
||||||
};
|
};
|
||||||
|
|
||||||
double opacity = MAX(fadeout_begin_opacity - animation_passed, 0);
|
double opacity_eased_progress =
|
||||||
|
find_animation_curve_at(animation_passed, OPAFADEOUT);
|
||||||
|
|
||||||
|
double percent = fadeout_begin_opacity -
|
||||||
|
(opacity_eased_progress * fadeout_begin_opacity);
|
||||||
|
|
||||||
|
double opacity = MAX(percent, 0);
|
||||||
|
|
||||||
if (animation_fade_out && !c->nofadeout)
|
if (animation_fade_out && !c->nofadeout)
|
||||||
wlr_scene_node_for_each_buffer(&c->scene->node,
|
wlr_scene_node_for_each_buffer(&c->scene->node,
|
||||||
|
|
@ -683,20 +680,22 @@ void fadeout_client_animation_next_tick(Client *c) {
|
||||||
&c->scene->node, snap_scene_buffer_apply_effect, &buffer_data);
|
&c->scene->node, snap_scene_buffer_apply_effect, &buffer_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (animation_passed == 1.0) {
|
if (animation_passed >= 1.0) {
|
||||||
wl_list_remove(&c->fadeout_link);
|
wl_list_remove(&c->fadeout_link);
|
||||||
wlr_scene_node_destroy(&c->scene->node);
|
wlr_scene_node_destroy(&c->scene->node);
|
||||||
free(c);
|
free(c);
|
||||||
c = NULL;
|
c = NULL;
|
||||||
} else {
|
|
||||||
c->animation.passed_frames++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void client_animation_next_tick(Client *c) {
|
void client_animation_next_tick(Client *c) {
|
||||||
|
struct timespec now;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
uint32_t passed_time = timespec_to_ms(&now) - c->animation.time_started;
|
||||||
double animation_passed =
|
double animation_passed =
|
||||||
c->animation.total_frames
|
c->animation.duration
|
||||||
? (double)c->animation.passed_frames / c->animation.total_frames
|
? (double)passed_time / (double)c->animation.duration
|
||||||
: 1.0;
|
: 1.0;
|
||||||
|
|
||||||
int type = c->animation.action == NONE ? MOVE : c->animation.action;
|
int type = c->animation.action == NONE ? MOVE : c->animation.action;
|
||||||
|
|
@ -706,17 +705,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 +
|
int32_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 +
|
int32_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){
|
||||||
|
|
@ -728,7 +726,7 @@ void client_animation_next_tick(Client *c) {
|
||||||
|
|
||||||
c->is_pending_open_animation = false;
|
c->is_pending_open_animation = false;
|
||||||
|
|
||||||
if (animation_passed == 1.0) {
|
if (animation_passed >= 1.0) {
|
||||||
|
|
||||||
// clear the open action state
|
// clear the open action state
|
||||||
// To prevent him from being mistaken that
|
// To prevent him from being mistaken that
|
||||||
|
|
@ -756,8 +754,6 @@ void client_animation_next_tick(Client *c) {
|
||||||
|
|
||||||
// end flush in next frame, not the current frame
|
// end flush in next frame, not the current frame
|
||||||
c->need_output_flush = false;
|
c->need_output_flush = false;
|
||||||
} else {
|
|
||||||
c->animation.passed_frames++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
client_apply_clip(c, factor);
|
client_apply_clip(c, factor);
|
||||||
|
|
@ -841,14 +837,12 @@ void init_fadeout_client(Client *c) {
|
||||||
fadeout_cient->geom.height * zoom_end_ratio;
|
fadeout_cient->geom.height * zoom_end_ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
fadeout_cient->animation.passed_frames = 0;
|
fadeout_cient->animation.time_started = get_now_in_ms();
|
||||||
fadeout_cient->animation.total_frames =
|
|
||||||
fadeout_cient->animation.duration / all_output_frame_duration_ms();
|
|
||||||
wlr_scene_node_set_enabled(&fadeout_cient->scene->node, true);
|
wlr_scene_node_set_enabled(&fadeout_cient->scene->node, true);
|
||||||
wl_list_insert(&fadeout_clients, &fadeout_cient->fadeout_link);
|
wl_list_insert(&fadeout_clients, &fadeout_cient->fadeout_link);
|
||||||
|
|
||||||
// 请求刷新屏幕
|
// 请求刷新屏幕
|
||||||
wlr_output_schedule_frame(c->mon->wlr_output);
|
request_fresh_all_monitors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void client_commit(Client *c) {
|
void client_commit(Client *c) {
|
||||||
|
|
@ -860,30 +854,21 @@ void client_commit(Client *c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
c->animation.initial = c->animainit_geom;
|
c->animation.initial = c->animainit_geom;
|
||||||
// 设置动画速度
|
c->animation.time_started = get_now_in_ms();
|
||||||
c->animation.passed_frames = 0;
|
|
||||||
c->animation.total_frames =
|
|
||||||
c->animation.duration / all_output_frame_duration_ms();
|
|
||||||
|
|
||||||
// 标记动画开始
|
// 标记动画开始
|
||||||
c->animation.running = true;
|
c->animation.running = true;
|
||||||
c->animation.should_animate = false;
|
c->animation.should_animate = false;
|
||||||
} else {
|
|
||||||
// 如果动画没有开始,且被判定为不应该动画,
|
|
||||||
// 则设置总帧数为1,不然其他地方一旦获取动画
|
|
||||||
// 进度,总帧数作为分母会造成除零
|
|
||||||
// 比如动画类型为none的时候
|
|
||||||
if (!c->animation.running) {
|
|
||||||
c->animation.passed_frames = 1;
|
|
||||||
c->animation.total_frames = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 请求刷新屏幕
|
// 请求刷新屏幕
|
||||||
wlr_output_schedule_frame(c->mon->wlr_output);
|
request_fresh_all_monitors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void client_set_pending_state(Client *c) {
|
void client_set_pending_state(Client *c) {
|
||||||
|
|
||||||
|
if (!c || c->iskilling)
|
||||||
|
return;
|
||||||
|
|
||||||
// 判断是否需要动画
|
// 判断是否需要动画
|
||||||
if (!animations) {
|
if (!animations) {
|
||||||
c->animation.should_animate = false;
|
c->animation.should_animate = false;
|
||||||
|
|
@ -915,6 +900,11 @@ void client_set_pending_state(Client *c) {
|
||||||
c->animation.duration = 0;
|
c->animation.duration = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c->isnoanimation) {
|
||||||
|
c->animation.should_animate = false;
|
||||||
|
c->animation.duration = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// 开始动画
|
// 开始动画
|
||||||
client_commit(c);
|
client_commit(c);
|
||||||
c->dirty = true;
|
c->dirty = true;
|
||||||
|
|
@ -951,7 +941,7 @@ void resize(Client *c, struct wlr_box geo, int interact) {
|
||||||
bbox); // 去掉这个推荐的窗口大小,因为有时推荐的窗口特别大导致平铺异常
|
bbox); // 去掉这个推荐的窗口大小,因为有时推荐的窗口特别大导致平铺异常
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!c->isnosizehint && !c->ismaxmizescreen && !c->isfullscreen &&
|
if (!c->isnosizehint && !c->ismaximizescreen && !c->isfullscreen &&
|
||||||
c->isfloating) {
|
c->isfloating) {
|
||||||
client_set_size_bound(c);
|
client_set_size_bound(c);
|
||||||
}
|
}
|
||||||
|
|
@ -1048,22 +1038,162 @@ bool client_draw_fadeout_frame(Client *c) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void client_set_focused_opacity_animation(Client *c) {
|
||||||
|
float *border_color = get_border_color(c);
|
||||||
|
|
||||||
|
if (!animations) {
|
||||||
|
setborder_color(c);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
c->opacity_animation.duration = animation_duration_focus;
|
||||||
|
memcpy(c->opacity_animation.target_border_color, border_color,
|
||||||
|
sizeof(c->opacity_animation.target_border_color));
|
||||||
|
c->opacity_animation.target_opacity = c->focused_opacity;
|
||||||
|
c->opacity_animation.time_started = get_now_in_ms();
|
||||||
|
if (c->opacity_animation.running) {
|
||||||
|
memcpy(c->opacity_animation.initial_border_color,
|
||||||
|
c->opacity_animation.current_border_color,
|
||||||
|
sizeof(c->opacity_animation.initial_border_color));
|
||||||
|
c->opacity_animation.initial_opacity =
|
||||||
|
c->opacity_animation.current_opacity;
|
||||||
|
} else {
|
||||||
|
memcpy(c->opacity_animation.initial_border_color, border_color,
|
||||||
|
sizeof(c->opacity_animation.initial_border_color));
|
||||||
|
memcpy(c->opacity_animation.current_border_color, border_color,
|
||||||
|
sizeof(c->opacity_animation.current_border_color));
|
||||||
|
c->opacity_animation.initial_opacity = c->unfocused_opacity;
|
||||||
|
c->opacity_animation.current_opacity = c->unfocused_opacity;
|
||||||
|
}
|
||||||
|
c->opacity_animation.running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void client_set_unfocused_opacity_animation(Client *c) {
|
||||||
|
// Start border color animation to unfocused
|
||||||
|
float *border_color = get_border_color(c);
|
||||||
|
|
||||||
|
if (!animations) {
|
||||||
|
setborder_color(c);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
c->opacity_animation.duration = animation_duration_focus;
|
||||||
|
memcpy(c->opacity_animation.target_border_color, border_color,
|
||||||
|
sizeof(c->opacity_animation.target_border_color));
|
||||||
|
// Start opacity animation to unfocused
|
||||||
|
c->opacity_animation.target_opacity = c->unfocused_opacity;
|
||||||
|
c->opacity_animation.time_started = get_now_in_ms();
|
||||||
|
|
||||||
|
if (c->opacity_animation.running) {
|
||||||
|
memcpy(c->opacity_animation.initial_border_color,
|
||||||
|
c->opacity_animation.current_border_color,
|
||||||
|
sizeof(c->opacity_animation.initial_border_color));
|
||||||
|
c->opacity_animation.initial_opacity =
|
||||||
|
c->opacity_animation.current_opacity;
|
||||||
|
} else {
|
||||||
|
memcpy(c->opacity_animation.initial_border_color, border_color,
|
||||||
|
sizeof(c->opacity_animation.initial_border_color));
|
||||||
|
memcpy(c->opacity_animation.current_border_color, border_color,
|
||||||
|
sizeof(c->opacity_animation.current_border_color));
|
||||||
|
c->opacity_animation.initial_opacity = c->focused_opacity;
|
||||||
|
c->opacity_animation.current_opacity = c->focused_opacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
c->opacity_animation.running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool client_apply_focus_opacity(Client *c) {
|
||||||
|
// Animate focus transitions (opacity + border color)
|
||||||
|
float *border_color = get_border_color(c);
|
||||||
|
if (c->isfullscreen) {
|
||||||
|
c->opacity_animation.running = false;
|
||||||
|
client_set_opacity(c, 1);
|
||||||
|
} else if (c->animation.running && c->animation.action == OPEN) {
|
||||||
|
c->opacity_animation.running = false;
|
||||||
|
struct timespec now;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
uint32_t passed_time = timespec_to_ms(&now) - c->animation.time_started;
|
||||||
|
double linear_progress =
|
||||||
|
c->animation.duration
|
||||||
|
? (double)passed_time / (double)c->animation.duration
|
||||||
|
: 1.0;
|
||||||
|
|
||||||
|
double opacity_eased_progress =
|
||||||
|
find_animation_curve_at(linear_progress, OPAFADEIN);
|
||||||
|
|
||||||
|
float percent =
|
||||||
|
animation_fade_in && !c->nofadein ? opacity_eased_progress : 1.0;
|
||||||
|
float opacity =
|
||||||
|
c == selmon->sel ? c->focused_opacity : c->unfocused_opacity;
|
||||||
|
|
||||||
|
float target_opacity =
|
||||||
|
percent * (1.0 - fadein_begin_opacity) + fadein_begin_opacity;
|
||||||
|
if (target_opacity > opacity) {
|
||||||
|
target_opacity = opacity;
|
||||||
|
}
|
||||||
|
client_set_opacity(c, target_opacity);
|
||||||
|
} else if (animations && c->opacity_animation.running) {
|
||||||
|
|
||||||
|
struct timespec now;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
uint32_t passed_time =
|
||||||
|
timespec_to_ms(&now) - c->opacity_animation.time_started;
|
||||||
|
double linear_progress =
|
||||||
|
c->opacity_animation.duration
|
||||||
|
? (double)passed_time / (double)c->opacity_animation.duration
|
||||||
|
: 1.0;
|
||||||
|
|
||||||
|
float eased_progress = find_animation_curve_at(linear_progress, FOCUS);
|
||||||
|
|
||||||
|
c->opacity_animation.current_opacity =
|
||||||
|
c->opacity_animation.initial_opacity +
|
||||||
|
(c->opacity_animation.target_opacity -
|
||||||
|
c->opacity_animation.initial_opacity) *
|
||||||
|
eased_progress;
|
||||||
|
client_set_opacity(c, c->opacity_animation.current_opacity);
|
||||||
|
|
||||||
|
// Animate border color
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
c->opacity_animation.current_border_color[i] =
|
||||||
|
c->opacity_animation.initial_border_color[i] +
|
||||||
|
(c->opacity_animation.target_border_color[i] -
|
||||||
|
c->opacity_animation.initial_border_color[i]) *
|
||||||
|
eased_progress;
|
||||||
|
}
|
||||||
|
client_set_border_color(c, c->opacity_animation.current_border_color);
|
||||||
|
if (linear_progress == 1.0f) {
|
||||||
|
c->opacity_animation.running = false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (c == selmon->sel) {
|
||||||
|
c->opacity_animation.running = false;
|
||||||
|
c->opacity_animation.current_opacity = c->focused_opacity;
|
||||||
|
memcpy(c->opacity_animation.current_border_color, border_color,
|
||||||
|
sizeof(c->opacity_animation.current_border_color));
|
||||||
|
client_set_opacity(c, c->focused_opacity);
|
||||||
|
} else {
|
||||||
|
c->opacity_animation.running = false;
|
||||||
|
c->opacity_animation.current_opacity = c->unfocused_opacity;
|
||||||
|
memcpy(c->opacity_animation.current_border_color, border_color,
|
||||||
|
sizeof(c->opacity_animation.current_border_color));
|
||||||
|
client_set_opacity(c, c->unfocused_opacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool client_draw_frame(Client *c) {
|
bool client_draw_frame(Client *c) {
|
||||||
|
|
||||||
if (!c || !client_surface(c)->mapped)
|
if (!c || !client_surface(c)->mapped)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (c->isfullscreen) {
|
if (!c->need_output_flush) {
|
||||||
client_set_opacity(c, 1);
|
return client_apply_focus_opacity(c);
|
||||||
} else if (c == selmon->sel && !c->animation.running) {
|
|
||||||
client_set_opacity(c, c->focused_opacity);
|
|
||||||
} else if (!c->animation.running) {
|
|
||||||
client_set_opacity(c, c->unfocused_opacity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!c->need_output_flush)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (animations && c->animation.running) {
|
if (animations && c->animation.running) {
|
||||||
client_animation_next_tick(c);
|
client_animation_next_tick(c);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1074,5 +1204,6 @@ bool client_draw_frame(Client *c) {
|
||||||
client_apply_clip(c, 1.0);
|
client_apply_clip(c, 1.0);
|
||||||
c->need_output_flush = false;
|
c->need_output_flush = false;
|
||||||
}
|
}
|
||||||
|
client_apply_focus_opacity(c);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,12 @@ struct dvec2 calculate_animation_curve_at(double t, int type) {
|
||||||
animation_curve = animation_curve_tag;
|
animation_curve = animation_curve_tag;
|
||||||
} else if (type == CLOSE) {
|
} else if (type == CLOSE) {
|
||||||
animation_curve = animation_curve_close;
|
animation_curve = animation_curve_close;
|
||||||
|
} else if (type == FOCUS) {
|
||||||
|
animation_curve = animation_curve_focus;
|
||||||
|
} else if (type == OPAFADEIN) {
|
||||||
|
animation_curve = animation_curve_opafadein;
|
||||||
|
} else if (type == OPAFADEOUT) {
|
||||||
|
animation_curve = animation_curve_opafadeout;
|
||||||
} else {
|
} else {
|
||||||
animation_curve = animation_curve_move;
|
animation_curve = animation_curve_move;
|
||||||
}
|
}
|
||||||
|
|
@ -28,30 +34,48 @@ void init_baked_points(void) {
|
||||||
baked_points_tag = calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_tag));
|
baked_points_tag = calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_tag));
|
||||||
baked_points_close =
|
baked_points_close =
|
||||||
calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_close));
|
calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_close));
|
||||||
|
baked_points_focus =
|
||||||
|
calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_focus));
|
||||||
|
baked_points_opafadein =
|
||||||
|
calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_opafadein));
|
||||||
|
baked_points_opafadeout =
|
||||||
|
calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_opafadeout));
|
||||||
|
|
||||||
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 (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
|
||||||
|
baked_points_focus[i] = calculate_animation_curve_at(
|
||||||
|
(double)i / (BAKED_POINTS_COUNT - 1), FOCUS);
|
||||||
|
}
|
||||||
|
for (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
|
||||||
|
baked_points_opafadein[i] = calculate_animation_curve_at(
|
||||||
|
(double)i / (BAKED_POINTS_COUNT - 1), OPAFADEIN);
|
||||||
|
}
|
||||||
|
for (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
|
||||||
|
baked_points_opafadeout[i] = calculate_animation_curve_at(
|
||||||
|
(double)i / (BAKED_POINTS_COUNT - 1), OPAFADEOUT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
@ -61,6 +85,12 @@ double find_animation_curve_at(double t, int type) {
|
||||||
baked_points = baked_points_tag;
|
baked_points = baked_points_tag;
|
||||||
} else if (type == CLOSE) {
|
} else if (type == CLOSE) {
|
||||||
baked_points = baked_points_close;
|
baked_points = baked_points_close;
|
||||||
|
} else if (type == FOCUS) {
|
||||||
|
baked_points = baked_points_focus;
|
||||||
|
} else if (type == OPAFADEIN) {
|
||||||
|
baked_points = baked_points_opafadein;
|
||||||
|
} else if (type == OPAFADEOUT) {
|
||||||
|
baked_points = baked_points_opafadeout;
|
||||||
} else {
|
} else {
|
||||||
baked_points = baked_points_move;
|
baked_points = baked_points_move;
|
||||||
}
|
}
|
||||||
|
|
@ -76,22 +106,6 @@ double find_animation_curve_at(double t, int type) {
|
||||||
return baked_points[up].y;
|
return baked_points[up].y;
|
||||||
}
|
}
|
||||||
|
|
||||||
double all_output_frame_duration_ms() {
|
|
||||||
int32_t refresh_total = 0;
|
|
||||||
Monitor *m = NULL;
|
|
||||||
wl_list_for_each(m, &mons, link) {
|
|
||||||
if (!m->wlr_output->enabled) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
refresh_total += m->wlr_output->refresh;
|
|
||||||
}
|
|
||||||
return 1000000.0 / refresh_total;
|
|
||||||
}
|
|
||||||
|
|
||||||
double output_frame_duration_ms(Monitor *m) {
|
|
||||||
return 1000000.0 / m->wlr_output->refresh;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool scene_node_snapshot(struct wlr_scene_node *node, int lx, int ly,
|
static bool scene_node_snapshot(struct wlr_scene_node *node, int lx, int ly,
|
||||||
struct wlr_scene_tree *snapshot_tree) {
|
struct wlr_scene_tree *snapshot_tree) {
|
||||||
if (!node->enabled && node->type != WLR_SCENE_NODE_TREE) {
|
if (!node->enabled && node->type != WLR_SCENE_NODE_TREE) {
|
||||||
|
|
@ -234,4 +248,14 @@ struct wlr_scene_tree *wlr_scene_tree_snapshot(struct wlr_scene_node *node,
|
||||||
wlr_scene_node_set_enabled(&snapshot->node, true);
|
wlr_scene_node_set_enabled(&snapshot->node, true);
|
||||||
|
|
||||||
return snapshot;
|
return snapshot;
|
||||||
|
}
|
||||||
|
|
||||||
|
void request_fresh_all_monitors(void) {
|
||||||
|
Monitor *m = NULL;
|
||||||
|
wl_list_for_each(m, &mons, link) {
|
||||||
|
if (!m->wlr_output->enabled) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
wlr_output_schedule_frame(m->wlr_output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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) {
|
||||||
|
|
@ -234,23 +232,27 @@ void fadeout_layer_animation_next_tick(LayerSurface *l) {
|
||||||
if (!l)
|
if (!l)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
struct timespec now;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
uint32_t passed_time = timespec_to_ms(&now) - l->animation.time_started;
|
||||||
double animation_passed =
|
double animation_passed =
|
||||||
l->animation.total_frames
|
l->animation.duration
|
||||||
? (double)l->animation.passed_frames / l->animation.total_frames
|
? (double)passed_time / (double)l->animation.duration
|
||||||
: 1.0;
|
: 1.0;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
|
@ -274,19 +276,23 @@ void fadeout_layer_animation_next_tick(LayerSurface *l) {
|
||||||
.height = height,
|
.height = height,
|
||||||
};
|
};
|
||||||
|
|
||||||
double opacity = MAX(fadeout_begin_opacity - animation_passed, 0.0f);
|
double opacity_eased_progress =
|
||||||
|
find_animation_curve_at(animation_passed, OPAFADEOUT);
|
||||||
|
|
||||||
|
double percent = fadeout_begin_opacity -
|
||||||
|
(opacity_eased_progress * fadeout_begin_opacity);
|
||||||
|
|
||||||
|
double opacity = MAX(percent, 0.0f);
|
||||||
|
|
||||||
if (animation_fade_out)
|
if (animation_fade_out)
|
||||||
wlr_scene_node_for_each_buffer(&l->scene->node,
|
wlr_scene_node_for_each_buffer(&l->scene->node,
|
||||||
scene_buffer_apply_opacity, &opacity);
|
scene_buffer_apply_opacity, &opacity);
|
||||||
|
|
||||||
if (animation_passed == 1.0) {
|
if (animation_passed >= 1.0) {
|
||||||
wl_list_remove(&l->fadeout_link);
|
wl_list_remove(&l->fadeout_link);
|
||||||
wlr_scene_node_destroy(&l->scene->node);
|
wlr_scene_node_destroy(&l->scene->node);
|
||||||
free(l);
|
free(l);
|
||||||
l = NULL;
|
l = NULL;
|
||||||
} else {
|
|
||||||
l->animation.passed_frames++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -295,27 +301,36 @@ void layer_animation_next_tick(LayerSurface *l) {
|
||||||
if (!l || !l->mapped)
|
if (!l || !l->mapped)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
struct timespec now;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
uint32_t passed_time = timespec_to_ms(&now) - l->animation.time_started;
|
||||||
double animation_passed =
|
double animation_passed =
|
||||||
l->animation.total_frames
|
l->animation.duration
|
||||||
? (double)l->animation.passed_frames / l->animation.total_frames
|
? (double)passed_time / (double)l->animation.duration
|
||||||
: 1.0;
|
: 1.0;
|
||||||
|
|
||||||
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 + animation_passed, 1.0f);
|
double opacity_eased_progress =
|
||||||
|
find_animation_curve_at(animation_passed, OPAFADEIN);
|
||||||
|
|
||||||
|
double opacity =
|
||||||
|
MIN(fadein_begin_opacity +
|
||||||
|
opacity_eased_progress * (1.0 - fadein_begin_opacity),
|
||||||
|
1.0f);
|
||||||
|
|
||||||
if (animation_fade_in)
|
if (animation_fade_in)
|
||||||
wlr_scene_node_for_each_buffer(&l->scene->node,
|
wlr_scene_node_for_each_buffer(&l->scene->node,
|
||||||
|
|
@ -347,12 +362,10 @@ void layer_animation_next_tick(LayerSurface *l) {
|
||||||
.height = height,
|
.height = height,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (animation_passed == 1.0) {
|
if (animation_passed >= 1.0) {
|
||||||
l->animation.running = false;
|
l->animation.running = false;
|
||||||
l->need_output_flush = false;
|
l->need_output_flush = false;
|
||||||
l->animation.action = MOVE;
|
l->animation.action = MOVE;
|
||||||
} else {
|
|
||||||
l->animation.passed_frames++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -446,10 +459,8 @@ void init_fadeout_layers(LayerSurface *l) {
|
||||||
fadeout_layer->current.height = 0;
|
fadeout_layer->current.height = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算动画帧数
|
// 动画开始时间
|
||||||
fadeout_layer->animation.passed_frames = 0;
|
fadeout_layer->animation.time_started = get_now_in_ms();
|
||||||
fadeout_layer->animation.total_frames =
|
|
||||||
fadeout_layer->animation.duration / all_output_frame_duration_ms();
|
|
||||||
|
|
||||||
// 将节点插入到关闭动画链表中,屏幕刷新哪里会检查链表中是否有节点可以应用于动画
|
// 将节点插入到关闭动画链表中,屏幕刷新哪里会检查链表中是否有节点可以应用于动画
|
||||||
wlr_scene_node_set_enabled(&fadeout_layer->scene->node, true);
|
wlr_scene_node_set_enabled(&fadeout_layer->scene->node, true);
|
||||||
|
|
@ -532,23 +543,11 @@ void layer_commit(LayerSurface *l) {
|
||||||
}
|
}
|
||||||
|
|
||||||
l->animation.initial = l->animainit_geom;
|
l->animation.initial = l->animainit_geom;
|
||||||
// 设置动画速度
|
l->animation.time_started = get_now_in_ms();
|
||||||
l->animation.passed_frames = 0;
|
|
||||||
l->animation.total_frames =
|
|
||||||
l->animation.duration / output_frame_duration_ms(l->mon);
|
|
||||||
|
|
||||||
// 标记动画开始
|
// 标记动画开始
|
||||||
l->animation.running = true;
|
l->animation.running = true;
|
||||||
l->animation.should_animate = false;
|
l->animation.should_animate = false;
|
||||||
} else {
|
|
||||||
// 如果动画没有开始,且被判定为不应该动画,
|
|
||||||
// 则设置总帧数为1,不然其他地方一旦获取动画
|
|
||||||
// 进度,总帧数作为分母会造成除零
|
|
||||||
// 比如动画类型为none的时候
|
|
||||||
if (!l->animation.running) {
|
|
||||||
l->animation.passed_frames = 1;
|
|
||||||
l->animation.total_frames = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 请求刷新屏幕
|
// 请求刷新屏幕
|
||||||
wlr_output_schedule_frame(l->mon->wlr_output);
|
wlr_output_schedule_frame(l->mon->wlr_output);
|
||||||
|
|
|
||||||
|
|
@ -9,19 +9,23 @@ void set_tagin_animation(Monitor *m, Client *c) {
|
||||||
|
|
||||||
c->animainit_geom.x = tag_animation_direction == VERTICAL
|
c->animainit_geom.x = tag_animation_direction == VERTICAL
|
||||||
? c->animation.current.x
|
? c->animation.current.x
|
||||||
: c->geom.x + c->mon->m.width;
|
: MAX(c->mon->m.x + c->mon->m.width,
|
||||||
|
c->geom.x + c->mon->m.width);
|
||||||
c->animainit_geom.y = tag_animation_direction == VERTICAL
|
c->animainit_geom.y = tag_animation_direction == VERTICAL
|
||||||
? c->geom.y + c->mon->m.height
|
? MAX(c->mon->m.y + c->mon->m.height,
|
||||||
|
c->geom.y + c->mon->m.height)
|
||||||
: c->animation.current.y;
|
: c->animation.current.y;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
c->animainit_geom.x = tag_animation_direction == VERTICAL
|
c->animainit_geom.x =
|
||||||
? c->animation.current.x
|
tag_animation_direction == VERTICAL
|
||||||
: c->geom.x - c->mon->m.width;
|
? c->animation.current.x
|
||||||
c->animainit_geom.y = tag_animation_direction == VERTICAL
|
: MIN(m->m.x - c->geom.width, c->geom.x - c->mon->m.width);
|
||||||
? c->geom.y - c->mon->m.height
|
c->animainit_geom.y =
|
||||||
: c->animation.current.y;
|
tag_animation_direction == VERTICAL
|
||||||
|
? MIN(m->m.y - c->geom.height, c->geom.y - c->mon->m.height)
|
||||||
|
: c->animation.current.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,11 +56,13 @@ void set_arrange_visible(Monitor *m, Client *c, bool want_animation) {
|
||||||
void set_tagout_animation(Monitor *m, Client *c) {
|
void set_tagout_animation(Monitor *m, Client *c) {
|
||||||
if (m->pertag->curtag > m->pertag->prevtag) {
|
if (m->pertag->curtag > m->pertag->prevtag) {
|
||||||
c->pending = c->geom;
|
c->pending = c->geom;
|
||||||
c->pending.x = tag_animation_direction == VERTICAL
|
c->pending.x =
|
||||||
? c->animation.current.x
|
tag_animation_direction == VERTICAL
|
||||||
: c->geom.x - c->mon->m.width;
|
? c->animation.current.x
|
||||||
|
: MIN(c->mon->m.x - c->geom.width, c->geom.x - c->mon->m.width);
|
||||||
c->pending.y = tag_animation_direction == VERTICAL
|
c->pending.y = tag_animation_direction == VERTICAL
|
||||||
? c->geom.y - c->mon->m.height
|
? MIN(c->mon->m.y - c->geom.height,
|
||||||
|
c->geom.y - c->mon->m.height)
|
||||||
: c->animation.current.y;
|
: c->animation.current.y;
|
||||||
|
|
||||||
resize(c, c->geom, 0);
|
resize(c, c->geom, 0);
|
||||||
|
|
@ -64,9 +70,11 @@ void set_tagout_animation(Monitor *m, Client *c) {
|
||||||
c->pending = c->geom;
|
c->pending = c->geom;
|
||||||
c->pending.x = tag_animation_direction == VERTICAL
|
c->pending.x = tag_animation_direction == VERTICAL
|
||||||
? c->animation.current.x
|
? c->animation.current.x
|
||||||
: c->geom.x + c->mon->m.width;
|
: MAX(c->mon->m.x + c->mon->m.width,
|
||||||
|
c->geom.x + c->mon->m.width);
|
||||||
c->pending.y = tag_animation_direction == VERTICAL
|
c->pending.y = tag_animation_direction == VERTICAL
|
||||||
? c->geom.y + c->mon->m.height
|
? MAX(c->mon->m.y + c->mon->m.height,
|
||||||
|
c->geom.y + c->mon->m.height)
|
||||||
: c->animation.current.y;
|
: c->animation.current.y;
|
||||||
resize(c, c->geom, 0);
|
resize(c, c->geom, 0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -359,7 +359,7 @@ static inline void client_set_maximized(Client *c, bool maximized) {
|
||||||
static inline void client_set_tiled(Client *c, uint32_t edges) {
|
static inline void client_set_tiled(Client *c, uint32_t edges) {
|
||||||
struct wlr_xdg_toplevel *toplevel;
|
struct wlr_xdg_toplevel *toplevel;
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c)) {
|
if (client_is_x11(c) && c->force_maximize) {
|
||||||
wlr_xwayland_surface_set_maximized(c->surface.xwayland,
|
wlr_xwayland_surface_set_maximized(c->surface.xwayland,
|
||||||
edges != WLR_EDGE_NONE,
|
edges != WLR_EDGE_NONE,
|
||||||
edges != WLR_EDGE_NONE);
|
edges != WLR_EDGE_NONE);
|
||||||
|
|
@ -374,7 +374,7 @@ static inline void client_set_tiled(Client *c, uint32_t edges) {
|
||||||
wlr_xdg_toplevel_set_tiled(c->surface.xdg->toplevel, edges);
|
wlr_xdg_toplevel_set_tiled(c->surface.xdg->toplevel, edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!c->ignore_maximize && c->force_maximize) {
|
if (c->force_maximize) {
|
||||||
wlr_xdg_toplevel_set_maximized(toplevel, edges != WLR_EDGE_NONE);
|
wlr_xdg_toplevel_set_maximized(toplevel, edges != WLR_EDGE_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -390,6 +390,21 @@ static inline void client_set_suspended(Client *c, int suspended) {
|
||||||
|
|
||||||
static inline int client_should_ignore_focus(Client *c) {
|
static inline int client_should_ignore_focus(Client *c) {
|
||||||
|
|
||||||
|
#ifdef XWAYLAND
|
||||||
|
if (client_is_x11(c)) {
|
||||||
|
struct wlr_xwayland_surface *surface = c->surface.xwayland;
|
||||||
|
|
||||||
|
if (!surface->hints)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return !surface->hints->input;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int client_is_x11_popup(Client *c) {
|
||||||
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c)) {
|
if (client_is_x11(c)) {
|
||||||
struct wlr_xwayland_surface *surface = c->surface.xwayland;
|
struct wlr_xwayland_surface *surface = c->surface.xwayland;
|
||||||
|
|
@ -473,6 +488,18 @@ static inline bool client_request_minimize(Client *c, void *data) {
|
||||||
return c->surface.xdg->toplevel->requested.minimized;
|
return c->surface.xdg->toplevel->requested.minimized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool client_request_maximize(Client *c, void *data) {
|
||||||
|
|
||||||
|
#ifdef XWAYLAND
|
||||||
|
if (client_is_x11(c)) {
|
||||||
|
struct wlr_xwayland_surface *surface = c->surface.xwayland;
|
||||||
|
return surface->maximized_vert || surface->maximized_horz;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return c->surface.xdg->toplevel->requested.maximized;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void client_set_size_bound(Client *c) {
|
static inline void client_set_size_bound(Client *c) {
|
||||||
struct wlr_xdg_toplevel *toplevel;
|
struct wlr_xdg_toplevel *toplevel;
|
||||||
struct wlr_xdg_toplevel_state state;
|
struct wlr_xdg_toplevel_state state;
|
||||||
|
|
@ -485,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;
|
||||||
|
|
@ -503,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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
|
@ -80,3 +81,14 @@ int regex_match(const char *pattern, const char *str) {
|
||||||
void wl_list_append(struct wl_list *list, struct wl_list *object) {
|
void wl_list_append(struct wl_list *list, struct wl_list *object) {
|
||||||
wl_list_insert(list->prev, object);
|
wl_list_insert(list->prev, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t get_now_in_ms(void) {
|
||||||
|
struct timespec now;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
return timespec_to_ms(&now);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t timespec_to_ms(struct timespec *ts) {
|
||||||
|
return (uint32_t)ts->tv_sec * 1000 + (uint32_t)ts->tv_nsec / 1000000;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,3 +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);
|
||||||
|
uint32_t get_now_in_ms(void);
|
||||||
|
uint32_t timespec_to_ms(struct timespec *ts);
|
||||||
|
|
@ -25,39 +25,44 @@ uint32_t animation_duration_move = 500; // Animation move speed
|
||||||
uint32_t animation_duration_open = 400; // Animation open speed
|
uint32_t animation_duration_open = 400; // Animation open speed
|
||||||
uint32_t animation_duration_tag = 300; // Animation tag speed
|
uint32_t animation_duration_tag = 300; // Animation tag speed
|
||||||
uint32_t animation_duration_close = 300; // Animation close speed
|
uint32_t animation_duration_close = 300; // Animation close speed
|
||||||
double animation_curve_move[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
uint32_t animation_duration_focus = 0; // Animation focus opacity speed
|
||||||
double animation_curve_open[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
double animation_curve_move[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||||
double animation_curve_tag[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
double animation_curve_open[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||||
double animation_curve_close[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
double animation_curve_tag[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||||
|
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_opafadein[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||||
|
double animation_curve_opafadeout[4] = {0.5, 0.5, 0.5, 0.5}; // 动画曲线
|
||||||
|
|
||||||
/* 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 = 1; // 是否打开右边小键盘
|
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;
|
||||||
int focus_cross_monitor = 0;
|
int focus_cross_monitor = 0;
|
||||||
|
|
@ -70,19 +75,19 @@ 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 idleinhibit_ignore_visible =
|
||||||
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);
|
||||||
float maxmizescreencolor[] = COLOR(0x89aa61ff);
|
float maximizescreencolor[] = COLOR(0x89aa61ff);
|
||||||
float urgentcolor[] = COLOR(0xad401fff);
|
float urgentcolor[] = COLOR(0xad401fff);
|
||||||
float scratchpadcolor[] = COLOR(0x516c93ff);
|
float scratchpadcolor[] = COLOR(0x516c93ff);
|
||||||
float globalcolor[] = COLOR(0xb153a7ff);
|
float globalcolor[] = COLOR(0xb153a7ff);
|
||||||
|
|
@ -100,7 +105,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;
|
||||||
double drag_refresh_interval = 30.0;
|
int allow_lock_transparent = 0;
|
||||||
|
double drag_refresh_interval = 16.0;
|
||||||
|
int allow_tearing = TEARING_DISABLED;
|
||||||
|
int allow_shortcuts_inhibit = SHORTCUTS_INHIBIT_ENABLE;
|
||||||
|
|
||||||
/* keyboard */
|
/* keyboard */
|
||||||
|
|
||||||
|
|
@ -114,6 +122,19 @@ char xkb_rules_layout[256];
|
||||||
char xkb_rules_variant[256];
|
char xkb_rules_variant[256];
|
||||||
char xkb_rules_options[256];
|
char xkb_rules_options[256];
|
||||||
|
|
||||||
|
/* keyboard */
|
||||||
|
static const struct xkb_rule_names xkb_fallback_rules = {
|
||||||
|
.layout = "us",
|
||||||
|
.variant = NULL,
|
||||||
|
.model = NULL,
|
||||||
|
.rules = NULL,
|
||||||
|
.options = NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct xkb_rule_names xkb_default_rules = {
|
||||||
|
.options = NULL,
|
||||||
|
};
|
||||||
|
|
||||||
struct xkb_rule_names xkb_rules = {
|
struct xkb_rule_names xkb_rules = {
|
||||||
/* can specify fields: rules, model, layout, variant, options */
|
/* can specify fields: rules, model, layout, variant, options */
|
||||||
/* example:
|
/* example:
|
||||||
|
|
@ -147,7 +168,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
|
||||||
|
|
@ -157,6 +178,8 @@ LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER
|
||||||
enum libinput_config_click_method click_method =
|
enum libinput_config_click_method click_method =
|
||||||
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
|
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
|
||||||
|
|
||||||
|
double axis_scroll_factor = 1.0;
|
||||||
|
|
||||||
/* You can choose between:
|
/* You can choose between:
|
||||||
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED
|
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED
|
||||||
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED
|
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED
|
||||||
|
|
@ -205,7 +228,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;
|
||||||
|
|
|
||||||
|
|
@ -4,28 +4,29 @@ int toggle_scratchpad(const Arg *arg);
|
||||||
int focusdir(const Arg *arg);
|
int focusdir(const Arg *arg);
|
||||||
int toggleoverview(const Arg *arg);
|
int toggleoverview(const Arg *arg);
|
||||||
int set_proportion(const Arg *arg);
|
int set_proportion(const Arg *arg);
|
||||||
int increase_proportion(const Arg *arg);
|
|
||||||
int switch_proportion_preset(const Arg *arg);
|
int switch_proportion_preset(const Arg *arg);
|
||||||
int zoom(const Arg *arg);
|
int zoom(const Arg *arg);
|
||||||
int tagsilent(const Arg *arg);
|
int tagsilent(const Arg *arg);
|
||||||
int tagtoleft(const Arg *arg);
|
int tagtoleft(const Arg *arg);
|
||||||
int tagtoright(const Arg *arg);
|
int tagtoright(const Arg *arg);
|
||||||
|
int tagcrossmon(const Arg *arg);
|
||||||
int viewtoleft(const Arg *arg);
|
int viewtoleft(const Arg *arg);
|
||||||
int viewtoright(const Arg *arg);
|
int viewtoright(const Arg *arg);
|
||||||
int viewtoleft_have_client(const Arg *arg);
|
int viewtoleft_have_client(const Arg *arg);
|
||||||
int viewtoright_have_client(const Arg *arg);
|
int viewtoright_have_client(const Arg *arg);
|
||||||
|
int viewcrossmon(const Arg *arg);
|
||||||
int togglefloating(const Arg *arg);
|
int togglefloating(const Arg *arg);
|
||||||
int togglefullscreen(const Arg *arg);
|
int togglefullscreen(const Arg *arg);
|
||||||
int togglemaxmizescreen(const Arg *arg);
|
int togglemaximizescreen(const Arg *arg);
|
||||||
int togglegaps(const Arg *arg);
|
int togglegaps(const Arg *arg);
|
||||||
int tagmon(const Arg *arg);
|
int tagmon(const Arg *arg);
|
||||||
int spawn(const Arg *arg);
|
int spawn(const Arg *arg);
|
||||||
int spawn_shell(const Arg *arg);
|
int spawn_shell(const Arg *arg);
|
||||||
int spawn_on_empty(const Arg *arg);
|
int spawn_on_empty(const Arg *arg);
|
||||||
int setkeymode(const Arg *arg);
|
int setkeymode(const Arg *arg);
|
||||||
|
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 switch_keyboard_layout(const Arg *arg);
|
|
||||||
int setmfact(const Arg *arg);
|
int setmfact(const Arg *arg);
|
||||||
int quit(const Arg *arg);
|
int quit(const Arg *arg);
|
||||||
int moveresize(const Arg *arg);
|
int moveresize(const Arg *arg);
|
||||||
|
|
@ -64,4 +65,7 @@ int create_virtual_output(const Arg *arg);
|
||||||
int destroy_all_virtual_output(const Arg *arg);
|
int destroy_all_virtual_output(const Arg *arg);
|
||||||
int focuslast(const Arg *arg);
|
int focuslast(const Arg *arg);
|
||||||
int toggle_trackpad_enable(const Arg *arg);
|
int toggle_trackpad_enable(const Arg *arg);
|
||||||
int setoption(const Arg *arg);
|
int setoption(const Arg *arg);
|
||||||
|
int disable_monitor(const Arg *arg);
|
||||||
|
int enable_monitor(const Arg *arg);
|
||||||
|
int toggle_monitor(const Arg *arg);
|
||||||
|
|
@ -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->ismaxmizescreen)
|
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;
|
||||||
}
|
}
|
||||||
|
|
@ -89,7 +93,7 @@ int exchange_client(const Arg *arg) {
|
||||||
int exchange_stack_client(const Arg *arg) {
|
int exchange_stack_client(const Arg *arg) {
|
||||||
Client *c = selmon->sel;
|
Client *c = selmon->sel;
|
||||||
Client *tc = NULL;
|
Client *tc = NULL;
|
||||||
if (!c || c->isfloating || c->isfullscreen || c->ismaxmizescreen)
|
if (!c || c->isfloating || c->isfullscreen || c->ismaximizescreen)
|
||||||
return 0;
|
return 0;
|
||||||
if (arg->i == NEXT) {
|
if (arg->i == NEXT) {
|
||||||
tc = get_next_stack_client(c, false);
|
tc = get_next_stack_client(c, false);
|
||||||
|
|
@ -126,12 +130,12 @@ 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_should_ignore_focus(c))
|
client_is_x11_popup(c))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (selmon && !selmon->sel) {
|
if (selmon && !selmon->sel) {
|
||||||
|
|
@ -167,17 +171,19 @@ 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;
|
||||||
|
Monitor *tm = NULL;
|
||||||
|
|
||||||
if (arg->i != UNDIR) {
|
if (arg->i != UNDIR) {
|
||||||
m = dirtomon(arg->i);
|
tm = dirtomon(arg->i);
|
||||||
} else if (arg->v) {
|
} else if (arg->v) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
if (regex_match(arg->v, m->wlr_output->name)) {
|
if (regex_match(arg->v, m->wlr_output->name)) {
|
||||||
|
tm = m;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -185,11 +191,10 @@ int focusmon(const Arg *arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m || !m->wlr_output->enabled)
|
if (!tm || !tm->wlr_output->enabled || tm == selmon)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
old_selmon_sel = selmon->sel;
|
selmon = tm;
|
||||||
selmon = m;
|
|
||||||
if (warpcursor) {
|
if (warpcursor) {
|
||||||
warp_cursor_to_selmon(selmon);
|
warp_cursor_to_selmon(selmon);
|
||||||
}
|
}
|
||||||
|
|
@ -198,12 +203,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,7 +215,7 @@ int focusstack(const Arg *arg) {
|
||||||
Client *sel = focustop(selmon);
|
Client *sel = focustop(selmon);
|
||||||
Client *tc = NULL;
|
Client *tc = NULL;
|
||||||
|
|
||||||
if (!sel || (sel->isfullscreen && !client_has_children(sel)))
|
if (!sel)
|
||||||
return 0;
|
return 0;
|
||||||
if (arg->i == NEXT) {
|
if (arg->i == NEXT) {
|
||||||
tc = get_next_stack_client(sel, false);
|
tc = get_next_stack_client(sel, false);
|
||||||
|
|
@ -281,18 +284,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;
|
||||||
|
|
@ -329,7 +320,7 @@ int moveresize(const Arg *arg) {
|
||||||
return 0;
|
return 0;
|
||||||
xytonode(cursor->x, cursor->y, NULL, &grabc, NULL, NULL, NULL);
|
xytonode(cursor->x, cursor->y, NULL, &grabc, NULL, NULL, NULL);
|
||||||
if (!grabc || client_is_unmanaged(grabc) || grabc->isfullscreen ||
|
if (!grabc || client_is_unmanaged(grabc) || grabc->isfullscreen ||
|
||||||
grabc->ismaxmizescreen) {
|
grabc->ismaximizescreen) {
|
||||||
grabc = NULL;
|
grabc = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -410,7 +401,7 @@ int resizewin(const Arg *arg) {
|
||||||
c = selmon->sel;
|
c = selmon->sel;
|
||||||
int offsetx = 0, offsety = 0;
|
int offsetx = 0, offsety = 0;
|
||||||
|
|
||||||
if (!c || c->isfullscreen || c->ismaxmizescreen)
|
if (!c || c->isfullscreen || c->ismaximizescreen)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (ISTILED(c)) {
|
if (ISTILED(c)) {
|
||||||
|
|
@ -479,7 +470,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 +479,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 +500,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 +521,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 +715,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 +820,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;
|
||||||
}
|
}
|
||||||
|
|
@ -836,90 +847,35 @@ 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;
|
||||||
|
|
||||||
// 2. 创建上下文
|
|
||||||
struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
|
||||||
if (!context) {
|
|
||||||
wlr_log(WLR_ERROR, "Failed to create XKB context");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 分配并获取布局缩写
|
|
||||||
const char **layout_ids = calloc(num_layouts, sizeof(char *));
|
|
||||||
if (!layout_ids) {
|
|
||||||
wlr_log(WLR_ERROR, "Failed to allocate layout IDs");
|
|
||||||
goto cleanup_context;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < num_layouts; i++) {
|
|
||||||
layout_ids[i] =
|
|
||||||
get_layout_abbr(xkb_keymap_layout_get_name(keyboard->keymap, i));
|
|
||||||
if (!layout_ids[i]) {
|
|
||||||
wlr_log(WLR_ERROR, "Failed to get layout abbreviation");
|
|
||||||
goto cleanup_layouts;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. 直接修改 rules.layout(保持原有逻辑)
|
|
||||||
struct xkb_rule_names rules = xkb_rules;
|
|
||||||
char *layout_buf = (char *)rules.layout; // 假设这是可修改的
|
|
||||||
|
|
||||||
// 清空原有内容(安全方式)
|
|
||||||
unsigned int layout_buf_size = strlen(layout_buf) + 1;
|
|
||||||
memset(layout_buf, 0, layout_buf_size);
|
|
||||||
|
|
||||||
// 构建新的布局字符串
|
|
||||||
for (int i = 0; i < num_layouts; i++) {
|
|
||||||
const char *layout = layout_ids[(next + i) % num_layouts];
|
|
||||||
|
|
||||||
if (i > 0) {
|
|
||||||
strncat(layout_buf, ",", layout_buf_size - strlen(layout_buf) - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strchr(layout, ',')) {
|
|
||||||
// 处理包含逗号的布局名
|
|
||||||
char *quoted = malloc(strlen(layout) + 3);
|
|
||||||
if (quoted) {
|
|
||||||
snprintf(quoted, strlen(layout) + 3, "\"%s\"", layout);
|
|
||||||
strncat(layout_buf, quoted,
|
|
||||||
layout_buf_size - strlen(layout_buf) - 1);
|
|
||||||
free(quoted);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
strncat(layout_buf, layout,
|
|
||||||
layout_buf_size - strlen(layout_buf) - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. 创建新 keymap
|
|
||||||
struct xkb_keymap *new_keymap =
|
|
||||||
xkb_keymap_new_from_names(context, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
|
||||||
if (!new_keymap) {
|
|
||||||
wlr_log(WLR_ERROR, "Failed to create keymap for layouts: %s",
|
|
||||||
rules.layout);
|
|
||||||
goto cleanup_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, new_keymap);
|
wlr_keyboard_set_keymap(keyboard, keyboard->keymap);
|
||||||
wlr_keyboard_notify_modifiers(keyboard, depressed, latched, locked, 0);
|
wlr_keyboard_notify_modifiers(keyboard, depressed, latched, locked, next);
|
||||||
keyboard->modifiers.group = 0;
|
keyboard->modifiers.group = 0;
|
||||||
|
|
||||||
// 7. 更新 seat
|
// 7. 更新 seat
|
||||||
wlr_seat_set_keyboard(seat, keyboard);
|
wlr_seat_set_keyboard(seat, keyboard);
|
||||||
wlr_seat_keyboard_notify_modifiers(seat, &keyboard->modifiers);
|
wlr_seat_keyboard_notify_modifiers(seat, &keyboard->modifiers);
|
||||||
|
|
||||||
// 8. 清理资源
|
InputDevice *id;
|
||||||
xkb_keymap_unref(new_keymap);
|
wl_list_for_each(id, &inputdevices, link) {
|
||||||
|
if (id->wlr_device->type != WLR_INPUT_DEVICE_KEYBOARD) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
cleanup_layouts:
|
struct wlr_keyboard *tkb = (struct wlr_keyboard *)id->device_data;
|
||||||
free(layout_ids);
|
|
||||||
|
|
||||||
cleanup_context:
|
wlr_keyboard_set_keymap(tkb, keyboard->keymap);
|
||||||
xkb_context_unref(context);
|
wlr_keyboard_notify_modifiers(tkb, depressed, latched, locked, next);
|
||||||
|
tkb->modifiers.group = 0;
|
||||||
|
|
||||||
|
// 7. 更新 seat
|
||||||
|
wlr_seat_set_keyboard(seat, tkb);
|
||||||
|
wlr_seat_keyboard_notify_modifiers(seat, &tkb->modifiers);
|
||||||
|
}
|
||||||
|
|
||||||
printstatus();
|
printstatus();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -929,7 +885,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++) {
|
||||||
|
|
@ -960,7 +916,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;
|
||||||
|
|
@ -971,6 +927,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;
|
||||||
|
|
@ -986,6 +943,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++) {
|
||||||
|
|
@ -1006,7 +970,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;
|
||||||
|
|
@ -1023,7 +987,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)
|
||||||
|
|
@ -1032,11 +996,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1044,11 +1009,17 @@ int tagmon(const Arg *arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m || !m->wlr_output->enabled || m == c->mon)
|
if (!m || !m->wlr_output->enabled)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
unsigned int newtags = arg->ui ? 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) {
|
||||||
|
view(&(Arg){.ui = newtags}, true);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (c == selmon->sel) {
|
if (c == selmon->sel) {
|
||||||
selmon->sel = NULL;
|
selmon->sel = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -1065,6 +1036,7 @@ int tagmon(const Arg *arg) {
|
||||||
selmon = c->mon;
|
selmon = c->mon;
|
||||||
c->float_geom = setclient_coordinate_center(c, c->float_geom, 0, 0);
|
c->float_geom = setclient_coordinate_center(c, c->float_geom, 0, 0);
|
||||||
|
|
||||||
|
// 重新计算居中的坐标
|
||||||
// 重新计算居中的坐标
|
// 重新计算居中的坐标
|
||||||
if (c->isfloating) {
|
if (c->isfloating) {
|
||||||
c->geom = c->float_geom;
|
c->geom = c->float_geom;
|
||||||
|
|
@ -1132,7 +1104,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1161,7 +1133,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;
|
||||||
}
|
}
|
||||||
|
|
@ -1193,7 +1165,7 @@ int togglefloating(const Arg *arg) {
|
||||||
if (!sel)
|
if (!sel)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ((sel->isfullscreen || sel->ismaxmizescreen)) {
|
if ((sel->isfullscreen || sel->ismaximizescreen)) {
|
||||||
sel->isfloating = 1;
|
sel->isfloating = 1;
|
||||||
} else {
|
} else {
|
||||||
sel->isfloating = !sel->isfloating;
|
sel->isfloating = !sel->isfloating;
|
||||||
|
|
@ -1241,7 +1213,7 @@ int togglegaps(const Arg *arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int togglemaxmizescreen(const Arg *arg) {
|
int togglemaximizescreen(const Arg *arg) {
|
||||||
Client *sel = focustop(selmon);
|
Client *sel = focustop(selmon);
|
||||||
if (!sel)
|
if (!sel)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1250,10 +1222,10 @@ int togglemaxmizescreen(const Arg *arg) {
|
||||||
sel->is_in_scratchpad = 0;
|
sel->is_in_scratchpad = 0;
|
||||||
sel->isnamedscratchpad = 0;
|
sel->isnamedscratchpad = 0;
|
||||||
|
|
||||||
if (sel->ismaxmizescreen)
|
if (sel->ismaximizescreen)
|
||||||
setmaxmizescreen(sel, 0);
|
setmaximizescreen(sel, 0);
|
||||||
else
|
else
|
||||||
setmaxmizescreen(sel, 1);
|
setmaximizescreen(sel, 1);
|
||||||
|
|
||||||
setborder_color(sel);
|
setborder_color(sel);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1281,7 +1253,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;
|
||||||
|
|
@ -1304,8 +1276,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;
|
||||||
|
|
||||||
|
|
@ -1322,7 +1294,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;
|
||||||
|
|
@ -1345,7 +1317,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])
|
||||||
|
|
@ -1359,9 +1331,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) {
|
||||||
|
|
@ -1384,9 +1355,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) {
|
||||||
|
|
@ -1408,8 +1378,22 @@ int viewtoright_have_client(const Arg *arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int viewcrossmon(const Arg *arg) {
|
||||||
|
focusmon(&(Arg){.v = arg->v, .i = UNDIR});
|
||||||
|
view_in_mon(arg, true, selmon, true);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tagcrossmon(const Arg *arg) {
|
||||||
|
if (!selmon->sel)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
tagmon(&(Arg){.ui = arg->ui, .i = UNDIR, .v = arg->v});
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
@ -1472,7 +1456,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;
|
||||||
|
|
@ -1481,21 +1465,21 @@ int minimized(const Arg *arg) {
|
||||||
int toggleoverview(const Arg *arg) {
|
int toggleoverview(const Arg *arg) {
|
||||||
Client *c = NULL;
|
Client *c = NULL;
|
||||||
|
|
||||||
if (selmon->isoverview && ov_tab_mode && arg->i != -1 && selmon->sel) {
|
if (selmon->isoverview && ov_tab_mode && arg->i != 1 && selmon->sel) {
|
||||||
focusstack(&(Arg){.i = 1});
|
focusstack(&(Arg){.i = 1});
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
wl_list_for_each(c, &clients, link) if (c && c->mon == selmon &&
|
||||||
link) if (c && c->mon == selmon &&
|
!client_is_unmanaged(c) &&
|
||||||
!client_is_unmanaged(c) &&
|
!client_is_x11_popup(c) &&
|
||||||
!client_should_ignore_focus(c) &&
|
!c->isminimized &&
|
||||||
!c->isminied && !c->isunglobal) {
|
!c->isunglobal) {
|
||||||
visible_client_number++;
|
visible_client_number++;
|
||||||
}
|
}
|
||||||
if (visible_client_number > 0) {
|
if (visible_client_number > 0) {
|
||||||
|
|
@ -1518,24 +1502,65 @@ int toggleoverview(const Arg *arg) {
|
||||||
if (selmon->isoverview) {
|
if (selmon->isoverview) {
|
||||||
wl_list_for_each(c, &clients, link) {
|
wl_list_for_each(c, &clients, link) {
|
||||||
if (c && c->mon == selmon && !client_is_unmanaged(c) &&
|
if (c && c->mon == selmon && !client_is_unmanaged(c) &&
|
||||||
!client_should_ignore_focus(c) && !c->isunglobal)
|
!client_is_x11_popup(c) && !c->isunglobal)
|
||||||
overview_backup(c);
|
overview_backup(c);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wl_list_for_each(c, &clients, link) {
|
wl_list_for_each(c, &clients, link) {
|
||||||
if (c && c->mon == selmon && !c->iskilling &&
|
if (c && c->mon == selmon && !c->iskilling &&
|
||||||
!client_is_unmanaged(c) && !c->isunglobal &&
|
!client_is_unmanaged(c) && !c->isunglobal &&
|
||||||
!client_should_ignore_focus(c) && client_surface(c)->mapped)
|
!client_is_x11_popup(c) && client_surface(c)->mapped)
|
||||||
overview_restore(c, &(Arg){.ui = target});
|
overview_restore(c, &(Arg){.ui = target});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view(&(Arg){.ui = target}, false);
|
view(&(Arg){.ui = target}, false);
|
||||||
|
|
||||||
if (ov_tab_mode && selmon->isoverview && selmon->sel) {
|
|
||||||
focusstack(&(Arg){.i = 1});
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh_monitors_workspaces_status(selmon);
|
refresh_monitors_workspaces_status(selmon);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int disable_monitor(const Arg *arg) {
|
||||||
|
Monitor *m = NULL;
|
||||||
|
struct wlr_output_state state = {0};
|
||||||
|
wl_list_for_each(m, &mons, link) {
|
||||||
|
if (regex_match(arg->v, m->wlr_output->name)) {
|
||||||
|
wlr_output_state_set_enabled(&state, false);
|
||||||
|
wlr_output_commit_state(m->wlr_output, &state);
|
||||||
|
m->asleep = 1;
|
||||||
|
updatemons(NULL, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int enable_monitor(const Arg *arg) {
|
||||||
|
Monitor *m = NULL;
|
||||||
|
struct wlr_output_state state = {0};
|
||||||
|
wl_list_for_each(m, &mons, link) {
|
||||||
|
if (regex_match(arg->v, m->wlr_output->name)) {
|
||||||
|
wlr_output_state_set_enabled(&state, true);
|
||||||
|
wlr_output_commit_state(m->wlr_output, &state);
|
||||||
|
m->asleep = 0;
|
||||||
|
updatemons(NULL, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int toggle_monitor(const Arg *arg) {
|
||||||
|
Monitor *m = NULL;
|
||||||
|
struct wlr_output_state state = {0};
|
||||||
|
wl_list_for_each(m, &mons, link) {
|
||||||
|
if (regex_match(arg->v, m->wlr_output->name)) {
|
||||||
|
wlr_output_state_set_enabled(&state, !m->wlr_output->enabled);
|
||||||
|
wlr_output_commit_state(m->wlr_output, &state);
|
||||||
|
m->asleep = !m->wlr_output->enabled;
|
||||||
|
updatemons(NULL, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include "dwl-ipc.h"
|
#include "dwl-ipc.h"
|
||||||
#include "ext-workspace.h"
|
#include "ext-workspace.h"
|
||||||
#include "foreign-toplevel.h"
|
#include "foreign-toplevel.h"
|
||||||
#include "tablet.h"
|
#include "tearing.h"
|
||||||
#include "text-input.h"
|
#include "text-input.h"
|
||||||
|
|
|
||||||
|
|
@ -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,19 +99,22 @@ 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;
|
||||||
struct wlr_keyboard *keyboard;
|
struct wlr_keyboard *keyboard;
|
||||||
xkb_layout_index_t current;
|
xkb_layout_index_t current;
|
||||||
int tagmask, state, numclients, focused_client, tag;
|
int tagmask, state, numclients, focused_client, tag;
|
||||||
const char *title, *appid, *symbol, *kb_layout;
|
const char *title, *appid, *symbol;
|
||||||
|
char kb_layout[32];
|
||||||
focused = focustop(monitor);
|
focused = focustop(monitor);
|
||||||
zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon);
|
zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon);
|
||||||
|
|
||||||
|
|
@ -149,8 +150,8 @@ void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) {
|
||||||
keyboard = &kb_group->wlr_group->keyboard;
|
keyboard = &kb_group->wlr_group->keyboard;
|
||||||
current = xkb_state_serialize_layout(keyboard->xkb_state,
|
current = xkb_state_serialize_layout(keyboard->xkb_state,
|
||||||
XKB_STATE_LAYOUT_EFFECTIVE);
|
XKB_STATE_LAYOUT_EFFECTIVE);
|
||||||
kb_layout =
|
get_layout_abbr(kb_layout,
|
||||||
get_layout_abbr(xkb_keymap_layout_get_name(keyboard->keymap, current));
|
xkb_keymap_layout_get_name(keyboard->keymap, current));
|
||||||
|
|
||||||
zdwl_ipc_output_v2_send_layout(
|
zdwl_ipc_output_v2_send_layout(
|
||||||
ipc_output->resource,
|
ipc_output->resource,
|
||||||
|
|
@ -204,17 +205,22 @@ void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) {
|
||||||
zdwl_ipc_output_v2_send_keymode(ipc_output->resource, keymode.mode);
|
zdwl_ipc_output_v2_send_keymode(ipc_output->resource, keymode.mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wl_resource_get_version(ipc_output->resource) >=
|
||||||
|
ZDWL_IPC_OUTPUT_V2_SCALEFACTOR_SINCE_VERSION) {
|
||||||
|
zdwl_ipc_output_v2_send_scalefactor(ipc_output->resource,
|
||||||
|
monitor->wlr_output->scale * 100);
|
||||||
|
}
|
||||||
|
|
||||||
zdwl_ipc_output_v2_send_frame(ipc_output->resource);
|
zdwl_ipc_output_v2_send_frame(ipc_output->resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
|
@ -237,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;
|
||||||
|
|
||||||
|
|
@ -251,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)
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
#include "wlr_ext_workspace_v1.h"
|
#include "wlr_ext_workspace_v1.h"
|
||||||
|
|
||||||
#define EXT_WORKSPACE_ENABLE_CAPS \
|
#define EXT_WORKSPACE_ENABLE_CAPS \
|
||||||
WLR_EXT_WORKSPACE_HANDLE_V1_CAP_ACTIVATE | \
|
EXT_WORKSPACE_HANDLE_V1_WORKSPACE_CAPABILITIES_ACTIVATE | \
|
||||||
WLR_EXT_WORKSPACE_HANDLE_V1_CAP_DEACTIVATE
|
EXT_WORKSPACE_HANDLE_V1_WORKSPACE_CAPABILITIES_DEACTIVATE
|
||||||
|
|
||||||
typedef struct Monitor Monitor;
|
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) {
|
||||||
|
|
@ -134,6 +144,10 @@ void dwl_ext_workspace_printstatus(Monitor *m) {
|
||||||
if (!w->m->pertag->no_hide[w->tag])
|
if (!w->m->pertag->no_hide[w->tag])
|
||||||
wlr_ext_workspace_handle_v1_set_hidden(w->ext_workspace,
|
wlr_ext_workspace_handle_v1_set_hidden(w->ext_workspace,
|
||||||
true);
|
true);
|
||||||
|
else {
|
||||||
|
wlr_ext_workspace_handle_v1_set_hidden(w->ext_workspace,
|
||||||
|
false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m->tagset[m->seltags] & (1 << (w->tag - 1)) & TAGMASK) ||
|
if ((m->tagset[m->seltags] & (1 << (w->tag - 1)) & TAGMASK) ||
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
171
src/ext-protocol/tearing.h
Normal file
|
|
@ -0,0 +1,171 @@
|
||||||
|
#include <wlr/types/wlr_tearing_control_v1.h>
|
||||||
|
|
||||||
|
struct tearing_controller {
|
||||||
|
struct wlr_tearing_control_v1 *tearing_control;
|
||||||
|
struct wl_listener set_hint;
|
||||||
|
struct wl_listener destroy;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct wlr_tearing_control_manager_v1 *tearing_control;
|
||||||
|
struct wl_listener tearing_new_object;
|
||||||
|
|
||||||
|
static void handle_controller_set_hint(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct tearing_controller *controller =
|
||||||
|
wl_container_of(listener, controller, set_hint);
|
||||||
|
Client *c = NULL;
|
||||||
|
|
||||||
|
toplevel_from_wlr_surface(controller->tearing_control->surface, &c, NULL);
|
||||||
|
|
||||||
|
if (c) {
|
||||||
|
/*
|
||||||
|
* tearing_control->current is actually an enum:
|
||||||
|
* WP_TEARING_CONTROL_V1_PRESENTATION_HINT_VSYNC = 0
|
||||||
|
* WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC = 1
|
||||||
|
*
|
||||||
|
* Using it as a bool here allows us to not ship the XML.
|
||||||
|
*/
|
||||||
|
c->tearing_hint = controller->tearing_control->current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_controller_destroy(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct tearing_controller *controller =
|
||||||
|
wl_container_of(listener, controller, destroy);
|
||||||
|
wl_list_remove(&controller->set_hint.link);
|
||||||
|
wl_list_remove(&controller->destroy.link);
|
||||||
|
free(controller);
|
||||||
|
}
|
||||||
|
|
||||||
|
void handle_tearing_new_object(struct wl_listener *listener, void *data) {
|
||||||
|
struct wlr_tearing_control_v1 *new_tearing_control = data;
|
||||||
|
|
||||||
|
enum wp_tearing_control_v1_presentation_hint hint =
|
||||||
|
wlr_tearing_control_manager_v1_surface_hint_from_surface(
|
||||||
|
tearing_control, new_tearing_control->surface);
|
||||||
|
wlr_log(WLR_DEBUG, "New presentation hint %d received for surface %p", hint,
|
||||||
|
new_tearing_control->surface);
|
||||||
|
|
||||||
|
struct tearing_controller *controller =
|
||||||
|
ecalloc(1, sizeof(struct tearing_controller));
|
||||||
|
controller->tearing_control = new_tearing_control;
|
||||||
|
|
||||||
|
controller->set_hint.notify = handle_controller_set_hint;
|
||||||
|
wl_signal_add(&new_tearing_control->events.set_hint, &controller->set_hint);
|
||||||
|
|
||||||
|
controller->destroy.notify = handle_controller_destroy;
|
||||||
|
wl_signal_add(&new_tearing_control->events.destroy, &controller->destroy);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool check_tearing_frame_allow(Monitor *m) {
|
||||||
|
/* never allow tearing when disabled */
|
||||||
|
if (!allow_tearing) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Client *c = selmon->sel;
|
||||||
|
|
||||||
|
/* tearing is only allowed for the output with the active client */
|
||||||
|
if (!c || c->mon != m) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* allow tearing for any window when requested or forced */
|
||||||
|
if (allow_tearing == TEARING_ENABLED) {
|
||||||
|
if (c->force_tearing == STATE_UNSPECIFIED) {
|
||||||
|
return c->tearing_hint;
|
||||||
|
} else {
|
||||||
|
return c->force_tearing == STATE_ENABLED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* remaining tearing options apply only to full-screen windows */
|
||||||
|
if (!c->isfullscreen) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c->force_tearing == STATE_UNSPECIFIED) {
|
||||||
|
/* honor the tearing hint or the fullscreen-force preference */
|
||||||
|
return c->tearing_hint || allow_tearing == TEARING_FULLSCREEN_ONLY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* honor tearing as requested by action */
|
||||||
|
return c->force_tearing == STATE_ENABLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool custom_wlr_scene_output_commit(struct wlr_scene_output *scene_output,
|
||||||
|
struct wlr_output_state *state) {
|
||||||
|
struct wlr_output *wlr_output = scene_output->output;
|
||||||
|
Monitor *m = wlr_output->data;
|
||||||
|
|
||||||
|
// 检查是否需要帧
|
||||||
|
if (!wlr_scene_output_needs_frame(scene_output)) {
|
||||||
|
wlr_log(WLR_DEBUG, "No frame needed for output %s", wlr_output->name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建输出状态
|
||||||
|
if (!wlr_scene_output_build_state(scene_output, state, NULL)) {
|
||||||
|
wlr_log(WLR_ERROR, "Failed to build output state for %s",
|
||||||
|
wlr_output->name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 测试撕裂翻页
|
||||||
|
if (state->tearing_page_flip) {
|
||||||
|
if (!wlr_output_test_state(wlr_output, state)) {
|
||||||
|
state->tearing_page_flip = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 尝试提交
|
||||||
|
bool committed = wlr_output_commit_state(wlr_output, state);
|
||||||
|
|
||||||
|
// 如果启用撕裂翻页但提交失败,重试禁用撕裂翻页
|
||||||
|
if (!committed && state->tearing_page_flip) {
|
||||||
|
wlr_log(WLR_DEBUG, "Retrying commit without tearing for %s",
|
||||||
|
wlr_output->name);
|
||||||
|
state->tearing_page_flip = false;
|
||||||
|
committed = wlr_output_commit_state(wlr_output, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理状态清理
|
||||||
|
if (committed) {
|
||||||
|
wlr_log(WLR_DEBUG, "Successfully committed output %s",
|
||||||
|
wlr_output->name);
|
||||||
|
if (state == &m->pending) {
|
||||||
|
wlr_output_state_finish(&m->pending);
|
||||||
|
wlr_output_state_init(&m->pending);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wlr_log(WLR_ERROR, "Failed to commit output %s", wlr_output->name);
|
||||||
|
// 即使提交失败,也清理状态避免积累
|
||||||
|
if (state == &m->pending) {
|
||||||
|
wlr_output_state_finish(&m->pending);
|
||||||
|
wlr_output_state_init(&m->pending);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void apply_tear_state(Monitor *m) {
|
||||||
|
if (wlr_scene_output_needs_frame(m->scene_output)) {
|
||||||
|
wlr_output_state_init(&m->pending);
|
||||||
|
if (wlr_scene_output_build_state(m->scene_output, &m->pending, NULL)) {
|
||||||
|
struct wlr_output_state *pending = &m->pending;
|
||||||
|
pending->tearing_page_flip = true;
|
||||||
|
|
||||||
|
if (!custom_wlr_scene_output_commit(m->scene_output, pending)) {
|
||||||
|
wlr_log(WLR_ERROR, "Failed to commit output %s",
|
||||||
|
m->scene_output->output->name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wlr_log(WLR_ERROR, "Failed to build state for output %s",
|
||||||
|
m->scene_output->output->name);
|
||||||
|
wlr_output_state_finish(&m->pending);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ struct wlr_ext_workspace_v1_request {
|
||||||
// ACTIVATE / DEACTIVATE / ASSIGN / REMOVE
|
// ACTIVATE / DEACTIVATE / ASSIGN / REMOVE
|
||||||
struct wlr_ext_workspace_handle_v1 *workspace;
|
struct wlr_ext_workspace_handle_v1 *workspace;
|
||||||
|
|
||||||
struct wl_list link; // wlr_ext_workspace_manager_client_v1.requests
|
struct wl_list link; // wlr_ext_workspace_manager_v1_resource.requests
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_ext_workspace_v1_group_output {
|
struct wlr_ext_workspace_v1_group_output {
|
||||||
|
|
@ -41,33 +41,40 @@ struct wlr_ext_workspace_v1_group_output {
|
||||||
};
|
};
|
||||||
|
|
||||||
// These structs wrap wl_resource of each interface to access the request queue
|
// These structs wrap wl_resource of each interface to access the request queue
|
||||||
// (wlr_ext_workspace_manager_client_v1.requests) assigned per manager resource
|
// (wlr_ext_workspace_manager_v1_resource.requests) assigned per manager
|
||||||
|
// resource
|
||||||
|
|
||||||
struct wlr_ext_workspace_manager_client_v1 {
|
struct wlr_ext_workspace_manager_v1_resource {
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
struct wlr_ext_workspace_manager_v1 *manager;
|
struct wlr_ext_workspace_manager_v1 *manager;
|
||||||
struct wl_list requests; // wlr_ext_workspace_v1_request.link
|
struct wl_list requests; // wlr_ext_workspace_v1_request.link
|
||||||
struct wl_list link; // wlr_ext_workspace_manager_v1.clients
|
struct wl_list workspace_resources; // wlr_ext_workspace_v1_resource.link
|
||||||
|
struct wl_list group_resources; // wlr_ext_workspace_group_v1_resource.link
|
||||||
|
struct wl_list link; // wlr_ext_workspace_manager_v1.resources
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_ext_workspace_group_client_v1 {
|
struct wlr_ext_workspace_group_v1_resource {
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
struct wlr_ext_workspace_group_handle_v1 *group;
|
struct wlr_ext_workspace_group_handle_v1 *group;
|
||||||
struct wlr_ext_workspace_manager_client_v1 *manager;
|
struct wlr_ext_workspace_manager_v1_resource *manager;
|
||||||
struct wl_list link; // wlr_ext_workspace_group_v1.clients
|
struct wl_list link; // wlr_ext_workspace_group_v1.resources
|
||||||
|
struct wl_list
|
||||||
|
manager_resource_link; // wlr_ext_workspace_manager_v1_resource.group_resources
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_ext_workspace_client_v1 {
|
struct wlr_ext_workspace_v1_resource {
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
struct wlr_ext_workspace_handle_v1 *workspace;
|
struct wlr_ext_workspace_handle_v1 *workspace;
|
||||||
struct wlr_ext_workspace_manager_client_v1 *manager;
|
struct wlr_ext_workspace_manager_v1_resource *manager;
|
||||||
struct wl_list link; // wlr_ext_workspace_v1.clients
|
struct wl_list link; // wlr_ext_workspace_v1.resources
|
||||||
|
struct wl_list
|
||||||
|
manager_resource_link; // wlr_ext_workspace_manager_v1_resource.workspace_resources
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct ext_workspace_group_handle_v1_interface group_impl;
|
static const struct ext_workspace_group_handle_v1_interface group_impl;
|
||||||
|
|
||||||
static struct wlr_ext_workspace_group_client_v1 *
|
static struct wlr_ext_workspace_group_v1_resource *
|
||||||
group_client_from_resource(struct wl_resource *resource) {
|
group_resource_from_resource(struct wl_resource *resource) {
|
||||||
assert(wl_resource_instance_of(
|
assert(wl_resource_instance_of(
|
||||||
resource, &ext_workspace_group_handle_v1_interface, &group_impl));
|
resource, &ext_workspace_group_handle_v1_interface, &group_impl));
|
||||||
return wl_resource_get_user_data(resource);
|
return wl_resource_get_user_data(resource);
|
||||||
|
|
@ -75,8 +82,8 @@ group_client_from_resource(struct wl_resource *resource) {
|
||||||
|
|
||||||
static const struct ext_workspace_handle_v1_interface workspace_impl;
|
static const struct ext_workspace_handle_v1_interface workspace_impl;
|
||||||
|
|
||||||
static struct wlr_ext_workspace_client_v1 *
|
static struct wlr_ext_workspace_v1_resource *
|
||||||
workspace_client_from_resource(struct wl_resource *resource) {
|
workspace_resource_from_resource(struct wl_resource *resource) {
|
||||||
assert(wl_resource_instance_of(resource, &ext_workspace_handle_v1_interface,
|
assert(wl_resource_instance_of(resource, &ext_workspace_handle_v1_interface,
|
||||||
&workspace_impl));
|
&workspace_impl));
|
||||||
return wl_resource_get_user_data(resource);
|
return wl_resource_get_user_data(resource);
|
||||||
|
|
@ -84,8 +91,8 @@ workspace_client_from_resource(struct wl_resource *resource) {
|
||||||
|
|
||||||
static const struct ext_workspace_manager_v1_interface manager_impl;
|
static const struct ext_workspace_manager_v1_interface manager_impl;
|
||||||
|
|
||||||
static struct wlr_ext_workspace_manager_client_v1 *
|
static struct wlr_ext_workspace_manager_v1_resource *
|
||||||
manager_client_from_resource(struct wl_resource *resource) {
|
manager_resource_from_resource(struct wl_resource *resource) {
|
||||||
assert(wl_resource_instance_of(
|
assert(wl_resource_instance_of(
|
||||||
resource, &ext_workspace_manager_v1_interface, &manager_impl));
|
resource, &ext_workspace_manager_v1_interface, &manager_impl));
|
||||||
return wl_resource_get_user_data(resource);
|
return wl_resource_get_user_data(resource);
|
||||||
|
|
@ -98,9 +105,9 @@ static void workspace_handle_destroy(struct wl_client *client,
|
||||||
|
|
||||||
static void workspace_handle_activate(struct wl_client *client,
|
static void workspace_handle_activate(struct wl_client *client,
|
||||||
struct wl_resource *workspace_resource) {
|
struct wl_resource *workspace_resource) {
|
||||||
struct wlr_ext_workspace_client_v1 *workspace =
|
struct wlr_ext_workspace_v1_resource *workspace_res =
|
||||||
workspace_client_from_resource(workspace_resource);
|
workspace_resource_from_resource(workspace_resource);
|
||||||
if (!workspace) {
|
if (!workspace_res) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,16 +117,16 @@ static void workspace_handle_activate(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_ACTIVATE;
|
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_ACTIVATE;
|
||||||
req->workspace = workspace->workspace;
|
req->workspace = workspace_res->workspace;
|
||||||
wl_list_insert(workspace->manager->requests.prev, &req->link);
|
wl_list_insert(workspace_res->manager->requests.prev, &req->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
workspace_handle_deactivate(struct wl_client *client,
|
workspace_handle_deactivate(struct wl_client *client,
|
||||||
struct wl_resource *workspace_resource) {
|
struct wl_resource *workspace_resource) {
|
||||||
struct wlr_ext_workspace_client_v1 *workspace =
|
struct wlr_ext_workspace_v1_resource *workspace_res =
|
||||||
workspace_client_from_resource(workspace_resource);
|
workspace_resource_from_resource(workspace_resource);
|
||||||
if (!workspace) {
|
if (!workspace_res) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,18 +136,18 @@ workspace_handle_deactivate(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_DEACTIVATE;
|
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_DEACTIVATE;
|
||||||
req->workspace = workspace->workspace;
|
req->workspace = workspace_res->workspace;
|
||||||
wl_list_insert(workspace->manager->requests.prev, &req->link);
|
wl_list_insert(workspace_res->manager->requests.prev, &req->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void workspace_handle_assign(struct wl_client *client,
|
static void workspace_handle_assign(struct wl_client *client,
|
||||||
struct wl_resource *workspace_resource,
|
struct wl_resource *workspace_resource,
|
||||||
struct wl_resource *group_resource) {
|
struct wl_resource *group_resource) {
|
||||||
struct wlr_ext_workspace_client_v1 *workspace =
|
struct wlr_ext_workspace_v1_resource *workspace_res =
|
||||||
workspace_client_from_resource(workspace_resource);
|
workspace_resource_from_resource(workspace_resource);
|
||||||
struct wlr_ext_workspace_group_client_v1 *group =
|
struct wlr_ext_workspace_group_v1_resource *group_res =
|
||||||
group_client_from_resource(group_resource);
|
group_resource_from_resource(group_resource);
|
||||||
if (!workspace || !group) {
|
if (!workspace_res || !group_res) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,16 +157,16 @@ static void workspace_handle_assign(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_ASSIGN;
|
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_ASSIGN;
|
||||||
req->group = group->group;
|
req->group = group_res->group;
|
||||||
req->workspace = workspace->workspace;
|
req->workspace = workspace_res->workspace;
|
||||||
wl_list_insert(workspace->manager->requests.prev, &req->link);
|
wl_list_insert(workspace_res->manager->requests.prev, &req->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void workspace_handle_remove(struct wl_client *client,
|
static void workspace_handle_remove(struct wl_client *client,
|
||||||
struct wl_resource *workspace_resource) {
|
struct wl_resource *workspace_resource) {
|
||||||
struct wlr_ext_workspace_client_v1 *workspace =
|
struct wlr_ext_workspace_v1_resource *workspace_res =
|
||||||
workspace_client_from_resource(workspace_resource);
|
workspace_resource_from_resource(workspace_resource);
|
||||||
if (!workspace) {
|
if (!workspace_res) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -169,8 +176,8 @@ static void workspace_handle_remove(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_REMOVE;
|
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_REMOVE;
|
||||||
req->workspace = workspace->workspace;
|
req->workspace = workspace_res->workspace;
|
||||||
wl_list_insert(workspace->manager->requests.prev, &req->link);
|
wl_list_insert(workspace_res->manager->requests.prev, &req->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct ext_workspace_handle_v1_interface workspace_impl = {
|
static const struct ext_workspace_handle_v1_interface workspace_impl = {
|
||||||
|
|
@ -184,9 +191,9 @@ static const struct ext_workspace_handle_v1_interface workspace_impl = {
|
||||||
static void group_handle_create_workspace(struct wl_client *client,
|
static void group_handle_create_workspace(struct wl_client *client,
|
||||||
struct wl_resource *group_resource,
|
struct wl_resource *group_resource,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
struct wlr_ext_workspace_group_client_v1 *group =
|
struct wlr_ext_workspace_group_v1_resource *group_res =
|
||||||
group_client_from_resource(group_resource);
|
group_resource_from_resource(group_resource);
|
||||||
if (!group) {
|
if (!group_res) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -195,9 +202,15 @@ static void group_handle_create_workspace(struct wl_client *client,
|
||||||
wl_resource_post_no_memory(group_resource);
|
wl_resource_post_no_memory(group_resource);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
req->name = strdup(name);
|
||||||
|
if (!req->name) {
|
||||||
|
free(req);
|
||||||
|
wl_resource_post_no_memory(group_resource);
|
||||||
|
return;
|
||||||
|
}
|
||||||
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_CREATE_WORKSPACE;
|
req->type = WLR_EXT_WORKSPACE_V1_REQUEST_CREATE_WORKSPACE;
|
||||||
req->group = group->group;
|
req->group = group_res->group;
|
||||||
wl_list_insert(group->manager->requests.prev, &req->link);
|
wl_list_insert(group_res->manager->requests.prev, &req->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void group_handle_destroy(struct wl_client *client,
|
static void group_handle_destroy(struct wl_client *client,
|
||||||
|
|
@ -210,89 +223,94 @@ static const struct ext_workspace_group_handle_v1_interface group_impl = {
|
||||||
.destroy = group_handle_destroy,
|
.destroy = group_handle_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void destroy_workspace_resource(
|
||||||
destroy_workspace_client(struct wlr_ext_workspace_client_v1 *workspace_client) {
|
struct wlr_ext_workspace_v1_resource *workspace_res) {
|
||||||
wl_list_remove(&workspace_client->link);
|
wl_list_remove(&workspace_res->link);
|
||||||
wl_resource_set_user_data(workspace_client->resource, NULL);
|
wl_list_remove(&workspace_res->manager_resource_link);
|
||||||
free(workspace_client);
|
wl_resource_set_user_data(workspace_res->resource, NULL);
|
||||||
|
free(workspace_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void workspace_resource_destroy(struct wl_resource *resource) {
|
static void workspace_resource_destroy(struct wl_resource *resource) {
|
||||||
struct wlr_ext_workspace_client_v1 *workspace_client =
|
struct wlr_ext_workspace_v1_resource *workspace_res =
|
||||||
workspace_client_from_resource(resource);
|
workspace_resource_from_resource(resource);
|
||||||
if (workspace_client) {
|
if (workspace_res) {
|
||||||
destroy_workspace_client(workspace_client);
|
destroy_workspace_resource(workspace_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct wlr_ext_workspace_client_v1 *create_workspace_client(
|
static struct wlr_ext_workspace_v1_resource *create_workspace_resource(
|
||||||
struct wlr_ext_workspace_handle_v1 *workspace,
|
struct wlr_ext_workspace_handle_v1 *workspace,
|
||||||
struct wlr_ext_workspace_manager_client_v1 *manager_client) {
|
struct wlr_ext_workspace_manager_v1_resource *manager_res) {
|
||||||
struct wlr_ext_workspace_client_v1 *workspace_client =
|
struct wlr_ext_workspace_v1_resource *workspace_res =
|
||||||
calloc(1, sizeof(*workspace_client));
|
calloc(1, sizeof(*workspace_res));
|
||||||
if (!workspace_client) {
|
if (!workspace_res) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wl_client *client = wl_resource_get_client(manager_client->resource);
|
struct wl_client *client = wl_resource_get_client(manager_res->resource);
|
||||||
workspace_client->resource = wl_resource_create(
|
workspace_res->resource =
|
||||||
client, &ext_workspace_handle_v1_interface,
|
wl_resource_create(client, &ext_workspace_handle_v1_interface,
|
||||||
wl_resource_get_version(manager_client->resource), 0);
|
wl_resource_get_version(manager_res->resource), 0);
|
||||||
if (!workspace_client->resource) {
|
if (!workspace_res->resource) {
|
||||||
free(workspace_client);
|
free(workspace_res);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
wl_resource_set_implementation(workspace_client->resource, &workspace_impl,
|
wl_resource_set_implementation(workspace_res->resource, &workspace_impl,
|
||||||
workspace_client,
|
workspace_res, workspace_resource_destroy);
|
||||||
workspace_resource_destroy);
|
|
||||||
|
|
||||||
workspace_client->workspace = workspace;
|
workspace_res->workspace = workspace;
|
||||||
workspace_client->manager = manager_client;
|
workspace_res->manager = manager_res;
|
||||||
wl_list_insert(&workspace->clients, &workspace_client->link);
|
wl_list_insert(&workspace->resources, &workspace_res->link);
|
||||||
|
wl_list_insert(&manager_res->workspace_resources,
|
||||||
|
&workspace_res->manager_resource_link);
|
||||||
|
|
||||||
return workspace_client;
|
return workspace_res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
destroy_group_client(struct wlr_ext_workspace_group_client_v1 *group_client) {
|
destroy_group_resource(struct wlr_ext_workspace_group_v1_resource *group_res) {
|
||||||
wl_list_remove(&group_client->link);
|
wl_list_remove(&group_res->link);
|
||||||
wl_resource_set_user_data(group_client->resource, NULL);
|
wl_list_remove(&group_res->manager_resource_link);
|
||||||
free(group_client);
|
wl_resource_set_user_data(group_res->resource, NULL);
|
||||||
|
free(group_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void group_handle_resource_destroy(struct wl_resource *resource) {
|
static void group_handle_resource_destroy(struct wl_resource *resource) {
|
||||||
struct wlr_ext_workspace_group_client_v1 *group_client =
|
struct wlr_ext_workspace_group_v1_resource *group_res =
|
||||||
group_client_from_resource(resource);
|
group_resource_from_resource(resource);
|
||||||
if (group_client) {
|
if (group_res) {
|
||||||
destroy_group_client(group_client);
|
destroy_group_resource(group_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct wlr_ext_workspace_group_client_v1 *create_group_client(
|
static struct wlr_ext_workspace_group_v1_resource *create_group_resource(
|
||||||
struct wlr_ext_workspace_group_handle_v1 *group,
|
struct wlr_ext_workspace_group_handle_v1 *group,
|
||||||
struct wlr_ext_workspace_manager_client_v1 *manager_client) {
|
struct wlr_ext_workspace_manager_v1_resource *manager_res) {
|
||||||
struct wlr_ext_workspace_group_client_v1 *group_client =
|
struct wlr_ext_workspace_group_v1_resource *group_res =
|
||||||
calloc(1, sizeof(*group_client));
|
calloc(1, sizeof(*group_res));
|
||||||
if (!group_client) {
|
if (!group_res) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wl_client *client = wl_resource_get_client(manager_client->resource);
|
struct wl_client *client = wl_resource_get_client(manager_res->resource);
|
||||||
uint32_t version = wl_resource_get_version(manager_client->resource);
|
uint32_t version = wl_resource_get_version(manager_res->resource);
|
||||||
group_client->resource = wl_resource_create(
|
group_res->resource = wl_resource_create(
|
||||||
client, &ext_workspace_group_handle_v1_interface, version, 0);
|
client, &ext_workspace_group_handle_v1_interface, version, 0);
|
||||||
if (group_client->resource == NULL) {
|
if (group_res->resource == NULL) {
|
||||||
free(group_client);
|
free(group_res);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
wl_resource_set_implementation(group_client->resource, &group_impl,
|
wl_resource_set_implementation(group_res->resource, &group_impl, group_res,
|
||||||
group_client, group_handle_resource_destroy);
|
group_handle_resource_destroy);
|
||||||
|
|
||||||
group_client->group = group;
|
group_res->group = group;
|
||||||
group_client->manager = manager_client;
|
group_res->manager = manager_res;
|
||||||
wl_list_insert(&group->clients, &group_client->link);
|
wl_list_insert(&group->resources, &group_res->link);
|
||||||
|
wl_list_insert(&manager_res->group_resources,
|
||||||
|
&group_res->manager_resource_link);
|
||||||
|
|
||||||
return group_client;
|
return group_res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroy_request(struct wlr_ext_workspace_v1_request *req) {
|
static void destroy_request(struct wlr_ext_workspace_v1_request *req) {
|
||||||
|
|
@ -303,18 +321,22 @@ static void destroy_request(struct wlr_ext_workspace_v1_request *req) {
|
||||||
|
|
||||||
static void manager_handle_commit(struct wl_client *client,
|
static void manager_handle_commit(struct wl_client *client,
|
||||||
struct wl_resource *resource) {
|
struct wl_resource *resource) {
|
||||||
struct wlr_ext_workspace_manager_client_v1 *manager =
|
struct wlr_ext_workspace_manager_v1_resource *manager_res =
|
||||||
manager_client_from_resource(resource);
|
manager_resource_from_resource(resource);
|
||||||
if (!manager) {
|
if (!manager_res) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_ext_workspace_v1_request *req, *tmp;
|
struct wlr_ext_workspace_v1_request *req, *tmp;
|
||||||
wl_list_for_each_safe(req, tmp, &manager->requests, link) {
|
wl_list_for_each_safe(req, tmp, &manager_res->requests, link) {
|
||||||
switch (req->type) {
|
switch (req->type) {
|
||||||
case WLR_EXT_WORKSPACE_V1_REQUEST_CREATE_WORKSPACE:
|
case WLR_EXT_WORKSPACE_V1_REQUEST_CREATE_WORKSPACE:;
|
||||||
|
struct wlr_ext_workspace_group_handle_v1_create_workspace_event
|
||||||
|
event = {
|
||||||
|
.name = req->name,
|
||||||
|
};
|
||||||
wl_signal_emit_mutable(&req->group->events.create_workspace,
|
wl_signal_emit_mutable(&req->group->events.create_workspace,
|
||||||
req->name);
|
&event);
|
||||||
break;
|
break;
|
||||||
case WLR_EXT_WORKSPACE_V1_REQUEST_ACTIVATE:
|
case WLR_EXT_WORKSPACE_V1_REQUEST_ACTIVATE:
|
||||||
wl_signal_emit_mutable(&req->workspace->events.activate, NULL);
|
wl_signal_emit_mutable(&req->workspace->events.activate, NULL);
|
||||||
|
|
@ -323,13 +345,11 @@ static void manager_handle_commit(struct wl_client *client,
|
||||||
wl_signal_emit_mutable(&req->workspace->events.deactivate, NULL);
|
wl_signal_emit_mutable(&req->workspace->events.deactivate, NULL);
|
||||||
break;
|
break;
|
||||||
case WLR_EXT_WORKSPACE_V1_REQUEST_ASSIGN:
|
case WLR_EXT_WORKSPACE_V1_REQUEST_ASSIGN:
|
||||||
wl_signal_emit_mutable(&req->workspace->events.assign, &req->group);
|
wl_signal_emit_mutable(&req->workspace->events.assign, req->group);
|
||||||
break;
|
break;
|
||||||
case WLR_EXT_WORKSPACE_V1_REQUEST_REMOVE:
|
case WLR_EXT_WORKSPACE_V1_REQUEST_REMOVE:
|
||||||
wl_signal_emit_mutable(&req->workspace->events.remove, NULL);
|
wl_signal_emit_mutable(&req->workspace->events.remove, NULL);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
destroy_request(req);
|
destroy_request(req);
|
||||||
}
|
}
|
||||||
|
|
@ -338,9 +358,9 @@ static void manager_handle_commit(struct wl_client *client,
|
||||||
static void handle_idle(void *data) {
|
static void handle_idle(void *data) {
|
||||||
struct wlr_ext_workspace_manager_v1 *manager = data;
|
struct wlr_ext_workspace_manager_v1 *manager = data;
|
||||||
|
|
||||||
struct wlr_ext_workspace_manager_client_v1 *manager_client;
|
struct wlr_ext_workspace_manager_v1_resource *manager_res;
|
||||||
wl_list_for_each(manager_client, &manager->clients, link) {
|
wl_list_for_each(manager_res, &manager->resources, link) {
|
||||||
ext_workspace_manager_v1_send_done(manager_client->resource);
|
ext_workspace_manager_v1_send_done(manager_res->resource);
|
||||||
}
|
}
|
||||||
manager->idle_source = NULL;
|
manager->idle_source = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -354,9 +374,9 @@ manager_schedule_done(struct wlr_ext_workspace_manager_v1 *manager) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
workspace_send_details(struct wlr_ext_workspace_client_v1 *workspace_client) {
|
workspace_send_details(struct wlr_ext_workspace_v1_resource *workspace_res) {
|
||||||
struct wlr_ext_workspace_handle_v1 *workspace = workspace_client->workspace;
|
struct wlr_ext_workspace_handle_v1 *workspace = workspace_res->workspace;
|
||||||
struct wl_resource *resource = workspace_client->resource;
|
struct wl_resource *resource = workspace_res->resource;
|
||||||
|
|
||||||
ext_workspace_handle_v1_send_capabilities(resource, workspace->caps);
|
ext_workspace_handle_v1_send_capabilities(resource, workspace->caps);
|
||||||
if (workspace->coordinates.size > 0) {
|
if (workspace->coordinates.size > 0) {
|
||||||
|
|
@ -384,29 +404,41 @@ static const struct ext_workspace_manager_v1_interface manager_impl = {
|
||||||
.stop = manager_handle_stop,
|
.stop = manager_handle_stop,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void destroy_manager_client(
|
static void destroy_manager_resource(
|
||||||
struct wlr_ext_workspace_manager_client_v1 *manager_client) {
|
struct wlr_ext_workspace_manager_v1_resource *manager_res) {
|
||||||
struct wlr_ext_workspace_v1_request *req, *tmp;
|
struct wlr_ext_workspace_v1_request *req, *tmp;
|
||||||
wl_list_for_each_safe(req, tmp, &manager_client->requests, link) {
|
wl_list_for_each_safe(req, tmp, &manager_res->requests, link) {
|
||||||
destroy_request(req);
|
destroy_request(req);
|
||||||
}
|
}
|
||||||
wl_list_remove(&manager_client->link);
|
struct wlr_ext_workspace_v1_resource *workspace_res, *tmp2;
|
||||||
wl_resource_set_user_data(manager_client->resource, NULL);
|
wl_list_for_each_safe(workspace_res, tmp2,
|
||||||
free(manager_client);
|
&manager_res->workspace_resources,
|
||||||
|
manager_resource_link) {
|
||||||
|
destroy_workspace_resource(workspace_res);
|
||||||
|
}
|
||||||
|
struct wlr_ext_workspace_group_v1_resource *group_res, *tmp3;
|
||||||
|
wl_list_for_each_safe(group_res, tmp3, &manager_res->group_resources,
|
||||||
|
manager_resource_link) {
|
||||||
|
destroy_group_resource(group_res);
|
||||||
|
}
|
||||||
|
|
||||||
|
wl_list_remove(&manager_res->link);
|
||||||
|
wl_resource_set_user_data(manager_res->resource, NULL);
|
||||||
|
free(manager_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void manager_resource_destroy(struct wl_resource *resource) {
|
static void manager_resource_destroy(struct wl_resource *resource) {
|
||||||
struct wlr_ext_workspace_manager_client_v1 *manager_client =
|
struct wlr_ext_workspace_manager_v1_resource *manager_res =
|
||||||
manager_client_from_resource(resource);
|
manager_resource_from_resource(resource);
|
||||||
if (manager_client) {
|
if (manager_res) {
|
||||||
destroy_manager_client(manager_client);
|
destroy_manager_resource(manager_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
group_send_details(struct wlr_ext_workspace_group_client_v1 *group_client) {
|
group_send_details(struct wlr_ext_workspace_group_v1_resource *group_res) {
|
||||||
struct wlr_ext_workspace_group_handle_v1 *group = group_client->group;
|
struct wlr_ext_workspace_group_handle_v1 *group = group_res->group;
|
||||||
struct wl_resource *resource = group_client->resource;
|
struct wl_resource *resource = group_res->resource;
|
||||||
struct wl_client *client = wl_resource_get_client(resource);
|
struct wl_client *client = wl_resource_get_client(resource);
|
||||||
|
|
||||||
ext_workspace_group_handle_v1_send_capabilities(resource, group->caps);
|
ext_workspace_group_handle_v1_send_capabilities(resource, group->caps);
|
||||||
|
|
@ -430,65 +462,67 @@ static void manager_bind(struct wl_client *client, void *data, uint32_t version,
|
||||||
uint32_t id) {
|
uint32_t id) {
|
||||||
struct wlr_ext_workspace_manager_v1 *manager = data;
|
struct wlr_ext_workspace_manager_v1 *manager = data;
|
||||||
|
|
||||||
struct wlr_ext_workspace_manager_client_v1 *manager_client =
|
struct wlr_ext_workspace_manager_v1_resource *manager_res =
|
||||||
calloc(1, sizeof(*manager_client));
|
calloc(1, sizeof(*manager_res));
|
||||||
if (!manager_client) {
|
if (!manager_res) {
|
||||||
wl_client_post_no_memory(client);
|
wl_client_post_no_memory(client);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
manager_client->manager = manager;
|
manager_res->manager = manager;
|
||||||
wl_list_init(&manager_client->requests);
|
wl_list_init(&manager_res->requests);
|
||||||
wl_list_insert(&manager->clients, &manager_client->link);
|
wl_list_init(&manager_res->workspace_resources);
|
||||||
|
wl_list_init(&manager_res->group_resources);
|
||||||
|
|
||||||
manager_client->resource = wl_resource_create(
|
manager_res->resource = wl_resource_create(
|
||||||
client, &ext_workspace_manager_v1_interface, version, id);
|
client, &ext_workspace_manager_v1_interface, version, id);
|
||||||
if (!manager_client->resource) {
|
if (!manager_res->resource) {
|
||||||
free(manager_client);
|
free(manager_res);
|
||||||
wl_client_post_no_memory(client);
|
wl_client_post_no_memory(client);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wl_resource_set_implementation(manager_client->resource, &manager_impl,
|
wl_resource_set_implementation(manager_res->resource, &manager_impl,
|
||||||
manager_client, manager_resource_destroy);
|
manager_res, manager_resource_destroy);
|
||||||
|
wl_list_insert(&manager->resources, &manager_res->link);
|
||||||
|
|
||||||
struct wlr_ext_workspace_group_handle_v1 *group;
|
struct wlr_ext_workspace_group_handle_v1 *group;
|
||||||
wl_list_for_each(group, &manager->groups, link) {
|
wl_list_for_each(group, &manager->groups, link) {
|
||||||
struct wlr_ext_workspace_group_client_v1 *group_client =
|
struct wlr_ext_workspace_group_v1_resource *group_res =
|
||||||
create_group_client(group, manager_client);
|
create_group_resource(group, manager_res);
|
||||||
if (!group_client) {
|
if (!group_res) {
|
||||||
wl_resource_post_no_memory(manager_client->resource);
|
wl_resource_post_no_memory(manager_res->resource);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ext_workspace_manager_v1_send_workspace_group(manager_client->resource,
|
ext_workspace_manager_v1_send_workspace_group(manager_res->resource,
|
||||||
group_client->resource);
|
group_res->resource);
|
||||||
group_send_details(group_client);
|
group_send_details(group_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_ext_workspace_handle_v1 *workspace;
|
struct wlr_ext_workspace_handle_v1 *workspace;
|
||||||
wl_list_for_each(workspace, &manager->workspaces, link) {
|
wl_list_for_each(workspace, &manager->workspaces, link) {
|
||||||
struct wlr_ext_workspace_client_v1 *workspace_client =
|
struct wlr_ext_workspace_v1_resource *workspace_res =
|
||||||
create_workspace_client(workspace, manager_client);
|
create_workspace_resource(workspace, manager_res);
|
||||||
if (!workspace) {
|
if (!workspace_res) {
|
||||||
wl_client_post_no_memory(client);
|
wl_resource_post_no_memory(manager_res->resource);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ext_workspace_manager_v1_send_workspace(manager_client->resource,
|
ext_workspace_manager_v1_send_workspace(manager_res->resource,
|
||||||
workspace_client->resource);
|
workspace_res->resource);
|
||||||
workspace_send_details(workspace_client);
|
workspace_send_details(workspace_res);
|
||||||
|
|
||||||
if (!workspace->group) {
|
if (!workspace->group) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
struct wlr_ext_workspace_group_client_v1 *group_client;
|
struct wlr_ext_workspace_group_v1_resource *group_res;
|
||||||
wl_list_for_each(group_client, &workspace->group->clients, link) {
|
wl_list_for_each(group_res, &workspace->group->resources, link) {
|
||||||
if (group_client->manager == manager_client) {
|
if (group_res->manager == manager_res) {
|
||||||
ext_workspace_group_handle_v1_send_workspace_enter(
|
ext_workspace_group_handle_v1_send_workspace_enter(
|
||||||
group_client->resource, workspace_client->resource);
|
group_res->resource, workspace_res->resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
manager_schedule_done(manager);
|
ext_workspace_manager_v1_send_done(manager_res->resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void manager_handle_display_destroy(struct wl_listener *listener,
|
static void manager_handle_display_destroy(struct wl_listener *listener,
|
||||||
|
|
@ -509,9 +543,9 @@ static void manager_handle_display_destroy(struct wl_listener *listener,
|
||||||
wlr_ext_workspace_handle_v1_destroy(workspace);
|
wlr_ext_workspace_handle_v1_destroy(workspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_ext_workspace_manager_client_v1 *manager_client, *tmp3;
|
struct wlr_ext_workspace_manager_v1_resource *manager_res, *tmp3;
|
||||||
wl_list_for_each_safe(manager_client, tmp3, &manager->clients, link) {
|
wl_list_for_each_safe(manager_res, tmp3, &manager->resources, link) {
|
||||||
destroy_manager_client(manager_client);
|
destroy_manager_resource(manager_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (manager->idle_source) {
|
if (manager->idle_source) {
|
||||||
|
|
@ -548,7 +582,7 @@ wlr_ext_workspace_manager_v1_create(struct wl_display *display,
|
||||||
|
|
||||||
wl_list_init(&manager->groups);
|
wl_list_init(&manager->groups);
|
||||||
wl_list_init(&manager->workspaces);
|
wl_list_init(&manager->workspaces);
|
||||||
wl_list_init(&manager->clients);
|
wl_list_init(&manager->resources);
|
||||||
wl_signal_init(&manager->events.destroy);
|
wl_signal_init(&manager->events.destroy);
|
||||||
|
|
||||||
return manager;
|
return manager;
|
||||||
|
|
@ -566,22 +600,22 @@ wlr_ext_workspace_group_handle_v1_create(
|
||||||
group->caps = caps;
|
group->caps = caps;
|
||||||
|
|
||||||
wl_list_init(&group->outputs);
|
wl_list_init(&group->outputs);
|
||||||
wl_list_init(&group->clients);
|
wl_list_init(&group->resources);
|
||||||
wl_signal_init(&group->events.create_workspace);
|
wl_signal_init(&group->events.create_workspace);
|
||||||
wl_signal_init(&group->events.destroy);
|
wl_signal_init(&group->events.destroy);
|
||||||
|
|
||||||
wl_list_insert(manager->groups.prev, &group->link);
|
wl_list_insert(manager->groups.prev, &group->link);
|
||||||
|
|
||||||
struct wlr_ext_workspace_manager_client_v1 *manager_client;
|
struct wlr_ext_workspace_manager_v1_resource *manager_res;
|
||||||
wl_list_for_each(manager_client, &manager->clients, link) {
|
wl_list_for_each(manager_res, &manager->resources, link) {
|
||||||
struct wlr_ext_workspace_group_client_v1 *group_client =
|
struct wlr_ext_workspace_group_v1_resource *group_res =
|
||||||
create_group_client(group, manager_client);
|
create_group_resource(group, manager_res);
|
||||||
if (!group_client) {
|
if (!group_res) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ext_workspace_manager_v1_send_workspace_group(manager_client->resource,
|
ext_workspace_manager_v1_send_workspace_group(manager_res->resource,
|
||||||
group_client->resource);
|
group_res->resource);
|
||||||
group_send_details(group_client);
|
group_send_details(group_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
manager_schedule_done(manager);
|
manager_schedule_done(manager);
|
||||||
|
|
@ -594,19 +628,19 @@ workspace_send_group(struct wlr_ext_workspace_handle_v1 *workspace,
|
||||||
struct wlr_ext_workspace_group_handle_v1 *group,
|
struct wlr_ext_workspace_group_handle_v1 *group,
|
||||||
bool enter) {
|
bool enter) {
|
||||||
|
|
||||||
struct wlr_ext_workspace_client_v1 *workspace_client;
|
struct wlr_ext_workspace_v1_resource *workspace_res;
|
||||||
wl_list_for_each(workspace_client, &workspace->clients, link) {
|
wl_list_for_each(workspace_res, &workspace->resources, link) {
|
||||||
struct wlr_ext_workspace_group_client_v1 *group_client;
|
struct wlr_ext_workspace_group_v1_resource *group_res;
|
||||||
wl_list_for_each(group_client, &group->clients, link) {
|
wl_list_for_each(group_res, &group->resources, link) {
|
||||||
if (group_client->manager != workspace_client->manager) {
|
if (group_res->manager != workspace_res->manager) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (enter) {
|
if (enter) {
|
||||||
ext_workspace_group_handle_v1_send_workspace_enter(
|
ext_workspace_group_handle_v1_send_workspace_enter(
|
||||||
group_client->resource, workspace_client->resource);
|
group_res->resource, workspace_res->resource);
|
||||||
} else {
|
} else {
|
||||||
ext_workspace_group_handle_v1_send_workspace_leave(
|
ext_workspace_group_handle_v1_send_workspace_leave(
|
||||||
group_client->resource, workspace_client->resource);
|
group_res->resource, workspace_res->resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -625,10 +659,9 @@ destroy_group_output(struct wlr_ext_workspace_v1_group_output *group_output) {
|
||||||
static void group_send_output(struct wlr_ext_workspace_group_handle_v1 *group,
|
static void group_send_output(struct wlr_ext_workspace_group_handle_v1 *group,
|
||||||
struct wlr_output *output, bool enter) {
|
struct wlr_output *output, bool enter) {
|
||||||
|
|
||||||
struct wlr_ext_workspace_group_client_v1 *group_client;
|
struct wlr_ext_workspace_group_v1_resource *group_res;
|
||||||
wl_list_for_each(group_client, &group->clients, link) {
|
wl_list_for_each(group_res, &group->resources, link) {
|
||||||
struct wl_client *client =
|
struct wl_client *client = wl_resource_get_client(group_res->resource);
|
||||||
wl_resource_get_client(group_client->resource);
|
|
||||||
|
|
||||||
struct wl_resource *output_resource;
|
struct wl_resource *output_resource;
|
||||||
wl_resource_for_each(output_resource, &output->resources) {
|
wl_resource_for_each(output_resource, &output->resources) {
|
||||||
|
|
@ -637,10 +670,10 @@ static void group_send_output(struct wlr_ext_workspace_group_handle_v1 *group,
|
||||||
}
|
}
|
||||||
if (enter) {
|
if (enter) {
|
||||||
ext_workspace_group_handle_v1_send_output_enter(
|
ext_workspace_group_handle_v1_send_output_enter(
|
||||||
group_client->resource, output_resource);
|
group_res->resource, output_resource);
|
||||||
} else {
|
} else {
|
||||||
ext_workspace_group_handle_v1_send_output_leave(
|
ext_workspace_group_handle_v1_send_output_leave(
|
||||||
group_client->resource, output_resource);
|
group_res->resource, output_resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -650,6 +683,10 @@ static void group_send_output(struct wlr_ext_workspace_group_handle_v1 *group,
|
||||||
|
|
||||||
void wlr_ext_workspace_group_handle_v1_destroy(
|
void wlr_ext_workspace_group_handle_v1_destroy(
|
||||||
struct wlr_ext_workspace_group_handle_v1 *group) {
|
struct wlr_ext_workspace_group_handle_v1 *group) {
|
||||||
|
if (!group) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wl_signal_emit_mutable(&group->events.destroy, NULL);
|
wl_signal_emit_mutable(&group->events.destroy, NULL);
|
||||||
|
|
||||||
assert(wl_list_empty(&group->events.create_workspace.listener_list));
|
assert(wl_list_empty(&group->events.create_workspace.listener_list));
|
||||||
|
|
@ -663,16 +700,16 @@ void wlr_ext_workspace_group_handle_v1_destroy(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_ext_workspace_group_client_v1 *group_client, *tmp;
|
struct wlr_ext_workspace_group_v1_resource *group_res, *tmp;
|
||||||
wl_list_for_each_safe(group_client, tmp, &group->clients, link) {
|
wl_list_for_each_safe(group_res, tmp, &group->resources, link) {
|
||||||
ext_workspace_group_handle_v1_send_removed(group_client->resource);
|
ext_workspace_group_handle_v1_send_removed(group_res->resource);
|
||||||
destroy_group_client(group_client);
|
destroy_group_resource(group_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_ext_workspace_manager_client_v1 *manager_client;
|
struct wlr_ext_workspace_manager_v1_resource *manager_res;
|
||||||
wl_list_for_each(manager_client, &group->manager->clients, link) {
|
wl_list_for_each(manager_res, &group->manager->resources, link) {
|
||||||
struct wlr_ext_workspace_v1_request *req, *tmp2;
|
struct wlr_ext_workspace_v1_request *req, *tmp2;
|
||||||
wl_list_for_each_safe(req, tmp2, &manager_client->requests, link) {
|
wl_list_for_each_safe(req, tmp2, &manager_res->requests, link) {
|
||||||
if (req->group == group) {
|
if (req->group == group) {
|
||||||
destroy_request(req);
|
destroy_request(req);
|
||||||
}
|
}
|
||||||
|
|
@ -697,11 +734,11 @@ static void handle_output_bind(struct wl_listener *listener, void *data) {
|
||||||
struct wlr_output_event_bind *event = data;
|
struct wlr_output_event_bind *event = data;
|
||||||
struct wl_client *client = wl_resource_get_client(event->resource);
|
struct wl_client *client = wl_resource_get_client(event->resource);
|
||||||
|
|
||||||
struct wlr_ext_workspace_group_client_v1 *group_client;
|
struct wlr_ext_workspace_group_v1_resource *group_res;
|
||||||
wl_list_for_each(group_client, &group_output->group->clients, link) {
|
wl_list_for_each(group_res, &group_output->group->resources, link) {
|
||||||
if (wl_resource_get_client(group_client->resource) == client) {
|
if (wl_resource_get_client(group_res->resource) == client) {
|
||||||
ext_workspace_group_handle_v1_send_output_enter(
|
ext_workspace_group_handle_v1_send_output_enter(group_res->resource,
|
||||||
group_client->resource, event->resource);
|
event->resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -778,11 +815,12 @@ wlr_ext_workspace_handle_v1_create(struct wlr_ext_workspace_manager_v1 *manager,
|
||||||
if (id) {
|
if (id) {
|
||||||
workspace->id = strdup(id);
|
workspace->id = strdup(id);
|
||||||
if (!workspace->id) {
|
if (!workspace->id) {
|
||||||
|
free(workspace);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_list_init(&workspace->clients);
|
wl_list_init(&workspace->resources);
|
||||||
wl_array_init(&workspace->coordinates);
|
wl_array_init(&workspace->coordinates);
|
||||||
wl_signal_init(&workspace->events.activate);
|
wl_signal_init(&workspace->events.activate);
|
||||||
wl_signal_init(&workspace->events.deactivate);
|
wl_signal_init(&workspace->events.deactivate);
|
||||||
|
|
@ -792,16 +830,16 @@ wlr_ext_workspace_handle_v1_create(struct wlr_ext_workspace_manager_v1 *manager,
|
||||||
|
|
||||||
wl_list_insert(&manager->workspaces, &workspace->link);
|
wl_list_insert(&manager->workspaces, &workspace->link);
|
||||||
|
|
||||||
struct wlr_ext_workspace_manager_client_v1 *manager_client;
|
struct wlr_ext_workspace_manager_v1_resource *manager_res;
|
||||||
wl_list_for_each(manager_client, &manager->clients, link) {
|
wl_list_for_each(manager_res, &manager->resources, link) {
|
||||||
struct wlr_ext_workspace_client_v1 *workspace_client =
|
struct wlr_ext_workspace_v1_resource *workspace_res =
|
||||||
create_workspace_client(workspace, manager_client);
|
create_workspace_resource(workspace, manager_res);
|
||||||
if (!workspace_client) {
|
if (!workspace_res) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ext_workspace_manager_v1_send_workspace(manager_client->resource,
|
ext_workspace_manager_v1_send_workspace(manager_res->resource,
|
||||||
workspace_client->resource);
|
workspace_res->resource);
|
||||||
workspace_send_details(workspace_client);
|
workspace_send_details(workspace_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
manager_schedule_done(manager);
|
manager_schedule_done(manager);
|
||||||
|
|
@ -811,6 +849,10 @@ wlr_ext_workspace_handle_v1_create(struct wlr_ext_workspace_manager_v1 *manager,
|
||||||
|
|
||||||
void wlr_ext_workspace_handle_v1_destroy(
|
void wlr_ext_workspace_handle_v1_destroy(
|
||||||
struct wlr_ext_workspace_handle_v1 *workspace) {
|
struct wlr_ext_workspace_handle_v1 *workspace) {
|
||||||
|
if (!workspace) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wl_signal_emit_mutable(&workspace->events.destroy, NULL);
|
wl_signal_emit_mutable(&workspace->events.destroy, NULL);
|
||||||
|
|
||||||
assert(wl_list_empty(&workspace->events.activate.listener_list));
|
assert(wl_list_empty(&workspace->events.activate.listener_list));
|
||||||
|
|
@ -823,16 +865,16 @@ void wlr_ext_workspace_handle_v1_destroy(
|
||||||
workspace_send_group(workspace, workspace->group, false);
|
workspace_send_group(workspace, workspace->group, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_ext_workspace_client_v1 *workspace_client, *tmp;
|
struct wlr_ext_workspace_v1_resource *workspace_res, *tmp;
|
||||||
wl_list_for_each_safe(workspace_client, tmp, &workspace->clients, link) {
|
wl_list_for_each_safe(workspace_res, tmp, &workspace->resources, link) {
|
||||||
ext_workspace_handle_v1_send_removed(workspace_client->resource);
|
ext_workspace_handle_v1_send_removed(workspace_res->resource);
|
||||||
destroy_workspace_client(workspace_client);
|
destroy_workspace_resource(workspace_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_ext_workspace_manager_client_v1 *manager_client;
|
struct wlr_ext_workspace_manager_v1_resource *manager_res;
|
||||||
wl_list_for_each(manager_client, &workspace->manager->clients, link) {
|
wl_list_for_each(manager_res, &workspace->manager->resources, link) {
|
||||||
struct wlr_ext_workspace_v1_request *req, *tmp2;
|
struct wlr_ext_workspace_v1_request *req, *tmp2;
|
||||||
wl_list_for_each_safe(req, tmp2, &manager_client->requests, link) {
|
wl_list_for_each_safe(req, tmp2, &manager_res->requests, link) {
|
||||||
if (req->workspace == workspace) {
|
if (req->workspace == workspace) {
|
||||||
destroy_request(req);
|
destroy_request(req);
|
||||||
}
|
}
|
||||||
|
|
@ -856,7 +898,7 @@ void wlr_ext_workspace_handle_v1_set_group(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (workspace->group) {
|
if (workspace->group) {
|
||||||
workspace_send_group(workspace, group, false);
|
workspace_send_group(workspace, workspace->group, false);
|
||||||
}
|
}
|
||||||
workspace->group = group;
|
workspace->group = group;
|
||||||
if (group) {
|
if (group) {
|
||||||
|
|
@ -878,9 +920,9 @@ void wlr_ext_workspace_handle_v1_set_name(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_ext_workspace_client_v1 *workspace_client;
|
struct wlr_ext_workspace_v1_resource *workspace_res;
|
||||||
wl_list_for_each(workspace_client, &workspace->clients, link) {
|
wl_list_for_each(workspace_res, &workspace->resources, link) {
|
||||||
ext_workspace_handle_v1_send_name(workspace_client->resource,
|
ext_workspace_handle_v1_send_name(workspace_res->resource,
|
||||||
workspace->name);
|
workspace->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -905,9 +947,9 @@ void wlr_ext_workspace_handle_v1_set_coordinates(
|
||||||
wl_array_init(&workspace->coordinates);
|
wl_array_init(&workspace->coordinates);
|
||||||
wl_array_copy(&workspace->coordinates, coordinates);
|
wl_array_copy(&workspace->coordinates, coordinates);
|
||||||
|
|
||||||
struct wlr_ext_workspace_client_v1 *workspace_client;
|
struct wlr_ext_workspace_v1_resource *workspace_res;
|
||||||
wl_list_for_each(workspace_client, &workspace->clients, link) {
|
wl_list_for_each(workspace_res, &workspace->resources, link) {
|
||||||
ext_workspace_handle_v1_send_coordinates(workspace_client->resource,
|
ext_workspace_handle_v1_send_coordinates(workspace_res->resource,
|
||||||
&workspace->coordinates);
|
&workspace->coordinates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -927,9 +969,9 @@ static void workspace_set_state(struct wlr_ext_workspace_handle_v1 *workspace,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_ext_workspace_client_v1 *workspace_client;
|
struct wlr_ext_workspace_v1_resource *workspace_res;
|
||||||
wl_list_for_each(workspace_client, &workspace->clients, link) {
|
wl_list_for_each(workspace_res, &workspace->resources, link) {
|
||||||
ext_workspace_handle_v1_send_state(workspace_client->resource,
|
ext_workspace_handle_v1_send_state(workspace_res->resource,
|
||||||
workspace->state);
|
workspace->state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,32 +2,11 @@
|
||||||
// TODO: remove this file
|
// TODO: remove this file
|
||||||
// refer: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/5115
|
// refer: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/5115
|
||||||
|
|
||||||
/*
|
#include <wayland-protocols/ext-workspace-v1-enum.h>
|
||||||
* This an unstable interface of wlroots. No guarantees are made regarding the
|
|
||||||
* future consistency of this API.
|
|
||||||
*/
|
|
||||||
#ifndef WLR_USE_UNSTABLE
|
|
||||||
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WLR_TYPES_WLR_EXT_WORKSPACE_V1_H
|
|
||||||
#define WLR_TYPES_WLR_EXT_WORKSPACE_V1_H
|
|
||||||
|
|
||||||
#include <wayland-server-core.h>
|
#include <wayland-server-core.h>
|
||||||
|
|
||||||
struct wlr_output;
|
struct wlr_output;
|
||||||
|
|
||||||
enum wlr_ext_workspace_group_handle_v1_cap {
|
|
||||||
WLR_EXT_WORKSPACE_GROUP_HANDLE_V1_CAP_CREATE_WORKSPACE = 1 << 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum wlr_ext_workspace_handle_v1_cap {
|
|
||||||
WLR_EXT_WORKSPACE_HANDLE_V1_CAP_ACTIVATE = 1 << 0,
|
|
||||||
WLR_EXT_WORKSPACE_HANDLE_V1_CAP_DEACTIVATE = 1 << 1,
|
|
||||||
WLR_EXT_WORKSPACE_HANDLE_V1_CAP_REMOVE = 1 << 2,
|
|
||||||
WLR_EXT_WORKSPACE_HANDLE_V1_CAP_ASSIGN = 1 << 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct wlr_ext_workspace_manager_v1 {
|
struct wlr_ext_workspace_manager_v1 {
|
||||||
struct wl_global *global;
|
struct wl_global *global;
|
||||||
struct wl_list groups; // wlr_ext_workspace_group_handle_v1.link
|
struct wl_list groups; // wlr_ext_workspace_group_handle_v1.link
|
||||||
|
|
@ -37,24 +16,33 @@ struct wlr_ext_workspace_manager_v1 {
|
||||||
struct wl_signal destroy;
|
struct wl_signal destroy;
|
||||||
} events;
|
} events;
|
||||||
|
|
||||||
struct wl_list clients; // wlr_ext_workspace_manager_client_v1.link
|
struct {
|
||||||
struct wl_event_source *idle_source;
|
struct wl_list resources; // wlr_ext_workspace_manager_v1_resource.link
|
||||||
struct wl_event_loop *event_loop;
|
struct wl_event_source *idle_source;
|
||||||
struct wl_listener display_destroy;
|
struct wl_event_loop *event_loop;
|
||||||
|
struct wl_listener display_destroy;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct wlr_ext_workspace_group_handle_v1_create_workspace_event {
|
||||||
|
const char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_ext_workspace_group_handle_v1 {
|
struct wlr_ext_workspace_group_handle_v1 {
|
||||||
struct wlr_ext_workspace_manager_v1 *manager;
|
struct wlr_ext_workspace_manager_v1 *manager;
|
||||||
uint32_t caps; // wlr_ext_workspace_group_handle_v1_cap
|
uint32_t caps; // ext_workspace_group_handle_v1_group_capabilities
|
||||||
struct {
|
struct {
|
||||||
struct wl_signal create_workspace; // const char *
|
struct wl_signal
|
||||||
|
create_workspace; // wlr_ext_workspace_group_handle_v1_create_workspace_event
|
||||||
struct wl_signal destroy;
|
struct wl_signal destroy;
|
||||||
} events;
|
} events;
|
||||||
|
|
||||||
struct wl_list link; // wlr_ext_workspace_manager_v1.groups
|
struct wl_list link; // wlr_ext_workspace_manager_v1.groups
|
||||||
|
|
||||||
struct wl_list outputs; // wlr_ext_workspace_v1_group_output.link
|
struct {
|
||||||
struct wl_list clients; // wlr_ext_workspace_manager_client_v1.link
|
struct wl_list outputs; // wlr_ext_workspace_v1_group_output.link
|
||||||
|
struct wl_list resources; // wlr_ext_workspace_manager_v1_resource.link
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_ext_workspace_handle_v1 {
|
struct wlr_ext_workspace_handle_v1 {
|
||||||
|
|
@ -63,7 +51,7 @@ struct wlr_ext_workspace_handle_v1 {
|
||||||
char *id;
|
char *id;
|
||||||
char *name;
|
char *name;
|
||||||
struct wl_array coordinates;
|
struct wl_array coordinates;
|
||||||
uint32_t caps; // wlr_ext_workspace_handle_v1_cap
|
uint32_t caps; // ext_workspace_handle_v1_workspace_capabilities
|
||||||
uint32_t state; // ext_workspace_handle_v1_state
|
uint32_t state; // ext_workspace_handle_v1_state
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -74,9 +62,11 @@ struct wlr_ext_workspace_handle_v1 {
|
||||||
struct wl_signal destroy;
|
struct wl_signal destroy;
|
||||||
} events;
|
} events;
|
||||||
|
|
||||||
struct wl_list link; // wlr_ext_workspace_manager_v1.workspaces;
|
struct wl_list link; // wlr_ext_workspace_manager_v1.workspaces
|
||||||
|
|
||||||
struct wl_list clients;
|
struct {
|
||||||
|
struct wl_list resources; // wlr_ext_workspace_v1_resource.link
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_ext_workspace_manager_v1 *
|
struct wlr_ext_workspace_manager_v1 *
|
||||||
|
|
@ -114,5 +104,3 @@ void wlr_ext_workspace_handle_v1_set_urgent(
|
||||||
struct wlr_ext_workspace_handle_v1 *workspace, bool enabled);
|
struct wlr_ext_workspace_handle_v1 *workspace, bool enabled);
|
||||||
void wlr_ext_workspace_handle_v1_set_hidden(
|
void wlr_ext_workspace_handle_v1_set_hidden(
|
||||||
struct wlr_ext_workspace_handle_v1 *workspace, bool enabled);
|
struct wlr_ext_workspace_handle_v1 *workspace, bool enabled);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
||||||
|
|
@ -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,7 +154,7 @@ Client *center_tiled_select(Monitor *m) {
|
||||||
return target_c;
|
return target_c;
|
||||||
}
|
}
|
||||||
Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
|
Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
|
||||||
bool align) {
|
bool ignore_align) {
|
||||||
Client *c = NULL;
|
Client *c = NULL;
|
||||||
Client **tempClients = NULL; // 初始化为 NULL
|
Client **tempClients = NULL; // 初始化为 NULL
|
||||||
int last = -1;
|
int last = -1;
|
||||||
|
|
@ -150,7 +162,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
|
||||||
// 第一次遍历,计算客户端数量
|
// 第一次遍历,计算客户端数量
|
||||||
wl_list_for_each(c, &clients, link) {
|
wl_list_for_each(c, &clients, link) {
|
||||||
if (c && (findfloating || !c->isfloating) && !c->isunglobal &&
|
if (c && (findfloating || !c->isfloating) && !c->isunglobal &&
|
||||||
(focus_cross_monitor || c->mon == selmon) &&
|
(focus_cross_monitor || c->mon == tc->mon) &&
|
||||||
(c->tags & c->mon->tagset[c->mon->seltags])) {
|
(c->tags & c->mon->tagset[c->mon->seltags])) {
|
||||||
last++;
|
last++;
|
||||||
}
|
}
|
||||||
|
|
@ -171,7 +183,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
|
||||||
last = -1;
|
last = -1;
|
||||||
wl_list_for_each(c, &clients, link) {
|
wl_list_for_each(c, &clients, link) {
|
||||||
if (c && (findfloating || !c->isfloating) && !c->isunglobal &&
|
if (c && (findfloating || !c->isfloating) && !c->isunglobal &&
|
||||||
(focus_cross_monitor || c->mon == selmon) &&
|
(focus_cross_monitor || c->mon == tc->mon) &&
|
||||||
(c->tags & c->mon->tagset[c->mon->seltags])) {
|
(c->tags & c->mon->tagset[c->mon->seltags])) {
|
||||||
last++;
|
last++;
|
||||||
tempClients[last] = c;
|
tempClients[last] = c;
|
||||||
|
|
@ -181,24 +193,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 &&
|
||||||
int dis_x = tempClients[_i]->geom.x - sel_x;
|
tempClients[_i]->geom.x == sel_x &&
|
||||||
int dis_y = tempClients[_i]->geom.y - sel_y;
|
tempClients[_i]->mon == tc->mon) {
|
||||||
long long int tmp_distance =
|
int dis_x = tempClients[_i]->geom.x - sel_x;
|
||||||
dis_x * dis_x + dis_y * dis_y; // 计算距离
|
int dis_y = tempClients[_i]->geom.y - sel_y;
|
||||||
if (tmp_distance < distance) {
|
long long int tmp_distance =
|
||||||
distance = tmp_distance;
|
dis_x * dis_x + dis_y * dis_y; // 计算距离
|
||||||
tempFocusClients = tempClients[_i];
|
if (tmp_distance < distance) {
|
||||||
|
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;
|
||||||
|
|
@ -209,25 +226,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 &&
|
||||||
int dis_x = tempClients[_i]->geom.x - sel_x;
|
tempClients[_i]->geom.x == sel_x &&
|
||||||
int dis_y = tempClients[_i]->geom.y - sel_y;
|
tempClients[_i]->mon == tc->mon) {
|
||||||
long long int tmp_distance =
|
int dis_x = tempClients[_i]->geom.x - sel_x;
|
||||||
dis_x * dis_x + dis_y * dis_y; // 计算距离
|
int dis_y = tempClients[_i]->geom.y - sel_y;
|
||||||
if (tmp_distance < distance) {
|
long long int tmp_distance =
|
||||||
distance = tmp_distance;
|
dis_x * dis_x + dis_y * dis_y; // 计算距离
|
||||||
tempFocusClients = tempClients[_i];
|
if (tmp_distance < distance) {
|
||||||
|
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;
|
||||||
|
|
@ -238,25 +263,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) {
|
||||||
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 &&
|
||||||
int dis_x = tempClients[_i]->geom.x - sel_x;
|
tempClients[_i]->geom.y == sel_y &&
|
||||||
int dis_y = tempClients[_i]->geom.y - sel_y;
|
tempClients[_i]->mon == tc->mon) {
|
||||||
long long int tmp_distance =
|
int dis_x = tempClients[_i]->geom.x - sel_x;
|
||||||
dis_x * dis_x + dis_y * dis_y; // 计算距离
|
int dis_y = tempClients[_i]->geom.y - sel_y;
|
||||||
if (tmp_distance < distance) {
|
long long int tmp_distance =
|
||||||
distance = tmp_distance;
|
dis_x * dis_x + dis_y * dis_y; // 计算距离
|
||||||
tempFocusClients = tempClients[_i];
|
if (tmp_distance < distance) {
|
||||||
|
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.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;
|
||||||
|
|
@ -267,27 +300,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) {
|
||||||
if (tempClients[_i]->geom.x > sel_x &&
|
|
||||||
tempClients[_i]->geom.y == sel_y) {
|
|
||||||
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 =
|
||||||
|
|
@ -299,11 +326,34 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!tempFocusClients) {
|
||||||
|
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) {
|
||||||
|
|
@ -313,12 +363,13 @@ Client *direction_select(const Arg *arg) {
|
||||||
if (!tc)
|
if (!tc)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (tc && (tc->isfullscreen || tc->ismaxmizescreen)) {
|
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
|
||||||
|
|
@ -336,17 +387,47 @@ Client *focustop(Monitor *m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *get_next_stack_client(Client *c, bool reverse) {
|
Client *get_next_stack_client(Client *c, bool reverse) {
|
||||||
|
if (!c || !c->mon)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
Client *next = NULL;
|
Client *next = NULL;
|
||||||
if (reverse) {
|
if (reverse) {
|
||||||
wl_list_for_each_reverse(next, &c->link, link) {
|
wl_list_for_each_reverse(next, &c->link, link) {
|
||||||
if (VISIBLEON(next, c->mon) && next != c)
|
if (&next->link == &clients)
|
||||||
|
continue; /* wrap past the sentinel node */
|
||||||
|
|
||||||
|
if (next != c && next->mon && VISIBLEON(next, c->mon))
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wl_list_for_each(next, &c->link, link) {
|
wl_list_for_each(next, &c->link, link) {
|
||||||
if (VISIBLEON(next, c->mon) && next != c)
|
if (&next->link == &clients)
|
||||||
|
continue; /* wrap past the sentinel node */
|
||||||
|
|
||||||
|
if (next != c && next->mon && VISIBLEON(next, c->mon))
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float *get_border_color(Client *c) {
|
||||||
|
|
||||||
|
if (c->mon != selmon) {
|
||||||
|
return bordercolor;
|
||||||
|
} else if (c->isurgent) {
|
||||||
|
return urgentcolor;
|
||||||
|
} else if (c->is_in_scratchpad && selmon && c == selmon->sel) {
|
||||||
|
return scratchpadcolor;
|
||||||
|
} else if (c->isglobal && selmon && c == selmon->sel) {
|
||||||
|
return globalcolor;
|
||||||
|
} else if (c->isoverlay && selmon && c == selmon->sel) {
|
||||||
|
return overlaycolor;
|
||||||
|
} else if (c->ismaximizescreen && selmon && c == selmon->sel) {
|
||||||
|
return maximizescreencolor;
|
||||||
|
} else if (selmon && c == selmon->sel) {
|
||||||
|
return focuscolor;
|
||||||
|
} else {
|
||||||
|
return bordercolor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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,29 +26,15 @@ 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) {
|
void get_layout_abbr(char *abbr, const char *full_name) {
|
||||||
const char *mangoconfig = getenv("MANGOCONFIG");
|
// 清空输出缓冲区
|
||||||
|
abbr[0] = '\0';
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *get_layout_abbr(const char *full_name) {
|
|
||||||
// 1. 尝试在映射表中查找
|
// 1. 尝试在映射表中查找
|
||||||
for (int i = 0; layout_mappings[i].full_name != NULL; i++) {
|
for (int i = 0; layout_mappings[i].full_name != NULL; i++) {
|
||||||
if (strcmp(full_name, layout_mappings[i].full_name) == 0) {
|
if (strcmp(full_name, layout_mappings[i].full_name) == 0) {
|
||||||
return layout_mappings[i].abbr;
|
strcpy(abbr, layout_mappings[i].abbr);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,48 +42,39 @@ const char *get_layout_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) {
|
||||||
char *abbr = malloc(len + 1);
|
// 提取并转换为小写
|
||||||
if (abbr) {
|
for (uint32_t j = 0; j < len; j++) {
|
||||||
// 提取并转换为小写
|
abbr[j] = tolower(open[j + 1]);
|
||||||
for (unsigned int j = 0; j < len; j++) {
|
|
||||||
abbr[j] = tolower(open[j + 1]);
|
|
||||||
}
|
|
||||||
abbr[len] = '\0';
|
|
||||||
return abbr;
|
|
||||||
}
|
}
|
||||||
|
abbr[len] = '\0';
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 提取前2-3个字母并转换为小写
|
// 3. 提取前2-3个字母并转换为小写
|
||||||
char *abbr = malloc(4);
|
uint32_t j = 0;
|
||||||
if (abbr) {
|
for (uint32_t i = 0; full_name[i] != '\0' && j < 3; i++) {
|
||||||
unsigned int j = 0;
|
if (isalpha(full_name[i])) {
|
||||||
for (unsigned int i = 0; full_name[i] != '\0' && j < 3; i++) {
|
abbr[j++] = tolower(full_name[i]);
|
||||||
if (isalpha(full_name[i])) {
|
|
||||||
abbr[j++] = tolower(full_name[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
abbr[j] = '\0';
|
}
|
||||||
|
abbr[j] = '\0';
|
||||||
|
|
||||||
// 确保至少2个字符
|
// 确保至少2个字符
|
||||||
if (j >= 2)
|
if (j >= 2) {
|
||||||
return abbr;
|
return;
|
||||||
free(abbr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 回退方案:使用首字母小写
|
// 4. 回退方案:使用首字母小写
|
||||||
char *fallback = malloc(3);
|
if (j == 1) {
|
||||||
if (fallback) {
|
abbr[1] = full_name[1] ? tolower(full_name[1]) : '\0';
|
||||||
fallback[0] = tolower(full_name[0]);
|
abbr[2] = '\0';
|
||||||
fallback[1] = full_name[1] ? tolower(full_name[1]) : '\0';
|
} else {
|
||||||
fallback[2] = '\0';
|
// 5. 最终回退:返回 "xx"
|
||||||
return fallback;
|
strcpy(abbr, "xx");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. 最终回退:返回 "xx"
|
|
||||||
return strdup("xx");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
|
void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
|
||||||
|
|
@ -120,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,
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,9 @@ bool is_scroller_layout(Monitor *m) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int get_tag_status(unsigned int tag, Monitor *m) {
|
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 +41,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 +63,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) {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ void set_size_per(Monitor *m, Client *c) {
|
||||||
if (VISIBLEON(fc, m) && ISTILED(fc) && fc != c) {
|
if (VISIBLEON(fc, m) && ISTILED(fc) && fc != c) {
|
||||||
c->master_mfact_per = fc->master_mfact_per;
|
c->master_mfact_per = fc->master_mfact_per;
|
||||||
c->master_inner_per = fc->master_inner_per;
|
c->master_inner_per = fc->master_inner_per;
|
||||||
c->stack_innder_per = fc->stack_innder_per;
|
c->stack_inner_per = fc->stack_inner_per;
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -14,12 +14,12 @@ void set_size_per(Monitor *m, Client *c) {
|
||||||
if (!found) {
|
if (!found) {
|
||||||
c->master_mfact_per = m->pertag->mfacts[m->pertag->curtag];
|
c->master_mfact_per = m->pertag->mfacts[m->pertag->curtag];
|
||||||
c->master_inner_per = 1.0f;
|
c->master_inner_per = 1.0f;
|
||||||
c->stack_innder_per = 1.0f;
|
c->stack_inner_per = 1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
@ -70,7 +70,7 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int offsetx,
|
||||||
// 记录初始状态
|
// 记录初始状态
|
||||||
grabc->old_master_mfact_per = grabc->master_mfact_per;
|
grabc->old_master_mfact_per = grabc->master_mfact_per;
|
||||||
grabc->old_master_inner_per = grabc->master_inner_per;
|
grabc->old_master_inner_per = grabc->master_inner_per;
|
||||||
grabc->old_stack_innder_per = grabc->stack_innder_per;
|
grabc->old_stack_inner_per = grabc->stack_inner_per;
|
||||||
grabc->cursor_in_upper_half =
|
grabc->cursor_in_upper_half =
|
||||||
cursor->y < grabc->geom.y + grabc->geom.height / 2;
|
cursor->y < grabc->geom.y + grabc->geom.height / 2;
|
||||||
grabc->cursor_in_left_half =
|
grabc->cursor_in_left_half =
|
||||||
|
|
@ -86,7 +86,7 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int offsetx,
|
||||||
} else {
|
} else {
|
||||||
grabc->old_master_mfact_per = grabc->master_mfact_per;
|
grabc->old_master_mfact_per = grabc->master_mfact_per;
|
||||||
grabc->old_master_inner_per = grabc->master_inner_per;
|
grabc->old_master_inner_per = grabc->master_inner_per;
|
||||||
grabc->old_stack_innder_per = grabc->stack_innder_per;
|
grabc->old_stack_inner_per = grabc->stack_inner_per;
|
||||||
grabc->drag_begin_geom = grabc->geom;
|
grabc->drag_begin_geom = grabc->geom;
|
||||||
grabc->cursor_in_upper_half = true;
|
grabc->cursor_in_upper_half = true;
|
||||||
grabc->cursor_in_left_half = false;
|
grabc->cursor_in_left_half = false;
|
||||||
|
|
@ -100,7 +100,7 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int offsetx,
|
||||||
} else {
|
} else {
|
||||||
delta_x = (float)(offsetx) * (1 - grabc->old_master_mfact_per) /
|
delta_x = (float)(offsetx) * (1 - grabc->old_master_mfact_per) /
|
||||||
grabc->drag_begin_geom.width;
|
grabc->drag_begin_geom.width;
|
||||||
delta_y = (float)(offsety) * (grabc->old_stack_innder_per) /
|
delta_y = (float)(offsety) * (grabc->old_stack_inner_per) /
|
||||||
grabc->drag_begin_geom.height;
|
grabc->drag_begin_geom.height;
|
||||||
}
|
}
|
||||||
bool moving_up;
|
bool moving_up;
|
||||||
|
|
@ -182,12 +182,12 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int offsetx,
|
||||||
// 直接设置新的比例,基于初始值 + 变化量
|
// 直接设置新的比例,基于初始值 + 变化量
|
||||||
float new_master_mfact_per = grabc->old_master_mfact_per + delta_x;
|
float new_master_mfact_per = grabc->old_master_mfact_per + delta_x;
|
||||||
float new_master_inner_per = grabc->old_master_inner_per + delta_y;
|
float new_master_inner_per = grabc->old_master_inner_per + delta_y;
|
||||||
float new_stack_innder_per = grabc->old_stack_innder_per + delta_y;
|
float new_stack_inner_per = grabc->old_stack_inner_per + delta_y;
|
||||||
|
|
||||||
// 应用限制,确保比例在合理范围内
|
// 应用限制,确保比例在合理范围内
|
||||||
new_master_mfact_per = fmaxf(0.1f, fminf(0.9f, new_master_mfact_per));
|
new_master_mfact_per = fmaxf(0.1f, fminf(0.9f, new_master_mfact_per));
|
||||||
new_master_inner_per = fmaxf(0.1f, fminf(0.9f, new_master_inner_per));
|
new_master_inner_per = fmaxf(0.1f, fminf(0.9f, new_master_inner_per));
|
||||||
new_stack_innder_per = fmaxf(0.1f, fminf(0.9f, new_stack_innder_per));
|
new_stack_inner_per = fmaxf(0.1f, fminf(0.9f, new_stack_inner_per));
|
||||||
|
|
||||||
// 应用到所有平铺窗口
|
// 应用到所有平铺窗口
|
||||||
wl_list_for_each(tc, &clients, link) {
|
wl_list_for_each(tc, &clients, link) {
|
||||||
|
|
@ -197,7 +197,7 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int offsetx,
|
||||||
}
|
}
|
||||||
|
|
||||||
grabc->master_inner_per = new_master_inner_per;
|
grabc->master_inner_per = new_master_inner_per;
|
||||||
grabc->stack_innder_per = new_stack_innder_per;
|
grabc->stack_inner_per = new_stack_inner_per;
|
||||||
|
|
||||||
if (!isdrag) {
|
if (!isdrag) {
|
||||||
arrange(grabc->mon, false);
|
arrange(grabc->mon, false);
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -250,7 +250,7 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int offsetx,
|
||||||
// 记录初始状态
|
// 记录初始状态
|
||||||
grabc->old_master_mfact_per = grabc->master_mfact_per;
|
grabc->old_master_mfact_per = grabc->master_mfact_per;
|
||||||
grabc->old_master_inner_per = grabc->master_inner_per;
|
grabc->old_master_inner_per = grabc->master_inner_per;
|
||||||
grabc->old_stack_innder_per = grabc->stack_innder_per;
|
grabc->old_stack_inner_per = grabc->stack_inner_per;
|
||||||
grabc->cursor_in_upper_half =
|
grabc->cursor_in_upper_half =
|
||||||
cursor->y < grabc->geom.y + grabc->geom.height / 2;
|
cursor->y < grabc->geom.y + grabc->geom.height / 2;
|
||||||
grabc->cursor_in_left_half =
|
grabc->cursor_in_left_half =
|
||||||
|
|
@ -267,7 +267,7 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int offsetx,
|
||||||
} else {
|
} else {
|
||||||
grabc->old_master_mfact_per = grabc->master_mfact_per;
|
grabc->old_master_mfact_per = grabc->master_mfact_per;
|
||||||
grabc->old_master_inner_per = grabc->master_inner_per;
|
grabc->old_master_inner_per = grabc->master_inner_per;
|
||||||
grabc->old_stack_innder_per = grabc->stack_innder_per;
|
grabc->old_stack_inner_per = grabc->stack_inner_per;
|
||||||
grabc->drag_begin_geom = grabc->geom;
|
grabc->drag_begin_geom = grabc->geom;
|
||||||
grabc->cursor_in_upper_half = true;
|
grabc->cursor_in_upper_half = true;
|
||||||
grabc->cursor_in_left_half = false;
|
grabc->cursor_in_left_half = false;
|
||||||
|
|
@ -280,7 +280,7 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int offsetx,
|
||||||
delta_y = (float)(offsety) * (grabc->old_master_mfact_per) /
|
delta_y = (float)(offsety) * (grabc->old_master_mfact_per) /
|
||||||
grabc->drag_begin_geom.height;
|
grabc->drag_begin_geom.height;
|
||||||
} else {
|
} else {
|
||||||
delta_x = (float)(offsetx) * (grabc->old_stack_innder_per) /
|
delta_x = (float)(offsetx) * (grabc->old_stack_inner_per) /
|
||||||
grabc->drag_begin_geom.width;
|
grabc->drag_begin_geom.width;
|
||||||
delta_y = (float)(offsety) * (1 - grabc->old_master_mfact_per) /
|
delta_y = (float)(offsety) * (1 - grabc->old_master_mfact_per) /
|
||||||
grabc->drag_begin_geom.height;
|
grabc->drag_begin_geom.height;
|
||||||
|
|
@ -338,13 +338,13 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int offsetx,
|
||||||
delta_y; // 垂直:delta_y调整主区域高度
|
delta_y; // 垂直:delta_y调整主区域高度
|
||||||
float new_master_inner_per = grabc->old_master_inner_per +
|
float new_master_inner_per = grabc->old_master_inner_per +
|
||||||
delta_x; // 垂直:delta_x调整主区域内部宽度
|
delta_x; // 垂直:delta_x调整主区域内部宽度
|
||||||
float new_stack_innder_per = grabc->old_stack_innder_per +
|
float new_stack_inner_per = grabc->old_stack_inner_per +
|
||||||
delta_x; // 垂直:delta_x调整栈区域内部宽度
|
delta_x; // 垂直:delta_x调整栈区域内部宽度
|
||||||
|
|
||||||
// 应用限制,确保比例在合理范围内
|
// 应用限制,确保比例在合理范围内
|
||||||
new_master_mfact_per = fmaxf(0.1f, fminf(0.9f, new_master_mfact_per));
|
new_master_mfact_per = fmaxf(0.1f, fminf(0.9f, new_master_mfact_per));
|
||||||
new_master_inner_per = fmaxf(0.1f, fminf(0.9f, new_master_inner_per));
|
new_master_inner_per = fmaxf(0.1f, fminf(0.9f, new_master_inner_per));
|
||||||
new_stack_innder_per = fmaxf(0.1f, fminf(0.9f, new_stack_innder_per));
|
new_stack_inner_per = fmaxf(0.1f, fminf(0.9f, new_stack_inner_per));
|
||||||
|
|
||||||
// 应用到所有平铺窗口
|
// 应用到所有平铺窗口
|
||||||
wl_list_for_each(tc, &clients, link) {
|
wl_list_for_each(tc, &clients, link) {
|
||||||
|
|
@ -354,7 +354,7 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int offsetx,
|
||||||
}
|
}
|
||||||
|
|
||||||
grabc->master_inner_per = new_master_inner_per;
|
grabc->master_inner_per = new_master_inner_per;
|
||||||
grabc->stack_innder_per = new_stack_innder_per;
|
grabc->stack_inner_per = new_stack_inner_per;
|
||||||
|
|
||||||
if (!isdrag) {
|
if (!isdrag) {
|
||||||
arrange(grabc->mon, false);
|
arrange(grabc->mon, false);
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -398,7 +402,7 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int offsetx, int offsety,
|
||||||
} else {
|
} else {
|
||||||
grabc->old_master_mfact_per = grabc->master_mfact_per;
|
grabc->old_master_mfact_per = grabc->master_mfact_per;
|
||||||
grabc->old_master_inner_per = grabc->master_inner_per;
|
grabc->old_master_inner_per = grabc->master_inner_per;
|
||||||
grabc->old_stack_innder_per = grabc->stack_innder_per;
|
grabc->old_stack_inner_per = grabc->stack_inner_per;
|
||||||
grabc->drag_begin_geom = grabc->geom;
|
grabc->drag_begin_geom = grabc->geom;
|
||||||
grabc->old_scroller_pproportion = grabc->scroller_proportion;
|
grabc->old_scroller_pproportion = grabc->scroller_proportion;
|
||||||
grabc->cursor_in_upper_half = false;
|
grabc->cursor_in_upper_half = false;
|
||||||
|
|
@ -470,15 +474,19 @@ 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->ismaxmizescreen)
|
if (!grabc || grabc->isfullscreen || grabc->ismaximizescreen)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (grabc->mon->isoverview)
|
||||||
return;
|
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 ||
|
||||||
current_layout->id == CENTER_TILE || current_layout->id == RIGHT_TILE
|
current_layout->id == CENTER_TILE || current_layout->id == RIGHT_TILE ||
|
||||||
|
(current_layout->id == TGMIX && grabc->mon->visible_tiling_clients <= 3)
|
||||||
|
|
||||||
) {
|
) {
|
||||||
resize_tile_master_horizontal(grabc, isdrag, offsetx, offsety, time,
|
resize_tile_master_horizontal(grabc, isdrag, offsetx, offsety, time,
|
||||||
|
|
@ -502,27 +510,25 @@ 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_inner_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 =
|
||||||
c->stack_innder_per =
|
master_num > 0 ? 1.0f / master_num : 1.0f;
|
||||||
|
c->stack_inner_per =
|
||||||
total_stack_hight_percent
|
total_stack_hight_percent
|
||||||
? c->stack_innder_per / total_stack_hight_percent
|
? c->stack_inner_per / total_stack_hight_percent
|
||||||
: 1.0f;
|
: 1.0f;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
@ -531,17 +537,14 @@ 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_inner_per =
|
||||||
stack_num > 1 ? 1.0f / ((stack_num - 1) / 2) : 1.0f;
|
stack_num > 1 ? 1.0f / ((stack_num - 1) / 2) : 1.0f;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
c->stack_innder_per =
|
c->stack_inner_per =
|
||||||
stack_num > 1 ? 2.0f / stack_num : 1.0f;
|
stack_num > 1 ? 2.0f / stack_num : 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -551,17 +554,18 @@ 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_inner_per =
|
||||||
total_right_stack_hight_percent
|
total_right_stack_hight_percent
|
||||||
? c->stack_innder_per /
|
? c->stack_inner_per /
|
||||||
total_right_stack_hight_percent
|
total_right_stack_hight_percent
|
||||||
: 1.0f;
|
: 1.0f;
|
||||||
} else {
|
} else {
|
||||||
c->stack_innder_per =
|
c->stack_inner_per =
|
||||||
total_left_stack_hight_percent
|
total_left_stack_hight_percent
|
||||||
? c->stack_innder_per /
|
? c->stack_inner_per /
|
||||||
total_left_stack_hight_percent
|
total_left_stack_hight_percent
|
||||||
: 1.0f;
|
: 1.0f;
|
||||||
}
|
}
|
||||||
|
|
@ -575,7 +579,7 @@ void reset_size_per_mon(Monitor *m, int tile_cilent_num,
|
||||||
void // 17
|
void // 17
|
||||||
arrange(Monitor *m, bool want_animation) {
|
arrange(Monitor *m, bool want_animation) {
|
||||||
Client *c = NULL;
|
Client *c = NULL;
|
||||||
double total_stack_innder_percent = 0;
|
double total_stack_inner_percent = 0;
|
||||||
double total_master_inner_percent = 0;
|
double total_master_inner_percent = 0;
|
||||||
double total_right_stack_hight_percent = 0;
|
double total_right_stack_hight_percent = 0;
|
||||||
double total_left_stack_hight_percent = 0;
|
double total_left_stack_hight_percent = 0;
|
||||||
|
|
@ -592,6 +596,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;
|
||||||
|
|
||||||
wl_list_for_each(c, &clients, link) {
|
wl_list_for_each(c, &clients, link) {
|
||||||
|
|
||||||
|
|
@ -602,10 +607,16 @@ arrange(Monitor *m, bool want_animation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VISIBLEON(c, m)) {
|
if (VISIBLEON(c, m)) {
|
||||||
m->visible_clients++;
|
if (!c->isunglobal)
|
||||||
|
m->visible_clients++;
|
||||||
|
|
||||||
if (ISTILED(c)) {
|
if (ISTILED(c)) {
|
||||||
m->visible_tiling_clients++;
|
m->visible_tiling_clients++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ISSCROLLTILED(c)) {
|
||||||
|
m->visible_scroll_tiling_clients++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -619,22 +630,22 @@ 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 {
|
||||||
stack_num++;
|
stack_num++;
|
||||||
total_stack_innder_percent += c->stack_innder_per;
|
total_stack_inner_percent += c->stack_inner_per;
|
||||||
stack_index = i - nmasters;
|
stack_index = i - nmasters;
|
||||||
if ((stack_index % 2) ^
|
if ((stack_index % 2) ^
|
||||||
(m->visible_tiling_clients % 2 == 0)) {
|
(m->visible_tiling_clients % 2 == 0)) {
|
||||||
c->isleftstack = false;
|
c->isleftstack = false;
|
||||||
total_right_stack_hight_percent +=
|
total_right_stack_hight_percent +=
|
||||||
c->stack_innder_per;
|
c->stack_inner_per;
|
||||||
} else {
|
} else {
|
||||||
c->isleftstack = true;
|
c->isleftstack = true;
|
||||||
total_left_stack_hight_percent +=
|
total_left_stack_hight_percent +=
|
||||||
c->stack_innder_per;
|
c->stack_inner_per;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -647,15 +658,15 @@ arrange(Monitor *m, bool want_animation) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->mon == m && c->ismaxmizescreen && !c->animation.tagouted &&
|
if (c->mon == m && c->ismaximizescreen && !c->animation.tagouted &&
|
||||||
!c->animation.tagouting && VISIBLEON(c, m)) {
|
!c->animation.tagouting && VISIBLEON(c, m)) {
|
||||||
reset_maxmizescreen_size(c);
|
reset_maximizescreen_size(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reset_size_per_mon(
|
reset_size_per_mon(
|
||||||
m, m->visible_tiling_clients, total_left_stack_hight_percent,
|
m, m->visible_tiling_clients, total_left_stack_hight_percent,
|
||||||
total_right_stack_hight_percent, total_stack_innder_percent,
|
total_right_stack_hight_percent, total_stack_inner_percent,
|
||||||
total_master_inner_percent, master_num, stack_num);
|
total_master_inner_percent, master_num, stack_num);
|
||||||
|
|
||||||
if (m->isoverview) {
|
if (m->isoverview) {
|
||||||
|
|
@ -668,4 +679,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();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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,13 +23,8 @@ 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_should_ignore_focus(c)) ||
|
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
||||||
ISTILED(c))) {
|
|
||||||
cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
|
cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
|
||||||
ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
|
ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
|
||||||
c->geom.x = m->w.x + (m->w.width - cw) / 2;
|
c->geom.x = m->w.x + (m->w.width - cw) / 2;
|
||||||
|
|
@ -50,13 +45,8 @@ 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_should_ignore_focus(c)) ||
|
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
||||||
ISTILED(c))) {
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
c->geom.x = m->w.x + target_gappo;
|
c->geom.x = m->w.x + target_gappo;
|
||||||
c->geom.y = m->w.y + (m->w.height - ch) / 2 + target_gappo;
|
c->geom.y = m->w.y + (m->w.height - ch) / 2 + target_gappo;
|
||||||
|
|
@ -101,12 +91,9 @@ 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_should_ignore_focus(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);
|
||||||
cy = m->w.y + (i / cols) * (ch + target_gappi);
|
cy = m->w.y + (i / cols) * (ch + target_gappi);
|
||||||
if (overcols && i >= n - overcols) {
|
if (overcols && i >= n - overcols) {
|
||||||
|
|
@ -123,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;
|
||||||
|
|
@ -191,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; // 没有需要处理的客户端,直接返回
|
||||||
|
|
@ -227,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);
|
||||||
|
|
@ -245,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->ismaxmizescreen && !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);
|
||||||
|
|
@ -263,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;
|
||||||
|
|
@ -276,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)) &&
|
||||||
|
|
@ -309,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;
|
||||||
|
|
@ -327,7 +366,7 @@ void scroller(Monitor *m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
@ -336,6 +375,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)
|
||||||
|
|
@ -348,10 +389,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;
|
||||||
|
|
@ -359,7 +400,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];
|
||||||
|
|
||||||
|
|
@ -372,6 +413,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
|
||||||
|
|
@ -416,9 +470,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 -
|
||||||
|
|
@ -438,22 +494,22 @@ 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) {
|
||||||
// 单个堆叠窗口
|
// 单个堆叠窗口
|
||||||
r = n - i;
|
r = n - i;
|
||||||
if (c->stack_innder_per > 0.0f) {
|
if (c->stack_inner_per > 0.0f) {
|
||||||
h = (m->w.height - 2 * cur_gappov -
|
h = (m->w.height - 2 * cur_gappov -
|
||||||
cur_gappiv * ie * (stack_num - 1)) *
|
cur_gappiv * ie * (stack_num - 1)) *
|
||||||
c->stack_innder_per;
|
c->stack_inner_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 -
|
||||||
cur_gappiv * ie * (r - 1)) /
|
cur_gappiv * ie * (r - 1)) /
|
||||||
r;
|
r;
|
||||||
c->stack_innder_per = h / (m->w.height - ety - cur_gappov -
|
c->stack_inner_per = h / (m->w.height - ety - cur_gappov -
|
||||||
cur_gappiv * ie * (r - 1));
|
cur_gappiv * ie * (r - 1));
|
||||||
c->master_mfact_per = mfact;
|
c->master_mfact_per = mfact;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -479,16 +535,19 @@ 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_inner_per > 0.0f) {
|
||||||
h = (m->w.height - 2 * cur_gappov -
|
h = slave_right_surplus_height * c->stack_inner_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_inner_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 -
|
||||||
cur_gappiv * ie * (r - 1)) /
|
cur_gappiv * ie * (r - 1)) /
|
||||||
r;
|
r;
|
||||||
c->stack_innder_per =
|
c->stack_inner_per =
|
||||||
h / (m->w.height - ety - cur_gappov -
|
h / (m->w.height - ety - cur_gappov -
|
||||||
cur_gappiv * ie * (r - 1));
|
cur_gappiv * ie * (r - 1));
|
||||||
c->master_mfact_per = mfact;
|
c->master_mfact_per = mfact;
|
||||||
|
|
@ -505,16 +564,19 @@ void center_tile(Monitor *m) {
|
||||||
ety += c->geom.height + cur_gappiv * ie;
|
ety += c->geom.height + cur_gappiv * ie;
|
||||||
} else {
|
} else {
|
||||||
// 左侧堆叠窗口
|
// 左侧堆叠窗口
|
||||||
if (c->stack_innder_per > 0.0f) {
|
if (c->stack_inner_per > 0.0f) {
|
||||||
h = (m->w.height - 2 * cur_gappov -
|
h = slave_left_surplus_height * c->stack_inner_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_inner_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 -
|
||||||
cur_gappiv * ie * (r - 1)) /
|
cur_gappiv * ie * (r - 1)) /
|
||||||
r;
|
r;
|
||||||
c->stack_innder_per =
|
c->stack_inner_per =
|
||||||
h / (m->w.height - oty - cur_gappov -
|
h / (m->w.height - oty - cur_gappov -
|
||||||
cur_gappiv * ie * (r - 1));
|
cur_gappiv * ie * (r - 1));
|
||||||
c->master_mfact_per = mfact;
|
c->master_mfact_per = mfact;
|
||||||
|
|
@ -536,7 +598,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;
|
||||||
|
|
@ -545,15 +607,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;
|
||||||
|
|
@ -577,15 +640,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 -
|
||||||
|
|
@ -604,21 +678,22 @@ void tile(Monitor *m) {
|
||||||
my += c->geom.height + cur_gappiv * ie;
|
my += c->geom.height + cur_gappiv * ie;
|
||||||
} else {
|
} else {
|
||||||
r = n - i;
|
r = n - i;
|
||||||
if (c->stack_innder_per > 0.0f) {
|
if (c->stack_inner_per > 0.0f) {
|
||||||
h = (m->w.height - 2 * cur_gappov -
|
h = slave_surplus_height * c->stack_inner_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_inner_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 -
|
||||||
cur_gappiv * ie * (r - 1)) /
|
cur_gappiv * ie * (r - 1)) /
|
||||||
r;
|
r;
|
||||||
c->stack_innder_per = h / (m->w.height - ty - cur_gappov -
|
c->stack_inner_per = h / (m->w.height - ty - cur_gappov -
|
||||||
cur_gappiv * ie * (r - 1));
|
cur_gappiv * ie * (r - 1));
|
||||||
c->master_mfact_per = mfact;
|
c->master_mfact_per = mfact;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wlr_log(WLR_ERROR, "stack_innder_per: %f", c->stack_innder_per);
|
// wlr_log(WLR_ERROR, "stack_inner_per: %f", c->stack_inner_per);
|
||||||
|
|
||||||
resize(c,
|
resize(c,
|
||||||
(struct wlr_box){.x = m->w.x + mw + cur_gappoh,
|
(struct wlr_box){.x = m->w.x + mw + cur_gappoh,
|
||||||
|
|
@ -633,7 +708,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;
|
||||||
|
|
@ -642,15 +717,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;
|
||||||
|
|
@ -674,15 +750,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 -
|
||||||
|
|
@ -702,21 +789,22 @@ void right_tile(Monitor *m) {
|
||||||
my += c->geom.height + cur_gappiv * ie;
|
my += c->geom.height + cur_gappiv * ie;
|
||||||
} else {
|
} else {
|
||||||
r = n - i;
|
r = n - i;
|
||||||
if (c->stack_innder_per > 0.0f) {
|
if (c->stack_inner_per > 0.0f) {
|
||||||
h = (m->w.height - 2 * cur_gappov -
|
h = slave_surplus_height * c->stack_inner_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_inner_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 -
|
||||||
cur_gappiv * ie * (r - 1)) /
|
cur_gappiv * ie * (r - 1)) /
|
||||||
r;
|
r;
|
||||||
c->stack_innder_per = h / (m->w.height - ty - cur_gappov -
|
c->stack_inner_per = h / (m->w.height - ty - cur_gappov -
|
||||||
cur_gappiv * ie * (r - 1));
|
cur_gappiv * ie * (r - 1));
|
||||||
c->master_mfact_per = mfact;
|
c->master_mfact_per = mfact;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wlr_log(WLR_ERROR, "stack_innder_per: %f", c->stack_innder_per);
|
// wlr_log(WLR_ERROR, "stack_inner_per: %f", c->stack_inner_per);
|
||||||
|
|
||||||
resize(c,
|
resize(c,
|
||||||
(struct wlr_box){.x = m->w.x + cur_gappoh,
|
(struct wlr_box){.x = m->w.x + cur_gappoh,
|
||||||
|
|
@ -735,8 +823,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;
|
||||||
|
|
@ -752,4 +840,15 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tgmix(Monitor *m) {
|
||||||
|
uint32_t n = m->visible_tiling_clients;
|
||||||
|
if (n <= 3) {
|
||||||
|
tile(m);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
grid(m);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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 tgmix(Monitor *m);
|
||||||
|
|
||||||
/* 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,
|
||||||
|
TGMIX,
|
||||||
};
|
};
|
||||||
|
|
||||||
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}, // 垂直卡片布局
|
||||||
|
{"TG", tgmix, "tgmix", TGMIX}, // 混合布局
|
||||||
};
|
};
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -39,16 +40,27 @@ void vertical_tile(Monitor *m) {
|
||||||
mh = m->w.height - 2 * cur_gapov + cur_gapiv * ie;
|
mh = m->w.height - 2 * cur_gapov + cur_gapiv * ie;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
mx = tx = cur_gapih;
|
mx = tx = cur_gapoh;
|
||||||
|
|
||||||
|
uint32_t master_surplus_width =
|
||||||
|
(m->w.width - 2 * cur_gapoh - cur_gapih * ie * (master_num - 1));
|
||||||
|
float master_surplus_ratio = 1.0;
|
||||||
|
|
||||||
|
uint32_t slave_surplus_width =
|
||||||
|
(m->w.width - 2 * cur_gapoh - 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)) /
|
||||||
|
|
@ -66,16 +78,17 @@ void vertical_tile(Monitor *m) {
|
||||||
mx += c->geom.width + cur_gapih * ie;
|
mx += c->geom.width + cur_gapih * ie;
|
||||||
} else {
|
} else {
|
||||||
r = n - i;
|
r = n - i;
|
||||||
if (c->stack_innder_per > 0.0f) {
|
if (c->stack_inner_per > 0.0f) {
|
||||||
w = (m->w.width - 2 * cur_gapih -
|
w = slave_surplus_width * c->stack_inner_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_inner_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)) /
|
||||||
r;
|
r;
|
||||||
c->stack_innder_per = w / (m->w.width - tx - cur_gapih -
|
c->stack_inner_per = w / (m->w.width - tx - cur_gapih -
|
||||||
cur_gapih * ie * (r - 1));
|
cur_gapih * ie * (r - 1));
|
||||||
c->master_mfact_per = mfact;
|
c->master_mfact_per = mfact;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -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->ismaxmizescreen && !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,13 +376,8 @@ 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_should_ignore_focus(c)) ||
|
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
||||||
ISTILED(c))) {
|
|
||||||
ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
|
ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
|
||||||
cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
|
cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
|
||||||
c->geom.x = m->w.x + (m->w.width - cw) / 2;
|
c->geom.x = m->w.x + (m->w.width - cw) / 2;
|
||||||
|
|
@ -333,13 +399,8 @@ 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_should_ignore_focus(c)) ||
|
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
||||||
ISTILED(c))) {
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
c->geom.x = m->w.x + (m->w.width - cw) / 2 + target_gappo;
|
c->geom.x = m->w.x + (m->w.width - cw) / 2 + target_gappo;
|
||||||
c->geom.y = m->w.y + target_gappo;
|
c->geom.y = m->w.y + target_gappo;
|
||||||
|
|
@ -380,12 +441,8 @@ 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_should_ignore_focus(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);
|
||||||
cy = m->w.y + (i % rows) * (ch + target_gappi);
|
cy = m->w.y + (i % rows) * (ch + target_gappi);
|
||||||
if (overrows && i >= n - overrows) {
|
if (overrows && i >= n - overrows) {
|
||||||
|
|
|
||||||