diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2012-02-29 16:36:05 +0100 |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2012-03-05 08:55:30 +0100 |
commit | d36a08d97f03888ffcb77950708195474e7e30d9 (patch) | |
tree | ef8804d51b56393565f5284c0236e009f6a7fafd /src | |
parent | edd424d1ed41434f979abe42428ed74c664d59a2 (diff) |
Upgrade to newer wayland SHA-1.
Change-Id: If0c1d86a3011e266cafabeb875bc5616191a8cf4
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src')
18 files changed, 356 insertions, 95 deletions
diff --git a/src/compositor/wayland_wrapper/wayland_wrapper.pri b/src/compositor/wayland_wrapper/wayland_wrapper.pri index 9e4f99e58..abf4d649f 100644 --- a/src/compositor/wayland_wrapper/wayland_wrapper.pri +++ b/src/compositor/wayland_wrapper/wayland_wrapper.pri @@ -22,7 +22,8 @@ HEADERS += \ $$PWD/wlsubsurface.h \ $$PWD/wltouch.h \ $$PWD/../../shared/qwaylandmimehelper.h \ - $$PWD/wlsurfacebuffer.h + $$PWD/wlsurfacebuffer.h \ + $$PWD/wlregion.h SOURCES += \ $$PWD/wlcompositor.cpp \ @@ -41,7 +42,8 @@ SOURCES += \ $$PWD/wlsubsurface.cpp \ $$PWD/wltouch.cpp \ $$PWD/../../shared/qwaylandmimehelper.cpp \ - $$PWD/wlsurfacebuffer.cpp + $$PWD/wlsurfacebuffer.cpp \ + $$PWD/wlregion.cpp INCLUDEPATH += $$PWD INCLUDEPATH += $$PWD/../../shared diff --git a/src/compositor/wayland_wrapper/wlcompositor.cpp b/src/compositor/wayland_wrapper/wlcompositor.cpp index 46bb1138f..6cd9a3dcb 100644 --- a/src/compositor/wayland_wrapper/wlcompositor.cpp +++ b/src/compositor/wayland_wrapper/wlcompositor.cpp @@ -53,6 +53,7 @@ #include "wlshellsurface.h" #include "wltouch.h" #include "wlinputdevice.h" +#include "wlregion.h" #include <QWindow> #include <QSocketNotifier> @@ -89,8 +90,16 @@ void compositor_create_surface(struct wl_client *client, static_cast<Compositor *>(resource->data)->createSurface(client,id); } +void compositor_create_region(struct wl_client *client, + struct wl_resource *compositor, uint32_t id) +{ + Q_UNUSED(compositor); + new Region(client, id); +} + const static struct wl_compositor_interface compositor_interface = { - compositor_create_surface + compositor_create_surface, + compositor_create_region }; void Compositor::bind_func(struct wl_client *client, void *data, diff --git a/src/compositor/wayland_wrapper/wldatadevice.cpp b/src/compositor/wayland_wrapper/wldatadevice.cpp index 06c036ec6..abcf67b45 100644 --- a/src/compositor/wayland_wrapper/wldatadevice.cpp +++ b/src/compositor/wayland_wrapper/wldatadevice.cpp @@ -54,34 +54,19 @@ void DataDevice::start_drag(struct wl_client *client, struct wl_resource *resource, struct wl_resource *source, struct wl_resource *surface, + struct wl_resource *icon, uint32_t time) { Q_UNUSED(client); Q_UNUSED(surface); + Q_UNUSED(icon); Q_UNUSED(time); - DataDevice *data_device = static_cast<DataDevice *>(resource->data); DataSource *data_source = static_cast<DataSource *>(source->data); - Q_UNUSED(data_device); Q_UNUSED(data_source); } -void DataDevice::attach(struct wl_client *client, - struct wl_resource *resource, - uint32_t time, - struct wl_resource *buffer, - int32_t x, - int32_t y) -{ - Q_UNUSED(client); - Q_UNUSED(resource); - Q_UNUSED(time); - Q_UNUSED(buffer); - Q_UNUSED(x); - Q_UNUSED(y); -} - void DataDevice::set_selection(struct wl_client *client, struct wl_resource *data_device_resource, struct wl_resource *source, @@ -98,7 +83,6 @@ void DataDevice::set_selection(struct wl_client *client, const struct wl_data_device_interface DataDevice::data_device_interface = { DataDevice::start_drag, - DataDevice::attach, DataDevice::set_selection }; diff --git a/src/compositor/wayland_wrapper/wldatadevice.h b/src/compositor/wayland_wrapper/wldatadevice.h index 8cdec5233..373820c29 100644 --- a/src/compositor/wayland_wrapper/wldatadevice.h +++ b/src/compositor/wayland_wrapper/wldatadevice.h @@ -69,13 +69,8 @@ private: struct wl_resource *resource, struct wl_resource *source, struct wl_resource *surface, + struct wl_resource *icon, uint32_t time); - static void attach(struct wl_client *client, - struct wl_resource *resource, - uint32_t time, - struct wl_resource *buffer, - int32_t x, - int32_t y); static void set_selection(struct wl_client *client, struct wl_resource *resource, struct wl_resource *source, diff --git a/src/compositor/wayland_wrapper/wlinputdevice.cpp b/src/compositor/wayland_wrapper/wlinputdevice.cpp index 57d1e3d9a..e9d879766 100644 --- a/src/compositor/wayland_wrapper/wlinputdevice.cpp +++ b/src/compositor/wayland_wrapper/wlinputdevice.cpp @@ -223,10 +223,10 @@ Surface *InputDevice::mouseFocus() const void InputDevice::setMouseFocus(Surface *surface, const QPoint &globalPos, const QPoint &localPos) { + Q_UNUSED(globalPos); wl_input_device_set_pointer_focus(base(), surface ? surface->base() : 0, m_compositor->currentTimeMsecs(), - globalPos.x(), globalPos.y(), localPos.x(), localPos.y()); } diff --git a/src/compositor/wayland_wrapper/wlregion.cpp b/src/compositor/wayland_wrapper/wlregion.cpp new file mode 100644 index 000000000..7553da7af --- /dev/null +++ b/src/compositor/wayland_wrapper/wlregion.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "wlregion.h" + +#include "wlcompositor.h" + +namespace Wayland { + +void destroy_region(struct wl_resource *resource) +{ + delete resolve<Region>(resource); +} + +Region::Region(struct wl_client *client, uint32_t id) +{ + addClientResource(client, base(), id, &wl_region_interface, + ®ion_interface, destroy_region); +} + +Region::~Region() +{ +} + +const struct wl_region_interface Region::region_interface = { + region_destroy, + region_add, + region_subtract +}; + +void Region::region_destroy(wl_client *client, wl_resource *region) +{ + Q_UNUSED(client); + wl_resource_destroy(region, Compositor::currentTimeMsecs()); +} + +void Region::region_add(wl_client *client, wl_resource *region, + int32_t x, int32_t y, int32_t w, int32_t h) +{ + Q_UNUSED(client); + resolve<Region>(region)->m_region += QRect(x, y, w, h); +} + +void Region::region_subtract(wl_client *client, wl_resource *region, + int32_t x, int32_t y, int32_t w, int32_t h) +{ + Q_UNUSED(client); + resolve<Region>(region)->m_region -= QRect(x, y, w, h); +} + +} + + diff --git a/src/compositor/wayland_wrapper/wlregion.h b/src/compositor/wayland_wrapper/wlregion.h new file mode 100644 index 000000000..d2f083a44 --- /dev/null +++ b/src/compositor/wayland_wrapper/wlregion.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt Compositor. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WL_REGION_H +#define WL_REGION_H + +#include "waylandexport.h" +#include "waylandobject.h" + +#include <QRegion> + +#include <wayland-util.h> + +namespace Wayland { + +class Q_COMPOSITOR_EXPORT Region : public Object<wl_resource> +{ +public: + Region(struct wl_client *client, uint32_t id); + ~Region(); + + uint id() const { return base()->object.id; } + + QRegion region() const { return m_region; } + + static const struct wl_region_interface region_interface; + +private: + Q_DISABLE_COPY(Region) + + QRegion m_region; + + static void region_destroy(wl_client *client, wl_resource *region); + static void region_add(wl_client *client, wl_resource *region, + int32_t x, int32_t y, int32_t w, int32_t h); + static void region_subtract(wl_client *client, wl_resource *region, + int32_t x, int32_t y, int32_t w, int32_t h); +}; + +} + +#endif // WL_REGION_H + diff --git a/src/compositor/wayland_wrapper/wlshellsurface.cpp b/src/compositor/wayland_wrapper/wlshellsurface.cpp index 39c60a2ee..ea4b54b62 100644 --- a/src/compositor/wayland_wrapper/wlshellsurface.cpp +++ b/src/compositor/wayland_wrapper/wlshellsurface.cpp @@ -134,10 +134,16 @@ void ShellSurface::set_transient(struct wl_client *client, } void ShellSurface::set_fullscreen(struct wl_client *client, - struct wl_resource *shell_surface_resource) + struct wl_resource *shell_surface_resource, + uint32_t method, + uint32_t framerate, + struct wl_resource *output) { Q_UNUSED(client); Q_UNUSED(shell_surface_resource); + Q_UNUSED(method); + Q_UNUSED(framerate); + Q_UNUSED(output); } void ShellSurface::set_popup(wl_client *client, wl_resource *resource, wl_resource *input_device, uint32_t time, wl_resource *parent, int32_t x, int32_t y, uint32_t flags) @@ -152,14 +158,23 @@ void ShellSurface::set_popup(wl_client *client, wl_resource *resource, wl_resour Q_UNUSED(flags); } +void ShellSurface::set_maximized(struct wl_client *client, + struct wl_resource *shell_surface_resource, + struct wl_resource *output) +{ + Q_UNUSED(client); + Q_UNUSED(shell_surface_resource); + Q_UNUSED(output); +} + const struct wl_shell_surface_interface ShellSurface::shell_surface_interface = { ShellSurface::move, ShellSurface::resize, ShellSurface::set_toplevel, ShellSurface::set_transient, ShellSurface::set_fullscreen, - ShellSurface::set_popup - + ShellSurface::set_popup, + ShellSurface::set_maximized }; } diff --git a/src/compositor/wayland_wrapper/wlshellsurface.h b/src/compositor/wayland_wrapper/wlshellsurface.h index 0f2469c57..a4eacd7b1 100644 --- a/src/compositor/wayland_wrapper/wlshellsurface.h +++ b/src/compositor/wayland_wrapper/wlshellsurface.h @@ -91,7 +91,10 @@ private: int y, uint32_t flags); static void set_fullscreen(struct wl_client *client, - struct wl_resource *shell_surface_resource); + struct wl_resource *shell_surface_resource, + uint32_t method, + uint32_t framerate, + struct wl_resource *output); static void set_popup(struct wl_client *client, struct wl_resource *resource, struct wl_resource *input_device, @@ -100,6 +103,9 @@ private: int32_t x, int32_t y, uint32_t flags); + static void set_maximized(struct wl_client *client, + struct wl_resource *shell_surface_resource, + struct wl_resource *output); static const struct wl_shell_surface_interface shell_surface_interface; diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp index f7721c1a7..4bfe521a4 100644 --- a/src/compositor/wayland_wrapper/wlsurface.cpp +++ b/src/compositor/wayland_wrapper/wlsurface.cpp @@ -47,6 +47,7 @@ #include "wlshmbuffer.h" #include "wlinputdevice.h" #include "wlextendedsurface.h" +#include "wlregion.h" #include "wlsubsurface.h" #include "wlsurfacebuffer.h" #include "wlshellsurface.h" @@ -83,6 +84,8 @@ Surface::Surface(struct wl_client *client, uint32_t id, Compositor *compositor) , m_extendedSurface(0) , m_subSurface(0) , m_shellSurface(0) + , m_inputRegion(0) + , m_opaqueRegion(0) { wl_list_init(&m_frame_callback_list); addClientResource(client, &base()->resource, id, &wl_surface_interface, @@ -164,10 +167,22 @@ QSize Surface::size() const void Surface::setSize(const QSize &size) { - bool emitChange = size != m_size; - m_size = size; - if (emitChange) + if (size != m_size) { + m_opaqueRegion = QRegion(); + m_inputRegion = QRegion(QRect(QPoint(), size)); + m_size = size; m_waylandSurface->sizeChanged(); + } +} + +QRegion Surface::inputRegion() const +{ + return m_inputRegion; +} + +QRegion Surface::opaqueRegion() const +{ + return m_opaqueRegion; } QImage Surface::image() const @@ -403,7 +418,9 @@ const struct wl_surface_interface Surface::surface_interface = { Surface::surface_destroy, Surface::surface_attach, Surface::surface_damage, - Surface::surface_frame + Surface::surface_frame, + Surface::surface_set_opaque_region, + Surface::surface_set_input_region }; void Surface::surface_destroy(struct wl_client *, struct wl_resource *surface_resource) @@ -436,5 +453,21 @@ void Surface::surface_frame(struct wl_client *client, wl_list_insert(&surface->m_frame_callback_list,&frame_callback->link); } +void Surface::surface_set_opaque_region(struct wl_client *client, struct wl_resource *surfaceResource, + struct wl_resource *region) +{ + Q_UNUSED(client); + Surface *surface = resolve<Surface>(surfaceResource); + surface->m_opaqueRegion = region ? resolve<Region>(region)->region() : QRegion(); +} + +void Surface::surface_set_input_region(struct wl_client *client, struct wl_resource *surfaceResource, + struct wl_resource *region) +{ + Q_UNUSED(client); + Surface *surface = resolve<Surface>(surfaceResource); + surface->m_inputRegion = region ? resolve<Region>(region)->region() : QRegion(QRect(QPoint(), surface->size())); +} + } // namespace Wayland diff --git a/src/compositor/wayland_wrapper/wlsurface.h b/src/compositor/wayland_wrapper/wlsurface.h index 7ad0bcd53..0d917cbd8 100644 --- a/src/compositor/wayland_wrapper/wlsurface.h +++ b/src/compositor/wayland_wrapper/wlsurface.h @@ -91,6 +91,9 @@ public: QSize size() const; void setSize(const QSize &size); + QRegion inputRegion() const; + QRegion opaqueRegion() const; + QImage image() const; #ifdef QT_COMPOSITOR_WAYLAND_GL @@ -138,6 +141,9 @@ private: SubSurface *m_subSurface; ShellSurface *m_shellSurface; + QRegion m_inputRegion; + QRegion m_opaqueRegion; + static const int buffer_pool_size = 3; SurfaceBuffer *m_bufferPool[buffer_pool_size]; @@ -161,6 +167,10 @@ private: int32_t x, int32_t y, int32_t width, int32_t height); static void surface_frame(struct wl_client *client, struct wl_resource *resource, uint32_t callback); + static void surface_set_opaque_region(struct wl_client *client, struct wl_resource *resource, + struct wl_resource *region); + static void surface_set_input_region(struct wl_client *client, struct wl_resource *resource, + struct wl_resource *region); }; diff --git a/src/plugins/platforms/wayland/qwaylanddatadevicemanager.cpp b/src/plugins/platforms/wayland/qwaylanddatadevicemanager.cpp index 3b82ee55f..5f5c13682 100644 --- a/src/plugins/platforms/wayland/qwaylanddatadevicemanager.cpp +++ b/src/plugins/platforms/wayland/qwaylanddatadevicemanager.cpp @@ -194,7 +194,8 @@ QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, u , m_drag_data_offer(0) , m_drag_data_source(0) , m_drag_surface(0) - , m_drag_buffer(0) + , m_drag_icon_surface(0) + , m_drag_icon_buffer(0) , m_drag_can_drop(false) { m_data_device_manager = static_cast<struct wl_data_device_manager *>(wl_display_bind(display->wl_display(),id,&wl_data_device_manager_interface)); @@ -253,16 +254,18 @@ void QWaylandDataDeviceManager::createAndSetDrag(QDrag *drag) if (pixmap.isNull()) { // pixmap = QPlatformDrag::defaultPixmap(); } - m_drag_buffer = new QWaylandShmBuffer(m_display,pixmap.size(),QImage::Format_ARGB32_Premultiplied); + + m_drag_icon_buffer = new QWaylandShmBuffer(m_display, pixmap.size(), QImage::Format_ARGB32_Premultiplied); { - QPainter p(m_drag_buffer->image()); + QPainter p(m_drag_icon_buffer->image()); p.drawPixmap(0,0,pixmap); } - wl_data_device_start_drag(transfer_device,m_drag_data_source->handle(),m_drag_surface,QWaylandDisplay::currentTimeMillisec()); - wl_data_device_attach(transfer_device,QWaylandDisplay::currentTimeMillisec() - ,m_drag_buffer->buffer(),drag->hotSpot().x(),drag->hotSpot().y()); + m_drag_icon_surface = wl_compositor_create_surface(m_display->wl_compositor()); + wl_surface_attach(m_drag_icon_surface, m_drag_icon_buffer->buffer(), -drag->hotSpot().x(), -drag->hotSpot().y()); + + wl_data_device_start_drag(transfer_device, m_drag_data_source->handle(), m_drag_surface, m_drag_icon_surface, QWaylandDisplay::currentTimeMillisec()); } QMimeData *QWaylandDataDeviceManager::dragMime() const @@ -283,6 +286,7 @@ bool QWaylandDataDeviceManager::canDropDrag() const void QWaylandDataDeviceManager::cancelDrag() { wl_data_source_destroy(m_drag_data_source->handle() ); + wl_surface_destroy(m_drag_icon_surface); m_drag_data_source = 0; } diff --git a/src/plugins/platforms/wayland/qwaylanddatadevicemanager.h b/src/plugins/platforms/wayland/qwaylanddatadevicemanager.h index 4382ba2fe..21d8bfbfa 100644 --- a/src/plugins/platforms/wayland/qwaylanddatadevicemanager.h +++ b/src/plugins/platforms/wayland/qwaylanddatadevicemanager.h @@ -88,8 +88,9 @@ private: QWaylandDataOffer *m_drag_data_offer; QWaylandDataSource *m_drag_data_source; QWaylandWindow *m_drag_current_event_window; - struct wl_surface *m_drag_surface; - QWaylandShmBuffer *m_drag_buffer; + wl_surface *m_drag_surface; + wl_surface *m_drag_icon_surface; + QWaylandShmBuffer *m_drag_icon_buffer; bool m_drag_can_drop; uint32_t m_drag_last_event_time; QPoint m_drag_position; diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 73b46c459..223b547fa 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -166,7 +166,7 @@ QWaylandDisplay::~QWaylandDisplay(void) #ifdef QT_WAYLAND_GL_SUPPORT delete mEglIntegration; #endif - wl_display_destroy(mDisplay); + wl_display_disconnect(mDisplay); } void QWaylandDisplay::createNewScreen(struct wl_output *output, QRect geometry) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index ed9cc55c3..2a6f83268 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -88,6 +88,7 @@ public: void setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y); struct wl_display *wl_display() const { return mDisplay; } + struct wl_compositor *wl_compositor() const { return mCompositor; } QWaylandShell *shell() const { return mShell; } diff --git a/src/plugins/platforms/wayland/qwaylanddnd.cpp b/src/plugins/platforms/wayland/qwaylanddnd.cpp index 325c1fd34..79fc9aead 100644 --- a/src/plugins/platforms/wayland/qwaylanddnd.cpp +++ b/src/plugins/platforms/wayland/qwaylanddnd.cpp @@ -61,6 +61,7 @@ QMimeData * QWaylandDrag::platformDropData() Qt::DropAction QWaylandDrag::drag(QDrag *m_drag) { + Q_UNUSED(m_drag); // m_display->dndSelectionHandler()->createAndSetDrag(drag); return Qt::IgnoreAction; } diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index 1f66ea91c..98980e6d7 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -124,7 +124,6 @@ struct wl_data_device *QWaylandInputDevice::transferDevice() const void QWaylandInputDevice::inputHandleMotion(void *data, struct wl_input_device *input_device, uint32_t time, - int32_t x, int32_t y, int32_t surface_x, int32_t surface_y) { Q_UNUSED(input_device); @@ -137,13 +136,14 @@ void QWaylandInputDevice::inputHandleMotion(void *data, return; } - inputDevice->mSurfacePos = QPoint(surface_x, surface_y); - inputDevice->mGlobalPos = QPoint(x, y); + QPoint pos(surface_x, surface_y); + QPoint global = window->window()->mapToGlobal(pos); + + inputDevice->mSurfacePos = pos; + inputDevice->mGlobalPos = global; inputDevice->mTime = time; QWindowSystemInterface::handleMouseEvent(window->window(), - time, - inputDevice->mSurfacePos, - inputDevice->mGlobalPos, + time, pos, global, inputDevice->mButtons); } @@ -323,39 +323,48 @@ void QWaylandInputDevice::inputHandleKey(void *data, #endif } -void QWaylandInputDevice::inputHandlePointerFocus(void *data, - struct wl_input_device *input_device, - uint32_t time, struct wl_surface *surface, - int32_t x, int32_t y, int32_t sx, int32_t sy) +void QWaylandInputDevice::inputHandlePointerEnter(void *data, + struct wl_input_device *input_device, + uint32_t time, struct wl_surface *surface, + int32_t sx, int32_t sy) { Q_UNUSED(input_device); - Q_UNUSED(x); - Q_UNUSED(y); Q_UNUSED(sx); Q_UNUSED(sy); QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; - QWaylandWindow *window; - if (inputDevice->mPointerFocus) { - window = inputDevice->mPointerFocus; - QWindowSystemInterface::handleLeaveEvent(window->window()); - inputDevice->mPointerFocus = NULL; - } + // shouldn't get pointer leave with no surface + Q_ASSERT(surface); - if (surface) { - window = (QWaylandWindow *) wl_surface_get_user_data(surface); - QWindowSystemInterface::handleEnterEvent(window->window()); - inputDevice->mPointerFocus = window; - } + QWaylandWindow *window = (QWaylandWindow *) wl_surface_get_user_data(surface); + QWindowSystemInterface::handleEnterEvent(window->window()); + inputDevice->mPointerFocus = window; inputDevice->mTime = time; } -void QWaylandInputDevice::inputHandleKeyboardFocus(void *data, - struct wl_input_device *input_device, - uint32_t time, - struct wl_surface *surface, - struct wl_array *keys) +void QWaylandInputDevice::inputHandlePointerLeave(void *data, + struct wl_input_device *input_device, + uint32_t time, struct wl_surface *surface) +{ + Q_UNUSED(input_device); + QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; + + // shouldn't get pointer leave with no surface + Q_ASSERT(surface); + + QWaylandWindow *window = (QWaylandWindow *) wl_surface_get_user_data(surface); + QWindowSystemInterface::handleLeaveEvent(window->window()); + inputDevice->mPointerFocus = 0; + + inputDevice->mTime = time; +} + +void QWaylandInputDevice::inputHandleKeyboardEnter(void *data, + struct wl_input_device *input_device, + uint32_t time, + struct wl_surface *surface, + struct wl_array *keys) { Q_UNUSED(input_device); Q_UNUSED(time); @@ -378,16 +387,29 @@ void QWaylandInputDevice::inputHandleKeyboardFocus(void *data, Q_UNUSED(keys); #endif - if (surface) { - window = (QWaylandWindow *) wl_surface_get_user_data(surface); - inputDevice->mKeyboardFocus = window; - inputDevice->mQDisplay->setLastKeyboardFocusInputDevice(inputDevice); - QWindowSystemInterface::handleWindowActivated(window->window()); - } else { - inputDevice->mKeyboardFocus = NULL; - inputDevice->mQDisplay->setLastKeyboardFocusInputDevice(0); - QWindowSystemInterface::handleWindowActivated(0); - } + // shouldn't get keyboard enter with no surface + Q_ASSERT(surface); + + window = (QWaylandWindow *) wl_surface_get_user_data(surface); + inputDevice->mKeyboardFocus = window; + inputDevice->mQDisplay->setLastKeyboardFocusInputDevice(inputDevice); + QWindowSystemInterface::handleWindowActivated(window->window()); +} + +void QWaylandInputDevice::inputHandleKeyboardLeave(void *data, + struct wl_input_device *input_device, + uint32_t time, + struct wl_surface *surface) +{ + Q_UNUSED(input_device); + Q_UNUSED(time); + Q_UNUSED(surface); + + QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; + + inputDevice->mKeyboardFocus = NULL; + inputDevice->mQDisplay->setLastKeyboardFocusInputDevice(0); + QWindowSystemInterface::handleWindowActivated(0); } void QWaylandInputDevice::inputHandleTouchDown(void *data, @@ -536,8 +558,10 @@ const struct wl_input_device_listener QWaylandInputDevice::inputDeviceListener = QWaylandInputDevice::inputHandleMotion, QWaylandInputDevice::inputHandleButton, QWaylandInputDevice::inputHandleKey, - QWaylandInputDevice::inputHandlePointerFocus, - QWaylandInputDevice::inputHandleKeyboardFocus, + QWaylandInputDevice::inputHandlePointerEnter, + QWaylandInputDevice::inputHandlePointerLeave, + QWaylandInputDevice::inputHandleKeyboardEnter, + QWaylandInputDevice::inputHandleKeyboardLeave, QWaylandInputDevice::inputHandleTouchDown, QWaylandInputDevice::inputHandleTouchUp, QWaylandInputDevice::inputHandleTouchMotion, diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.h b/src/plugins/platforms/wayland/qwaylandinputdevice.h index abdd49794..52e80a64f 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.h +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.h @@ -87,7 +87,6 @@ private: static void inputHandleMotion(void *data, struct wl_input_device *input_device, uint32_t time, - int32_t x, int32_t y, int32_t sx, int32_t sy); static void inputHandleButton(void *data, struct wl_input_device *input_device, @@ -95,15 +94,22 @@ private: static void inputHandleKey(void *data, struct wl_input_device *input_device, uint32_t time, uint32_t key, uint32_t state); - static void inputHandlePointerFocus(void *data, - struct wl_input_device *input_device, - uint32_t time, struct wl_surface *surface, - int32_t x, int32_t y, int32_t sx, int32_t sy); - static void inputHandleKeyboardFocus(void *data, - struct wl_input_device *input_device, - uint32_t time, - struct wl_surface *surface, - struct wl_array *keys); + static void inputHandlePointerEnter(void *data, + struct wl_input_device *input_device, + uint32_t time, struct wl_surface *surface, + int32_t sx, int32_t sy); + static void inputHandlePointerLeave(void *data, + struct wl_input_device *input_device, + uint32_t time, struct wl_surface *surface); + static void inputHandleKeyboardEnter(void *data, + struct wl_input_device *input_device, + uint32_t time, + struct wl_surface *surface, + struct wl_array *keys); + static void inputHandleKeyboardLeave(void *data, + struct wl_input_device *input_device, + uint32_t time, + struct wl_surface *surface); static void inputHandleTouchDown(void *data, struct wl_input_device *wl_input_device, uint32_t time, |