Introduce an XcbEventFilter and install it in the Application

Forwards all xcb events to Workspace::workspaceEvent() which got changed
to process xcb events instead of XEvents. So far all handling is
disabled. Will be re-enabled step by step in the following patches.
This commit is contained in:
Martin Gräßlin 2013-07-26 07:52:56 +02:00
parent a3089e4c44
commit f11e3283d7
4 changed files with 29 additions and 3 deletions

View file

@ -72,10 +72,11 @@ extern int currentRefreshRate();
// **************************************** // ****************************************
/*! /*!
Handles workspace specific XEvents Handles workspace specific XCB event
*/ */
bool Workspace::workspaceEvent(XEvent * e) bool Workspace::workspaceEvent(xcb_generic_event_t *e)
{ {
#if KWIN_QT5_PORTING
if (effects && static_cast< EffectsHandlerImpl* >(effects)->hasKeyboardGrab() if (effects && static_cast< EffectsHandlerImpl* >(effects)->hasKeyboardGrab()
&& (e->type == KeyPress || e->type == KeyRelease)) && (e->type == KeyPress || e->type == KeyRelease))
return false; // let Qt process it, it'll be intercepted again in eventFilter() return false; // let Qt process it, it'll be intercepted again in eventFilter()
@ -349,6 +350,7 @@ bool Workspace::workspaceEvent(XEvent * e)
} }
break; break;
} }
#endif
return false; return false;
} }

View file

@ -305,6 +305,7 @@ int Application::crashes = 0;
Application::Application() Application::Application()
: KApplication() : KApplication()
, owner(screen_number) , owner(screen_number)
, m_eventFilter(new XcbEventFilter())
{ {
if (KCmdLineArgs::parsedArgs("qt")->isSet("sync")) { if (KCmdLineArgs::parsedArgs("qt")->isSet("sync")) {
kwin_sync = true; kwin_sync = true;
@ -360,6 +361,7 @@ Application::Application()
QTimer::singleShot(15 * 1000, this, SLOT(resetCrashesCount())); QTimer::singleShot(15 * 1000, this, SLOT(resetCrashesCount()));
initting = true; // Startup... initting = true; // Startup...
installNativeEventFilter(m_eventFilter.data());
// first load options - done internally by a different thread // first load options - done internally by a different thread
options = new Options; options = new Options;
@ -444,6 +446,19 @@ void Application::resetCrashesCount()
crashes = 0; crashes = 0;
} }
bool XcbEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long int *result)
{
Q_UNUSED(result)
if (!Workspace::self()) {
// Workspace not yet created
return false;
}
if (eventType != "xcb_generic_event_t") {
return false;
}
return Workspace::self()->workspaceEvent(static_cast<xcb_generic_event_t *>(message));
}
} // namespace } // namespace
static const char version[] = KDE_VERSION_STRING; static const char version[] = KDE_VERSION_STRING;

9
main.h
View file

@ -24,10 +24,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kapplication.h> #include <kapplication.h>
#include <KDE/KSelectionWatcher> #include <KDE/KSelectionWatcher>
// Qt
#include <QAbstractNativeEventFilter>
namespace KWin namespace KWin
{ {
class XcbEventFilter : public QAbstractNativeEventFilter
{
public:
virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long int *result) override;
};
class KWinSelectionOwner class KWinSelectionOwner
: public KSelectionOwner : public KSelectionOwner
{ {
@ -60,6 +68,7 @@ private Q_SLOTS:
private: private:
KWinSelectionOwner owner; KWinSelectionOwner owner;
QScopedPointer<XcbEventFilter> m_eventFilter;
static int crashes; static int crashes;
}; };

View file

@ -68,7 +68,7 @@ public:
return _self; return _self;
} }
bool workspaceEvent(XEvent*); bool workspaceEvent(xcb_generic_event_t*);
bool workspaceEvent(QEvent*); bool workspaceEvent(QEvent*);
bool hasClient(const Client*); bool hasClient(const Client*);