1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the plugins of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or (at your option) the GNU General 28 ** Public license version 3 or any later version approved by the KDE Free 29 ** Qt Foundation. The licenses are as published by the Free Software 30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 31 ** included in the packaging of this file. Please review the following 32 ** information to ensure the GNU General Public License requirements will 33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 34 ** https://www.gnu.org/licenses/gpl-3.0.html. 35 ** 36 ** $QT_END_LICENSE$ 37 ** 38 ****************************************************************************/ 39 40 #ifndef QWINRTSCREEN_H 41 #define QWINRTSCREEN_H 42 43 #include <qpa/qplatformscreen.h> 44 #include <qpa/qwindowsysteminterface.h> 45 46 namespace ABI { 47 namespace Windows { 48 namespace ApplicationModel { 49 struct ISuspendingEventArgs; 50 } 51 namespace UI { 52 namespace Core { 53 struct IAutomationProviderRequestedEventArgs; 54 struct ICharacterReceivedEventArgs; 55 struct ICorePointerRedirector; 56 struct ICoreWindow; 57 struct ICoreWindowEventArgs; 58 struct IKeyEventArgs; 59 struct IPointerEventArgs; 60 struct IVisibilityChangedEventArgs; 61 struct IWindowActivatedEventArgs; 62 } 63 namespace Xaml { 64 struct IDependencyObject; 65 struct IWindow; 66 } 67 namespace ViewManagement { 68 struct IApplicationView; 69 } 70 } 71 namespace Graphics { 72 namespace Display { 73 struct IDisplayInformation; 74 } 75 } 76 } 77 } 78 struct IInspectable; 79 80 QT_BEGIN_NAMESPACE 81 82 class QTouchDevice; 83 class QWinRTCursor; 84 class QWinRTInputContext; 85 class QWinRTScreenPrivate; 86 class QWinRTWindow; 87 class QWinRTScreen : public QPlatformScreen 88 { 89 public: 90 explicit QWinRTScreen(); 91 ~QWinRTScreen() override; 92 93 QRect geometry() const override; 94 QRect availableGeometry() const override; 95 int depth() const override; 96 QImage::Format format() const override; 97 QSizeF physicalSize() const override; 98 QDpi logicalDpi() const override; 99 qreal scaleFactor() const; 100 QPlatformCursor *cursor() const override; 101 Qt::KeyboardModifiers keyboardModifiers() const; 102 103 Qt::ScreenOrientation nativeOrientation() const override; 104 Qt::ScreenOrientation orientation() const override; 105 106 QWindow *topWindow() const; 107 QWindow *windowAt(const QPoint &pos); 108 void addWindow(QWindow *window); 109 void removeWindow(QWindow *window); 110 void raise(QWindow *window); 111 void lower(QWindow *window); 112 113 bool setMouseGrabWindow(QWinRTWindow *window, bool grab); 114 QWinRTWindow* mouseGrabWindow() const; 115 116 bool setKeyboardGrabWindow(QWinRTWindow *window, bool grab); 117 QWinRTWindow* keyboardGrabWindow() const; 118 119 void updateWindowTitle(const QString &title); 120 121 ABI::Windows::UI::Core::ICoreWindow *coreWindow() const; 122 ABI::Windows::UI::Xaml::IDependencyObject *canvas() const; 123 124 void initialize(); 125 126 void setCursorRect(const QRectF &cursorRect); 127 void setKeyboardRect(const QRectF &keyboardRect); 128 129 enum class MousePositionTransition { 130 MovedOut, 131 MovedIn, 132 StayedIn, 133 StayedOut 134 }; 135 136 void emulateMouseMove(const QPointF &point, MousePositionTransition transition); 137 138 void setResizePending(); 139 bool resizePending() const; 140 141 private: 142 void handleExpose(); 143 144 HRESULT onKeyDown(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IKeyEventArgs *); 145 HRESULT onKeyUp(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IKeyEventArgs *); 146 HRESULT onCharacterReceived(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::ICharacterReceivedEventArgs *); 147 HRESULT onPointerEntered(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IPointerEventArgs *); 148 HRESULT onPointerExited(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IPointerEventArgs *); 149 HRESULT onPointerUpdated(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IPointerEventArgs *); 150 151 HRESULT onActivated(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IWindowActivatedEventArgs *); 152 153 HRESULT onClosed(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::ICoreWindowEventArgs *); 154 HRESULT onVisibilityChanged(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IVisibilityChangedEventArgs *); 155 156 HRESULT onOrientationChanged(ABI::Windows::Graphics::Display::IDisplayInformation *, IInspectable *); 157 HRESULT onDpiChanged(ABI::Windows::Graphics::Display::IDisplayInformation *, IInspectable *); 158 HRESULT onWindowSizeChanged(ABI::Windows::UI::ViewManagement::IApplicationView *, IInspectable *); 159 HRESULT onRedirectReleased(ABI::Windows::UI::Core::ICorePointerRedirector *, ABI::Windows::UI::Core::IPointerEventArgs *); 160 161 QScopedPointer<QWinRTScreenPrivate> d_ptr; 162 QRectF mCursorRect; 163 Q_DECLARE_PRIVATE(QWinRTScreen) 164 }; 165 166 QT_END_NAMESPACE 167 168 #endif // QWINRTSCREEN_H 169