Compare commits
37 Commits
be6ed1764f
...
2f9cabe4b2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f9cabe4b2 | ||
|
|
e2ee985b8f | ||
|
|
4280f8e0bf | ||
|
|
c004f7460c | ||
|
|
03ee277ef6 | ||
|
|
a0824c05df | ||
|
|
e7cb4f77f3 | ||
|
|
e22cf99e74 | ||
|
|
8e4d3b7aac | ||
|
|
58d5938e14 | ||
|
|
4fda32bf1f | ||
|
|
d941e0078e | ||
|
|
9c8f9e3b38 | ||
|
|
cdcc64ab5f | ||
|
|
ecab47fe92 | ||
|
|
fce47b37d9 | ||
|
|
f2b9835243 | ||
|
|
407c9d74a4 | ||
|
|
8875156760 | ||
|
|
514c916678 | ||
|
|
f542d5d5e6 | ||
|
|
d85f4375c8 | ||
|
|
33a0fe2485 | ||
|
|
16296898ce | ||
|
|
5ba7da0570 | ||
|
|
17f1ae2463 | ||
|
|
64dc30dc31 | ||
|
|
0501719604 | ||
|
|
6010cea805 | ||
|
|
e09748764d | ||
|
|
5774df00e0 | ||
|
|
d32fecfd23 | ||
|
|
18ad32384b | ||
|
|
9d6436cf42 | ||
|
|
08097b0991 | ||
|
|
e0bc7fb5e4 | ||
|
|
1029936b18 |
11
README.md
11
README.md
@@ -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,7 +119,7 @@ sudo ninja -C build install
|
||||
|
||||
## Suggested Tools
|
||||
|
||||
### integrated component
|
||||
### Hybrid component
|
||||
- [dms-shell](https://github.com/AvengeMedia/DankMaterialShell)
|
||||
|
||||
### Independent component
|
||||
@@ -189,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, ... }:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
project('mango', ['c', 'cpp'],
|
||||
version : '0.10.5',
|
||||
version : '0.10.6',
|
||||
)
|
||||
|
||||
subdir('protocols')
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -255,8 +255,12 @@ void client_draw_shadow(Client *c) {
|
||||
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);
|
||||
@@ -442,7 +446,7 @@ struct ivec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
|
||||
int offsetx = 0, offsety = 0, offsetw = 0, offseth = 0;
|
||||
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;
|
||||
|
||||
@@ -463,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);
|
||||
@@ -491,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)) {
|
||||
@@ -1056,7 +1060,7 @@ void client_set_focused_opacity_animation(Client *c) {
|
||||
c->opacity_animation.running = true;
|
||||
}
|
||||
|
||||
void cleint_set_unfocused_opacity_animation(Client *c) {
|
||||
void client_set_unfocused_opacity_animation(Client *c) {
|
||||
// Start border color animation to unfocused
|
||||
float *border_color = get_border_color(c);
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ typedef struct {
|
||||
int isunglobal;
|
||||
int isglobal;
|
||||
int isoverlay;
|
||||
int allow_shortcuts_inhibit;
|
||||
int ignore_maximize;
|
||||
int ignore_minimize;
|
||||
int isnosizehint;
|
||||
@@ -77,6 +78,7 @@ typedef struct {
|
||||
int offsety;
|
||||
int width;
|
||||
int height;
|
||||
int nofocus;
|
||||
int nofadein;
|
||||
int nofadeout;
|
||||
int no_force_center;
|
||||
@@ -88,6 +90,7 @@ typedef struct {
|
||||
int noblur;
|
||||
float focused_opacity;
|
||||
float unfocused_opacity;
|
||||
float scroller_proportion_single;
|
||||
uint32_t passmod;
|
||||
xkb_keysym_t keysym;
|
||||
KeyBinding globalkeybinding;
|
||||
@@ -193,6 +196,7 @@ typedef struct {
|
||||
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;
|
||||
@@ -334,6 +338,7 @@ typedef struct {
|
||||
int syncobj_enable;
|
||||
int adaptive_sync;
|
||||
int allow_tearing;
|
||||
int allow_shortcuts_inhibit;
|
||||
|
||||
struct xkb_rule_names xkb_rules;
|
||||
|
||||
@@ -513,61 +518,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) {
|
||||
@@ -886,9 +836,6 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *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) {
|
||||
@@ -1210,6 +1157,8 @@ void parse_option(Config *config, char *key, char *value) {
|
||||
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) {
|
||||
@@ -1270,6 +1219,8 @@ void parse_option(Config *config, char *key, char *value) {
|
||||
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, "no_border_when_single") == 0) {
|
||||
config->no_border_when_single = atoi(value);
|
||||
} else if (strcmp(key, "no_radius_when_single") == 0) {
|
||||
@@ -1707,6 +1658,7 @@ void parse_option(Config *config, char *key, char *value) {
|
||||
rule->isunglobal = -1;
|
||||
rule->isglobal = -1;
|
||||
rule->isoverlay = -1;
|
||||
rule->allow_shortcuts_inhibit = -1;
|
||||
rule->ignore_maximize = -1;
|
||||
rule->ignore_minimize = -1;
|
||||
rule->isnosizehint = -1;
|
||||
@@ -1716,6 +1668,7 @@ void parse_option(Config *config, char *key, char *value) {
|
||||
rule->force_tearing = -1;
|
||||
rule->noswallow = -1;
|
||||
rule->noblur = -1;
|
||||
rule->nofocus = -1;
|
||||
rule->nofadein = -1;
|
||||
rule->nofadeout = -1;
|
||||
rule->no_force_center = -1;
|
||||
@@ -1727,6 +1680,7 @@ void parse_option(Config *config, char *key, char *value) {
|
||||
// float rule value, relay to a client property
|
||||
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
|
||||
@@ -1770,6 +1724,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) {
|
||||
@@ -1796,12 +1752,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) {
|
||||
@@ -2314,35 +2274,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);
|
||||
}
|
||||
|
||||
@@ -2665,6 +2643,8 @@ void override_config(void) {
|
||||
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 =
|
||||
@@ -2690,6 +2670,7 @@ void override_config(void) {
|
||||
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);
|
||||
axis_bind_apply_timeout =
|
||||
CLAMP_INT(config.axis_bind_apply_timeout, 0, 1000);
|
||||
focus_on_activate = CLAMP_INT(config.focus_on_activate, 0, 1);
|
||||
@@ -2852,6 +2833,8 @@ void set_value_default() {
|
||||
config.scroller_default_proportion = scroller_default_proportion;
|
||||
config.scroller_default_proportion_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;
|
||||
@@ -2865,6 +2848,7 @@ void set_value_default() {
|
||||
config.syncobj_enable = syncobj_enable;
|
||||
config.adaptive_sync = adaptive_sync;
|
||||
config.allow_tearing = allow_tearing;
|
||||
config.allow_shortcuts_inhibit = allow_shortcuts_inhibit;
|
||||
config.no_border_when_single = no_border_when_single;
|
||||
config.no_radius_when_single = no_radius_when_single;
|
||||
config.snap_distance = snap_distance;
|
||||
@@ -3144,6 +3128,12 @@ void reapply_monitor_rules(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void reapply_cursor_style(void) {
|
||||
if (cursor_mgr)
|
||||
wlr_xcursor_manager_destroy(cursor_mgr);
|
||||
cursor_mgr = wlr_xcursor_manager_create(config.cursor_theme, cursor_size);
|
||||
}
|
||||
|
||||
void reapply_border(void) {
|
||||
Client *c = NULL;
|
||||
|
||||
@@ -3203,33 +3193,37 @@ void reapply_master(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void parse_tagrule(Monitor *m) {
|
||||
int i, jk;
|
||||
ConfigTagRule tr;
|
||||
|
||||
for (i = 0; i < config.tag_rules_count; i++) {
|
||||
|
||||
tr = config.tag_rules[i];
|
||||
|
||||
if (config.tag_rules_count > 0 &&
|
||||
(!tr.monitor_name ||
|
||||
regex_match(tr.monitor_name, m->wlr_output->name))) {
|
||||
|
||||
for (jk = 0; jk < LENGTH(layouts); jk++) {
|
||||
if (tr.layout_name &&
|
||||
strcmp(layouts[jk].name, tr.layout_name) == 0) {
|
||||
m->pertag->ltidxs[tr.id] = &layouts[jk];
|
||||
}
|
||||
}
|
||||
|
||||
m->pertag->no_hide[tr.id] = tr.no_hide;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void reapply_tagrule(void) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3241,6 +3235,7 @@ void reset_option(void) {
|
||||
set_env();
|
||||
run_exec();
|
||||
|
||||
reapply_cursor_style();
|
||||
reapply_border();
|
||||
reapply_keyboard();
|
||||
reapply_pointer();
|
||||
|
||||
@@ -60,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;
|
||||
@@ -104,6 +105,7 @@ int syncobj_enable = 0;
|
||||
int adaptive_sync = 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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
@@ -488,7 +480,7 @@ int restore_minimized(const Arg *arg) {
|
||||
}
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (c->isminied) {
|
||||
if (c->isminied && !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;
|
||||
}
|
||||
@@ -905,7 +905,7 @@ int switch_layout(const Arg *arg) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
clear_fullscreen_and_maximized_state(selmon);
|
||||
arrange(selmon, false);
|
||||
printstatus();
|
||||
return 0;
|
||||
@@ -916,6 +916,7 @@ int switch_layout(const Arg *arg) {
|
||||
selmon->pertag->ltidxs[selmon->pertag->curtag]->name) == 0) {
|
||||
selmon->pertag->ltidxs[selmon->pertag->curtag] =
|
||||
jk == LENGTH(layouts) - 1 ? &layouts[0] : &layouts[jk + 1];
|
||||
clear_fullscreen_and_maximized_state(selmon);
|
||||
arrange(selmon, false);
|
||||
printstatus();
|
||||
return 0;
|
||||
@@ -931,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++) {
|
||||
@@ -968,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)
|
||||
@@ -977,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;
|
||||
}
|
||||
}
|
||||
@@ -1084,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -258,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);
|
||||
}
|
||||
|
||||
@@ -142,7 +142,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 +185,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 +217,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 +249,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 +281,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 +325,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
|
||||
@@ -374,7 +383,10 @@ Client *get_next_stack_client(Client *c, bool reverse) {
|
||||
}
|
||||
|
||||
float *get_border_color(Client *c) {
|
||||
if (c->isurgent) {
|
||||
|
||||
if (c->mon != selmon) {
|
||||
return bordercolor;
|
||||
} else if (c->isurgent) {
|
||||
return urgentcolor;
|
||||
} else if (c->is_in_scratchpad && selmon && c == selmon->sel) {
|
||||
return scratchpadcolor;
|
||||
|
||||
@@ -115,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) {
|
||||
@@ -612,6 +620,10 @@ arrange(Monitor *m, bool want_animation) {
|
||||
if (ISTILED(c)) {
|
||||
m->visible_tiling_clients++;
|
||||
}
|
||||
|
||||
if (ISSCROLLTILED(c)) {
|
||||
m->visible_scroll_tiling_clients++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -189,9 +189,42 @@ void deck(Monitor *m) {
|
||||
}
|
||||
}
|
||||
|
||||
void horizontal_scroll_adjust_fullandmax(Client *c,
|
||||
struct wlr_box *target_geom) {
|
||||
Monitor *m = c->mon;
|
||||
unsigned int cur_gappih = enablegaps ? m->gappih : 0;
|
||||
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
|
||||
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
|
||||
|
||||
cur_gappih =
|
||||
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappih;
|
||||
cur_gappoh =
|
||||
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappoh;
|
||||
cur_gappov =
|
||||
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappov;
|
||||
|
||||
if (c->isfullscreen) {
|
||||
target_geom->height = m->m.height;
|
||||
target_geom->width = m->m.width;
|
||||
target_geom->y = m->m.y;
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->ismaximizescreen) {
|
||||
target_geom->height = m->w.height - 2 * cur_gappov;
|
||||
target_geom->width = m->w.width - 2 * cur_gappoh;
|
||||
target_geom->y = m->w.y + cur_gappov;
|
||||
return;
|
||||
}
|
||||
|
||||
target_geom->height = m->w.height - 2 * cur_gappov;
|
||||
target_geom->y = m->w.y + (m->w.height - target_geom->height) / 2;
|
||||
}
|
||||
|
||||
// 滚动布局
|
||||
void scroller(Monitor *m) {
|
||||
unsigned int i, n, j;
|
||||
float single_proportion = 1.0;
|
||||
|
||||
Client *c = NULL, *root_client = NULL;
|
||||
Client **tempClients = NULL; // 初始化为 NULL
|
||||
@@ -202,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; // 没有需要处理的客户端,直接返回
|
||||
@@ -225,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);
|
||||
@@ -243,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) && !m->sel->isfloating) {
|
||||
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);
|
||||
@@ -261,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;
|
||||
@@ -274,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)) &&
|
||||
@@ -307,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) && !m->sel->isfloating) {
|
||||
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;
|
||||
|
||||
221
src/mango.c
221
src/mango.c
@@ -48,6 +48,7 @@
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/types/wlr_keyboard.h>
|
||||
#include <wlr/types/wlr_keyboard_group.h>
|
||||
#include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h>
|
||||
#include <wlr/types/wlr_layer_shell_v1.h>
|
||||
#include <wlr/types/wlr_linux_dmabuf_v1.h>
|
||||
#include <wlr/types/wlr_linux_drm_syncobj_v1.h>
|
||||
@@ -103,6 +104,9 @@
|
||||
#define ISTILED(A) \
|
||||
(A && !(A)->isfloating && !(A)->isminied && !(A)->iskilling && \
|
||||
!(A)->ismaximizescreen && !(A)->isfullscreen && !(A)->isunglobal)
|
||||
#define ISSCROLLTILED(A) \
|
||||
(A && !(A)->isfloating && !(A)->isminied && !(A)->iskilling && \
|
||||
!(A)->isunglobal)
|
||||
#define VISIBLEON(C, M) \
|
||||
((C) && (M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
|
||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||
@@ -172,6 +176,11 @@ enum tearing_mode {
|
||||
TEARING_FULLSCREEN_ONLY,
|
||||
};
|
||||
|
||||
enum seat_config_shortcuts_inhibit {
|
||||
SHORTCUTS_INHIBIT_DISABLE,
|
||||
SHORTCUTS_INHIBIT_ENABLE,
|
||||
};
|
||||
|
||||
typedef struct Pertag Pertag;
|
||||
typedef struct Monitor Monitor;
|
||||
typedef struct Client Client;
|
||||
@@ -352,6 +361,7 @@ struct Client {
|
||||
bool drag_to_tile;
|
||||
bool scratchpad_switching_mon;
|
||||
bool fake_no_border;
|
||||
int nofocus;
|
||||
int nofadein;
|
||||
int nofadeout;
|
||||
int no_force_center;
|
||||
@@ -368,6 +378,8 @@ struct Client {
|
||||
bool isleftstack;
|
||||
int tearing_hint;
|
||||
int force_tearing;
|
||||
int allow_shortcuts_inhibit;
|
||||
float scroller_proportion_single;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -397,6 +409,12 @@ typedef struct {
|
||||
struct wl_listener destroy;
|
||||
} KeyboardGroup;
|
||||
|
||||
typedef struct {
|
||||
struct wlr_keyboard_shortcuts_inhibitor_v1 *inhibitor;
|
||||
struct wl_listener destroy;
|
||||
struct wl_list link;
|
||||
} KeyboardShortcutsInhibitor;
|
||||
|
||||
typedef struct {
|
||||
/* Must keep these three elements in this order */
|
||||
unsigned int type; /* LayerShell */
|
||||
@@ -464,6 +482,7 @@ struct Monitor {
|
||||
int asleep;
|
||||
unsigned int visible_clients;
|
||||
unsigned int visible_tiling_clients;
|
||||
unsigned int visible_scroll_tiling_clients;
|
||||
bool has_visible_fullscreen_client;
|
||||
struct wlr_scene_optimized_blur *blur;
|
||||
char last_surface_ws_name[256];
|
||||
@@ -621,7 +640,9 @@ static void urgent(struct wl_listener *listener, void *data);
|
||||
static void view(const Arg *arg, bool want_animation);
|
||||
|
||||
static void handlesig(int signo);
|
||||
|
||||
static void
|
||||
handle_keyboard_shortcuts_inhibit_new_inhibitor(struct wl_listener *listener,
|
||||
void *data);
|
||||
static void virtualkeyboard(struct wl_listener *listener, void *data);
|
||||
static void virtualpointer(struct wl_listener *listener, void *data);
|
||||
static void warp_cursor(const Client *c);
|
||||
@@ -716,6 +737,7 @@ static void refresh_monitors_workspaces_status(Monitor *m);
|
||||
static void init_client_properties(Client *c);
|
||||
static float *get_border_color(Client *c);
|
||||
static void request_fresh_all_monitors(void);
|
||||
static void clear_fullscreen_and_maximized_state(Monitor *m);
|
||||
|
||||
#include "data/static_keymap.h"
|
||||
#include "dispatch/bind_declare.h"
|
||||
@@ -749,6 +771,8 @@ static struct wlr_idle_inhibit_manager_v1 *idle_inhibit_mgr;
|
||||
static struct wlr_layer_shell_v1 *layer_shell;
|
||||
static struct wlr_output_manager_v1 *output_mgr;
|
||||
static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
|
||||
static struct wlr_keyboard_shortcuts_inhibit_manager_v1
|
||||
*keyboard_shortcuts_inhibit;
|
||||
static struct wlr_virtual_pointer_manager_v1 *virtual_pointer_mgr;
|
||||
static struct wlr_output_power_manager_v1 *power_mgr;
|
||||
static struct wlr_pointer_gestures_v1 *pointer_gestures;
|
||||
@@ -772,6 +796,7 @@ static struct wlr_pointer_constraint_v1 *active_constraint;
|
||||
static struct wlr_seat *seat;
|
||||
static KeyboardGroup *kb_group;
|
||||
static struct wl_list inputdevices;
|
||||
static struct wl_list keyboard_shortcut_inhibitors;
|
||||
static unsigned int cursor_mode;
|
||||
static Client *grabc;
|
||||
static int grabcx, grabcy; /* client-relative */
|
||||
@@ -858,6 +883,8 @@ static struct wl_listener request_start_drag = {.notify = requeststartdrag};
|
||||
static struct wl_listener start_drag = {.notify = startdrag};
|
||||
static struct wl_listener new_session_lock = {.notify = locksession};
|
||||
static struct wl_listener drm_lease_request = {.notify = requestdrmlease};
|
||||
static struct wl_listener keyboard_shortcuts_inhibit_new_inhibitor = {
|
||||
.notify = handle_keyboard_shortcuts_inhibit_new_inhibitor};
|
||||
|
||||
#ifdef XWAYLAND
|
||||
static void activatex11(struct wl_listener *listener, void *data);
|
||||
@@ -908,8 +935,26 @@ void applybounds(Client *c, struct wlr_box *bbox) {
|
||||
c->geom.y = bbox->y;
|
||||
}
|
||||
|
||||
void clear_fullscreen_and_maximized_state(Monitor *m) {
|
||||
Client *fc = NULL;
|
||||
wl_list_for_each(fc, &clients, link) {
|
||||
if (fc && VISIBLEON(fc, m) && ISFULLSCREEN(fc)) {
|
||||
clear_fullscreen_flag(fc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*清除全屏标志,还原全屏时清0的border*/
|
||||
void clear_fullscreen_flag(Client *c) {
|
||||
|
||||
if ((c->mon->pertag->ltidxs[get_tags_first_tag_num(c->tags)]->id ==
|
||||
SCROLLER ||
|
||||
c->mon->pertag->ltidxs[get_tags_first_tag_num(c->tags)]->id ==
|
||||
VERTICAL_SCROLLER) &&
|
||||
!c->isfloating) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->isfullscreen) {
|
||||
setfullscreen(c, false);
|
||||
}
|
||||
@@ -1130,6 +1175,7 @@ static void apply_rule_properties(Client *c, const ConfigWinRule *r) {
|
||||
APPLY_INT_PROP(c, r, force_maximize);
|
||||
APPLY_INT_PROP(c, r, force_tearing);
|
||||
APPLY_INT_PROP(c, r, noswallow);
|
||||
APPLY_INT_PROP(c, r, nofocus);
|
||||
APPLY_INT_PROP(c, r, nofadein);
|
||||
APPLY_INT_PROP(c, r, nofadeout);
|
||||
APPLY_INT_PROP(c, r, no_force_center);
|
||||
@@ -1148,8 +1194,10 @@ static void apply_rule_properties(Client *c, const ConfigWinRule *r) {
|
||||
APPLY_INT_PROP(c, r, isnosizehint);
|
||||
APPLY_INT_PROP(c, r, isunglobal);
|
||||
APPLY_INT_PROP(c, r, noblur);
|
||||
APPLY_INT_PROP(c, r, allow_shortcuts_inhibit);
|
||||
|
||||
APPLY_FLOAT_PROP(c, r, scroller_proportion);
|
||||
APPLY_FLOAT_PROP(c, r, scroller_proportion_single);
|
||||
APPLY_FLOAT_PROP(c, r, focused_opacity);
|
||||
APPLY_FLOAT_PROP(c, r, unfocused_opacity);
|
||||
|
||||
@@ -1243,11 +1291,16 @@ void applyrules(Client *c) {
|
||||
const char *appid, *title;
|
||||
unsigned int i, newtags = 0;
|
||||
const ConfigWinRule *r;
|
||||
Monitor *mon = selmon, *m = NULL;
|
||||
Monitor *m = NULL;
|
||||
Client *fc = NULL;
|
||||
bool hit_rule_pos = false;
|
||||
Client *parent = NULL;
|
||||
|
||||
c->isfloating = client_is_float_type(c);
|
||||
parent = client_get_parent(c);
|
||||
|
||||
Monitor *mon = parent && parent->mon ? parent->mon : selmon;
|
||||
|
||||
c->isfloating = client_is_float_type(c) || parent;
|
||||
if (!(appid = client_get_appid(c)))
|
||||
appid = broken;
|
||||
if (!(title = client_get_title(c)))
|
||||
@@ -1264,8 +1317,12 @@ void applyrules(Client *c) {
|
||||
// set general properties
|
||||
apply_rule_properties(c, r);
|
||||
|
||||
// set tags
|
||||
newtags |= (r->tags > 0) ? r->tags : 0;
|
||||
// // set tags
|
||||
if (r->tags > 0) {
|
||||
newtags |= r->tags;
|
||||
} else if (parent) {
|
||||
newtags = parent->tags;
|
||||
}
|
||||
|
||||
// set monitor of client
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
@@ -1334,8 +1391,10 @@ void applyrules(Client *c) {
|
||||
|
||||
int fullscreen_state_backup = c->isfullscreen || client_wants_fullscreen(c);
|
||||
setmon(c, mon, newtags,
|
||||
!c->isopensilent && (!c->istagsilent || !newtags ||
|
||||
newtags & mon->tagset[mon->seltags]));
|
||||
!c->isopensilent &&
|
||||
!(client_is_x11_popup(c) && client_should_ignore_focus(c)) &&
|
||||
(!c->istagsilent || !newtags ||
|
||||
newtags & mon->tagset[mon->seltags]));
|
||||
|
||||
if (c->mon &&
|
||||
!(c->mon == selmon && c->tags & c->mon->tagset[c->mon->seltags]) &&
|
||||
@@ -1964,8 +2023,11 @@ void cleanuplisteners(void) {
|
||||
wl_list_remove(&request_start_drag.link);
|
||||
wl_list_remove(&start_drag.link);
|
||||
wl_list_remove(&new_session_lock.link);
|
||||
wl_list_remove(&drm_lease_request.link);
|
||||
wl_list_remove(&tearing_new_object.link);
|
||||
wl_list_remove(&keyboard_shortcuts_inhibit_new_inhibitor.link);
|
||||
if (drm_lease_manager) {
|
||||
wl_list_remove(&drm_lease_request.link);
|
||||
}
|
||||
#ifdef XWAYLAND
|
||||
wl_list_remove(&new_xwayland_surface.link);
|
||||
wl_list_remove(&xwayland_ready.link);
|
||||
@@ -2148,6 +2210,15 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) {
|
||||
}
|
||||
// 刷新布局,让窗口能感应到exclude_zone变化以及设置独占表面
|
||||
arrangelayers(l->mon);
|
||||
|
||||
// 按需交互layer需要像正常窗口一样抢占非独占layer的焦点
|
||||
if (!exclusive_focus &&
|
||||
l->layer_surface->current.keyboard_interactive ==
|
||||
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND) {
|
||||
focusclient(NULL, 0);
|
||||
client_notify_enter(l->layer_surface->surface,
|
||||
wlr_seat_get_keyboard(seat));
|
||||
}
|
||||
}
|
||||
|
||||
void commitlayersurfacenotify(struct wl_listener *listener, void *data) {
|
||||
@@ -2658,18 +2729,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
||||
}
|
||||
|
||||
// apply tag rule
|
||||
for (i = 1; i <= config.tag_rules_count; i++) {
|
||||
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);
|
||||
|
||||
/* The xdg-protocol specifies:
|
||||
*
|
||||
@@ -3067,6 +3127,9 @@ void destroykeyboardgroup(struct wl_listener *listener, void *data) {
|
||||
}
|
||||
|
||||
void focusclient(Client *c, int lift) {
|
||||
|
||||
Client *last_focus_client = NULL;
|
||||
|
||||
struct wlr_surface *old_keyboard_focus_surface =
|
||||
seat->keyboard_state.focused_surface;
|
||||
|
||||
@@ -3082,6 +3145,9 @@ void focusclient(Client *c, int lift) {
|
||||
if (c && client_should_ignore_focus(c) && client_is_x11_popup(c))
|
||||
return;
|
||||
|
||||
if (c && c->nofocus)
|
||||
return;
|
||||
|
||||
/* Raise client in stacking order if requested */
|
||||
if (c && lift)
|
||||
wlr_scene_node_raise_to_top(&c->scene->node); // 将视图提升到顶层
|
||||
@@ -3098,12 +3164,14 @@ void focusclient(Client *c, int lift) {
|
||||
|
||||
if (c && !c->iskilling && !client_is_unmanaged(c) && c->mon) {
|
||||
|
||||
last_focus_client = selmon->sel;
|
||||
selmon = c->mon;
|
||||
selmon->prevsel = selmon->sel;
|
||||
selmon->sel = c;
|
||||
|
||||
if (selmon->prevsel && !selmon->prevsel->iskilling) {
|
||||
cleint_set_unfocused_opacity_animation(selmon->prevsel);
|
||||
if (last_focus_client && !last_focus_client->iskilling &&
|
||||
last_focus_client != c) {
|
||||
client_set_unfocused_opacity_animation(last_focus_client);
|
||||
}
|
||||
|
||||
client_set_focused_opacity_animation(c);
|
||||
@@ -3113,7 +3181,6 @@ void focusclient(Client *c, int lift) {
|
||||
if (c && selmon->prevsel &&
|
||||
(selmon->prevsel->tags & selmon->tagset[selmon->seltags]) &&
|
||||
(c->tags & selmon->tagset[selmon->seltags]) && !c->isfloating &&
|
||||
!c->isfullscreen && !c->ismaximizescreen &&
|
||||
is_scroller_layout(selmon)) {
|
||||
arrange(selmon, false);
|
||||
}
|
||||
@@ -3249,6 +3316,17 @@ int keyrepeat(void *data) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool is_keyboard_shortcut_inhibitor(struct wlr_surface *surface) {
|
||||
KeyboardShortcutsInhibitor *kbsinhibitor;
|
||||
|
||||
wl_list_for_each(kbsinhibitor, &keyboard_shortcut_inhibitors, link) {
|
||||
if (kbsinhibitor->inhibitor->surface == surface) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int // 17
|
||||
keybinding(unsigned int state, bool locked, unsigned int mods, xkb_keysym_t sym,
|
||||
unsigned int keycode) {
|
||||
@@ -3267,6 +3345,10 @@ keybinding(unsigned int state, bool locked, unsigned int mods, xkb_keysym_t sym,
|
||||
keycode == 62 || keycode == 108 || keycode == 105 || keycode == 134)
|
||||
return false;
|
||||
|
||||
if (is_keyboard_shortcut_inhibitor(seat->keyboard_state.focused_surface)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ji = 0; ji < config.key_bindings_count; ji++) {
|
||||
if (config.key_bindings_count < 1)
|
||||
break;
|
||||
@@ -3291,8 +3373,8 @@ keybinding(unsigned int state, bool locked, unsigned int mods, xkb_keysym_t sym,
|
||||
(strcmp(keymode.mode, k->mode) == 0)) &&
|
||||
CLEANMASK(mods) == CLEANMASK(k->mod) &&
|
||||
((k->keysymcode.type == KEY_TYPE_SYM &&
|
||||
normalize_keysym(sym) ==
|
||||
normalize_keysym(k->keysymcode.keysym)) ||
|
||||
xkb_keysym_to_lower(sym) ==
|
||||
xkb_keysym_to_lower(k->keysymcode.keysym)) ||
|
||||
(k->keysymcode.type == KEY_TYPE_CODE &&
|
||||
(keycode == k->keysymcode.keycode.keycode1 ||
|
||||
keycode == k->keysymcode.keycode.keycode2 ||
|
||||
@@ -3558,6 +3640,7 @@ void init_client_properties(Client *c) {
|
||||
c->fake_no_border = false;
|
||||
c->focused_opacity = focused_opacity;
|
||||
c->unfocused_opacity = unfocused_opacity;
|
||||
c->nofocus = 0;
|
||||
c->nofadein = 0;
|
||||
c->nofadeout = 0;
|
||||
c->no_force_center = 0;
|
||||
@@ -3573,12 +3656,13 @@ void init_client_properties(Client *c) {
|
||||
c->allow_csd = 0;
|
||||
c->force_maximize = 0;
|
||||
c->force_tearing = 0;
|
||||
c->allow_shortcuts_inhibit = SHORTCUTS_INHIBIT_ENABLE;
|
||||
c->scroller_proportion_single = 0.0f;
|
||||
}
|
||||
|
||||
void // old fix to 0.5
|
||||
mapnotify(struct wl_listener *listener, void *data) {
|
||||
/* Called when the surface is mapped, or ready to display on-screen. */
|
||||
Client *p = NULL;
|
||||
Client *at_client = NULL;
|
||||
Client *c = wl_container_of(listener, c, map);
|
||||
/* Create scene tree for this client and its border */
|
||||
@@ -3649,9 +3733,9 @@ mapnotify(struct wl_listener *listener, void *data) {
|
||||
// tile at the top
|
||||
wl_list_insert(&clients, &c->link); // 新窗口是master,头部入栈
|
||||
else if (selmon && is_scroller_layout(selmon) &&
|
||||
selmon->visible_tiling_clients > 0) {
|
||||
selmon->visible_scroll_tiling_clients > 0) {
|
||||
|
||||
if (selmon->sel && ISTILED(selmon->sel) &&
|
||||
if (selmon->sel && ISSCROLLTILED(selmon->sel) &&
|
||||
VISIBLEON(selmon->sel, selmon)) {
|
||||
at_client = selmon->sel;
|
||||
} else {
|
||||
@@ -3670,16 +3754,7 @@ mapnotify(struct wl_listener *listener, void *data) {
|
||||
wl_list_insert(clients.prev, &c->link); // 尾部入栈
|
||||
wl_list_insert(&fstack, &c->flink);
|
||||
|
||||
/* Set initial monitor, tags, floating status, and focus:
|
||||
* we always consider floating, clients that have parent and thus
|
||||
* we set the same tags and monitor than its parent, if not
|
||||
* try to apply rules for them */
|
||||
if ((p = client_get_parent(c))) {
|
||||
c->isfloating = 1;
|
||||
setmon(c, p->mon, p->tags, true);
|
||||
} else {
|
||||
applyrules(c);
|
||||
}
|
||||
applyrules(c);
|
||||
|
||||
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
|
||||
WLR_EDGE_RIGHT);
|
||||
@@ -4492,7 +4567,8 @@ void setmaximizescreen(Client *c, int maximizescreen) {
|
||||
maximizescreen_box.width = c->mon->w.width - 2 * gappoh;
|
||||
maximizescreen_box.height = c->mon->w.height - 2 * gappov;
|
||||
wlr_scene_node_raise_to_top(&c->scene->node); // 将视图提升到顶层
|
||||
resize(c, maximizescreen_box, 0);
|
||||
if (!is_scroller_layout(c->mon) || c->isfloating)
|
||||
resize(c, maximizescreen_box, 0);
|
||||
c->ismaximizescreen = 1;
|
||||
} else {
|
||||
c->bw = c->isnoborder ? 0 : borderpx;
|
||||
@@ -4501,9 +4577,8 @@ void setmaximizescreen(Client *c, int maximizescreen) {
|
||||
setfloating(c, 1);
|
||||
}
|
||||
|
||||
wlr_scene_node_reparent(&c->scene->node, layers[maximizescreen ? LyrTile
|
||||
: c->isfloating ? LyrTop
|
||||
: LyrTile]);
|
||||
wlr_scene_node_reparent(&c->scene->node,
|
||||
layers[c->isfloating ? LyrTop : LyrTile]);
|
||||
if (!c->ismaximizescreen) {
|
||||
set_size_per(c->mon, c);
|
||||
}
|
||||
@@ -4549,7 +4624,8 @@ void setfullscreen(Client *c, int fullscreen) // 用自定义全屏代理自带
|
||||
|
||||
c->bw = 0;
|
||||
wlr_scene_node_raise_to_top(&c->scene->node); // 将视图提升到顶层
|
||||
resize(c, c->mon->m, 1);
|
||||
if (!is_scroller_layout(c->mon) || c->isfloating)
|
||||
resize(c, c->mon->m, 1);
|
||||
c->isfullscreen = 1;
|
||||
} else {
|
||||
c->bw = c->isnoborder ? 0 : borderpx;
|
||||
@@ -4747,8 +4823,11 @@ void setsel(struct wl_listener *listener, void *data) {
|
||||
}
|
||||
|
||||
void show_hide_client(Client *c) {
|
||||
unsigned int target = 1;
|
||||
|
||||
set_size_per(c->mon, c);
|
||||
target = get_tags_first_tag(c->oldtags);
|
||||
|
||||
unsigned int target = get_tags_first_tag(c->oldtags);
|
||||
if (!c->is_in_scratchpad) {
|
||||
tag_client(&(Arg){.ui = target}, c);
|
||||
} else {
|
||||
@@ -4995,6 +5074,7 @@ void setup(void) {
|
||||
* to let us know when new input devices are available on the backend.
|
||||
*/
|
||||
wl_list_init(&inputdevices);
|
||||
wl_list_init(&keyboard_shortcut_inhibitors);
|
||||
wl_signal_add(&backend->events.new_input, &new_input_device);
|
||||
virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy);
|
||||
wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard,
|
||||
@@ -5024,6 +5104,10 @@ void setup(void) {
|
||||
kb_group = createkeyboardgroup();
|
||||
wl_list_init(&kb_group->destroy.link);
|
||||
|
||||
keyboard_shortcuts_inhibit = wlr_keyboard_shortcuts_inhibit_v1_create(dpy);
|
||||
wl_signal_add(&keyboard_shortcuts_inhibit->events.new_inhibitor,
|
||||
&keyboard_shortcuts_inhibit_new_inhibitor);
|
||||
|
||||
output_mgr = wlr_output_manager_v1_create(dpy);
|
||||
wl_signal_add(&output_mgr->events.apply, &output_mgr_apply);
|
||||
wl_signal_add(&output_mgr->events.test, &output_mgr_test);
|
||||
@@ -5116,7 +5200,11 @@ unsigned int want_restore_fullscreen(Client *target_client) {
|
||||
Client *c = NULL;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (c && c != target_client && c->tags == target_client->tags &&
|
||||
c == selmon->sel) {
|
||||
c == selmon->sel &&
|
||||
c->mon->pertag->ltidxs[get_tags_first_tag_num(c->tags)]->id !=
|
||||
SCROLLER &&
|
||||
c->mon->pertag->ltidxs[get_tags_first_tag_num(c->tags)]->id !=
|
||||
VERTICAL_SCROLLER) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -5551,6 +5639,49 @@ void view(const Arg *arg, bool want_animation) {
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
handle_keyboard_shortcuts_inhibitor_destroy(struct wl_listener *listener,
|
||||
void *data) {
|
||||
KeyboardShortcutsInhibitor *inhibitor =
|
||||
wl_container_of(listener, inhibitor, destroy);
|
||||
|
||||
wlr_log(WLR_DEBUG, "Removing keyboard shortcuts inhibitor");
|
||||
|
||||
wl_list_remove(&inhibitor->link);
|
||||
wl_list_remove(&inhibitor->destroy.link);
|
||||
free(inhibitor);
|
||||
}
|
||||
|
||||
void handle_keyboard_shortcuts_inhibit_new_inhibitor(
|
||||
struct wl_listener *listener, void *data) {
|
||||
|
||||
struct wlr_keyboard_shortcuts_inhibitor_v1 *inhibitor = data;
|
||||
|
||||
if (allow_shortcuts_inhibit == SHORTCUTS_INHIBIT_DISABLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// per-view, seat-agnostic config via criteria
|
||||
Client *c = get_client_from_surface(inhibitor->surface);
|
||||
if (c && !c->allow_shortcuts_inhibit) {
|
||||
return;
|
||||
}
|
||||
|
||||
wlr_log(WLR_DEBUG, "Adding keyboard shortcuts inhibitor");
|
||||
|
||||
KeyboardShortcutsInhibitor *kbsinhibitor =
|
||||
calloc(1, sizeof(KeyboardShortcutsInhibitor));
|
||||
|
||||
kbsinhibitor->inhibitor = inhibitor;
|
||||
|
||||
kbsinhibitor->destroy.notify = handle_keyboard_shortcuts_inhibitor_destroy;
|
||||
wl_signal_add(&inhibitor->events.destroy, &kbsinhibitor->destroy);
|
||||
|
||||
wl_list_insert(&keyboard_shortcut_inhibitors, &kbsinhibitor->link);
|
||||
|
||||
wlr_keyboard_shortcuts_inhibitor_v1_activate(inhibitor);
|
||||
}
|
||||
|
||||
void virtualkeyboard(struct wl_listener *listener, void *data) {
|
||||
struct wlr_virtual_keyboard_v1 *kb = data;
|
||||
/* virtual keyboards shouldn't share keyboard group */
|
||||
|
||||
Reference in New Issue
Block a user