Skip to content

Commit

Permalink
WIP: Add ignoreSurfacePointerEventExclusiveGrabber property for WSeat
Browse files Browse the repository at this point in the history
  • Loading branch information
zccrs committed Oct 22, 2024
1 parent 68b6927 commit 5641ebb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
29 changes: 29 additions & 0 deletions src/server/kernel/wseat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ class Q_DECL_HIDDEN WSeatPrivate : public WWrapObjectPrivate
WGlobal::CursorShape cursorShape = WGlobal::CursorShape::Invalid;

QPointer<WSurface> dragSurface;
bool ignoreSurfacePointerEventExclusiveGrabber = false;
};

void WSeatPrivate::on_destroy()
Expand Down Expand Up @@ -803,6 +804,19 @@ bool WSeat::sendEvent(WSurface *target, QObject *shellObject, QObject *eventObje

event->accept();

if (d->ignoreSurfacePointerEventExclusiveGrabber && event->isPointerEvent()) {
auto pe = static_cast<QPointerEvent*>(event);
if (pe->isBeginEvent()) {
for (const auto &point : pe->points()) {
auto grabber = pe->exclusiveGrabber(point);
// Qt will auto grab the pointer event for QQuickItem when mouse pressed until mouse released.
// But we want always update the HoverEnter/Leave's WSurfaceItem between drag move.
if (grabber == target)
pe->setExclusiveGrabber(point, nullptr);
}
}
}

switch (event->type()) {
case QEvent::HoverEnter: {
auto e = static_cast<QHoverEvent*>(event);
Expand Down Expand Up @@ -1034,6 +1048,21 @@ void WSeat::setKeyboard(WInputDevice *newKeyboard)
Q_EMIT this->keyboardChanged();
}

bool WSeat::ignoreSurfacePointerEventExclusiveGrabber() const
{
W_DC(WSeat);
return d->ignoreSurfacePointerEventExclusiveGrabber;
}

void WSeat::setIgnoreSurfacePointerEventExclusiveGrabber(bool newIgnoreSurfacePointerEventExclusiveGrabber)
{
W_D(WSeat);
if (d->ignoreSurfacePointerEventExclusiveGrabber == newIgnoreSurfacePointerEventExclusiveGrabber)
return;
d->ignoreSurfacePointerEventExclusiveGrabber = newIgnoreSurfacePointerEventExclusiveGrabber;
Q_EMIT ignoreSurfacePointerEventExclusiveGrabberChanged();
}

void WSeat::notifyMotion(WCursor *cursor, WInputDevice *device, uint32_t timestamp)
{
W_D(WSeat);
Expand Down
5 changes: 5 additions & 0 deletions src/server/kernel/wseat.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class WAYLIB_SERVER_EXPORT WSeat : public WWrapObject, public WServerInterface
W_DECLARE_PRIVATE(WSeat)
Q_PROPERTY(WInputDevice* keyboard READ keyboard WRITE setKeyboard NOTIFY keyboardChanged FINAL)
Q_PROPERTY(WSurface* keyboardFocus READ keyboardFocusSurface WRITE setKeyboardFocusSurface NOTIFY keyboardFocusSurfaceChanged FINAL)
Q_PROPERTY(bool ignoreSurfacePointerEventExclusiveGrabber READ ignoreSurfacePointerEventExclusiveGrabber WRITE setIgnoreSurfacePointerEventExclusiveGrabber NOTIFY ignoreSurfacePointerEventExclusiveGrabberChanged FINAL)

public:
WSeat(const QString &name = QStringLiteral("seat0"));
Expand Down Expand Up @@ -99,12 +100,16 @@ class WAYLIB_SERVER_EXPORT WSeat : public WWrapObject, public WServerInterface
WInputDevice *keyboard() const;
void setKeyboard(WInputDevice *newKeyboard);

bool ignoreSurfacePointerEventExclusiveGrabber() const;
void setIgnoreSurfacePointerEventExclusiveGrabber(bool newIgnoreSurfacePointerEventExclusiveGrabber);

Q_SIGNALS:
void keyboardChanged();
void keyboardFocusSurfaceChanged();
void requestCursorShape(WAYLIB_SERVER_NAMESPACE::WGlobal::CursorShape shape);
void requestCursorSurface(WAYLIB_SERVER_NAMESPACE::WSurface *surface, const QPoint &hotspot);
void requestDrag(WAYLIB_SERVER_NAMESPACE::WSurface *surface);
void ignoreSurfacePointerEventExclusiveGrabberChanged();

protected:
using QObject::eventFilter;
Expand Down

0 comments on commit 5641ebb

Please sign in to comment.