diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/client.pro | 5 | ||||
-rw-r--r-- | src/client/qwaylandcursor.cpp | 2 | ||||
-rw-r--r-- | src/client/qwaylanddisplay.cpp | 21 | ||||
-rw-r--r-- | src/client/qwaylanddisplay_p.h | 6 | ||||
-rw-r--r-- | src/client/qwaylanddnd.cpp | 8 | ||||
-rw-r--r-- | src/client/qwaylanddnd_p.h | 4 | ||||
-rw-r--r-- | src/client/qwaylandextendedoutput.cpp | 53 | ||||
-rw-r--r-- | src/client/qwaylandextendedoutput_p.h | 58 | ||||
-rw-r--r-- | src/client/qwaylandinputdevice.cpp | 158 | ||||
-rw-r--r-- | src/client/qwaylandintegration.cpp | 4 | ||||
-rw-r--r-- | src/client/qwaylandscreen.cpp | 20 | ||||
-rw-r--r-- | src/client/qwaylandscreen_p.h | 5 | ||||
-rw-r--r-- | src/client/qwaylandsubsurface.cpp | 41 | ||||
-rw-r--r-- | src/client/qwaylandsubsurface_p.h | 14 | ||||
-rw-r--r-- | src/client/qwaylandwindow.cpp | 127 | ||||
-rw-r--r-- | src/client/qwaylandwindow_p.h | 5 | ||||
-rw-r--r-- | src/client/qwaylandwlshellsurface.cpp | 4 | ||||
-rw-r--r-- | src/client/qwaylandxdgsurface.cpp | 27 |
18 files changed, 149 insertions, 413 deletions
diff --git a/src/client/client.pro b/src/client/client.pro index 0c13a4a9b..ba17b21c5 100644 --- a/src/client/client.pro +++ b/src/client/client.pro @@ -46,7 +46,6 @@ WAYLANDCLIENTSOURCES += \ ../3rdparty/protocol/wayland.xml \ ../extensions/surface-extension.xml \ ../extensions/sub-surface-extension.xml \ - ../extensions/output-extension.xml \ ../extensions/touch-extension.xml \ ../extensions/qtkey-extension.xml \ ../extensions/windowmanager.xml \ @@ -71,12 +70,12 @@ SOURCES += qwaylandintegration.cpp \ qwaylandwlshellsurface.cpp \ qwaylandxdgshell.cpp \ qwaylandxdgsurface.cpp \ - qwaylandextendedoutput.cpp \ qwaylandextendedsurface.cpp \ qwaylandsubsurface.cpp \ qwaylandtouch.cpp \ qwaylandqtkey.cpp \ ../shared/qwaylandmimehelper.cpp \ + ../shared/qwaylandxkb.cpp \ qwaylandabstractdecoration.cpp \ qwaylanddecorationfactory.cpp \ qwaylanddecorationplugin.cpp \ @@ -104,12 +103,12 @@ HEADERS += qwaylandintegration_p.h \ qwaylandwlshellsurface_p.h \ qwaylandxdgshell_p.h \ qwaylandxdgsurface_p.h \ - qwaylandextendedoutput_p.h \ qwaylandextendedsurface_p.h \ qwaylandsubsurface_p.h \ qwaylandtouch_p.h \ qwaylandqtkey_p.h \ ../shared/qwaylandmimehelper.h \ + ../shared/qwaylandxkb.h \ qwaylandabstractdecoration_p.h \ qwaylanddecorationfactory_p.h \ qwaylanddecorationplugin_p.h \ diff --git a/src/client/qwaylandcursor.cpp b/src/client/qwaylandcursor.cpp index 8e8293a09..8dfc95c36 100644 --- a/src/client/qwaylandcursor.cpp +++ b/src/client/qwaylandcursor.cpp @@ -161,7 +161,7 @@ wl_cursor *QWaylandCursor::requestCursor(WaylandCursor shape) return NULL; QList<QByteArray> cursorNames = mCursorNamesMap.values(shape); - foreach (QByteArray name, cursorNames) { + foreach (const QByteArray &name, cursorNames) { cursor = wl_cursor_theme_get_cursor(mCursorTheme, name.constData()); if (cursor) { mCursors.insert(shape, cursor); diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index 0bea9af65..dbb8e12dd 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -50,7 +50,6 @@ #include "qwaylandshellintegration_p.h" #include "qwaylandclientbufferintegration_p.h" -#include "qwaylandextendedoutput_p.h" #include "qwaylandextendedsurface_p.h" #include "qwaylandsubsurface_p.h" #include "qwaylandtouch_p.h" @@ -101,6 +100,15 @@ struct ::wl_region *QWaylandDisplay::createRegion(const QRegion &qregion) return region; } +::wl_subsurface *QWaylandDisplay::createSubSurface(QWaylandWindow *window, QWaylandWindow *parent) +{ + if (!mSubCompositor) { + return NULL; + } + + return mSubCompositor->get_subsurface(window->object(), parent->object()); +} + QWaylandClientBufferIntegration * QWaylandDisplay::clientBufferIntegration() const { return mWaylandIntegration->clientBufferIntegration(); @@ -126,8 +134,7 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration) , mLastKeyboardFocusInputDevice(0) , mDndSelectionHandler(0) , mWindowExtension(0) - , mSubSurfaceExtension(0) - , mOutputExtension(0) + , mSubCompositor(0) , mTouchExtension(0) , mQtKeyExtension(0) , mTextInputManager(0) @@ -256,14 +263,10 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin mInputDevices.append(inputDevice); } else if (interface == QStringLiteral("wl_data_device_manager")) { mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id)); - } else if (interface == QStringLiteral("qt_output_extension")) { - mOutputExtension.reset(new QtWayland::qt_output_extension(registry, id, 1)); - foreach (QPlatformScreen *screen, screens()) - static_cast<QWaylandScreen *>(screen)->createExtendedOutput(); } else if (interface == QStringLiteral("qt_surface_extension")) { mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1)); - } else if (interface == QStringLiteral("qt_sub_surface_extension")) { - mSubSurfaceExtension.reset(new QtWayland::qt_sub_surface_extension(registry, id, 1)); + } else if (interface == QStringLiteral("wl_subcompositor")) { + mSubCompositor.reset(new QtWayland::wl_subcompositor(registry, id, 1)); } else if (interface == QStringLiteral("qt_touch_extension")) { mTouchExtension.reset(new QWaylandTouchExtension(this, id)); } else if (interface == QStringLiteral("qt_key_extension")) { diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h index ee129a50e..84c79d70d 100644 --- a/src/client/qwaylanddisplay_p.h +++ b/src/client/qwaylanddisplay_p.h @@ -100,6 +100,7 @@ public: struct wl_surface *createSurface(void *handle); QWaylandShellSurface *createShellSurface(QWaylandWindow *window); struct ::wl_region *createRegion(const QRegion &qregion); + struct ::wl_subsurface *createSubSurface(QWaylandWindow *window, QWaylandWindow *parent); QWaylandClientBufferIntegration *clientBufferIntegration() const; @@ -127,8 +128,6 @@ public: QWaylandDataDeviceManager *dndSelectionHandler() const { return mDndSelectionHandler.data(); } QtWayland::qt_surface_extension *windowExtension() const { return mWindowExtension.data(); } - QtWayland::qt_sub_surface_extension *subSurfaceExtension() const { return mSubSurfaceExtension.data(); } - QtWayland::qt_output_extension *outputExtension() const { return mOutputExtension.data(); } QWaylandTouchExtension *touchExtension() const { return mTouchExtension.data(); } QtWayland::wl_text_input_manager *textInputManager() const { return mTextInputManager.data(); } QWaylandHardwareIntegration *hardwareIntegration() const { return mHardwareIntegration.data(); } @@ -187,8 +186,7 @@ private: QWaylandInputDevice *mLastKeyboardFocusInputDevice; QScopedPointer<QWaylandDataDeviceManager> mDndSelectionHandler; QScopedPointer<QtWayland::qt_surface_extension> mWindowExtension; - QScopedPointer<QtWayland::qt_sub_surface_extension> mSubSurfaceExtension; - QScopedPointer<QtWayland::qt_output_extension> mOutputExtension; + QScopedPointer<QtWayland::wl_subcompositor> mSubCompositor; QScopedPointer<QWaylandTouchExtension> mTouchExtension; QScopedPointer<QWaylandQtKeyExtension> mQtKeyExtension; QScopedPointer<QWaylandWindowManagerIntegration> mWindowManagerIntegration; diff --git a/src/client/qwaylanddnd.cpp b/src/client/qwaylanddnd.cpp index 302864d4b..59f91411f 100644 --- a/src/client/qwaylanddnd.cpp +++ b/src/client/qwaylanddnd.cpp @@ -89,15 +89,15 @@ void QWaylandDrag::cancel() m_display->currentInputDevice()->dataDevice()->cancelDrag(); } -void QWaylandDrag::move(const QMouseEvent *me) +void QWaylandDrag::move(const QPoint &globalPos) { - Q_UNUSED(me); + Q_UNUSED(globalPos); // Do nothing } -void QWaylandDrag::drop(const QMouseEvent *me) +void QWaylandDrag::drop(const QPoint &globalPos) { - Q_UNUSED(me); + Q_UNUSED(globalPos); // Do nothing } diff --git a/src/client/qwaylanddnd_p.h b/src/client/qwaylanddnd_p.h index 994c65c45..19b1f92ed 100644 --- a/src/client/qwaylanddnd_p.h +++ b/src/client/qwaylanddnd_p.h @@ -63,8 +63,8 @@ public: protected: void startDrag() Q_DECL_OVERRIDE; void cancel() Q_DECL_OVERRIDE; - void move(const QMouseEvent *me) Q_DECL_OVERRIDE; - void drop(const QMouseEvent *me) Q_DECL_OVERRIDE; + void move(const QPoint &globalPos) Q_DECL_OVERRIDE; + void drop(const QPoint &globalpos) Q_DECL_OVERRIDE; void endDrag() Q_DECL_OVERRIDE; diff --git a/src/client/qwaylandextendedoutput.cpp b/src/client/qwaylandextendedoutput.cpp deleted file mode 100644 index d1e8ffe2f..000000000 --- a/src/client/qwaylandextendedoutput.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandextendedoutput_p.h" - -#include "qwaylandscreen_p.h" - -#include <qpa/qwindowsysteminterface.h> - -#include <QtCore/QDebug> - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -QWaylandExtendedOutput::QWaylandExtendedOutput(QWaylandScreen *screen, ::qt_extended_output *extended_output) - : QtWayland::qt_extended_output(extended_output) -{ - Q_UNUSED(screen); -} - -} -QT_END_NAMESPACE diff --git a/src/client/qwaylandextendedoutput_p.h b/src/client/qwaylandextendedoutput_p.h deleted file mode 100644 index b3e4c469e..000000000 --- a/src/client/qwaylandextendedoutput_p.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDEXTENDEDOUTPUT_H -#define QWAYLANDEXTENDEDOUTPUT_H - -#include <QtWaylandClient/private/qwayland-output-extension.h> -#include <QtWaylandClient/private/qwaylandclientexport_p.h> - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - -class QWaylandDisplay; -class QWaylandScreen; -class QWaylandExtendedOutput; - -class Q_WAYLAND_CLIENT_EXPORT QWaylandExtendedOutput : public QtWayland::qt_extended_output -{ -public: - QWaylandExtendedOutput(QWaylandScreen *screen, struct ::qt_extended_output *extended_output); -}; - -} - -QT_END_NAMESPACE - -#endif // QWAYLANDEXTENDEDOUTPUT_H diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp index 009ef670e..9ac678c93 100644 --- a/src/client/qwaylandinputdevice.cpp +++ b/src/client/qwaylandinputdevice.cpp @@ -42,6 +42,7 @@ #include "qwaylandscreen_p.h" #include "qwaylandcursor_p.h" #include "qwaylanddisplay_p.h" +#include "../shared/qwaylandxkb.h" #include <QtGui/private/qpixmap_raster_p.h> #include <qpa/qplatformwindow.h> @@ -302,16 +303,7 @@ Qt::KeyboardModifiers QWaylandInputDevice::Keyboard::modifiers() const if (!mXkbState) return ret; - xkb_state_component cstate = static_cast<xkb_state_component>(XKB_STATE_DEPRESSED | XKB_STATE_LATCHED); - - if (xkb_state_mod_name_is_active(mXkbState, XKB_MOD_NAME_SHIFT, cstate)) - ret |= Qt::ShiftModifier; - if (xkb_state_mod_name_is_active(mXkbState, XKB_MOD_NAME_CTRL, cstate)) - ret |= Qt::ControlModifier; - if (xkb_state_mod_name_is_active(mXkbState, XKB_MOD_NAME_ALT, cstate)) - ret |= Qt::AltModifier; - if (xkb_state_mod_name_is_active(mXkbState, XKB_MOD_NAME_LOGO, cstate)) - ret |= Qt::MetaModifier; + ret = QWaylandXkb::modifiers(mXkbState); #endif return ret; @@ -530,150 +522,6 @@ void QWaylandInputDevice::Pointer::pointer_axis(uint32_t time, uint32_t axis, in window->handleMouse(mParent, e); } -#ifndef QT_NO_WAYLAND_XKB - -static const uint32_t KeyTbl[] = { - XKB_KEY_Escape, Qt::Key_Escape, - XKB_KEY_Tab, Qt::Key_Tab, - XKB_KEY_ISO_Left_Tab, Qt::Key_Backtab, - XKB_KEY_BackSpace, Qt::Key_Backspace, - XKB_KEY_Return, Qt::Key_Return, - XKB_KEY_Insert, Qt::Key_Insert, - XKB_KEY_Delete, Qt::Key_Delete, - XKB_KEY_Clear, Qt::Key_Delete, - XKB_KEY_Pause, Qt::Key_Pause, - XKB_KEY_Print, Qt::Key_Print, - - XKB_KEY_Home, Qt::Key_Home, - XKB_KEY_End, Qt::Key_End, - XKB_KEY_Left, Qt::Key_Left, - XKB_KEY_Up, Qt::Key_Up, - XKB_KEY_Right, Qt::Key_Right, - XKB_KEY_Down, Qt::Key_Down, - XKB_KEY_Prior, Qt::Key_PageUp, - XKB_KEY_Next, Qt::Key_PageDown, - - XKB_KEY_Shift_L, Qt::Key_Shift, - XKB_KEY_Shift_R, Qt::Key_Shift, - XKB_KEY_Shift_Lock, Qt::Key_Shift, - XKB_KEY_Control_L, Qt::Key_Control, - XKB_KEY_Control_R, Qt::Key_Control, - XKB_KEY_Meta_L, Qt::Key_Meta, - XKB_KEY_Meta_R, Qt::Key_Meta, - XKB_KEY_Alt_L, Qt::Key_Alt, - XKB_KEY_Alt_R, Qt::Key_Alt, - XKB_KEY_Caps_Lock, Qt::Key_CapsLock, - XKB_KEY_Num_Lock, Qt::Key_NumLock, - XKB_KEY_Scroll_Lock, Qt::Key_ScrollLock, - XKB_KEY_Super_L, Qt::Key_Super_L, - XKB_KEY_Super_R, Qt::Key_Super_R, - XKB_KEY_Menu, Qt::Key_Menu, - XKB_KEY_Hyper_L, Qt::Key_Hyper_L, - XKB_KEY_Hyper_R, Qt::Key_Hyper_R, - XKB_KEY_Help, Qt::Key_Help, - - XKB_KEY_KP_Space, Qt::Key_Space, - XKB_KEY_KP_Tab, Qt::Key_Tab, - XKB_KEY_KP_Enter, Qt::Key_Enter, - XKB_KEY_KP_Home, Qt::Key_Home, - XKB_KEY_KP_Left, Qt::Key_Left, - XKB_KEY_KP_Up, Qt::Key_Up, - XKB_KEY_KP_Right, Qt::Key_Right, - XKB_KEY_KP_Down, Qt::Key_Down, - XKB_KEY_KP_Prior, Qt::Key_PageUp, - XKB_KEY_KP_Next, Qt::Key_PageDown, - XKB_KEY_KP_End, Qt::Key_End, - XKB_KEY_KP_Begin, Qt::Key_Clear, - XKB_KEY_KP_Insert, Qt::Key_Insert, - XKB_KEY_KP_Delete, Qt::Key_Delete, - XKB_KEY_KP_Equal, Qt::Key_Equal, - XKB_KEY_KP_Multiply, Qt::Key_Asterisk, - XKB_KEY_KP_Add, Qt::Key_Plus, - XKB_KEY_KP_Separator, Qt::Key_Comma, - XKB_KEY_KP_Subtract, Qt::Key_Minus, - XKB_KEY_KP_Decimal, Qt::Key_Period, - XKB_KEY_KP_Divide, Qt::Key_Slash, - - XKB_KEY_ISO_Level3_Shift, Qt::Key_AltGr, - XKB_KEY_Multi_key, Qt::Key_Multi_key, - XKB_KEY_Codeinput, Qt::Key_Codeinput, - XKB_KEY_SingleCandidate, Qt::Key_SingleCandidate, - XKB_KEY_MultipleCandidate, Qt::Key_MultipleCandidate, - XKB_KEY_PreviousCandidate, Qt::Key_PreviousCandidate, - - XKB_KEY_Mode_switch, Qt::Key_Mode_switch, - XKB_KEY_script_switch, Qt::Key_Mode_switch, - - XKB_KEY_XF86Back, Qt::Key_Back, - XKB_KEY_XF86Forward, Qt::Key_Forward, - - XKB_KEY_XF86AudioPlay, Qt::Key_MediaTogglePlayPause, //there isn't a PlayPause keysym, however just play keys are not common - XKB_KEY_XF86AudioPause, Qt::Key_MediaPause, - XKB_KEY_XF86AudioStop, Qt::Key_MediaStop, - XKB_KEY_XF86AudioPrev, Qt::Key_MediaPrevious, - XKB_KEY_XF86AudioNext, Qt::Key_MediaNext, - XKB_KEY_XF86AudioRewind, Qt::Key_MediaPrevious, - XKB_KEY_XF86AudioForward, Qt::Key_MediaNext, - XKB_KEY_XF86AudioRecord, Qt::Key_MediaRecord, - - XKB_KEY_XF86AudioMute, Qt::Key_VolumeMute, - XKB_KEY_XF86AudioLowerVolume, Qt::Key_VolumeDown, - XKB_KEY_XF86AudioRaiseVolume, Qt::Key_VolumeUp, - - XKB_KEY_XF86AudioRandomPlay, Qt::Key_AudioRandomPlay, - XKB_KEY_XF86AudioRepeat, Qt::Key_AudioRepeat, - - XKB_KEY_XF86ZoomIn, Qt::Key_ZoomIn, - XKB_KEY_XF86ZoomOut, Qt::Key_ZoomOut, - - XKB_KEY_XF86Eject, Qt::Key_Eject, - - 0, 0 -}; - -static int keysymToQtKey(xkb_keysym_t key) -{ - int code = 0; - int i = 0; - while (KeyTbl[i]) { - if (key == KeyTbl[i]) { - code = (int)KeyTbl[i+1]; - break; - } - i += 2; - } - - return code; -} - -static int keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers &modifiers, const QString &text) -{ - int code = 0; - - if (keysym >= XKB_KEY_F1 && keysym <= XKB_KEY_F35) { - code = Qt::Key_F1 + (int(keysym) - XKB_KEY_F1); - } else if (keysym >= XKB_KEY_KP_Space && keysym <= XKB_KEY_KP_9) { - if (keysym >= XKB_KEY_KP_0) { - // numeric keypad keys - code = Qt::Key_0 + ((int)keysym - XKB_KEY_KP_0); - } else { - code = keysymToQtKey(keysym); - } - modifiers |= Qt::KeypadModifier; - } else if (text.length() == 1 && text.unicode()->unicode() > 0x1f - && text.unicode()->unicode() != 0x7f - && !(keysym >= XKB_KEY_dead_grave && keysym <= XKB_KEY_dead_currency)) { - code = text.unicode()->toUpper().unicode(); - } else { - // any other keys - code = keysymToQtKey(keysym); - } - - return code; -} - -#endif // QT_NO_WAYLAND_XKB - void QWaylandInputDevice::Keyboard::keyboard_keymap(uint32_t format, int32_t fd, uint32_t size) { #ifndef QT_NO_WAYLAND_XKB @@ -795,7 +643,7 @@ void QWaylandInputDevice::Keyboard::keyboard_key(uint32_t serial, uint32_t time, if (utf32) text = QString::fromUcs4(&utf32, 1); - qtkey = keysymToQtKey(sym, modifiers, text); + qtkey = QWaylandXkb::keysymToQtKey(sym, modifiers, text); QWindowSystemInterface::handleExtendedKeyEvent(window->window(), time, type, qtkey, diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp index 9526aec4c..82df8a30a 100644 --- a/src/client/qwaylandintegration.cpp +++ b/src/client/qwaylandintegration.cpp @@ -128,7 +128,9 @@ QWaylandIntegration::QWaylandIntegration() mClipboard = new QWaylandClipboard(mDisplay); mDrag = new QWaylandDrag(mDisplay); - mInputContext.reset(new QWaylandInputContext(mDisplay)); + QString icStr = QPlatformInputContextFactory::requested(); + icStr.isNull() ? mInputContext.reset(new QWaylandInputContext(mDisplay)) + : mInputContext.reset(QPlatformInputContextFactory::create(icStr)); } QWaylandIntegration::~QWaylandIntegration() diff --git a/src/client/qwaylandscreen.cpp b/src/client/qwaylandscreen.cpp index 8a01e366e..1be90e8e7 100644 --- a/src/client/qwaylandscreen.cpp +++ b/src/client/qwaylandscreen.cpp @@ -35,7 +35,6 @@ #include "qwaylanddisplay_p.h" #include "qwaylandcursor_p.h" -#include "qwaylandextendedoutput_p.h" #include "qwaylandwindow_p.h" #include <QtGui/QGuiApplication> @@ -52,7 +51,6 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin , QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2)) , m_outputId(id) , mWaylandDisplay(waylandDisplay) - , mExtendedOutput(0) , mScale(1) , mDepth(32) , mRefreshRate(60000) @@ -62,8 +60,6 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin , m_orientation(Qt::PrimaryOrientation) , mWaylandCursor(0) { - // handle case of output extension global being sent after outputs - createExtendedOutput(); } QWaylandScreen::~QWaylandScreen() @@ -118,7 +114,9 @@ QDpi QWaylandScreen::logicalDpi() const QList<QPlatformScreen *> QWaylandScreen::virtualSiblings() const { QList<QPlatformScreen *> list; - foreach (QWaylandScreen *screen, mWaylandDisplay->screens()) + const QList<QWaylandScreen*> screens = mWaylandDisplay->screens(); + list.reserve(screens.count()); + foreach (QWaylandScreen *screen, screens) list << screen; return list; } @@ -157,18 +155,6 @@ QPlatformCursor *QWaylandScreen::cursor() const return mWaylandCursor; } -QWaylandExtendedOutput *QWaylandScreen::extendedOutput() const -{ - return mExtendedOutput; -} - -void QWaylandScreen::createExtendedOutput() -{ - QtWayland::qt_output_extension *extension = mWaylandDisplay->outputExtension(); - if (!mExtendedOutput && extension) - mExtendedOutput = new QWaylandExtendedOutput(this, extension->get_extended_output(output())); -} - QWaylandScreen * QWaylandScreen::waylandScreenFromWindow(QWindow *window) { QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWindow(window); diff --git a/src/client/qwaylandscreen_p.h b/src/client/qwaylandscreen_p.h index 06389f7e4..3d38e30a8 100644 --- a/src/client/qwaylandscreen_p.h +++ b/src/client/qwaylandscreen_p.h @@ -45,7 +45,6 @@ namespace QtWaylandClient { class QWaylandDisplay; class QWaylandCursor; -class QWaylandExtendedOutput; class Q_WAYLAND_CLIENT_EXPORT QWaylandScreen : public QPlatformScreen, QtWayland::wl_output { @@ -80,9 +79,6 @@ public: uint32_t outputId() const { return m_outputId; } ::wl_output *output() { return object(); } - QWaylandExtendedOutput *extendedOutput() const; - void createExtendedOutput(); - static QWaylandScreen *waylandScreenFromWindow(QWindow *window); private: @@ -98,7 +94,6 @@ private: int m_outputId; QWaylandDisplay *mWaylandDisplay; - QWaylandExtendedOutput *mExtendedOutput; QRect mGeometry; int mScale; int mDepth; diff --git a/src/client/qwaylandsubsurface.cpp b/src/client/qwaylandsubsurface.cpp index 81cfef254..ec813609f 100644 --- a/src/client/qwaylandsubsurface.cpp +++ b/src/client/qwaylandsubsurface.cpp @@ -41,45 +41,18 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { -QWaylandSubSurface::QWaylandSubSurface(QWaylandWindow *window, struct ::qt_sub_surface *sub_surface) - : QtWayland::qt_sub_surface(sub_surface) +QWaylandSubSurface::QWaylandSubSurface(QWaylandWindow *window, QWaylandWindow *parent, ::wl_subsurface *sub_surface) + : QtWayland::wl_subsurface(sub_surface) , m_window(window) + , m_parent(parent) { + m_parent->mChildren << this; + set_desync(); } -void QWaylandSubSurface::setParent(const QWaylandWindow *parent) +QWaylandSubSurface::~QWaylandSubSurface() { - QWaylandSubSurface *parentSurface = parent ? parent->subSurfaceWindow() : 0; - if (parentSurface) { - int x = m_window->geometry().x() + parent->frameMargins().left(); - int y = m_window->geometry().y() + parent->frameMargins().top(); - parentSurface->attach_sub_surface(object(), x, y); - } -} - -static void setPositionToParent(QWaylandWindow *parentWaylandWindow) -{ - QObjectList children = parentWaylandWindow->window()->children(); - for (int i = 0; i < children.size(); i++) { - QWindow *childWindow = qobject_cast<QWindow *>(children.at(i)); - if (!childWindow) - continue; - - if (childWindow->handle()) { - QWaylandWindow *waylandWindow = static_cast<QWaylandWindow *>(childWindow->handle()); - waylandWindow->subSurfaceWindow()->setParent(parentWaylandWindow); - setPositionToParent(waylandWindow); - } - } -} - -void QWaylandSubSurface::adjustPositionOfChildren() -{ - QWindow *window = m_window->window(); - if (window->parent()) { - qDebug() << "QWaylandSubSurface::adjustPositionOfChildren not called for toplevel window"; - } - setPositionToParent(m_window); + m_parent->mChildren.removeOne(this); } } diff --git a/src/client/qwaylandsubsurface_p.h b/src/client/qwaylandsubsurface_p.h index 232330855..75d8cf6a0 100644 --- a/src/client/qwaylandsubsurface_p.h +++ b/src/client/qwaylandsubsurface_p.h @@ -39,8 +39,7 @@ #include <QtCore/qglobal.h> #include <QtWaylandClient/private/qwaylandclientexport_p.h> - -#include <QtWaylandClient/private/qwayland-sub-surface-extension.h> +#include <QtWaylandClient/private/qwayland-wayland.h> QT_BEGIN_NAMESPACE @@ -48,18 +47,19 @@ namespace QtWaylandClient { class QWaylandDisplay; class QWaylandWindow; -class QWaylandSubSurface; -class Q_WAYLAND_CLIENT_EXPORT QWaylandSubSurface : public QtWayland::qt_sub_surface +class Q_WAYLAND_CLIENT_EXPORT QWaylandSubSurface : public QtWayland::wl_subsurface { public: - QWaylandSubSurface(QWaylandWindow *window, struct ::qt_sub_surface *sub_surface); + QWaylandSubSurface(QWaylandWindow *window, QWaylandWindow *parent, ::wl_subsurface *subsurface); + ~QWaylandSubSurface(); - void setParent(const QWaylandWindow *parent); - void adjustPositionOfChildren(); + QWaylandWindow *window() const { return m_window; } + QWaylandWindow *parent() const { return m_parent; } private: QWaylandWindow *m_window; + QWaylandWindow *m_parent; }; QT_END_NAMESPACE diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index b98dd9dae..ed7b656d9 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -86,21 +86,49 @@ QWaylandWindow::QWaylandWindow(QWindow *window) , mMask() , mBackingStore(Q_NULLPTR) { - init(mDisplay->createSurface(static_cast<QtWayland::wl_surface *>(this))); - static WId id = 1; mWindowId = id++; - if (mDisplay->subSurfaceExtension()) - mSubSurfaceWindow = new QWaylandSubSurface(this, mDisplay->subSurfaceExtension()->get_sub_surface_aware_surface(object())); + initWindow(); +} + +QWaylandWindow::~QWaylandWindow() +{ + delete mWindowDecoration; + + if (isInitialized()) + reset(); - if (!(window->flags() & Qt::BypassWindowManagerHint)) { + QList<QWaylandInputDevice *> inputDevices = mDisplay->inputDevices(); + for (int i = 0; i < inputDevices.size(); ++i) + inputDevices.at(i)->handleWindowDestroyed(this); + + const QWindow *parent = window(); + foreach (QWindow *w, QGuiApplication::topLevelWindows()) { + if (w->transientParent() == parent) + QWindowSystemInterface::handleCloseEvent(w); + } + + if (mMouseGrab == this) { + mMouseGrab = 0; + } +} + +void QWaylandWindow::initWindow() +{ + init(mDisplay->createSurface(static_cast<QtWayland::wl_surface *>(this))); + if (QPlatformWindow::parent()) { + QWaylandWindow *p = static_cast<QWaylandWindow *>(QPlatformWindow::parent()); + if (::wl_subsurface *ss = mDisplay->createSubSurface(this, p)) { + mSubSurfaceWindow = new QWaylandSubSurface(this, p, ss); + } + } else if (!(window()->flags() & Qt::BypassWindowManagerHint)) { mShellSurface = mDisplay->createShellSurface(this); } if (mShellSurface) { // Set initial surface title - mShellSurface->setTitle(window->title()); + mShellSurface->setTitle(window()->title()); // The appId is the desktop entry identifier that should follow the // reverse DNS convention (see http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s02.html), @@ -122,14 +150,15 @@ QWaylandWindow::QWaylandWindow(QWindow *window) } } - if (QPlatformWindow::parent() && mSubSurfaceWindow) { - mSubSurfaceWindow->setParent(static_cast<const QWaylandWindow *>(QPlatformWindow::parent())); - } else if (window->transientParent() && mShellSurface) { - if (window->type() != Qt::Popup) { - mShellSurface->updateTransientParent(window->transientParent()); + if (mShellSurface) { + if (window()->transientParent()) { + if (window()->type() != Qt::Popup) { + mShellSurface->updateTransientParent(window()->transientParent()); + } + } else { + if (window()->type() != Qt::ToolTip) + mShellSurface->setTopLevel(); } - } else if (mShellSurface && window->type() != Qt::ToolTip) { - mShellSurface->setTopLevel(); } // Enable high-dpi rendering. Scale() returns the screen scale factor and will @@ -138,38 +167,25 @@ QWaylandWindow::QWaylandWindow(QWindow *window) if (mDisplay->compositorVersion() >= 3) set_buffer_scale(scale()); - setOrientationMask(window->screen()->orientationUpdateMask()); - setWindowFlags(window->flags()); - setGeometry_helper(window->geometry()); - setMask(window->mask()); - setWindowStateInternal(window->windowState()); - handleContentOrientationChange(window->contentOrientation()); + if (QScreen *s = window()->screen()) + setOrientationMask(s->orientationUpdateMask()); + setWindowFlags(window()->flags()); + setGeometry_helper(window()->geometry()); + setMask(window()->mask()); + setWindowStateInternal(window()->windowState()); + handleContentOrientationChange(window()->contentOrientation()); } -QWaylandWindow::~QWaylandWindow() +void QWaylandWindow::reset() { - delete mWindowDecoration; + delete mShellSurface; + mShellSurface = 0; + delete mSubSurfaceWindow; + mSubSurfaceWindow = 0; + destroy(); - if (isInitialized()) { - delete mShellSurface; - destroy(); - } if (mFrameCallback) wl_callback_destroy(mFrameCallback); - - QList<QWaylandInputDevice *> inputDevices = mDisplay->inputDevices(); - for (int i = 0; i < inputDevices.size(); ++i) - inputDevices.at(i)->handleWindowDestroyed(this); - - const QWindow *parent = window(); - foreach (QWindow *w, QGuiApplication::topLevelWindows()) { - if (w->transientParent() == parent) - QWindowSystemInterface::handleCloseEvent(w); - } - - if (mMouseGrab == this) { - mMouseGrab = 0; - } } QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface) @@ -184,9 +200,17 @@ WId QWaylandWindow::winId() const void QWaylandWindow::setParent(const QPlatformWindow *parent) { - const QWaylandWindow *parentWaylandWindow = static_cast<const QWaylandWindow *>(parent); - if (subSurfaceWindow()) { - subSurfaceWindow()->setParent(parentWaylandWindow); + QWaylandWindow *oldparent = mSubSurfaceWindow ? mSubSurfaceWindow->parent() : 0; + if (oldparent == parent) + return; + + if (mSubSurfaceWindow && parent) { // new parent, but we were a subsurface already + delete mSubSurfaceWindow; + QWaylandWindow *p = const_cast<QWaylandWindow *>(static_cast<const QWaylandWindow *>(parent)); + mSubSurfaceWindow = new QWaylandSubSurface(this, p, mDisplay->createSubSurface(this, p)); + } else { // we're changing role, need to make a new wl_surface + reset(); + initWindow(); } } @@ -214,7 +238,10 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect) qBound(window()->minimumWidth(), rect.width(), window()->maximumWidth()), qBound(window()->minimumHeight(), rect.height(), window()->maximumHeight()))); - if (shellSurface() && window()->transientParent() && window()->type() != Qt::Popup) + if (mSubSurfaceWindow) { + QMargins m = QPlatformWindow::parent()->frameMargins(); + mSubSurfaceWindow->set_position(rect.x() + m.left(), rect.y() + m.top()); + } else if (shellSurface() && window()->transientParent() && window()->type() != Qt::Popup) shellSurface()->updateTransientParent(window()->transientParent()); } @@ -547,7 +574,10 @@ bool QWaylandWindow::createDecoration() decoration = false; if (window()->flags() & Qt::BypassWindowManagerHint) decoration = false; + if (mSubSurfaceWindow) + decoration = false; + bool hadDecoration = mWindowDecoration; if (decoration && !decorationPluginFailed) { if (!mWindowDecoration) { QStringList decorations = QWaylandDecorationFactory::keys(); @@ -578,15 +608,20 @@ bool QWaylandWindow::createDecoration() return false; } mWindowDecoration->setWaylandWindow(this); - if (subSurfaceWindow()) { - subSurfaceWindow()->adjustPositionOfChildren(); - } } } else { delete mWindowDecoration; mWindowDecoration = 0; } + if (hadDecoration != (bool)mWindowDecoration) { + foreach (QWaylandSubSurface *subsurf, mChildren) { + QPoint pos = subsurf->window()->geometry().topLeft(); + QMargins m = frameMargins(); + subsurf->set_position(pos.x() + m.left(), pos.y() + m.top()); + } + } + return mWindowDecoration; } diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h index 1898c4953..6b9af1031 100644 --- a/src/client/qwaylandwindow_p.h +++ b/src/client/qwaylandwindow_p.h @@ -190,6 +190,7 @@ protected: QWaylandDisplay *mDisplay; QWaylandShellSurface *mShellSurface; QWaylandSubSurface *mSubSurfaceWindow; + QVector<QWaylandSubSurface *> mChildren; QWaylandAbstractDecoration *mWindowDecoration; bool mMouseEventsInContentArea; @@ -223,6 +224,8 @@ protected: private: bool setWindowStateInternal(Qt::WindowState flags); void setGeometry_helper(const QRect &rect); + void initWindow(); + void reset(); void handleMouseEventWithDecoration(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e); @@ -231,6 +234,8 @@ private: static QMutex mFrameSyncMutex; static QWaylandWindow *mMouseGrab; + + friend class QWaylandSubSurface; }; inline QIcon QWaylandWindow::windowIcon() const diff --git a/src/client/qwaylandwlshellsurface.cpp b/src/client/qwaylandwlshellsurface.cpp index f7bdc2c99..7235931d3 100644 --- a/src/client/qwaylandwlshellsurface.cpp +++ b/src/client/qwaylandwlshellsurface.cpp @@ -47,8 +47,8 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { QWaylandWlShellSurface::QWaylandWlShellSurface(struct ::wl_shell_surface *shell_surface, QWaylandWindow *window) - : QtWayland::wl_shell_surface(shell_surface) - , QWaylandShellSurface(window) + : QWaylandShellSurface(window) + , QtWayland::wl_shell_surface(shell_surface) , m_window(window) , m_maximized(false) , m_fullscreen(false) diff --git a/src/client/qwaylandxdgsurface.cpp b/src/client/qwaylandxdgsurface.cpp index f06d7e353..c89e230db 100644 --- a/src/client/qwaylandxdgsurface.cpp +++ b/src/client/qwaylandxdgsurface.cpp @@ -46,8 +46,8 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { QWaylandXdgSurface::QWaylandXdgSurface(struct ::xdg_surface *xdg_surface, QWaylandWindow *window) - : QtWayland::xdg_surface(xdg_surface) - , QWaylandShellSurface(window) + : QWaylandShellSurface(window) + , QtWayland::xdg_surface(xdg_surface) , m_window(window) , m_maximized(false) , m_minimized(false) @@ -56,6 +56,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(struct ::xdg_surface *xdg_surface, QWayla { if (window->display()->windowExtension()) m_extendedWindow = new QWaylandExtendedSurface(window); + m_size = m_window->window()->geometry().size(); } QWaylandXdgSurface::~QWaylandXdgSurface() @@ -126,8 +127,8 @@ void QWaylandXdgSurface::updateTransientParent(QWindow *parent) QWaylandWindow *parent_wayland_window = static_cast<QWaylandWindow *>(parent->handle()); if (!parent_wayland_window) return; - - set_parent(parent_wayland_window->object()); + QtWayland::xdg_shell *shell = parent_wayland_window->display()->shellXdg(); + set_parent(shell->get_xdg_surface(parent_wayland_window->object())); } void QWaylandXdgSurface::setTitle(const QString & title) @@ -178,11 +179,11 @@ void QWaylandXdgSurface::xdg_surface_configure(int32_t width, int32_t height, st state = (uint32_t*) states->data; - for (uint32_t i=0; i < states->size; i++) + for (uint32_t i = 0; i < states->size / sizeof(state) ; i++) { switch (*(state+i)) { case XDG_SURFACE_STATE_MAXIMIZED: - aboutToMaximize = true; + aboutToMaximize = ((width > 0) && (height > 0)); break; case XDG_SURFACE_STATE_FULLSCREEN: aboutToFullScreen = true; @@ -191,7 +192,7 @@ void QWaylandXdgSurface::xdg_surface_configure(int32_t width, int32_t height, st m_margins = m_window->frameMargins(); width -= m_margins.left() + m_margins.right(); height -= m_margins.top() + m_margins.bottom(); - m_size = QSize(width,height); + m_size = m_window->window()->geometry().size(); break; case XDG_SURFACE_STATE_ACTIVATED: // TODO: here about the missing window activation @@ -203,21 +204,23 @@ void QWaylandXdgSurface::xdg_surface_configure(int32_t width, int32_t height, st if (!m_fullscreen && aboutToFullScreen) { m_fullscreen = true; - m_size = m_window->window()->geometry().size(); m_window->window()->showFullScreen(); } else if (m_fullscreen && !aboutToFullScreen) { m_fullscreen = false; - m_window->window()->showNormal(); + if ( m_maximized ) { + m_window->window()->showMaximized(); + } else { + m_window->window()->showNormal(); + } } else if (!m_maximized && aboutToMaximize) { m_maximized = true; - m_size = m_window->window()->geometry().size(); m_window->window()->showMaximized(); } else if (m_maximized && !aboutToMaximize) { m_maximized = false; m_window->window()->showNormal(); } - if (width == 0 && height == 0) { + if (width == 0 || height == 0) { width = m_size.width(); height = m_size.height(); } @@ -227,7 +230,7 @@ void QWaylandXdgSurface::xdg_surface_configure(int32_t width, int32_t height, st m_window->configure(0, width + m_margins.left() + m_margins.right(), height + m_margins.top() + m_margins.bottom()); } - xdg_surface_ack_configure(object(), serial); + ack_configure(serial); } void QWaylandXdgSurface::xdg_surface_close() |