opt: make groupbar same layer with its client

This commit is contained in:
DreamMaoMao 2026-06-22 09:31:23 +08:00
parent 060b0a0c7d
commit 06eed8cd2e
7 changed files with 48 additions and 42 deletions

View file

@ -121,12 +121,17 @@ void client_add_tab_bar_node(Client *c) {
return;
}
MangoNodeData *mangonodedata = ecalloc(1, sizeof(MangoNodeData));
mangonodedata->node_data = c;
mangonodedata->type = MANGO_TITLE_NODE;
MangoCustomDecorate *MangoCustomDecorate =
ecalloc(1, sizeof(MangoCustomDecorate));
MangoCustomDecorate->node_data = c;
MangoCustomDecorate->node_type = MANGO_TITLE_NODE;
MangoCustomDecorate->type = CustomDecorate;
uint32_t layer = c->isfloating || c->isfullscreen ? LyrTop
: c->ismaximizescreen ? LyrMaximize
: LyrTile;
c->tab_bar_node = mango_tab_bar_node_create(
mangonodedata, layers[LyrDecorate], config.tabdata, 0, 0);
MangoCustomDecorate, layers[layer], config.tabdata, 0, 0);
wlr_scene_node_lower_to_bottom(&c->tab_bar_node->scene_buffer->node);
wlr_scene_node_set_enabled(&c->tab_bar_node->scene_buffer->node, false);
mango_tab_bar_node_update(c->tab_bar_node, client_get_title(c), 1.0);
@ -224,10 +229,9 @@ void client_reparent_group(Client *c) {
if (!c->group_prev && !c->group_next)
return;
int32_t bar_layer = c->isfloating ? LyrDecorateTop : LyrDecorate;
int32_t client_layer = c->isfloating || c->isfullscreen ? LyrTop
: c->ismaximizescreen ? LyrMaximize
: LyrTile;
int32_t layer = c->isfloating || c->isfullscreen ? LyrTop
: c->ismaximizescreen ? LyrMaximize
: LyrTile;
Client *head = c;
while (head->group_prev)
@ -237,28 +241,20 @@ void client_reparent_group(Client *c) {
while (cur) {
if (cur->tab_bar_node) {
wlr_scene_node_reparent(&cur->tab_bar_node->scene_buffer->node,
layers[bar_layer]);
wlr_scene_node_reparent(&cur->scene->node, layers[client_layer]);
layers[layer]);
wlr_scene_node_reparent(&cur->scene->node, layers[layer]);
}
cur = cur->group_next;
}
}
void client_handle_decorate_click(int32_t x, int32_t y) {
struct wlr_scene_node *node =
wlr_scene_node_at(&layers[LyrDecorateTop]->node, x, y, NULL, NULL);
void client_handle_decorate_click(MangoCustomDecorate *md) {
if (!node || !node->data) {
node = wlr_scene_node_at(&layers[LyrDecorate]->node, x, y, NULL, NULL);
}
if (!node || !node->data) {
if (!md)
return;
}
MangoNodeData *mangonodedata = (MangoNodeData *)node->data;
if (mangonodedata->type == MANGO_TITLE_NODE) {
Client *c = mangonodedata->node_data;
if (md->node_type == MANGO_TITLE_NODE) {
Client *c = md->node_data;
client_focus_group_member(c);
}
}

View file

@ -252,11 +252,13 @@ void scene_buffer_apply_overview_effect(struct wlr_scene_buffer *buffer,
bool is_subsurface = false;
struct wlr_scene_tree *parent_tree = buffer->node.parent;
if (parent_tree->node.data != NULL) {
SnapshotMetadata *meta = (SnapshotMetadata *)parent_tree->node.data;
SnapshotMetadata *meta = (SnapshotMetadata *)parent_tree->node.data;
if (parent_tree->node.data != NULL && meta->type == Snapshot) {
surface_width = meta->orig_width;
surface_height = meta->orig_height;
is_subsurface = meta->is_subsurface;
} else {
return;
}
surface_height = surface_height * buffer_data->height_scale;
@ -1228,7 +1230,7 @@ void client_animation_next_tick(Client *c) {
c->animation.current = c->geom;
}
xytonode(cursor->x, cursor->y, NULL, &pointer_c, NULL, &sx, &sy);
xytonode(cursor->x, cursor->y, NULL, &pointer_c, NULL, NULL, &sx, &sy);
surface =
pointer_c && pointer_c == c ? client_surface(pointer_c) : NULL;

View file

@ -175,6 +175,7 @@ static bool scene_node_snapshot(struct wlr_scene_node *node, int32_t lx,
}
meta->orig_width = scene_buffer->dst_width;
meta->orig_height = scene_buffer->dst_height;
meta->type = Snapshot;
struct wlr_scene_surface *scene_surface =
wlr_scene_surface_try_from_buffer(scene_buffer);

View file

@ -471,7 +471,7 @@ int32_t moveresize(const Arg *arg) {
if (cursor_mode != CurNormal && cursor_mode != CurPressed)
return 0;
xytonode(cursor->x, cursor->y, NULL, &grabc, NULL, NULL, NULL);
xytonode(cursor->x, cursor->y, NULL, &grabc, NULL, NULL, NULL, NULL);
if (!grabc || client_is_unmanaged(grabc) || grabc->isfullscreen ||
grabc->ismaximizescreen) {
grabc = NULL;

View file

@ -281,7 +281,7 @@ void tablettoolmotion(struct TabletTool *tool, bool change_x, bool change_y,
if (config.sloppyfocus)
selmon = xytomon(cursor->x, cursor->y);
xytonode(cursor->x, cursor->y, &surface, &c, NULL, &sx, &sy);
xytonode(cursor->x, cursor->y, &surface, &c, NULL, NULL, &sx, &sy);
if (cursor_mode == CurPressed && !seat->drag &&
surface != seat->pointer_state.focused_surface &&
toplevel_from_wlr_surface(seat->pointer_state.focused_surface, &w,

View file

@ -100,11 +100,13 @@ static bool layer_ignores_focus(LayerSurface *l) {
}
void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
LayerSurface **pl, double *nx, double *ny) {
LayerSurface **pl, MangoCustomDecorate **pd, double *nx,
double *ny) {
struct wlr_scene_node *node, *pnode;
struct wlr_surface *surface = NULL;
Client *c = NULL;
LayerSurface *l = NULL;
MangoCustomDecorate *mangocustomdecorate = NULL;
int32_t layer;
Client *ovc = NULL;
@ -125,8 +127,6 @@ void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
wlr_scene_buffer_from_node(node));
if (scene_surface) {
surface = scene_surface->surface;
} else {
continue;
}
}
@ -142,6 +142,9 @@ void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
if (c && c->type == LayerShell) {
l = (LayerSurface *)c;
c = NULL;
} else if (c && c->type == CustomDecorate) {
mangocustomdecorate = (MangoCustomDecorate *)c;
c = NULL;
}
}
@ -159,6 +162,8 @@ void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
*pc = c;
if (pl)
*pl = l;
if (pd)
*pd = mangocustomdecorate;
if (selmon && selmon->isoverview && config.ov_no_resize) {
ovc = xytoclient(x, y);

View file

@ -165,17 +165,15 @@ enum { TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT };
enum { VERTICAL, HORIZONTAL };
enum { SWIPE_UP, SWIPE_DOWN, SWIPE_LEFT, SWIPE_RIGHT };
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
enum { XDGShell, LayerShell, X11 }; /* client types */
enum { AxisUp, AxisDown, AxisLeft, AxisRight }; // 滚轮滚动的方向
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
enum { XDGShell, LayerShell, X11, CustomDecorate, Snapshot }; /* client types */
enum { AxisUp, AxisDown, AxisLeft, AxisRight }; // 滚轮滚动的方向
enum {
LyrBg,
LyrBlur,
LyrBottom,
LyrTile,
LyrDecorate,
LyrMaximize,
LyrDecorateTop,
LyrTop,
LyrFadeOut,
LyrOverlay,
@ -184,7 +182,7 @@ enum {
NUM_LAYERS
}; /* scene layers */
enum mango_node_type { MANGO_TITLE_NODE, MANGO_jump_label_node };
enum mango_node_type { MANGO_TITLE_NODE, MANGO_JUMP_NODE };
#ifdef XWAYLAND
enum {
@ -253,9 +251,10 @@ typedef struct {
} Arg;
typedef struct {
enum mango_node_type type;
uint32_t type;
enum mango_node_type node_type;
void *node_data;
} MangoNodeData;
} MangoCustomDecorate;
typedef struct {
uint32_t mod;
@ -652,6 +651,7 @@ struct TagScrollerState {
};
typedef struct {
uint32_t type;
int32_t orig_width;
int32_t orig_height;
bool is_subsurface;
@ -805,7 +805,8 @@ static Monitor *get_monitor_nearest_to(int32_t x, int32_t y);
static void handle_iamge_copy_capture_new_session(struct wl_listener *listener,
void *data);
static void xytonode(double x, double y, struct wlr_surface **psurface,
Client **pc, LayerSurface **pl, double *nx, double *ny);
Client **pc, LayerSurface **pl, MangoCustomDecorate **pd,
double *nx, double *ny);
static void clear_fullscreen_flag(Client *c);
static pid_t getparentprocess(pid_t p);
static int32_t isdescprocess(pid_t p, pid_t c);
@ -2435,6 +2436,7 @@ bool handle_buttonpress(struct wlr_pointer_button_event *event) {
uint32_t hard_mods, mods;
Client *c = NULL;
LayerSurface *l = NULL;
MangoCustomDecorate *md = NULL;
struct wlr_surface *surface;
Client *tmpc = NULL;
int32_t ji;
@ -2456,7 +2458,7 @@ bool handle_buttonpress(struct wlr_pointer_button_event *event) {
if (locked)
break;
xytonode(cursor->x, cursor->y, &surface, NULL, NULL, NULL, NULL);
xytonode(cursor->x, cursor->y, &surface, NULL, NULL, &md, NULL, NULL);
if (toplevel_from_wlr_surface(surface, &c, &l) >= 0) {
if (c && c->scene->node.enabled &&
(!client_is_unmanaged(c) || client_wants_focus(c)))
@ -2487,7 +2489,7 @@ bool handle_buttonpress(struct wlr_pointer_button_event *event) {
}
// handle click on tile node
client_handle_decorate_click(cursor->x, cursor->y);
client_handle_decorate_click(md);
// 当鼠标焦点在layer上的时候不检测虚拟键盘的mod状态
// 避免layer虚拟键盘锁死mod按键状态
@ -4951,7 +4953,7 @@ void motionnotify(uint32_t time, struct wlr_input_device *device, double dx,
}
/* Find the client under the pointer and send the event along. */
xytonode(cursor->x, cursor->y, &surface, &c, NULL, &sx, &sy);
xytonode(cursor->x, cursor->y, &surface, &c, NULL, NULL, &sx, &sy);
if (cursor_mode == CurPressed && !seat->drag &&
surface != seat->pointer_state.focused_surface &&