From 93161db90cc0e1af53724977ae9c2e321aea05e7 Mon Sep 17 00:00:00 2001 From: Bert Gijsbers Date: Sun, 16 Jun 2024 11:49:14 +0200 Subject: [PATCH] Do XFilterEvent globally. --- src/yinputline.cc | 10 ++-------- src/ywindow.cc | 4 ---- src/ywindow.h | 5 ----- src/yxapp.cc | 6 ++++-- 4 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/yinputline.cc b/src/yinputline.cc index df45cf679..a1b177420 100644 --- a/src/yinputline.cc +++ b/src/yinputline.cc @@ -905,19 +905,13 @@ void YInputLine::gotFocus() { XNClientWindow, handle(), XNFocusWindow, handle(), nullptr); - if (inputContext == nullptr) { - if (ONCE) - warn("Cannot create input context with XCreateIC"); - } else { + if (inputContext) { unsigned long mask = None; const char* name = XGetICValues(inputContext, XNFilterEvents, &mask, nullptr); - if (name) { - warn("XGetICValues fails for %s", name); - } else if (mask) { + if (name == nullptr && mask) { addEventMask(mask); } - eventFiltering(true); } } if (inputContext) { diff --git a/src/ywindow.cc b/src/ywindow.cc index c0d25b136..fa4bbc754 100644 --- a/src/ywindow.cc +++ b/src/ywindow.cc @@ -565,10 +565,6 @@ void YWindow::raiseTo(YWindow* inferior) { } void YWindow::handleEvent(const XEvent &event) { - if (hasbit(flags, wfFiltering) && - XFilterEvent(const_cast(&event), fHandle)) - return; - switch (event.type) { case KeyPress: case KeyRelease: diff --git a/src/ywindow.h b/src/ywindow.h index 79ffba727..d1f8dbc52 100644 --- a/src/ywindow.h +++ b/src/ywindow.h @@ -291,10 +291,6 @@ class YWindow : protected YWindowList, private YWindowNode { void unmanageWindow() { removeWindow(); } -protected: - void eventFiltering(bool f) { if (f) flags |= wfFiltering; - else flags &= ~wfFiltering; } - private: enum WindowFlags { wfVisible = 1 << 0, @@ -304,7 +300,6 @@ class YWindow : protected YWindowList, private YWindowNode { wfToplevel = 1 << 4, wfNullSize = 1 << 5, wfFocused = 1 << 6, - wfFiltering = 1 << 7, }; Window create(); diff --git a/src/yxapp.cc b/src/yxapp.cc index bf964f659..3c624168f 100644 --- a/src/yxapp.cc +++ b/src/yxapp.cc @@ -634,7 +634,8 @@ void YXApplication::dispatchEvent(YWindow *win, XEvent &xev) { if (fGrabTree && w == fXGrabWindow) break; } - } else if (win->destroyed() == false) { + } else if (win->destroyed() == false || + xev.type == DestroyNotify || xev.type == UnmapNotify) { Window child; if (xev.type == MotionNotify) { @@ -1173,7 +1174,6 @@ bool YXApplication::handleXEvents() { #ifdef DEBUG xeventcount++; #endif - //msg("%d", xev.type); saveEventTime(xev); @@ -1193,6 +1193,8 @@ bool YXApplication::handleXEvents() { #endif } #endif + if (XFilterEvent(&xev, None)) + continue; if (filterEvent(xev)) { } else {