summaryrefslogtreecommitdiffstats
path: root/src/compositor/compositor_api/qwaylandpointer.cpp
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-09-15 14:39:39 +0200
committerJørgen Lind <jorgen.lind@theqtcompany.com>2015-09-15 13:31:31 +0000
commit0345bba55ab67249fd3cda721de12b5fa1d95c36 (patch)
tree7c3db1fb27e0ca171caac44c505048cb60fb53b9 /src/compositor/compositor_api/qwaylandpointer.cpp
parentf5f06c709937b657c66ca4e35f4e3065ba390153 (diff)
Remove the mouse grabber
This is no longer used for move/resize, and we are going to introduce a new concept for drag and drop (which stopped working several changes ago anyway). The old drag and drop code is left commented out to assist in the new implementation. Change-Id: I18cb41d04f09d6033d1c9e666a739793fcef494b Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
Diffstat (limited to 'src/compositor/compositor_api/qwaylandpointer.cpp')
-rw-r--r--src/compositor/compositor_api/qwaylandpointer.cpp106
1 files changed, 15 insertions, 91 deletions
diff --git a/src/compositor/compositor_api/qwaylandpointer.cpp b/src/compositor/compositor_api/qwaylandpointer.cpp
index 5cec6fca6..5646544ee 100644
--- a/src/compositor/compositor_api/qwaylandpointer.cpp
+++ b/src/compositor/compositor_api/qwaylandpointer.cpp
@@ -46,11 +46,6 @@ QWaylandPointerPrivate::QWaylandPointerPrivate(QWaylandPointer *pointer, QWaylan
, wl_pointer()
, seat(seat)
, output()
- , defaultGrab(pointer)
- , grab(&defaultGrab)
- , grabButton()
- , grabTime()
- , grabSerial()
, focusResource()
, hasSentEnter(false)
, buttonCount()
@@ -83,10 +78,6 @@ void QWaylandPointerPrivate::pointer_set_cursor(wl_pointer::Resource *resource,
seat->cursorSurfaceRequest(s, hotspot_x, hotspot_y);
}
-QWaylandPointerGrabber::~QWaylandPointerGrabber()
-{
-}
-
QWaylandPointer::QWaylandPointer(QWaylandInputDevice *seat, QObject *parent)
: QObject(* new QWaylandPointerPrivate(this, seat), parent)
{
@@ -94,32 +85,6 @@ QWaylandPointer::QWaylandPointer(QWaylandInputDevice *seat, QObject *parent)
connect(seat, &QWaylandInputDevice::mouseFocusChanged, this, &QWaylandPointer::pointerFocusChanged);
}
-void QWaylandDefaultPointerGrabber::focus()
-{
-// if (buttonPressed())
-// return;
-//
-// setFocus(currentPosition.view(), currentPosition.position());
-}
-
-void QWaylandDefaultPointerGrabber::motion(uint32_t time)
-{
- struct wl_resource *focusResource = pointer->focusResource();
- if (focusResource) {
- wl_fixed_t x = wl_fixed_from_double(pointer->currentLocalPosition().x());
- wl_fixed_t y = wl_fixed_from_double(pointer->currentLocalPosition().y());
- wl_pointer_send_motion(focusResource, time, x, y);
- }
-}
-
-void QWaylandDefaultPointerGrabber::button(uint32_t time, Qt::MouseButton button, uint32_t state)
-{
- struct wl_resource *focusResource = pointer->focusResource();
- if (focusResource) {
- pointer->sendButton(focusResource, time, button, state);
- }
-}
-
QWaylandInputDevice *QWaylandPointer::inputDevice() const
{
Q_D(const QWaylandPointer);
@@ -146,62 +111,16 @@ void QWaylandPointer::setOutput(QWaylandOutput *output)
outputChanged();
}
-void QWaylandPointer::startGrab(QWaylandPointerGrabber *grab)
-{
- Q_D(QWaylandPointer);
- d->grab = grab;
- d->grab->pointer = this;
-
- if (d->seat->mouseFocus())
- d->grab->focus();
-}
-
-void QWaylandPointer::endGrab()
-{
- Q_D(QWaylandPointer);
- d->grab = &d->defaultGrab;
- d->grab->focus();
-}
-
-QWaylandPointerGrabber *QWaylandPointer::currentGrab() const
-{
- Q_D(const QWaylandPointer);
- return d->grab;
-}
-
-Qt::MouseButton QWaylandPointer::grabButton() const
-{
- Q_D(const QWaylandPointer);
- return d->grabButton;
-}
-
-uint32_t QWaylandPointer::grabTime() const
-{
- Q_D(const QWaylandPointer);
- return d->grabTime;
-
-}
-
-uint32_t QWaylandPointer::grabSerial() const
-{
- Q_D(const QWaylandPointer);
- return d->grabSerial;
-}
-
void QWaylandPointer::sendMousePressEvent(Qt::MouseButton button)
{
Q_D(QWaylandPointer);
uint32_t time = d->compositor()->currentTimeMsecs();
- if (d->buttonCount == 0) {
- d->grabButton = button;
- d->grabTime = time;
- }
d->buttonCount++;
- d->grab->button(time, button, WL_POINTER_BUTTON_STATE_PRESSED);
+ if (d->focusResource)
+ sendButton(d->focusResource, time, button, WL_POINTER_BUTTON_STATE_PRESSED);
if (d->buttonCount == 1) {
- d->grabSerial = d->compositor()->nextSerial();
- buttonPressedChanged();
+ emit buttonPressedChanged();
}
}
@@ -210,12 +129,12 @@ void QWaylandPointer::sendMouseReleaseEvent(Qt::MouseButton button)
Q_D(QWaylandPointer);
uint32_t time = d->compositor()->currentTimeMsecs();
d->buttonCount--;
- d->grab->button(time, button, WL_POINTER_BUTTON_STATE_RELEASED);
- if (d->buttonCount == 1)
- d->grabSerial = d->compositor()->nextSerial();
+ if (d->focusResource)
+ sendButton(d->focusResource, time, button, WL_POINTER_BUTTON_STATE_RELEASED);
+
if (d->buttonCount == 0)
- buttonPressedChanged();
+ emit buttonPressedChanged();
}
void QWaylandPointer::sendMouseMoveEvent(QWaylandView *view, const QPointF &localPos, const QPointF &outputSpacePos)
@@ -228,7 +147,7 @@ void QWaylandPointer::sendMouseMoveEvent(QWaylandView *view, const QPointF &loca
d->spacePosition = outputSpacePos;
//we adjust if the mouse position is on the edge
- //to work around Qt's event propogation
+ //to work around Qt's event propagation
if (view && view->surface()) {
QSizeF size(view->surface()->size());
if (d->localPosition.x() == size.width())
@@ -257,7 +176,13 @@ void QWaylandPointer::sendMouseMoveEvent(QWaylandView *view, const QPointF &loca
if (view && view->output())
setOutput(view->output());
- d->grab->motion(d->compositor()->currentTimeMsecs());
+ uint32_t time = d->compositor()->currentTimeMsecs();
+
+ if (d->focusResource) {
+ wl_fixed_t x = wl_fixed_from_double(currentLocalPosition().x());
+ wl_fixed_t y = wl_fixed_from_double(currentLocalPosition().y());
+ wl_pointer_send_motion(d->focusResource, time, x, y);
+ }
}
void QWaylandPointer::sendMouseWheelEvent(Qt::Orientation orientation, int delta)
@@ -356,7 +281,6 @@ void QWaylandPointer::focusDestroyed(void *data)
d->seat->setMouseFocus(Q_NULLPTR);
d->focusResource = 0;
d->buttonCount = 0;
- endGrab();
}
void QWaylandPointer::pointerFocusChanged(QWaylandView *newFocus, QWaylandView *oldFocus)