Compare commits
18 Commits
e4c3fc5ed7
...
40948d22ba
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40948d22ba | ||
|
|
c0eceeb3bf | ||
|
|
09c1920515 | ||
|
|
b3ccf43453 | ||
|
|
7c7a9437e6 | ||
|
|
66bf6d5cff | ||
|
|
006cf46c52 | ||
|
|
16368a8781 | ||
|
|
b768f72eaa | ||
|
|
28ab0e6343 | ||
|
|
94a051e266 | ||
| dd6223d383 | |||
| f7d4420685 | |||
| 09847dd09e | |||
| 50b24942e7 | |||
| 8994b4cee2 | |||
| 5089995cfa | |||
| 9db45cbb52 |
@@ -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
|
||||
|
||||
@@ -200,6 +200,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;
|
||||
@@ -339,6 +340,7 @@ typedef struct {
|
||||
int adaptive_sync;
|
||||
int allow_tearing;
|
||||
int allow_shortcuts_inhibit;
|
||||
int allow_lock_transparent;
|
||||
|
||||
struct xkb_rule_names xkb_rules;
|
||||
|
||||
@@ -814,12 +816,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) {
|
||||
@@ -1165,6 +1172,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) {
|
||||
@@ -1221,6 +1230,8 @@ void parse_option(Config *config, char *key, char *value) {
|
||||
config->allow_tearing = atoi(value);
|
||||
} else if (strcmp(key, "allow_shortcuts_inhibit") == 0) {
|
||||
config->allow_shortcuts_inhibit = atoi(value);
|
||||
} else if (strcmp(key, "allow_lock_transparent") == 0) {
|
||||
config->allow_lock_transparent = atoi(value);
|
||||
} else if (strcmp(key, "no_border_when_single") == 0) {
|
||||
config->no_border_when_single = atoi(value);
|
||||
} else if (strcmp(key, "no_radius_when_single") == 0) {
|
||||
@@ -2650,6 +2661,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);
|
||||
@@ -2671,6 +2684,7 @@ void override_config(void) {
|
||||
adaptive_sync = CLAMP_INT(config.adaptive_sync, 0, 1);
|
||||
allow_tearing = CLAMP_INT(config.allow_tearing, 0, 2);
|
||||
allow_shortcuts_inhibit = CLAMP_INT(config.allow_shortcuts_inhibit, 0, 1);
|
||||
allow_lock_transparent = CLAMP_INT(config.allow_lock_transparent, 0, 1);
|
||||
axis_bind_apply_timeout =
|
||||
CLAMP_INT(config.axis_bind_apply_timeout, 0, 1000);
|
||||
focus_on_activate = CLAMP_INT(config.focus_on_activate, 0, 1);
|
||||
@@ -2838,6 +2852,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;
|
||||
@@ -2849,6 +2864,7 @@ void set_value_default() {
|
||||
config.adaptive_sync = adaptive_sync;
|
||||
config.allow_tearing = allow_tearing;
|
||||
config.allow_shortcuts_inhibit = allow_shortcuts_inhibit;
|
||||
config.allow_lock_transparent = allow_lock_transparent;
|
||||
config.no_border_when_single = no_border_when_single;
|
||||
config.no_radius_when_single = no_radius_when_single;
|
||||
config.snap_distance = snap_distance;
|
||||
|
||||
@@ -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;
|
||||
@@ -103,6 +104,7 @@ int warpcursor = 1; /* Warp cursor to focused client */
|
||||
int xwayland_persistence = 1; /* xwayland persistence */
|
||||
int syncobj_enable = 0;
|
||||
int adaptive_sync = 0;
|
||||
int allow_lock_transparent = 0;
|
||||
double drag_refresh_interval = 30.0;
|
||||
int allow_tearing = TEARING_DISABLED;
|
||||
int allow_shortcuts_inhibit = SHORTCUTS_INHIBIT_ENABLE;
|
||||
|
||||
@@ -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;
|
||||
@@ -133,7 +156,7 @@ int focuslast(const Arg *arg) {
|
||||
unsigned int target = 0;
|
||||
|
||||
wl_list_for_each(c, &fstack, flink) {
|
||||
if (c->iskilling || c->isminied || c->isunglobal ||
|
||||
if (c->iskilling || c->isminimized || c->isunglobal ||
|
||||
!client_surface(c)->mapped || client_is_unmanaged(c) ||
|
||||
client_is_x11_popup(c))
|
||||
continue;
|
||||
@@ -307,6 +330,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;
|
||||
@@ -471,7 +516,7 @@ int restore_minimized(const Arg *arg) {
|
||||
|
||||
if (selmon && selmon->sel && selmon->sel->is_in_scratchpad &&
|
||||
selmon->sel->is_scratchpad_show) {
|
||||
selmon->sel->isminied = 0;
|
||||
selmon->sel->isminimized = 0;
|
||||
selmon->sel->is_scratchpad_show = 0;
|
||||
selmon->sel->is_in_scratchpad = 0;
|
||||
selmon->sel->isnamedscratchpad = 0;
|
||||
@@ -480,7 +525,7 @@ int restore_minimized(const Arg *arg) {
|
||||
}
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (c->isminied && !c->isnamedscratchpad) {
|
||||
if (c->isminimized && !c->isnamedscratchpad) {
|
||||
c->is_scratchpad_show = 0;
|
||||
c->is_in_scratchpad = 0;
|
||||
c->isnamedscratchpad = 0;
|
||||
@@ -1122,7 +1167,7 @@ int toggle_scratchpad(const Arg *arg) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (single_scratchpad && c->isnamedscratchpad && !c->isminied) {
|
||||
if (single_scratchpad && c->isnamedscratchpad && !c->isminimized) {
|
||||
set_minimized(c);
|
||||
continue;
|
||||
}
|
||||
@@ -1447,7 +1492,7 @@ int minimized(const Arg *arg) {
|
||||
if (selmon && selmon->isoverview)
|
||||
return 0;
|
||||
|
||||
if (selmon->sel && !selmon->sel->isminied) {
|
||||
if (selmon->sel && !selmon->sel->isminimized) {
|
||||
set_minimized(selmon->sel);
|
||||
}
|
||||
return 0;
|
||||
@@ -1469,7 +1514,7 @@ int toggleoverview(const Arg *arg) {
|
||||
wl_list_for_each(c, &clients, link) if (c && c->mon == selmon &&
|
||||
!client_is_unmanaged(c) &&
|
||||
!client_is_x11_popup(c) &&
|
||||
!c->isminied &&
|
||||
!c->isminimized &&
|
||||
!c->isunglobal) {
|
||||
visible_client_number++;
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ void handle_foreign_activate_request(struct wl_listener *listener, void *data) {
|
||||
if (c && c->swallowing)
|
||||
return;
|
||||
|
||||
if (c && !c->isminied && c == selmon->sel) {
|
||||
if (c && !c->isminimized && c == selmon->sel) {
|
||||
set_minimized(c);
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->isminied) {
|
||||
if (c->isminimized) {
|
||||
c->is_in_scratchpad = 0;
|
||||
c->isnamedscratchpad = 0;
|
||||
c->is_scratchpad_show = 0;
|
||||
|
||||
@@ -146,6 +146,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) {
|
||||
@@ -249,7 +250,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 &&
|
||||
@@ -265,7 +266,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;
|
||||
@@ -281,7 +282,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 &&
|
||||
@@ -297,7 +298,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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -377,6 +377,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) {
|
||||
unsigned int i, n = 0, h, r, ie = enablegaps, mw, mx, my, oty, ety, tw;
|
||||
Client *c = NULL;
|
||||
@@ -803,4 +1009,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}, // 双行滚动布局
|
||||
};
|
||||
101
src/mango.c
101
src/mango.c
@@ -102,10 +102,10 @@
|
||||
A->geom.x + A->geom.width <= A->mon->m.x + A->mon->m.width && \
|
||||
A->geom.y + A->geom.height <= A->mon->m.y + A->mon->m.height)
|
||||
#define ISTILED(A) \
|
||||
(A && !(A)->isfloating && !(A)->isminied && !(A)->iskilling && \
|
||||
(A && !(A)->isfloating && !(A)->isminimized && !(A)->iskilling && \
|
||||
!(A)->ismaximizescreen && !(A)->isfullscreen && !(A)->isunglobal)
|
||||
#define ISSCROLLTILED(A) \
|
||||
(A && !(A)->isfloating && !(A)->isminied && !(A)->iskilling && \
|
||||
(A && !(A)->isfloating && !(A)->isminimized && !(A)->iskilling && \
|
||||
!(A)->isunglobal)
|
||||
#define VISIBLEON(C, M) \
|
||||
((C) && (M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
|
||||
@@ -315,7 +315,7 @@ struct Client {
|
||||
unsigned int configure_serial;
|
||||
struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel;
|
||||
int isfloating, isurgent, isfullscreen, isfakefullscreen,
|
||||
need_float_size_reduce, isminied, isoverlay, isnosizehint,
|
||||
need_float_size_reduce, isminimized, isoverlay, isnosizehint,
|
||||
ignore_maximize, ignore_minimize;
|
||||
int ismaximizescreen;
|
||||
int overview_backup_bw;
|
||||
@@ -374,6 +374,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;
|
||||
@@ -719,6 +720,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);
|
||||
@@ -1009,7 +1011,7 @@ void swallow(Client *c, Client *w) {
|
||||
c->isurgent = w->isurgent;
|
||||
c->isfullscreen = w->isfullscreen;
|
||||
c->ismaximizescreen = w->ismaximizescreen;
|
||||
c->isminied = w->isminied;
|
||||
c->isminimized = w->isminimized;
|
||||
c->is_in_scratchpad = w->is_in_scratchpad;
|
||||
c->is_scratchpad_show = w->is_scratchpad_show;
|
||||
c->tags = w->tags;
|
||||
@@ -1029,7 +1031,7 @@ void swallow(Client *c, Client *w) {
|
||||
if (!c->foreign_toplevel && c->mon)
|
||||
add_foreign_toplevel(c);
|
||||
|
||||
if (c->isminied && c->foreign_toplevel) {
|
||||
if (c->isminimized && c->foreign_toplevel) {
|
||||
wlr_foreign_toplevel_handle_v1_set_activated(c->foreign_toplevel,
|
||||
false);
|
||||
wlr_foreign_toplevel_handle_v1_set_minimized(c->foreign_toplevel, true);
|
||||
@@ -1376,7 +1378,7 @@ void applyrules(Client *c) {
|
||||
if (!c->noswallow && !c->isfloating && !client_is_float_type(c) &&
|
||||
!c->surface.xdg->initial_commit) {
|
||||
Client *p = termforwin(c);
|
||||
if (p) {
|
||||
if (p && !p->isminimized) {
|
||||
c->swallowedby = p;
|
||||
p->swallowing = c;
|
||||
wl_list_remove(&c->link);
|
||||
@@ -1557,12 +1559,19 @@ void apply_window_snap(Client *c) {
|
||||
resize(c, c->geom, 0);
|
||||
}
|
||||
|
||||
void focuslayer(LayerSurface *l) {
|
||||
focusclient(NULL, 0);
|
||||
dwl_im_relay_set_focus(dwl_input_method_relay, l->layer_surface->surface);
|
||||
client_notify_enter(l->layer_surface->surface, wlr_seat_get_keyboard(seat));
|
||||
}
|
||||
|
||||
void reset_exclusive_layer(Monitor *m) {
|
||||
LayerSurface *l = NULL;
|
||||
int i;
|
||||
unsigned int layers_above_shell[] = {
|
||||
ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY,
|
||||
ZWLR_LAYER_SHELL_V1_LAYER_TOP,
|
||||
ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM,
|
||||
};
|
||||
|
||||
if (!m)
|
||||
@@ -1570,18 +1579,24 @@ void reset_exclusive_layer(Monitor *m) {
|
||||
|
||||
for (i = 0; i < (int)LENGTH(layers_above_shell); i++) {
|
||||
wl_list_for_each_reverse(l, &m->layers[layers_above_shell[i]], link) {
|
||||
if (l == exclusive_focus &&
|
||||
l->layer_surface->current.keyboard_interactive !=
|
||||
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)
|
||||
exclusive_focus = NULL;
|
||||
if (l->layer_surface->current.keyboard_interactive ==
|
||||
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE &&
|
||||
l->layer_surface->surface ==
|
||||
seat->keyboard_state.focused_surface)
|
||||
focusclient(focustop(selmon), 1);
|
||||
|
||||
if (locked ||
|
||||
l->layer_surface->current.keyboard_interactive !=
|
||||
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE ||
|
||||
!l->mapped || l == exclusive_focus)
|
||||
continue;
|
||||
/* Deactivate the focused client. */
|
||||
focusclient(NULL, 0);
|
||||
exclusive_focus = l;
|
||||
dwl_im_relay_set_focus(dwl_input_method_relay,
|
||||
l->layer_surface->surface);
|
||||
client_notify_enter(l->layer_surface->surface,
|
||||
wlr_seat_get_keyboard(seat));
|
||||
focuslayer(l);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1882,11 +1897,7 @@ buttonpress(struct wl_listener *listener, void *data) {
|
||||
if (l && !exclusive_focus &&
|
||||
l->layer_surface->current.keyboard_interactive ==
|
||||
ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND) {
|
||||
focusclient(NULL, 0);
|
||||
dwl_im_relay_set_focus(dwl_input_method_relay,
|
||||
l->layer_surface->surface);
|
||||
client_notify_enter(l->layer_surface->surface,
|
||||
wlr_seat_get_keyboard(seat));
|
||||
focuslayer(l);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2215,9 +2226,7 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) {
|
||||
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));
|
||||
focuslayer(l);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2784,6 +2793,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);
|
||||
@@ -3029,7 +3039,9 @@ void destroylock(SessionLock *lock, int unlock) {
|
||||
if ((locked = !unlock))
|
||||
goto destroy;
|
||||
|
||||
wlr_scene_node_set_enabled(&locked_bg->node, false);
|
||||
if (locked_bg->node.enabled) {
|
||||
wlr_scene_node_set_enabled(&locked_bg->node, false);
|
||||
}
|
||||
|
||||
focusclient(focustop(selmon), 0);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
@@ -3567,7 +3579,9 @@ void pending_kill_client(Client *c) {
|
||||
void locksession(struct wl_listener *listener, void *data) {
|
||||
struct wlr_session_lock_v1 *session_lock = data;
|
||||
SessionLock *lock;
|
||||
wlr_scene_node_set_enabled(&locked_bg->node, true);
|
||||
if (!allow_lock_transparent) {
|
||||
wlr_scene_node_set_enabled(&locked_bg->node, true);
|
||||
}
|
||||
if (cur_lock) {
|
||||
wlr_session_lock_v1_destroy(session_lock);
|
||||
return;
|
||||
@@ -3622,7 +3636,7 @@ void init_client_properties(Client *c) {
|
||||
c->iskilling = 0;
|
||||
c->istagswitching = 0;
|
||||
c->isglobal = 0;
|
||||
c->isminied = 0;
|
||||
c->isminimized = 0;
|
||||
c->isoverlay = 0;
|
||||
c->isunglobal = 0;
|
||||
c->is_in_scratchpad = 0;
|
||||
@@ -3743,6 +3757,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;
|
||||
@@ -3792,7 +3811,7 @@ void maximizenotify(struct wl_listener *listener, void *data) {
|
||||
|
||||
void unminimize(Client *c) {
|
||||
if (c && c->is_in_scratchpad && c->is_scratchpad_show) {
|
||||
c->isminied = 0;
|
||||
c->isminimized = 0;
|
||||
c->is_scratchpad_show = 0;
|
||||
c->is_in_scratchpad = 0;
|
||||
c->isnamedscratchpad = 0;
|
||||
@@ -3800,7 +3819,7 @@ void unminimize(Client *c) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (c && c->isminied) {
|
||||
if (c && c->isminimized) {
|
||||
show_hide_client(c);
|
||||
c->is_scratchpad_show = 0;
|
||||
c->is_in_scratchpad = 0;
|
||||
@@ -3820,7 +3839,7 @@ void set_minimized(Client *c) {
|
||||
c->oldtags = c->mon->tagset[c->mon->seltags];
|
||||
c->mini_restore_tag = c->tags;
|
||||
c->tags = 0;
|
||||
c->isminied = 1;
|
||||
c->isminimized = 1;
|
||||
c->is_in_scratchpad = 1;
|
||||
c->is_scratchpad_show = 0;
|
||||
focusclient(focustop(selmon), 1);
|
||||
@@ -3835,15 +3854,15 @@ void minimizenotify(struct wl_listener *listener, void *data) {
|
||||
|
||||
Client *c = wl_container_of(listener, c, minimize);
|
||||
|
||||
if (!c || !c->mon || c->iskilling || c->isminied)
|
||||
if (!c || !c->mon || c->iskilling || c->isminimized)
|
||||
return;
|
||||
|
||||
if (client_request_minimize(c, data) && !c->ignore_minimize) {
|
||||
if (!c->isminied)
|
||||
if (!c->isminimized)
|
||||
set_minimized(c);
|
||||
client_set_minimized(c, true);
|
||||
} else {
|
||||
if (c->isminied)
|
||||
if (c->isminimized)
|
||||
unminimize(c);
|
||||
client_set_minimized(c, false);
|
||||
}
|
||||
@@ -4548,6 +4567,9 @@ void setmaximizescreen(Client *c, int maximizescreen) {
|
||||
if (!c || !c->mon || !client_surface(c)->mapped || c->iskilling)
|
||||
return;
|
||||
|
||||
if (c->mon->isoverview)
|
||||
return;
|
||||
|
||||
c->ismaximizescreen = maximizescreen;
|
||||
|
||||
if (maximizescreen) {
|
||||
@@ -4557,10 +4579,6 @@ void setmaximizescreen(Client *c, int maximizescreen) {
|
||||
|
||||
if (c->isfloating)
|
||||
c->float_geom = c->geom;
|
||||
if (selmon->isoverview) {
|
||||
Arg arg = {0};
|
||||
toggleoverview(&arg);
|
||||
}
|
||||
|
||||
maximizescreen_box.x = c->mon->w.x + gappoh;
|
||||
maximizescreen_box.y = c->mon->w.y + gappov;
|
||||
@@ -4604,11 +4622,15 @@ void setfakefullscreen(Client *c, int fakefullscreen) {
|
||||
|
||||
void setfullscreen(Client *c, int fullscreen) // 用自定义全屏代理自带全屏
|
||||
{
|
||||
c->isfullscreen = fullscreen;
|
||||
|
||||
if (!c || !c->mon || !client_surface(c)->mapped || c->iskilling)
|
||||
return;
|
||||
|
||||
if (c->mon->isoverview)
|
||||
return;
|
||||
|
||||
c->isfullscreen = fullscreen;
|
||||
|
||||
client_set_fullscreen(c, fullscreen);
|
||||
|
||||
if (fullscreen) {
|
||||
@@ -4617,10 +4639,6 @@ void setfullscreen(Client *c, int fullscreen) // 用自定义全屏代理自带
|
||||
|
||||
if (c->isfloating)
|
||||
c->float_geom = c->geom;
|
||||
if (selmon->isoverview) {
|
||||
Arg arg = {0};
|
||||
toggleoverview(&arg);
|
||||
}
|
||||
|
||||
c->bw = 0;
|
||||
wlr_scene_node_raise_to_top(&c->scene->node); // 将视图提升到顶层
|
||||
@@ -4834,7 +4852,7 @@ void show_hide_client(Client *c) {
|
||||
c->tags = c->oldtags;
|
||||
arrange(c->mon, false);
|
||||
}
|
||||
c->isminied = 0;
|
||||
c->isminimized = 0;
|
||||
wlr_foreign_toplevel_handle_v1_set_minimized(c->foreign_toplevel, false);
|
||||
focusclient(c, 1);
|
||||
wlr_foreign_toplevel_handle_v1_set_activated(c->foreign_toplevel, true);
|
||||
@@ -5323,7 +5341,7 @@ void unmapnotify(struct wl_listener *listener, void *data) {
|
||||
Monitor *m = NULL;
|
||||
c->iskilling = 1;
|
||||
|
||||
if (animations && !c->is_clip_to_hide && !c->isminied &&
|
||||
if (animations && !c->is_clip_to_hide && !c->isminimized &&
|
||||
(!c->mon || VISIBLEON(c, c->mon)))
|
||||
init_fadeout_client(c);
|
||||
|
||||
@@ -5734,8 +5752,8 @@ void activatex11(struct wl_listener *listener, void *data) {
|
||||
if (c && c->swallowing)
|
||||
return;
|
||||
|
||||
if (c->isminied) {
|
||||
c->isminied = 0;
|
||||
if (c->isminimized) {
|
||||
c->isminimized = 0;
|
||||
c->tags = c->mini_restore_tag;
|
||||
c->is_scratchpad_show = 0;
|
||||
c->is_in_scratchpad = 0;
|
||||
@@ -5802,6 +5820,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