mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-29 21:37:42 -04:00
feat: manual split
This commit is contained in:
parent
2723e50a90
commit
d9b906d276
7 changed files with 382 additions and 54 deletions
|
|
@ -1,3 +1,4 @@
|
|||
#include "wlr/util/log.h"
|
||||
void client_actual_size(Client *c, int32_t *width, int32_t *height) {
|
||||
*width = c->animation.current.width - 2 * (int32_t)c->bw;
|
||||
|
||||
|
|
@ -245,6 +246,94 @@ void apply_shield(Client *c, struct wlr_box clip_box) {
|
|||
}
|
||||
}
|
||||
|
||||
void apply_split_border(Client *c, bool hit_no_border) {
|
||||
|
||||
if (c->iskilling || !client_surface(c)->mapped)
|
||||
return;
|
||||
|
||||
const Layout *layout = c->mon->pertag->ltidxs[c->mon->pertag->curtag];
|
||||
|
||||
if (hit_no_border || layout->id != DWINDLE ||
|
||||
!config.dwindle_manual_split) {
|
||||
if (c->splitindicator[0]->node.enabled) {
|
||||
wlr_scene_node_set_enabled(&c->splitindicator[0]->node, false);
|
||||
}
|
||||
if (c->splitindicator[1]->node.enabled) {
|
||||
wlr_scene_node_set_enabled(&c->splitindicator[1]->node, false);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
|
||||
DwindleNode **root =
|
||||
&c->mon->pertag->dwindle_root[c->mon->pertag->curtag];
|
||||
DwindleNode *dnode = dwindle_find_leaf(*root, c);
|
||||
|
||||
if (!dnode) {
|
||||
wlr_scene_node_set_enabled(&c->splitindicator[0]->node, false);
|
||||
wlr_scene_node_set_enabled(&c->splitindicator[1]->node, false);
|
||||
return;
|
||||
} else {
|
||||
if (dnode->custom_leaf_split_h) {
|
||||
wlr_scene_node_set_enabled(&c->splitindicator[0]->node, false);
|
||||
wlr_scene_node_set_enabled(&c->splitindicator[1]->node, true);
|
||||
} else {
|
||||
wlr_scene_node_set_enabled(&c->splitindicator[0]->node, true);
|
||||
wlr_scene_node_set_enabled(&c->splitindicator[1]->node, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct wlr_box fullgeom = c->animation.current;
|
||||
// 一但在GEZERO如果使用无符号,那么其他数据也会转换为无符号导致没有负数出错
|
||||
int32_t bw = (int32_t)c->bw;
|
||||
|
||||
int32_t right_offset, bottom_offset, left_offset, top_offset;
|
||||
|
||||
if (c == grabc) {
|
||||
right_offset = 0;
|
||||
bottom_offset = 0;
|
||||
left_offset = 0;
|
||||
top_offset = 0;
|
||||
} else {
|
||||
right_offset =
|
||||
GEZERO(c->animation.current.x + c->animation.current.width -
|
||||
c->mon->m.x - c->mon->m.width);
|
||||
bottom_offset =
|
||||
GEZERO(c->animation.current.y + c->animation.current.height -
|
||||
c->mon->m.y - c->mon->m.height);
|
||||
|
||||
left_offset = GEZERO(c->mon->m.x - c->animation.current.x);
|
||||
top_offset = GEZERO(c->mon->m.y - c->animation.current.y);
|
||||
}
|
||||
|
||||
int32_t border_down_width = GEZERO(fullgeom.width - left_offset -
|
||||
right_offset - 2 * config.border_radius);
|
||||
int32_t border_down_height =
|
||||
GEZERO(bw - bottom_offset - GEZERO(top_offset + bw - fullgeom.height));
|
||||
|
||||
int32_t border_right_width =
|
||||
GEZERO(bw - right_offset - GEZERO(left_offset + bw - fullgeom.width));
|
||||
int32_t border_right_height =
|
||||
GEZERO(fullgeom.height - top_offset - bottom_offset -
|
||||
2 * config.border_radius);
|
||||
|
||||
int32_t border_down_x = GEZERO(config.border_radius - left_offset);
|
||||
int32_t border_down_y = GEZERO(fullgeom.height - bw) +
|
||||
GEZERO(top_offset + bw - fullgeom.height);
|
||||
|
||||
int32_t border_right_x =
|
||||
GEZERO(fullgeom.width - bw) + GEZERO(left_offset + bw - fullgeom.width);
|
||||
int32_t border_right_y = GEZERO(config.border_radius - top_offset);
|
||||
|
||||
set_rect_size(c->splitindicator[0], border_down_width, border_down_height);
|
||||
set_rect_size(c->splitindicator[1], border_right_width,
|
||||
border_right_height);
|
||||
wlr_scene_node_set_position(&c->splitindicator[0]->node, border_down_x,
|
||||
border_down_y);
|
||||
wlr_scene_node_set_position(&c->splitindicator[1]->node, border_right_x,
|
||||
border_right_y);
|
||||
}
|
||||
|
||||
void apply_border(Client *c) {
|
||||
bool hit_no_border = false;
|
||||
|
||||
|
|
@ -253,6 +342,8 @@ void apply_border(Client *c) {
|
|||
|
||||
hit_no_border = check_hit_no_border(c);
|
||||
|
||||
apply_split_border(c, hit_no_border);
|
||||
|
||||
if (hit_no_border && config.smartgaps) {
|
||||
c->bw = 0;
|
||||
c->fake_no_border = true;
|
||||
|
|
@ -1100,6 +1191,7 @@ bool client_draw_fadeout_frame(Client *c) {
|
|||
|
||||
void client_set_focused_opacity_animation(Client *c) {
|
||||
float *border_color = get_border_color(c);
|
||||
wlr_scene_node_lower_to_bottom(&c->border->node);
|
||||
|
||||
if (!config.animations) {
|
||||
setborder_color(c);
|
||||
|
|
@ -1121,7 +1213,7 @@ void client_set_focused_opacity_animation(Client *c) {
|
|||
|
||||
void client_set_unfocused_opacity_animation(Client *c) {
|
||||
float *border_color = get_border_color(c);
|
||||
|
||||
wlr_scene_node_raise_to_top(&c->border->node);
|
||||
if (!config.animations) {
|
||||
setborder_color(c);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue