opt: optimize code struct

This commit is contained in:
DreamMaoMao
2025-09-05 22:01:08 +08:00
parent 6b02283f6d
commit 50fcb5ed68

View File

@@ -1806,7 +1806,7 @@ buttonpress(struct wl_listener *listener, void *data) {
struct wlr_surface *surface; struct wlr_surface *surface;
Client *tmpc; Client *tmpc;
int ji; int ji;
const MouseBinding *b; const MouseBinding *m;
struct wlr_surface *old_pointer_focus_surface = struct wlr_surface *old_pointer_focus_surface =
seat->pointer_state.focused_surface; seat->pointer_state.focused_surface;
@@ -1858,16 +1858,16 @@ buttonpress(struct wl_listener *listener, void *data) {
for (ji = 0; ji < config.mouse_bindings_count; ji++) { for (ji = 0; ji < config.mouse_bindings_count; ji++) {
if (config.mouse_bindings_count < 1) if (config.mouse_bindings_count < 1)
break; break;
b = &config.mouse_bindings[ji]; m = &config.mouse_bindings[ji];
if (CLEANMASK(mods) == CLEANMASK(b->mod) && if (CLEANMASK(mods) == CLEANMASK(m->mod) &&
event->button == b->button && b->func && event->button == m->button && m->func &&
(selmon->isoverview == 1 || b->button == BTN_MIDDLE) && c) { (selmon->isoverview == 1 || m->button == BTN_MIDDLE) && c) {
b->func(&b->arg); m->func(&m->arg);
return; return;
} else if (CLEANMASK(mods) == CLEANMASK(b->mod) && } else if (CLEANMASK(mods) == CLEANMASK(m->mod) &&
event->button == b->button && b->func && event->button == m->button && m->func &&
CLEANMASK(b->mod) != 0) { CLEANMASK(m->mod) != 0) {
b->func(&b->arg); m->func(&m->arg);
return; return;
} }
} }
@@ -2777,15 +2777,15 @@ void switch_toggle(struct wl_listener *listener, void *data) {
// 处理切换事件 // 处理切换事件
struct wlr_switch_toggle_event *event = data; struct wlr_switch_toggle_event *event = data;
SwitchBinding *a; SwitchBinding *s;
int ji; int ji;
for (ji = 0; ji < config.switch_bindings_count; ji++) { for (ji = 0; ji < config.switch_bindings_count; ji++) {
if (config.switch_bindings_count < 1) if (config.switch_bindings_count < 1)
break; break;
a = &config.switch_bindings[ji]; s = &config.switch_bindings[ji];
if (event->switch_state == a->fold && a->func) { if (event->switch_state == s->fold && s->func) {
a->func(&a->arg); s->func(&s->arg);
return; return;
} }
} }