Compare commits
26 Commits
0e59209d2b
...
feature/du
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d04eff5ea | ||
|
|
f771e56c31 | ||
|
|
64d350ee9b | ||
|
|
4e296671c2 | ||
|
|
31d29fb48c | ||
|
|
2aa7e58d7c | ||
|
|
01e957f2ae | ||
|
|
318dc85b22 | ||
|
|
dfb59d12c2 | ||
|
|
c3253af75d | ||
|
|
9a2d2397c1 | ||
|
|
dd72e472bf | ||
|
|
f3f3215791 | ||
|
|
1e8e4677dd | ||
|
|
6086507c5a | ||
|
|
178fa5220e | ||
|
|
40948d22ba | ||
|
|
c0eceeb3bf | ||
|
|
94a051e266 | ||
| dd6223d383 | |||
| f7d4420685 | |||
| 09847dd09e | |||
| 50b24942e7 | |||
| 8994b4cee2 | |||
| 5089995cfa | |||
| 9db45cbb52 |
15
README.md
15
README.md
@@ -82,7 +82,6 @@ yay -S mangowc-git
|
||||
```
|
||||
|
||||
## Gentoo Linux
|
||||
|
||||
The package is in the community-maintained repository called GURU.
|
||||
First, add GURU repository:
|
||||
|
||||
@@ -100,6 +99,16 @@ Finally, install the package:
|
||||
emerge --ask --verbose gui-wm/mangowc
|
||||
```
|
||||
|
||||
## Fedora Linux
|
||||
The package is in the third-party Terra repository.
|
||||
First, add the [Terra Repository](https://terra.fyralabs.com/).
|
||||
|
||||
Then, install the package:
|
||||
|
||||
```bash
|
||||
dnf install mangowc
|
||||
```
|
||||
|
||||
## Other
|
||||
|
||||
```bash
|
||||
@@ -172,7 +181,9 @@ git clone https://github.com/DreamMaoMao/mango-config.git ~/.config/mango
|
||||
|
||||
## Config Documentation
|
||||
|
||||
Refer to the [wiki](https://github.com/DreamMaoMao/mango/wiki/)
|
||||
Refer to the repo wiki [wiki](https://github.com/DreamMaoMao/mango/wiki/)
|
||||
|
||||
or the website docs [docs](https://mangowc.vercel.app/docs)
|
||||
|
||||
# NixOS + Home-manager
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ scroller_prefer_center=0
|
||||
edge_scroller_pointer_focus=1
|
||||
scroller_default_proportion_single=1.0
|
||||
scroller_proportion_preset=0.5,0.8,1.0
|
||||
dual_scroller_default_split_ratio=0.3
|
||||
|
||||
# Master-Stack Layout Setting
|
||||
new_is_master=1
|
||||
@@ -237,6 +238,10 @@ bind=CTRL+ALT,Down,resizewin,+0,+50
|
||||
bind=CTRL+ALT,Left,resizewin,-50,+0
|
||||
bind=CTRL+ALT,Right,resizewin,+50,+0
|
||||
|
||||
# dual-scroller split adjustment (increase/decrease top row height)
|
||||
# bind=SUPER+SHIFT,Equal,adjust_dual_scroller_split,0.05
|
||||
# bind=SUPER+SHIFT,Minus,adjust_dual_scroller_split,-0.05
|
||||
|
||||
# Mouse Button Bindings
|
||||
# NONE mode key only work in ov mode
|
||||
mousebind=SUPER,btn_left,moveresize,curmove
|
||||
|
||||
@@ -153,20 +153,6 @@ 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
|
||||
|
||||
@@ -43,6 +43,7 @@ typedef struct {
|
||||
bool isdefaultmode;
|
||||
bool islockapply;
|
||||
bool isreleaseapply;
|
||||
bool ispassapply;
|
||||
} KeyBinding;
|
||||
|
||||
typedef struct {
|
||||
@@ -201,6 +202,7 @@ typedef struct {
|
||||
int scroller_focus_center;
|
||||
int scroller_prefer_center;
|
||||
int edge_scroller_pointer_focus;
|
||||
float dual_scroller_default_split_ratio;
|
||||
int focus_cross_monitor;
|
||||
int exchange_cross_monitor;
|
||||
int scratchpad_cross_monitor;
|
||||
@@ -443,6 +445,9 @@ void parse_bind_flags(const char *str, KeyBinding *kb) {
|
||||
case 'r':
|
||||
kb->isreleaseapply = true;
|
||||
break;
|
||||
case 'p':
|
||||
kb->ispassapply = true;
|
||||
break;
|
||||
default:
|
||||
// 忽略其他字符或可根据需要处理错误
|
||||
break;
|
||||
@@ -816,12 +821,17 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
|
||||
} else if (strcmp(func_name, "focusdir") == 0) {
|
||||
func = focusdir;
|
||||
(*arg).i = parse_direction(arg_value);
|
||||
} else if (strcmp(func_name, "togglerow") == 0) {
|
||||
func = togglerow;
|
||||
} else if (strcmp(func_name, "incnmaster") == 0) {
|
||||
func = incnmaster;
|
||||
(*arg).i = atoi(arg_value);
|
||||
} else if (strcmp(func_name, "setmfact") == 0) {
|
||||
func = setmfact;
|
||||
(*arg).f = atof(arg_value);
|
||||
} else if (strcmp(func_name, "adjust_dual_scroller_split") == 0) {
|
||||
func = adjust_dual_scroller_split;
|
||||
(*arg).f = atof(arg_value);
|
||||
} else if (strcmp(func_name, "zoom") == 0) {
|
||||
func = zoom;
|
||||
} else if (strcmp(func_name, "exchange_client") == 0) {
|
||||
@@ -1191,6 +1201,8 @@ void parse_option(Config *config, char *key, char *value) {
|
||||
config->scroller_prefer_center = atoi(value);
|
||||
} else if (strcmp(key, "edge_scroller_pointer_focus") == 0) {
|
||||
config->edge_scroller_pointer_focus = atoi(value);
|
||||
} else if (strcmp(key, "dual_scroller_default_split_ratio") == 0) {
|
||||
config->dual_scroller_default_split_ratio = atof(value);
|
||||
} else if (strcmp(key, "focus_cross_monitor") == 0) {
|
||||
config->focus_cross_monitor = atoi(value);
|
||||
} else if (strcmp(key, "exchange_cross_monitor") == 0) {
|
||||
@@ -1956,7 +1968,7 @@ void parse_option(Config *config, char *key, char *value) {
|
||||
|
||||
config->exec_once_count++;
|
||||
|
||||
} else if (regex_match("^bind[s|l|r]*$", key)) {
|
||||
} else if (regex_match("^bind[s|l|r|p]*$", key)) {
|
||||
config->key_bindings =
|
||||
realloc(config->key_bindings,
|
||||
(config->key_bindings_count + 1) * sizeof(KeyBinding));
|
||||
@@ -2680,6 +2692,8 @@ void override_config(void) {
|
||||
edge_scroller_pointer_focus =
|
||||
CLAMP_INT(config.edge_scroller_pointer_focus, 0, 1);
|
||||
scroller_structs = CLAMP_INT(config.scroller_structs, 0, 1000);
|
||||
dual_scroller_default_split_ratio =
|
||||
CLAMP_FLOAT(config.dual_scroller_default_split_ratio, 0.1f, 0.9f);
|
||||
|
||||
// 主从布局设置
|
||||
default_mfact = CLAMP_FLOAT(config.default_mfact, 0.1f, 0.9f);
|
||||
@@ -2869,6 +2883,7 @@ void set_value_default() {
|
||||
config.scroller_focus_center = scroller_focus_center;
|
||||
config.scroller_prefer_center = scroller_prefer_center;
|
||||
config.edge_scroller_pointer_focus = edge_scroller_pointer_focus;
|
||||
config.dual_scroller_default_split_ratio = dual_scroller_default_split_ratio;
|
||||
config.focus_cross_monitor = focus_cross_monitor;
|
||||
config.exchange_cross_monitor = exchange_cross_monitor;
|
||||
config.scratchpad_cross_monitor = scratchpad_cross_monitor;
|
||||
|
||||
@@ -63,6 +63,7 @@ float scroller_default_proportion_single = 1.0;
|
||||
int scroller_ignore_proportion_single = 0;
|
||||
int scroller_focus_center = 0;
|
||||
int scroller_prefer_center = 0;
|
||||
float dual_scroller_default_split_ratio = 0.3;
|
||||
int focus_cross_monitor = 0;
|
||||
int focus_cross_tag = 0;
|
||||
int exchange_cross_monitor = 0;
|
||||
|
||||
@@ -2,6 +2,7 @@ int minimized(const Arg *arg);
|
||||
int restore_minimized(const Arg *arg);
|
||||
int toggle_scratchpad(const Arg *arg);
|
||||
int focusdir(const Arg *arg);
|
||||
int togglerow(const Arg *arg);
|
||||
int toggleoverview(const Arg *arg);
|
||||
int set_proportion(const Arg *arg);
|
||||
int switch_proportion_preset(const Arg *arg);
|
||||
@@ -28,6 +29,7 @@ int switch_keyboard_layout(const Arg *arg);
|
||||
int setlayout(const Arg *arg);
|
||||
int switch_layout(const Arg *arg);
|
||||
int setmfact(const Arg *arg);
|
||||
int adjust_dual_scroller_split(const Arg *arg);
|
||||
int quit(const Arg *arg);
|
||||
int moveresize(const Arg *arg);
|
||||
int exchange_client(const Arg *arg);
|
||||
|
||||
@@ -125,6 +125,29 @@ int focusdir(const Arg *arg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int togglerow(const Arg *arg) {
|
||||
// Toggle between top and bottom row in dual-scroller layout
|
||||
if (!selmon || !selmon->sel || !is_row_layout(selmon))
|
||||
return 0;
|
||||
|
||||
Client *c = selmon->sel;
|
||||
|
||||
// Only toggle for tiled windows
|
||||
if (c->isfloating || !ISSCROLLTILED(c) || !VISIBLEON(c, selmon))
|
||||
return 0;
|
||||
|
||||
// Toggle the row (0 <-> 1)
|
||||
if (c->dual_scroller_row == 0) {
|
||||
c->dual_scroller_row = 1;
|
||||
} else {
|
||||
c->dual_scroller_row = 0;
|
||||
}
|
||||
|
||||
// Trigger a relayout
|
||||
arrange(selmon, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int focuslast(const Arg *arg) {
|
||||
|
||||
Client *c = NULL;
|
||||
@@ -304,6 +327,28 @@ int setmfact(const Arg *arg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int adjust_dual_scroller_split(const Arg *arg) {
|
||||
float new_ratio;
|
||||
|
||||
if (!arg || !selmon)
|
||||
return 0;
|
||||
|
||||
// Check if we're in a dual-scroller layout
|
||||
if (!is_row_layout(selmon))
|
||||
return 0;
|
||||
|
||||
// Calculate new ratio: if arg->f < 1.0, treat as relative adjustment, otherwise as absolute value
|
||||
new_ratio = arg->f < 1.0 ? dual_scroller_default_split_ratio + arg->f : arg->f - 1.0;
|
||||
|
||||
// Clamp the ratio between 0.1 and 0.9
|
||||
if (new_ratio < 0.1 || new_ratio > 0.9)
|
||||
return 0;
|
||||
|
||||
dual_scroller_default_split_ratio = new_ratio;
|
||||
arrange(selmon, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int killclient(const Arg *arg) {
|
||||
Client *c = NULL;
|
||||
c = selmon->sel;
|
||||
@@ -713,14 +758,26 @@ int centerwin(const Arg *arg) {
|
||||
Client *c = NULL;
|
||||
c = selmon->sel;
|
||||
|
||||
if (!c || c->isfullscreen)
|
||||
if (!c || c->isfullscreen || c->ismaximizescreen)
|
||||
return 0;
|
||||
if (!c->isfloating)
|
||||
setfloating(c, true);
|
||||
|
||||
c->float_geom = setclient_coordinate_center(c, c->geom, 0, 0);
|
||||
c->iscustomsize = 1;
|
||||
resize(c, c->float_geom, 1);
|
||||
if (c->isfloating) {
|
||||
c->float_geom = setclient_coordinate_center(c, c->geom, 0, 0);
|
||||
c->iscustomsize = 1;
|
||||
resize(c, c->float_geom, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!is_scroller_layout(selmon))
|
||||
return 0;
|
||||
|
||||
if (selmon->pertag->ltidxs[selmon->pertag->curtag]->id == SCROLLER) {
|
||||
c->geom.x = selmon->w.x + (selmon->w.width - c->geom.width) / 2;
|
||||
} else {
|
||||
c->geom.y = selmon->w.y + (selmon->w.height - c->geom.height) / 2;
|
||||
}
|
||||
|
||||
arrange(selmon, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1549,4 +1606,4 @@ int toggle_monitor(const Arg *arg) {
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,14 +6,9 @@ void handle_foreign_activate_request(struct wl_listener *listener, void *data) {
|
||||
Client *c = wl_container_of(listener, c, foreign_activate_request);
|
||||
uint32_t target;
|
||||
|
||||
if (c && c->swallowing)
|
||||
if (c->swallowing)
|
||||
return;
|
||||
|
||||
if (c && !c->isminimized && c == selmon->sel) {
|
||||
set_minimized(c);
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->isminimized) {
|
||||
c->is_in_scratchpad = 0;
|
||||
c->isnamedscratchpad = 0;
|
||||
@@ -27,29 +22,82 @@ void handle_foreign_activate_request(struct wl_listener *listener, void *data) {
|
||||
target = get_tags_first_tag(c->tags);
|
||||
view_in_mon(&(Arg){.ui = target}, true, c->mon, true);
|
||||
focusclient(c, 1);
|
||||
wlr_foreign_toplevel_handle_v1_set_activated(c->foreign_toplevel, true);
|
||||
}
|
||||
|
||||
void handle_foreign_maximize_request(struct wl_listener *listener, void *data) {
|
||||
Client *c = wl_container_of(listener, c, foreign_maximize_request);
|
||||
struct wlr_foreign_toplevel_handle_v1_maximized_event *event = data;
|
||||
|
||||
if (c->swallowing)
|
||||
return;
|
||||
|
||||
if (c->ismaximizescreen && !event->maximized) {
|
||||
setmaximizescreen(c, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!c->ismaximizescreen && event->maximized) {
|
||||
setmaximizescreen(c, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void handle_foreign_minimize_request(struct wl_listener *listener, void *data) {
|
||||
Client *c = wl_container_of(listener, c, foreign_minimize_request);
|
||||
struct wlr_foreign_toplevel_handle_v1_minimized_event *event = data;
|
||||
|
||||
if (c->swallowing)
|
||||
return;
|
||||
|
||||
if (!c->isminimized && event->minimized) {
|
||||
set_minimized(c);
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->isminimized && !event->minimized) {
|
||||
c->is_in_scratchpad = 0;
|
||||
c->isnamedscratchpad = 0;
|
||||
c->is_scratchpad_show = 0;
|
||||
setborder_color(c);
|
||||
show_hide_client(c);
|
||||
arrange(c->mon, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void handle_foreign_fullscreen_request(struct wl_listener *listener,
|
||||
void *data) {
|
||||
return;
|
||||
|
||||
Client *c = wl_container_of(listener, c, foreign_fullscreen_request);
|
||||
struct wlr_foreign_toplevel_handle_v1_fullscreen_event *event = data;
|
||||
|
||||
if (c->swallowing)
|
||||
return;
|
||||
|
||||
if (c->isfullscreen && !event->fullscreen) {
|
||||
setfullscreen(c, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!c->isfullscreen && event->fullscreen) {
|
||||
setfullscreen(c, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void handle_foreign_close_request(struct wl_listener *listener, void *data) {
|
||||
Client *c = wl_container_of(listener, c, foreign_close_request);
|
||||
if (c) {
|
||||
pending_kill_client(c);
|
||||
}
|
||||
pending_kill_client(c);
|
||||
}
|
||||
|
||||
void handle_foreign_destroy(struct wl_listener *listener, void *data) {
|
||||
Client *c = wl_container_of(listener, c, foreign_destroy);
|
||||
if (c) {
|
||||
wl_list_remove(&c->foreign_activate_request.link);
|
||||
wl_list_remove(&c->foreign_fullscreen_request.link);
|
||||
wl_list_remove(&c->foreign_close_request.link);
|
||||
wl_list_remove(&c->foreign_destroy.link);
|
||||
}
|
||||
wl_list_remove(&c->foreign_activate_request.link);
|
||||
wl_list_remove(&c->foreign_minimize_request.link);
|
||||
wl_list_remove(&c->foreign_maximize_request.link);
|
||||
wl_list_remove(&c->foreign_fullscreen_request.link);
|
||||
wl_list_remove(&c->foreign_close_request.link);
|
||||
wl_list_remove(&c->foreign_destroy.link);
|
||||
}
|
||||
|
||||
void remove_foreign_topleve(Client *c) {
|
||||
@@ -67,6 +115,10 @@ void add_foreign_toplevel(Client *c) {
|
||||
if (c->foreign_toplevel) {
|
||||
LISTEN(&(c->foreign_toplevel->events.request_activate),
|
||||
&c->foreign_activate_request, handle_foreign_activate_request);
|
||||
LISTEN(&(c->foreign_toplevel->events.request_minimize),
|
||||
&c->foreign_minimize_request, handle_foreign_minimize_request);
|
||||
LISTEN(&(c->foreign_toplevel->events.request_maximize),
|
||||
&c->foreign_maximize_request, handle_foreign_maximize_request);
|
||||
LISTEN(&(c->foreign_toplevel->events.request_fullscreen),
|
||||
&c->foreign_fullscreen_request,
|
||||
handle_foreign_fullscreen_request);
|
||||
|
||||
@@ -13,7 +13,10 @@ 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);
|
||||
Client *c = NULL;
|
||||
|
||||
toplevel_from_wlr_surface(controller->tearing_control->surface, &c, NULL);
|
||||
|
||||
if (c) {
|
||||
/*
|
||||
* tearing_control->current is actually an enum:
|
||||
|
||||
@@ -158,6 +158,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
|
||||
Client *c = NULL;
|
||||
Client **tempClients = NULL; // 初始化为 NULL
|
||||
int last = -1;
|
||||
bool constrain_to_row = tc->mon && is_row_layout(tc->mon);
|
||||
|
||||
// 第一次遍历,计算客户端数量
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
@@ -273,7 +274,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
|
||||
}
|
||||
break;
|
||||
case LEFT:
|
||||
if (!ignore_align) {
|
||||
if (!ignore_align || constrain_to_row) {
|
||||
for (int _i = 0; _i <= last; _i++) {
|
||||
if (tempClients[_i]->geom.x < sel_x &&
|
||||
tempClients[_i]->geom.y == sel_y &&
|
||||
@@ -289,7 +290,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!tempFocusClients) {
|
||||
if (!tempFocusClients && !constrain_to_row) {
|
||||
for (int _i = 0; _i <= last; _i++) {
|
||||
if (tempClients[_i]->geom.x < sel_x) {
|
||||
int dis_x = tempClients[_i]->geom.x - sel_x;
|
||||
@@ -310,7 +311,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
|
||||
}
|
||||
break;
|
||||
case RIGHT:
|
||||
if (!ignore_align) {
|
||||
if (!ignore_align || constrain_to_row) {
|
||||
for (int _i = 0; _i <= last; _i++) {
|
||||
if (tempClients[_i]->geom.x > sel_x &&
|
||||
tempClients[_i]->geom.y == sel_y &&
|
||||
@@ -326,7 +327,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!tempFocusClients) {
|
||||
if (!tempFocusClients && !constrain_to_row) {
|
||||
for (int _i = 0; _i <= last; _i++) {
|
||||
if (tempClients[_i]->geom.x > sel_x) {
|
||||
int dis_x = tempClients[_i]->geom.x - sel_x;
|
||||
@@ -349,7 +350,7 @@ Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
|
||||
}
|
||||
|
||||
free(tempClients); // 释放内存
|
||||
if(tempSameMonitorFocusClients) {
|
||||
if (tempSameMonitorFocusClients) {
|
||||
return tempSameMonitorFocusClients;
|
||||
} else {
|
||||
return tempFocusClients;
|
||||
|
||||
@@ -23,6 +23,19 @@ bool is_scroller_layout(Monitor *m) {
|
||||
if (m->pertag->ltidxs[m->pertag->curtag]->id == VERTICAL_SCROLLER)
|
||||
return true;
|
||||
|
||||
if (m->pertag->ltidxs[m->pertag->curtag]->id == DUAL_SCROLLER)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_row_layout(Monitor *m) {
|
||||
// Layout has independent horizontal rows where navigation should be constrained
|
||||
// LEFT/RIGHT: stay within same row (same Y)
|
||||
// UP/DOWN: move between rows
|
||||
if (m->pertag->ltidxs[m->pertag->curtag]->id == DUAL_SCROLLER)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -498,6 +498,8 @@ void resize_tile_client(Client *grabc, bool isdrag, int offsetx, int offsety,
|
||||
resize_tile_scroller(grabc, isdrag, offsetx, offsety, time, false);
|
||||
} else if (current_layout->id == VERTICAL_SCROLLER) {
|
||||
resize_tile_scroller(grabc, isdrag, offsetx, offsety, time, true);
|
||||
} else if (current_layout->id == DUAL_SCROLLER) {
|
||||
resize_tile_scroller(grabc, isdrag, offsetx, offsety, time, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -516,17 +518,15 @@ void reset_size_per_mon(Monitor *m, int tile_cilent_num,
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (VISIBLEON(c, m) && ISTILED(c)) {
|
||||
|
||||
if (total_master_inner_percent <= 0.0)
|
||||
return;
|
||||
if (i < m->pertag->nmasters[m->pertag->curtag]) {
|
||||
if (total_master_inner_percent > 0.0 && i < nmasters) {
|
||||
c->ismaster = true;
|
||||
c->stack_innder_per = stack_num ? 1.0f / stack_num : 1.0f;
|
||||
c->master_inner_per =
|
||||
c->master_inner_per / total_master_inner_percent;
|
||||
} else {
|
||||
c->ismaster = false;
|
||||
c->master_inner_per = 1.0f / master_num;
|
||||
c->master_inner_per =
|
||||
master_num > 0 ? 1.0f / master_num : 1.0f;
|
||||
c->stack_innder_per =
|
||||
total_stack_hight_percent
|
||||
? c->stack_innder_per / total_stack_hight_percent
|
||||
@@ -538,10 +538,7 @@ void reset_size_per_mon(Monitor *m, int tile_cilent_num,
|
||||
} else {
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (VISIBLEON(c, m) && ISTILED(c)) {
|
||||
|
||||
if (total_master_inner_percent <= 0.0)
|
||||
return;
|
||||
if (i < m->pertag->nmasters[m->pertag->curtag]) {
|
||||
if (total_master_inner_percent > 0.0 && i < nmasters) {
|
||||
c->ismaster = true;
|
||||
if ((stack_index % 2) ^ (tile_cilent_num % 2 == 0)) {
|
||||
c->stack_innder_per =
|
||||
@@ -558,7 +555,8 @@ void reset_size_per_mon(Monitor *m, int tile_cilent_num,
|
||||
stack_index = i - nmasters;
|
||||
|
||||
c->ismaster = false;
|
||||
c->master_inner_per = 1.0f / master_num;
|
||||
c->master_inner_per =
|
||||
master_num > 0 ? 1.0f / master_num : 1.0f;
|
||||
if ((stack_index % 2) ^ (tile_cilent_num % 2 == 0)) {
|
||||
c->stack_innder_per =
|
||||
total_right_stack_hight_percent
|
||||
@@ -637,7 +635,7 @@ arrange(Monitor *m, bool want_animation) {
|
||||
if (VISIBLEON(c, m)) {
|
||||
if (ISTILED(c)) {
|
||||
|
||||
if (i < m->pertag->nmasters[m->pertag->curtag]) {
|
||||
if (i < nmasters) {
|
||||
master_num++;
|
||||
total_master_inner_percent += c->master_inner_per;
|
||||
} else {
|
||||
@@ -686,4 +684,6 @@ arrange(Monitor *m, bool want_animation) {
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
checkidleinhibitor(NULL);
|
||||
}
|
||||
|
||||
printstatus();
|
||||
}
|
||||
|
||||
@@ -23,10 +23,6 @@ void grid(Monitor *m) {
|
||||
if (c->mon != m)
|
||||
continue;
|
||||
|
||||
c->bw = m->visible_tiling_clients == 1 && no_border_when_single &&
|
||||
smartgaps
|
||||
? 0
|
||||
: borderpx;
|
||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
||||
cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
|
||||
@@ -49,10 +45,6 @@ void grid(Monitor *m) {
|
||||
if (c->mon != m)
|
||||
continue;
|
||||
|
||||
c->bw = m->visible_tiling_clients == 1 && no_border_when_single &&
|
||||
smartgaps
|
||||
? 0
|
||||
: borderpx;
|
||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
||||
if (i == 0) {
|
||||
@@ -99,10 +91,7 @@ void grid(Monitor *m) {
|
||||
|
||||
if (c->mon != m)
|
||||
continue;
|
||||
c->bw =
|
||||
m->visible_tiling_clients == 1 && no_border_when_single && smartgaps
|
||||
? 0
|
||||
: borderpx;
|
||||
|
||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
||||
cx = m->w.x + (i % cols) * (cw + target_gappi);
|
||||
@@ -376,6 +365,212 @@ void scroller(Monitor *m) {
|
||||
free(tempClients); // 最后释放内存
|
||||
}
|
||||
|
||||
// Dual-row scroller layout with independent scrolling
|
||||
// Top row: 30% of screen height, Bottom row: 70% of screen height
|
||||
void dual_scroller(Monitor *m) {
|
||||
unsigned int i, n_top = 0, n_bottom = 0, n_total = 0;
|
||||
|
||||
Client *c = NULL;
|
||||
Client **top_row_clients = NULL;
|
||||
Client **bottom_row_clients = NULL;
|
||||
struct wlr_box target_geom;
|
||||
|
||||
unsigned int cur_gappih = enablegaps ? m->gappih : 0;
|
||||
unsigned int cur_gappoh = enablegaps ? m->gappoh : 0;
|
||||
unsigned int cur_gappov = enablegaps ? m->gappov : 0;
|
||||
unsigned int cur_gappiv = enablegaps ? m->gappiv : 0;
|
||||
|
||||
cur_gappih =
|
||||
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappih;
|
||||
cur_gappoh =
|
||||
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappoh;
|
||||
cur_gappov =
|
||||
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappov;
|
||||
cur_gappiv =
|
||||
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappiv;
|
||||
|
||||
unsigned int max_client_width =
|
||||
m->w.width - 2 * scroller_structs - cur_gappih;
|
||||
|
||||
n_total = m->visible_scroll_tiling_clients;
|
||||
|
||||
if (n_total == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// First pass: count clients per row and assign unassigned clients
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (VISIBLEON(c, m) && ISSCROLLTILED(c)) {
|
||||
// Assign to bottom row by default if not assigned
|
||||
if (c->dual_scroller_row == -1) {
|
||||
c->dual_scroller_row = 1; // Default to bottom row
|
||||
}
|
||||
|
||||
if (c->dual_scroller_row == 0) {
|
||||
n_top++;
|
||||
} else {
|
||||
n_bottom++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Allocate arrays for each row
|
||||
if (n_top > 0) {
|
||||
top_row_clients = malloc(n_top * sizeof(Client *));
|
||||
if (!top_row_clients) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (n_bottom > 0) {
|
||||
bottom_row_clients = malloc(n_bottom * sizeof(Client *));
|
||||
if (!bottom_row_clients) {
|
||||
free(top_row_clients);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Fill row arrays
|
||||
unsigned int top_idx = 0, bottom_idx = 0;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (VISIBLEON(c, m) && ISSCROLLTILED(c)) {
|
||||
if (c->dual_scroller_row == 0) {
|
||||
top_row_clients[top_idx++] = c;
|
||||
} else {
|
||||
bottom_row_clients[bottom_idx++] = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate row heights using configurable split ratio
|
||||
unsigned int top_row_height = (unsigned int)((m->w.height - 2 * cur_gappov - cur_gappiv) * dual_scroller_default_split_ratio);
|
||||
unsigned int bottom_row_height = m->w.height - 2 * cur_gappov - cur_gappiv - top_row_height;
|
||||
unsigned int top_row_y = m->w.y + cur_gappov;
|
||||
unsigned int bottom_row_y = top_row_y + top_row_height + cur_gappiv;
|
||||
|
||||
// Helper function to layout a single row
|
||||
void layout_row(Client **row_clients, unsigned int n_row, unsigned int row_y,
|
||||
unsigned int row_height, bool is_top_row) {
|
||||
if (n_row == 0) return;
|
||||
|
||||
Client *root_client = NULL;
|
||||
int focus_index = -1;
|
||||
bool need_scroller = false;
|
||||
|
||||
// Find focused client in this row
|
||||
for (i = 0; i < n_row; i++) {
|
||||
if (row_clients[i] == m->sel) {
|
||||
root_client = row_clients[i];
|
||||
focus_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If no focused client in this row, keep current scroll position
|
||||
if (!root_client && n_row > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if scrolling is needed
|
||||
if (root_client && !root_client->is_pending_open_animation &&
|
||||
root_client->geom.x >= m->w.x + scroller_structs &&
|
||||
root_client->geom.x + root_client->geom.width <=
|
||||
m->w.x + m->w.width - scroller_structs) {
|
||||
need_scroller = false;
|
||||
} else {
|
||||
need_scroller = true;
|
||||
}
|
||||
|
||||
if (start_drag_window)
|
||||
need_scroller = false;
|
||||
|
||||
// Layout focused client
|
||||
if (focus_index >= 0 && root_client) {
|
||||
target_geom.height = row_height;
|
||||
target_geom.width = max_client_width * root_client->scroller_proportion;
|
||||
target_geom.y = row_y;
|
||||
|
||||
// Handle fullscreen and maximize
|
||||
if (root_client->isfullscreen) {
|
||||
target_geom.height = m->m.height;
|
||||
target_geom.width = m->m.width;
|
||||
target_geom.y = m->m.y;
|
||||
target_geom.x = m->m.x;
|
||||
resize(root_client, target_geom, 0);
|
||||
} else if (root_client->ismaximizescreen) {
|
||||
target_geom.height = m->w.height - 2 * cur_gappov;
|
||||
target_geom.width = m->w.width - 2 * cur_gappoh;
|
||||
target_geom.y = m->w.y + cur_gappov;
|
||||
target_geom.x = m->w.x + cur_gappoh;
|
||||
resize(root_client, target_geom, 0);
|
||||
} else if (need_scroller) {
|
||||
// Determine if we should center
|
||||
bool should_center = (scroller_focus_center ||
|
||||
((!m->prevsel ||
|
||||
(ISSCROLLTILED(m->prevsel) &&
|
||||
(m->prevsel->scroller_proportion * max_client_width) +
|
||||
(root_client->scroller_proportion * max_client_width) >
|
||||
m->w.width - 2 * scroller_structs - cur_gappih)) &&
|
||||
scroller_prefer_center));
|
||||
|
||||
// Top row: never center
|
||||
if (is_top_row) {
|
||||
should_center = false;
|
||||
}
|
||||
|
||||
if (should_center) {
|
||||
target_geom.x = m->w.x + (m->w.width - target_geom.width) / 2;
|
||||
} else {
|
||||
target_geom.x = root_client->geom.x > m->w.x + (m->w.width) / 2
|
||||
? m->w.x + (m->w.width -
|
||||
root_client->scroller_proportion *
|
||||
max_client_width -
|
||||
scroller_structs)
|
||||
: m->w.x + scroller_structs;
|
||||
}
|
||||
resize(root_client, target_geom, 0);
|
||||
} else {
|
||||
target_geom.x = root_client->geom.x;
|
||||
resize(root_client, target_geom, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Layout clients to the left of focused
|
||||
for (i = focus_index - 1; i >= 0 && i < n_row; i--) {
|
||||
c = row_clients[i];
|
||||
target_geom.width = max_client_width * c->scroller_proportion;
|
||||
target_geom.height = row_height;
|
||||
target_geom.y = row_y;
|
||||
|
||||
if (!c->isfullscreen && !c->ismaximizescreen) {
|
||||
target_geom.x = row_clients[i + 1]->geom.x - cur_gappih - target_geom.width;
|
||||
resize(c, target_geom, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Layout clients to the right of focused
|
||||
for (i = focus_index + 1; i < n_row; i++) {
|
||||
c = row_clients[i];
|
||||
target_geom.width = max_client_width * c->scroller_proportion;
|
||||
target_geom.height = row_height;
|
||||
target_geom.y = row_y;
|
||||
|
||||
if (!c->isfullscreen && !c->ismaximizescreen) {
|
||||
target_geom.x = row_clients[i - 1]->geom.x + cur_gappih + row_clients[i - 1]->geom.width;
|
||||
resize(c, target_geom, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Layout both rows independently
|
||||
layout_row(top_row_clients, n_top, top_row_y, top_row_height, true);
|
||||
layout_row(bottom_row_clients, n_bottom, bottom_row_y, bottom_row_height, false);
|
||||
|
||||
// Cleanup
|
||||
free(top_row_clients);
|
||||
free(bottom_row_clients);
|
||||
}
|
||||
|
||||
void center_tile(Monitor *m) {
|
||||
uint32_t i, n = 0, h, r, ie = enablegaps, mw, mx, my, oty, ety, tw;
|
||||
Client *c = NULL;
|
||||
@@ -386,6 +581,8 @@ void center_tile(Monitor *m) {
|
||||
|
||||
n = m->visible_tiling_clients;
|
||||
master_num = m->pertag->nmasters[m->pertag->curtag];
|
||||
master_num = n > master_num ? master_num : n;
|
||||
|
||||
stack_num = n - master_num;
|
||||
|
||||
if (n == 0)
|
||||
@@ -422,6 +619,19 @@ void center_tile(Monitor *m) {
|
||||
// 判断是否需要主区域铺满
|
||||
int should_overspread = center_master_overspread && (n <= nmasters);
|
||||
|
||||
uint32_t master_surplus_height =
|
||||
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (master_num - 1));
|
||||
float master_surplus_ratio = 1.0;
|
||||
|
||||
uint32_t slave_left_surplus_height =
|
||||
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (stack_num / 2 - 1));
|
||||
float slave_left_surplus_ratio = 1.0;
|
||||
|
||||
uint32_t slave_right_surplus_height =
|
||||
(m->w.height - 2 * cur_gappov -
|
||||
cur_gappiv * ie * ((stack_num + 1) / 2 - 1));
|
||||
float slave_right_surplus_ratio = 1.0;
|
||||
|
||||
if (n > nmasters || !should_overspread) {
|
||||
// 计算主区域宽度(居中模式)
|
||||
mw = nmasters ? (m->w.width - 2 * cur_gappoh - cur_gappih * ie) * mfact
|
||||
@@ -466,9 +676,11 @@ void center_tile(Monitor *m) {
|
||||
// 主区域窗口
|
||||
r = MIN(n, nmasters) - i;
|
||||
if (c->master_inner_per > 0.0f) {
|
||||
h = (m->w.height - 2 * cur_gappov -
|
||||
cur_gappiv * ie * (master_num - 1)) *
|
||||
c->master_inner_per;
|
||||
h = master_surplus_height * c->master_inner_per /
|
||||
master_surplus_ratio;
|
||||
master_surplus_height = master_surplus_height - h;
|
||||
master_surplus_ratio =
|
||||
master_surplus_ratio - c->master_inner_per;
|
||||
c->master_mfact_per = mfact;
|
||||
} else {
|
||||
h = (m->w.height - my - cur_gappov -
|
||||
@@ -530,9 +742,12 @@ void center_tile(Monitor *m) {
|
||||
if ((stack_index % 2) ^ (n % 2 == 0)) {
|
||||
// 右侧堆叠窗口
|
||||
if (c->stack_innder_per > 0.0f) {
|
||||
h = (m->w.height - 2 * cur_gappov -
|
||||
cur_gappiv * ie * ((stack_num + 1) / 2 - 1)) *
|
||||
c->stack_innder_per;
|
||||
h = slave_right_surplus_height * c->stack_innder_per /
|
||||
slave_right_surplus_ratio;
|
||||
slave_right_surplus_height =
|
||||
slave_right_surplus_height - h;
|
||||
slave_right_surplus_ratio =
|
||||
slave_right_surplus_ratio - c->stack_innder_per;
|
||||
c->master_mfact_per = mfact;
|
||||
} else {
|
||||
h = (m->w.height - ety - cur_gappov -
|
||||
@@ -556,9 +771,12 @@ void center_tile(Monitor *m) {
|
||||
} else {
|
||||
// 左侧堆叠窗口
|
||||
if (c->stack_innder_per > 0.0f) {
|
||||
h = (m->w.height - 2 * cur_gappov -
|
||||
cur_gappiv * ie * (stack_num / 2 - 1)) *
|
||||
c->stack_innder_per;
|
||||
h = slave_left_surplus_height * c->stack_innder_per /
|
||||
slave_left_surplus_ratio;
|
||||
slave_left_surplus_height =
|
||||
slave_left_surplus_height - h;
|
||||
slave_left_surplus_ratio =
|
||||
slave_left_surplus_ratio - c->stack_innder_per;
|
||||
c->master_mfact_per = mfact;
|
||||
} else {
|
||||
h = (m->w.height - oty - cur_gappov -
|
||||
@@ -595,6 +813,7 @@ void tile(Monitor *m) {
|
||||
|
||||
n = m->visible_tiling_clients;
|
||||
master_num = m->pertag->nmasters[m->pertag->curtag];
|
||||
master_num = n > master_num ? master_num : n;
|
||||
stack_num = n - master_num;
|
||||
|
||||
if (n == 0)
|
||||
@@ -627,15 +846,26 @@ void tile(Monitor *m) {
|
||||
mw = m->w.width - 2 * cur_gappoh + cur_gappih * ie;
|
||||
i = 0;
|
||||
my = ty = cur_gappov;
|
||||
|
||||
uint32_t master_surplus_height =
|
||||
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (master_num - 1));
|
||||
float master_surplus_ratio = 1.0;
|
||||
|
||||
uint32_t slave_surplus_height =
|
||||
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (stack_num - 1));
|
||||
float slave_surplus_ratio = 1.0;
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (!VISIBLEON(c, m) || !ISTILED(c))
|
||||
continue;
|
||||
if (i < m->pertag->nmasters[m->pertag->curtag]) {
|
||||
r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i;
|
||||
if (c->master_inner_per > 0.0f) {
|
||||
h = (m->w.height - 2 * cur_gappov -
|
||||
cur_gappiv * ie * (master_num - 1)) *
|
||||
c->master_inner_per;
|
||||
h = master_surplus_height * c->master_inner_per /
|
||||
master_surplus_ratio;
|
||||
master_surplus_height = master_surplus_height - h;
|
||||
master_surplus_ratio =
|
||||
master_surplus_ratio - c->master_inner_per;
|
||||
c->master_mfact_per = mfact;
|
||||
} else {
|
||||
h = (m->w.height - my - cur_gappov -
|
||||
@@ -655,9 +885,10 @@ void tile(Monitor *m) {
|
||||
} else {
|
||||
r = n - i;
|
||||
if (c->stack_innder_per > 0.0f) {
|
||||
h = (m->w.height - 2 * cur_gappov -
|
||||
cur_gappiv * ie * (stack_num - 1)) *
|
||||
c->stack_innder_per;
|
||||
h = slave_surplus_height * c->stack_innder_per /
|
||||
slave_surplus_ratio;
|
||||
slave_surplus_height = slave_surplus_height - h;
|
||||
slave_surplus_ratio = slave_surplus_ratio - c->stack_innder_per;
|
||||
c->master_mfact_per = mfact;
|
||||
} else {
|
||||
h = (m->w.height - ty - cur_gappov -
|
||||
@@ -692,6 +923,7 @@ void right_tile(Monitor *m) {
|
||||
|
||||
n = m->visible_tiling_clients;
|
||||
master_num = m->pertag->nmasters[m->pertag->curtag];
|
||||
master_num = n > master_num ? master_num : n;
|
||||
stack_num = n - master_num;
|
||||
|
||||
if (n == 0)
|
||||
@@ -724,15 +956,26 @@ void right_tile(Monitor *m) {
|
||||
mw = m->w.width - 2 * cur_gappoh + cur_gappih * ie;
|
||||
i = 0;
|
||||
my = ty = cur_gappov;
|
||||
|
||||
uint32_t master_surplus_height =
|
||||
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (master_num - 1));
|
||||
float master_surplus_ratio = 1.0;
|
||||
|
||||
uint32_t slave_surplus_height =
|
||||
(m->w.height - 2 * cur_gappov - cur_gappiv * ie * (stack_num - 1));
|
||||
float slave_surplus_ratio = 1.0;
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (!VISIBLEON(c, m) || !ISTILED(c))
|
||||
continue;
|
||||
if (i < m->pertag->nmasters[m->pertag->curtag]) {
|
||||
r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i;
|
||||
if (c->master_inner_per > 0.0f) {
|
||||
h = (m->w.height - 2 * cur_gappov -
|
||||
cur_gappiv * ie * (master_num - 1)) *
|
||||
c->master_inner_per;
|
||||
h = master_surplus_height * c->master_inner_per /
|
||||
master_surplus_ratio;
|
||||
master_surplus_height = master_surplus_height - h;
|
||||
master_surplus_ratio =
|
||||
master_surplus_ratio - c->master_inner_per;
|
||||
c->master_mfact_per = mfact;
|
||||
} else {
|
||||
h = (m->w.height - my - cur_gappov -
|
||||
@@ -753,9 +996,10 @@ void right_tile(Monitor *m) {
|
||||
} else {
|
||||
r = n - i;
|
||||
if (c->stack_innder_per > 0.0f) {
|
||||
h = (m->w.height - 2 * cur_gappov -
|
||||
cur_gappiv * ie * (stack_num - 1)) *
|
||||
c->stack_innder_per;
|
||||
h = slave_surplus_height * c->stack_innder_per /
|
||||
slave_surplus_ratio;
|
||||
slave_surplus_height = slave_surplus_height - h;
|
||||
slave_surplus_ratio = slave_surplus_ratio - c->stack_innder_per;
|
||||
c->master_mfact_per = mfact;
|
||||
} else {
|
||||
h = (m->w.height - ty - cur_gappov -
|
||||
@@ -802,4 +1046,4 @@ monocle(Monitor *m) {
|
||||
}
|
||||
if ((c = focustop(m)))
|
||||
wlr_scene_node_raise_to_top(&c->scene->node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ static void vertical_overview(Monitor *m);
|
||||
static void vertical_grid(Monitor *m);
|
||||
static void vertical_scroller(Monitor *m);
|
||||
static void vertical_deck(Monitor *mon);
|
||||
static void dual_scroller(Monitor *mon);
|
||||
|
||||
/* layout(s) */
|
||||
Layout overviewlayout = {"", overview, "overview"};
|
||||
@@ -27,6 +28,7 @@ enum {
|
||||
VERTICAL_GRID,
|
||||
VERTICAL_DECK,
|
||||
RIGHT_TILE,
|
||||
DUAL_SCROLLER,
|
||||
};
|
||||
|
||||
Layout layouts[] = {
|
||||
@@ -44,4 +46,5 @@ Layout layouts[] = {
|
||||
{"VT", vertical_tile, "vertical_tile", VERTICAL_TILE}, // 垂直平铺布局
|
||||
{"VG", vertical_grid, "vertical_grid", VERTICAL_GRID}, // 垂直格子布局
|
||||
{"VK", vertical_deck, "vertical_deck", VERTICAL_DECK}, // 垂直卡片布局
|
||||
{"DS", dual_scroller, "dual_scroller", DUAL_SCROLLER}, // 双行滚动布局
|
||||
};
|
||||
@@ -8,6 +8,7 @@ void vertical_tile(Monitor *m) {
|
||||
|
||||
n = m->visible_tiling_clients;
|
||||
master_num = m->pertag->nmasters[m->pertag->curtag];
|
||||
master_num = n > master_num ? master_num : n;
|
||||
stack_num = n - master_num;
|
||||
|
||||
if (n == 0)
|
||||
@@ -40,15 +41,26 @@ void vertical_tile(Monitor *m) {
|
||||
|
||||
i = 0;
|
||||
mx = tx = cur_gapih;
|
||||
|
||||
uint32_t master_surplus_width =
|
||||
(m->w.width - 2 * cur_gapih - cur_gapih * ie * (master_num - 1));
|
||||
float master_surplus_ratio = 1.0;
|
||||
|
||||
uint32_t slave_surplus_width =
|
||||
(m->w.width - 2 * cur_gapih - cur_gapih * ie * (stack_num - 1));
|
||||
float slave_surplus_ratio = 1.0;
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (!VISIBLEON(c, m) || !ISTILED(c))
|
||||
continue;
|
||||
if (i < m->pertag->nmasters[m->pertag->curtag]) {
|
||||
r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i;
|
||||
if (c->master_inner_per > 0.0f) {
|
||||
w = (m->w.width - 2 * cur_gapih -
|
||||
cur_gapih * ie * (master_num - 1)) *
|
||||
c->master_inner_per;
|
||||
w = master_surplus_width * c->master_inner_per /
|
||||
master_surplus_ratio;
|
||||
master_surplus_width = master_surplus_width - w;
|
||||
master_surplus_ratio =
|
||||
master_surplus_ratio - c->master_inner_per;
|
||||
c->master_mfact_per = mfact;
|
||||
} else {
|
||||
w = (m->w.width - mx - cur_gapih - cur_gapih * ie * (r - 1)) /
|
||||
@@ -67,9 +79,10 @@ void vertical_tile(Monitor *m) {
|
||||
} else {
|
||||
r = n - i;
|
||||
if (c->stack_innder_per > 0.0f) {
|
||||
w = (m->w.width - 2 * cur_gapih -
|
||||
cur_gapih * ie * (stack_num - 1)) *
|
||||
c->stack_innder_per;
|
||||
w = slave_surplus_width * c->stack_innder_per /
|
||||
slave_surplus_ratio;
|
||||
slave_surplus_width = slave_surplus_width - w;
|
||||
slave_surplus_ratio = slave_surplus_ratio - c->stack_innder_per;
|
||||
c->master_mfact_per = mfact;
|
||||
} else {
|
||||
w = (m->w.width - tx - cur_gapih - cur_gapih * ie * (r - 1)) /
|
||||
@@ -363,10 +376,6 @@ void vertical_grid(Monitor *m) {
|
||||
if (c->mon != m)
|
||||
continue;
|
||||
|
||||
c->bw = m->visible_tiling_clients == 1 && no_border_when_single &&
|
||||
smartgaps
|
||||
? 0
|
||||
: borderpx;
|
||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
||||
ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
|
||||
@@ -390,10 +399,6 @@ void vertical_grid(Monitor *m) {
|
||||
if (c->mon != m)
|
||||
continue;
|
||||
|
||||
c->bw = m->visible_tiling_clients == 1 && no_border_when_single &&
|
||||
smartgaps
|
||||
? 0
|
||||
: borderpx;
|
||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
||||
if (i == 0) {
|
||||
@@ -436,10 +441,6 @@ void vertical_grid(Monitor *m) {
|
||||
if (c->mon != m)
|
||||
continue;
|
||||
|
||||
c->bw =
|
||||
m->visible_tiling_clients == 1 && no_border_when_single && smartgaps
|
||||
? 0
|
||||
: borderpx;
|
||||
if (VISIBLEON(c, m) && !c->isunglobal &&
|
||||
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
||||
cx = m->w.x + (i / rows) * (cw + target_gappi);
|
||||
|
||||
28
src/mango.c
28
src/mango.c
@@ -351,6 +351,8 @@ struct Client {
|
||||
struct wl_listener foreign_fullscreen_request;
|
||||
struct wl_listener foreign_close_request;
|
||||
struct wl_listener foreign_destroy;
|
||||
struct wl_listener foreign_minimize_request;
|
||||
struct wl_listener foreign_maximize_request;
|
||||
struct wl_listener set_decoration_mode;
|
||||
struct wl_listener destroy_decoration;
|
||||
|
||||
@@ -396,6 +398,7 @@ struct Client {
|
||||
double old_master_mfact_per, old_master_inner_per, old_stack_innder_per;
|
||||
double old_scroller_pproportion;
|
||||
bool ismaster;
|
||||
int dual_scroller_row; // 0 = top row, 1 = bottom row, -1 = not set
|
||||
bool cursor_in_upper_half, cursor_in_left_half;
|
||||
bool isleftstack;
|
||||
int tearing_hint;
|
||||
@@ -741,6 +744,7 @@ static struct wlr_scene_tree *
|
||||
wlr_scene_tree_snapshot(struct wlr_scene_node *node,
|
||||
struct wlr_scene_tree *parent);
|
||||
static bool is_scroller_layout(Monitor *m);
|
||||
static bool is_row_layout(Monitor *m);
|
||||
static void create_output(struct wlr_backend *backend, void *data);
|
||||
static void get_layout_abbr(char *abbr, const char *full_name);
|
||||
static void apply_named_scratchpad(Client *target_client);
|
||||
@@ -2820,6 +2824,7 @@ createnotify(struct wl_listener *listener, void *data) {
|
||||
c = toplevel->base->data = ecalloc(1, sizeof(*c));
|
||||
c->surface.xdg = toplevel->base;
|
||||
c->bw = borderpx;
|
||||
c->dual_scroller_row = -1; // Not assigned to a row yet
|
||||
|
||||
LISTEN(&toplevel->base->surface->events.commit, &c->commit, commitnotify);
|
||||
LISTEN(&toplevel->base->surface->events.map, &c->map, mapnotify);
|
||||
@@ -3432,7 +3437,11 @@ keybinding(uint32_t state, bool locked, uint32_t mods, xkb_keysym_t sym,
|
||||
k->func) {
|
||||
|
||||
isbreak = k->func(&k->arg);
|
||||
handled = 1;
|
||||
|
||||
if (!k->ispassapply)
|
||||
handled = 1;
|
||||
else
|
||||
handled = 0;
|
||||
|
||||
if (isbreak)
|
||||
break;
|
||||
@@ -3796,6 +3805,11 @@ mapnotify(struct wl_listener *listener, void *data) {
|
||||
}
|
||||
|
||||
if (at_client) {
|
||||
// For row-based layouts, assign new client to same row as focused client
|
||||
if (is_row_layout(selmon) && at_client->dual_scroller_row >= 0) {
|
||||
c->dual_scroller_row = at_client->dual_scroller_row;
|
||||
}
|
||||
|
||||
at_client->link.next->prev = &c->link;
|
||||
c->link.prev = &at_client->link;
|
||||
c->link.next = at_client->link.next;
|
||||
@@ -5700,8 +5714,15 @@ void handle_keyboard_shortcuts_inhibit_new_inhibitor(
|
||||
}
|
||||
|
||||
// per-view, seat-agnostic config via criteria
|
||||
Client *c = get_client_from_surface(inhibitor->surface);
|
||||
if (c && !c->allow_shortcuts_inhibit) {
|
||||
Client *c = NULL;
|
||||
LayerSurface *l = NULL;
|
||||
|
||||
int type = toplevel_from_wlr_surface(inhibitor->surface, &c, &l);
|
||||
|
||||
if (type < 0)
|
||||
return;
|
||||
|
||||
if (type != LayerShell && c && !c->allow_shortcuts_inhibit) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5840,6 +5861,7 @@ void createnotifyx11(struct wl_listener *listener, void *data) {
|
||||
c = xsurface->data = ecalloc(1, sizeof(*c));
|
||||
c->surface.xwayland = xsurface;
|
||||
c->type = X11;
|
||||
c->dual_scroller_row = -1; // Not assigned to a row yet
|
||||
/* Listen to the various events it can emit */
|
||||
LISTEN(&xsurface->events.associate, &c->associate, associatex11);
|
||||
LISTEN(&xsurface->events.destroy, &c->destroy, destroynotify);
|
||||
|
||||
Reference in New Issue
Block a user