summaryrefslogtreecommitdiffstats
path: root/src/compositor/wayland_wrapper
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2012-01-11 09:35:39 +0100
committerLaszlo Agocs <laszlo.p.agocs@nokia.com>2012-01-11 11:07:24 +0100
commit8894f58e01b51e9b2072973edbe043ebe62858b4 (patch)
tree1a449793f14256d228b0ea0251e289a9013f13de /src/compositor/wayland_wrapper
parentbf850bd6ea971a44a0af8e6940edb3ba419da962 (diff)
Move event handling into WaylandInput api
Qt only gives us 1 input device as of now, ie. the mouse/keyboard and touch events. However, at some point in the future, this will change, so that the events will have a device id. This will ie on x map to the same device, but on evdev this can be different devices. Also this is part of what is needed to implement grabbing Change-Id: Ice049502d6f0f53fd06142d4dedde05806d60120 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
Diffstat (limited to 'src/compositor/wayland_wrapper')
-rw-r--r--src/compositor/wayland_wrapper/wlcompositor.cpp46
-rw-r--r--src/compositor/wayland_wrapper/wlcompositor.h11
-rw-r--r--src/compositor/wayland_wrapper/wlinputdevice.cpp181
-rw-r--r--src/compositor/wayland_wrapper/wlinputdevice.h41
-rw-r--r--src/compositor/wayland_wrapper/wlsurface.cpp151
-rw-r--r--src/compositor/wayland_wrapper/wlsurface.h20
6 files changed, 225 insertions, 225 deletions
diff --git a/src/compositor/wayland_wrapper/wlcompositor.cpp b/src/compositor/wayland_wrapper/wlcompositor.cpp
index 806a5f7d3..5b762f533 100644
--- a/src/compositor/wayland_wrapper/wlcompositor.cpp
+++ b/src/compositor/wayland_wrapper/wlcompositor.cpp
@@ -40,10 +40,10 @@
#include "wlcompositor.h"
+#include "waylandinput.h"
#include "wldisplay.h"
#include "wlshmbuffer.h"
#include "wlsurface.h"
-#include "wlinputdevice.h"
#include "waylandcompositor.h"
#include "wldatadevicemanager.h"
#include "wldatadevice.h"
@@ -103,6 +103,7 @@ Compositor *Compositor::instance()
Compositor::Compositor(WaylandCompositor *qt_compositor)
: m_display(new Display)
, m_shm(m_display)
+ , m_default_input_device(0)
, m_current_frame(0)
, m_last_queued_buf(-1)
, m_qt_compositor(qt_compositor)
@@ -130,8 +131,6 @@ Compositor::Compositor(WaylandCompositor *qt_compositor)
m_data_device_manager = new DataDeviceManager(this);
- m_input = new InputDevice(this);
-
wl_display_add_global(m_display->handle(),&wl_output_interface, &m_output_global,OutputGlobal::output_bind_func);
wl_display_add_global(m_display->handle(), &wl_shell_interface, &m_shell, Shell::bind_func);
@@ -157,7 +156,7 @@ Compositor::Compositor(WaylandCompositor *qt_compositor)
Compositor::~Compositor()
{
- delete m_input;
+ delete m_default_input_device;
delete m_data_device_manager;
delete m_display;
@@ -268,37 +267,6 @@ void Compositor::destroyClientForSurface(Surface *surface)
}
}
-void Compositor::setInputFocus(Surface *surface)
-{
- setKeyFocus(surface);
- setPointerFocus(surface);
-}
-
-void Compositor::setKeyFocus(Surface *surface)
-{
- m_input->sendSelectionFocus(surface);
- wl_input_device_set_keyboard_focus(m_input->base(), surface ? surface->base() : 0, currentTimeMsecs());
-}
-
-Surface *Compositor::keyFocus() const
-{
- return wayland_cast<Surface *>(m_input->base()->keyboard_focus);
-}
-
-void Compositor::setPointerFocus(Surface *surface, const QPoint &globalPos, const QPoint &localPos)
-{
- wl_input_device_set_pointer_focus(m_input->base(),
- surface ? surface->base() : 0,
- currentTimeMsecs(),
- globalPos.x(), globalPos.y(),
- localPos.x(), localPos.y());
-}
-
-Surface *Compositor::pointerFocus() const
-{
- return wayland_cast<Surface *>(m_input->base()->pointer_focus);
-}
-
QWindow *Compositor::window() const
{
return m_qt_compositor->window();
@@ -321,6 +289,12 @@ void Compositor::initializeHardwareIntegration()
#endif
}
+void Compositor::initializeDefaultInputDevice()
+{
+ WaylandInputDevice *defaultInput = new WaylandInputDevice(m_qt_compositor);
+ m_default_input_device = defaultInput->handle();
+}
+
void Compositor::initializeWindowManagerProtocol()
{
m_windowManagerIntegration->initialize(m_display);
@@ -384,7 +358,7 @@ void Compositor::setOutputGeometry(const QRect &geometry)
InputDevice* Compositor::defaultInputDevice()
{
- return m_input;
+ return m_default_input_device;
}
QList<Wayland::Surface *> Compositor::surfacesForClient(wl_client *client)
diff --git a/src/compositor/wayland_wrapper/wlcompositor.h b/src/compositor/wayland_wrapper/wlcompositor.h
index b3afe861d..135228a76 100644
--- a/src/compositor/wayland_wrapper/wlcompositor.h
+++ b/src/compositor/wayland_wrapper/wlcompositor.h
@@ -75,18 +75,12 @@ public:
~Compositor();
void frameFinished(Surface *surface = 0);
- void setInputFocus(Surface *surface);
- void setKeyFocus(Surface *surface);
- Surface *keyFocus() const;
- void setPointerFocus(Surface *surface, const QPoint &globalPos = QPoint(), const QPoint &localPos = QPoint());
- Surface *pointerFocus() const;
Surface *getSurfaceFromWinId(uint winId) const;
struct wl_client *getClientFromWinId(uint winId) const;
QImage image(uint winId) const;
- InputDevice *inputDevice() { return m_input; }
- InputDevice *defaultInputDevice();
+ InputDevice *defaultInputDevice(); //we just have 1 default device for now (since QPA doesn't give us anything else)
void createSurface(struct wl_client *client, uint32_t id);
void surfaceDestroyed(Surface *surface);
@@ -100,6 +94,7 @@ public:
GraphicsHardwareIntegration *graphicsHWIntegration() const;
void initializeHardwareIntegration();
+ void initializeDefaultInputDevice();
void initializeWindowManagerProtocol();
void enableSubSurfaceExtension();
bool setDirectRenderSurface(Surface *surface);
@@ -142,7 +137,7 @@ private:
Display *m_display;
/* Input */
- InputDevice *m_input;
+ InputDevice *m_default_input_device;
/* Output */
//make this a list of the available screens
diff --git a/src/compositor/wayland_wrapper/wlinputdevice.cpp b/src/compositor/wayland_wrapper/wlinputdevice.cpp
index 511ac483a..92eb12238 100644
--- a/src/compositor/wayland_wrapper/wlinputdevice.cpp
+++ b/src/compositor/wayland_wrapper/wlinputdevice.cpp
@@ -45,28 +45,169 @@
#include "wldatadevice.h"
#include "wlsurface.h"
-#include <QtCore/QDebug>
-
#include "waylandcompositor.h"
+#include <QtGui/QTouchEvent>
+
namespace Wayland {
static ShmBuffer *currentCursor;
-InputDevice::InputDevice(Compositor *compositor)
- : m_compositor(compositor)
+InputDevice::InputDevice(WaylandInputDevice *handle, Compositor *compositor)
+ : m_handle(handle)
+ , m_compositor(compositor)
{
wl_input_device_init(base());
wl_display_add_global(compositor->wl_display(),&wl_input_device_interface,this,InputDevice::bind_func);
}
+void InputDevice::sendMousePressEvent(Qt::MouseButton button, const QPoint &localPos, const QPoint &globalPos)
+{
+ sendMouseMoveEvent(localPos,globalPos);
+
+ uint32_t time = m_compositor->currentTimeMsecs();
+ struct wl_resource *pointer_focus_resource = base()->pointer_focus_resource;
+ if (pointer_focus_resource) {
+ wl_resource_post_event(pointer_focus_resource,
+ WL_INPUT_DEVICE_BUTTON, time, toWaylandButton(button), 1);
+ }
+}
+
+void InputDevice::sendMouseReleaseEvent(Qt::MouseButton button, const QPoint &localPos, const QPoint &globalPos)
+{
+ sendMouseMoveEvent(localPos,globalPos);
+
+ uint32_t time = m_compositor->currentTimeMsecs();
+ struct wl_resource *pointer_focus_resource = base()->pointer_focus_resource;
+ if (pointer_focus_resource) {
+ wl_resource_post_event(pointer_focus_resource,
+ WL_INPUT_DEVICE_BUTTON, time, toWaylandButton(button), 0);
+ }
+}
+
+void InputDevice::sendMouseMoveEvent(const QPoint &localPos, const QPoint &globalPos)
+{
+ uint32_t time = m_compositor->currentTimeMsecs();
+ struct wl_resource *pointer_focus_resource = base()->pointer_focus_resource;
+ if (pointer_focus_resource) {
+ QPoint validGlobalPos = globalPos.isNull()?localPos:globalPos;
+ wl_resource_post_event(pointer_focus_resource,
+ WL_INPUT_DEVICE_MOTION,
+ time,
+ validGlobalPos.x(), validGlobalPos.y(), //wayland sends globals before locals
+ localPos.x(), localPos.y());
+ }
+}
+
+void InputDevice::sendMouseMoveEvent(Surface *surface, const QPoint &localPos, const QPoint &globalPos)
+{
+ if (mouseFocus() != surface) {
+ setMouseFocus(surface,localPos,globalPos);
+ }
+ sendMouseMoveEvent(localPos,globalPos);
+}
+
+void InputDevice::sendKeyPressEvent(uint code)
+{
+ if (base()->keyboard_focus_resource != NULL) {
+ uint32_t time = m_compositor->currentTimeMsecs();
+ wl_resource_post_event(base()->keyboard_focus_resource,
+ WL_INPUT_DEVICE_KEY, time, code - 8, 1);
+ }
+}
+
+void InputDevice::sendKeyReleaseEvent(uint code)
+{
+ if (base()->keyboard_focus_resource != NULL) {
+ uint32_t time = m_compositor->currentTimeMsecs();
+ wl_resource_post_event(base()->keyboard_focus_resource,
+ WL_INPUT_DEVICE_KEY, time, code - 8, 0);
+ }
+}
+
+void InputDevice::sendTouchPointEvent(int id, int x, int y, Qt::TouchPointState state)
+{
+ uint32_t time = m_compositor->currentTimeMsecs();
+ struct wl_resource *resource = base()->pointer_focus_resource;
+ switch (state) {
+ case Qt::TouchPointPressed:
+ wl_resource_post_event(resource, WL_INPUT_DEVICE_TOUCH_DOWN, time, this, id, x, y);
+ break;
+ case Qt::TouchPointMoved:
+ wl_resource_post_event(resource, WL_INPUT_DEVICE_TOUCH_MOTION, time, id, x, y);
+ break;
+ case Qt::TouchPointReleased:
+ wl_resource_post_event(resource, WL_INPUT_DEVICE_TOUCH_UP, time, id);
+ break;
+ case Qt::TouchPointStationary:
+ // stationary points are not sent through wayland, the client must cache them
+ break;
+ default:
+ break;
+ }
+}
+
+void InputDevice::sendTouchFrameEvent()
+{
+ struct wl_resource *resource = base()->pointer_focus_resource;
+ wl_resource_post_event(resource,
+ WL_INPUT_DEVICE_TOUCH_FRAME);
+}
+
+void InputDevice::sendTouchCancelEvent()
+{
+ struct wl_resource *resource = base()->pointer_focus_resource;
+ wl_resource_post_event(resource,
+ WL_INPUT_DEVICE_TOUCH_CANCEL);
+}
+
+void InputDevice::sendFullTouchEvent(QTouchEvent *event)
+{
+ const QList<QTouchEvent::TouchPoint> points = event->touchPoints();
+ if (points.isEmpty())
+ return;
+ const int pointCount = points.count();
+ QPointF pos = mouseFocus()? mouseFocus()->pos():QPointF(0,0);
+ for (int i = 0; i < pointCount; ++i) {
+ const QTouchEvent::TouchPoint &tp(points.at(i));
+ // Convert the local pos in the compositor window to surface-relative.
+ QPoint p = (tp.pos() - pos).toPoint();
+ sendTouchPointEvent(tp.id(), p.x(), p.y(), tp.state());
+ }
+ sendTouchFrameEvent();
+}
+
+Surface *InputDevice::keyboardFocus() const
+{
+ return wayland_cast<Surface *>(base()->keyboard_focus);
+}
+
+void InputDevice::setKeyboardFocus(Surface *surface)
+{
+ sendSelectionFocus(surface);
+ wl_input_device_set_keyboard_focus(base(), surface ? surface->base() : 0, m_compositor->currentTimeMsecs());
+}
+
+Surface *InputDevice::mouseFocus() const
+{
+ return wayland_cast<Surface *>(base()->pointer_focus);
+}
+
+void InputDevice::setMouseFocus(Surface *surface, const QPoint &globalPos, const QPoint &localPos)
+{
+ wl_input_device_set_pointer_focus(base(),
+ surface ? surface->base() : 0,
+ m_compositor->currentTimeMsecs(),
+ globalPos.x(), globalPos.y(),
+ localPos.x(), localPos.y());
+}
+
void InputDevice::clientRequestedDataDevice(DataDeviceManager *data_device_manager, struct wl_client *client, uint32_t id)
{
for (int i = 0; i < m_data_devices.size(); i++) {
struct wl_resource *data_device_resource =
m_data_devices.at(i)->dataDeviceResource();
if (data_device_resource->client == client) {
- qDebug() << "Client created data device, but already has one; removing the old one!";
m_data_devices.removeAt(i);
free(data_device_resource);
break;
@@ -74,7 +215,6 @@ void InputDevice::clientRequestedDataDevice(DataDeviceManager *data_device_manag
}
DataDevice *dataDevice = new DataDevice(data_device_manager,client,id);
m_data_devices.append(dataDevice);
- qDebug("created datadevice %p resource %p", dataDevice, dataDevice->dataDeviceResource());
}
void InputDevice::sendSelectionFocus(Surface *surface)
@@ -87,6 +227,33 @@ void InputDevice::sendSelectionFocus(Surface *surface)
}
}
+Compositor *InputDevice::compositor() const
+{
+ return m_compositor;
+}
+
+WaylandInputDevice *InputDevice::handle() const
+{
+ return m_handle;
+}
+
+uint32_t InputDevice::toWaylandButton(Qt::MouseButton button)
+{
+#ifndef BTN_LEFT
+ uint32_t BTN_LEFT = 0x110;
+ uint32_t BTN_RIGHT = 0x111;
+ uint32_t BTN_MIDDLE = 0x112;
+#endif
+ switch (button) {
+ case Qt::LeftButton:
+ return BTN_LEFT;
+ case Qt::RightButton:
+ return BTN_RIGHT;
+ default:
+ return BTN_MIDDLE;
+ }
+}
+
DataDevice *InputDevice::dataDevice(struct wl_client *client) const
{
for (int i = 0; i < m_data_devices.size();i++) {
@@ -118,7 +285,6 @@ void InputDevice::input_device_attach(struct wl_client *client,
struct wl_input_device *device_base = reinterpret_cast<struct wl_input_device *>(device_resource->data);
struct wl_buffer *buffer = reinterpret_cast<struct wl_buffer *>(buffer_resource);
- qDebug() << "Client input device attach" << client << buffer << x << y;
InputDevice *inputDevice = wayland_cast<InputDevice *>(device_base);
if (wl_buffer_is_shm(buffer)) {
@@ -136,7 +302,6 @@ const struct wl_input_device_interface InputDevice::input_device_interface = {
void InputDevice::destroy_resource(wl_resource *resource)
{
- qDebug() << "input device resource destroy" << resource;
InputDevice *input_device = static_cast<InputDevice *>(resource->data);
if (input_device->base()->keyboard_focus_resource == resource) {
input_device->base()->keyboard_focus_resource = 0;
diff --git a/src/compositor/wayland_wrapper/wlinputdevice.h b/src/compositor/wayland_wrapper/wlinputdevice.h
index c70e835e7..9bf11ba12 100644
--- a/src/compositor/wayland_wrapper/wlinputdevice.h
+++ b/src/compositor/wayland_wrapper/wlinputdevice.h
@@ -46,6 +46,10 @@
#include <stdint.h>
#include <QtCore/QList>
+#include <QtCore/QPoint>
+
+class QTouchEvent;
+class WaylandInputDevice;
namespace Wayland {
@@ -57,13 +61,41 @@ class DataDeviceManager;
class InputDevice : public Object<struct wl_input_device>
{
public:
- InputDevice(Compositor *compositor);
+ InputDevice(WaylandInputDevice *handle, Compositor *compositor);
+
+ void sendMousePressEvent(Qt::MouseButton button, const QPoint &localPos, const QPoint &globalPos = QPoint());
+ void sendMouseReleaseEvent(Qt::MouseButton button, const QPoint &localPos, const QPoint &globalPos = QPoint());
+ void sendMouseMoveEvent(const QPoint &localPos, const QPoint &globalPos = QPoint());
+ void sendMouseMoveEvent(Surface *surface, const QPoint &localPos, const QPoint &globalPos = QPoint());
+
+ void sendKeyPressEvent(uint code);
+ void sendKeyReleaseEvent(uint code);
+
+ void sendTouchPointEvent(int id, int x, int y, Qt::TouchPointState state);
+ void sendTouchFrameEvent();
+ void sendTouchCancelEvent();
+
+ void sendFullTouchEvent(QTouchEvent *event);
+
+ Surface *keyboardFocus() const;
+ void setKeyboardFocus(Surface *surface);
+
+ Surface *mouseFocus() const;
+ void setMouseFocus(Surface *surface, const QPoint &localPos, const QPoint &globalPos);
void clientRequestedDataDevice(DataDeviceManager *dndSelection, struct wl_client *client, uint32_t id);
DataDevice *dataDevice(struct wl_client *client) const;
-
void sendSelectionFocus(Surface *surface);
+ Compositor *compositor() const;
+ WaylandInputDevice *handle() const;
+private:
+ WaylandInputDevice *m_handle;
+ Compositor *m_compositor;
+ QList<DataDevice *>m_data_devices;
+
+ uint32_t toWaylandButton(Qt::MouseButton button);
+
static void bind_func(struct wl_client *client, void *data,
uint32_t version, uint32_t id);
static void input_device_attach(struct wl_client *client,
@@ -72,11 +104,6 @@ public:
struct wl_resource *buffer, int32_t x, int32_t y);
const static struct wl_input_device_interface input_device_interface;
static void destroy_resource(struct wl_resource *resource);
-
-private:
- Compositor *m_compositor;
- QList<DataDevice *>m_data_devices;
-
};
}
diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp
index c81f746bc..629404b6e 100644
--- a/src/compositor/wayland_wrapper/wlsurface.cpp
+++ b/src/compositor/wayland_wrapper/wlsurface.cpp
@@ -604,24 +604,6 @@ void Surface::setWindowProperty(const QString &name, const QVariant &value, bool
}
}
-uint32_t toWaylandButton(Qt::MouseButton button)
-{
-#ifndef BTN_LEFT
-uint32_t BTN_LEFT = 0x110;
-uint32_t BTN_RIGHT = 0x111;
-uint32_t BTN_MIDDLE = 0x112;
-#endif
- switch (button) {
- case Qt::LeftButton:
- return BTN_LEFT;
- case Qt::RightButton:
- return BTN_RIGHT;
- default:
- return BTN_MIDDLE;
- }
-
-}
-
QPoint Surface::lastMousePos() const
{
Q_D(const Surface);
@@ -664,131 +646,10 @@ ShellSurface *Surface::shellSurface() const
return d->shellSurface;
}
-void Surface::sendMousePressEvent(int x, int y, Qt::MouseButton button)
-{
- sendMousePressEvent(x,y,x,y,button);
-}
-
-void Surface::sendMousePressEvent(int global_x, int global_y, int local_x, int local_y, Qt::MouseButton button)
-{
- Q_D(Surface);
- sendMouseMoveEvent(global_x,global_y,local_x,local_y);
- uint32_t time = d->compositor->currentTimeMsecs();
- struct wl_resource *pointer_focus_resource = d->compositor->defaultInputDevice()->base()->pointer_focus_resource;
- if (pointer_focus_resource) {
- wl_resource_post_event(d->compositor->defaultInputDevice()->base()->pointer_focus_resource,
- WL_INPUT_DEVICE_BUTTON, time, toWaylandButton(button), 1);
- }
-}
-
-void Surface::sendMouseReleaseEvent(int x, int y, Qt::MouseButton button)
-{
- sendMouseReleaseEvent(x,y,x,y,button);
-}
-
-void Surface::sendMouseReleaseEvent(int global_x, int global_y, int local_x, int local_y, Qt::MouseButton button)
-{
- Q_D(Surface);
- sendMouseMoveEvent(global_x,global_y,local_x, local_y);
- uint32_t time = d->compositor->currentTimeMsecs();
- struct wl_resource *pointer_focus_resource = d->compositor->defaultInputDevice()->base()->pointer_focus_resource;
- if (pointer_focus_resource) {
- wl_resource_post_event(pointer_focus_resource,
- WL_INPUT_DEVICE_BUTTON, time, toWaylandButton(button), 0);
- }
-}
-
-void Surface::sendMouseMoveEvent(int x, int y)
-{
- sendMouseMoveEvent(x,y,x,y);
-}
-
-void Surface::sendMouseMoveEvent(int global_x, int global_y, int local_x, int local_y)
-{
- Q_D(Surface);
- d->lastLocalMousePos = QPoint(local_x, local_y);
- d->lastGlobalMousePos = QPoint(global_x, global_y);
- uint32_t time = d->compositor->currentTimeMsecs();
- d->compositor->setPointerFocus(this, d->lastGlobalMousePos, d->lastLocalMousePos);
- struct wl_resource *pointer_focus_resource = d->compositor->defaultInputDevice()->base()->pointer_focus_resource;
- if (pointer_focus_resource) {
- wl_resource_post_event(pointer_focus_resource,
- WL_INPUT_DEVICE_MOTION, time, global_x, global_y, local_x, local_y);
- }
-}
-
-void Surface::sendKeyPressEvent(uint code)
-{
- Q_D(Surface);
- if (d->compositor->defaultInputDevice()->base()->keyboard_focus_resource != NULL) {
- uint32_t time = d->compositor->currentTimeMsecs();
- wl_resource_post_event(d->compositor->defaultInputDevice()->base()->keyboard_focus_resource,
- WL_INPUT_DEVICE_KEY, time, code - 8, 1);
- }
-}
-
-void Surface::sendKeyReleaseEvent(uint code)
-{
- Q_D(Surface);
- if (d->compositor->defaultInputDevice()->base()->keyboard_focus_resource != NULL) {
- uint32_t time = d->compositor->currentTimeMsecs();
- wl_resource_post_event(d->compositor->defaultInputDevice()->base()->keyboard_focus_resource,
- WL_INPUT_DEVICE_KEY, time, code - 8, 0);
- }
-}
-
-void Surface::sendTouchPointEvent(int id, int x, int y, Qt::TouchPointState state)
-{
- Q_D(Surface);
- uint32_t time = d->compositor->currentTimeMsecs();
- struct wl_resource *resource = d->compositor->defaultInputDevice()->base()->pointer_focus_resource;
- switch (state) {
- case Qt::TouchPointPressed:
- wl_resource_post_event(resource, WL_INPUT_DEVICE_TOUCH_DOWN, time, this, id, x, y);
- break;
- case Qt::TouchPointMoved:
- wl_resource_post_event(resource, WL_INPUT_DEVICE_TOUCH_MOTION, time, id, x, y);
- break;
- case Qt::TouchPointReleased:
- wl_resource_post_event(resource, WL_INPUT_DEVICE_TOUCH_UP, time, id);
- break;
- case Qt::TouchPointStationary:
- // stationary points are not sent through wayland, the client must cache them
- break;
- default:
- break;
- }
-}
-
-void Surface::sendTouchFrameEvent()
-{
- Q_D(Surface);
- struct wl_resource *resource = d->compositor->defaultInputDevice()->base()->pointer_focus_resource;
- wl_resource_post_event(resource,
- WL_INPUT_DEVICE_TOUCH_FRAME);
-}
-
-void Surface::sendTouchCancelEvent()
+Compositor *Surface::compositor() const
{
- Q_D(Surface);
- struct wl_resource *resource = d->compositor->defaultInputDevice()->base()->pointer_focus_resource;
- wl_resource_post_event(resource,
- WL_INPUT_DEVICE_TOUCH_CANCEL);
-}
-
-void Surface::sendFullTouchEvent(QTouchEvent *event)
-{
- const QList<QTouchEvent::TouchPoint> points = event->touchPoints();
- if (points.isEmpty())
- return;
- const int pointCount = points.count();
- for (int i = 0; i < pointCount; ++i) {
- const QTouchEvent::TouchPoint &tp(points.at(i));
- // Convert the local pos in the compositor window to surface-relative.
- QPoint p = (tp.pos() - pos()).toPoint();
- sendTouchPointEvent(tp.id(), p.x(), p.y(), tp.state());
- }
- sendTouchFrameEvent();
+ Q_D(const Surface);
+ return d->compositor;
}
void Surface::sendFrameCallback()
@@ -813,12 +674,6 @@ void Surface::frameFinished()
d->compositor->frameFinished(this);
}
-void Surface::setInputFocus()
-{
- Q_D(Surface);
- d->compositor->setInputFocus(this);
-}
-
void Surface::sendOnScreenVisibilityChange(bool visible)
{
Q_D(Surface);
diff --git a/src/compositor/wayland_wrapper/wlsurface.h b/src/compositor/wayland_wrapper/wlsurface.h
index 06dd3bdb0..c0066bb2a 100644
--- a/src/compositor/wayland_wrapper/wlsurface.h
+++ b/src/compositor/wayland_wrapper/wlsurface.h
@@ -97,27 +97,9 @@ public:
GLuint textureId(QOpenGLContext *context) const;
#endif
- void sendMousePressEvent(int x, int y, Qt::MouseButton button);
- void sendMousePressEvent(int global_x, int global_y, int local_x, int local_y, Qt::MouseButton button);
- void sendMouseReleaseEvent(int x, int y, Qt::MouseButton button);
- void sendMouseReleaseEvent(int global_x, int global_y, int local_x, int local_y, Qt::MouseButton button);
- void sendMouseMoveEvent(int x, int y);
- void sendMouseMoveEvent(int global_x, int global_y, int local_x, int local_y);
-
-
- void sendKeyPressEvent(uint code);
- void sendKeyReleaseEvent(uint code);
-
- void sendTouchPointEvent(int id, int x, int y, Qt::TouchPointState state);
- void sendTouchFrameEvent();
- void sendTouchCancelEvent();
-
- void sendFullTouchEvent(QTouchEvent *event);
-
void sendFrameCallback();
void frameFinished();
- void setInputFocus();
void sendOnScreenVisibilityChange(bool visible);
@@ -143,6 +125,8 @@ public:
void setShellSurface(ShellSurface *shellSurface);
ShellSurface *shellSurface() const;
+ Compositor *compositor() const;
+
static const struct wl_surface_interface surface_interface;
protected:
QScopedPointer<SurfacePrivate> d_ptr;