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:
parent
a3089e4c44
commit
f11e3283d7
4 changed files with 29 additions and 3 deletions
|
@ -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()
|
||||
&& (e->type == KeyPress || e->type == KeyRelease))
|
||||
return false; // let Qt process it, it'll be intercepted again in eventFilter()
|
||||
|
@ -349,6 +350,7 @@ bool Workspace::workspaceEvent(XEvent * e)
|
|||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
15
main.cpp
15
main.cpp
|
@ -305,6 +305,7 @@ int Application::crashes = 0;
|
|||
Application::Application()
|
||||
: KApplication()
|
||||
, owner(screen_number)
|
||||
, m_eventFilter(new XcbEventFilter())
|
||||
{
|
||||
if (KCmdLineArgs::parsedArgs("qt")->isSet("sync")) {
|
||||
kwin_sync = true;
|
||||
|
@ -360,6 +361,7 @@ Application::Application()
|
|||
QTimer::singleShot(15 * 1000, this, SLOT(resetCrashesCount()));
|
||||
|
||||
initting = true; // Startup...
|
||||
installNativeEventFilter(m_eventFilter.data());
|
||||
// first load options - done internally by a different thread
|
||||
options = new Options;
|
||||
|
||||
|
@ -444,6 +446,19 @@ void Application::resetCrashesCount()
|
|||
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
|
||||
|
||||
static const char version[] = KDE_VERSION_STRING;
|
||||
|
|
9
main.h
9
main.h
|
@ -24,10 +24,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include <kapplication.h>
|
||||
#include <KDE/KSelectionWatcher>
|
||||
// Qt
|
||||
#include <QAbstractNativeEventFilter>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class XcbEventFilter : public QAbstractNativeEventFilter
|
||||
{
|
||||
public:
|
||||
virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long int *result) override;
|
||||
};
|
||||
|
||||
class KWinSelectionOwner
|
||||
: public KSelectionOwner
|
||||
{
|
||||
|
@ -60,6 +68,7 @@ private Q_SLOTS:
|
|||
|
||||
private:
|
||||
KWinSelectionOwner owner;
|
||||
QScopedPointer<XcbEventFilter> m_eventFilter;
|
||||
static int crashes;
|
||||
};
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
return _self;
|
||||
}
|
||||
|
||||
bool workspaceEvent(XEvent*);
|
||||
bool workspaceEvent(xcb_generic_event_t*);
|
||||
bool workspaceEvent(QEvent*);
|
||||
|
||||
bool hasClient(const Client*);
|
||||
|
|
Loading…
Reference in a new issue