core: event code refactoring

This commit is contained in:
Nikolay Borodin 2023-06-17 01:08:47 +02:00
parent 07303ce2cb
commit 56745b64d7
1 changed files with 6 additions and 4 deletions

View File

@ -107,7 +107,7 @@ static inline xcb_window_t attr_pure ev_window(session_t *ps, xcb_generic_event_
static inline const char *ev_name(session_t *ps, xcb_generic_event_t *ev) { static inline const char *ev_name(session_t *ps, xcb_generic_event_t *ev) {
static char buf[128]; static char buf[128];
switch (ev->response_type & 0x7f) { switch (XCB_EVENT_RESPONSE_TYPE(ev)) {
CASESTRRET(FocusIn); CASESTRRET(FocusIn);
CASESTRRET(FocusOut); CASESTRRET(FocusOut);
CASESTRRET(CreateNotify); CASESTRRET(CreateNotify);
@ -666,7 +666,7 @@ ev_selection_clear(session_t *ps, xcb_selection_clear_event_t attr_unused *ev) {
} }
void ev_handle(session_t *ps, xcb_generic_event_t *ev) { void ev_handle(session_t *ps, xcb_generic_event_t *ev) {
if ((ev->response_type & 0x7f) != KeymapNotify) { if (XCB_EVENT_RESPONSE_TYPE(ev) != KeymapNotify) {
discard_pending(ps, ev->full_sequence); discard_pending(ps, ev->full_sequence);
} }
@ -688,9 +688,10 @@ void ev_handle(session_t *ps, xcb_generic_event_t *ev) {
// For even more details, see: // For even more details, see:
// https://bugs.freedesktop.org/show_bug.cgi?id=35945 // https://bugs.freedesktop.org/show_bug.cgi?id=35945
// https://lists.freedesktop.org/archives/xcb/2011-November/007337.html // https://lists.freedesktop.org/archives/xcb/2011-November/007337.html
auto proc = XESetWireToEvent(ps->dpy, XCB_EVENT_RESPONSE_TYPE(ev), 0); auto response_type = XCB_EVENT_RESPONSE_TYPE(ev);
auto proc = XESetWireToEvent(ps->dpy, response_type, 0);
if (proc) { if (proc) {
XESetWireToEvent(ps->dpy, XCB_EVENT_RESPONSE_TYPE(ev), proc); XESetWireToEvent(ps->dpy, response_type, proc);
XEvent dummy; XEvent dummy;
// Stop Xlib from complaining about lost sequence numbers. // Stop Xlib from complaining about lost sequence numbers.
@ -709,6 +710,7 @@ void ev_handle(session_t *ps, xcb_generic_event_t *ev) {
// XXX redraw needs to be more fine grained // XXX redraw needs to be more fine grained
queue_redraw(ps); queue_redraw(ps);
// the events sent from SendEvent will be ignored
switch (ev->response_type) { switch (ev->response_type) {
case FocusIn: ev_focus_in(ps, (xcb_focus_in_event_t *)ev); break; case FocusIn: ev_focus_in(ps, (xcb_focus_in_event_t *)ev); break;
case FocusOut: ev_focus_out(ps, (xcb_focus_out_event_t *)ev); break; case FocusOut: ev_focus_out(ps, (xcb_focus_out_event_t *)ev); break;