qtubuntu-0.62+16.04.20160322/0000755000015600001650000000000012674205406015676 5ustar pbuserpbgroup00000000000000qtubuntu-0.62+16.04.20160322/src/0000755000015600001650000000000012674205406016465 5ustar pbuserpbgroup00000000000000qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/0000755000015600001650000000000012674205406021716 5ustar pbuserpbgroup00000000000000qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/ubuntumirclient.pro0000644000015600001650000000214012674203446025670 0ustar pbuserpbgroup00000000000000TARGET = qpa-ubuntumirclient TEMPLATE = lib QT -= gui QT += core-private platformsupport-private dbus CONFIG += plugin no_keywords qpa/genericunixfontdatabase DEFINES += MESA_EGL_NO_X11_HEADERS # CONFIG += c++11 # only enables C++0x QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden -std=c++11 -Werror -Wall QMAKE_LFLAGS += -std=c++11 -Wl,-no-undefined CONFIG += link_pkgconfig PKGCONFIG += egl mirclient ubuntu-platform-api xkbcommon SOURCES = \ backingstore.cpp \ clipboard.cpp \ cursor.cpp \ glcontext.cpp \ input.cpp \ integration.cpp \ nativeinterface.cpp \ offscreensurface.cpp \ platformservices.cpp \ plugin.cpp \ screen.cpp \ theme.cpp \ window.cpp HEADERS = \ backingstore.h \ clipboard.h \ cursor.h \ glcontext.h \ input.h \ integration.h \ logging.h \ nativeinterface.h \ offscreensurface.h \ orientationchangeevent_p.h \ platformservices.h \ plugin.h \ screen.h \ theme.h \ window.h # Installation path target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/theme.cpp0000644000015600001650000000234412674203424023525 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "theme.h" #include const char *UbuntuTheme::name = "ubuntu"; UbuntuTheme::UbuntuTheme() { } UbuntuTheme::~UbuntuTheme() { } QVariant UbuntuTheme::themeHint(ThemeHint hint) const { if (hint == QPlatformTheme::SystemIconThemeName) { QByteArray iconTheme = qgetenv("QTUBUNTU_ICON_THEME"); if (iconTheme.isEmpty()) { return QVariant(QStringLiteral("ubuntu-mobile")); } else { return QVariant(QString(iconTheme)); } } else { return QGenericUnixTheme::themeHint(hint); } } qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/orientationchangeevent_p.h0000644000015600001650000000220112674203424027142 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef ORIENTATIONCHANGEEVENT_P_H #define ORIENTATIONCHANGEEVENT_P_H #include #include "logging.h" class OrientationChangeEvent : public QEvent { public: enum Orientation { TopUp, LeftUp, TopDown, RightUp }; OrientationChangeEvent(QEvent::Type type, Orientation orientation) : QEvent(type) , mOrientation(orientation) { } static const QEvent::Type mType; Orientation mOrientation; }; #endif // ORIENTATIONCHANGEEVENT_P_H qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/cursor.h0000644000015600001650000000237412674203424023410 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2015 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_CURSOR_H #define UBUNTU_CURSOR_H #include #include #include struct MirConnection; struct MirSurface; class UbuntuCursor : public QPlatformCursor { public: UbuntuCursor(MirConnection *connection); void changeCursor(QCursor *windowCursor, QWindow *window) override; private: void configureMirCursorWithPixmapQCursor(MirSurface *surface, QCursor &cursor); void applyDefaultCursorConfiguration(MirSurface *surface); QMap mShapeToCursorName; MirConnection *mConnection; }; #endif // UBUNTU_CURSOR_H qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/logging.h0000644000015600001650000000177512674203424023525 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014-2015 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef QUBUNTULOGGING_H #define QUBUNTULOGGING_H #include #define ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop()) Q_DECLARE_LOGGING_CATEGORY(ubuntumirclient) Q_DECLARE_LOGGING_CATEGORY(ubuntumirclientBufferSwap) Q_DECLARE_LOGGING_CATEGORY(ubuntumirclientInput) #endif // QUBUNTULOGGING_H qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/glcontext.cpp0000644000015600001650000000774712674203424024446 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014-2016 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "glcontext.h" #include "logging.h" #include "offscreensurface.h" #include "window.h" #include #include static void printOpenGLESConfig() { static bool once = true; if (once) { const char* string = (const char*) glGetString(GL_VENDOR); qCDebug(ubuntumirclient, "OpenGL ES vendor: %s", string); string = (const char*) glGetString(GL_RENDERER); qCDebug(ubuntumirclient, "OpenGL ES renderer: %s", string); string = (const char*) glGetString(GL_VERSION); qCDebug(ubuntumirclient, "OpenGL ES version: %s", string); string = (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION); qCDebug(ubuntumirclient, "OpenGL ES Shading Language version: %s", string); string = (const char*) glGetString(GL_EXTENSIONS); qCDebug(ubuntumirclient, "OpenGL ES extensions: %s", string); once = false; } } static EGLenum api_in_use() { #ifdef QTUBUNTU_USE_OPENGL return EGL_OPENGL_API; #else return EGL_OPENGL_ES_API; #endif } UbuntuOpenGLContext::UbuntuOpenGLContext(UbuntuScreen* screen, UbuntuOpenGLContext* share) { ASSERT(screen != NULL); mEglDisplay = screen->eglDisplay(); mScreen = screen; // Create an OpenGL ES 2 context. QVector attribs; attribs.append(EGL_CONTEXT_CLIENT_VERSION); attribs.append(2); attribs.append(EGL_NONE); ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE); mEglContext = eglCreateContext(mEglDisplay, screen->eglConfig(), share ? share->eglContext() : EGL_NO_CONTEXT, attribs.constData()); Q_ASSERT(mEglContext != EGL_NO_CONTEXT); } UbuntuOpenGLContext::~UbuntuOpenGLContext() { ASSERT(eglDestroyContext(mEglDisplay, mEglContext) == EGL_TRUE); } bool UbuntuOpenGLContext::makeCurrent(QPlatformSurface* surface) { Q_ASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface); if (surface->surface()->surfaceClass() == QSurface::Offscreen) { auto offscreen = static_cast(surface); if (!offscreen->buffer()) { auto buffer = new QOpenGLFramebufferObject(surface->surface()->size()); offscreen->setBuffer(buffer); } return offscreen->buffer()->bind(); } else { EGLSurface eglSurface = static_cast(surface)->eglSurface(); ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE); ASSERT(eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext) == EGL_TRUE); if (ubuntumirclient().isDebugEnabled()) { printOpenGLESConfig(); } return true; } } void UbuntuOpenGLContext::doneCurrent() { ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE); ASSERT(eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) == EGL_TRUE); } void UbuntuOpenGLContext::swapBuffers(QPlatformSurface* surface) { UbuntuWindow *ubuntuWindow = static_cast(surface); EGLSurface eglSurface = ubuntuWindow->eglSurface(); ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE); ASSERT(eglSwapBuffers(mEglDisplay, eglSurface) == EGL_TRUE); ubuntuWindow->onSwapBuffersDone(); } void (*UbuntuOpenGLContext::getProcAddress(const QByteArray& procName)) () { ASSERT(eglBindAPI(api_in_use()) == EGL_TRUE); return eglGetProcAddress(procName.constData()); } qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/backingstore.h0000644000015600001650000000302012674203424024533 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_BACKING_STORE_H #define UBUNTU_BACKING_STORE_H #include class QOpenGLContext; class QOpenGLTexture; class QOpenGLTextureBlitter; class UbuntuBackingStore : public QPlatformBackingStore { public: UbuntuBackingStore(QWindow* window); virtual ~UbuntuBackingStore(); // QPlatformBackingStore methods. void beginPaint(const QRegion&) override; void flush(QWindow* window, const QRegion& region, const QPoint& offset) override; void resize(const QSize& size, const QRegion& staticContents) override; QPaintDevice* paintDevice() override; protected: void updateTexture(); private: QScopedPointer mContext; QScopedPointer mTexture; QScopedPointer mBlitter; QImage mImage; QRegion mDirty; }; #endif // UBUNTU_BACKING_STORE_H qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/plugin.h0000644000015600001650000000213512674203424023364 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_CLIENT_PLUGIN_H #define UBUNTU_CLIENT_PLUGIN_H #include class UbuntuMirClientIntegrationPlugin : public QPlatformIntegrationPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "ubuntumirclient.json") public: QStringList keys() const; QPlatformIntegration* create(const QString&, const QStringList&); }; #endif // UBUNTU_CLIENT_PLUGIN_H qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/screen.h0000644000015600001650000000470012674203424023345 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014-2015 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_SCREEN_H #define UBUNTU_SCREEN_H #include #include #include #include "cursor.h" struct MirConnection; class UbuntuScreen : public QObject, public QPlatformScreen { Q_OBJECT public: UbuntuScreen(MirConnection *connection); virtual ~UbuntuScreen(); // QPlatformScreen methods. QImage::Format format() const override { return mFormat; } int depth() const override { return mDepth; } QRect geometry() const override { return mGeometry; } QRect availableGeometry() const override { return mGeometry; } QSizeF physicalSize() const override { return mPhysicalSize; } Qt::ScreenOrientation nativeOrientation() const override { return mNativeOrientation; } Qt::ScreenOrientation orientation() const override { return mNativeOrientation; } QPlatformCursor *cursor() const override { return const_cast(&mCursor); } // New methods. QSurfaceFormat surfaceFormat() const { return mSurfaceFormat; } EGLDisplay eglDisplay() const { return mEglDisplay; } EGLConfig eglConfig() const { return mEglConfig; } EGLNativeDisplayType eglNativeDisplay() const { return mEglNativeDisplay; } void handleWindowSurfaceResize(int width, int height); uint32_t mirOutputId() const { return mOutputId; } // QObject methods. void customEvent(QEvent* event) override; private: QRect mGeometry; QSizeF mPhysicalSize; Qt::ScreenOrientation mNativeOrientation; Qt::ScreenOrientation mCurrentOrientation; QImage::Format mFormat; int mDepth; uint32_t mOutputId; QSurfaceFormat mSurfaceFormat; EGLDisplay mEglDisplay; EGLConfig mEglConfig; EGLNativeDisplayType mEglNativeDisplay; UbuntuCursor mCursor; }; #endif // UBUNTU_SCREEN_H qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/ubuntumirclient.json0000644000015600001650000000004612674203424026040 0ustar pbuserpbgroup00000000000000{ "Keys": [ "ubuntumirclient" ] } qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/theme.h0000644000015600001650000000200412674203424023163 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_THEME_H #define UBUNTU_THEME_H #include class UbuntuTheme : public QGenericUnixTheme { public: static const char* name; UbuntuTheme(); virtual ~UbuntuTheme(); // From QPlatformTheme QVariant themeHint(ThemeHint hint) const override; }; #endif // UBUNTU_THEME_H qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/glcontext.h0000644000015600001650000000306112674203424024074 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_OPENGL_CONTEXT_H #define UBUNTU_OPENGL_CONTEXT_H #include #include "screen.h" class UbuntuOpenGLContext : public QPlatformOpenGLContext { public: UbuntuOpenGLContext(UbuntuScreen* screen, UbuntuOpenGLContext* share); virtual ~UbuntuOpenGLContext(); // QPlatformOpenGLContext methods. QSurfaceFormat format() const override { return mScreen->surfaceFormat(); } void swapBuffers(QPlatformSurface* surface) override; bool makeCurrent(QPlatformSurface* surface) override; void doneCurrent() override; bool isValid() const override { return mEglContext != EGL_NO_CONTEXT; } void (*getProcAddress(const QByteArray& procName)) () override; EGLContext eglContext() const { return mEglContext; } private: UbuntuScreen* mScreen; EGLContext mEglContext; EGLDisplay mEglDisplay; }; #endif // UBUNTU_OPENGL_CONTEXT_H qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/platformservices.cpp0000644000015600001650000000315512674203424026014 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "platformservices.h" #include #include #include bool UbuntuPlatformServices::openUrl(const QUrl &url) { return callDispatcher(url); } bool UbuntuPlatformServices::openDocument(const QUrl &url) { return callDispatcher(url); } bool UbuntuPlatformServices::callDispatcher(const QUrl &url) { UAUrlDispatcherSession* session = ua_url_dispatcher_session(); if (!session) return false; ua_url_dispatcher_session_open(session, url.toEncoded().constData(), NULL, NULL); free(session); // We are returning true here because the other option // is spawning a nested event loop and wait for the // callback. But there is no guarantee on how fast // the callback is going to be so we prefer to avoid the // nested event loop. Long term plan is improve Qt API // to support an async openUrl return true; } qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/input.cpp0000644000015600001650000006017212674203446023571 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014-2015 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ // Local #include "input.h" #include "integration.h" #include "nativeinterface.h" #include "screen.h" #include "window.h" #include "logging.h" #include "orientationchangeevent_p.h" // Qt #include #include #include #include #include #include #include #include #include #include Q_LOGGING_CATEGORY(ubuntumirclientInput, "ubuntumirclient.input", QtWarningMsg) namespace { // XKB Keysyms which do not map directly to Qt types (i.e. Unicode points) static const uint32_t KeyTable[] = { 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, // dead keys XKB_KEY_dead_grave, Qt::Key_Dead_Grave, XKB_KEY_dead_acute, Qt::Key_Dead_Acute, XKB_KEY_dead_circumflex, Qt::Key_Dead_Circumflex, XKB_KEY_dead_tilde, Qt::Key_Dead_Tilde, XKB_KEY_dead_macron, Qt::Key_Dead_Macron, XKB_KEY_dead_breve, Qt::Key_Dead_Breve, XKB_KEY_dead_abovedot, Qt::Key_Dead_Abovedot, XKB_KEY_dead_diaeresis, Qt::Key_Dead_Diaeresis, XKB_KEY_dead_abovering, Qt::Key_Dead_Abovering, XKB_KEY_dead_doubleacute, Qt::Key_Dead_Doubleacute, XKB_KEY_dead_caron, Qt::Key_Dead_Caron, XKB_KEY_dead_cedilla, Qt::Key_Dead_Cedilla, XKB_KEY_dead_ogonek, Qt::Key_Dead_Ogonek, XKB_KEY_dead_iota, Qt::Key_Dead_Iota, XKB_KEY_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound, XKB_KEY_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound, XKB_KEY_dead_belowdot, Qt::Key_Dead_Belowdot, XKB_KEY_dead_hook, Qt::Key_Dead_Hook, XKB_KEY_dead_horn, Qt::Key_Dead_Horn, XKB_KEY_Mode_switch, Qt::Key_Mode_switch, XKB_KEY_script_switch, Qt::Key_Mode_switch, XKB_KEY_XF86AudioRaiseVolume, Qt::Key_VolumeUp, XKB_KEY_XF86AudioLowerVolume, Qt::Key_VolumeDown, XKB_KEY_XF86PowerOff, Qt::Key_PowerOff, XKB_KEY_XF86PowerDown, Qt::Key_PowerDown, 0, 0 }; Qt::WindowState mirSurfaceStateToWindowState(MirSurfaceState state) { switch (state) { case mir_surface_state_fullscreen: return Qt::WindowFullScreen; case mir_surface_state_maximized: case mir_surface_state_vertmaximized: case mir_surface_state_horizmaximized: return Qt::WindowMaximized; case mir_surface_state_minimized: return Qt::WindowMinimized; case mir_surface_state_hidden: // We should be handling this state separately. Q_ASSERT(false); case mir_surface_state_restored: case mir_surface_state_unknown: default: return Qt::WindowNoState; } } } // namespace class UbuntuEvent : public QEvent { public: UbuntuEvent(UbuntuWindow* window, const MirEvent *event, QEvent::Type type) : QEvent(type), window(window) { nativeEvent = mir_event_ref(event); } ~UbuntuEvent() { mir_event_unref(nativeEvent); } QPointer window; const MirEvent *nativeEvent; }; UbuntuInput::UbuntuInput(UbuntuClientIntegration* integration) : QObject(nullptr) , mIntegration(integration) , mEventFilterType(static_cast( integration->nativeInterface())->genericEventFilterType()) , mEventType(static_cast(QEvent::registerEventType())) , mLastFocusedWindow(nullptr) { // Initialize touch device. mTouchDevice = new QTouchDevice; mTouchDevice->setType(QTouchDevice::TouchScreen); mTouchDevice->setCapabilities( QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::Pressure | QTouchDevice::NormalizedPosition); QWindowSystemInterface::registerTouchDevice(mTouchDevice); } UbuntuInput::~UbuntuInput() { // Qt will take care of deleting mTouchDevice. } static const char* nativeEventTypeToStr(MirEventType t) { switch (t) { case mir_event_type_key: return "mir_event_type_key"; case mir_event_type_motion: return "mir_event_type_motion"; case mir_event_type_surface: return "mir_event_type_surface"; case mir_event_type_resize: return "mir_event_type_resize"; case mir_event_type_prompt_session_state_change: return "mir_event_type_prompt_session_state_change"; case mir_event_type_orientation: return "mir_event_type_orientation"; case mir_event_type_close_surface: return "mir_event_type_close_surface"; case mir_event_type_input: return "mir_event_type_input"; default: return "invalid"; } } void UbuntuInput::customEvent(QEvent* event) { Q_ASSERT(QThread::currentThread() == thread()); UbuntuEvent* ubuntuEvent = static_cast(event); const MirEvent *nativeEvent = ubuntuEvent->nativeEvent; if ((ubuntuEvent->window == nullptr) || (ubuntuEvent->window->window() == nullptr)) { qCWarning(ubuntumirclient) << "Attempted to deliver an event to a non-existent window, ignoring."; return; } // Event filtering. long result; if (QWindowSystemInterface::handleNativeEvent( ubuntuEvent->window->window(), mEventFilterType, const_cast(static_cast(nativeEvent)), &result) == true) { qCDebug(ubuntumirclient, "event filtered out by native interface"); return; } qCDebug(ubuntumirclientInput, "customEvent(type=%s)", nativeEventTypeToStr(mir_event_get_type(nativeEvent))); // Event dispatching. switch (mir_event_get_type(nativeEvent)) { case mir_event_type_input: dispatchInputEvent(ubuntuEvent->window, mir_event_get_input_event(nativeEvent)); break; case mir_event_type_resize: { Q_ASSERT(ubuntuEvent->window->screen() == mIntegration->screen()); auto resizeEvent = mir_event_get_resize_event(nativeEvent); mIntegration->screen()->handleWindowSurfaceResize( mir_resize_event_get_width(resizeEvent), mir_resize_event_get_height(resizeEvent)); ubuntuEvent->window->handleSurfaceResized(mir_resize_event_get_width(resizeEvent), mir_resize_event_get_height(resizeEvent)); break; } case mir_event_type_surface: { auto surfaceEvent = mir_event_get_surface_event(nativeEvent); auto surfaceEventAttribute = mir_surface_event_get_attribute(surfaceEvent); if (surfaceEventAttribute == mir_surface_attrib_focus) { const bool focused = mir_surface_event_get_attribute_value(surfaceEvent) == mir_surface_focused; // Mir may have sent a pair of focus lost/gained events, so we need to "peek" into the queue // so that we don't deactivate windows prematurely. if (focused) { mPendingFocusGainedEvents--; ubuntuEvent->window->handleSurfaceFocused(); QWindowSystemInterface::handleWindowActivated(ubuntuEvent->window->window(), Qt::ActiveWindowFocusReason); // NB: Since processing of system events is queued, never check qGuiApp->applicationState() // as it might be outdated. Always call handleApplicationStateChanged() with the latest // state regardless. QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive); } else if(!mPendingFocusGainedEvents) { qCDebug(ubuntumirclient, "No windows have focus"); QWindowSystemInterface::handleWindowActivated(nullptr, Qt::ActiveWindowFocusReason); QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive); } } else if (surfaceEventAttribute == mir_surface_attrib_state) { MirSurfaceState state = static_cast(mir_surface_event_get_attribute_value(surfaceEvent)); if (state == mir_surface_state_hidden) { ubuntuEvent->window->handleSurfaceVisibilityChanged(false); } else { // it's visible! ubuntuEvent->window->handleSurfaceVisibilityChanged(true); ubuntuEvent->window->handleSurfaceStateChanged(mirSurfaceStateToWindowState(state)); } } break; } case mir_event_type_orientation: dispatchOrientationEvent(ubuntuEvent->window->window(), mir_event_get_orientation_event(nativeEvent)); break; case mir_event_type_close_surface: QWindowSystemInterface::handleCloseEvent(ubuntuEvent->window->window()); break; default: qCDebug(ubuntumirclient, "unhandled event type: %d", static_cast(mir_event_get_type(nativeEvent))); } } void UbuntuInput::postEvent(UbuntuWindow *platformWindow, const MirEvent *event) { QWindow *window = platformWindow->window(); const auto eventType = mir_event_get_type(event); if (mir_event_type_surface == eventType) { auto surfaceEvent = mir_event_get_surface_event(event); if (mir_surface_attrib_focus == mir_surface_event_get_attribute(surfaceEvent)) { const bool focused = mir_surface_event_get_attribute_value(surfaceEvent) == mir_surface_focused; if (focused) { mPendingFocusGainedEvents++; } } } QCoreApplication::postEvent(this, new UbuntuEvent( platformWindow, event, mEventType)); if ((window->flags().testFlag(Qt::WindowTransparentForInput)) && window->parent()) { QCoreApplication::postEvent(this, new UbuntuEvent( static_cast(platformWindow->QPlatformWindow::parent()), event, mEventType)); } } void UbuntuInput::dispatchInputEvent(UbuntuWindow *window, const MirInputEvent *ev) { switch (mir_input_event_get_type(ev)) { case mir_input_event_type_key: dispatchKeyEvent(window, ev); break; case mir_input_event_type_touch: dispatchTouchEvent(window, ev); break; case mir_input_event_type_pointer: dispatchPointerEvent(window, ev); break; default: break; } } void UbuntuInput::dispatchTouchEvent(UbuntuWindow *window, const MirInputEvent *ev) { const MirTouchEvent *tev = mir_input_event_get_touch_event(ev); // FIXME(loicm) Max pressure is device specific. That one is for the Samsung Galaxy Nexus. That // needs to be fixed as soon as the compat input lib adds query support. const float kMaxPressure = 1.28; const QRect kWindowGeometry = window->geometry(); QList touchPoints; // TODO: Is it worth setting the Qt::TouchPointStationary ones? Currently they are left // as Qt::TouchPointMoved const unsigned int kPointerCount = mir_touch_event_point_count(tev); for (unsigned int i = 0; i < kPointerCount; ++i) { QWindowSystemInterface::TouchPoint touchPoint; const float kX = mir_touch_event_axis_value(tev, i, mir_touch_axis_x) + kWindowGeometry.x(); const float kY = mir_touch_event_axis_value(tev, i, mir_touch_axis_y) + kWindowGeometry.y(); // see bug lp:1346633 workaround comments elsewhere const float kW = mir_touch_event_axis_value(tev, i, mir_touch_axis_touch_major); const float kH = mir_touch_event_axis_value(tev, i, mir_touch_axis_touch_minor); const float kP = mir_touch_event_axis_value(tev, i, mir_touch_axis_pressure); touchPoint.id = mir_touch_event_id(tev, i); touchPoint.normalPosition = QPointF(kX / kWindowGeometry.width(), kY / kWindowGeometry.height()); touchPoint.area = QRectF(kX - (kW / 2.0), kY - (kH / 2.0), kW, kH); touchPoint.pressure = kP / kMaxPressure; MirTouchAction touch_action = mir_touch_event_action(tev, i); switch (touch_action) { case mir_touch_action_down: mLastFocusedWindow = window; touchPoint.state = Qt::TouchPointPressed; break; case mir_touch_action_up: touchPoint.state = Qt::TouchPointReleased; break; case mir_touch_action_change: default: touchPoint.state = Qt::TouchPointMoved; } touchPoints.append(touchPoint); } ulong timestamp = mir_input_event_get_event_time(ev) / 1000000; QWindowSystemInterface::handleTouchEvent(window->window(), timestamp, mTouchDevice, touchPoints); } static uint32_t translateKeysym(uint32_t sym, const QString &text) { int code = 0; QTextCodec *systemCodec = QTextCodec::codecForLocale(); if (sym < 128 || (sym < 256 && systemCodec->mibEnum() == 4)) { // upper-case key, if known code = isprint((int)sym) ? toupper((int)sym) : 0; } else if (sym >= XKB_KEY_F1 && sym <= XKB_KEY_F35) { return Qt::Key_F1 + (int(sym) - XKB_KEY_F1); } else if (text.length() == 1 && text.unicode()->unicode() > 0x1f && text.unicode()->unicode() != 0x7f && !(sym >= XKB_KEY_dead_grave && sym <= XKB_KEY_dead_currency)) { code = text.unicode()->toUpper().unicode(); } else { for (int i = 0; KeyTable[i]; i += 2) if (sym == KeyTable[i]) code = KeyTable[i + 1]; } return code; } namespace { Qt::KeyboardModifiers qt_modifiers_from_mir(MirInputEventModifiers modifiers) { Qt::KeyboardModifiers q_modifiers = Qt::NoModifier; if (modifiers & mir_input_event_modifier_shift) { q_modifiers |= Qt::ShiftModifier; } if (modifiers & mir_input_event_modifier_ctrl) { q_modifiers |= Qt::ControlModifier; } if (modifiers & mir_input_event_modifier_alt) { q_modifiers |= Qt::AltModifier; } if (modifiers & mir_input_event_modifier_meta) { q_modifiers |= Qt::MetaModifier; } if (modifiers & mir_input_event_modifier_alt_right) { q_modifiers |= Qt::GroupSwitchModifier; } return q_modifiers; } } void UbuntuInput::dispatchKeyEvent(UbuntuWindow *window, const MirInputEvent *event) { const MirKeyboardEvent *key_event = mir_input_event_get_keyboard_event(event); ulong timestamp = mir_input_event_get_event_time(event) / 1000000; xkb_keysym_t xk_sym = mir_keyboard_event_key_code(key_event); quint32 scan_code = mir_keyboard_event_scan_code(key_event); quint32 native_modifiers = mir_keyboard_event_modifiers(key_event); // Key modifier and unicode index mapping. auto modifiers = qt_modifiers_from_mir(mir_keyboard_event_modifiers(key_event)); MirKeyboardAction action = mir_keyboard_event_action(key_event); QEvent::Type keyType = action == mir_keyboard_action_up ? QEvent::KeyRelease : QEvent::KeyPress; if (action == mir_keyboard_action_down) mLastFocusedWindow = window; QString text; QVarLengthArray chars(32); { int result = xkb_keysym_to_utf8(xk_sym, chars.data(), chars.size()); if (result > 0) { text = QString::fromUtf8(chars.constData()); } } int sym = translateKeysym(xk_sym, text); bool is_auto_rep = action == mir_keyboard_action_repeat; QPlatformInputContext *context = QGuiApplicationPrivate::platformIntegration()->inputContext(); if (context) { QKeyEvent qKeyEvent(keyType, sym, modifiers, scan_code, xk_sym, native_modifiers, text, is_auto_rep); qKeyEvent.setTimestamp(timestamp); if (context->filterEvent(&qKeyEvent)) { qCDebug(ubuntumirclient, "key event filtered out by input context"); return; } } QWindowSystemInterface::handleExtendedKeyEvent(window->window(), timestamp, keyType, sym, modifiers, scan_code, xk_sym, native_modifiers, text, is_auto_rep); } namespace { Qt::MouseButtons extract_buttons(const MirPointerEvent *pev) { Qt::MouseButtons buttons = Qt::NoButton; if (mir_pointer_event_button_state(pev, mir_pointer_button_primary)) buttons |= Qt::LeftButton; if (mir_pointer_event_button_state(pev, mir_pointer_button_secondary)) buttons |= Qt::RightButton; if (mir_pointer_event_button_state(pev, mir_pointer_button_tertiary)) buttons |= Qt::MiddleButton; if (mir_pointer_event_button_state(pev, mir_pointer_button_back)) buttons |= Qt::BackButton; if (mir_pointer_event_button_state(pev, mir_pointer_button_forward)) buttons |= Qt::ForwardButton; return buttons; } } void UbuntuInput::dispatchPointerEvent(UbuntuWindow *platformWindow, const MirInputEvent *ev) { auto window = platformWindow->window(); auto timestamp = mir_input_event_get_event_time(ev) / 1000000; auto pev = mir_input_event_get_pointer_event(ev); auto action = mir_pointer_event_action(pev); auto localPoint = QPointF(mir_pointer_event_axis_value(pev, mir_pointer_axis_x), mir_pointer_event_axis_value(pev, mir_pointer_axis_y)); auto modifiers = qt_modifiers_from_mir(mir_pointer_event_modifiers(pev)); switch (action) { case mir_pointer_action_button_up: case mir_pointer_action_button_down: case mir_pointer_action_motion: { const float hDelta = mir_pointer_event_axis_value(pev, mir_pointer_axis_hscroll); const float vDelta = mir_pointer_event_axis_value(pev, mir_pointer_axis_vscroll); if (hDelta != 0 || vDelta != 0) { const QPoint angleDelta = QPoint(hDelta * 15, vDelta * 15); QWindowSystemInterface::handleWheelEvent(window, timestamp, localPoint, window->position() + localPoint, QPoint(), angleDelta, modifiers, Qt::ScrollUpdate); } auto buttons = extract_buttons(pev); QWindowSystemInterface::handleMouseEvent(window, timestamp, localPoint, window->position() + localPoint /* Should we omit global point instead? */, buttons, modifiers); break; } case mir_pointer_action_enter: QWindowSystemInterface::handleEnterEvent(window, localPoint, window->position() + localPoint); break; case mir_pointer_action_leave: QWindowSystemInterface::handleLeaveEvent(window); break; default: qCDebug(ubuntumirclient, "Unrecognized pointer event"); } } static const char* nativeOrientationDirectionToStr(MirOrientation orientation) { switch (orientation) { case mir_orientation_normal: return "Normal"; break; case mir_orientation_left: return "Left"; break; case mir_orientation_inverted: return "Inverted"; break; case mir_orientation_right: return "Right"; break; default: return "INVALID!"; } } void UbuntuInput::dispatchOrientationEvent(QWindow *window, const MirOrientationEvent *event) { MirOrientation mir_orientation = mir_orientation_event_get_direction(event); qCDebug(ubuntumirclientInput, "orientation direction: %s", nativeOrientationDirectionToStr(mir_orientation)); if (!window->screen()) { qCDebug(ubuntumirclient, "Window has no associated screen, dropping orientation event"); return; } OrientationChangeEvent::Orientation orientation; switch (mir_orientation) { case mir_orientation_normal: orientation = OrientationChangeEvent::TopUp; break; case mir_orientation_left: orientation = OrientationChangeEvent::LeftUp; break; case mir_orientation_inverted: orientation = OrientationChangeEvent::TopDown; break; case mir_orientation_right: orientation = OrientationChangeEvent::RightUp; break; default: qCDebug(ubuntumirclient, "No such orientation %d", mir_orientation); return; } // Dispatch orientation event to [Platform]Screen, as that is where Qt reads it. Screen will handle // notifying Qt of the actual orientation change - done to prevent multiple Windows each creating // an identical orientation change event and passing it directly to Qt. // [Platform]Screen can also factor in the native orientation. QCoreApplication::postEvent(static_cast(window->screen()->handle()), new OrientationChangeEvent(OrientationChangeEvent::mType, orientation)); } qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/integration.cpp0000644000015600001650000002036412674203424024750 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014-2015 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ // Local #include "integration.h" #include "backingstore.h" #include "clipboard.h" #include "glcontext.h" #include "input.h" #include "logging.h" #include "nativeinterface.h" #include "offscreensurface.h" #include "screen.h" #include "theme.h" #include "window.h" // Qt #include #include #include #include #include #include #include #include // platform-api #include #include #include static void resumedCallback(const UApplicationOptions *options, void* context) { Q_UNUSED(options) Q_UNUSED(context) Q_ASSERT(context != NULL); if (qGuiApp->focusWindow()) { QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive); } else { QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive); } } static void aboutToStopCallback(UApplicationArchive *archive, void* context) { Q_UNUSED(archive) Q_ASSERT(context != NULL); UbuntuClientIntegration* integration = static_cast(context); QPlatformInputContext *inputContext = integration->inputContext(); if (inputContext) { inputContext->hideInputPanel(); } else { qCWarning(ubuntumirclient) << "aboutToStopCallback(): no input context"; } QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationSuspended); } UbuntuClientIntegration::UbuntuClientIntegration() : QPlatformIntegration() , mNativeInterface(new UbuntuNativeInterface) , mFontDb(new QGenericUnixFontDatabase) , mServices(new UbuntuPlatformServices) , mClipboard(new UbuntuClipboard) , mScaleFactor(1.0) { setupOptions(); setupDescription(); // Create new application instance mInstance = u_application_instance_new_from_description_with_options(mDesc, mOptions); if (mInstance == nullptr) qFatal("UbuntuClientIntegration: connection to Mir server failed. Check that a Mir server is\n" "running, and the correct socket is being used and is accessible. The shell may have\n" "rejected the incoming connection, so check its log file"); mNativeInterface->setMirConnection(u_application_instance_get_mir_connection(mInstance)); // Create default screen. mScreen = new UbuntuScreen(u_application_instance_get_mir_connection(mInstance)); screenAdded(mScreen); // Initialize input. if (qEnvironmentVariableIsEmpty("QTUBUNTU_NO_INPUT")) { mInput = new UbuntuInput(this); mInputContext = QPlatformInputContextFactory::create(); } else { mInput = nullptr; mInputContext = nullptr; } // compute the scale factor const int defaultGridUnit = 8; int gridUnit = defaultGridUnit; QByteArray gridUnitString = qgetenv("GRID_UNIT_PX"); if (!gridUnitString.isEmpty()) { bool ok; gridUnit = gridUnitString.toInt(&ok); if (!ok) { gridUnit = defaultGridUnit; } } mScaleFactor = static_cast(gridUnit) / defaultGridUnit; } UbuntuClientIntegration::~UbuntuClientIntegration() { delete mInput; delete mInputContext; delete mScreen; delete mServices; } QPlatformServices *UbuntuClientIntegration::services() const { return mServices; } void UbuntuClientIntegration::setupOptions() { QStringList args = QCoreApplication::arguments(); int argc = args.size() + 1; char **argv = new char*[argc]; for (int i = 0; i < argc - 1; i++) argv[i] = qstrdup(args.at(i).toLocal8Bit()); argv[argc - 1] = nullptr; mOptions = u_application_options_new_from_cmd_line(argc - 1, argv); for (int i = 0; i < argc; i++) delete [] argv[i]; delete [] argv; } void UbuntuClientIntegration::setupDescription() { mDesc = u_application_description_new(); UApplicationId* id = u_application_id_new_from_stringn("QtUbuntu", 8); u_application_description_set_application_id(mDesc, id); UApplicationLifecycleDelegate* delegate = u_application_lifecycle_delegate_new(); u_application_lifecycle_delegate_set_application_resumed_cb(delegate, &resumedCallback); u_application_lifecycle_delegate_set_application_about_to_stop_cb(delegate, &aboutToStopCallback); u_application_lifecycle_delegate_set_context(delegate, this); u_application_description_set_application_lifecycle_delegate(mDesc, delegate); } QPlatformWindow* UbuntuClientIntegration::createPlatformWindow(QWindow* window) const { return const_cast(this)->createPlatformWindow(window); } QPlatformWindow* UbuntuClientIntegration::createPlatformWindow(QWindow* window) { return new UbuntuWindow(window, mClipboard, static_cast(mScreen), mInput, u_application_instance_get_mir_connection(mInstance)); } bool UbuntuClientIntegration::hasCapability(QPlatformIntegration::Capability cap) const { switch (cap) { case ThreadedPixmaps: return true; case OpenGL: return true; case ApplicationState: return true; case ThreadedOpenGL: if (qEnvironmentVariableIsEmpty("QTUBUNTU_NO_THREADED_OPENGL")) { return true; } else { qCDebug(ubuntumirclient, "disabled threaded OpenGL"); return false; } case MultipleWindows: case NonFullScreenWindows: return true; default: return QPlatformIntegration::hasCapability(cap); } } QAbstractEventDispatcher *UbuntuClientIntegration::createEventDispatcher() const { return createUnixEventDispatcher(); } QPlatformBackingStore* UbuntuClientIntegration::createPlatformBackingStore(QWindow* window) const { return new UbuntuBackingStore(window); } QPlatformOpenGLContext* UbuntuClientIntegration::createPlatformOpenGLContext( QOpenGLContext* context) const { return const_cast(this)->createPlatformOpenGLContext(context); } QPlatformOpenGLContext* UbuntuClientIntegration::createPlatformOpenGLContext( QOpenGLContext* context) { return new UbuntuOpenGLContext(static_cast(context->screen()->handle()), static_cast(context->shareHandle())); } QStringList UbuntuClientIntegration::themeNames() const { return QStringList(UbuntuTheme::name); } QPlatformTheme* UbuntuClientIntegration::createPlatformTheme(const QString& name) const { Q_UNUSED(name); return new UbuntuTheme; } QVariant UbuntuClientIntegration::styleHint(StyleHint hint) const { switch (hint) { case QPlatformIntegration::StartDragDistance: { // default is 10 pixels (see QPlatformTheme::defaultThemeHint) return 10.0 * mScaleFactor; } case QPlatformIntegration::PasswordMaskDelay: { // return time in milliseconds - 1 second return QVariant(1000); } default: break; } return QPlatformIntegration::styleHint(hint); } QPlatformClipboard* UbuntuClientIntegration::clipboard() const { return mClipboard.data(); } QPlatformNativeInterface* UbuntuClientIntegration::nativeInterface() const { return mNativeInterface; } QPlatformOffscreenSurface *UbuntuClientIntegration::createPlatformOffscreenSurface( QOffscreenSurface *surface) const { return new UbuntuOffscreenSurface(surface); } qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/window.h0000644000015600001650000000444112674203435023401 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014-2015 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_WINDOW_H #define UBUNTU_WINDOW_H #include #include #include #include #include class UbuntuClipboard; class UbuntuInput; class UbuntuScreen; class UbuntuSurface; struct MirConnection; struct MirSurface; class UbuntuWindow : public QObject, public QPlatformWindow { Q_OBJECT public: UbuntuWindow(QWindow *w, const QSharedPointer &clipboard, UbuntuScreen *screen, UbuntuInput *input, MirConnection *mirConnection); virtual ~UbuntuWindow(); // QPlatformWindow methods. WId winId() const override; void setGeometry(const QRect&) override; void setWindowState(Qt::WindowState state) override; void setWindowFlags(Qt::WindowFlags flags) override; void setVisible(bool visible) override; void setWindowTitle(const QString &title) override; void propagateSizeHints() override; bool isExposed() const override; // New methods. void *eglSurface() const; MirSurface *mirSurface() const; void handleSurfaceResized(int width, int height); void handleSurfaceFocused(); void handleSurfaceVisibilityChanged(bool visible); void handleSurfaceStateChanged(Qt::WindowState state); void onSwapBuffersDone(); private: void enablePanelHeightHack(bool enable); void updateSurfaceState(); mutable QMutex mMutex; const WId mId; const QSharedPointer mClipboard; Qt::WindowState mWindowState; Qt::WindowFlags mWindowFlags; bool mWindowVisible; std::unique_ptr mSurface; }; #endif // UBUNTU_WINDOW_H qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/plugin.cpp0000644000015600001650000000266612674203424023730 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "plugin.h" #include "integration.h" #include "logging.h" Q_LOGGING_CATEGORY(ubuntumirclient, "ubuntumirclient", QtWarningMsg) QStringList UbuntuMirClientIntegrationPlugin::keys() const { QStringList list; list << QStringLiteral("ubuntumirclient"); return list; } QPlatformIntegration* UbuntuMirClientIntegrationPlugin::create(const QString &system, const QStringList &) { if (system.toLower() == QLatin1String("ubuntumirclient")) { #ifdef PLATFORM_API_TOUCH setenv("UBUNTU_PLATFORM_API_BACKEND", "touch_mirclient", 1); #else setenv("UBUNTU_PLATFORM_API_BACKEND", "desktop_mirclient", 1); #endif return new UbuntuClientIntegration; } else { return 0; } } qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/backingstore.cpp0000644000015600001650000000771712674203424025107 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "backingstore.h" #include "logging.h" #include #include #include #include #include UbuntuBackingStore::UbuntuBackingStore(QWindow* window) : QPlatformBackingStore(window) , mContext(new QOpenGLContext) , mTexture(new QOpenGLTexture(QOpenGLTexture::Target2D)) , mBlitter(new QOpenGLTextureBlitter) { mContext->setFormat(window->requestedFormat()); mContext->setScreen(window->screen()); mContext->create(); window->setSurfaceType(QSurface::OpenGLSurface); } UbuntuBackingStore::~UbuntuBackingStore() { } void UbuntuBackingStore::flush(QWindow* window, const QRegion& region, const QPoint& offset) { Q_UNUSED(region); Q_UNUSED(offset); mContext->makeCurrent(window); glViewport(0, 0, window->width(), window->height()); updateTexture(); if (!mBlitter->isCreated()) mBlitter->create(); mBlitter->bind(); mBlitter->setSwizzleRB(true); mBlitter->blit(mTexture->textureId(), QMatrix4x4(), QOpenGLTextureBlitter::OriginTopLeft); mBlitter->release(); mContext->swapBuffers(window); } void UbuntuBackingStore::updateTexture() { if (mDirty.isNull()) return; if (!mTexture->isCreated()) { mTexture->setMinificationFilter(QOpenGLTexture::Nearest); mTexture->setMagnificationFilter(QOpenGLTexture::Nearest); mTexture->setWrapMode(QOpenGLTexture::ClampToEdge); mTexture->setData(mImage, QOpenGLTexture::DontGenerateMipMaps); mTexture->create(); } mTexture->bind(); QRegion fixed; QRect imageRect = mImage.rect(); /* Following code taken from QEGLPlatformBackingStore under the terms of the Lesser GPL v2.1 licence * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). */ Q_FOREACH (const QRect &rect, mDirty.rects()) { // intersect with image rect to be sure QRect r = imageRect & rect; // if the rect is wide enough it is cheaper to just extend it instead of doing an image copy if (r.width() >= imageRect.width() / 2) { r.setX(0); r.setWidth(imageRect.width()); } fixed |= r; } Q_FOREACH (const QRect &rect, fixed.rects()) { // if the sub-rect is full-width we can pass the image data directly to // OpenGL instead of copying, since there is no gap between scanlines if (rect.width() == imageRect.width()) { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, rect.y(), rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE, mImage.constScanLine(rect.y())); } else { glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x(), rect.y(), rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE, mImage.copy(rect).constBits()); } } /* End of code taken from QEGLPlatformBackingStore */ mDirty = QRegion(); } void UbuntuBackingStore::beginPaint(const QRegion& region) { mDirty |= region; } void UbuntuBackingStore::resize(const QSize& size, const QRegion& /*staticContents*/) { mImage = QImage(size, QImage::Format_RGB32); if (mTexture->isCreated()) mTexture->destroy(); } QPaintDevice* UbuntuBackingStore::paintDevice() { return &mImage; } qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/window.cpp0000644000015600001650000006246612674203435023747 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014-2015 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ // Local #include "window.h" #include "clipboard.h" #include "input.h" #include "screen.h" #include "logging.h" #include // Qt #include #include #include #include // Platform API #include #include Q_LOGGING_CATEGORY(ubuntumirclientBufferSwap, "ubuntumirclient.bufferSwap", QtWarningMsg) const Qt::WindowType LowChromeWindowHint = (Qt::WindowType)0x00800000; namespace { // FIXME: this used to be defined by platform-api, but it's been removed in v3. Change ubuntu-keyboard to use // a different enum for window roles. enum UAUiWindowRole { U_MAIN_ROLE = 1, U_DASH_ROLE, U_INDICATOR_ROLE, U_NOTIFICATIONS_ROLE, U_GREETER_ROLE, U_LAUNCHER_ROLE, U_ON_SCREEN_KEYBOARD_ROLE, U_SHUTDOWN_DIALOG_ROLE, }; struct MirSpecDeleter { void operator()(MirSurfaceSpec *spec) { mir_surface_spec_release(spec); } }; using Spec = std::unique_ptr; EGLNativeWindowType nativeWindowFor(MirSurface *surf) { auto stream = mir_surface_get_buffer_stream(surf); return reinterpret_cast(mir_buffer_stream_get_egl_native_window(stream)); } const char *qtWindowStateToStr(Qt::WindowState state) { switch (state) { case Qt::WindowNoState: return "NoState"; case Qt::WindowFullScreen: return "FullScreen"; case Qt::WindowMaximized: return "Maximized"; case Qt::WindowMinimized: return "Minimized"; case Qt::WindowActive: return "Active"; default: return "!?"; } } const char *mirSurfaceStateToStr(MirSurfaceState surfaceState) { switch (surfaceState) { case mir_surface_state_unknown: return "unknown"; case mir_surface_state_restored: return "restored"; case mir_surface_state_minimized: return "minimized"; case mir_surface_state_maximized: return "vertmaximized"; case mir_surface_state_vertmaximized: return "vertmaximized"; case mir_surface_state_fullscreen: return "fullscreen"; case mir_surface_state_horizmaximized: return "horizmaximized"; case mir_surface_state_hidden: return "hidden"; default: return "!?"; } } MirSurfaceState qtWindowStateToMirSurfaceState(Qt::WindowState state) { switch (state) { case Qt::WindowNoState: return mir_surface_state_restored; case Qt::WindowFullScreen: return mir_surface_state_fullscreen; case Qt::WindowMaximized: return mir_surface_state_maximized; case Qt::WindowMinimized: return mir_surface_state_minimized; default: qCWarning(ubuntumirclient, "Unexpected Qt::WindowState: %d", state); return mir_surface_state_restored; } } WId makeId() { static int id = 1; return id++; } MirPixelFormat defaultPixelFormatFor(MirConnection *connection) { MirPixelFormat format; unsigned int nformats; mir_connection_get_available_surface_formats(connection, &format, 1, &nformats); return format; } UAUiWindowRole roleFor(QWindow *window) { QVariant roleVariant = window->property("role"); if (!roleVariant.isValid()) return U_MAIN_ROLE; uint role = roleVariant.toUInt(); if (role < U_MAIN_ROLE || role > U_SHUTDOWN_DIALOG_ROLE) return U_MAIN_ROLE; return static_cast(role); } UbuntuWindow *transientParentFor(QWindow *window) { QWindow *parent = window->transientParent(); return parent ? static_cast(parent->handle()) : nullptr; } Spec makeSurfaceSpec(QWindow *window, UbuntuInput *input, MirConnection *connection) { const auto geom = window->geometry(); const int width = geom.width() > 0 ? geom.width() : 1; const int height = geom.height() > 0 ? geom.height() : 1; const auto pixelFormat = defaultPixelFormatFor(connection); if (U_ON_SCREEN_KEYBOARD_ROLE == roleFor(window)) { qCDebug(ubuntumirclient, "makeSurfaceSpec(window=%p) - creating input method surface (width=%d, height=%d", window, width, height); return Spec{mir_connection_create_spec_for_input_method(connection, width, height, pixelFormat)}; } const Qt::WindowType type = window->type(); if (type == Qt::Popup) { auto parent = transientParentFor(window); if (parent == nullptr) { //NOTE: We cannot have a parentless popup - //try using the last surface to receive input as that will most likely be //the one that caused this popup to be created parent = input->lastFocusedWindow(); } if (parent) { auto pos = geom.topLeft(); pos -= parent->geometry().topLeft(); MirRectangle location{pos.x(), pos.y(), 0, 0}; qCDebug(ubuntumirclient, "makeSurfaceSpec(window=%p) - creating menu surface(width:%d, height:%d)", window, width, height); return Spec{mir_connection_create_spec_for_menu( connection, width, height, pixelFormat, parent->mirSurface(), &location, mir_edge_attachment_any)}; } else { qCDebug(ubuntumirclient, "makeSurfaceSpec(window=%p) - cannot create a menu without a parent!", window); } } else if (type == Qt::Dialog) { auto parent = transientParentFor(window); if (parent) { // Modal dialog qCDebug(ubuntumirclient, "makeSurfaceSpec(window=%p) - creating modal dialog (width=%d, height=%d", window, width, height); return Spec{mir_connection_create_spec_for_modal_dialog(connection, width, height, pixelFormat, parent->mirSurface())}; } else { // TODO: do Qt parentless dialogs have the same semantics as mir? qCDebug(ubuntumirclient, "makeSurfaceSpec(window=%p) - creating parentless dialog (width=%d, height=%d)", window, width, height); return Spec{mir_connection_create_spec_for_dialog(connection, width, height, pixelFormat)}; } } qCDebug(ubuntumirclient, "makeSurfaceSpec(window=%p) - creating normal surface(type=0x%x, width=%d, height=%d)", window, type, width, height); return Spec{mir_connection_create_spec_for_normal_surface(connection, width, height, pixelFormat)}; } void setSizingConstraints(MirSurfaceSpec *spec, const QSize& minSize, const QSize& maxSize, const QSize& increment) { mir_surface_spec_set_min_width(spec, minSize.width()); mir_surface_spec_set_min_height(spec, minSize.height()); if (maxSize.width() >= minSize.width()) { mir_surface_spec_set_max_width(spec, maxSize.width()); } if (maxSize.height() >= minSize.height()) { mir_surface_spec_set_max_height(spec, maxSize.height()); } if (increment.width() > 0) { mir_surface_spec_set_width_increment(spec, increment.width()); } if (increment.height() > 0) { mir_surface_spec_set_height_increment(spec, increment.height()); } } MirSurface *createMirSurface(QWindow *window, UbuntuScreen *screen, UbuntuInput *input, MirConnection *connection) { auto spec = makeSurfaceSpec(window, input, connection); const auto title = window->title().toUtf8(); mir_surface_spec_set_name(spec.get(), title.constData()); setSizingConstraints(spec.get(), window->minimumSize(), window->maximumSize(), window->sizeIncrement()); if (window->windowState() == Qt::WindowFullScreen) { mir_surface_spec_set_fullscreen_on_output(spec.get(), screen->mirOutputId()); } if (window->flags() & LowChromeWindowHint) { mir_surface_spec_set_shell_chrome(spec.get(), mir_shell_chrome_low); } auto surface = mir_surface_create_sync(spec.get()); Q_ASSERT(mir_surface_is_valid(surface)); return surface; } // FIXME - in order to work around https://bugs.launchpad.net/mir/+bug/1346633 // we need to guess the panel height (3GU) int panelHeight() { const int defaultGridUnit = 8; int gridUnit = defaultGridUnit; QByteArray gridUnitString = qgetenv("GRID_UNIT_PX"); if (!gridUnitString.isEmpty()) { bool ok; gridUnit = gridUnitString.toInt(&ok); if (!ok) { gridUnit = defaultGridUnit; } } return gridUnit * 3; } } //namespace class UbuntuSurface { public: UbuntuSurface(UbuntuWindow *platformWindow, UbuntuScreen *screen, UbuntuInput *input, MirConnection *connection) : mWindow(platformWindow->window()) , mPlatformWindow(platformWindow) , mInput(input) , mConnection(connection) , mMirSurface(createMirSurface(mWindow, screen, input, connection)) , mEglDisplay(screen->eglDisplay()) , mEglSurface(eglCreateWindowSurface(mEglDisplay, screen->eglConfig(), nativeWindowFor(mMirSurface), nullptr)) , mNeedsRepaint(false) , mParented(mWindow->transientParent() || mWindow->parent()) , mShellChrome(mWindow->flags() & LowChromeWindowHint ? mir_shell_chrome_low : mir_shell_chrome_normal) { mir_surface_set_event_handler(mMirSurface, surfaceEventCallback, this); // Window manager can give us a final size different from what we asked for // so let's check what we ended up getting MirSurfaceParameters parameters; mir_surface_get_parameters(mMirSurface, ¶meters); auto geom = mWindow->geometry(); geom.setWidth(parameters.width); geom.setHeight(parameters.height); if (mWindow->windowState() == Qt::WindowFullScreen) { geom.setY(0); } else { geom.setY(panelHeight()); } // Assume that the buffer size matches the surface size at creation time mBufferSize = geom.size(); platformWindow->QPlatformWindow::setGeometry(geom); QWindowSystemInterface::handleGeometryChange(mWindow, geom); qCDebug(ubuntumirclient, "created surface at (%d, %d) with size (%d, %d), title '%s', role: '%d'\n", geom.x(), geom.y(), geom.width(), geom.height(), mWindow->title().toUtf8().constData(), roleFor(mWindow)); } ~UbuntuSurface() { if (mEglSurface != EGL_NO_SURFACE) eglDestroySurface(mEglDisplay, mEglSurface); if (mMirSurface) mir_surface_release_sync(mMirSurface); } UbuntuSurface(UbuntuSurface const&) = delete; UbuntuSurface& operator=(UbuntuSurface const&) = delete; void resize(const QSize& newSize); void updateTitle(const QString& title); void setSizingConstraints(const QSize& minSize, const QSize& maxSize, const QSize& increment); void onSwapBuffersDone(); void handleSurfaceResized(int width, int height); int needsRepaint() const; MirSurfaceState state() const { return mir_surface_get_state(mMirSurface); } void setState(MirSurfaceState state); MirSurfaceType type() const { return mir_surface_get_type(mMirSurface); } void setShellChrome(MirShellChrome shellChrome); EGLSurface eglSurface() const { return mEglSurface; } MirSurface *mirSurface() const { return mMirSurface; } void setSurfaceParent(MirSurface*); bool hasParent() const { return mParented; } private: static void surfaceEventCallback(MirSurface* surface, const MirEvent *event, void* context); void postEvent(const MirEvent *event); QWindow * const mWindow; UbuntuWindow * const mPlatformWindow; UbuntuInput * const mInput; MirConnection * const mConnection; MirSurface * const mMirSurface; const EGLDisplay mEglDisplay; const EGLSurface mEglSurface; bool mNeedsRepaint; bool mParented; QSize mBufferSize; QMutex mTargetSizeMutex; QSize mTargetSize; MirShellChrome mShellChrome; }; void UbuntuSurface::resize(const QSize& size) { qCDebug(ubuntumirclient,"resize(window=%p, width=%d, height=%d)", mWindow, size.width(), size.height()); if (mWindow->windowState() == Qt::WindowFullScreen || mWindow->windowState() == Qt::WindowMaximized) { qCDebug(ubuntumirclient, "resize(window=%p) - not resizing, window is maximized or fullscreen", mWindow); return; } if (size.isEmpty()) { qCDebug(ubuntumirclient, "resize(window=%p) - not resizing, size is empty", mWindow); return; } Spec spec{mir_connection_create_spec_for_changes(mConnection)}; mir_surface_spec_set_width(spec.get(), size.width()); mir_surface_spec_set_height(spec.get(), size.height()); mir_surface_apply_spec(mMirSurface, spec.get()); } void UbuntuSurface::updateTitle(const QString& newTitle) { const auto title = newTitle.toUtf8(); Spec spec{mir_connection_create_spec_for_changes(mConnection)}; mir_surface_spec_set_name(spec.get(), title.constData()); mir_surface_apply_spec(mMirSurface, spec.get()); } void UbuntuSurface::setSizingConstraints(const QSize& minSize, const QSize& maxSize, const QSize& increment) { Spec spec{mir_connection_create_spec_for_changes(mConnection)}; ::setSizingConstraints(spec.get(), minSize, maxSize, increment); mir_surface_apply_spec(mMirSurface, spec.get()); } void UbuntuSurface::handleSurfaceResized(int width, int height) { QMutexLocker lock(&mTargetSizeMutex); // mir's resize event is mainly a signal that we need to redraw our content. We use the // width/height as identifiers to figure out if this is the latest surface resize event // that has posted, discarding any old ones. This avoids issuing too many redraw events. // see TODO in postEvent as the ideal way we should handle this. // The actual buffer size may or may have not changed at this point, so let the rendering // thread drive the window geometry updates. mNeedsRepaint = mTargetSize.width() == width && mTargetSize.height() == height; } int UbuntuSurface::needsRepaint() const { if (mNeedsRepaint) { if (mTargetSize != mBufferSize) { //If the buffer hasn't changed yet, we need at least two redraws, //once to get the new buffer size and propagate the geometry changes //and the second to redraw the content at the new size return 2; } else { // The buffer size has already been updated so we only need one redraw // to render at the new size return 1; } } return 0; } void UbuntuSurface::setState(MirSurfaceState state) { mir_wait_for(mir_surface_set_state(mMirSurface, state)); } void UbuntuSurface::setShellChrome(MirShellChrome chrome) { if (chrome != mShellChrome) { auto spec = Spec{mir_connection_create_spec_for_changes(mConnection)}; mir_surface_spec_set_shell_chrome(spec.get(), chrome); mir_surface_apply_spec(mMirSurface, spec.get()); mShellChrome = chrome; } } void UbuntuSurface::onSwapBuffersDone() { static int sFrameNumber = 0; ++sFrameNumber; EGLint eglSurfaceWidth = -1; EGLint eglSurfaceHeight = -1; eglQuerySurface(mEglDisplay, mEglSurface, EGL_WIDTH, &eglSurfaceWidth); eglQuerySurface(mEglDisplay, mEglSurface, EGL_HEIGHT, &eglSurfaceHeight); const bool validSize = eglSurfaceWidth > 0 && eglSurfaceHeight > 0; if (validSize && (mBufferSize.width() != eglSurfaceWidth || mBufferSize.height() != eglSurfaceHeight)) { qCDebug(ubuntumirclientBufferSwap, "onSwapBuffersDone(window=%p) [%d] - size changed (%d, %d) => (%d, %d)", mWindow, sFrameNumber, mBufferSize.width(), mBufferSize.height(), eglSurfaceWidth, eglSurfaceHeight); mBufferSize.rwidth() = eglSurfaceWidth; mBufferSize.rheight() = eglSurfaceHeight; QRect newGeometry = mPlatformWindow->geometry(); newGeometry.setSize(mBufferSize); mPlatformWindow->QPlatformWindow::setGeometry(newGeometry); QWindowSystemInterface::handleGeometryChange(mWindow, newGeometry); } else { qCDebug(ubuntumirclientBufferSwap, "onSwapBuffersDone(window=%p) [%d] - buffer size (%d,%d)", mWindow, sFrameNumber, mBufferSize.width(), mBufferSize.height()); } } void UbuntuSurface::surfaceEventCallback(MirSurface *surface, const MirEvent *event, void* context) { Q_UNUSED(surface); Q_ASSERT(context != nullptr); auto s = static_cast(context); s->postEvent(event); } void UbuntuSurface::postEvent(const MirEvent *event) { if (mir_event_type_resize == mir_event_get_type(event)) { // TODO: The current event queue just accumulates all resize events; // It would be nicer if we could update just one event if that event has not been dispatched. // As a workaround, we use the width/height as an identifier of this latest event // so the event handler (handleSurfaceResized) can discard/ignore old ones. const auto resizeEvent = mir_event_get_resize_event(event); const auto width = mir_resize_event_get_width(resizeEvent); const auto height = mir_resize_event_get_height(resizeEvent); qCDebug(ubuntumirclient, "resizeEvent(window=%p, width=%d, height=%d)", mWindow, width, height); QMutexLocker lock(&mTargetSizeMutex); mTargetSize.rwidth() = width; mTargetSize.rheight() = height; } mInput->postEvent(mPlatformWindow, event); } void UbuntuSurface::setSurfaceParent(MirSurface* parent) { qCDebug(ubuntumirclient, "setSurfaceParent(window=%p)", mWindow); mParented = true; Spec spec{mir_connection_create_spec_for_changes(mConnection)}; mir_surface_spec_set_parent(spec.get(), parent); mir_surface_apply_spec(mMirSurface, spec.get()); } UbuntuWindow::UbuntuWindow(QWindow *w, const QSharedPointer &clipboard, UbuntuScreen *screen, UbuntuInput *input, MirConnection *connection) : QObject(nullptr) , QPlatformWindow(w) , mId(makeId()) , mClipboard(clipboard) , mWindowState(w->windowState()) , mWindowFlags(w->flags()) , mWindowVisible(false) , mSurface(new UbuntuSurface{this, screen, input, connection}) { qCDebug(ubuntumirclient, "UbuntuWindow(window=%p, screen=%p, input=%p, surf=%p)", w, screen, input, mSurface.get()); } UbuntuWindow::~UbuntuWindow() { qCDebug(ubuntumirclient, "~UbuntuWindow(window=%p)", this); } void UbuntuWindow::handleSurfaceResized(int width, int height) { QMutexLocker lock(&mMutex); qCDebug(ubuntumirclient, "handleSurfaceResize(window=%p, width=%d, height=%d)", window(), width, height); mSurface->handleSurfaceResized(width, height); // This resize event could have occurred just after the last buffer swap for this window. // This means the client may still be holding a buffer with the older size. The first redraw call // will then render at the old size. After swapping the client now will get a new buffer with the // updated size but it still needs re-rendering so another redraw may be needed. // A mir API to drop the currently held buffer would help here, so that we wouldn't have to redraw twice auto const numRepaints = mSurface->needsRepaint(); lock.unlock(); qCDebug(ubuntumirclient, "handleSurfaceResize(window=%p) redraw %d times", window(), numRepaints); for (int i = 0; i < numRepaints; i++) { qCDebug(ubuntumirclient, "handleSurfaceResize(window=%p) repainting width=%d, height=%d", window(), geometry().size().width(), geometry().size().height()); QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); } } void UbuntuWindow::handleSurfaceFocused() { qCDebug(ubuntumirclient, "handleSurfaceFocused(window=%p)", window()); // System clipboard contents might have changed while this window was unfocused and without // this process getting notified about it because it might have been suspended (due to // application lifecycle policies), thus unable to listen to any changes notified through // D-Bus. // Therefore let's ensure we are up to date with the system clipboard now that we are getting // focused again. mClipboard->requestDBusClipboardContents(); } void UbuntuWindow::handleSurfaceVisibilityChanged(bool visible) { qCDebug(ubuntumirclient, "handleSurfaceFocused(window=%p)", window()); if (mWindowVisible == visible) return; mWindowVisible = visible; QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); } void UbuntuWindow::handleSurfaceStateChanged(Qt::WindowState state) { qCDebug(ubuntumirclient, "handleSurfaceStateChanged(window=%p, %s)", window(), qtWindowStateToStr(state)); if (mWindowState == state) return; mWindowState = state; QWindowSystemInterface::handleWindowStateChanged(window(), state); } void UbuntuWindow::setWindowState(Qt::WindowState state) { QMutexLocker lock(&mMutex); qCDebug(ubuntumirclient, "setWindowState(window=%p, %s)", this, qtWindowStateToStr(state)); if (mWindowState == state) return; mWindowState = state; lock.unlock(); updateSurfaceState(); } void UbuntuWindow::setWindowFlags(Qt::WindowFlags flags) { QMutexLocker lock(&mMutex); qCDebug(ubuntumirclient, "setWindowFlags(window=%p, 0x%x)", this, (int)flags); if (mWindowFlags == flags) return; mWindowFlags = flags; mSurface->setShellChrome(mWindowFlags & LowChromeWindowHint ? mir_shell_chrome_low : mir_shell_chrome_normal); } /* FIXME: Mir does not let clients know the position of their windows in the virtual desktop space. So we have this ugly hack that assumes a phone situation where the window is always on the top-left corner, right below the indicators panel if not in fullscreen. */ void UbuntuWindow::enablePanelHeightHack(bool enable) { QMutexLocker lock(&mMutex); QRect newGeometry = geometry(); if (enable) { newGeometry.setY(panelHeight()); } else { newGeometry.setY(0); } if (newGeometry != geometry()) { lock.unlock(); QPlatformWindow::setGeometry(newGeometry); QWindowSystemInterface::handleGeometryChange(window(), newGeometry); } } void UbuntuWindow::setGeometry(const QRect& rect) { QMutexLocker lock(&mMutex); qCDebug(ubuntumirclient, "setGeometry (window=%p, x=%d, y=%d, width=%d, height=%d)", window(), rect.x(), rect.y(), rect.width(), rect.height()); //NOTE: mir surfaces cannot be moved by the client so ignore the topLeft coordinates const auto newSize = rect.size(); auto newGeometry = geometry(); newGeometry.setSize(newSize); QPlatformWindow::setGeometry(newGeometry); mSurface->resize(newSize); } void UbuntuWindow::setVisible(bool visible) { QMutexLocker lock(&mMutex); qCDebug(ubuntumirclient, "setVisible (window=%p, visible=%s)", window(), visible ? "true" : "false"); if (mWindowVisible == visible) return; mWindowVisible = visible; if (visible) { if (!mSurface->hasParent() && window()->type() == Qt::Dialog) { // The dialog may have been parented after creation time // so morph it into a modal dialog auto parent = transientParentFor(window()); if (parent) { mSurface->setSurfaceParent(parent->mirSurface()); } } } lock.unlock(); updateSurfaceState(); QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); QWindowSystemInterface::flushWindowSystemEvents(); } void UbuntuWindow::setWindowTitle(const QString& title) { QMutexLocker lock(&mMutex); qCDebug(ubuntumirclient, "setWindowTitle(window=%p) title=%s)", window(), title.toUtf8().constData()); mSurface->updateTitle(title); } void UbuntuWindow::propagateSizeHints() { QMutexLocker lock(&mMutex); const auto win = window(); qCDebug(ubuntumirclient, "propagateSizeHints(window=%p) min(%d,%d), max(%d,%d) increment(%d, %d)", win, win->minimumSize().width(), win->minimumSize().height(), win->maximumSize().width(), win->maximumSize().height(), win->sizeIncrement().width(), win->sizeIncrement().height()); mSurface->setSizingConstraints(win->minimumSize(), win->maximumSize(), win->sizeIncrement()); } bool UbuntuWindow::isExposed() const { return mWindowVisible; } void* UbuntuWindow::eglSurface() const { return mSurface->eglSurface(); } MirSurface *UbuntuWindow::mirSurface() const { return mSurface->mirSurface(); } WId UbuntuWindow::winId() const { return mId; } void UbuntuWindow::onSwapBuffersDone() { QMutexLocker lock(&mMutex); mSurface->onSwapBuffersDone(); } void UbuntuWindow::updateSurfaceState() { QMutexLocker lock(&mMutex); MirSurfaceState newState = mWindowVisible ? qtWindowStateToMirSurfaceState(mWindowState) : mir_surface_state_hidden; qCDebug(ubuntumirclient, "updateSurfaceState (window=%p, surfaceState=%s)", window(), mirSurfaceStateToStr(newState)); if (newState != mSurface->state()) { mSurface->setState(newState); lock.unlock(); enablePanelHeightHack(newState != mir_surface_state_fullscreen); } } qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/nativeinterface.cpp0000644000015600001650000001120312674203424025564 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ // Local #include "nativeinterface.h" #include "screen.h" #include "glcontext.h" // Qt #include #include #include #include class UbuntuResourceMap : public QMap { public: UbuntuResourceMap() : QMap() { insert("egldisplay", UbuntuNativeInterface::EglDisplay); insert("eglcontext", UbuntuNativeInterface::EglContext); insert("nativeorientation", UbuntuNativeInterface::NativeOrientation); insert("display", UbuntuNativeInterface::Display); insert("mirconnection", UbuntuNativeInterface::MirConnection); } }; Q_GLOBAL_STATIC(UbuntuResourceMap, ubuntuResourceMap) UbuntuNativeInterface::UbuntuNativeInterface() : mGenericEventFilterType(QByteArrayLiteral("Event")) , mNativeOrientation(nullptr) , mMirConnection(nullptr) { } UbuntuNativeInterface::~UbuntuNativeInterface() { delete mNativeOrientation; mNativeOrientation = nullptr; } void* UbuntuNativeInterface::nativeResourceForIntegration(const QByteArray &resourceString) { const QByteArray lowerCaseResource = resourceString.toLower(); if (!ubuntuResourceMap()->contains(lowerCaseResource)) { return nullptr; } const ResourceType resourceType = ubuntuResourceMap()->value(lowerCaseResource); if (resourceType == UbuntuNativeInterface::MirConnection) { return mMirConnection; } else { return nullptr; } } void* UbuntuNativeInterface::nativeResourceForContext( const QByteArray& resourceString, QOpenGLContext* context) { if (!context) return nullptr; const QByteArray kLowerCaseResource = resourceString.toLower(); if (!ubuntuResourceMap()->contains(kLowerCaseResource)) return nullptr; const ResourceType kResourceType = ubuntuResourceMap()->value(kLowerCaseResource); if (kResourceType == UbuntuNativeInterface::EglContext) return static_cast(context->handle())->eglContext(); else return nullptr; } void* UbuntuNativeInterface::nativeResourceForWindow(const QByteArray& resourceString, QWindow* window) { const QByteArray kLowerCaseResource = resourceString.toLower(); if (!ubuntuResourceMap()->contains(kLowerCaseResource)) return NULL; const ResourceType kResourceType = ubuntuResourceMap()->value(kLowerCaseResource); if (kResourceType == UbuntuNativeInterface::EglDisplay) { if (window) { return static_cast(window->screen()->handle())->eglDisplay(); } else { return static_cast( QGuiApplication::primaryScreen()->handle())->eglDisplay(); } } else if (kResourceType == UbuntuNativeInterface::NativeOrientation) { // Return the device's native screen orientation. if (window) { UbuntuScreen *ubuntuScreen = static_cast(window->screen()->handle()); mNativeOrientation = new Qt::ScreenOrientation(ubuntuScreen->nativeOrientation()); } else { QPlatformScreen *platformScreen = QGuiApplication::primaryScreen()->handle(); mNativeOrientation = new Qt::ScreenOrientation(platformScreen->nativeOrientation()); } return mNativeOrientation; } else { return NULL; } } void* UbuntuNativeInterface::nativeResourceForScreen(const QByteArray& resourceString, QScreen* screen) { const QByteArray kLowerCaseResource = resourceString.toLower(); if (!ubuntuResourceMap()->contains(kLowerCaseResource)) return NULL; const ResourceType kResourceType = ubuntuResourceMap()->value(kLowerCaseResource); if (kResourceType == UbuntuNativeInterface::Display) { if (!screen) screen = QGuiApplication::primaryScreen(); return static_cast(screen->handle())->eglNativeDisplay(); } else return NULL; } qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/cursor.cpp0000644000015600001650000001375512674203424023750 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2015 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "cursor.h" #include "logging.h" #include "window.h" #include UbuntuCursor::UbuntuCursor(MirConnection *connection) : mConnection(connection) { mShapeToCursorName[Qt::ArrowCursor] = "left_ptr"; mShapeToCursorName[Qt::UpArrowCursor] = "up_arrow"; mShapeToCursorName[Qt::CrossCursor] = "cross"; mShapeToCursorName[Qt::WaitCursor] = "watch"; mShapeToCursorName[Qt::IBeamCursor] = "xterm"; mShapeToCursorName[Qt::SizeVerCursor] = "size_ver"; mShapeToCursorName[Qt::SizeHorCursor] = "size_hor"; mShapeToCursorName[Qt::SizeBDiagCursor] = "size_bdiag"; mShapeToCursorName[Qt::SizeFDiagCursor] = "size_fdiag"; mShapeToCursorName[Qt::SizeAllCursor] = "size_all"; mShapeToCursorName[Qt::BlankCursor] = "blank"; mShapeToCursorName[Qt::SplitVCursor] = "split_v"; mShapeToCursorName[Qt::SplitHCursor] = "split_h"; mShapeToCursorName[Qt::PointingHandCursor] = "hand"; mShapeToCursorName[Qt::ForbiddenCursor] = "forbidden"; mShapeToCursorName[Qt::WhatsThisCursor] = "whats_this"; mShapeToCursorName[Qt::BusyCursor] = "left_ptr_watch"; mShapeToCursorName[Qt::OpenHandCursor] = "openhand"; mShapeToCursorName[Qt::ClosedHandCursor] = "closedhand"; mShapeToCursorName[Qt::DragCopyCursor] = "dnd-copy"; mShapeToCursorName[Qt::DragMoveCursor] = "dnd-move"; mShapeToCursorName[Qt::DragLinkCursor] = "dnd-link"; } namespace { const char *qtCursorShapeToStr(Qt::CursorShape shape) { switch(shape) { case Qt::ArrowCursor: return "Arrow"; case Qt::UpArrowCursor: return "UpArrow"; case Qt::CrossCursor: return "Cross"; case Qt::WaitCursor: return "Wait"; case Qt::IBeamCursor: return "IBeam"; case Qt::SizeVerCursor: return "SizeVer"; case Qt::SizeHorCursor: return "SizeHor"; case Qt::SizeBDiagCursor: return "SizeBDiag"; case Qt::SizeFDiagCursor: return "SizeFDiag"; case Qt::SizeAllCursor: return "SizeAll"; case Qt::BlankCursor: return "Blank"; case Qt::SplitVCursor: return "SplitV"; case Qt::SplitHCursor: return "SplitH"; case Qt::PointingHandCursor: return "PointingHand"; case Qt::ForbiddenCursor: return "Forbidden"; case Qt::WhatsThisCursor: return "WhatsThis"; case Qt::BusyCursor: return "Busy"; case Qt::OpenHandCursor: return "OpenHand"; case Qt::ClosedHandCursor: return "ClosedHand"; case Qt::DragCopyCursor: return "DragCopy"; case Qt::DragMoveCursor: return "DragMove"; case Qt::DragLinkCursor: return "DragLink"; case Qt::BitmapCursor: return "Bitmap"; default: return "???"; } } } // anonymous namespace void UbuntuCursor::changeCursor(QCursor *windowCursor, QWindow *window) { if (!window) { return; } MirSurface *surface = static_cast(window->handle())->mirSurface(); if (!surface) { return; } if (windowCursor) { qCDebug(ubuntumirclient, "changeCursor shape=%s, window=%p", qtCursorShapeToStr(windowCursor->shape()), window); if (!windowCursor->pixmap().isNull()) { configureMirCursorWithPixmapQCursor(surface, *windowCursor); } else if (windowCursor->shape() == Qt::BitmapCursor) { // TODO: Implement bitmap cursor support applyDefaultCursorConfiguration(surface); } else { const auto &cursorName = mShapeToCursorName.value(windowCursor->shape(), QByteArray("left_ptr")); auto cursorConfiguration = mir_cursor_configuration_from_name(cursorName.data()); mir_surface_configure_cursor(surface, cursorConfiguration); mir_cursor_configuration_destroy(cursorConfiguration); } } else { applyDefaultCursorConfiguration(surface); } } void UbuntuCursor::configureMirCursorWithPixmapQCursor(MirSurface *surface, QCursor &cursor) { QImage image = cursor.pixmap().toImage(); if (image.format() != QImage::Format_ARGB32) { image.convertToFormat(QImage::Format_ARGB32); } MirBufferStream *bufferStream = mir_connection_create_buffer_stream_sync(mConnection, image.width(), image.height(), mir_pixel_format_argb_8888, mir_buffer_usage_software); { MirGraphicsRegion region; mir_buffer_stream_get_graphics_region(bufferStream, ®ion); char *regionLine = region.vaddr; Q_ASSERT(image.bytesPerLine() <= region.stride); for (int i = 0; i < image.height(); ++i) { memcpy(regionLine, image.scanLine(i), image.bytesPerLine()); regionLine += region.stride; } } mir_buffer_stream_swap_buffers_sync(bufferStream); { auto configuration = mir_cursor_configuration_from_buffer_stream(bufferStream, cursor.hotSpot().x(), cursor.hotSpot().y()); mir_surface_configure_cursor(surface, configuration); mir_cursor_configuration_destroy(configuration); } mir_buffer_stream_release_sync(bufferStream); } void UbuntuCursor::applyDefaultCursorConfiguration(MirSurface *surface) { auto cursorConfiguration = mir_cursor_configuration_from_name("left_ptr"); mir_surface_configure_cursor(surface, cursorConfiguration); mir_cursor_configuration_destroy(cursorConfiguration); } qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/platformservices.h0000644000015600001650000000222312674203424025454 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_PLATFORM_SERVICES_H #define UBUNTU_PLATFORM_SERVICES_H #include #include #include class UbuntuPlatformServices : public QPlatformServices { public: bool openUrl(const QUrl &url) override; bool openDocument(const QUrl &url) override; private: bool callDispatcher(const QUrl &url); }; #endif // UBUNTU_PLATFORM_SERVICES_H qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/clipboard.cpp0000644000015600001650000002366612674203424024374 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "clipboard.h" #include "logging.h" #include #include #include #include #include // FIXME(loicm) The clipboard data format is not defined by Ubuntu Platform API // which makes it impossible to have non-Qt applications communicate with Qt // applications through the clipboard API. The solution would be to have // Ubuntu Platform define the data format or propose an API that supports // embedding different mime types in the clipboard. // Data format: // number of mime types (sizeof(int)) // data layout ((4 * sizeof(int)) * number of mime types) // mime type string offset (sizeof(int)) // mime type string size (sizeof(int)) // data offset (sizeof(int)) // data size (sizeof(int)) // data (n bytes) namespace { const int maxFormatsCount = 16; const int maxBufferSize = 4 * 1024 * 1024; // 4 Mb } UbuntuClipboard::UbuntuClipboard() : mMimeData(new QMimeData) , mIsOutdated(true) , mUpdatesDisabled(false) , mDBusSetupDone(false) { } UbuntuClipboard::~UbuntuClipboard() { delete mMimeData; } void UbuntuClipboard::requestDBusClipboardContents() { if (!mDBusSetupDone) { setupDBus(); } if (!mPendingGetContentsCall.isNull()) return; QDBusPendingCall pendingCall = mDBusClipboard->asyncCall(QStringLiteral("GetContents")); mPendingGetContentsCall = new QDBusPendingCallWatcher(pendingCall, this); QObject::connect(mPendingGetContentsCall.data(), &QDBusPendingCallWatcher::finished, this, &UbuntuClipboard::onDBusClipboardGetContentsFinished); } void UbuntuClipboard::onDBusClipboardGetContentsFinished(QDBusPendingCallWatcher* call) { Q_ASSERT(call == mPendingGetContentsCall.data()); QDBusPendingReply reply = *call; if (reply.isError()) { qCCritical(ubuntumirclient, "Failed to get system clipboard contents via D-Bus. %s, %s", qPrintable(reply.error().name()), qPrintable(reply.error().message())); // TODO: Might try again later a number of times... } else { QByteArray serializedMimeData = reply.argumentAt<0>(); updateMimeData(serializedMimeData); } call->deleteLater(); } void UbuntuClipboard::onDBusClipboardSetContentsFinished(QDBusPendingCallWatcher *call) { QDBusPendingReply reply = *call; if (reply.isError()) { qCCritical(ubuntumirclient, "Failed to set the system clipboard contents via D-Bus. %s, %s", qPrintable(reply.error().name()), qPrintable(reply.error().message())); // TODO: Might try again later a number of times... } call->deleteLater(); } void UbuntuClipboard::updateMimeData(const QByteArray &serializedMimeData) { if (mUpdatesDisabled) return; QMimeData *newMimeData = deserializeMimeData(serializedMimeData); if (newMimeData) { delete mMimeData; mMimeData = newMimeData; mIsOutdated = false; emitChanged(QClipboard::Clipboard); } else { qCWarning(ubuntumirclient) << "Got invalid serialized mime data. Ignoring it."; } } void UbuntuClipboard::setupDBus() { QDBusConnection dbusConnection = QDBusConnection::sessionBus(); bool ok = dbusConnection.connect( QStringLiteral("com.canonical.QtMir"), QStringLiteral("/com/canonical/QtMir/Clipboard"), QStringLiteral("com.canonical.QtMir.Clipboard"), QStringLiteral("ContentsChanged"), this, SLOT(updateMimeData(QByteArray))); if (!ok) { qCCritical(ubuntumirclient) << "Failed to connect to ContentsChanged signal form the D-Bus system clipboard."; } mDBusClipboard = new QDBusInterface(QStringLiteral("com.canonical.QtMir"), QStringLiteral("/com/canonical/QtMir/Clipboard"), QStringLiteral("com.canonical.QtMir.Clipboard"), dbusConnection); mDBusSetupDone = true; } QByteArray UbuntuClipboard::serializeMimeData(QMimeData *mimeData) const { Q_ASSERT(mimeData != nullptr); const QStringList formats = mimeData->formats(); const int formatCount = qMin(formats.size(), maxFormatsCount); const int headerSize = sizeof(int) + (formatCount * 4 * sizeof(int)); int bufferSize = headerSize; for (int i = 0; i < formatCount; i++) bufferSize += formats[i].size() + mimeData->data(formats[i]).size(); QByteArray serializedMimeData; if (bufferSize <= maxBufferSize) { // Serialize data. serializedMimeData.resize(bufferSize); { char *buffer = serializedMimeData.data(); int* header = reinterpret_cast(serializedMimeData.data()); int offset = headerSize; header[0] = formatCount; for (int i = 0; i < formatCount; i++) { const QByteArray data = mimeData->data(formats[i]); const int formatOffset = offset; const int formatSize = formats[i].size(); const int dataOffset = offset + formatSize; const int dataSize = data.size(); memcpy(&buffer[formatOffset], formats[i].toLatin1().data(), formatSize); memcpy(&buffer[dataOffset], data.data(), dataSize); header[i*4+1] = formatOffset; header[i*4+2] = formatSize; header[i*4+3] = dataOffset; header[i*4+4] = dataSize; offset += formatSize + dataSize; } } } else { qCWarning(ubuntumirclient, "Not sending contents (%d bytes) to the global clipboard as it's" " bigger than the maximum allowed size of %d bytes", bufferSize, maxBufferSize); } return serializedMimeData; } QMimeData *UbuntuClipboard::deserializeMimeData(const QByteArray &serializedMimeData) const { if (static_cast(serializedMimeData.size()) < sizeof(int)) { // Data is invalid return nullptr; } QMimeData *mimeData = new QMimeData; const char* const buffer = serializedMimeData.constData(); const int* const header = reinterpret_cast(serializedMimeData.constData()); const int count = qMin(header[0], maxFormatsCount); for (int i = 0; i < count; i++) { const int formatOffset = header[i*4+1]; const int formatSize = header[i*4+2]; const int dataOffset = header[i*4+3]; const int dataSize = header[i*4+4]; if (formatOffset + formatSize <= serializedMimeData.size() && dataOffset + dataSize <= serializedMimeData.size()) { QString mimeType = QString::fromLatin1(&buffer[formatOffset], formatSize); QByteArray mimeDataBytes(&buffer[dataOffset], dataSize); mimeData->setData(mimeType, mimeDataBytes); } } return mimeData; } QMimeData* UbuntuClipboard::mimeData(QClipboard::Mode mode) { if (mode != QClipboard::Clipboard) return nullptr; if (mIsOutdated && mPendingGetContentsCall.isNull()) { requestDBusClipboardContents(); } // Return whatever we have at the moment instead of blocking until we have something. // // This might be called during app startup just for the sake of checking if some // "Paste" UI control should be enabled or not. // We will emit QClipboard::changed() once we finally have something. return mMimeData; } void UbuntuClipboard::setMimeData(QMimeData* mimeData, QClipboard::Mode mode) { if (mode != QClipboard::Clipboard) return; if (!mPendingGetContentsCall.isNull()) { // Ignore whatever comes from the system clipboard as we are going to change it anyway QObject::disconnect(mPendingGetContentsCall.data(), 0, this, 0); mUpdatesDisabled = true; mPendingGetContentsCall->waitForFinished(); mUpdatesDisabled = false; delete mPendingGetContentsCall.data(); } if (mimeData != nullptr) { QByteArray serializedMimeData = serializeMimeData(mimeData); if (!serializedMimeData.isEmpty()) { setDBusClipboardContents(serializedMimeData); } mMimeData = mimeData; emitChanged(QClipboard::Clipboard); } } bool UbuntuClipboard::supportsMode(QClipboard::Mode mode) const { return mode == QClipboard::Clipboard; } bool UbuntuClipboard::ownsMode(QClipboard::Mode mode) const { Q_UNUSED(mode); return false; } void UbuntuClipboard::setDBusClipboardContents(const QByteArray &clipboardContents) { if (!mDBusSetupDone) { setupDBus(); } if (!mPendingSetContentsCall.isNull()) { // Ignore any previous set call as we are going to overwrite it anyway QObject::disconnect(mPendingSetContentsCall.data(), 0, this, 0); mUpdatesDisabled = true; mPendingSetContentsCall->waitForFinished(); mUpdatesDisabled = false; delete mPendingSetContentsCall.data(); } QDBusPendingCall pendingCall = mDBusClipboard->asyncCall(QStringLiteral("SetContents"), clipboardContents); mPendingSetContentsCall = new QDBusPendingCallWatcher(pendingCall, this); QObject::connect(mPendingSetContentsCall.data(), &QDBusPendingCallWatcher::finished, this, &UbuntuClipboard::onDBusClipboardSetContentsFinished); } qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/offscreensurface.h0000644000015600001650000000241312674203424025410 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2016 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_OFFSCREEN_SURFACE_H #define UBUNTU_OFFSCREEN_SURFACE_H #include #include class QOpenGLFramebufferObject; class UbuntuOffscreenSurface : public QPlatformOffscreenSurface { public: UbuntuOffscreenSurface(QOffscreenSurface *offscreenSurface); QSurfaceFormat format() const override; bool isValid() const override; QOpenGLFramebufferObject* buffer() const; void setBuffer(QOpenGLFramebufferObject *buffer); private: QOpenGLFramebufferObject *m_buffer; QSurfaceFormat m_format; }; #endif // UBUNTU_OFFSCREEN_SURFACE_H qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/clipboard.h0000644000015600001650000000415612674203424024032 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_CLIPBOARD_H #define UBUNTU_CLIPBOARD_H #include #include #include class QDBusInterface; class QDBusPendingCallWatcher; class UbuntuClipboard : public QObject, public QPlatformClipboard { Q_OBJECT public: UbuntuClipboard(); virtual ~UbuntuClipboard(); // QPlatformClipboard methods. QMimeData* mimeData(QClipboard::Mode mode = QClipboard::Clipboard) override; void setMimeData(QMimeData* data, QClipboard::Mode mode = QClipboard::Clipboard) override; bool supportsMode(QClipboard::Mode mode) const override; bool ownsMode(QClipboard::Mode mode) const override; void requestDBusClipboardContents(); private Q_SLOTS: void onDBusClipboardGetContentsFinished(QDBusPendingCallWatcher*); void onDBusClipboardSetContentsFinished(QDBusPendingCallWatcher*); void updateMimeData(const QByteArray &serializedMimeData); private: void setupDBus(); QByteArray serializeMimeData(QMimeData *mimeData) const; QMimeData *deserializeMimeData(const QByteArray &serializedMimeData) const; void setDBusClipboardContents(const QByteArray &clipboardContents); QMimeData *mMimeData; bool mIsOutdated; QPointer mDBusClipboard; QPointer mPendingGetContentsCall; QPointer mPendingSetContentsCall; bool mUpdatesDisabled; bool mDBusSetupDone; }; #endif // UBUNTU_CLIPBOARD_H qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/integration.h0000644000015600001650000000562112674203424024414 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_CLIENT_INTEGRATION_H #define UBUNTU_CLIENT_INTEGRATION_H #include #include #include "platformservices.h" // platform-api #include #include class UbuntuClipboard; class UbuntuInput; class UbuntuNativeInterface; class UbuntuScreen; class UbuntuClientIntegration : public QPlatformIntegration { public: UbuntuClientIntegration(); virtual ~UbuntuClientIntegration(); // QPlatformIntegration methods. bool hasCapability(QPlatformIntegration::Capability cap) const override; QAbstractEventDispatcher *createEventDispatcher() const override; QPlatformNativeInterface* nativeInterface() const override; QPlatformBackingStore* createPlatformBackingStore(QWindow* window) const override; QPlatformOpenGLContext* createPlatformOpenGLContext(QOpenGLContext* context) const override; QPlatformFontDatabase* fontDatabase() const override { return mFontDb; } QStringList themeNames() const override; QPlatformTheme* createPlatformTheme(const QString& name) const override; QVariant styleHint(StyleHint hint) const override; QPlatformServices *services() const override; QPlatformWindow* createPlatformWindow(QWindow* window) const override; QPlatformInputContext* inputContext() const override { return mInputContext; } QPlatformClipboard* clipboard() const override; QPlatformOpenGLContext* createPlatformOpenGLContext(QOpenGLContext* context); QPlatformWindow* createPlatformWindow(QWindow* window); UbuntuScreen* screen() const { return mScreen; } QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override; private: void setupOptions(); void setupDescription(); UbuntuNativeInterface* mNativeInterface; QPlatformFontDatabase* mFontDb; UbuntuPlatformServices* mServices; UbuntuScreen* mScreen; UbuntuInput* mInput; QPlatformInputContext* mInputContext; QSharedPointer mClipboard; qreal mScaleFactor; // Platform API stuff UApplicationOptions* mOptions; UApplicationDescription* mDesc; UApplicationInstance* mInstance; }; #endif // UBUNTU_CLIENT_INTEGRATION_H qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/offscreensurface.cpp0000644000015600001650000000252512674203424025747 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2016 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "offscreensurface.h" #include #include UbuntuOffscreenSurface::UbuntuOffscreenSurface(QOffscreenSurface *offscreenSurface) : QPlatformOffscreenSurface(offscreenSurface) , m_buffer(nullptr) , m_format(offscreenSurface->requestedFormat()) { } QSurfaceFormat UbuntuOffscreenSurface::format() const { return m_format; } bool UbuntuOffscreenSurface::isValid() const { return m_buffer != nullptr && m_buffer->isValid(); } QOpenGLFramebufferObject* UbuntuOffscreenSurface::buffer() const { return m_buffer; } void UbuntuOffscreenSurface::setBuffer(QOpenGLFramebufferObject *buffer) { m_buffer = buffer; } qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/input.h0000644000015600001650000000376212674203424023234 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014-2015 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_INPUT_H #define UBUNTU_INPUT_H // Qt #include #include #include #include class UbuntuClientIntegration; class UbuntuWindow; class UbuntuInput : public QObject { Q_OBJECT public: UbuntuInput(UbuntuClientIntegration* integration); virtual ~UbuntuInput(); // QObject methods. void customEvent(QEvent* event) override; void postEvent(UbuntuWindow* window, const MirEvent *event); UbuntuClientIntegration* integration() const { return mIntegration; } UbuntuWindow *lastFocusedWindow() const {return mLastFocusedWindow; } protected: void dispatchKeyEvent(UbuntuWindow *window, const MirInputEvent *event); void dispatchPointerEvent(UbuntuWindow *window, const MirInputEvent *event); void dispatchTouchEvent(UbuntuWindow *window, const MirInputEvent *event); void dispatchInputEvent(UbuntuWindow *window, const MirInputEvent *event); void dispatchOrientationEvent(QWindow* window, const MirOrientationEvent *event); private: UbuntuClientIntegration* mIntegration; QTouchDevice* mTouchDevice; const QByteArray mEventFilterType; const QEvent::Type mEventType; UbuntuWindow *mLastFocusedWindow; QAtomicInt mPendingFocusGainedEvents; }; #endif // UBUNTU_INPUT_H qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/nativeinterface.h0000644000015600001650000000354412674203424025242 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_NATIVE_INTERFACE_H #define UBUNTU_NATIVE_INTERFACE_H #include class UbuntuNativeInterface : public QPlatformNativeInterface { public: enum ResourceType { EglDisplay, EglContext, NativeOrientation, Display, MirConnection }; UbuntuNativeInterface(); ~UbuntuNativeInterface(); // QPlatformNativeInterface methods. void* nativeResourceForIntegration(const QByteArray &resource) override; void* nativeResourceForContext(const QByteArray& resourceString, QOpenGLContext* context) override; void* nativeResourceForWindow(const QByteArray& resourceString, QWindow* window) override; void* nativeResourceForScreen(const QByteArray& resourceString, QScreen* screen) override; // New methods. const QByteArray& genericEventFilterType() const { return mGenericEventFilterType; } void setMirConnection(void *mirConnection) { mMirConnection = mirConnection; } private: const QByteArray mGenericEventFilterType; Qt::ScreenOrientation* mNativeOrientation; void *mMirConnection; }; #endif // UBUNTU_NATIVE_INTERFACE_H qtubuntu-0.62+16.04.20160322/src/ubuntumirclient/screen.cpp0000644000015600001650000002622112674203424023702 0ustar pbuserpbgroup00000000000000/* * Copyright (C) 2014-2015 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ // local #include "screen.h" #include "logging.h" #include "orientationchangeevent_p.h" #include // Qt #include #include #include #include #include #include #include static const int kSwapInterval = 1; static const char *orientationToStr(Qt::ScreenOrientation orientation) { switch (orientation) { case Qt::PrimaryOrientation: return "primary"; case Qt::PortraitOrientation: return "portrait"; case Qt::LandscapeOrientation: return "landscape"; case Qt::InvertedPortraitOrientation: return "inverted portrait"; case Qt::InvertedLandscapeOrientation: return "inverted landscape"; default: return "INVALID!"; } } static void printEglConfig(EGLDisplay display, EGLConfig config) { Q_ASSERT(display != EGL_NO_DISPLAY); Q_ASSERT(config != nullptr); static const struct { const EGLint attrib; const char* name; } kAttribs[] = { { EGL_BUFFER_SIZE, "EGL_BUFFER_SIZE" }, { EGL_ALPHA_SIZE, "EGL_ALPHA_SIZE" }, { EGL_BLUE_SIZE, "EGL_BLUE_SIZE" }, { EGL_GREEN_SIZE, "EGL_GREEN_SIZE" }, { EGL_RED_SIZE, "EGL_RED_SIZE" }, { EGL_DEPTH_SIZE, "EGL_DEPTH_SIZE" }, { EGL_STENCIL_SIZE, "EGL_STENCIL_SIZE" }, { EGL_CONFIG_CAVEAT, "EGL_CONFIG_CAVEAT" }, { EGL_CONFIG_ID, "EGL_CONFIG_ID" }, { EGL_LEVEL, "EGL_LEVEL" }, { EGL_MAX_PBUFFER_HEIGHT, "EGL_MAX_PBUFFER_HEIGHT" }, { EGL_MAX_PBUFFER_PIXELS, "EGL_MAX_PBUFFER_PIXELS" }, { EGL_MAX_PBUFFER_WIDTH, "EGL_MAX_PBUFFER_WIDTH" }, { EGL_NATIVE_RENDERABLE, "EGL_NATIVE_RENDERABLE" }, { EGL_NATIVE_VISUAL_ID, "EGL_NATIVE_VISUAL_ID" }, { EGL_NATIVE_VISUAL_TYPE, "EGL_NATIVE_VISUAL_TYPE" }, { EGL_SAMPLES, "EGL_SAMPLES" }, { EGL_SAMPLE_BUFFERS, "EGL_SAMPLE_BUFFERS" }, { EGL_SURFACE_TYPE, "EGL_SURFACE_TYPE" }, { EGL_TRANSPARENT_TYPE, "EGL_TRANSPARENT_TYPE" }, { EGL_TRANSPARENT_BLUE_VALUE, "EGL_TRANSPARENT_BLUE_VALUE" }, { EGL_TRANSPARENT_GREEN_VALUE, "EGL_TRANSPARENT_GREEN_VALUE" }, { EGL_TRANSPARENT_RED_VALUE, "EGL_TRANSPARENT_RED_VALUE" }, { EGL_BIND_TO_TEXTURE_RGB, "EGL_BIND_TO_TEXTURE_RGB" }, { EGL_BIND_TO_TEXTURE_RGBA, "EGL_BIND_TO_TEXTURE_RGBA" }, { EGL_MIN_SWAP_INTERVAL, "EGL_MIN_SWAP_INTERVAL" }, { EGL_MAX_SWAP_INTERVAL, "EGL_MAX_SWAP_INTERVAL" }, { -1, NULL } }; const char* string = eglQueryString(display, EGL_VENDOR); qCDebug(ubuntumirclient, "EGL vendor: %s", string); string = eglQueryString(display, EGL_VERSION); qCDebug(ubuntumirclient, "EGL version: %s", string); string = eglQueryString(display, EGL_EXTENSIONS); qCDebug(ubuntumirclient, "EGL extensions: %s", string); qCDebug(ubuntumirclient, "EGL configuration attibutes:"); for (int index = 0; kAttribs[index].attrib != -1; index++) { EGLint value; if (eglGetConfigAttrib(display, config, kAttribs[index].attrib, &value)) qCDebug(ubuntumirclient, " %s: %d", kAttribs[index].name, static_cast(value)); } } const QEvent::Type OrientationChangeEvent::mType = static_cast(QEvent::registerEventType()); static const MirDisplayOutput *find_active_output( const MirDisplayConfiguration *conf) { const MirDisplayOutput *output = NULL; for (uint32_t d = 0; d < conf->num_outputs; d++) { const MirDisplayOutput *out = conf->outputs + d; if (out->used && out->connected && out->num_modes && out->current_mode < out->num_modes) { output = out; break; } } return output; } UbuntuScreen::UbuntuScreen(MirConnection *connection) : mFormat(QImage::Format_RGB32) , mDepth(32) , mOutputId(0) , mSurfaceFormat() , mEglDisplay(EGL_NO_DISPLAY) , mEglConfig(nullptr) , mCursor(connection) { // Initialize EGL. ASSERT(eglBindAPI(EGL_OPENGL_ES_API) == EGL_TRUE); mEglNativeDisplay = mir_connection_get_egl_native_display(connection); ASSERT((mEglDisplay = eglGetDisplay(mEglNativeDisplay)) != EGL_NO_DISPLAY); ASSERT(eglInitialize(mEglDisplay, nullptr, nullptr) == EGL_TRUE); // Configure EGL buffers format. mSurfaceFormat.setRedBufferSize(8); mSurfaceFormat.setGreenBufferSize(8); mSurfaceFormat.setBlueBufferSize(8); mSurfaceFormat.setAlphaBufferSize(8); mSurfaceFormat.setDepthBufferSize(24); mSurfaceFormat.setStencilBufferSize(8); if (!qEnvironmentVariableIsEmpty("QTUBUNTU_MULTISAMPLE")) { mSurfaceFormat.setSamples(4); qCDebug(ubuntumirclient, "setting MSAA to 4 samples"); } #ifdef QTUBUNTU_USE_OPENGL mSurfaceFormat.setRenderableType(QSurfaceFormat::OpenGL); #else mSurfaceFormat.setRenderableType(QSurfaceFormat::OpenGLES); #endif mEglConfig = q_configFromGLFormat(mEglDisplay, mSurfaceFormat, true); if (ubuntumirclient().isDebugEnabled()) { printEglConfig(mEglDisplay, mEglConfig); } // Set vblank swap interval. int swapInterval = kSwapInterval; QByteArray swapIntervalString = qgetenv("QTUBUNTU_SWAPINTERVAL"); if (!swapIntervalString.isEmpty()) { bool ok; swapInterval = swapIntervalString.toInt(&ok); if (!ok) swapInterval = kSwapInterval; } qCDebug(ubuntumirclient, "setting swap interval to %d", swapInterval); eglSwapInterval(mEglDisplay, swapInterval); // Get screen resolution. auto configDeleter = [](MirDisplayConfiguration *config) { mir_display_config_destroy(config); }; using configUp = std::unique_ptr; configUp displayConfig(mir_connection_create_display_config(connection), configDeleter); ASSERT(displayConfig != nullptr); auto const displayOutput = find_active_output(displayConfig.get()); ASSERT(displayOutput != nullptr); mOutputId = displayOutput->output_id; mPhysicalSize = QSizeF(displayOutput->physical_width_mm, displayOutput->physical_height_mm); qCDebug(ubuntumirclient, "screen physical size: %.2fx%.2f", mPhysicalSize.width(), mPhysicalSize.height()); const MirDisplayMode *mode = &displayOutput->modes[displayOutput->current_mode]; const int kScreenWidth = mode->horizontal_resolution; const int kScreenHeight = mode->vertical_resolution; Q_ASSERT(kScreenWidth > 0 && kScreenHeight > 0); qCDebug(ubuntumirclient, "screen resolution: %dx%d", kScreenWidth, kScreenHeight); mGeometry = QRect(0, 0, kScreenWidth, kScreenHeight); // Set the default orientation based on the initial screen dimmensions. mNativeOrientation = (mGeometry.width() >= mGeometry.height()) ? Qt::LandscapeOrientation : Qt::PortraitOrientation; // If it's a landscape device (i.e. some tablets), start in landscape, otherwise portrait mCurrentOrientation = (mNativeOrientation == Qt::LandscapeOrientation) ? Qt::LandscapeOrientation : Qt::PortraitOrientation; } UbuntuScreen::~UbuntuScreen() { eglTerminate(mEglDisplay); } void UbuntuScreen::customEvent(QEvent* event) { Q_ASSERT(QThread::currentThread() == thread()); OrientationChangeEvent* oReadingEvent = static_cast(event); switch (oReadingEvent->mOrientation) { case OrientationChangeEvent::LeftUp: { mCurrentOrientation = (screen()->primaryOrientation() == Qt::LandscapeOrientation) ? Qt::InvertedPortraitOrientation : Qt::LandscapeOrientation; break; } case OrientationChangeEvent::TopUp: { mCurrentOrientation = (screen()->primaryOrientation() == Qt::LandscapeOrientation) ? Qt::LandscapeOrientation : Qt::PortraitOrientation; break; } case OrientationChangeEvent::RightUp: { mCurrentOrientation = (screen()->primaryOrientation() == Qt::LandscapeOrientation) ? Qt::PortraitOrientation : Qt::InvertedLandscapeOrientation; break; } case OrientationChangeEvent::TopDown: { mCurrentOrientation = (screen()->primaryOrientation() == Qt::LandscapeOrientation) ? Qt::InvertedLandscapeOrientation : Qt::InvertedPortraitOrientation; break; } default: { qCDebug(ubuntumirclient, "UbuntuScreen::customEvent - Unknown orientation."); return; } } // Raise the event signal so that client apps know the orientation changed qCDebug(ubuntumirclient, "UbuntuScreen::customEvent - handling orientation change to %s", orientationToStr(mCurrentOrientation)); QWindowSystemInterface::handleScreenOrientationChange(screen(), mCurrentOrientation); } void UbuntuScreen::handleWindowSurfaceResize(int windowWidth, int windowHeight) { if ((windowWidth > windowHeight && mGeometry.width() < mGeometry.height()) || (windowWidth < windowHeight && mGeometry.width() > mGeometry.height())) { // The window aspect ratio differ's from the screen one. This means that // unity8 has rotated the window in its scene. // As there's no way to express window rotation in Qt's API, we have // Flip QScreen's dimensions so that orientation properties match // (primaryOrientation particularly). // FIXME: This assumes a phone scenario. Won't work, or make sense, // on the desktop QRect currGeometry = mGeometry; mGeometry.setWidth(currGeometry.height()); mGeometry.setHeight(currGeometry.width()); qCDebug(ubuntumirclient, "UbuntuScreen::handleWindowSurfaceResize - new screen geometry (w=%d, h=%d)", mGeometry.width(), mGeometry.height()); QWindowSystemInterface::handleScreenGeometryChange(screen(), mGeometry /* newGeometry */, mGeometry /* newAvailableGeometry */); if (mGeometry.width() < mGeometry.height()) { mCurrentOrientation = Qt::PortraitOrientation; } else { mCurrentOrientation = Qt::LandscapeOrientation; } qCDebug(ubuntumirclient, "UbuntuScreen::handleWindowSurfaceResize - new orientation %s",orientationToStr(mCurrentOrientation)); QWindowSystemInterface::handleScreenOrientationChange(screen(), mCurrentOrientation); } } qtubuntu-0.62+16.04.20160322/src/src.pro0000644000015600001650000000005712674203424017776 0ustar pbuserpbgroup00000000000000TEMPLATE = subdirs SUBDIRS += ubuntumirclient qtubuntu-0.62+16.04.20160322/README0000644000015600001650000000633212674203424016560 0ustar pbuserpbgroup00000000000000 1. Description 2. Running 3. Debug messages and logging 4. Building 5. QPA native interface 1. Description -------------- QtUbuntu contains a QPA (Qt Platform Abstraction) plugin based on the Ubuntu Platform API and Mir client API 2 Running --------- Considering the QPA plugin path is correctly set using either the QT_QPA_PLATFORM_PLUGIN_PATH environment variable or the "-platformpluginpath" command line switch, the following commands can be used to run with the Ubuntu QPA plugin: $ qmlscene -platform ubuntumirclient Foo.qml $ QT_QPA_PLATFORM=ubuntumirclient qmlscene Foo.qml The QPA plugins expose the following environment variables: QTUBUNTU_SWAPINTERVAL: Specifies the required swap interval as an integer. 1 by default. QTUBUNTU_MULTISAMPLE: Enables multisampling with using 4 samples per fragment. QTUBUNTU_NO_THREADED_OPENGL: Disables QtQuick threaded OpenGL rendering. QTUBUNTU_NO_INPUT: Disables touchscreen and buttons. QTUBUNTU_ICON_THEME: Specifies the default icon theme name. 3 Debug messages and logging ---------------------------- QtUbuntu uses Qt logging categories (see QLoggingCategory class documentation for more information). By default warnings and critical messages are logged and debug messages are disabled. QtUbuntu provides the following logging categories: * ubuntumirclient.input - Messages related to input and other Mir events. * ubuntumirclient.swapBuffers - Messages related to surface buffer swapping. * ubuntumirclient - For all other messages. 4. Building ----------- To compile QtUbuntu, create the makefiles with qmake and build with make: $ qmake $ make By default, QtUbuntu compiles a release build. To compile a debug build, the following qmake command should be used: $ qmake CONFIG+=debug 5. QPA native interface ----------------------- The QPA plugin exposes a native interface allowing to retrieve native handles and to filter out native events. In order to retrieve native handles, the following code can be used: #include #include ... QQuickView* view = new QQuickView(); ... QPlatformNativeInterface* native = QGuiApplication::platformNativeInterface(); printf("app: eglcontext=%p egldisplay=%p\n", native->nativeResourceForContext("eglcontext", view->openglContext()), native->nativeResourceForWindow("egldisplay", view)); Note that handles aren't valid until the application mainloop is started. The qmake .pro needs to add private gui include directories using QT += gui-private Some events exposed in the input compatibility layer can't be directly mapped to Qt. In order to retrieve such events, a native event filter needs to be installed. To do so, a QAbstractNativeEventFilter [1] filtering out "Event" events needs to be implemented and installed using QCoreApplication::installNativeEventFilter [2]. [1] http://doc-snapshot.qt-project.org/5.0/qabstractnativeeventfilter.html [2] http://doc-snapshot.qt-project.org/5.0/qcoreapplication.html#installNativeEventFilter qtubuntu-0.62+16.04.20160322/COPYING0000644000015600001650000010451312674203424016733 0ustar pbuserpbgroup00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . qtubuntu-0.62+16.04.20160322/COPYING.LGPL0000644000015600001650000001674312674203424017477 0ustar pbuserpbgroup00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. qtubuntu-0.62+16.04.20160322/qtubuntu.pro0000644000015600001650000000004212674203424020301 0ustar pbuserpbgroup00000000000000TEMPLATE = subdirs SUBDIRS += src