mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-06-19 14:33:16 -04:00
feat: add shield_when_capture windowrule
This commit is contained in:
parent
3b535d4005
commit
d11bc63802
3 changed files with 99 additions and 0 deletions
72
src/mango.c
72
src/mango.c
|
|
@ -316,6 +316,7 @@ struct Client {
|
|||
struct wlr_scene_tree *scene;
|
||||
struct wlr_scene_rect *border; /* top, bottom, left, right */
|
||||
struct wlr_scene_shadow *shadow;
|
||||
struct wlr_scene_rect *shield;
|
||||
struct wlr_scene_blur *blur;
|
||||
struct wlr_scene_tree *scene_surface;
|
||||
struct wlr_scene_tree *image_capture_tree;
|
||||
|
|
@ -386,6 +387,7 @@ struct Client {
|
|||
int32_t iskilling;
|
||||
int32_t istagswitching;
|
||||
int32_t isnamedscratchpad;
|
||||
int32_t shield_when_capture;
|
||||
bool is_pending_open_animation;
|
||||
bool is_restoring_from_ov;
|
||||
float scroller_proportion;
|
||||
|
|
@ -548,6 +550,11 @@ typedef struct {
|
|||
struct wl_listener destroy;
|
||||
} SessionLock;
|
||||
|
||||
struct capture_session_tracker {
|
||||
struct wl_listener session_destroy;
|
||||
struct wlr_ext_image_copy_capture_session_v1 *session;
|
||||
};
|
||||
|
||||
/* function declarations */
|
||||
static void applybounds(
|
||||
Client *c,
|
||||
|
|
@ -691,6 +698,8 @@ static void virtualpointer(struct wl_listener *listener, void *data);
|
|||
static void warp_cursor(const Client *c);
|
||||
static Monitor *xytomon(double x, double y);
|
||||
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);
|
||||
static void clear_fullscreen_flag(Client *c);
|
||||
|
|
@ -827,6 +836,7 @@ static struct wlr_keyboard_shortcuts_inhibit_manager_v1
|
|||
*keyboard_shortcuts_inhibit;
|
||||
static struct wlr_virtual_pointer_manager_v1 *virtual_pointer_mgr;
|
||||
static struct wlr_output_power_manager_v1 *power_mgr;
|
||||
static struct wlr_ext_image_copy_capture_manager_v1 *ext_image_copy_capture_mgr;
|
||||
static struct wlr_pointer_gestures_v1 *pointer_gestures;
|
||||
static struct wlr_drm_lease_v1_manager *drm_lease_manager;
|
||||
struct mango_print_status_manager *print_status_manager;
|
||||
|
|
@ -896,6 +906,7 @@ static struct wl_event_source *hide_source;
|
|||
static bool cursor_hidden = false;
|
||||
static bool tag_combo = false;
|
||||
static const char *cli_config_path = NULL;
|
||||
static int active_capture_count = 0;
|
||||
static KeyMode keymode = {
|
||||
.mode = {'d', 'e', 'f', 'a', 'u', 'l', 't', '\0'},
|
||||
.isdefault = true,
|
||||
|
|
@ -946,6 +957,8 @@ static struct wl_listener output_mgr_apply = {.notify = outputmgrapply};
|
|||
static struct wl_listener output_mgr_test = {.notify = outputmgrtest};
|
||||
static struct wl_listener output_power_mgr_set_mode = {.notify =
|
||||
powermgrsetmode};
|
||||
static struct wl_listener ext_image_copy_capture_mgr_new_session = {
|
||||
.notify = handle_iamge_copy_capture_new_session};
|
||||
static struct wl_listener request_activate = {.notify = urgent};
|
||||
static struct wl_listener request_cursor = {.notify = setcursor};
|
||||
static struct wl_listener request_set_psel = {.notify = setpsel};
|
||||
|
|
@ -1319,6 +1332,7 @@ static void apply_rule_properties(Client *c, const ConfigWinRule *r) {
|
|||
APPLY_INT_PROP(c, r, isnamedscratchpad);
|
||||
APPLY_INT_PROP(c, r, isglobal);
|
||||
APPLY_INT_PROP(c, r, isoverlay);
|
||||
APPLY_INT_PROP(c, r, shield_when_capture);
|
||||
APPLY_INT_PROP(c, r, ignore_maximize);
|
||||
APPLY_INT_PROP(c, r, ignore_minimize);
|
||||
APPLY_INT_PROP(c, r, isnosizehint);
|
||||
|
|
@ -3997,6 +4011,12 @@ mapnotify(struct wl_listener *listener, void *data) {
|
|||
wlr_scene_node_lower_to_bottom(&c->shadow->node);
|
||||
wlr_scene_node_set_enabled(&c->shadow->node, true);
|
||||
|
||||
c->shield = wlr_scene_rect_create(c->scene_surface, 0, 0,
|
||||
(float[4]){0, 0, 0, 0xff});
|
||||
c->shield->node.data = c;
|
||||
wlr_scene_node_lower_to_bottom(&c->shield->node);
|
||||
wlr_scene_node_set_enabled(&c->shield->node, false);
|
||||
|
||||
if (new_is_master && selmon && !is_scroller_layout(selmon))
|
||||
// tile at the top
|
||||
wl_list_insert(&clients, &c->link); // 新窗口是master,头部入栈
|
||||
|
|
@ -4425,6 +4445,53 @@ void pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
|
|||
// 修改printstatus函数,接受掩码参数
|
||||
void printstatus(void) { wl_signal_emit(&mango_print_status, NULL); }
|
||||
|
||||
// 会话销毁时的回调
|
||||
void handle_session_destroy(struct wl_listener *listener, void *data) {
|
||||
struct capture_session_tracker *tracker =
|
||||
wl_container_of(listener, tracker, session_destroy);
|
||||
active_capture_count--;
|
||||
wl_list_remove(&tracker->session_destroy.link);
|
||||
|
||||
Client *c = NULL;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (c->shield_when_capture && !c->iskilling && VISIBLEON(c, c->mon)) {
|
||||
arrange(c->mon, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
wlr_log(WLR_DEBUG, "Capture session ended, active count: %d",
|
||||
active_capture_count);
|
||||
free(tracker);
|
||||
}
|
||||
|
||||
// 新会话创建时的回调
|
||||
void handle_iamge_copy_capture_new_session(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct wlr_ext_image_copy_capture_session_v1 *session = data;
|
||||
|
||||
struct capture_session_tracker *tracker = calloc(1, sizeof(*tracker));
|
||||
if (!tracker) {
|
||||
wlr_log(WLR_ERROR, "Failed to allocate capture session tracker");
|
||||
return;
|
||||
}
|
||||
tracker->session = session;
|
||||
tracker->session_destroy.notify = handle_session_destroy;
|
||||
// 监听会话的 destroy 信号,以便在会话结束时减少计数
|
||||
wl_signal_add(&session->events.destroy, &tracker->session_destroy);
|
||||
|
||||
active_capture_count++;
|
||||
|
||||
Client *c = NULL;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (c->shield_when_capture && !c->iskilling && VISIBLEON(c, c->mon)) {
|
||||
arrange(c->mon, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
wlr_log(WLR_DEBUG, "New capture session started, active count: %d",
|
||||
active_capture_count);
|
||||
}
|
||||
|
||||
void powermgrsetmode(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output_power_v1_set_mode_event *event = data;
|
||||
struct wlr_output_state state = {0};
|
||||
|
|
@ -5338,6 +5405,11 @@ void setup(void) {
|
|||
wl_signal_init(&mango_print_status);
|
||||
wl_signal_add(&mango_print_status, &print_status_listener);
|
||||
|
||||
ext_image_copy_capture_mgr =
|
||||
wlr_ext_image_copy_capture_manager_v1_create(dpy, 1);
|
||||
wl_signal_add(&ext_image_copy_capture_mgr->events.new_session,
|
||||
&ext_image_copy_capture_mgr_new_session);
|
||||
|
||||
/* Initializes the interface used to implement urgency hints */
|
||||
activation = wlr_xdg_activation_v1_create(dpy);
|
||||
wl_signal_add(&activation->events.request_activate, &request_activate);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue