mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-07-04 00:07:04 -04:00
feat: shield for layershell
This commit is contained in:
parent
186259cf44
commit
a55c10f005
4 changed files with 71 additions and 15 deletions
|
|
@ -1,13 +1,11 @@
|
||||||
void layer_actual_size(LayerSurface *l, int32_t *width, int32_t *height) {
|
void layer_actual_size(LayerSurface *l, int32_t *width, int32_t *height) {
|
||||||
struct wlr_box box;
|
|
||||||
|
|
||||||
if (l->animation.running) {
|
if (l->animation.running) {
|
||||||
*width = l->animation.current.width;
|
*width = l->animation.current.width;
|
||||||
*height = l->animation.current.height;
|
*height = l->animation.current.height;
|
||||||
} else {
|
} else {
|
||||||
get_layer_target_geometry(l, &box);
|
*width = l->geom.width;
|
||||||
*width = box.width;
|
*height = l->geom.height;
|
||||||
*height = box.height;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -151,6 +149,34 @@ void set_layer_dir_animaiton(LayerSurface *l, struct wlr_box *geo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void layer_draw_shield(LayerSurface *l) {
|
||||||
|
int32_t width, height;
|
||||||
|
|
||||||
|
if (!l->mapped)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (active_capture_count > 0 && l->shield_when_capture) {
|
||||||
|
|
||||||
|
layer_actual_size(l, &width, &height);
|
||||||
|
|
||||||
|
if (width <= 0 || height <= 0) {
|
||||||
|
wlr_scene_node_set_enabled(&l->shield->node, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_scene_node_raise_to_top(&l->shield->node);
|
||||||
|
wlr_scene_node_set_position(&l->shield->node, 0, 0);
|
||||||
|
wlr_scene_rect_set_size(l->shield, width, height);
|
||||||
|
wlr_scene_node_set_enabled(&l->shield->node, true);
|
||||||
|
} else {
|
||||||
|
if (l->shield->node.enabled) {
|
||||||
|
wlr_scene_node_lower_to_bottom(&l->shield->node);
|
||||||
|
wlr_scene_node_set_position(&l->shield->node, 0, 0);
|
||||||
|
wlr_scene_node_set_enabled(&l->shield->node, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void layer_draw_shadow(LayerSurface *l) {
|
void layer_draw_shadow(LayerSurface *l) {
|
||||||
|
|
||||||
if (!l->mapped || !l->shadow)
|
if (!l->mapped || !l->shadow)
|
||||||
|
|
@ -575,8 +601,10 @@ bool layer_draw_frame(LayerSurface *l) {
|
||||||
if (config.animations && config.layer_animations && l->animation.running &&
|
if (config.animations && config.layer_animations && l->animation.running &&
|
||||||
!l->noanim) {
|
!l->noanim) {
|
||||||
layer_animation_next_tick(l);
|
layer_animation_next_tick(l);
|
||||||
|
layer_draw_shield(l);
|
||||||
layer_draw_shadow(l);
|
layer_draw_shadow(l);
|
||||||
} else {
|
} else {
|
||||||
|
layer_draw_shield(l);
|
||||||
layer_draw_shadow(l);
|
layer_draw_shadow(l);
|
||||||
l->need_output_flush = false;
|
l->need_output_flush = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -188,6 +188,7 @@ typedef struct {
|
||||||
char *layer_name; // 布局名称
|
char *layer_name; // 布局名称
|
||||||
char *animation_type_open;
|
char *animation_type_open;
|
||||||
char *animation_type_close;
|
char *animation_type_close;
|
||||||
|
int32_t shield_when_capture;
|
||||||
int32_t noblur;
|
int32_t noblur;
|
||||||
int32_t noanim;
|
int32_t noanim;
|
||||||
int32_t noshadow;
|
int32_t noshadow;
|
||||||
|
|
@ -2310,6 +2311,7 @@ bool parse_option(Config *config, char *key, char *value) {
|
||||||
rule->layer_name = NULL;
|
rule->layer_name = NULL;
|
||||||
rule->animation_type_open = NULL;
|
rule->animation_type_open = NULL;
|
||||||
rule->animation_type_close = NULL;
|
rule->animation_type_close = NULL;
|
||||||
|
rule->shield_when_capture = 0;
|
||||||
rule->noblur = 0;
|
rule->noblur = 0;
|
||||||
rule->noanim = 0;
|
rule->noanim = 0;
|
||||||
rule->noshadow = 0;
|
rule->noshadow = 0;
|
||||||
|
|
@ -2332,6 +2334,8 @@ bool parse_option(Config *config, char *key, char *value) {
|
||||||
rule->animation_type_open = strdup(val);
|
rule->animation_type_open = strdup(val);
|
||||||
} else if (strcmp(key, "animation_type_close") == 0) {
|
} else if (strcmp(key, "animation_type_close") == 0) {
|
||||||
rule->animation_type_close = strdup(val);
|
rule->animation_type_close = strdup(val);
|
||||||
|
} else if (strcmp(key, "shield_when_capture") == 0) {
|
||||||
|
rule->shield_when_capture = CLAMP_INT(atoi(val), 0, 1);
|
||||||
} else if (strcmp(key, "noblur") == 0) {
|
} else if (strcmp(key, "noblur") == 0) {
|
||||||
rule->noblur = CLAMP_INT(atoi(val), 0, 1);
|
rule->noblur = CLAMP_INT(atoi(val), 0, 1);
|
||||||
} else if (strcmp(key, "noanim") == 0) {
|
} else if (strcmp(key, "noanim") == 0) {
|
||||||
|
|
|
||||||
|
|
@ -160,9 +160,13 @@ void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node->type == WLR_SCENE_NODE_RECT) {
|
if (node->type == WLR_SCENE_NODE_RECT) {
|
||||||
if (c) {
|
if (c && (c->type == XDGShell || c->type == X11)) {
|
||||||
surface = client_surface(c);
|
surface = client_surface(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (l && l->type == LayerShell) {
|
||||||
|
surface = l->layer_surface->surface;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
40
src/mango.c
40
src/mango.c
|
|
@ -522,6 +522,7 @@ typedef struct {
|
||||||
Monitor *mon;
|
Monitor *mon;
|
||||||
struct wlr_scene_tree *scene;
|
struct wlr_scene_tree *scene;
|
||||||
struct wlr_scene_tree *popups;
|
struct wlr_scene_tree *popups;
|
||||||
|
struct wlr_scene_rect *shield;
|
||||||
struct wlr_scene_shadow *shadow;
|
struct wlr_scene_shadow *shadow;
|
||||||
struct wlr_scene_blur *blur;
|
struct wlr_scene_blur *blur;
|
||||||
struct wlr_scene_layer_surface_v1 *scene_layer;
|
struct wlr_scene_layer_surface_v1 *scene_layer;
|
||||||
|
|
@ -542,6 +543,7 @@ typedef struct {
|
||||||
int32_t noshadow;
|
int32_t noshadow;
|
||||||
char *animation_type_open;
|
char *animation_type_open;
|
||||||
char *animation_type_close;
|
char *animation_type_close;
|
||||||
|
bool shield_when_capture;
|
||||||
bool need_output_flush;
|
bool need_output_flush;
|
||||||
bool being_unmapped;
|
bool being_unmapped;
|
||||||
} LayerSurface;
|
} LayerSurface;
|
||||||
|
|
@ -2808,6 +2810,7 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
l->noanim = 0;
|
l->noanim = 0;
|
||||||
l->dirty = false;
|
l->dirty = false;
|
||||||
|
l->shield_when_capture = false;
|
||||||
l->noblur = 0;
|
l->noblur = 0;
|
||||||
l->shadow = NULL;
|
l->shadow = NULL;
|
||||||
l->need_output_flush = true;
|
l->need_output_flush = true;
|
||||||
|
|
@ -2820,6 +2823,7 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) {
|
||||||
l->layer_surface->namespace)) {
|
l->layer_surface->namespace)) {
|
||||||
|
|
||||||
r = &config.layer_rules[ji];
|
r = &config.layer_rules[ji];
|
||||||
|
APPLY_INT_PROP(l, r, shield_when_capture);
|
||||||
APPLY_INT_PROP(l, r, noblur);
|
APPLY_INT_PROP(l, r, noblur);
|
||||||
APPLY_INT_PROP(l, r, noanim);
|
APPLY_INT_PROP(l, r, noanim);
|
||||||
APPLY_INT_PROP(l, r, noshadow);
|
APPLY_INT_PROP(l, r, noshadow);
|
||||||
|
|
@ -2828,6 +2832,13 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化屏蔽
|
||||||
|
l->shield =
|
||||||
|
wlr_scene_rect_create(l->scene, 0, 0, (float[4]){0, 0, 0, 0xff});
|
||||||
|
l->shield->node.data = l;
|
||||||
|
wlr_scene_node_lower_to_bottom(&l->shield->node);
|
||||||
|
wlr_scene_node_set_enabled(&l->shield->node, false);
|
||||||
|
|
||||||
// 初始化阴影
|
// 初始化阴影
|
||||||
if (layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM &&
|
if (layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM &&
|
||||||
layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) {
|
layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) {
|
||||||
|
|
@ -2848,6 +2859,9 @@ void maplayersurfacenotify(struct wl_listener *listener, void *data) {
|
||||||
l->animation.duration = config.animation_duration_open;
|
l->animation.duration = config.animation_duration_open;
|
||||||
l->animation.action = OPEN;
|
l->animation.action = OPEN;
|
||||||
layer_set_pending_state(l);
|
layer_set_pending_state(l);
|
||||||
|
} else {
|
||||||
|
l->animainit_geom = l->animation.current = l->current = l->pending =
|
||||||
|
l->geom;
|
||||||
}
|
}
|
||||||
// 刷新布局,让窗口能感应到exclude_zone变化以及设置独占表面
|
// 刷新布局,让窗口能感应到exclude_zone变化以及设置独占表面
|
||||||
arrangelayers(l->mon);
|
arrangelayers(l->mon);
|
||||||
|
|
@ -2891,20 +2905,26 @@ void commitlayersurfacenotify(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
get_layer_target_geometry(l, &box);
|
get_layer_target_geometry(l, &box);
|
||||||
|
|
||||||
if (config.animations && config.layer_animations && !l->noanim &&
|
if (!wlr_box_equal(&box, &l->geom)) {
|
||||||
l->mapped &&
|
|
||||||
layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM &&
|
|
||||||
layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND &&
|
|
||||||
!wlr_box_equal(&box, &l->geom)) {
|
|
||||||
|
|
||||||
l->geom.x = box.x;
|
l->geom.x = box.x;
|
||||||
l->geom.y = box.y;
|
l->geom.y = box.y;
|
||||||
l->geom.width = box.width;
|
l->geom.width = box.width;
|
||||||
l->geom.height = box.height;
|
l->geom.height = box.height;
|
||||||
l->animation.action = MOVE;
|
|
||||||
l->animation.duration = config.animation_duration_move;
|
if (config.animations && config.layer_animations && !l->noanim &&
|
||||||
l->need_output_flush = true;
|
l->mapped &&
|
||||||
layer_set_pending_state(l);
|
layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM &&
|
||||||
|
layer_surface->current.layer !=
|
||||||
|
ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) {
|
||||||
|
l->animation.action = MOVE;
|
||||||
|
l->animation.duration = config.animation_duration_move;
|
||||||
|
l->need_output_flush = true;
|
||||||
|
layer_set_pending_state(l);
|
||||||
|
} else {
|
||||||
|
l->animainit_geom = l->animation.current = l->current = l->pending =
|
||||||
|
l->geom;
|
||||||
|
l->need_output_flush = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.blur && config.blur_layer) {
|
if (config.blur && config.blur_layer) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue