mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-02-22 01:40:22 -05:00
Added nixpup MangoWC build features.
This commit is contained in:
parent
bc1f310e1c
commit
c0abfaefc8
19 changed files with 324 additions and 491 deletions
|
|
@ -1080,6 +1080,26 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
|
|||
} else if (strcmp(func_name, "toggle_monitor") == 0) {
|
||||
func = toggle_monitor;
|
||||
(*arg).v = strdup(arg_value);
|
||||
} else if (strcmp(func_name, "expand_client_left") == 0) {
|
||||
func = expand_client_left;
|
||||
if (arg_value && *arg_value) {
|
||||
(*arg).f = atof(arg_value);
|
||||
} else {
|
||||
(*arg).f = 0.05;
|
||||
}
|
||||
} else if (strcmp(func_name, "collapse_client_right") == 0) {
|
||||
func = collapse_client_right;
|
||||
if (arg_value && *arg_value) {
|
||||
(*arg).f = atof(arg_value);
|
||||
} else {
|
||||
(*arg).f = -0.05;
|
||||
}
|
||||
} else if (strcmp(func_name, "stack_with_left") == 0) {
|
||||
func = stack_with_left;
|
||||
} else if (strcmp(func_name, "unstack") == 0) {
|
||||
func = unstack;
|
||||
} else if (strcmp(func_name, "revert_size") == 0) {
|
||||
func = revert_size;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,4 +68,10 @@ int32_t toggle_trackpad_enable(const Arg *arg);
|
|||
int32_t setoption(const Arg *arg);
|
||||
int32_t disable_monitor(const Arg *arg);
|
||||
int32_t enable_monitor(const Arg *arg);
|
||||
int32_t expand_client_left(const Arg *arg);
|
||||
int32_t collapse_client_right(const Arg *arg);
|
||||
int32_t stack_with_left(const Arg *arg);
|
||||
int32_t unstack(const Arg *arg);
|
||||
int32_t revert_size(const Arg *arg);
|
||||
|
||||
int32_t toggle_monitor(const Arg *arg);
|
||||
|
|
@ -1585,3 +1585,130 @@ int32_t toggle_monitor(const Arg *arg) {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t expand_client_left(const Arg *arg) {
|
||||
Client *c = selmon->sel;
|
||||
if (selmon && c && is_scroller_layout(selmon)) {
|
||||
c->scroller_proportion += arg->f;
|
||||
if (c->scroller_proportion > 1.0)
|
||||
c->scroller_proportion = 1.0;
|
||||
arrange(selmon, false, false);
|
||||
} else {
|
||||
setmfact(arg);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t collapse_client_right(const Arg *arg) {
|
||||
Client *c = selmon->sel;
|
||||
if (selmon && c && is_scroller_layout(selmon)) {
|
||||
c->scroller_proportion += arg->f;
|
||||
if (c->scroller_proportion < 0.1)
|
||||
c->scroller_proportion = 0.1;
|
||||
arrange(selmon, false, false);
|
||||
} else {
|
||||
setmfact(arg);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t stack_with_left(const Arg *arg) {
|
||||
Client *c = selmon->sel;
|
||||
if (!c || c->isfloating || !is_scroller_layout(selmon))
|
||||
return 0;
|
||||
|
||||
Client *left_c = get_next_stack_client(c, true);
|
||||
if (!left_c)
|
||||
return 0;
|
||||
|
||||
// If c is already in a stack, remove it.
|
||||
if (c->prev_in_stack) {
|
||||
c->prev_in_stack->next_in_stack = c->next_in_stack;
|
||||
}
|
||||
if (c->next_in_stack) {
|
||||
c->next_in_stack->prev_in_stack = c->prev_in_stack;
|
||||
}
|
||||
// If c was a stack head, its next client becomes the new head.
|
||||
if (c->next_in_stack) {
|
||||
c->next_in_stack->prev_in_stack = NULL;
|
||||
}
|
||||
|
||||
|
||||
// Find the tail of left_c's stack
|
||||
Client *stack_tail = left_c;
|
||||
while (stack_tail->next_in_stack) {
|
||||
stack_tail = stack_tail->next_in_stack;
|
||||
}
|
||||
|
||||
// Add c to the stack
|
||||
stack_tail->next_in_stack = c;
|
||||
c->prev_in_stack = stack_tail;
|
||||
c->next_in_stack = NULL;
|
||||
|
||||
arrange(selmon, false, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t unstack(const Arg *arg) {
|
||||
Client *c = selmon->sel;
|
||||
if (!c || !c->prev_in_stack) {
|
||||
// Not in a stack or is the head of a stack, do nothing.
|
||||
return 0;
|
||||
}
|
||||
|
||||
Client *stack_head = c;
|
||||
while(stack_head->prev_in_stack) {
|
||||
stack_head = stack_head->prev_in_stack;
|
||||
}
|
||||
|
||||
// Remove c from its current stack
|
||||
if (c->prev_in_stack) {
|
||||
c->prev_in_stack->next_in_stack = c->next_in_stack;
|
||||
}
|
||||
if (c->next_in_stack) {
|
||||
c->next_in_stack->prev_in_stack = c->prev_in_stack;
|
||||
}
|
||||
|
||||
c->next_in_stack = NULL;
|
||||
c->prev_in_stack = NULL;
|
||||
|
||||
// Insert c after the stack it was in
|
||||
wl_list_remove(&c->link);
|
||||
wl_list_insert(&stack_head->link, &c->link);
|
||||
|
||||
focusclient(c, 1);
|
||||
arrange(selmon, false, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t revert_size(const Arg *arg) {
|
||||
Client *c = selmon->sel;
|
||||
if (!c) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Ensure the client is not floating and its size is managed by the layout
|
||||
if (c->isfloating) {
|
||||
setfloating(c, false);
|
||||
}
|
||||
c->iscustomsize = 0; // Let the layout manage its size
|
||||
|
||||
// Explicitly remove the client from any stack it might be in
|
||||
if (c->prev_in_stack) {
|
||||
c->prev_in_stack->next_in_stack = c->next_in_stack;
|
||||
}
|
||||
if (c->next_in_stack) {
|
||||
c->next_in_stack->prev_in_stack = c->prev_in_stack;
|
||||
}
|
||||
c->prev_in_stack = NULL;
|
||||
c->next_in_stack = NULL;
|
||||
|
||||
// Explicitly reset float_geom to ensure arrange recalculates geometry
|
||||
c->float_geom = (struct wlr_box){0};
|
||||
|
||||
// The arrange function will now correctly size and position the window
|
||||
// within the scroller layout, giving it full vertical size and preventing overlaps.
|
||||
arrange(selmon, false, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -627,7 +627,7 @@ arrange(Monitor *m, bool want_animation, bool from_view) {
|
|||
m->visible_tiling_clients++;
|
||||
}
|
||||
|
||||
if (ISSCROLLTILED(c)) {
|
||||
if (ISSCROLLTILED(c) && !c->prev_in_stack) {
|
||||
m->visible_scroll_tiling_clients++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,6 +212,33 @@ void horizontal_scroll_adjust_fullandmax(Client *c,
|
|||
target_geom->y = m->w.y + (m->w.height - target_geom->height) / 2;
|
||||
}
|
||||
|
||||
void arrange_stack(Client *stack_head, struct wlr_box geometry, int32_t gappiv) {
|
||||
int32_t stack_size = 0;
|
||||
Client *iter = stack_head;
|
||||
while (iter) {
|
||||
stack_size++;
|
||||
iter = iter->next_in_stack;
|
||||
}
|
||||
|
||||
if (stack_size == 0) return;
|
||||
|
||||
int32_t client_height = (geometry.height - (stack_size - 1) * gappiv) / stack_size;
|
||||
int32_t current_y = geometry.y;
|
||||
|
||||
iter = stack_head;
|
||||
while (iter) {
|
||||
struct wlr_box client_geom = {
|
||||
.x = geometry.x,
|
||||
.y = current_y,
|
||||
.width = geometry.width,
|
||||
.height = client_height
|
||||
};
|
||||
resize(iter, client_geom, 0);
|
||||
current_y += client_height + gappiv;
|
||||
iter = iter->next_in_stack;
|
||||
}
|
||||
}
|
||||
|
||||
// 滚动布局
|
||||
void scroller(Monitor *m) {
|
||||
int32_t i, n, j;
|
||||
|
|
@ -225,6 +252,8 @@ void scroller(Monitor *m) {
|
|||
int32_t cur_gappih = enablegaps ? m->gappih : 0;
|
||||
int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
|
||||
int32_t cur_gappov = enablegaps ? m->gappov : 0;
|
||||
int32_t cur_gappiv = enablegaps ? m->gappiv : 0;
|
||||
|
||||
|
||||
cur_gappih =
|
||||
smartgaps && m->visible_scroll_tiling_clients == 1 ? 0 : cur_gappih;
|
||||
|
|
@ -251,7 +280,7 @@ void scroller(Monitor *m) {
|
|||
// 第二次遍历,填充 tempClients
|
||||
j = 0;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (VISIBLEON(c, m) && ISSCROLLTILED(c)) {
|
||||
if (VISIBLEON(c, m) && ISSCROLLTILED(c) && !c->prev_in_stack) {
|
||||
tempClients[j] = c;
|
||||
j++;
|
||||
}
|
||||
|
|
@ -269,7 +298,7 @@ void scroller(Monitor *m) {
|
|||
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);
|
||||
arrange_stack(c, target_geom, cur_gappiv);
|
||||
free(tempClients); // 释放内存
|
||||
return;
|
||||
}
|
||||
|
|
@ -283,6 +312,14 @@ void scroller(Monitor *m) {
|
|||
root_client = center_tiled_select(m);
|
||||
}
|
||||
|
||||
// root_client might be in a stack, find the stack head
|
||||
if (root_client) {
|
||||
while(root_client->prev_in_stack) {
|
||||
root_client = root_client->prev_in_stack;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!root_client) {
|
||||
free(tempClients); // 释放内存
|
||||
return;
|
||||
|
|
@ -317,10 +354,10 @@ void scroller(Monitor *m) {
|
|||
&target_geom);
|
||||
if (tempClients[focus_client_index]->isfullscreen) {
|
||||
target_geom.x = m->m.x;
|
||||
resize(tempClients[focus_client_index], target_geom, 0);
|
||||
arrange_stack(tempClients[focus_client_index], target_geom, cur_gappiv);
|
||||
} else if (tempClients[focus_client_index]->ismaximizescreen) {
|
||||
target_geom.x = m->w.x + cur_gappoh;
|
||||
resize(tempClients[focus_client_index], target_geom, 0);
|
||||
arrange_stack(tempClients[focus_client_index], target_geom, cur_gappiv);
|
||||
} else if (need_scroller) {
|
||||
if (scroller_focus_center ||
|
||||
((!m->prevsel ||
|
||||
|
|
@ -338,10 +375,10 @@ void scroller(Monitor *m) {
|
|||
scroller_structs)
|
||||
: m->w.x + scroller_structs;
|
||||
}
|
||||
resize(tempClients[focus_client_index], target_geom, 0);
|
||||
arrange_stack(tempClients[focus_client_index], target_geom, cur_gappiv);
|
||||
} else {
|
||||
target_geom.x = c->geom.x;
|
||||
resize(tempClients[focus_client_index], target_geom, 0);
|
||||
arrange_stack(tempClients[focus_client_index], target_geom, cur_gappiv);
|
||||
}
|
||||
|
||||
for (i = 1; i <= focus_client_index; i++) {
|
||||
|
|
@ -351,7 +388,7 @@ void scroller(Monitor *m) {
|
|||
target_geom.x = tempClients[focus_client_index - i + 1]->geom.x -
|
||||
cur_gappih - target_geom.width;
|
||||
|
||||
resize(c, target_geom, 0);
|
||||
arrange_stack(c, target_geom, cur_gappiv);
|
||||
}
|
||||
|
||||
for (i = 1; i < n - focus_client_index; i++) {
|
||||
|
|
@ -361,7 +398,7 @@ void scroller(Monitor *m) {
|
|||
target_geom.x = tempClients[focus_client_index + i - 1]->geom.x +
|
||||
cur_gappih +
|
||||
tempClients[focus_client_index + i - 1]->geom.width;
|
||||
resize(c, target_geom, 0);
|
||||
arrange_stack(c, target_geom, cur_gappiv);
|
||||
}
|
||||
|
||||
free(tempClients); // 最后释放内存
|
||||
|
|
|
|||
|
|
@ -407,6 +407,8 @@ struct Client {
|
|||
int32_t allow_shortcuts_inhibit;
|
||||
float scroller_proportion_single;
|
||||
bool isfocusing;
|
||||
struct Client *next_in_stack;
|
||||
struct Client *prev_in_stack;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue