xwayland: Make DataBridge a native event filter
With the DataBridge being a native event filter, we can further separate DataBridge-specific and generic Xwayland bits. In particular, we no longer have to call DataBridge::filterEvent() from the dispatchEvents() method, whose main purpose is to dispatch X11 events to kwin.
This commit is contained in:
parent
c86d3b717a
commit
8baf535a7a
3 changed files with 9 additions and 12 deletions
|
@ -81,15 +81,14 @@ void DataBridge::init()
|
|||
m_clipboard = new Clipboard(atoms->clipboard, this);
|
||||
m_dnd = new Dnd(atoms->xdnd_selection, this);
|
||||
waylandServer()->dispatch();
|
||||
kwinApp()->installNativeEventFilter(this);
|
||||
}
|
||||
|
||||
bool DataBridge::filterEvent(xcb_generic_event_t *event)
|
||||
bool DataBridge::nativeEventFilter(const QByteArray &eventType, void *message, long int *)
|
||||
{
|
||||
if (m_clipboard && m_clipboard->filterEvent(event)) {
|
||||
return true;
|
||||
}
|
||||
if (m_dnd && m_dnd->filterEvent(event)) {
|
||||
return true;
|
||||
if (eventType == "xcb_generic_event_t") {
|
||||
xcb_generic_event_t *event = static_cast<xcb_generic_event_t *>(message);
|
||||
return m_clipboard->filterEvent(event) || m_dnd->filterEvent(event);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#ifndef KWIN_XWL_DATABRIDGE
|
||||
#define KWIN_XWL_DATABRIDGE
|
||||
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QObject>
|
||||
#include <QPoint>
|
||||
|
||||
|
@ -42,7 +43,7 @@ enum class DragEventReply;
|
|||
*
|
||||
* Exists only once per Xwayland session.
|
||||
*/
|
||||
class DataBridge : public QObject
|
||||
class DataBridge : public QObject, public QAbstractNativeEventFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -52,7 +53,6 @@ public:
|
|||
explicit DataBridge(QObject *parent = nullptr);
|
||||
~DataBridge() override;
|
||||
|
||||
bool filterEvent(xcb_generic_event_t *event);
|
||||
DragEventReply dragMoveFilter(Toplevel *target, const QPoint &pos);
|
||||
|
||||
KWayland::Client::DataDevice *dataDevice() const
|
||||
|
@ -68,6 +68,8 @@ public:
|
|||
return m_dnd;
|
||||
}
|
||||
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, long int *result) override;
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
|
|
|
@ -187,10 +187,6 @@ void Xwayland::dispatchEvents()
|
|||
}
|
||||
|
||||
while (xcb_generic_event_t *event = xcb_poll_for_event(connection)) {
|
||||
if (m_dataBridge->filterEvent(event)) {
|
||||
free(event);
|
||||
continue;
|
||||
}
|
||||
long result = 0;
|
||||
QAbstractEventDispatcher *dispatcher = QCoreApplication::eventDispatcher();
|
||||
dispatcher->filterNativeEvent(QByteArrayLiteral("xcb_generic_event_t"), event, &result);
|
||||
|
|
Loading…
Reference in a new issue