Merge branch 'DreamMaoMao:main' into main
29
README.md
|
|
@ -1,6 +1,6 @@
|
|||
# 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/).
|
||||
|
|
@ -101,12 +101,12 @@ emerge --ask --verbose gui-wm/mangowc
|
|||
## Other
|
||||
|
||||
```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
|
||||
meson build -Dprefix=/usr
|
||||
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
|
||||
meson build -Dprefix=/usr
|
||||
sudo ninja -C build install
|
||||
|
|
@ -119,6 +119,10 @@ sudo ninja -C build install
|
|||
|
||||
## Suggested Tools
|
||||
|
||||
### Hybrid component
|
||||
- [dms-shell](https://github.com/AvengeMedia/DankMaterialShell)
|
||||
|
||||
### Independent component
|
||||
- Application launcher (rofi, bemenu, wmenu, fuzzel)
|
||||
- Terminal emulator (foot, wezterm, alacritty, kitty, ghostty)
|
||||
- Status bar (waybar, eww, quickshell, ags), waybar is preferred
|
||||
|
|
@ -139,13 +143,25 @@ sudo ninja -C build install
|
|||
|
||||
## My Dotfiles
|
||||
|
||||
### Daily
|
||||
- Dependencies
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
- 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
|
||||
git clone https://github.com/DreamMaoMao/mango-config.git ~/.config/mango
|
||||
|
|
@ -173,7 +189,10 @@ Here's an example of using the modules in a flake:
|
|||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
mango.url = "github:DreamMaoMao/mango";
|
||||
mango = {
|
||||
url = "github:DreamMaoMao/mango";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
outputs =
|
||||
inputs@{ self, flake-parts, ... }:
|
||||
|
|
|
|||
|
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 |
|
|
@ -42,10 +42,12 @@ animation_duration_move=500
|
|||
animation_duration_open=400
|
||||
animation_duration_tag=350
|
||||
animation_duration_close=800
|
||||
animation_duration_focus=0
|
||||
animation_curve_open=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_close=0.08,0.92,0,1
|
||||
animation_curve_focus=0.46,1.0,0.29,1
|
||||
|
||||
# Scroller Layout Setting
|
||||
scroller_structs=20
|
||||
|
|
@ -240,7 +242,7 @@ bind=CTRL+ALT,Right,resizewin,+50,+0
|
|||
mousebind=SUPER,btn_left,moveresize,curmove
|
||||
mousebind=NONE,btn_middle,togglemaximizescreen,0
|
||||
mousebind=SUPER,btn_right,moveresize,curresize
|
||||
mousebind=NONE,btn_left,toggleoverview,-1
|
||||
mousebind=NONE,btn_left,toggleoverview,1
|
||||
mousebind=NONE,btn_right,killclient,0
|
||||
|
||||
# Axis Bindings
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
}: let
|
||||
inherit (pkgs) callPackage ;
|
||||
mango = callPackage ./nix {
|
||||
inherit (inputs.scenefx.packages.${pkgs.system}) scenefx;
|
||||
inherit (inputs.scenefx.packages.${pkgs.stdenv.hostPlatform.system}) scenefx;
|
||||
};
|
||||
shellOverride = old: {
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
project('mango', ['c', 'cpp'],
|
||||
version : '0.10.4',
|
||||
version : '0.10.6',
|
||||
)
|
||||
|
||||
subdir('protocols')
|
||||
|
|
@ -32,10 +32,10 @@ cc = meson.get_compiler('c')
|
|||
libm = cc.find_library('m')
|
||||
xcb = dependency('xcb', 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')
|
||||
xkbcommon_dep = dependency('xkbcommon')
|
||||
libinput_dep = dependency('libinput')
|
||||
libinput_dep = dependency('libinput',version: '>=1.27.1')
|
||||
libwayland_client_dep = dependency('wayland-client')
|
||||
pcre2_dep = dependency('libpcre2-8')
|
||||
libscenefx_dep = dependency('scenefx-0.4',version: '>=0.4.1')
|
||||
|
|
|
|||
27
mmsg/mmsg.c
|
|
@ -41,6 +41,7 @@ static int xflag;
|
|||
static int eflag;
|
||||
static int kflag;
|
||||
static int bflag;
|
||||
static int Aflag;
|
||||
|
||||
static uint32_t occ, seltags, total_clients, urg;
|
||||
|
||||
|
|
@ -264,6 +265,18 @@ static void dwl_ipc_output_kb_layout(void *data,
|
|||
printf("kb_layout %s\n", kb_layout);
|
||||
}
|
||||
|
||||
static void
|
||||
dwl_ipc_output_scalefactor(void *data,
|
||||
struct zdwl_ipc_output_v2 *dwl_ipc_output,
|
||||
const unsigned int 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,
|
||||
struct zdwl_ipc_output_v2 *dwl_ipc_output,
|
||||
const char *keymode) {
|
||||
|
|
@ -413,6 +426,7 @@ static const struct zdwl_ipc_output_v2_listener dwl_ipc_output_listener = {
|
|||
.last_layer = dwl_ipc_output_last_layer,
|
||||
.kb_layout = dwl_ipc_output_kb_layout,
|
||||
.keymode = dwl_ipc_output_keymode,
|
||||
.scalefactor = dwl_ipc_output_scalefactor,
|
||||
.frame = dwl_ipc_output_frame,
|
||||
};
|
||||
|
||||
|
|
@ -490,7 +504,7 @@ static void usage(void) {
|
|||
"\t%s [-OTLq]\n"
|
||||
"\t%s [-o <output>] -s [-t <tags>] [-l <layout>] [-c <tags>] [-d "
|
||||
"<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);
|
||||
exit(2);
|
||||
}
|
||||
|
|
@ -732,6 +746,12 @@ int main(int argc, char *argv[]) {
|
|||
usage();
|
||||
mode |= GET;
|
||||
break;
|
||||
case 'A':
|
||||
Aflag = 1;
|
||||
if (mode == SET)
|
||||
usage();
|
||||
mode |= GET;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "bad option %c\n", ARGC());
|
||||
usage();
|
||||
|
|
@ -741,9 +761,10 @@ int main(int argc, char *argv[]) {
|
|||
usage();
|
||||
if (mode & GET && !output_name &&
|
||||
!(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 =
|
||||
kflag = bflag = 1;
|
||||
kflag = bflag = Aflag = 1;
|
||||
|
||||
display = wl_display_connect(NULL);
|
||||
if (!display)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ in {
|
|||
};
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = self.packages.${pkgs.system}.mango;
|
||||
default = self.packages.${pkgs.stdenv.hostPlatform.system}.mango;
|
||||
description = "The mango package to use";
|
||||
};
|
||||
systemd = {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ in {
|
|||
enable = lib.mkEnableOption "mango, a wayland compositor based on dwl";
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = self.packages.${pkgs.system}.mango;
|
||||
default = self.packages.${pkgs.stdenv.hostPlatform.system}.mango;
|
||||
description = "The mango package to use";
|
||||
};
|
||||
};
|
||||
|
|
@ -26,6 +26,25 @@ in {
|
|||
xdg.portal = {
|
||||
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;
|
||||
|
||||
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."/>
|
||||
</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>
|
||||
|
||||
</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-foreign-toplevel-list/ext-foreign-toplevel-list-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',
|
||||
'dwl-ipc-unstable-v2.xml',
|
||||
'wlr-layer-shell-unstable-v1.xml',
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
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) {
|
||||
|
|
@ -257,12 +251,16 @@ void buffer_set_effect(Client *c, BufferData data) {
|
|||
|
||||
void client_draw_shadow(Client *c) {
|
||||
|
||||
if (c->iskilling || !client_surface(c)->mapped)
|
||||
if (c->iskilling || !client_surface(c)->mapped || c->isnoshadow)
|
||||
return;
|
||||
|
||||
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;
|
||||
} 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);
|
||||
|
|
@ -448,7 +446,7 @@ struct ivec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
|
|||
int offsetx = 0, offsety = 0, offsetw = 0, offseth = 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)
|
||||
return offset;
|
||||
|
||||
|
|
@ -469,7 +467,7 @@ struct ivec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
|
|||
需要主要border超出屏幕的时候不计算如偏差之内而是
|
||||
要等窗口表面超出才开始计算偏差
|
||||
*/
|
||||
if (ISTILED(c) || c->animation.tagining || c->animation.tagouted ||
|
||||
if (ISSCROLLTILED(c) || c->animation.tagining || c->animation.tagouted ||
|
||||
c->animation.tagouting) {
|
||||
if (left_out_offset > 0) {
|
||||
offsetx = GEZERO(left_out_offset - bw);
|
||||
|
|
@ -497,7 +495,7 @@ struct ivec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
|
|||
offset.height = offseth;
|
||||
|
||||
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;
|
||||
wlr_scene_node_set_enabled(&c->scene->node, false);
|
||||
} else if (c->is_clip_to_hide && VISIBLEON(c, c->mon)) {
|
||||
|
|
@ -517,7 +515,6 @@ void client_apply_clip(Client *c, float factor) {
|
|||
bool should_render_client_surface = false;
|
||||
struct ivec2 offset;
|
||||
BufferData buffer_data;
|
||||
float opacity, percent;
|
||||
|
||||
enum corner_location current_corner_location =
|
||||
set_client_corner_location(c);
|
||||
|
|
@ -537,29 +534,17 @@ void client_apply_clip(Client *c, float factor) {
|
|||
apply_border(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) {
|
||||
return;
|
||||
}
|
||||
|
||||
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box);
|
||||
buffer_set_effect(c, (BufferData){1.0f, 1.0f, clip_box.width,
|
||||
clip_box.height, opacity, opacity,
|
||||
clip_box.height,
|
||||
current_corner_location, true});
|
||||
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;
|
||||
client_actual_size(c, &width, &height);
|
||||
|
|
@ -614,8 +599,6 @@ void client_apply_clip(Client *c, float factor) {
|
|||
buffer_data.width = clip_box.width;
|
||||
buffer_data.height = clip_box.height;
|
||||
buffer_data.corner_location = current_corner_location;
|
||||
buffer_data.percent = percent;
|
||||
buffer_data.opacity = opacity;
|
||||
|
||||
if (factor == 1.0) {
|
||||
buffer_data.width_scale = 1.0;
|
||||
|
|
@ -636,10 +619,15 @@ void fadeout_client_animation_next_tick(Client *c) {
|
|||
|
||||
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 =
|
||||
c->animation.total_frames
|
||||
? (double)c->animation.passed_frames / c->animation.total_frames
|
||||
c->animation.duration
|
||||
? (double)passed_time / (double)c->animation.duration
|
||||
: 1.0;
|
||||
|
||||
int type = c->animation.action = c->animation.action;
|
||||
double factor = find_animation_curve_at(animation_passed, type);
|
||||
unsigned int width =
|
||||
|
|
@ -683,20 +671,22 @@ void fadeout_client_animation_next_tick(Client *c) {
|
|||
&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);
|
||||
wlr_scene_node_destroy(&c->scene->node);
|
||||
free(c);
|
||||
c = NULL;
|
||||
} else {
|
||||
c->animation.passed_frames++;
|
||||
}
|
||||
}
|
||||
|
||||
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 =
|
||||
c->animation.total_frames
|
||||
? (double)c->animation.passed_frames / c->animation.total_frames
|
||||
c->animation.duration
|
||||
? (double)passed_time / (double)c->animation.duration
|
||||
: 1.0;
|
||||
|
||||
int type = c->animation.action == NONE ? MOVE : c->animation.action;
|
||||
|
|
@ -728,7 +718,7 @@ void client_animation_next_tick(Client *c) {
|
|||
|
||||
c->is_pending_open_animation = false;
|
||||
|
||||
if (animation_passed == 1.0) {
|
||||
if (animation_passed >= 1.0) {
|
||||
|
||||
// clear the open action state
|
||||
// To prevent him from being mistaken that
|
||||
|
|
@ -756,8 +746,6 @@ void client_animation_next_tick(Client *c) {
|
|||
|
||||
// end flush in next frame, not the current frame
|
||||
c->need_output_flush = false;
|
||||
} else {
|
||||
c->animation.passed_frames++;
|
||||
}
|
||||
|
||||
client_apply_clip(c, factor);
|
||||
|
|
@ -841,14 +829,12 @@ void init_fadeout_client(Client *c) {
|
|||
fadeout_cient->geom.height * zoom_end_ratio;
|
||||
}
|
||||
|
||||
fadeout_cient->animation.passed_frames = 0;
|
||||
fadeout_cient->animation.total_frames =
|
||||
fadeout_cient->animation.duration / all_output_frame_duration_ms();
|
||||
fadeout_cient->animation.time_started = get_now_in_ms();
|
||||
wlr_scene_node_set_enabled(&fadeout_cient->scene->node, true);
|
||||
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) {
|
||||
|
|
@ -860,30 +846,21 @@ void client_commit(Client *c) {
|
|||
}
|
||||
|
||||
c->animation.initial = c->animainit_geom;
|
||||
// 设置动画速度
|
||||
c->animation.passed_frames = 0;
|
||||
c->animation.total_frames =
|
||||
c->animation.duration / all_output_frame_duration_ms();
|
||||
c->animation.time_started = get_now_in_ms();
|
||||
|
||||
// 标记动画开始
|
||||
c->animation.running = true;
|
||||
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) {
|
||||
|
||||
if (!c || c->iskilling)
|
||||
return;
|
||||
|
||||
// 判断是否需要动画
|
||||
if (!animations) {
|
||||
c->animation.should_animate = false;
|
||||
|
|
@ -915,6 +892,11 @@ void client_set_pending_state(Client *c) {
|
|||
c->animation.duration = 0;
|
||||
}
|
||||
|
||||
if (c->isnoanimation) {
|
||||
c->animation.should_animate = false;
|
||||
c->animation.duration = 0;
|
||||
}
|
||||
|
||||
// 开始动画
|
||||
client_commit(c);
|
||||
c->dirty = true;
|
||||
|
|
@ -1048,22 +1030,159 @@ bool client_draw_fadeout_frame(Client *c) {
|
|||
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;
|
||||
|
||||
float percent =
|
||||
animation_fade_in && !c->nofadein ? linear_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) {
|
||||
|
||||
if (!c || !client_surface(c)->mapped)
|
||||
return false;
|
||||
|
||||
if (c->isfullscreen) {
|
||||
client_set_opacity(c, 1);
|
||||
} 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 client_apply_focus_opacity(c);
|
||||
}
|
||||
|
||||
if (!c->need_output_flush)
|
||||
return false;
|
||||
|
||||
if (animations && c->animation.running) {
|
||||
client_animation_next_tick(c);
|
||||
} else {
|
||||
|
|
@ -1074,5 +1193,6 @@ bool client_draw_frame(Client *c) {
|
|||
client_apply_clip(c, 1.0);
|
||||
c->need_output_flush = false;
|
||||
}
|
||||
client_apply_focus_opacity(c);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ struct dvec2 calculate_animation_curve_at(double t, int type) {
|
|||
animation_curve = animation_curve_tag;
|
||||
} else if (type == CLOSE) {
|
||||
animation_curve = animation_curve_close;
|
||||
} else if (type == FOCUS) {
|
||||
animation_curve = animation_curve_focus;
|
||||
} else {
|
||||
animation_curve = animation_curve_move;
|
||||
}
|
||||
|
|
@ -28,6 +30,8 @@ void init_baked_points(void) {
|
|||
baked_points_tag = calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_tag));
|
||||
baked_points_close =
|
||||
calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_close));
|
||||
baked_points_focus =
|
||||
calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_focus));
|
||||
|
||||
for (unsigned int i = 0; i < BAKED_POINTS_COUNT; i++) {
|
||||
baked_points_move[i] = calculate_animation_curve_at(
|
||||
|
|
@ -45,6 +49,10 @@ void init_baked_points(void) {
|
|||
baked_points_close[i] = calculate_animation_curve_at(
|
||||
(double)i / (BAKED_POINTS_COUNT - 1), CLOSE);
|
||||
}
|
||||
for (unsigned int i = 0; i < BAKED_POINTS_COUNT; i++) {
|
||||
baked_points_focus[i] = calculate_animation_curve_at(
|
||||
(double)i / (BAKED_POINTS_COUNT - 1), FOCUS);
|
||||
}
|
||||
}
|
||||
|
||||
double find_animation_curve_at(double t, int type) {
|
||||
|
|
@ -61,6 +69,8 @@ double find_animation_curve_at(double t, int type) {
|
|||
baked_points = baked_points_tag;
|
||||
} else if (type == CLOSE) {
|
||||
baked_points = baked_points_close;
|
||||
} else if (type == FOCUS) {
|
||||
baked_points = baked_points_focus;
|
||||
} else {
|
||||
baked_points = baked_points_move;
|
||||
}
|
||||
|
|
@ -76,22 +86,6 @@ double find_animation_curve_at(double t, int type) {
|
|||
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,
|
||||
struct wlr_scene_tree *snapshot_tree) {
|
||||
if (!node->enabled && node->type != WLR_SCENE_NODE_TREE) {
|
||||
|
|
@ -234,4 +228,14 @@ struct wlr_scene_tree *wlr_scene_tree_snapshot(struct wlr_scene_node *node,
|
|||
wlr_scene_node_set_enabled(&snapshot->node, true);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -234,10 +234,15 @@ void fadeout_layer_animation_next_tick(LayerSurface *l) {
|
|||
if (!l)
|
||||
return;
|
||||
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
|
||||
uint32_t passed_time = timespec_to_ms(&now) - l->animation.time_started;
|
||||
double animation_passed =
|
||||
l->animation.total_frames
|
||||
? (double)l->animation.passed_frames / l->animation.total_frames
|
||||
l->animation.duration
|
||||
? (double)passed_time / (double)l->animation.duration
|
||||
: 1.0;
|
||||
|
||||
int type = l->animation.action = l->animation.action;
|
||||
double factor = find_animation_curve_at(animation_passed, type);
|
||||
unsigned int width =
|
||||
|
|
@ -280,13 +285,11 @@ void fadeout_layer_animation_next_tick(LayerSurface *l) {
|
|||
wlr_scene_node_for_each_buffer(&l->scene->node,
|
||||
scene_buffer_apply_opacity, &opacity);
|
||||
|
||||
if (animation_passed == 1.0) {
|
||||
if (animation_passed >= 1.0) {
|
||||
wl_list_remove(&l->fadeout_link);
|
||||
wlr_scene_node_destroy(&l->scene->node);
|
||||
free(l);
|
||||
l = NULL;
|
||||
} else {
|
||||
l->animation.passed_frames++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -295,9 +298,13 @@ void layer_animation_next_tick(LayerSurface *l) {
|
|||
if (!l || !l->mapped)
|
||||
return;
|
||||
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
|
||||
uint32_t passed_time = timespec_to_ms(&now) - l->animation.time_started;
|
||||
double animation_passed =
|
||||
l->animation.total_frames
|
||||
? (double)l->animation.passed_frames / l->animation.total_frames
|
||||
l->animation.duration
|
||||
? (double)passed_time / (double)l->animation.duration
|
||||
: 1.0;
|
||||
|
||||
int type = l->animation.action == NONE ? MOVE : l->animation.action;
|
||||
|
|
@ -315,7 +322,9 @@ void layer_animation_next_tick(LayerSurface *l) {
|
|||
unsigned int y = l->animation.initial.y +
|
||||
(l->current.y - l->animation.initial.y) * factor;
|
||||
|
||||
double opacity = MIN(fadein_begin_opacity + animation_passed, 1.0f);
|
||||
double opacity = MIN(fadein_begin_opacity +
|
||||
animation_passed * (1.0 - fadein_begin_opacity),
|
||||
1.0f);
|
||||
|
||||
if (animation_fade_in)
|
||||
wlr_scene_node_for_each_buffer(&l->scene->node,
|
||||
|
|
@ -347,12 +356,10 @@ void layer_animation_next_tick(LayerSurface *l) {
|
|||
.height = height,
|
||||
};
|
||||
|
||||
if (animation_passed == 1.0) {
|
||||
if (animation_passed >= 1.0) {
|
||||
l->animation.running = false;
|
||||
l->need_output_flush = false;
|
||||
l->animation.action = MOVE;
|
||||
} else {
|
||||
l->animation.passed_frames++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -446,10 +453,8 @@ void init_fadeout_layers(LayerSurface *l) {
|
|||
fadeout_layer->current.height = 0;
|
||||
}
|
||||
|
||||
// 计算动画帧数
|
||||
fadeout_layer->animation.passed_frames = 0;
|
||||
fadeout_layer->animation.total_frames =
|
||||
fadeout_layer->animation.duration / all_output_frame_duration_ms();
|
||||
// 动画开始时间
|
||||
fadeout_layer->animation.time_started = get_now_in_ms();
|
||||
|
||||
// 将节点插入到关闭动画链表中,屏幕刷新哪里会检查链表中是否有节点可以应用于动画
|
||||
wlr_scene_node_set_enabled(&fadeout_layer->scene->node, true);
|
||||
|
|
@ -532,23 +537,11 @@ void layer_commit(LayerSurface *l) {
|
|||
}
|
||||
|
||||
l->animation.initial = l->animainit_geom;
|
||||
// 设置动画速度
|
||||
l->animation.passed_frames = 0;
|
||||
l->animation.total_frames =
|
||||
l->animation.duration / output_frame_duration_ms(l->mon);
|
||||
l->animation.time_started = get_now_in_ms();
|
||||
|
||||
// 标记动画开始
|
||||
l->animation.running = true;
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -153,6 +153,20 @@ static inline void client_get_geometry(Client *c, struct wlr_box *geom) {
|
|||
*geom = c->surface.xdg->geometry;
|
||||
}
|
||||
|
||||
static inline Client *get_client_from_surface(struct wlr_surface *surface) {
|
||||
if (!surface)
|
||||
return NULL;
|
||||
|
||||
// 从 surface 的 data 指针获取 scene tree
|
||||
struct wlr_scene_tree *scene_tree = surface->data;
|
||||
if (!scene_tree)
|
||||
return NULL;
|
||||
|
||||
// 从 scene tree 的 node data 获取 Client
|
||||
Client *c = scene_tree->node.data;
|
||||
return c;
|
||||
}
|
||||
|
||||
static inline Client *client_get_parent(Client *c) {
|
||||
Client *p = NULL;
|
||||
#ifdef XWAYLAND
|
||||
|
|
@ -359,7 +373,7 @@ static inline void client_set_maximized(Client *c, bool maximized) {
|
|||
static inline void client_set_tiled(Client *c, uint32_t edges) {
|
||||
struct wlr_xdg_toplevel *toplevel;
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
if (client_is_x11(c) && c->force_maximize) {
|
||||
wlr_xwayland_surface_set_maximized(c->surface.xwayland,
|
||||
edges != WLR_EDGE_NONE,
|
||||
edges != WLR_EDGE_NONE);
|
||||
|
|
@ -374,7 +388,7 @@ static inline void client_set_tiled(Client *c, uint32_t 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);
|
||||
}
|
||||
}
|
||||
|
|
@ -390,6 +404,21 @@ static inline void client_set_suspended(Client *c, int suspended) {
|
|||
|
||||
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
|
||||
if (client_is_x11(c)) {
|
||||
struct wlr_xwayland_surface *surface = c->surface.xwayland;
|
||||
|
|
@ -473,6 +502,18 @@ static inline bool client_request_minimize(Client *c, void *data) {
|
|||
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) {
|
||||
struct wlr_xdg_toplevel *toplevel;
|
||||
struct wlr_xdg_toplevel_state state;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
|
|
@ -80,3 +81,15 @@ int regex_match(const char *pattern, const char *str) {
|
|||
void wl_list_append(struct wl_list *list, struct wl_list *object) {
|
||||
wl_list_insert(list->prev, object);
|
||||
}
|
||||
|
||||
unsigned int get_now_in_ms(void) {
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
|
||||
return timespec_to_ms(&now);
|
||||
}
|
||||
|
||||
unsigned int timespec_to_ms(struct timespec *ts) {
|
||||
return (unsigned int)ts->tv_sec * 1000 +
|
||||
(unsigned int)ts->tv_nsec / 1000000;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,3 +6,5 @@ void *ecalloc(size_t nmemb, size_t size);
|
|||
int fd_set_nonblock(int fd);
|
||||
int regex_match(const char *pattern_mb, const char *str_mb);
|
||||
void wl_list_append(struct wl_list *list, struct wl_list *object);
|
||||
unsigned int get_now_in_ms(void);
|
||||
unsigned int timespec_to_ms(struct timespec *ts);
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
enum { NUM_TYPE_MINUS, NUM_TYPE_PLUS, NUM_TYPE_DEFAULT };
|
||||
|
||||
enum { KEY_TYPE_SYM, KEY_TYPE_CODE };
|
||||
enum { KEY_TYPE_CODE, KEY_TYPE_SYM };
|
||||
|
||||
typedef struct {
|
||||
uint32_t keycode1;
|
||||
|
|
@ -40,6 +40,8 @@ typedef struct {
|
|||
char mode[28];
|
||||
bool iscommonmode;
|
||||
bool isdefaultmode;
|
||||
bool islockapply;
|
||||
bool isreleaseapply;
|
||||
} KeyBinding;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -59,12 +61,15 @@ typedef struct {
|
|||
const char *layer_animation_type_open;
|
||||
const char *layer_animation_type_close;
|
||||
int isnoborder;
|
||||
int isnoshadow;
|
||||
int isnoanimation;
|
||||
int isopensilent;
|
||||
int istagsilent;
|
||||
int isnamedscratchpad;
|
||||
int isunglobal;
|
||||
int isglobal;
|
||||
int isoverlay;
|
||||
int allow_shortcuts_inhibit;
|
||||
int ignore_maximize;
|
||||
int ignore_minimize;
|
||||
int isnosizehint;
|
||||
|
|
@ -73,16 +78,19 @@ typedef struct {
|
|||
int offsety;
|
||||
int width;
|
||||
int height;
|
||||
int nofocus;
|
||||
int nofadein;
|
||||
int nofadeout;
|
||||
int no_force_center;
|
||||
int isterm;
|
||||
int allow_csd;
|
||||
int force_maximize;
|
||||
int force_tearing;
|
||||
int noswallow;
|
||||
int noblur;
|
||||
float focused_opacity;
|
||||
float unfocused_opacity;
|
||||
float scroller_proportion_single;
|
||||
uint32_t passmod;
|
||||
xkb_keysym_t keysym;
|
||||
KeyBinding globalkeybinding;
|
||||
|
|
@ -178,14 +186,17 @@ typedef struct {
|
|||
uint32_t animation_duration_open;
|
||||
uint32_t animation_duration_tag;
|
||||
uint32_t animation_duration_close;
|
||||
uint32_t animation_duration_focus;
|
||||
double animation_curve_move[4];
|
||||
double animation_curve_open[4];
|
||||
double animation_curve_tag[4];
|
||||
double animation_curve_close[4];
|
||||
double animation_curve_focus[4];
|
||||
|
||||
int scroller_structs;
|
||||
float scroller_default_proportion;
|
||||
float scroller_default_proportion_single;
|
||||
int scroller_ignore_proportion_single;
|
||||
int scroller_focus_center;
|
||||
int scroller_prefer_center;
|
||||
int edge_scroller_pointer_focus;
|
||||
|
|
@ -326,6 +337,9 @@ typedef struct {
|
|||
int xwayland_persistence;
|
||||
int syncobj_enable;
|
||||
int adaptive_sync;
|
||||
int allow_tearing;
|
||||
int allow_shortcuts_inhibit;
|
||||
int allow_lock_transparent;
|
||||
|
||||
struct xkb_rule_names xkb_rules;
|
||||
|
||||
|
|
@ -406,6 +420,35 @@ char *sanitize_string(char *str) {
|
|||
return str;
|
||||
}
|
||||
|
||||
// 解析bind组合字符串
|
||||
void parse_bind_flags(const char *str, KeyBinding *kb) {
|
||||
|
||||
// 检查是否以"bind"开头
|
||||
if (strncmp(str, "bind", 4) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const char *suffix = str + 4; // 跳过"bind"
|
||||
|
||||
// 遍历后缀字符
|
||||
for (int i = 0; suffix[i] != '\0'; i++) {
|
||||
switch (suffix[i]) {
|
||||
case 's':
|
||||
kb->keysymcode.type = KEY_TYPE_SYM;
|
||||
break;
|
||||
case 'l':
|
||||
kb->islockapply = true;
|
||||
break;
|
||||
case 'r':
|
||||
kb->isreleaseapply = true;
|
||||
break;
|
||||
default:
|
||||
// 忽略其他字符或可根据需要处理错误
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int parse_circle_direction(const char *str) {
|
||||
// 将输入字符串转换为小写
|
||||
char lowerStr[10];
|
||||
|
|
@ -476,61 +519,6 @@ long int parse_color(const char *hex_str) {
|
|||
return hex_num;
|
||||
}
|
||||
|
||||
xkb_keysym_t normalize_keysym(xkb_keysym_t sym) {
|
||||
// 首先转换为小写(主要影响字母键)
|
||||
sym = xkb_keysym_to_lower(sym);
|
||||
|
||||
// 将数字小键盘键转换为普通数字键
|
||||
switch (sym) {
|
||||
// 小键盘数字转换
|
||||
case XKB_KEY_KP_0:
|
||||
return XKB_KEY_0;
|
||||
case XKB_KEY_KP_1:
|
||||
return XKB_KEY_1;
|
||||
case XKB_KEY_KP_2:
|
||||
return XKB_KEY_2;
|
||||
case XKB_KEY_KP_3:
|
||||
return XKB_KEY_3;
|
||||
case XKB_KEY_KP_4:
|
||||
return XKB_KEY_4;
|
||||
case XKB_KEY_KP_5:
|
||||
return XKB_KEY_5;
|
||||
case XKB_KEY_KP_6:
|
||||
return XKB_KEY_6;
|
||||
case XKB_KEY_KP_7:
|
||||
return XKB_KEY_7;
|
||||
case XKB_KEY_KP_8:
|
||||
return XKB_KEY_8;
|
||||
case XKB_KEY_KP_9:
|
||||
return XKB_KEY_9;
|
||||
|
||||
// 将 Shift+数字 的符号转换回基础数字
|
||||
case XKB_KEY_exclam:
|
||||
return XKB_KEY_1; // !
|
||||
case XKB_KEY_at:
|
||||
return XKB_KEY_2; // @
|
||||
case XKB_KEY_numbersign:
|
||||
return XKB_KEY_3; // #
|
||||
case XKB_KEY_dollar:
|
||||
return XKB_KEY_4; // $
|
||||
case XKB_KEY_percent:
|
||||
return XKB_KEY_5; // %
|
||||
case XKB_KEY_asciicircum:
|
||||
return XKB_KEY_6; // ^
|
||||
case XKB_KEY_ampersand:
|
||||
return XKB_KEY_7; // &
|
||||
case XKB_KEY_asterisk:
|
||||
return XKB_KEY_8; // *
|
||||
case XKB_KEY_parenleft:
|
||||
return XKB_KEY_9; // (
|
||||
case XKB_KEY_parenright:
|
||||
return XKB_KEY_0; // )
|
||||
|
||||
default:
|
||||
return sym;
|
||||
}
|
||||
}
|
||||
|
||||
// 辅助函数:检查字符串是否以指定的前缀开头(忽略大小写)
|
||||
static bool starts_with_ignore_case(const char *str, const char *prefix) {
|
||||
while (*prefix) {
|
||||
|
|
@ -845,12 +833,10 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
|
|||
func = toggleglobal;
|
||||
} else if (strcmp(func_name, "toggleoverview") == 0) {
|
||||
func = toggleoverview;
|
||||
(*arg).i = atoi(arg_value);
|
||||
} else if (strcmp(func_name, "set_proportion") == 0) {
|
||||
func = set_proportion;
|
||||
(*arg).f = atof(arg_value);
|
||||
} else if (strcmp(func_name, "increase_proportion") == 0) {
|
||||
func = increase_proportion;
|
||||
(*arg).f = atof(arg_value);
|
||||
} else if (strcmp(func_name, "switch_proportion_preset") == 0) {
|
||||
func = switch_proportion_preset;
|
||||
} else if (strcmp(func_name, "viewtoleft") == 0) {
|
||||
|
|
@ -923,13 +909,13 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
|
|||
} else if (strcmp(func_name, "setkeymode") == 0) {
|
||||
func = setkeymode;
|
||||
(*arg).v = strdup(arg_value);
|
||||
} else if (strcmp(func_name, "switch_keyboard_layout") == 0) {
|
||||
func = switch_keyboard_layout;
|
||||
} else if (strcmp(func_name, "setlayout") == 0) {
|
||||
func = setlayout;
|
||||
(*arg).v = strdup(arg_value);
|
||||
} else if (strcmp(func_name, "switch_layout") == 0) {
|
||||
func = switch_layout;
|
||||
} else if (strcmp(func_name, "switch_keyboard_layout") == 0) {
|
||||
func = switch_keyboard_layout;
|
||||
} else if (strcmp(func_name, "togglefloating") == 0) {
|
||||
func = togglefloating;
|
||||
} else if (strcmp(func_name, "togglefullscreen") == 0) {
|
||||
|
|
@ -1048,6 +1034,15 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
|
|||
(*arg).v = strdup(arg_value);
|
||||
(*arg).v2 = strdup(arg_value2);
|
||||
(*arg).v3 = strdup(arg_value3);
|
||||
} else if (strcmp(func_name, "disable_monitor") == 0) {
|
||||
func = disable_monitor;
|
||||
(*arg).v = strdup(arg_value);
|
||||
} else if (strcmp(func_name, "enable_monitor") == 0) {
|
||||
func = enable_monitor;
|
||||
(*arg).v = strdup(arg_value);
|
||||
} else if (strcmp(func_name, "toggle_monitor") == 0) {
|
||||
func = toggle_monitor;
|
||||
(*arg).v = strdup(arg_value);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1123,6 +1118,8 @@ void parse_option(Config *config, char *key, char *value) {
|
|||
config->animation_duration_tag = atoi(value);
|
||||
} else if (strcmp(key, "animation_duration_close") == 0) {
|
||||
config->animation_duration_close = atoi(value);
|
||||
} else if (strcmp(key, "animation_duration_focus") == 0) {
|
||||
config->animation_duration_focus = atoi(value);
|
||||
} else if (strcmp(key, "animation_curve_move") == 0) {
|
||||
int num = parse_double_array(value, config->animation_curve_move, 4);
|
||||
if (num != 4) {
|
||||
|
|
@ -1148,12 +1145,21 @@ void parse_option(Config *config, char *key, char *value) {
|
|||
"Error: Failed to parse animation_curve_close: %s\n",
|
||||
value);
|
||||
}
|
||||
} else if (strcmp(key, "animation_curve_focus") == 0) {
|
||||
int num = parse_double_array(value, config->animation_curve_focus, 4);
|
||||
if (num != 4) {
|
||||
fprintf(stderr,
|
||||
"Error: Failed to parse animation_curve_focus: %s\n",
|
||||
value);
|
||||
}
|
||||
} else if (strcmp(key, "scroller_structs") == 0) {
|
||||
config->scroller_structs = atoi(value);
|
||||
} else if (strcmp(key, "scroller_default_proportion") == 0) {
|
||||
config->scroller_default_proportion = atof(value);
|
||||
} else if (strcmp(key, "scroller_default_proportion_single") == 0) {
|
||||
config->scroller_default_proportion_single = atof(value);
|
||||
} else if (strcmp(key, "scroller_ignore_proportion_single") == 0) {
|
||||
config->scroller_ignore_proportion_single = atoi(value);
|
||||
} else if (strcmp(key, "scroller_focus_center") == 0) {
|
||||
config->scroller_focus_center = atoi(value);
|
||||
} else if (strcmp(key, "scroller_prefer_center") == 0) {
|
||||
|
|
@ -1212,6 +1218,12 @@ void parse_option(Config *config, char *key, char *value) {
|
|||
config->syncobj_enable = atoi(value);
|
||||
} else if (strcmp(key, "adaptive_sync") == 0) {
|
||||
config->adaptive_sync = atoi(value);
|
||||
} else if (strcmp(key, "allow_tearing") == 0) {
|
||||
config->allow_tearing = atoi(value);
|
||||
} else if (strcmp(key, "allow_shortcuts_inhibit") == 0) {
|
||||
config->allow_shortcuts_inhibit = atoi(value);
|
||||
} else if (strcmp(key, "allow_lock_transparent") == 0) {
|
||||
config->allow_lock_transparent = atoi(value);
|
||||
} else if (strcmp(key, "no_border_when_single") == 0) {
|
||||
config->no_border_when_single = atoi(value);
|
||||
} else if (strcmp(key, "no_radius_when_single") == 0) {
|
||||
|
|
@ -1641,20 +1653,25 @@ void parse_option(Config *config, char *key, char *value) {
|
|||
rule->isfloating = -1;
|
||||
rule->isfullscreen = -1;
|
||||
rule->isnoborder = -1;
|
||||
rule->isnoshadow = -1;
|
||||
rule->isnoanimation = -1;
|
||||
rule->isopensilent = -1;
|
||||
rule->istagsilent = -1;
|
||||
rule->isnamedscratchpad = -1;
|
||||
rule->isunglobal = -1;
|
||||
rule->isglobal = -1;
|
||||
rule->isoverlay = -1;
|
||||
rule->allow_shortcuts_inhibit = -1;
|
||||
rule->ignore_maximize = -1;
|
||||
rule->ignore_minimize = -1;
|
||||
rule->isnosizehint = -1;
|
||||
rule->isterm = -1;
|
||||
rule->allow_csd = -1;
|
||||
rule->force_maximize = -1;
|
||||
rule->force_tearing = -1;
|
||||
rule->noswallow = -1;
|
||||
rule->noblur = -1;
|
||||
rule->nofocus = -1;
|
||||
rule->nofadein = -1;
|
||||
rule->nofadeout = -1;
|
||||
rule->no_force_center = -1;
|
||||
|
|
@ -1666,6 +1683,7 @@ void parse_option(Config *config, char *key, char *value) {
|
|||
// float rule value, relay to a client property
|
||||
rule->focused_opacity = 0;
|
||||
rule->unfocused_opacity = 0;
|
||||
rule->scroller_proportion_single = 0.0f;
|
||||
rule->scroller_proportion = 0;
|
||||
|
||||
// special rule value,not directly set to client property
|
||||
|
|
@ -1709,6 +1727,8 @@ void parse_option(Config *config, char *key, char *value) {
|
|||
rule->offsetx = atoi(val);
|
||||
} else if (strcmp(key, "offsety") == 0) {
|
||||
rule->offsety = atoi(val);
|
||||
} else if (strcmp(key, "nofocus") == 0) {
|
||||
rule->nofocus = atoi(val);
|
||||
} else if (strcmp(key, "nofadein") == 0) {
|
||||
rule->nofadein = atoi(val);
|
||||
} else if (strcmp(key, "nofadeout") == 0) {
|
||||
|
|
@ -1721,6 +1741,10 @@ void parse_option(Config *config, char *key, char *value) {
|
|||
rule->height = atoi(val);
|
||||
} else if (strcmp(key, "isnoborder") == 0) {
|
||||
rule->isnoborder = atoi(val);
|
||||
} else if (strcmp(key, "isnoshadow") == 0) {
|
||||
rule->isnoshadow = atoi(val);
|
||||
} else if (strcmp(key, "isnoanimation") == 0) {
|
||||
rule->isnoanimation = atoi(val);
|
||||
} else if (strcmp(key, "isopensilent") == 0) {
|
||||
rule->isopensilent = atoi(val);
|
||||
} else if (strcmp(key, "istagsilent") == 0) {
|
||||
|
|
@ -1731,12 +1755,16 @@ void parse_option(Config *config, char *key, char *value) {
|
|||
rule->isunglobal = atoi(val);
|
||||
} else if (strcmp(key, "isglobal") == 0) {
|
||||
rule->isglobal = atoi(val);
|
||||
} else if (strcmp(key, "scroller_proportion_single") == 0) {
|
||||
rule->scroller_proportion_single = atof(val);
|
||||
} else if (strcmp(key, "unfocused_opacity") == 0) {
|
||||
rule->unfocused_opacity = atof(val);
|
||||
} else if (strcmp(key, "focused_opacity") == 0) {
|
||||
rule->focused_opacity = atof(val);
|
||||
} else if (strcmp(key, "isoverlay") == 0) {
|
||||
rule->isoverlay = atoi(val);
|
||||
} else if (strcmp(key, "allow_shortcuts_inhibit") == 0) {
|
||||
rule->allow_shortcuts_inhibit = atoi(val);
|
||||
} else if (strcmp(key, "ignore_maximize") == 0) {
|
||||
rule->ignore_maximize = atoi(val);
|
||||
} else if (strcmp(key, "ignore_minimize") == 0) {
|
||||
|
|
@ -1749,6 +1777,8 @@ void parse_option(Config *config, char *key, char *value) {
|
|||
rule->allow_csd = atoi(val);
|
||||
} else if (strcmp(key, "force_maximize") == 0) {
|
||||
rule->force_maximize = atoi(val);
|
||||
} else if (strcmp(key, "force_tearing") == 0) {
|
||||
rule->force_tearing = atoi(val);
|
||||
} else if (strcmp(key, "noswallow") == 0) {
|
||||
rule->noswallow = atoi(val);
|
||||
} else if (strcmp(key, "noblur") == 0) {
|
||||
|
|
@ -1901,8 +1931,7 @@ void parse_option(Config *config, char *key, char *value) {
|
|||
|
||||
config->exec_once_count++;
|
||||
|
||||
} else if (strncmp(key, "bind", 4) == 0 ||
|
||||
strncmp(key, "bindsym", 7) == 0) {
|
||||
} else if (regex_match("^bind[s|l|r]*$", key)) {
|
||||
config->key_bindings =
|
||||
realloc(config->key_bindings,
|
||||
(config->key_bindings_count + 1) * sizeof(KeyBinding));
|
||||
|
|
@ -1948,9 +1977,10 @@ void parse_option(Config *config, char *key, char *value) {
|
|||
binding->iscommonmode = false;
|
||||
}
|
||||
|
||||
binding->mod = parse_mod(mod_str);
|
||||
parse_bind_flags(key, binding);
|
||||
binding->keysymcode =
|
||||
parse_key(keysym_str, strncmp(key, "bindsym", 7) == 0);
|
||||
parse_key(keysym_str, binding->keysymcode.type == KEY_TYPE_SYM);
|
||||
binding->mod = parse_mod(mod_str);
|
||||
binding->arg.v = NULL;
|
||||
binding->arg.v2 = NULL;
|
||||
binding->arg.v3 = NULL;
|
||||
|
|
@ -2247,35 +2277,53 @@ void parse_config_line(Config *config, const char *line) {
|
|||
|
||||
void parse_config_file(Config *config, const char *file_path) {
|
||||
FILE *file;
|
||||
// 检查路径是否以 ~/ 开头
|
||||
if (file_path[0] == '~' && (file_path[1] == '/' || file_path[1] == '\0')) {
|
||||
char full_path[1024];
|
||||
|
||||
if (file_path[0] == '.' && file_path[1] == '/') {
|
||||
// Relative path
|
||||
|
||||
const char *mangoconfig = getenv("MANGOCONFIG");
|
||||
if (mangoconfig && mangoconfig[0] != '\0') {
|
||||
snprintf(full_path, sizeof(full_path), "%s/%s", mangoconfig,
|
||||
file_path + 1);
|
||||
} else {
|
||||
const char *home = getenv("HOME");
|
||||
if (!home) {
|
||||
fprintf(stderr, "Error: HOME environment variable not set.\n");
|
||||
return;
|
||||
}
|
||||
snprintf(full_path, sizeof(full_path), "%s/.config/mango/%s", home,
|
||||
file_path + 1);
|
||||
}
|
||||
file = fopen(full_path, "r");
|
||||
|
||||
} else if (file_path[0] == '~' &&
|
||||
(file_path[1] == '/' || file_path[1] == '\0')) {
|
||||
// Home directory
|
||||
|
||||
const char *home = getenv("HOME");
|
||||
if (!home) {
|
||||
fprintf(stderr, "Error: HOME environment variable not set.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建完整路径(家目录 + / + 原路径去掉 ~)
|
||||
char full_path[1024];
|
||||
snprintf(full_path, sizeof(full_path), "%s%s", home, file_path + 1);
|
||||
|
||||
file = fopen(full_path, "r");
|
||||
if (!file) {
|
||||
perror("Error opening file");
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Absolute path
|
||||
file = fopen(file_path, "r");
|
||||
if (!file) {
|
||||
perror("Error opening file");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!file) {
|
||||
perror("Error opening file");
|
||||
return;
|
||||
}
|
||||
|
||||
char line[512];
|
||||
while (fgets(line, sizeof(line), file)) {
|
||||
if (line[0] == '#' || line[0] == '\n')
|
||||
if (line[0] == '#' || line[0] == '\n') {
|
||||
continue;
|
||||
}
|
||||
parse_config_line(config, line);
|
||||
}
|
||||
|
||||
|
|
@ -2315,6 +2363,10 @@ void free_baked_points(void) {
|
|||
free(baked_points_tag);
|
||||
baked_points_tag = NULL;
|
||||
}
|
||||
if (baked_points_focus) {
|
||||
free(baked_points_focus);
|
||||
baked_points_focus = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void free_config(void) {
|
||||
|
|
@ -2586,12 +2638,16 @@ void override_config(void) {
|
|||
animation_duration_tag = CLAMP_INT(config.animation_duration_tag, 1, 50000);
|
||||
animation_duration_close =
|
||||
CLAMP_INT(config.animation_duration_close, 1, 50000);
|
||||
animation_duration_focus =
|
||||
CLAMP_INT(config.animation_duration_focus, 1, 50000);
|
||||
|
||||
// 滚动布局设置
|
||||
scroller_default_proportion =
|
||||
CLAMP_FLOAT(config.scroller_default_proportion, 0.1f, 1.0f);
|
||||
scroller_default_proportion_single =
|
||||
CLAMP_FLOAT(config.scroller_default_proportion_single, 0.1f, 1.0f);
|
||||
scroller_ignore_proportion_single =
|
||||
CLAMP_INT(config.scroller_ignore_proportion_single, 0, 1);
|
||||
scroller_focus_center = CLAMP_INT(config.scroller_focus_center, 0, 1);
|
||||
scroller_prefer_center = CLAMP_INT(config.scroller_prefer_center, 0, 1);
|
||||
edge_scroller_pointer_focus =
|
||||
|
|
@ -2616,6 +2672,9 @@ void override_config(void) {
|
|||
xwayland_persistence = CLAMP_INT(config.xwayland_persistence, 0, 1);
|
||||
syncobj_enable = CLAMP_INT(config.syncobj_enable, 0, 1);
|
||||
adaptive_sync = CLAMP_INT(config.adaptive_sync, 0, 1);
|
||||
allow_tearing = CLAMP_INT(config.allow_tearing, 0, 2);
|
||||
allow_shortcuts_inhibit = CLAMP_INT(config.allow_shortcuts_inhibit, 0, 1);
|
||||
allow_lock_transparent = CLAMP_INT(config.allow_lock_transparent, 0, 1);
|
||||
axis_bind_apply_timeout =
|
||||
CLAMP_INT(config.axis_bind_apply_timeout, 0, 1000);
|
||||
focus_on_activate = CLAMP_INT(config.focus_on_activate, 0, 1);
|
||||
|
|
@ -2718,6 +2777,8 @@ void override_config(void) {
|
|||
sizeof(animation_curve_tag));
|
||||
memcpy(animation_curve_close, config.animation_curve_close,
|
||||
sizeof(animation_curve_close));
|
||||
memcpy(animation_curve_focus, config.animation_curve_focus,
|
||||
sizeof(animation_curve_focus));
|
||||
}
|
||||
|
||||
void set_value_default() {
|
||||
|
|
@ -2740,6 +2801,8 @@ void set_value_default() {
|
|||
animation_duration_tag; // Animation tag speed
|
||||
config.animation_duration_close =
|
||||
animation_duration_close; // Animation tag speed
|
||||
config.animation_duration_focus =
|
||||
animation_duration_focus; // Animation focus opacity speed
|
||||
|
||||
/* appearance */
|
||||
config.axis_bind_apply_timeout =
|
||||
|
|
@ -2774,6 +2837,8 @@ void set_value_default() {
|
|||
config.scroller_default_proportion = scroller_default_proportion;
|
||||
config.scroller_default_proportion_single =
|
||||
scroller_default_proportion_single;
|
||||
config.scroller_ignore_proportion_single =
|
||||
scroller_ignore_proportion_single;
|
||||
config.scroller_focus_center = scroller_focus_center;
|
||||
config.scroller_prefer_center = scroller_prefer_center;
|
||||
config.edge_scroller_pointer_focus = edge_scroller_pointer_focus;
|
||||
|
|
@ -2786,6 +2851,9 @@ void set_value_default() {
|
|||
config.xwayland_persistence = xwayland_persistence;
|
||||
config.syncobj_enable = syncobj_enable;
|
||||
config.adaptive_sync = adaptive_sync;
|
||||
config.allow_tearing = allow_tearing;
|
||||
config.allow_shortcuts_inhibit = allow_shortcuts_inhibit;
|
||||
config.allow_lock_transparent = allow_lock_transparent;
|
||||
config.no_border_when_single = no_border_when_single;
|
||||
config.no_radius_when_single = no_radius_when_single;
|
||||
config.snap_distance = snap_distance;
|
||||
|
|
@ -2857,6 +2925,8 @@ void set_value_default() {
|
|||
sizeof(animation_curve_tag));
|
||||
memcpy(config.animation_curve_close, animation_curve_close,
|
||||
sizeof(animation_curve_close));
|
||||
memcpy(config.animation_curve_focus, animation_curve_focus,
|
||||
sizeof(animation_curve_focus));
|
||||
|
||||
memcpy(config.rootcolor, rootcolor, sizeof(rootcolor));
|
||||
memcpy(config.bordercolor, bordercolor, sizeof(bordercolor));
|
||||
|
|
@ -2889,6 +2959,7 @@ void set_default_key_bindings(Config *config) {
|
|||
default_key_bindings[i];
|
||||
config->key_bindings[config->key_bindings_count + i].iscommonmode =
|
||||
true;
|
||||
config->key_bindings[config->key_bindings_count + i].islockapply = true;
|
||||
}
|
||||
|
||||
// 更新按键绑定的总数
|
||||
|
|
@ -2903,6 +2974,11 @@ void parse_config(void) {
|
|||
|
||||
// 重置config结构体,确保所有指针初始化为NULL
|
||||
memset(&config, 0, sizeof(config));
|
||||
memset(&xkb_rules_rules, 0, sizeof(xkb_rules_rules));
|
||||
memset(&xkb_rules_model, 0, sizeof(xkb_rules_model));
|
||||
memset(&xkb_rules_layout, 0, sizeof(xkb_rules_layout));
|
||||
memset(&xkb_rules_variant, 0, sizeof(xkb_rules_variant));
|
||||
memset(&xkb_rules_options, 0, sizeof(xkb_rules_options));
|
||||
|
||||
// 初始化动态数组的指针为NULL,避免野指针
|
||||
config.window_rules = NULL;
|
||||
|
|
@ -3057,6 +3133,12 @@ void reapply_monitor_rules(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void reapply_cursor_style(void) {
|
||||
if (cursor_mgr)
|
||||
wlr_xcursor_manager_destroy(cursor_mgr);
|
||||
cursor_mgr = wlr_xcursor_manager_create(config.cursor_theme, cursor_size);
|
||||
}
|
||||
|
||||
void reapply_border(void) {
|
||||
Client *c = NULL;
|
||||
|
||||
|
|
@ -3116,33 +3198,37 @@ void reapply_master(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void parse_tagrule(Monitor *m) {
|
||||
int i, jk;
|
||||
ConfigTagRule tr;
|
||||
|
||||
for (i = 0; i < config.tag_rules_count; i++) {
|
||||
|
||||
tr = config.tag_rules[i];
|
||||
|
||||
if (config.tag_rules_count > 0 &&
|
||||
(!tr.monitor_name ||
|
||||
regex_match(tr.monitor_name, m->wlr_output->name))) {
|
||||
|
||||
for (jk = 0; jk < LENGTH(layouts); jk++) {
|
||||
if (tr.layout_name &&
|
||||
strcmp(layouts[jk].name, tr.layout_name) == 0) {
|
||||
m->pertag->ltidxs[tr.id] = &layouts[jk];
|
||||
}
|
||||
}
|
||||
|
||||
m->pertag->no_hide[tr.id] = tr.no_hide;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void reapply_tagrule(void) {
|
||||
Monitor *m = NULL;
|
||||
int i, jk;
|
||||
char *rule_monitor_name = NULL;
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
if (!m->wlr_output->enabled) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// apply tag rule
|
||||
for (i = 1; i <= config.tag_rules_count; i++) {
|
||||
rule_monitor_name = config.tag_rules[i - 1].monitor_name;
|
||||
if (regex_match(rule_monitor_name, m->wlr_output->name) ||
|
||||
!rule_monitor_name) {
|
||||
for (jk = 0; jk < LENGTH(layouts); jk++) {
|
||||
if (config.tag_rules_count > 0 &&
|
||||
config.tag_rules[i - 1].layout_name &&
|
||||
strcmp(layouts[jk].name,
|
||||
config.tag_rules[i - 1].layout_name) == 0) {
|
||||
m->pertag->ltidxs[config.tag_rules[i - 1].id] =
|
||||
&layouts[jk];
|
||||
m->pertag->no_hide[config.tag_rules[i - 1].id] =
|
||||
config.tag_rules[i - 1].no_hide;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
parse_tagrule(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3154,6 +3240,7 @@ void reset_option(void) {
|
|||
set_env();
|
||||
run_exec();
|
||||
|
||||
reapply_cursor_style();
|
||||
reapply_border();
|
||||
reapply_keyboard();
|
||||
reapply_pointer();
|
||||
|
|
@ -3168,5 +3255,6 @@ void reset_option(void) {
|
|||
int reload_config(const Arg *arg) {
|
||||
parse_config();
|
||||
reset_option();
|
||||
printstatus();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,12 @@ uint32_t animation_duration_move = 500; // Animation move speed
|
|||
uint32_t animation_duration_open = 400; // Animation open speed
|
||||
uint32_t animation_duration_tag = 300; // Animation tag speed
|
||||
uint32_t animation_duration_close = 300; // Animation close speed
|
||||
uint32_t animation_duration_focus = 0; // Animation focus opacity speed
|
||||
double animation_curve_move[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_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}; // 动画曲线
|
||||
|
||||
/* appearance */
|
||||
unsigned int axis_bind_apply_timeout = 100; // 滚轮绑定动作的触发的时间间隔
|
||||
|
|
@ -58,6 +60,7 @@ float scratchpad_height_ratio = 0.9;
|
|||
int scroller_structs = 20;
|
||||
float scroller_default_proportion = 0.9;
|
||||
float scroller_default_proportion_single = 1.0;
|
||||
int scroller_ignore_proportion_single = 0;
|
||||
int scroller_focus_center = 0;
|
||||
int scroller_prefer_center = 0;
|
||||
int focus_cross_monitor = 0;
|
||||
|
|
@ -100,7 +103,10 @@ int warpcursor = 1; /* Warp cursor to focused client */
|
|||
int xwayland_persistence = 1; /* xwayland persistence */
|
||||
int syncobj_enable = 0;
|
||||
int adaptive_sync = 0;
|
||||
int allow_lock_transparent = 0;
|
||||
double drag_refresh_interval = 30.0;
|
||||
int allow_tearing = TEARING_DISABLED;
|
||||
int allow_shortcuts_inhibit = SHORTCUTS_INHIBIT_ENABLE;
|
||||
|
||||
/* keyboard */
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ int toggle_scratchpad(const Arg *arg);
|
|||
int focusdir(const Arg *arg);
|
||||
int toggleoverview(const Arg *arg);
|
||||
int set_proportion(const Arg *arg);
|
||||
int increase_proportion(const Arg *arg);
|
||||
int switch_proportion_preset(const Arg *arg);
|
||||
int zoom(const Arg *arg);
|
||||
int tagsilent(const Arg *arg);
|
||||
|
|
@ -25,9 +24,9 @@ int spawn(const Arg *arg);
|
|||
int spawn_shell(const Arg *arg);
|
||||
int spawn_on_empty(const Arg *arg);
|
||||
int setkeymode(const Arg *arg);
|
||||
int switch_keyboard_layout(const Arg *arg);
|
||||
int setlayout(const Arg *arg);
|
||||
int switch_layout(const Arg *arg);
|
||||
int switch_keyboard_layout(const Arg *arg);
|
||||
int setmfact(const Arg *arg);
|
||||
int quit(const Arg *arg);
|
||||
int moveresize(const Arg *arg);
|
||||
|
|
@ -66,4 +65,7 @@ int create_virtual_output(const Arg *arg);
|
|||
int destroy_all_virtual_output(const Arg *arg);
|
||||
int focuslast(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);
|
||||
|
|
@ -80,8 +80,12 @@ int defaultgaps(const Arg *arg) {
|
|||
|
||||
int exchange_client(const Arg *arg) {
|
||||
Client *c = selmon->sel;
|
||||
if (!c || c->isfloating || c->isfullscreen || c->ismaximizescreen)
|
||||
if (!c || c->isfloating)
|
||||
return 0;
|
||||
|
||||
if ((c->isfullscreen || c->ismaximizescreen) && !is_scroller_layout(c->mon))
|
||||
return 0;
|
||||
|
||||
exchange_two_client(c, direction_select(arg));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -129,9 +133,9 @@ int focuslast(const Arg *arg) {
|
|||
unsigned int target = 0;
|
||||
|
||||
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_should_ignore_focus(c))
|
||||
client_is_x11_popup(c))
|
||||
continue;
|
||||
|
||||
if (selmon && !selmon->sel) {
|
||||
|
|
@ -185,7 +189,7 @@ int focusmon(const Arg *arg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!m || !m->wlr_output->enabled)
|
||||
if (!m || !m->wlr_output->enabled || m == selmon)
|
||||
return 0;
|
||||
|
||||
old_selmon_sel = selmon->sel;
|
||||
|
|
@ -202,7 +206,7 @@ int focusmon(const Arg *arg) {
|
|||
focusclient(c, 1);
|
||||
|
||||
if (old_selmon_sel) {
|
||||
setborder_color(old_selmon_sel);
|
||||
client_set_unfocused_opacity_animation(old_selmon_sel);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -281,18 +285,6 @@ int incovgaps(const Arg *arg) {
|
|||
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) {
|
||||
float f;
|
||||
Client *c = NULL;
|
||||
|
|
@ -479,7 +471,7 @@ int restore_minimized(const Arg *arg) {
|
|||
|
||||
if (selmon && selmon->sel && selmon->sel->is_in_scratchpad &&
|
||||
selmon->sel->is_scratchpad_show) {
|
||||
selmon->sel->isminied = 0;
|
||||
selmon->sel->isminimized = 0;
|
||||
selmon->sel->is_scratchpad_show = 0;
|
||||
selmon->sel->is_in_scratchpad = 0;
|
||||
selmon->sel->isnamedscratchpad = 0;
|
||||
|
|
@ -488,7 +480,7 @@ int restore_minimized(const Arg *arg) {
|
|||
}
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (c->isminied) {
|
||||
if (c->isminimized && !c->isnamedscratchpad) {
|
||||
c->is_scratchpad_show = 0;
|
||||
c->is_in_scratchpad = 0;
|
||||
c->isnamedscratchpad = 0;
|
||||
|
|
@ -509,7 +501,7 @@ int setlayout(const Arg *arg) {
|
|||
for (jk = 0; jk < LENGTH(layouts); jk++) {
|
||||
if (strcmp(layouts[jk].name, arg->v) == 0) {
|
||||
selmon->pertag->ltidxs[selmon->pertag->curtag] = &layouts[jk];
|
||||
|
||||
clear_fullscreen_and_maximized_state(selmon);
|
||||
arrange(selmon, false);
|
||||
printstatus();
|
||||
return 0;
|
||||
|
|
@ -530,6 +522,14 @@ int setkeymode(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) {
|
||||
unsigned int max_client_width =
|
||||
selmon->w.width - 2 * scroller_structs - gappih;
|
||||
|
|
@ -809,7 +809,7 @@ int spawn_on_empty(const Arg *arg) {
|
|||
return 0;
|
||||
} else {
|
||||
view(arg, true);
|
||||
spawn(arg);
|
||||
spawn_shell(arg);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -836,97 +836,35 @@ int switch_keyboard_layout(const Arg *arg) {
|
|||
}
|
||||
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;
|
||||
// 验证规则是否有效
|
||||
if (!check_keyboard_rules_validate(&rules)) {
|
||||
wlr_log(WLR_ERROR,
|
||||
"Keyboard rules validation failed, skipping layout reset");
|
||||
rules = xkb_default_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
|
||||
unsigned int depressed = keyboard->modifiers.depressed;
|
||||
unsigned int latched = keyboard->modifiers.latched;
|
||||
unsigned int locked = keyboard->modifiers.locked;
|
||||
|
||||
wlr_keyboard_set_keymap(keyboard, new_keymap);
|
||||
wlr_keyboard_notify_modifiers(keyboard, depressed, latched, locked, 0);
|
||||
wlr_keyboard_set_keymap(keyboard, keyboard->keymap);
|
||||
wlr_keyboard_notify_modifiers(keyboard, depressed, latched, locked, next);
|
||||
keyboard->modifiers.group = 0;
|
||||
|
||||
// 7. 更新 seat
|
||||
wlr_seat_set_keyboard(seat, keyboard);
|
||||
wlr_seat_keyboard_notify_modifiers(seat, &keyboard->modifiers);
|
||||
|
||||
// 8. 清理资源
|
||||
xkb_keymap_unref(new_keymap);
|
||||
InputDevice *id;
|
||||
wl_list_for_each(id, &inputdevices, link) {
|
||||
if (id->wlr_device->type != WLR_INPUT_DEVICE_KEYBOARD) {
|
||||
continue;
|
||||
}
|
||||
|
||||
cleanup_layouts:
|
||||
free(layout_ids);
|
||||
struct wlr_keyboard *tkb = (struct wlr_keyboard *)id->device_data;
|
||||
|
||||
cleanup_context:
|
||||
xkb_context_unref(context);
|
||||
wlr_keyboard_set_keymap(tkb, keyboard->keymap);
|
||||
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();
|
||||
return 0;
|
||||
|
|
@ -967,7 +905,7 @@ int switch_layout(const Arg *arg) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
clear_fullscreen_and_maximized_state(selmon);
|
||||
arrange(selmon, false);
|
||||
printstatus();
|
||||
return 0;
|
||||
|
|
@ -978,6 +916,7 @@ int switch_layout(const Arg *arg) {
|
|||
selmon->pertag->ltidxs[selmon->pertag->curtag]->name) == 0) {
|
||||
selmon->pertag->ltidxs[selmon->pertag->curtag] =
|
||||
jk == LENGTH(layouts) - 1 ? &layouts[0] : &layouts[jk + 1];
|
||||
clear_fullscreen_and_maximized_state(selmon);
|
||||
arrange(selmon, false);
|
||||
printstatus();
|
||||
return 0;
|
||||
|
|
@ -993,6 +932,13 @@ int switch_proportion_preset(const Arg *arg) {
|
|||
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) {
|
||||
|
||||
for (int i = 0; i < config.scroller_proportion_preset_count; i++) {
|
||||
|
|
@ -1030,7 +976,7 @@ int tag(const Arg *arg) {
|
|||
}
|
||||
|
||||
int tagmon(const Arg *arg) {
|
||||
Monitor *m = NULL;
|
||||
Monitor *m = NULL, *cm = NULL;
|
||||
Client *c = focustop(selmon);
|
||||
|
||||
if (!c)
|
||||
|
|
@ -1039,11 +985,12 @@ int tagmon(const Arg *arg) {
|
|||
if (arg->i != UNDIR) {
|
||||
m = dirtomon(arg->i);
|
||||
} else if (arg->v) {
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
if (!m->wlr_output->enabled) {
|
||||
wl_list_for_each(cm, &mons, link) {
|
||||
if (!cm->wlr_output->enabled) {
|
||||
continue;
|
||||
}
|
||||
if (regex_match(arg->v, m->wlr_output->name)) {
|
||||
if (regex_match(arg->v, cm->wlr_output->name)) {
|
||||
m = cm;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1146,7 +1093,7 @@ int toggle_named_scratchpad(const Arg *arg) {
|
|||
|
||||
if (!target_client && arg->v3) {
|
||||
Arg arg_spawn = {.v = arg->v3};
|
||||
spawn(&arg_spawn);
|
||||
spawn_shell(&arg_spawn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1175,7 +1122,7 @@ int toggle_scratchpad(const Arg *arg) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (single_scratchpad && c->isnamedscratchpad && !c->isminied) {
|
||||
if (single_scratchpad && c->isnamedscratchpad && !c->isminimized) {
|
||||
set_minimized(c);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1423,7 +1370,7 @@ int viewtoright_have_client(const Arg *arg) {
|
|||
}
|
||||
|
||||
int viewcrossmon(const Arg *arg) {
|
||||
focusmon(arg);
|
||||
focusmon(&(Arg){.v = arg->v, .i = UNDIR});
|
||||
view_in_mon(arg, true, selmon, true);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1500,7 +1447,7 @@ int minimized(const Arg *arg) {
|
|||
if (selmon && selmon->isoverview)
|
||||
return 0;
|
||||
|
||||
if (selmon->sel && !selmon->sel->isminied) {
|
||||
if (selmon->sel && !selmon->sel->isminimized) {
|
||||
set_minimized(selmon->sel);
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -1509,7 +1456,7 @@ int minimized(const Arg *arg) {
|
|||
int toggleoverview(const Arg *arg) {
|
||||
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});
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1519,11 +1466,11 @@ int toggleoverview(const Arg *arg) {
|
|||
unsigned int visible_client_number = 0;
|
||||
|
||||
if (selmon->isoverview) {
|
||||
wl_list_for_each(c, &clients,
|
||||
link) if (c && c->mon == selmon &&
|
||||
!client_is_unmanaged(c) &&
|
||||
!client_should_ignore_focus(c) &&
|
||||
!c->isminied && !c->isunglobal) {
|
||||
wl_list_for_each(c, &clients, link) if (c && c->mon == selmon &&
|
||||
!client_is_unmanaged(c) &&
|
||||
!client_is_x11_popup(c) &&
|
||||
!c->isminimized &&
|
||||
!c->isunglobal) {
|
||||
visible_client_number++;
|
||||
}
|
||||
if (visible_client_number > 0) {
|
||||
|
|
@ -1546,24 +1493,65 @@ int toggleoverview(const Arg *arg) {
|
|||
if (selmon->isoverview) {
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (c && c->mon == selmon && !c->iskilling &&
|
||||
!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});
|
||||
}
|
||||
}
|
||||
|
||||
view(&(Arg){.ui = target}, false);
|
||||
|
||||
if (ov_tab_mode && selmon->isoverview && selmon->sel) {
|
||||
focusstack(&(Arg){.i = 1});
|
||||
}
|
||||
|
||||
refresh_monitors_workspaces_status(selmon);
|
||||
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,4 +1,5 @@
|
|||
#include "dwl-ipc.h"
|
||||
#include "ext-workspace.h"
|
||||
#include "foreign-toplevel.h"
|
||||
#include "tearing.h"
|
||||
#include "text-input.h"
|
||||
|
|
@ -113,7 +113,8 @@ void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) {
|
|||
struct wlr_keyboard *keyboard;
|
||||
xkb_layout_index_t current;
|
||||
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);
|
||||
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;
|
||||
current = xkb_state_serialize_layout(keyboard->xkb_state,
|
||||
XKB_STATE_LAYOUT_EFFECTIVE);
|
||||
kb_layout =
|
||||
get_layout_abbr(xkb_keymap_layout_get_name(keyboard->keymap, current));
|
||||
get_layout_abbr(kb_layout,
|
||||
xkb_keymap_layout_get_name(keyboard->keymap, current));
|
||||
|
||||
zdwl_ipc_output_v2_send_layout(
|
||||
ipc_output->resource,
|
||||
|
|
@ -204,6 +205,12 @@ void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
@ -251,6 +258,7 @@ void dwl_ipc_output_set_layout(struct wl_client *client,
|
|||
index = 0;
|
||||
|
||||
monitor->pertag->ltidxs[monitor->pertag->curtag] = &layouts[index];
|
||||
clear_fullscreen_and_maximized_state(monitor);
|
||||
arrange(monitor, false);
|
||||
printstatus();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,11 @@ static void handle_ext_workspace_activate(struct wl_listener *listener,
|
|||
void *data) {
|
||||
struct workspace *workspace =
|
||||
wl_container_of(listener, workspace, activate);
|
||||
|
||||
if (workspace->m->isoverview) {
|
||||
return;
|
||||
}
|
||||
|
||||
goto_workspace(workspace);
|
||||
wlr_log(WLR_INFO, "ext activating workspace %d", workspace->tag);
|
||||
}
|
||||
|
|
@ -55,6 +60,11 @@ static void handle_ext_workspace_deactivate(struct wl_listener *listener,
|
|||
void *data) {
|
||||
struct workspace *workspace =
|
||||
wl_container_of(listener, workspace, deactivate);
|
||||
|
||||
if (workspace->m->isoverview) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggle_workspace(workspace);
|
||||
wlr_log(WLR_INFO, "ext deactivating workspace %d", workspace->tag);
|
||||
}
|
||||
|
|
@ -134,6 +144,10 @@ void dwl_ext_workspace_printstatus(Monitor *m) {
|
|||
if (!w->m->pertag->no_hide[w->tag])
|
||||
wlr_ext_workspace_handle_v1_set_hidden(w->ext_workspace,
|
||||
true);
|
||||
else {
|
||||
wlr_ext_workspace_handle_v1_set_hidden(w->ext_workspace,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
if ((m->tagset[m->seltags] & (1 << (w->tag - 1)) & TAGMASK) ||
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ void handle_foreign_activate_request(struct wl_listener *listener, void *data) {
|
|||
if (c && c->swallowing)
|
||||
return;
|
||||
|
||||
if (c && !c->isminied && c == selmon->sel) {
|
||||
if (c && !c->isminimized && c == selmon->sel) {
|
||||
set_minimized(c);
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->isminied) {
|
||||
if (c->isminimized) {
|
||||
c->is_in_scratchpad = 0;
|
||||
c->isnamedscratchpad = 0;
|
||||
c->is_scratchpad_show = 0;
|
||||
|
|
|
|||
168
src/ext-protocol/tearing.h
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
#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 = get_client_from_surface(controller->tearing_control->surface);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -128,8 +128,9 @@ Client *center_tiled_select(Monitor *m) {
|
|||
int dirx, diry;
|
||||
long int distance;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (c && VISIBLEON(c, m) && ISTILED(c) && client_surface(c)->mapped &&
|
||||
!c->isfloating && !client_is_unmanaged(c)) {
|
||||
if (c && VISIBLEON(c, m) && ISSCROLLTILED(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);
|
||||
diry = c->geom.y + c->geom.height / 2 - (m->w.y + m->w.height / 2);
|
||||
distance = dirx * dirx + diry * diry;
|
||||
|
|
@ -142,7 +143,7 @@ Client *center_tiled_select(Monitor *m) {
|
|||
return target_c;
|
||||
}
|
||||
Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
|
||||
bool align) {
|
||||
bool ignore_align) {
|
||||
Client *c = NULL;
|
||||
Client **tempClients = NULL; // 初始化为 NULL
|
||||
int last = -1;
|
||||
|
|
@ -185,21 +186,23 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
|
|||
|
||||
switch (arg->i) {
|
||||
case UP:
|
||||
for (int _i = 0; _i <= last; _i++) {
|
||||
if (tempClients[_i]->geom.y < sel_y &&
|
||||
tempClients[_i]->geom.x == sel_x &&
|
||||
tempClients[_i]->mon == tc->mon) {
|
||||
int dis_x = tempClients[_i]->geom.x - sel_x;
|
||||
int dis_y = tempClients[_i]->geom.y - sel_y;
|
||||
long long int tmp_distance =
|
||||
dis_x * dis_x + dis_y * dis_y; // 计算距离
|
||||
if (tmp_distance < distance) {
|
||||
distance = tmp_distance;
|
||||
tempFocusClients = tempClients[_i];
|
||||
if (!ignore_align) {
|
||||
for (int _i = 0; _i <= last; _i++) {
|
||||
if (tempClients[_i]->geom.y < sel_y &&
|
||||
tempClients[_i]->geom.x == sel_x &&
|
||||
tempClients[_i]->mon == tc->mon) {
|
||||
int dis_x = tempClients[_i]->geom.x - sel_x;
|
||||
int dis_y = tempClients[_i]->geom.y - sel_y;
|
||||
long long int tmp_distance =
|
||||
dis_x * dis_x + dis_y * dis_y; // 计算距离
|
||||
if (tmp_distance < distance) {
|
||||
distance = tmp_distance;
|
||||
tempFocusClients = tempClients[_i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!tempFocusClients && !align) {
|
||||
if (!tempFocusClients) {
|
||||
for (int _i = 0; _i <= last; _i++) {
|
||||
if (tempClients[_i]->geom.y < sel_y) {
|
||||
int dis_x = tempClients[_i]->geom.x - sel_x;
|
||||
|
|
@ -215,21 +218,23 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
|
|||
}
|
||||
break;
|
||||
case DOWN:
|
||||
for (int _i = 0; _i <= last; _i++) {
|
||||
if (tempClients[_i]->geom.y > sel_y &&
|
||||
tempClients[_i]->geom.x == sel_x &&
|
||||
tempClients[_i]->mon == tc->mon) {
|
||||
int dis_x = tempClients[_i]->geom.x - sel_x;
|
||||
int dis_y = tempClients[_i]->geom.y - sel_y;
|
||||
long long int tmp_distance =
|
||||
dis_x * dis_x + dis_y * dis_y; // 计算距离
|
||||
if (tmp_distance < distance) {
|
||||
distance = tmp_distance;
|
||||
tempFocusClients = tempClients[_i];
|
||||
if (!ignore_align) {
|
||||
for (int _i = 0; _i <= last; _i++) {
|
||||
if (tempClients[_i]->geom.y > sel_y &&
|
||||
tempClients[_i]->geom.x == sel_x &&
|
||||
tempClients[_i]->mon == tc->mon) {
|
||||
int dis_x = tempClients[_i]->geom.x - sel_x;
|
||||
int dis_y = tempClients[_i]->geom.y - sel_y;
|
||||
long long int tmp_distance =
|
||||
dis_x * dis_x + dis_y * dis_y; // 计算距离
|
||||
if (tmp_distance < distance) {
|
||||
distance = tmp_distance;
|
||||
tempFocusClients = tempClients[_i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!tempFocusClients && !align) {
|
||||
if (!tempFocusClients) {
|
||||
for (int _i = 0; _i <= last; _i++) {
|
||||
if (tempClients[_i]->geom.y > sel_y) {
|
||||
int dis_x = tempClients[_i]->geom.x - sel_x;
|
||||
|
|
@ -245,21 +250,23 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
|
|||
}
|
||||
break;
|
||||
case LEFT:
|
||||
for (int _i = 0; _i <= last; _i++) {
|
||||
if (tempClients[_i]->geom.x < sel_x &&
|
||||
tempClients[_i]->geom.y == sel_y &&
|
||||
tempClients[_i]->mon == tc->mon) {
|
||||
int dis_x = tempClients[_i]->geom.x - sel_x;
|
||||
int dis_y = tempClients[_i]->geom.y - sel_y;
|
||||
long long int tmp_distance =
|
||||
dis_x * dis_x + dis_y * dis_y; // 计算距离
|
||||
if (tmp_distance < distance) {
|
||||
distance = tmp_distance;
|
||||
tempFocusClients = tempClients[_i];
|
||||
if (!ignore_align) {
|
||||
for (int _i = 0; _i <= last; _i++) {
|
||||
if (tempClients[_i]->geom.x < sel_x &&
|
||||
tempClients[_i]->geom.y == sel_y &&
|
||||
tempClients[_i]->mon == tc->mon) {
|
||||
int dis_x = tempClients[_i]->geom.x - sel_x;
|
||||
int dis_y = tempClients[_i]->geom.y - sel_y;
|
||||
long long int tmp_distance =
|
||||
dis_x * dis_x + dis_y * dis_y; // 计算距离
|
||||
if (tmp_distance < distance) {
|
||||
distance = tmp_distance;
|
||||
tempFocusClients = tempClients[_i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!tempFocusClients && !align) {
|
||||
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;
|
||||
|
|
@ -275,21 +282,23 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
|
|||
}
|
||||
break;
|
||||
case RIGHT:
|
||||
for (int _i = 0; _i <= last; _i++) {
|
||||
if (tempClients[_i]->geom.x > sel_x &&
|
||||
tempClients[_i]->geom.y == sel_y &&
|
||||
tempClients[_i]->mon == tc->mon) {
|
||||
int dis_x = tempClients[_i]->geom.x - sel_x;
|
||||
int dis_y = tempClients[_i]->geom.y - sel_y;
|
||||
long long int tmp_distance =
|
||||
dis_x * dis_x + dis_y * dis_y; // 计算距离
|
||||
if (tmp_distance < distance) {
|
||||
distance = tmp_distance;
|
||||
tempFocusClients = tempClients[_i];
|
||||
if (!ignore_align) {
|
||||
for (int _i = 0; _i <= last; _i++) {
|
||||
if (tempClients[_i]->geom.x > sel_x &&
|
||||
tempClients[_i]->geom.y == sel_y &&
|
||||
tempClients[_i]->mon == tc->mon) {
|
||||
int dis_x = tempClients[_i]->geom.x - sel_x;
|
||||
int dis_y = tempClients[_i]->geom.y - sel_y;
|
||||
long long int tmp_distance =
|
||||
dis_x * dis_x + dis_y * dis_y; // 计算距离
|
||||
if (tmp_distance < distance) {
|
||||
distance = tmp_distance;
|
||||
tempFocusClients = tempClients[_i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!tempFocusClients && !align) {
|
||||
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;
|
||||
|
|
@ -317,12 +326,13 @@ Client *direction_select(const Arg *arg) {
|
|||
if (!tc)
|
||||
return NULL;
|
||||
|
||||
if (tc && (tc->isfullscreen || tc->ismaximizescreen)) {
|
||||
// 不支持全屏窗口的焦点切换
|
||||
if (tc && (tc->isfullscreen || tc->ismaximizescreen) &&
|
||||
(!is_scroller_layout(selmon) || tc->isfloating)) {
|
||||
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
|
||||
|
|
@ -340,23 +350,56 @@ Client *focustop(Monitor *m) {
|
|||
}
|
||||
|
||||
Client *get_next_stack_client(Client *c, bool reverse) {
|
||||
if (!c || !c->mon)
|
||||
return NULL; // 添加输入检查
|
||||
|
||||
Client *next = NULL;
|
||||
if (reverse) {
|
||||
wl_list_for_each_reverse(next, &c->link, link) {
|
||||
if (!next)
|
||||
continue; // 安全检查
|
||||
|
||||
if (c->mon->has_visible_fullscreen_client && !next->isfloating &&
|
||||
!next->isfullscreen)
|
||||
continue;
|
||||
if (VISIBLEON(next, c->mon) && next != c)
|
||||
|
||||
// 添加更安全的 VISIBLEON 检查
|
||||
if (next != c && next->mon && VISIBLEON(next, c->mon))
|
||||
return next;
|
||||
}
|
||||
} else {
|
||||
wl_list_for_each(next, &c->link, link) {
|
||||
if (!next)
|
||||
continue; // 安全检查
|
||||
|
||||
if (c->mon->has_visible_fullscreen_client && !next->isfloating &&
|
||||
!next->isfullscreen)
|
||||
continue;
|
||||
if (VISIBLEON(next, c->mon) && next != c)
|
||||
|
||||
if (next != c && next->mon && VISIBLEON(next, c->mon))
|
||||
return next;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -44,11 +44,15 @@ char *get_autostart_path(char *autostart_path, unsigned int buf_size) {
|
|||
return autostart_path;
|
||||
}
|
||||
|
||||
const char *get_layout_abbr(const char *full_name) {
|
||||
void get_layout_abbr(char *abbr, const char *full_name) {
|
||||
// 清空输出缓冲区
|
||||
abbr[0] = '\0';
|
||||
|
||||
// 1. 尝试在映射表中查找
|
||||
for (int i = 0; layout_mappings[i].full_name != NULL; i++) {
|
||||
if (strcmp(full_name, layout_mappings[i].full_name) == 0) {
|
||||
return layout_mappings[i].abbr;
|
||||
strcpy(abbr, layout_mappings[i].abbr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -58,46 +62,37 @@ const char *get_layout_abbr(const char *full_name) {
|
|||
if (open && close && close > open) {
|
||||
unsigned int len = close - open - 1;
|
||||
if (len > 0 && len <= 4) {
|
||||
char *abbr = malloc(len + 1);
|
||||
if (abbr) {
|
||||
// 提取并转换为小写
|
||||
for (unsigned int j = 0; j < len; j++) {
|
||||
abbr[j] = tolower(open[j + 1]);
|
||||
}
|
||||
abbr[len] = '\0';
|
||||
return abbr;
|
||||
// 提取并转换为小写
|
||||
for (unsigned int j = 0; j < len; j++) {
|
||||
abbr[j] = tolower(open[j + 1]);
|
||||
}
|
||||
abbr[len] = '\0';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 提取前2-3个字母并转换为小写
|
||||
char *abbr = malloc(4);
|
||||
if (abbr) {
|
||||
unsigned int j = 0;
|
||||
for (unsigned int i = 0; full_name[i] != '\0' && j < 3; i++) {
|
||||
if (isalpha(full_name[i])) {
|
||||
abbr[j++] = tolower(full_name[i]);
|
||||
}
|
||||
unsigned int j = 0;
|
||||
for (unsigned int i = 0; full_name[i] != '\0' && j < 3; i++) {
|
||||
if (isalpha(full_name[i])) {
|
||||
abbr[j++] = tolower(full_name[i]);
|
||||
}
|
||||
abbr[j] = '\0';
|
||||
}
|
||||
abbr[j] = '\0';
|
||||
|
||||
// 确保至少2个字符
|
||||
if (j >= 2)
|
||||
return abbr;
|
||||
free(abbr);
|
||||
// 确保至少2个字符
|
||||
if (j >= 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 4. 回退方案:使用首字母小写
|
||||
char *fallback = malloc(3);
|
||||
if (fallback) {
|
||||
fallback[0] = tolower(full_name[0]);
|
||||
fallback[1] = full_name[1] ? tolower(full_name[1]) : '\0';
|
||||
fallback[2] = '\0';
|
||||
return fallback;
|
||||
if (j == 1) {
|
||||
abbr[1] = full_name[1] ? tolower(full_name[1]) : '\0';
|
||||
abbr[2] = '\0';
|
||||
} else {
|
||||
// 5. 最终回退:返回 "xx"
|
||||
strcpy(abbr, "xx");
|
||||
}
|
||||
|
||||
// 5. 最终回退:返回 "xx"
|
||||
return strdup("xx");
|
||||
}
|
||||
|
||||
void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
|
||||
|
|
@ -120,6 +115,10 @@ void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
|
|||
surface = wlr_scene_surface_try_from_buffer(
|
||||
wlr_scene_buffer_from_node(node))
|
||||
->surface;
|
||||
else if (node->type == WLR_SCENE_NODE_RECT) {
|
||||
surface = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* start from the topmost layer,
|
||||
find a sureface that can be focused by pointer,
|
||||
|
|
|
|||
|
|
@ -374,6 +374,10 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int offsetx, int offsety,
|
|||
float delta_x, delta_y;
|
||||
float new_scroller_proportion;
|
||||
|
||||
if (grabc && grabc->mon->visible_tiling_clients == 1 &&
|
||||
!scroller_ignore_proportion_single)
|
||||
return;
|
||||
|
||||
if (!start_drag_window && isdrag) {
|
||||
drag_begin_cursorx = cursor->x;
|
||||
drag_begin_cursory = cursor->y;
|
||||
|
|
@ -475,6 +479,9 @@ void resize_tile_client(Client *grabc, bool isdrag, int offsetx, int offsety,
|
|||
if (!grabc || grabc->isfullscreen || grabc->ismaximizescreen)
|
||||
return;
|
||||
|
||||
if (grabc->mon->isoverview)
|
||||
return;
|
||||
|
||||
const Layout *current_layout =
|
||||
grabc->mon->pertag->ltidxs[grabc->mon->pertag->curtag];
|
||||
if (current_layout->id == TILE || current_layout->id == DECK ||
|
||||
|
|
@ -592,6 +599,7 @@ arrange(Monitor *m, bool want_animation) {
|
|||
return;
|
||||
m->visible_clients = 0;
|
||||
m->visible_tiling_clients = 0;
|
||||
m->visible_scroll_tiling_clients = 0;
|
||||
m->has_visible_fullscreen_client = false;
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
|
|
@ -603,7 +611,8 @@ arrange(Monitor *m, bool want_animation) {
|
|||
}
|
||||
|
||||
if (VISIBLEON(c, m)) {
|
||||
m->visible_clients++;
|
||||
if (!c->isunglobal)
|
||||
m->visible_clients++;
|
||||
|
||||
if (c->isfullscreen)
|
||||
m->has_visible_fullscreen_client = true;
|
||||
|
|
@ -611,6 +620,10 @@ arrange(Monitor *m, bool want_animation) {
|
|||
if (ISTILED(c)) {
|
||||
m->visible_tiling_clients++;
|
||||
}
|
||||
|
||||
if (ISSCROLLTILED(c)) {
|
||||
m->visible_scroll_tiling_clients++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ void grid(Monitor *m) {
|
|||
? 0
|
||||
: borderpx;
|
||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||
((m->isoverview && !client_should_ignore_focus(c)) ||
|
||||
ISTILED(c))) {
|
||||
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
||||
cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
|
||||
ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
|
||||
c->geom.x = m->w.x + (m->w.width - cw) / 2;
|
||||
|
|
@ -55,8 +54,7 @@ void grid(Monitor *m) {
|
|||
? 0
|
||||
: borderpx;
|
||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||
((m->isoverview && !client_should_ignore_focus(c)) ||
|
||||
ISTILED(c))) {
|
||||
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
||||
if (i == 0) {
|
||||
c->geom.x = m->w.x + target_gappo;
|
||||
c->geom.y = m->w.y + (m->w.height - ch) / 2 + target_gappo;
|
||||
|
|
@ -106,7 +104,7 @@ void grid(Monitor *m) {
|
|||
? 0
|
||||
: borderpx;
|
||||
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);
|
||||
cy = m->w.y + (i / cols) * (ch + target_gappi);
|
||||
if (overcols && i >= n - overcols) {
|
||||
|
|
@ -191,9 +189,42 @@ void deck(Monitor *m) {
|
|||
}
|
||||
}
|
||||
|
||||
void horizontal_scroll_adjust_fullandmax(Client *c,
|
||||
struct wlr_box *target_geom) {
|
||||
Monitor *m = c->mon;
|
||||
unsigned int cur_gappih = enablegaps ? m->gappih : 0;
|
||||
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
|
||||
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
|
||||
|
||||
cur_gappih =
|
||||
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappih;
|
||||
cur_gappoh =
|
||||
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappoh;
|
||||
cur_gappov =
|
||||
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappov;
|
||||
|
||||
if (c->isfullscreen) {
|
||||
target_geom->height = m->m.height;
|
||||
target_geom->width = m->m.width;
|
||||
target_geom->y = m->m.y;
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->ismaximizescreen) {
|
||||
target_geom->height = m->w.height - 2 * cur_gappov;
|
||||
target_geom->width = m->w.width - 2 * cur_gappoh;
|
||||
target_geom->y = m->w.y + cur_gappov;
|
||||
return;
|
||||
}
|
||||
|
||||
target_geom->height = m->w.height - 2 * cur_gappov;
|
||||
target_geom->y = m->w.y + (m->w.height - target_geom->height) / 2;
|
||||
}
|
||||
|
||||
// 滚动布局
|
||||
void scroller(Monitor *m) {
|
||||
unsigned int i, n, j;
|
||||
float single_proportion = 1.0;
|
||||
|
||||
Client *c = NULL, *root_client = NULL;
|
||||
Client **tempClients = NULL; // 初始化为 NULL
|
||||
|
|
@ -204,14 +235,17 @@ void scroller(Monitor *m) {
|
|||
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
|
||||
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
|
||||
|
||||
cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih;
|
||||
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
|
||||
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
|
||||
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;
|
||||
|
||||
unsigned int max_client_width =
|
||||
m->w.width - 2 * scroller_structs - cur_gappih;
|
||||
|
||||
n = m->visible_tiling_clients;
|
||||
n = m->visible_scroll_tiling_clients;
|
||||
|
||||
if (n == 0) {
|
||||
return; // 没有需要处理的客户端,直接返回
|
||||
|
|
@ -227,17 +261,22 @@ void scroller(Monitor *m) {
|
|||
// 第二次遍历,填充 tempClients
|
||||
j = 0;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (VISIBLEON(c, m) && ISTILED(c)) {
|
||||
if (VISIBLEON(c, m) && ISSCROLLTILED(c)) {
|
||||
tempClients[j] = c;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
if (n == 1) {
|
||||
if (n == 1 && !scroller_ignore_proportion_single &&
|
||||
!tempClients[0]->isfullscreen && !tempClients[0]->ismaximizescreen) {
|
||||
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.width =
|
||||
(m->w.width - 2 * cur_gappoh) * scroller_default_proportion_single;
|
||||
target_geom.width = (m->w.width - 2 * cur_gappoh) * single_proportion;
|
||||
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;
|
||||
resize(c, target_geom, 0);
|
||||
|
|
@ -245,11 +284,10 @@ void scroller(Monitor *m) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (m->sel && !client_is_unmanaged(m->sel) && !m->sel->isfloating &&
|
||||
!m->sel->ismaximizescreen && !m->sel->isfullscreen) {
|
||||
if (m->sel && !client_is_unmanaged(m->sel) && ISSCROLLTILED(m->sel)) {
|
||||
root_client = m->sel;
|
||||
} else if (m->prevsel && ISTILED(m->prevsel) && VISIBLEON(m->prevsel, m) &&
|
||||
!client_is_unmanaged(m->prevsel)) {
|
||||
} else if (m->prevsel && ISSCROLLTILED(m->prevsel) &&
|
||||
VISIBLEON(m->prevsel, m) && !client_is_unmanaged(m->prevsel)) {
|
||||
root_client = m->prevsel;
|
||||
} else {
|
||||
root_client = center_tiled_select(m);
|
||||
|
|
@ -263,8 +301,7 @@ void scroller(Monitor *m) {
|
|||
for (i = 0; i < n; i++) {
|
||||
c = tempClients[i];
|
||||
if (root_client == c) {
|
||||
if (!c->is_pending_open_animation &&
|
||||
c->geom.x >= m->w.x + scroller_structs &&
|
||||
if (c->geom.x >= m->w.x + scroller_structs &&
|
||||
c->geom.x + c->geom.width <=
|
||||
m->w.x + m->w.width - scroller_structs) {
|
||||
need_scroller = false;
|
||||
|
|
@ -276,17 +313,28 @@ void scroller(Monitor *m) {
|
|||
}
|
||||
}
|
||||
|
||||
if (n == 1 && scroller_ignore_proportion_single) {
|
||||
need_scroller = true;
|
||||
}
|
||||
|
||||
if (start_drag_window)
|
||||
need_scroller = false;
|
||||
|
||||
target_geom.height = m->w.height - 2 * cur_gappov;
|
||||
target_geom.width = max_client_width * c->scroller_proportion;
|
||||
target_geom.y = m->w.y + (m->w.height - target_geom.height) / 2;
|
||||
|
||||
if (need_scroller) {
|
||||
horizontal_scroll_adjust_fullandmax(tempClients[focus_client_index],
|
||||
&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 ||
|
||||
((!m->prevsel ||
|
||||
(ISTILED(m->prevsel) &&
|
||||
(ISSCROLLTILED(m->prevsel) &&
|
||||
(m->prevsel->scroller_proportion * max_client_width) +
|
||||
(root_client->scroller_proportion * max_client_width) >
|
||||
m->w.width - 2 * scroller_structs - cur_gappih)) &&
|
||||
|
|
@ -309,14 +357,17 @@ void scroller(Monitor *m) {
|
|||
for (i = 1; i <= focus_client_index; i++) {
|
||||
c = tempClients[focus_client_index - i];
|
||||
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 -
|
||||
cur_gappih - target_geom.width;
|
||||
|
||||
resize(c, target_geom, 0);
|
||||
}
|
||||
|
||||
for (i = 1; i < n - focus_client_index; i++) {
|
||||
c = tempClients[focus_client_index + i];
|
||||
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 +
|
||||
cur_gappih +
|
||||
tempClients[focus_client_index + i - 1]->geom.width;
|
||||
|
|
|
|||
|
|
@ -155,8 +155,42 @@ void vertical_deck(Monitor *m) {
|
|||
}
|
||||
}
|
||||
|
||||
void vertical_scroll_adjust_fullandmax(Client *c, struct wlr_box *target_geom) {
|
||||
Monitor *m = c->mon;
|
||||
unsigned int cur_gappiv = enablegaps ? m->gappiv : 0;
|
||||
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
|
||||
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
|
||||
|
||||
cur_gappiv =
|
||||
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappiv;
|
||||
cur_gappov =
|
||||
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappov;
|
||||
cur_gappoh =
|
||||
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappoh;
|
||||
|
||||
if (c->isfullscreen) {
|
||||
target_geom->width = m->m.width;
|
||||
target_geom->height = m->m.height;
|
||||
target_geom->x = m->m.x;
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->ismaximizescreen) {
|
||||
target_geom->width = m->w.width - 2 * cur_gappoh;
|
||||
target_geom->height = m->w.height - 2 * cur_gappov;
|
||||
target_geom->x = m->w.x + cur_gappoh;
|
||||
return;
|
||||
}
|
||||
|
||||
target_geom->width = m->w.width - 2 * cur_gappoh;
|
||||
target_geom->x = m->w.x + (m->w.width - target_geom->width) / 2;
|
||||
}
|
||||
|
||||
// 竖屏滚动布局
|
||||
void vertical_scroller(Monitor *m) {
|
||||
unsigned int i, n, j;
|
||||
float single_proportion = 1.0;
|
||||
|
||||
Client *c = NULL, *root_client = NULL;
|
||||
Client **tempClients = NULL;
|
||||
struct wlr_box target_geom;
|
||||
|
|
@ -166,14 +200,17 @@ void vertical_scroller(Monitor *m) {
|
|||
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
|
||||
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
|
||||
|
||||
cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv;
|
||||
cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov;
|
||||
cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh;
|
||||
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;
|
||||
|
||||
unsigned int max_client_height =
|
||||
m->w.height - 2 * scroller_structs - cur_gappiv;
|
||||
|
||||
n = m->visible_tiling_clients;
|
||||
n = m->visible_scroll_tiling_clients;
|
||||
|
||||
if (n == 0) {
|
||||
return;
|
||||
|
|
@ -186,29 +223,33 @@ void vertical_scroller(Monitor *m) {
|
|||
|
||||
j = 0;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (VISIBLEON(c, m) && ISTILED(c)) {
|
||||
if (VISIBLEON(c, m) && ISSCROLLTILED(c)) {
|
||||
tempClients[j] = c;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
if (n == 1) {
|
||||
if (n == 1 && !scroller_ignore_proportion_single &&
|
||||
!tempClients[0]->isfullscreen && !tempClients[0]->ismaximizescreen) {
|
||||
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.height =
|
||||
(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.height = (m->w.height - 2 * cur_gappov) * single_proportion;
|
||||
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);
|
||||
free(tempClients);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m->sel && !client_is_unmanaged(m->sel) && !m->sel->isfloating &&
|
||||
!m->sel->ismaximizescreen && !m->sel->isfullscreen) {
|
||||
if (m->sel && !client_is_unmanaged(m->sel) && ISSCROLLTILED(m->sel)) {
|
||||
root_client = m->sel;
|
||||
} else if (m->prevsel && ISTILED(m->prevsel) && VISIBLEON(m->prevsel, m) &&
|
||||
!client_is_unmanaged(m->prevsel)) {
|
||||
} else if (m->prevsel && ISSCROLLTILED(m->prevsel) &&
|
||||
VISIBLEON(m->prevsel, m) && !client_is_unmanaged(m->prevsel)) {
|
||||
root_client = m->prevsel;
|
||||
} else {
|
||||
root_client = center_tiled_select(m);
|
||||
|
|
@ -222,8 +263,7 @@ void vertical_scroller(Monitor *m) {
|
|||
for (i = 0; i < n; i++) {
|
||||
c = tempClients[i];
|
||||
if (root_client == c) {
|
||||
if (!c->is_pending_open_animation &&
|
||||
c->geom.y >= m->w.y + scroller_structs &&
|
||||
if (c->geom.y >= m->w.y + scroller_structs &&
|
||||
c->geom.y + c->geom.height <=
|
||||
m->w.y + m->w.height - scroller_structs) {
|
||||
need_scroller = false;
|
||||
|
|
@ -235,14 +275,29 @@ void vertical_scroller(Monitor *m) {
|
|||
}
|
||||
}
|
||||
|
||||
if (n == 1 && scroller_ignore_proportion_single) {
|
||||
need_scroller = true;
|
||||
}
|
||||
|
||||
if (start_drag_window)
|
||||
need_scroller = false;
|
||||
|
||||
target_geom.width = m->w.width - 2 * cur_gappoh;
|
||||
target_geom.height = max_client_height * c->scroller_proportion;
|
||||
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 ||
|
||||
((!m->prevsel ||
|
||||
(ISTILED(m->prevsel) &&
|
||||
(ISSCROLLTILED(m->prevsel) &&
|
||||
(m->prevsel->scroller_proportion * max_client_height) +
|
||||
(root_client->scroller_proportion * max_client_height) >
|
||||
m->w.height - 2 * scroller_structs - cur_gappiv)) &&
|
||||
|
|
@ -265,14 +320,17 @@ void vertical_scroller(Monitor *m) {
|
|||
for (i = 1; i <= focus_client_index; i++) {
|
||||
c = tempClients[focus_client_index - i];
|
||||
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 -
|
||||
cur_gappiv - target_geom.height;
|
||||
|
||||
resize(c, target_geom, 0);
|
||||
}
|
||||
|
||||
for (i = 1; i < n - focus_client_index; i++) {
|
||||
c = tempClients[focus_client_index + i];
|
||||
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 +
|
||||
cur_gappiv +
|
||||
tempClients[focus_client_index + i - 1]->geom.height;
|
||||
|
|
@ -310,8 +368,7 @@ void vertical_grid(Monitor *m) {
|
|||
? 0
|
||||
: borderpx;
|
||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||
((m->isoverview && !client_should_ignore_focus(c)) ||
|
||||
ISTILED(c))) {
|
||||
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
||||
ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
|
||||
cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
|
||||
c->geom.x = m->w.x + (m->w.width - cw) / 2;
|
||||
|
|
@ -338,8 +395,7 @@ void vertical_grid(Monitor *m) {
|
|||
? 0
|
||||
: borderpx;
|
||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||
((m->isoverview && !client_should_ignore_focus(c)) ||
|
||||
ISTILED(c))) {
|
||||
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
||||
if (i == 0) {
|
||||
c->geom.x = m->w.x + (m->w.width - cw) / 2 + target_gappo;
|
||||
c->geom.y = m->w.y + target_gappo;
|
||||
|
|
@ -385,7 +441,7 @@ void vertical_grid(Monitor *m) {
|
|||
? 0
|
||||
: borderpx;
|
||||
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);
|
||||
cy = m->w.y + (i % rows) * (ch + target_gappi);
|
||||
if (overrows && i >= n - overrows) {
|
||||
|
|
|
|||