6#include <QtWaylandCompositor/QWaylandClient>
7#include <QtWaylandCompositor/QWaylandCompositor>
22 if (!
q->mouseFocus() || !
q->mouseFocus()->surface())
25 wl_client *client =
q->mouseFocus()->surface()->waylandClient();
28 for (
auto resource : resourceMap().
values(client))
33void QWaylandPointerPrivate::sendMotion()
37 wl_fixed_t
x = wl_fixed_from_double(localPosition.
x());
38 wl_fixed_t
y = wl_fixed_from_double(localPosition.
y());
39 for (
auto resource : resourceMap().
values(enteredSurface->waylandClient()))
45 Q_ASSERT(surface && !enteredSurface);
52 wl_fixed_t
x = wl_fixed_from_double(localPosition.
x());
53 wl_fixed_t
y = wl_fixed_from_double(localPosition.
y());
54 for (
auto resource : resourceMap().
values(surface->waylandClient()))
55 send_enter(resource->
handle, enterSerial, surface->resource(),
x,
y);
57 enteredSurface = surface;
61void QWaylandPointerPrivate::sendLeave()
65 for (
auto resource : resourceMap().
values(enteredSurface->waylandClient()))
66 send_leave(resource->
handle, serial, enteredSurface->resource());
68 enteredSurfaceDestroyListener.
reset();
69 enteredSurface =
nullptr;
74 if (enteredSurface == surface)
86 wl_resource_destroy(resource->handle);
106 wl_resource *displayRes = wl_client_get_object(resource->client(), 1);
107 if (
s->setRole(&QWaylandPointerPrivate::s_role, displayRes, WL_DISPLAY_ERROR_INVALID_OBJECT)) {
108 s->markAsCursorSurface(
true);
148 return d->compositor();
166 if (
d->output ==
output)
return;
181 if (
d->buttonCount == 1)
184 return d->sendButton(
button, WL_POINTER_BUTTON_STATE_PRESSED);
197 if (
d->buttonCount == 0)
200 return d->sendButton(
button, WL_POINTER_BUTTON_STATE_RELEASED);
210 if (
view && (!
view->surface() ||
view->surface()->isCursorSurface()))
212 d->seat->setMouseFocus(
view);
213 d->localPosition = localPos;
214 d->spacePosition = outputSpacePos;
220 if (
d->localPosition.x() ==
size.width())
221 d->localPosition.rx() -= 0.01;
222 if (
d->localPosition.y() ==
size.height())
223 d->localPosition.ry() -= 0.01;
225 d->ensureEntered(
view->surface());
239 if (!
d->enteredSurface)
242 uint32_t
time =
d->compositor()->currentTimeMsecs();
243 uint32_t axis = orientation ==
Qt::Horizontal ? WL_POINTER_AXIS_HORIZONTAL_SCROLL
244 : WL_POINTER_AXIS_VERTICAL_SCROLL;
246 for (
auto resource :
d->resourceMap().values(
d->enteredSurface->waylandClient()))
247 d->send_axis(resource->handle,
time, axis, wl_fixed_from_int(-delta / 12));
256 return d->seat->mouseFocus();
265 return d->localPosition;
274 return d->spacePosition;
283 return d->buttonCount > 0;
292 wl_resource *resource =
d->add(client->
client(),
id, qMin<uint32_t>(QtWaylandServer::wl_pointer::interfaceVersion(), version))->handle;
293 if (
d->enteredSurface && client ==
d->enteredSurface->client()) {
294 d->send_enter(resource,
d->enterSerial,
d->enteredSurface->resource(),
295 wl_fixed_from_double(
d->localPosition.x()),
296 wl_fixed_from_double(
d->localPosition.y()));
314 return d->resourceMap().value(
focus->surface()->waylandClient())->handle;
325 uint32_t serial =
d->compositor()->nextSerial();
336 uint32_t BTN_LEFT = 0x110;
358 default:
return uint32_t(0x11f);
365void QWaylandPointer::enteredSurfaceDestroyed(
void *
data)
369 d->enteredSurfaceDestroyListener.reset();
370 d->enteredSurface =
nullptr;
372 d->seat->setMouseFocus(
nullptr);
374 if (
d->buttonCount != 0) {
387 bool wasSameSurface = newFocus && newFocus->
surface() ==
d->enteredSurface;
388 if (
d->enteredSurface && !wasSameSurface)
394#include "moc_qwaylandpointer.cpp"
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
\qmltype WaylandClient \instantiates QWaylandClient \inqmlmodule QtWayland.Compositor
static QWaylandClient * fromWlClient(QWaylandCompositor *compositor, wl_client *wlClient)
Returns the QWaylandClient corresponding to the Wayland client wlClient and compositor.
wl_client * client() const
Returns the Wayland client of this QWaylandClient.
\qmltype WaylandCompositor \instantiates QWaylandCompositor \inqmlmodule QtWayland....
void listenForDestruction(struct wl_resource *resource)
\inmodule QtWaylandCompositor
virtual void sendKeyModifiers(QWaylandClient *client, uint32_t serial)
Sends the current key modifiers to client with the given serial.
\inmodule QtWaylandCompositor
\qmltype WaylandOutput \instantiates QWaylandOutput \inqmlmodule QtWayland.Compositor
void pointer_set_cursor(Resource *resource, uint32_t serial, wl_resource *surface, int32_t hotspot_x, int32_t hotspot_y) override
void pointer_release(Resource *resource) override
QWaylandPointerPrivate(QWaylandPointer *pointer, QWaylandSeat *seat)
QWaylandCompositor * compositor() const
\inmodule QtWaylandCompositor
virtual void addClient(QWaylandClient *client, uint32_t id, uint32_t version)
QPointF currentSpacePosition() const
Returns the current output space position of the QWaylandPointer.
virtual uint sendMouseReleaseEvent(Qt::MouseButton button)
Sends a mouse release event for button to the view currently holding mouse focus.
uint sendButton(struct wl_resource *resource, uint32_t time, Qt::MouseButton button, uint32_t state)
static uint32_t toWaylandButton(Qt::MouseButton button)
QWaylandView * mouseFocus() const
Returns the view that currently holds mouse focus.
virtual void sendMouseMoveEvent(QWaylandView *view, const QPointF &localPos, const QPointF &outputSpacePos)
Sets the current mouse focus to view and sends a mouse move event to it with the local position local...
QWaylandCompositor * compositor() const
Returns the compositor for this QWaylandPointer.
virtual uint sendMousePressEvent(Qt::MouseButton button)
Sends a mouse press event for button to the view currently holding mouse focus.
QWaylandPointer(QWaylandSeat *seat, QObject *parent=nullptr)
Constructs a QWaylandPointer for the given seat and with the given parent.
virtual void sendMouseWheelEvent(Qt::Orientation orientation, int delta)
Sends a mouse wheel event with the given orientation and delta to the view that currently holds mouse...
QWaylandSeat * seat() const
Returns the input device for this QWaylandPointer.
void setOutput(QWaylandOutput *output)
Sets the output for this QWaylandPointer to output.
QPointF currentLocalPosition() const
Returns the current local position of the QWaylandPointer in surface coordinates.
wl_resource * focusResource() const
Returns a Wayland resource for this QWaylandPointer.
QWaylandOutput * output() const
Returns the output for this QWaylandPointer.
void buttonPressedChanged()
\qmltype WaylandSeat \instantiates QWaylandSeat \inqmlmodule QtWayland.Compositor
QWaylandKeyboard * keyboard() const
Returns the keyboard for this input device.
void cursorSurfaceRequested(QWaylandSurface *surface, int hotspotX, int hotspotY, QWaylandClient *client)
void mouseFocusChanged(QWaylandView *newFocus, QWaylandView *oldFocus)
This signal is emitted when the mouse focus has changed from oldFocus to newFocus.
\inmodule QtWaylandCompositor
\qmltype WaylandSurface \instantiates QWaylandSurface \inqmlmodule QtWayland.Compositor
struct wl_resource * resource() const
Returns the Wayland resource corresponding to this QWaylandSurface.
static QWaylandSurface * fromResource(::wl_resource *resource)
Returns the QWaylandSurface corresponding to the Wayland resource resource.
QWaylandClient * client
\qmlproperty WaylandClient QtWayland.Compositor::WaylandSurface::client
\qmltype WaylandView \instantiates QWaylandView \inqmlmodule QtWayland.Compositor
QWaylandSurface * surface
\qmlproperty WaylandSurface QtWayland.Compositor::WaylandView::surface
Combined button and popup list for selecting options.
GLenum GLsizei GLsizei GLint * values
[15]
GLuint64 GLenum void * handle
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei const void * pointer
GLdouble GLdouble GLdouble GLdouble q
QT_BEGIN_NAMESPACE typedef uchar * output
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent