fix: dont use evenmask

This commit is contained in:
DreamMaoMao
2025-12-03 17:22:19 +08:00
parent 5c314be8c6
commit e965264f3b
4 changed files with 92 additions and 178 deletions

View File

@@ -3277,6 +3277,6 @@ void reset_option(void) {
int reload_config(const Arg *arg) {
parse_config();
reset_option();
printstatus(PRINT_ALL);
printstatus();
return 0;
}

View File

@@ -503,7 +503,7 @@ int setlayout(const Arg *arg) {
selmon->pertag->ltidxs[selmon->pertag->curtag] = &layouts[jk];
clear_fullscreen_and_maximized_state(selmon);
arrange(selmon, false);
printstatus(PRINT_ALL);
printstatus();
return 0;
}
}
@@ -517,7 +517,7 @@ int setkeymode(const Arg *arg) {
} else {
keymode.isdefault = false;
}
printstatus(PRINT_KEYMODE);
printstatus();
return 1;
}
@@ -866,7 +866,7 @@ int switch_keyboard_layout(const Arg *arg) {
wlr_seat_keyboard_notify_modifiers(seat, &tkb->modifiers);
}
printstatus(PRINT_KB_LAYOUT);
printstatus();
return 0;
}
@@ -907,7 +907,7 @@ int switch_layout(const Arg *arg) {
}
clear_fullscreen_and_maximized_state(selmon);
arrange(selmon, false);
printstatus(PRINT_ALL);
printstatus();
return 0;
}
@@ -918,7 +918,7 @@ int switch_layout(const Arg *arg) {
jk == LENGTH(layouts) - 1 ? &layouts[0] : &layouts[jk + 1];
clear_fullscreen_and_maximized_state(selmon);
arrange(selmon, false);
printstatus(PRINT_ALL);
printstatus();
return 0;
}
}
@@ -1260,7 +1260,7 @@ int toggletag(const Arg *arg) {
focusclient(focustop(selmon), 1);
arrange(selmon, false);
}
printstatus(PRINT_ALL);
printstatus();
return 0;
}
@@ -1278,7 +1278,7 @@ int toggleview(const Arg *arg) {
focusclient(focustop(selmon), 1);
arrange(selmon, false);
}
printstatus(PRINT_ALL);
printstatus();
return 0;
}
@@ -1396,7 +1396,7 @@ int comboview(const Arg *arg) {
view(&(Arg){.ui = newtags}, false);
}
printstatus(PRINT_ALL);
printstatus();
return 0;
}

View File

@@ -9,9 +9,8 @@ static void dwl_ipc_manager_get_output(struct wl_client *client,
static void dwl_ipc_manager_release(struct wl_client *client,
struct wl_resource *resource);
static void dwl_ipc_output_destroy(struct wl_resource *resource);
static void dwl_ipc_output_printstatus(Monitor *monitor, uint32_t event_mask);
static void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output,
uint32_t event_mask);
static void dwl_ipc_output_printstatus(Monitor *monitor);
static void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output);
static void dwl_ipc_output_set_client_tags(struct wl_client *client,
struct wl_resource *resource,
uint32_t and_tags,
@@ -86,7 +85,7 @@ void dwl_ipc_manager_get_output(struct wl_client *client,
wl_resource_set_implementation(output_resource, &dwl_output_implementation,
ipc_output, dwl_ipc_output_destroy);
wl_list_insert(&monitor->dwl_ipc_outputs, &ipc_output->link);
dwl_ipc_output_printstatus_to(ipc_output, PRINT_ALL);
dwl_ipc_output_printstatus_to(ipc_output);
}
void dwl_ipc_manager_release(struct wl_client *client,
@@ -101,15 +100,14 @@ static void dwl_ipc_output_destroy(struct wl_resource *resource) {
}
// 修改IPC输出函数接受掩码参数
void dwl_ipc_output_printstatus(Monitor *monitor, uint32_t event_mask) {
void dwl_ipc_output_printstatus(Monitor *monitor) {
DwlIpcOutput *ipc_output;
wl_list_for_each(ipc_output, &monitor->dwl_ipc_outputs, link)
dwl_ipc_output_printstatus_to(ipc_output, event_mask);
dwl_ipc_output_printstatus_to(ipc_output);
}
// 修改主IPC输出函数根据掩码发送相应事件
void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output,
uint32_t event_mask) {
void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) {
Monitor *monitor = ipc_output->mon;
Client *c = NULL, *focused = NULL;
struct wlr_keyboard *keyboard;
@@ -117,175 +115,103 @@ void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output,
int tagmask, state, numclients, focused_client, tag;
const char *title, *appid, *symbol;
char kb_layout[32];
focused = focustop(monitor);
zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon);
// 只在需要时才获取这些数据
if (event_mask & (PRINT_ACTIVE | PRINT_TAG | PRINT_TITLE | PRINT_APPID |
PRINT_FULLSCREEN | PRINT_FLOATING | PRINT_X | PRINT_Y |
PRINT_WIDTH | PRINT_HEIGHT)) {
focused = focustop(monitor);
}
// 发送活动状态
if (event_mask & PRINT_ACTIVE) {
zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon);
}
// 发送标签状态
if (event_mask & PRINT_TAG) {
for (tag = 0; tag < LENGTH(tags); tag++) {
numclients = state = focused_client = 0;
tagmask = 1 << tag;
if ((tagmask & monitor->tagset[monitor->seltags]) != 0)
state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_ACTIVE;
if (focused) {
wl_list_for_each(c, &clients, link) {
if (c->mon != monitor)
continue;
if (!(c->tags & tagmask))
continue;
if (c == focused)
focused_client = 1;
if (c->isurgent)
state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_URGENT;
numclients++;
}
}
zdwl_ipc_output_v2_send_tag(ipc_output->resource, tag, state,
numclients, focused_client);
for (tag = 0; tag < LENGTH(tags); tag++) {
numclients = state = focused_client = 0;
tagmask = 1 << tag;
if ((tagmask & monitor->tagset[monitor->seltags]) != 0)
state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_ACTIVE;
wl_list_for_each(c, &clients, link) {
if (c->mon != monitor)
continue;
if (!(c->tags & tagmask))
continue;
if (c == focused)
focused_client = 1;
if (c->isurgent)
state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_URGENT;
numclients++;
}
zdwl_ipc_output_v2_send_tag(ipc_output->resource, tag, state,
numclients, focused_client);
}
// 只在需要时才获取标题和应用ID
if (event_mask & (PRINT_TITLE | PRINT_APPID)) {
title = focused ? client_get_title(focused) : "";
appid = focused ? client_get_appid(focused) : "";
title = focused ? client_get_title(focused) : "";
appid = focused ? client_get_appid(focused) : "";
if (monitor->isoverview) {
symbol = overviewlayout.symbol;
} else {
symbol = monitor->pertag->ltidxs[monitor->pertag->curtag]->symbol;
}
// 获取布局符号
if (event_mask & PRINT_LAYOUT_SYMBOL) {
if (monitor->isoverview) {
symbol = overviewlayout.symbol;
} else {
symbol = monitor->pertag->ltidxs[monitor->pertag->curtag]->symbol;
}
}
keyboard = &kb_group->wlr_group->keyboard;
current = xkb_state_serialize_layout(keyboard->xkb_state,
XKB_STATE_LAYOUT_EFFECTIVE);
get_layout_abbr(kb_layout,
xkb_keymap_layout_get_name(keyboard->keymap, current));
// 发送布局索引
if (event_mask & PRINT_LAYOUT) {
zdwl_ipc_output_v2_send_layout(
ipc_output->resource,
monitor->pertag->ltidxs[monitor->pertag->curtag] - layouts);
}
// 发送标题
if (event_mask & PRINT_TITLE) {
zdwl_ipc_output_v2_send_title(ipc_output->resource,
title ? title : broken);
}
// 发送应用ID
if (event_mask & PRINT_APPID) {
zdwl_ipc_output_v2_send_appid(ipc_output->resource,
appid ? appid : broken);
}
// 发送布局符号
if (event_mask & PRINT_LAYOUT_SYMBOL) {
zdwl_ipc_output_v2_send_layout_symbol(ipc_output->resource, symbol);
}
// 发送全屏状态
if ((event_mask & PRINT_FULLSCREEN) &&
wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_FULLSCREEN_SINCE_VERSION) {
zdwl_ipc_output_v2_send_layout(
ipc_output->resource,
monitor->pertag->ltidxs[monitor->pertag->curtag] - layouts);
zdwl_ipc_output_v2_send_title(ipc_output->resource, title ? title : broken);
zdwl_ipc_output_v2_send_appid(ipc_output->resource, appid ? appid : broken);
zdwl_ipc_output_v2_send_layout_symbol(ipc_output->resource, symbol);
if (wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_FULLSCREEN_SINCE_VERSION) {
zdwl_ipc_output_v2_send_fullscreen(ipc_output->resource,
focused ? focused->isfullscreen : 0);
}
// 发送浮动状态
if ((event_mask & PRINT_FLOATING) &&
wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_FLOATING_SINCE_VERSION) {
if (wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_FLOATING_SINCE_VERSION) {
zdwl_ipc_output_v2_send_floating(ipc_output->resource,
focused ? focused->isfloating : 0);
}
// 发送X坐标
if ((event_mask & PRINT_X) &&
wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_X_SINCE_VERSION) {
if (wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_X_SINCE_VERSION) {
zdwl_ipc_output_v2_send_x(ipc_output->resource,
focused ? focused->geom.x : 0);
}
// 发送Y坐标
if ((event_mask & PRINT_Y) &&
wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_Y_SINCE_VERSION) {
if (wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_Y_SINCE_VERSION) {
zdwl_ipc_output_v2_send_y(ipc_output->resource,
focused ? focused->geom.y : 0);
}
// 发送宽度
if ((event_mask & PRINT_WIDTH) &&
wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_WIDTH_SINCE_VERSION) {
if (wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_WIDTH_SINCE_VERSION) {
zdwl_ipc_output_v2_send_width(ipc_output->resource,
focused ? focused->geom.width : 0);
}
// 发送高度
if ((event_mask & PRINT_HEIGHT) &&
wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_HEIGHT_SINCE_VERSION) {
if (wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_HEIGHT_SINCE_VERSION) {
zdwl_ipc_output_v2_send_height(ipc_output->resource,
focused ? focused->geom.height : 0);
}
// 发送最后图层
if ((event_mask & PRINT_LAST_LAYER) &&
wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_LAST_LAYER_SINCE_VERSION) {
if (wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_LAST_LAYER_SINCE_VERSION) {
zdwl_ipc_output_v2_send_last_layer(ipc_output->resource,
monitor->last_surface_ws_name);
}
// 获取键盘布局(只在需要时)
if (event_mask & PRINT_KB_LAYOUT) {
keyboard = &kb_group->wlr_group->keyboard;
current = xkb_state_serialize_layout(keyboard->xkb_state,
XKB_STATE_LAYOUT_EFFECTIVE);
get_layout_abbr(kb_layout,
xkb_keymap_layout_get_name(keyboard->keymap, current));
}
// 发送键盘布局
if ((event_mask & PRINT_KB_LAYOUT) &&
wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_KB_LAYOUT_SINCE_VERSION) {
if (wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_KB_LAYOUT_SINCE_VERSION) {
zdwl_ipc_output_v2_send_kb_layout(ipc_output->resource, kb_layout);
}
// 发送键模式
if ((event_mask & PRINT_KEYMODE) &&
wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_KEYMODE_SINCE_VERSION) {
if (wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_KEYMODE_SINCE_VERSION) {
zdwl_ipc_output_v2_send_keymode(ipc_output->resource, keymode.mode);
}
// 发送缩放因子
if ((event_mask & PRINT_SCALEFACTOR) &&
wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_SCALEFACTOR_SINCE_VERSION) {
if (wl_resource_get_version(ipc_output->resource) >=
ZDWL_IPC_OUTPUT_V2_SCALEFACTOR_SINCE_VERSION) {
zdwl_ipc_output_v2_send_scalefactor(ipc_output->resource,
monitor->wlr_output->scale * 100);
}
// 发送帧结束标记
if (event_mask & PRINT_FRAME) {
zdwl_ipc_output_v2_send_frame(ipc_output->resource);
}
zdwl_ipc_output_v2_send_frame(ipc_output->resource);
}
void dwl_ipc_output_set_client_tags(struct wl_client *client,
@@ -313,7 +239,7 @@ void dwl_ipc_output_set_client_tags(struct wl_client *client,
if (selmon == monitor)
focusclient(focustop(monitor), 1);
arrange(selmon, false);
printstatus(PRINT_ALL);
printstatus();
}
void dwl_ipc_output_set_layout(struct wl_client *client,
@@ -332,7 +258,7 @@ void dwl_ipc_output_set_layout(struct wl_client *client,
monitor->pertag->ltidxs[monitor->pertag->curtag] = &layouts[index];
clear_fullscreen_and_maximized_state(monitor);
arrange(monitor, false);
printstatus(PRINT_ALL);
printstatus();
}
void dwl_ipc_output_set_tags(struct wl_client *client,

View File

@@ -629,7 +629,7 @@ static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config,
static void outputmgrtest(struct wl_listener *listener, void *data);
static void pointerfocus(Client *c, struct wlr_surface *surface, double sx,
double sy, uint32_t time);
static void printstatus(uint32_t event_mask);
static void printstatus(void);
static void quitsignal(int signo);
static void powermgrsetmode(struct wl_listener *listener, void *data);
static void rendermon(struct wl_listener *listener, void *data);
@@ -2168,7 +2168,7 @@ void closemon(Monitor *m) {
}
if (selmon) {
focusclient(focustop(selmon), 1);
printstatus(PRINT_ALL);
printstatus();
}
}
@@ -2802,7 +2802,7 @@ void createmon(struct wl_listener *listener, void *data) {
add_workspace_by_tag(i, m);
}
printstatus(PRINT_ALL);
printstatus();
}
void // fix for 0.5
@@ -3258,7 +3258,7 @@ void focusclient(Client *c, int lift) {
client_activate_surface(old_keyboard_focus_surface, 0);
}
}
printstatus(PRINT_ALL);
printstatus();
if (!c) {
@@ -3808,7 +3808,7 @@ mapnotify(struct wl_listener *listener, void *data) {
// make sure the animation is open type
c->is_pending_open_animation = true;
resize(c, c->geom, 0);
printstatus(PRINT_ALL);
printstatus();
}
void maximizenotify(struct wl_listener *listener, void *data) {
@@ -4147,9 +4147,7 @@ void pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
}
// 修改printstatus函数接受掩码参数
void printstatus(uint32_t event_mask) {
wl_signal_emit(&mango_print_status, (void *)(uintptr_t)event_mask);
}
void printstatus(void) { wl_signal_emit(&mango_print_status, NULL); }
void powermgrsetmode(struct wl_listener *listener, void *data) {
struct wlr_output_power_v1_set_mode_event *event = data;
@@ -4406,7 +4404,7 @@ run(char *startup_cmd) {
if (fd_set_nonblock(STDOUT_FILENO) < 0)
close(STDOUT_FILENO);
printstatus(PRINT_ALL);
printstatus();
/* At this point the outputs are initialized, choose initial selmon
* based on cursor position, and set default cursor image */
@@ -4541,7 +4539,7 @@ setfloating(Client *c, int floating) {
arrange(c->mon, false);
setborder_color(c);
printstatus(PRINT_ALL);
printstatus();
}
void reset_maximizescreen_size(Client *c) {
@@ -4872,24 +4870,14 @@ void create_output(struct wlr_backend *backend, void *data) {
// 修改信号处理函数,接收掩码参数
void handle_print_status(struct wl_listener *listener, void *data) {
uint32_t event_mask = (uintptr_t)data;
// 如果传入的是NULL旧代码或0使用默认的所有事件
if (!event_mask) {
event_mask = PRINT_ALL;
}
Monitor *m = NULL;
wl_list_for_each(m, &mons, link) {
if (!m->wlr_output->enabled) {
continue;
}
// 更新workspace状态根据掩码决定是否更新
if (event_mask & PRINT_TAG || event_mask & PRINT_ACTIVE) {
dwl_ext_workspace_printstatus(m);
}
dwl_ext_workspace_printstatus(m);
// 更新IPC输出状态传入掩码
dwl_ipc_output_printstatus(m, event_mask);
dwl_ipc_output_printstatus(m);
}
}
@@ -5226,7 +5214,7 @@ void tag_client(const Arg *arg, Client *target_client) {
}
focusclient(target_client, 1);
printstatus(PRINT_ALL);
printstatus();
}
void overview(Monitor *m) { grid(m); }
@@ -5434,7 +5422,7 @@ void unmapnotify(struct wl_listener *listener, void *data) {
}
wlr_scene_node_destroy(&c->scene->node);
printstatus(PRINT_ALL);
printstatus();
motionnotify(0, NULL, 0, 0, 0, 0);
}
@@ -5582,7 +5570,7 @@ void updatetitle(struct wl_listener *listener, void *data) {
if (title && c->foreign_toplevel)
wlr_foreign_toplevel_handle_v1_set_title(c->foreign_toplevel, title);
if (c == focustop(c->mon))
printstatus(PRINT_TITLE);
printstatus();
}
void // 17 fix to 0.5
@@ -5602,7 +5590,7 @@ urgent(struct wl_listener *listener, void *data) {
c->isurgent = 1;
if (client_surface(c)->mapped)
setborder_color(c);
printstatus(PRINT_ALL);
printstatus();
}
}
@@ -5657,7 +5645,7 @@ toggleseltags:
if (changefocus)
focusclient(focustop(m), 1);
arrange(m, want_animation);
printstatus(PRINT_ALL);
printstatus();
}
void view(const Arg *arg, bool want_animation) {
@@ -5800,7 +5788,7 @@ void activatex11(struct wl_listener *listener, void *data) {
arrange(c->mon, false);
}
printstatus(PRINT_ALL);
printstatus();
}
void configurex11(struct wl_listener *listener, void *data) {
@@ -5872,7 +5860,7 @@ void sethints(struct wl_listener *listener, void *data) {
return;
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);
printstatus(PRINT_ALL);
printstatus();
if (c->isurgent && surface && surface->mapped)
setborder_color(c);