summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/CMakeLists.txt2
-rw-r--r--src/plugins/platforms/android/.prev_CMakeLists.txt31
-rw-r--r--src/plugins/platforms/android/CMakeLists.txt37
-rw-r--r--src/plugins/platforms/android/android.pro2
-rw-r--r--src/plugins/platforms/android/androidjniinput.cpp14
-rw-r--r--src/plugins/platforms/android/androidjniinput.h2
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp4
-rw-r--r--src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp75
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.cpp3
-rw-r--r--src/plugins/platforms/android/qandroidplatformintegration.cpp10
-rw-r--r--src/plugins/platforms/cocoa/.prev_CMakeLists.txt71
-rw-r--r--src/plugins/platforms/cocoa/CMakeLists.txt73
-rw-r--r--src/plugins/platforms/cocoa/cocoa.pro9
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibility.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm88
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.h6
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.mm38
-rw-r--r--src/plugins/platforms/cocoa/qcocoaclipboard.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoacursor.h3
-rw-r--r--src/plugins/platforms/cocoa/qcocoacursor.mm25
-rw-r--r--src/plugins/platforms/cocoa/qcocoadrag.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm94
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.h8
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm91
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm34
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoascreen.h29
-rw-r--r--src/plugins/platforms/cocoa/qcocoascreen.mm302
-rw-r--r--src/plugins/platforms/cocoa/qcocoasessionmanager.cpp88
-rw-r--r--src/plugins/platforms/cocoa/qcocoasessionmanager.h81
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemsettings.mm245
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.mm198
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm20
-rw-r--r--src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h4
-rw-r--r--src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm21
-rw-r--r--src/plugins/platforms/cocoa/qmacclipboard.mm8
-rw-r--r--src/plugins/platforms/cocoa/qnsview_drawing.mm11
-rw-r--r--src/plugins/platforms/cocoa/qnsview_menus.mm3
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac.mm2
-rw-r--r--src/plugins/platforms/directfb/.prev_CMakeLists.txt29
-rw-r--r--src/plugins/platforms/directfb/CMakeLists.txt29
-rw-r--r--src/plugins/platforms/eglfs/.prev_CMakeLists.txt83
-rw-r--r--src/plugins/platforms/eglfs/CMakeLists.txt63
-rw-r--r--src/plugins/platforms/eglfs/api/api.pri9
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfscontext.cpp4
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfscursor.cpp2
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp16
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsdeviceintegration_p.h4
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsintegration.cpp39
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsintegration_p.h3
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow.cpp2
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsscreen.cpp4
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfswindow.cpp13
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfswindow_p.h4
-rw-r--r--src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance.cpp280
-rw-r--r--src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance_p.h88
-rw-r--r--src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkanwindow.cpp75
-rw-r--r--src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkanwindow_p.h (renamed from src/plugins/platforms/cocoa/qcocoasystemsettings.h)36
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_emu/CMakeLists.txt15
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/CMakeLists.txt20
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp48
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp14
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp44
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h16
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/CMakeLists.txt20
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/CMakeLists.txt18
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro6
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h6
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp218
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.h99
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h11
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp21
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h6
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/CMakeLists.txt15
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp16
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h2
-rw-r--r--src/plugins/platforms/eglfs/eglfsdeviceintegration.pro3
-rw-r--r--src/plugins/platforms/eglfs/qeglfsmain.cpp2
-rw-r--r--src/plugins/platforms/haiku/qhaikuapplication.cpp5
-rw-r--r--src/plugins/platforms/ios/.prev_CMakeLists.txt65
-rw-r--r--src/plugins/platforms/ios/CMakeLists.txt65
-rw-r--r--src/plugins/platforms/ios/kernel.pro2
-rw-r--r--src/plugins/platforms/ios/optional/CMakeLists.txt5
-rw-r--r--src/plugins/platforms/ios/optional/nsphotolibrarysupport/CMakeLists.txt29
-rw-r--r--src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm2
-rw-r--r--src/plugins/platforms/ios/qioscontext.mm7
-rw-r--r--src/plugins/platforms/ios/qiosintegration.mm10
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.mm14
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm11
-rw-r--r--src/plugins/platforms/ios/quiview.h4
-rw-r--r--src/plugins/platforms/ios/quiview.mm43
-rw-r--r--src/plugins/platforms/linuxfb/.prev_CMakeLists.txt30
-rw-r--r--src/plugins/platforms/linuxfb/CMakeLists.txt30
-rw-r--r--src/plugins/platforms/minimal/.prev_CMakeLists.txt18
-rw-r--r--src/plugins/platforms/minimal/CMakeLists.txt18
-rw-r--r--src/plugins/platforms/minimalegl/.prev_CMakeLists.txt21
-rw-r--r--src/plugins/platforms/minimalegl/CMakeLists.txt21
-rw-r--r--src/plugins/platforms/minimalegl/minimalegl.pro1
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglbackingstore.cpp2
-rw-r--r--src/plugins/platforms/offscreen/.prev_CMakeLists.txt22
-rw-r--r--src/plugins/platforms/offscreen/CMakeLists.txt22
-rw-r--r--src/plugins/platforms/offscreen/main.cpp2
-rw-r--r--src/plugins/platforms/offscreen/qoffscreencommon.cpp10
-rw-r--r--src/plugins/platforms/offscreen/qoffscreenintegration.cpp2
-rw-r--r--src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp12
-rw-r--r--src/plugins/platforms/offscreen/qoffscreenwindow.cpp2
-rw-r--r--src/plugins/platforms/qnx/qqnxglcontext.cpp27
-rw-r--r--src/plugins/platforms/qnx/qqnxglcontext.h7
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.cpp37
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.h13
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp2
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventthread.cpp24
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventthread.h2
-rw-r--r--src/plugins/platforms/vnc/.prev_CMakeLists.txt27
-rw-r--r--src/plugins/platforms/vnc/CMakeLists.txt27
-rw-r--r--src/plugins/platforms/vnc/main.cpp2
-rw-r--r--src/plugins/platforms/vnc/qvnc.cpp4
-rw-r--r--src/plugins/platforms/vnc/qvncclient.cpp3
-rw-r--r--src/plugins/platforms/vnc/qvncscreen.cpp2
-rw-r--r--src/plugins/platforms/wasm/qwasmbackingstore.cpp2
-rw-r--r--src/plugins/platforms/wasm/qwasmclipboard.cpp40
-rw-r--r--src/plugins/platforms/wasm/qwasmcompositor.cpp5
-rw-r--r--src/plugins/platforms/wasm/qwasmcompositor.h5
-rw-r--r--src/plugins/platforms/wasm/qwasmcursor.cpp32
-rw-r--r--src/plugins/platforms/wasm/qwasmeventdispatcher.cpp25
-rw-r--r--src/plugins/platforms/wasm/qwasmeventdispatcher.h2
-rw-r--r--src/plugins/platforms/wasm/qwasmeventtranslator.cpp18
-rw-r--r--src/plugins/platforms/wasm/qwasmintegration.cpp13
-rw-r--r--src/plugins/platforms/wasm/qwasmopenglcontext.cpp9
-rw-r--r--src/plugins/platforms/wasm/qwasmscreen.cpp15
-rw-r--r--src/plugins/platforms/wasm/qwasmservices.cpp6
-rw-r--r--src/plugins/platforms/wasm/qwasmstring.cpp61
-rw-r--r--src/plugins/platforms/wasm/qwasmstring.h45
-rw-r--r--src/plugins/platforms/wasm/wasm.pro9
-rw-r--r--src/plugins/platforms/wasm/wasm_shell.html2
-rw-r--r--src/plugins/platforms/windows/.prev_CMakeLists.txt142
-rw-r--r--src/plugins/platforms/windows/CMakeLists.txt143
-rw-r--r--src/plugins/platforms/windows/qwindowsclipboard.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowscombase.h3
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp125
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.h5
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.cpp39
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.cpp64
-rw-r--r--src/plugins/platforms/windows/qwindowsdropdataobject.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsgdiintegration.cpp10
-rw-r--r--src/plugins/platforms/windows/qwindowsglcontext.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsglcontext.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsinputcontext.cpp16
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp54
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.h5
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowsmenu.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsmime.cpp54
-rw-r--r--src/plugins/platforms/windows/qwindowsmime.h3
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.cpp12
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.h8
-rw-r--r--src/plugins/platforms/windows/qwindowsopengltester.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowspointerhandler.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp8
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsservices.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowssystemtrayicon.cpp14
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp155
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.h6
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp83
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h13
-rw-r--r--src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp53
-rw-r--r--src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp24
-rw-r--r--src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp3
-rw-r--r--src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp4
-rw-r--r--src/plugins/platforms/windows/windows.pro2
-rw-r--r--src/plugins/platforms/winrt/qwinrtintegration.cpp9
-rw-r--r--src/plugins/platforms/winrt/winrt.pro2
-rw-r--r--src/plugins/platforms/xcb/.prev_CMakeLists.txt67
-rw-r--r--src/plugins/platforms/xcb/CMakeLists.txt84
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/CMakeLists.txt18
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h2
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp2
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/CMakeLists.txt22
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp54
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbatom.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.cpp12
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.cpp25
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp18
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h10
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_basic.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp12
-rw-r--r--src/plugins/platforms/xcb/qxcbcursor.cpp36
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.cpp36
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.h4
-rw-r--r--src/plugins/platforms/xcb/qxcbeventqueue.h3
-rw-r--r--src/plugins/platforms/xcb/qxcbimage.cpp8
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp31
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbmime.cpp8
-rw-r--r--src/plugins/platforms/xcb/qxcbmime.h4
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp10
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp33
-rw-r--r--src/plugins/platforms/xcb/qxcbsessionmanager.cpp29
-rw-r--r--src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp4
-rw-r--r--src/plugins/platforms/xcb/qxcbvulkaninstance.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbvulkanwindow.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp33
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbxsettings.cpp2
-rw-r--r--src/plugins/platforms/xcb/xcb_qpa_lib.pro3
222 files changed, 3923 insertions, 1867 deletions
diff --git a/src/plugins/platforms/CMakeLists.txt b/src/plugins/platforms/CMakeLists.txt
index aba67bd59b..57c3952e4c 100644
--- a/src/plugins/platforms/CMakeLists.txt
+++ b/src/plugins/platforms/CMakeLists.txt
@@ -13,7 +13,7 @@ if(QT_FEATURE_xcb)
add_subdirectory(xcb)
endif()
if(APPLE_UIKIT AND NOT APPLE_WATCHOS)
- # add_subdirectory(ios) special case TODO
+ add_subdirectory(ios)
endif()
if(APPLE_OSX)
add_subdirectory(cocoa)
diff --git a/src/plugins/platforms/android/.prev_CMakeLists.txt b/src/plugins/platforms/android/.prev_CMakeLists.txt
index 75a62f1e8c..7b21613fb9 100644
--- a/src/plugins/platforms/android/.prev_CMakeLists.txt
+++ b/src/plugins/platforms/android/.prev_CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from android.pro.
#####################################################################
-## qtforandroid Plugin:
+## QAndroidIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qtforandroid
+qt_add_plugin(QAndroidIntegrationPlugin
+ OUTPUT_NAME qtforandroid
TYPE platforms
- CLASS_NAME QAndroidIntegrationPlugin
SOURCES
androidcontentfileengine.cpp androidcontentfileengine.h
androiddeadlockprotector.cpp androiddeadlockprotector.h
@@ -42,47 +42,44 @@ add_qt_plugin(qtforandroid
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}
${QT_SOURCE_TREE}/src/3rdparty/android
- LIBRARIES
+ PUBLIC_LIBRARIES
Qt::AccessibilitySupportPrivate
+ Qt::Core
Qt::CorePrivate
Qt::EglSupportPrivate
Qt::EventDispatcherSupportPrivate
Qt::FontDatabaseSupportPrivate
- Qt::GuiPrivate
- PUBLIC_LIBRARIES
- Qt::AccessibilitySupport
- Qt::Core
- Qt::EglSupport
- Qt::EventDispatcherSupport
- Qt::FontDatabaseSupport
Qt::Gui
+ Qt::GuiPrivate
android
jnigraphics
)
#### Keys ignored in scope 1:.:.:android.pro:<TRUE>:
# OTHER_FILES = "$$PWD/android.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qtforandroid CONDITION QT_FEATURE_vulkan
+qt_extend_target(QAndroidIntegrationPlugin CONDITION QT_FEATURE_vulkan
SOURCES
qandroidplatformvulkaninstance.cpp qandroidplatformvulkaninstance.h
qandroidplatformvulkanwindow.cpp qandroidplatformvulkanwindow.h
- LIBRARIES
+ PUBLIC_LIBRARIES
Qt::VulkanSupportPrivate
+)
+
+qt_extend_target(QAndroidIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate
PUBLIC_LIBRARIES
- Qt::VulkanSupport
+ Qt::PlatformCompositorSupportPrivate
)
-extend_target(qtforandroid CONDITION QT_FEATURE_android_style_assets
+qt_extend_target(QAndroidIntegrationPlugin CONDITION QT_FEATURE_android_style_assets
SOURCES
extract.cpp
)
-extend_target(qtforandroid CONDITION NOT QT_FEATURE_android_style_assets
+qt_extend_target(QAndroidIntegrationPlugin CONDITION NOT QT_FEATURE_android_style_assets
SOURCES
extract-dummy.cpp
)
diff --git a/src/plugins/platforms/android/CMakeLists.txt b/src/plugins/platforms/android/CMakeLists.txt
index b6a92fa6ed..4d1f83053b 100644
--- a/src/plugins/platforms/android/CMakeLists.txt
+++ b/src/plugins/platforms/android/CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from android.pro.
#####################################################################
-## qtforandroid Plugin:
+## QAndroidIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qtforandroid
+qt_add_plugin(QAndroidIntegrationPlugin
+ OUTPUT_NAME qtforandroid
TYPE platforms
- CLASS_NAME QAndroidIntegrationPlugin
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES android # special case
SOURCES
androidcontentfileengine.cpp androidcontentfileengine.h
@@ -43,55 +43,52 @@ add_qt_plugin(qtforandroid
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}
${QT_SOURCE_TREE}/src/3rdparty/android
- LIBRARIES
+ PUBLIC_LIBRARIES
Qt::AccessibilitySupportPrivate
+ Qt::Core
Qt::CorePrivate
Qt::EglSupportPrivate
Qt::EventDispatcherSupportPrivate
Qt::FontDatabaseSupportPrivate
- Qt::GuiPrivate
- PUBLIC_LIBRARIES
- Qt::AccessibilitySupport
- Qt::Core
- Qt::EglSupport
- Qt::EventDispatcherSupport
- Qt::FontDatabaseSupport
Qt::Gui
+ Qt::GuiPrivate
android
jnigraphics
# special case begin
INSTALL_DIRECTORY
- plugins/platforms/android
+ plugins/platforms
OUTPUT_DIRECTORY
- plugins/platforms/android
+ plugins/platforms
ARCHIVE_INSTALL_DIRECTORY
- plugins/platforms/android
+ plugins/platforms
# special case end
)
#### Keys ignored in scope 1:.:.:android.pro:<TRUE>:
# OTHER_FILES = "$$PWD/android.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qtforandroid CONDITION QT_FEATURE_vulkan
+qt_extend_target(QAndroidIntegrationPlugin CONDITION QT_FEATURE_vulkan
SOURCES
qandroidplatformvulkaninstance.cpp qandroidplatformvulkaninstance.h
qandroidplatformvulkanwindow.cpp qandroidplatformvulkanwindow.h
- LIBRARIES
+ PUBLIC_LIBRARIES
Qt::VulkanSupportPrivate
+)
+
+qt_extend_target(QAndroidIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate
PUBLIC_LIBRARIES
- Qt::VulkanSupport
+ Qt::PlatformCompositorSupportPrivate
)
-extend_target(qtforandroid CONDITION QT_FEATURE_android_style_assets
+qt_extend_target(QAndroidIntegrationPlugin CONDITION QT_FEATURE_android_style_assets
SOURCES
extract.cpp
)
-extend_target(qtforandroid CONDITION NOT QT_FEATURE_android_style_assets
+qt_extend_target(QAndroidIntegrationPlugin CONDITION NOT QT_FEATURE_android_style_assets
SOURCES
extract-dummy.cpp
)
diff --git a/src/plugins/platforms/android/android.pro b/src/plugins/platforms/android/android.pro
index 61cac51633..8ea78f7cba 100644
--- a/src/plugins/platforms/android/android.pro
+++ b/src/plugins/platforms/android/android.pro
@@ -9,6 +9,8 @@ QT += \
qtConfig(vulkan): QT += vulkan_support-private
+qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private
+
OTHER_FILES += $$PWD/android.json
INCLUDEPATH += \
diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp
index 9cdc5de0e1..56885f2e23 100644
--- a/src/plugins/platforms/android/androidjniinput.cpp
+++ b/src/plugins/platforms/android/androidjniinput.cpp
@@ -195,20 +195,6 @@ namespace QtAndroidInput
angleDelta);
}
- void releaseMouse(int x, int y)
- {
- m_ignoreMouseEvents = true;
- QPoint globalPos(x,y);
- QWindow *tlw = topLevelWindowAt(globalPos);
- QPoint localPos = tlw ? (globalPos-tlw->position()) : globalPos;
-
- // Release left button
- QWindowSystemInterface::handleMouseEvent(tlw,
- localPos,
- globalPos,
- Qt::MouseButtons(Qt::NoButton));
- }
-
static void longPress(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint x, jint y)
{
QAndroidInputContext *inputContext = QAndroidInputContext::androidInputContext();
diff --git a/src/plugins/platforms/android/androidjniinput.h b/src/plugins/platforms/android/androidjniinput.h
index 2e2470ae8f..cc3070c4aa 100644
--- a/src/plugins/platforms/android/androidjniinput.h
+++ b/src/plugins/platforms/android/androidjniinput.h
@@ -61,8 +61,6 @@ namespace QtAndroidInput
void updateHandles(int handleCount, QPoint editMenuPos = QPoint(), uint32_t editButtons = 0, QPoint cursor = QPoint(), QPoint anchor = QPoint(), bool rtl = false);
bool registerNatives(JNIEnv *env);
-
- void releaseMouse(int x, int y);
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index fd2644717e..1c7800358f 100644
--- a/src/plugins/platforms/android/androidjnimain.cpp
+++ b/src/plugins/platforms/android/androidjnimain.cpp
@@ -900,7 +900,7 @@ Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void */*reserved*/)
uenv.venv = nullptr;
m_javaVM = nullptr;
- if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_4) != JNI_OK) {
+ if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_6) != JNI_OK) {
__android_log_print(ANDROID_LOG_FATAL, "Qt", "GetEnv failed");
return -1;
}
@@ -922,5 +922,5 @@ Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void */*reserved*/)
if (threadSetter.thread())
threadSetter.thread()->setObjectName("QtMainLoopThread");
__android_log_print(ANDROID_LOG_INFO, "Qt", "qt started");
- return JNI_VERSION_1_4;
+ return JNI_VERSION_1_6;
}
diff --git a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
index 26e72a480f..fcc08ea00d 100644
--- a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
+++ b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
@@ -72,9 +72,10 @@ static inline QString prefixedPath(QString path)
struct AssetItem {
enum class Type {
File,
- Folder
+ Folder,
+ Invalid
};
-
+ AssetItem() = default;
AssetItem (const QString &rawName)
: name(rawName)
{
@@ -92,21 +93,47 @@ using AssetItemList = QVector<AssetItem>;
class FolderIterator : public AssetItemList
{
public:
- static QSharedPointer<FolderIterator> fromCache(const QString &path)
+ static QSharedPointer<FolderIterator> fromCache(const QString &path, bool clone)
{
QMutexLocker lock(&m_assetsCacheMutex);
QSharedPointer<FolderIterator> *folder = m_assetsCache.object(path);
if (!folder) {
folder = new QSharedPointer<FolderIterator>{new FolderIterator{path}};
- if (!m_assetsCache.insert(path, folder)) {
+ if ((*folder)->empty() || !m_assetsCache.insert(path, folder)) {
QSharedPointer<FolderIterator> res = *folder;
delete folder;
return res;
}
}
- return *folder;
+ return clone ? QSharedPointer<FolderIterator>{new FolderIterator{*(*folder)}} : *folder;
+ }
+
+ static AssetItem::Type fileType(const QString &filePath)
+ {
+ const QStringList paths = filePath.split(QLatin1Char('/'));
+ QString fullPath;
+ AssetItem::Type res = AssetItem::Type::Invalid;
+ for (const auto &path: paths) {
+ auto folder = fromCache(fullPath, false);
+ auto it = std::lower_bound(folder->begin(), folder->end(), AssetItem{path}, [](const AssetItem &val, const AssetItem &assetItem) {
+ return val.name < assetItem.name;
+ });
+ if (it == folder->end() || it->name != path)
+ return AssetItem::Type::Invalid;
+ if (!fullPath.isEmpty())
+ fullPath.append(QLatin1Char('/'));
+ fullPath += path;
+ res = it->type;
+ }
+ return res;
}
+ FolderIterator(const FolderIterator &other)
+ : AssetItemList(other)
+ , m_index(-1)
+ , m_path(other.m_path)
+ {}
+
FolderIterator(const QString &path)
: m_path(path)
{
@@ -118,8 +145,12 @@ public:
QJNIEnvironmentPrivate env;
jobjectArray jFiles = static_cast<jobjectArray>(files.object());
const jint nFiles = env->GetArrayLength(jFiles);
- for (int i = 0; i < nFiles; ++i)
- push_back({QJNIObjectPrivate(env->GetObjectArrayElement(jFiles, i)).toString()});
+ for (int i = 0; i < nFiles; ++i) {
+ AssetItem item{QJNIObjectPrivate(env->GetObjectArrayElement(jFiles, i)).toString()};
+ insert(std::upper_bound(begin(), end(), item, [](const auto &a, const auto &b){
+ return a.name < b.name;
+ }), item);
+ }
}
m_path = assetsPrefix + QLatin1Char('/') + m_path + QLatin1Char('/');
m_path.replace(QLatin1String("//"), QLatin1String("/"));
@@ -169,7 +200,7 @@ public:
const QString &path)
: QAbstractFileEngineIterator(filters, nameFilters)
{
- m_stack.push_back(FolderIterator::fromCache(cleanedAssetPath(path)));
+ m_stack.push_back(FolderIterator::fromCache(cleanedAssetPath(path), true));
if (m_stack.last()->empty())
m_stack.pop_back();
}
@@ -215,7 +246,7 @@ public:
if (!res)
return {};
if (res->second.type == AssetItem::Type::Folder) {
- m_stack.push_back(FolderIterator::fromCache(cleanedAssetPath(currentFilePath())));
+ m_stack.push_back(FolderIterator::fromCache(cleanedAssetPath(currentFilePath()), true));
if (m_stack.last()->empty())
m_stack.pop_back();
}
@@ -257,6 +288,7 @@ public:
m_assetFile = 0;
return true;
}
+ m_isFolder = false;
return false;
}
@@ -305,12 +337,12 @@ public:
FileFlags fileFlags(FileFlags type = FileInfoAll) const override
{
- FileFlags flags(ReadOwnerPerm|ReadUserPerm|ReadGroupPerm|ReadOtherPerm|ExistsFlag);
+ FileFlags commonFlags(ReadOwnerPerm|ReadUserPerm|ReadGroupPerm|ReadOtherPerm|ExistsFlag);
+ FileFlags flags;
if (m_assetFile)
- flags |= FileType;
+ flags = FileType | commonFlags;
else if (m_isFolder)
- flags |= DirectoryType;
-
+ flags = DirectoryType | commonFlags;
return type & flags;
}
@@ -341,9 +373,20 @@ public:
void setFileName(const QString &file) override
{
+ if (m_fileName == cleanedAssetPath(file))
+ return;
close();
m_fileName = cleanedAssetPath(file);
- m_isFolder = !open(QIODevice::ReadOnly) && !FolderIterator::fromCache(m_fileName)->empty();
+ switch (FolderIterator::fileType(m_fileName)) {
+ case AssetItem::Type::File:
+ open(QIODevice::ReadOnly);
+ break;
+ case AssetItem::Type::Folder:
+ m_isFolder = true;
+ break;
+ case AssetItem::Type::Invalid:
+ break;
+ }
}
Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) override
@@ -355,9 +398,9 @@ public:
private:
AAsset *m_assetFile = nullptr;
- AAssetManager *m_assetManager;
+ AAssetManager *m_assetManager = nullptr;
QString m_fileName;
- bool m_isFolder;
+ bool m_isFolder = false;
};
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp
index 5614d3b04f..e78c317863 100644
--- a/src/plugins/platforms/android/qandroidinputcontext.cpp
+++ b/src/plugins/platforms/android/qandroidinputcontext.cpp
@@ -827,9 +827,6 @@ void QAndroidInputContext::longPress(int x, int y)
focusObjectStopComposing();
- // Release left button, otherwise the following events will cancel the menu popup
- QtAndroidInput::releaseMouse(x, y);
-
const double pixelDensity =
QGuiApplication::focusWindow()
? QHighDpiScaling::factor(QGuiApplication::focusWindow())
diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp
index e0c437be27..ae584965e6 100644
--- a/src/plugins/platforms/android/qandroidplatformintegration.cpp
+++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp
@@ -43,6 +43,9 @@
#include <QtGui/private/qguiapplication_p.h>
#include <QGuiApplication>
#include <QOpenGLContext>
+#if QT_CONFIG(opengl)
+#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h>
+#endif
#include <QThread>
#include <QOffscreenSurface>
@@ -275,7 +278,12 @@ QPlatformBackingStore *QAndroidPlatformIntegration::createPlatformBackingStore(Q
{
if (!QtAndroid::activity())
return nullptr;
- return new QAndroidPlatformBackingStore(window);
+
+ auto *backingStore = new QAndroidPlatformBackingStore(window);
+#if QT_CONFIG(opengl)
+ backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
+#endif // QT_CONFIG(opengl)
+ return backingStore;
}
QPlatformOpenGLContext *QAndroidPlatformIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
diff --git a/src/plugins/platforms/cocoa/.prev_CMakeLists.txt b/src/plugins/platforms/cocoa/.prev_CMakeLists.txt
index 8808017a87..1491340b65 100644
--- a/src/plugins/platforms/cocoa/.prev_CMakeLists.txt
+++ b/src/plugins/platforms/cocoa/.prev_CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from cocoa.pro.
#####################################################################
-## qcocoa Plugin:
+## QCocoaIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qcocoa
+qt_add_plugin(QCocoaIntegrationPlugin
+ OUTPUT_NAME qcocoa
TYPE platforms
- CLASS_NAME QCocoaIntegrationPlugin
SOURCES
main.mm
messages.cpp messages.h
@@ -31,7 +31,6 @@ add_qt_plugin(qcocoa
qcocoansmenu.h qcocoansmenu.mm
qcocoascreen.h qcocoascreen.mm
qcocoaservices.h qcocoaservices.mm
- qcocoasystemsettings.h qcocoasystemsettings.mm
qcocoasystemtrayicon.h qcocoasystemtrayicon.mm
qcocoatheme.h qcocoatheme.mm
qcocoawindow.h qcocoawindow.mm
@@ -42,13 +41,6 @@ add_qt_plugin(qcocoa
qnsview.h qnsview.mm
qnswindow.h qnswindow.mm
qnswindowdelegate.h qnswindowdelegate.mm
- LIBRARIES
- Qt::ClipboardSupportPrivate
- Qt::CorePrivate
- Qt::FontDatabaseSupportPrivate
- Qt::GraphicsSupportPrivate
- Qt::GuiPrivate
- Qt::ThemeSupportPrivate
PUBLIC_LIBRARIES
${FWAppKit}
${FWCarbon}
@@ -59,12 +51,14 @@ add_qt_plugin(qcocoa
${FWMetal}
${FWQuartzCore}
Cups::Cups
- Qt::ClipboardSupport
+ Qt::ClipboardSupportPrivate
Qt::Core
- Qt::FontDatabaseSupport
- Qt::GraphicsSupport
+ Qt::CorePrivate
+ Qt::FontDatabaseSupportPrivate
+ Qt::GraphicsSupportPrivate
Qt::Gui
- Qt::ThemeSupport
+ Qt::GuiPrivate
+ Qt::ThemeSupportPrivate
)
# Resources:
@@ -74,7 +68,7 @@ set(qcocoaresources_resource_files
"images/waitcursor.png"
)
-add_qt_resource(qcocoa "qcocoaresources"
+qt_add_resource(QCocoaIntegrationPlugin "qcocoaresources"
PREFIX
"/qt-project.org/mac/cursors"
FILES
@@ -84,72 +78,73 @@ add_qt_resource(qcocoa "qcocoaresources"
#### Keys ignored in scope 1:.:.:cocoa.pro:<TRUE>:
# OTHER_FILES = "cocoa.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qcocoa CONDITION QT_FEATURE_opengl
+qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_opengl
SOURCES
qcocoaglcontext.h qcocoaglcontext.mm
)
-extend_target(qcocoa CONDITION QT_FEATURE_vulkan
+qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_vulkan
SOURCES
qcocoavulkaninstance.h qcocoavulkaninstance.mm
- LIBRARIES
- Qt::VulkanSupportPrivate
PUBLIC_LIBRARIES
- Qt::VulkanSupport
+ Qt::VulkanSupportPrivate
)
-extend_target(qcocoa CONDITION QT_FEATURE_accessibility
+qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_accessibility
SOURCES
qcocoaaccessibility.h qcocoaaccessibility.mm
qcocoaaccessibilityelement.h qcocoaaccessibilityelement.mm
- LIBRARIES
+ PUBLIC_LIBRARIES
Qt::AccessibilitySupportPrivate
+)
+
+qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_sessionmanager
+ SOURCES
+ qcocoasessionmanager.cpp qcocoasessionmanager.h
+)
+
+qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate
PUBLIC_LIBRARIES
- Qt::AccessibilitySupport
+ Qt::PlatformCompositorSupportPrivate
)
-extend_target(qcocoa CONDITION TARGET Qt::Widgets
+qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::Widgets
SOURCES
qpaintengine_mac.mm qpaintengine_mac_p.h
- LIBRARIES
- Qt::WidgetsPrivate
PUBLIC_LIBRARIES
- Qt::Widgets
+ Qt::WidgetsPrivate
)
-#### Keys ignored in scope 6:.:.:cocoa.pro:TARGET Qt::Widgets:
+#### Keys ignored in scope 8:.:.:cocoa.pro:TARGET Qt::Widgets:
# QT_FOR_CONFIG = "widgets"
-extend_target(qcocoa CONDITION TARGET Qt::PrintSupport AND TARGET Qt::Widgets
+qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::PrintSupport AND TARGET Qt::Widgets
SOURCES
qcocoaprintdevice.h qcocoaprintdevice.mm
qcocoaprintersupport.h qcocoaprintersupport.mm
qprintengine_mac.mm qprintengine_mac_p.h
- LIBRARIES
- Qt::PrintSupportPrivate
PUBLIC_LIBRARIES
- Qt::PrintSupport
+ Qt::PrintSupportPrivate
)
-extend_target(qcocoa CONDITION QT_FEATURE_colordialog AND TARGET Qt::Widgets
+qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_colordialog AND TARGET Qt::Widgets
SOURCES
qcocoacolordialoghelper.h qcocoacolordialoghelper.mm
)
-extend_target(qcocoa CONDITION QT_FEATURE_filedialog AND TARGET Qt::Widgets
+qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_filedialog AND TARGET Qt::Widgets
SOURCES
qcocoafiledialoghelper.h qcocoafiledialoghelper.mm
)
-extend_target(qcocoa CONDITION QT_FEATURE_fontdialog AND TARGET Qt::Widgets
+qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_fontdialog AND TARGET Qt::Widgets
SOURCES
qcocoafontdialoghelper.h qcocoafontdialoghelper.mm
)
-#### Keys ignored in scope 11:.:.:cocoa.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
+#### Keys ignored in scope 13:.:.:cocoa.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
# PLUGIN_EXTENDS = "-"
diff --git a/src/plugins/platforms/cocoa/CMakeLists.txt b/src/plugins/platforms/cocoa/CMakeLists.txt
index 53b56da5f1..9e8b162aec 100644
--- a/src/plugins/platforms/cocoa/CMakeLists.txt
+++ b/src/plugins/platforms/cocoa/CMakeLists.txt
@@ -4,13 +4,13 @@
qt_find_package(Cups PROVIDED_TARGETS Cups::Cups)
#####################################################################
-## qcocoa Plugin:
+## QCocoaIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qcocoa
- TYPE platforms
+qt_add_plugin(QCocoaIntegrationPlugin
+ OUTPUT_NAME qcocoa
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES cocoa # special case
- CLASS_NAME QCocoaIntegrationPlugin
+ TYPE platforms
SOURCES
main.mm
messages.cpp messages.h
@@ -35,7 +35,6 @@ add_qt_plugin(qcocoa
qcocoansmenu.h qcocoansmenu.mm
qcocoascreen.h qcocoascreen.mm
qcocoaservices.h qcocoaservices.mm
- qcocoasystemsettings.h qcocoasystemsettings.mm
qcocoasystemtrayicon.h qcocoasystemtrayicon.mm
qcocoatheme.h qcocoatheme.mm
qcocoawindow.h qcocoawindow.mm
@@ -46,13 +45,6 @@ add_qt_plugin(qcocoa
qnsview.h qnsview.mm
qnswindow.h qnswindow.mm
qnswindowdelegate.h qnswindowdelegate.mm
- LIBRARIES
- Qt::ClipboardSupportPrivate
- Qt::CorePrivate
- Qt::FontDatabaseSupportPrivate
- Qt::GraphicsSupportPrivate
- Qt::GuiPrivate
- Qt::ThemeSupportPrivate
PUBLIC_LIBRARIES
${FWAppKit}
${FWCarbon}
@@ -63,12 +55,14 @@ add_qt_plugin(qcocoa
${FWMetal}
${FWQuartzCore}
Cups::Cups
- Qt::ClipboardSupport
+ Qt::ClipboardSupportPrivate
Qt::Core
- Qt::FontDatabaseSupport
- Qt::GraphicsSupport
+ Qt::CorePrivate
+ Qt::FontDatabaseSupportPrivate
+ Qt::GraphicsSupportPrivate
Qt::Gui
- Qt::ThemeSupport
+ Qt::GuiPrivate
+ Qt::ThemeSupportPrivate
)
# Resources:
@@ -78,7 +72,7 @@ set(qcocoaresources_resource_files
"images/waitcursor.png"
)
-add_qt_resource(qcocoa "qcocoaresources"
+qt_add_resource(QCocoaIntegrationPlugin "qcocoaresources"
PREFIX
"/qt-project.org/mac/cursors"
FILES
@@ -88,72 +82,73 @@ add_qt_resource(qcocoa "qcocoaresources"
#### Keys ignored in scope 1:.:.:cocoa.pro:<TRUE>:
# OTHER_FILES = "cocoa.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qcocoa CONDITION QT_FEATURE_opengl
+qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_opengl
SOURCES
qcocoaglcontext.h qcocoaglcontext.mm
)
-extend_target(qcocoa CONDITION QT_FEATURE_vulkan
+qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_vulkan
SOURCES
qcocoavulkaninstance.h qcocoavulkaninstance.mm
- LIBRARIES
- Qt::VulkanSupportPrivate
PUBLIC_LIBRARIES
- Qt::VulkanSupport
+ Qt::VulkanSupportPrivate
)
-extend_target(qcocoa CONDITION QT_FEATURE_accessibility
+qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_accessibility
SOURCES
qcocoaaccessibility.h qcocoaaccessibility.mm
qcocoaaccessibilityelement.h qcocoaaccessibilityelement.mm
- LIBRARIES
+ PUBLIC_LIBRARIES
Qt::AccessibilitySupportPrivate
+)
+
+qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_sessionmanager
+ SOURCES
+ qcocoasessionmanager.cpp qcocoasessionmanager.h
+)
+
+qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate
PUBLIC_LIBRARIES
- Qt::AccessibilitySupport
+ Qt::PlatformCompositorSupportPrivate
)
-extend_target(qcocoa CONDITION TARGET Qt::Widgets
+qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::Widgets
SOURCES
qpaintengine_mac.mm qpaintengine_mac_p.h
- LIBRARIES
- Qt::WidgetsPrivate
PUBLIC_LIBRARIES
- Qt::Widgets
+ Qt::WidgetsPrivate
)
-#### Keys ignored in scope 6:.:.:cocoa.pro:TARGET Qt::Widgets:
+#### Keys ignored in scope 8:.:.:cocoa.pro:TARGET Qt::Widgets:
# QT_FOR_CONFIG = "widgets"
-extend_target(qcocoa CONDITION TARGET Qt::PrintSupport AND TARGET Qt::Widgets
+qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::PrintSupport AND TARGET Qt::Widgets
SOURCES
qcocoaprintdevice.h qcocoaprintdevice.mm
qcocoaprintersupport.h qcocoaprintersupport.mm
qprintengine_mac.mm qprintengine_mac_p.h
- LIBRARIES
- Qt::PrintSupportPrivate
PUBLIC_LIBRARIES
- Qt::PrintSupport
+ Qt::PrintSupportPrivate
)
-extend_target(qcocoa CONDITION QT_FEATURE_colordialog AND TARGET Qt::Widgets
+qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_colordialog AND TARGET Qt::Widgets
SOURCES
qcocoacolordialoghelper.h qcocoacolordialoghelper.mm
)
-extend_target(qcocoa CONDITION QT_FEATURE_filedialog AND TARGET Qt::Widgets
+qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_filedialog AND TARGET Qt::Widgets
SOURCES
qcocoafiledialoghelper.h qcocoafiledialoghelper.mm
)
-extend_target(qcocoa CONDITION QT_FEATURE_fontdialog AND TARGET Qt::Widgets
+qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_fontdialog AND TARGET Qt::Widgets
SOURCES
qcocoafontdialoghelper.h qcocoafontdialoghelper.mm
)
-#### Keys ignored in scope 11:.:.:cocoa.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
+#### Keys ignored in scope 13:.:.:cocoa.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
# PLUGIN_EXTENDS = "-"
diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro
index 4cf9e64447..953346c56e 100644
--- a/src/plugins/platforms/cocoa/cocoa.pro
+++ b/src/plugins/platforms/cocoa/cocoa.pro
@@ -25,7 +25,6 @@ SOURCES += main.mm \
qcocoaclipboard.mm \
qcocoadrag.mm \
qmacclipboard.mm \
- qcocoasystemsettings.mm \
qcocoainputcontext.mm \
qcocoaservices.mm \
qcocoasystemtrayicon.mm \
@@ -59,7 +58,6 @@ HEADERS += qcocoaintegration.h \
qcocoaclipboard.h \
qcocoadrag.h \
qmacclipboard.h \
- qcocoasystemsettings.h \
qcocoainputcontext.h \
qcocoaservices.h \
qcocoasystemtrayicon.h \
@@ -87,6 +85,11 @@ qtConfig(accessibility) {
qcocoaaccessibility.h
}
+qtConfig(sessionmanager) {
+ SOURCES += qcocoasessionmanager.cpp
+ HEADERS += qcocoasessionmanager.h
+}
+
RESOURCES += qcocoaresources.qrc
LIBS += -framework AppKit -framework CoreServices -framework Carbon -framework IOKit -framework QuartzCore -framework CoreVideo -framework Metal -framework IOSurface -lcups
@@ -98,6 +101,8 @@ QT += \
qtConfig(vulkan): QT += vulkan_support-private
+qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private
+
CONFIG += no_app_extension_api_only
qtHaveModule(widgets) {
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
index db4ec251ae..106c226adc 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
@@ -133,7 +133,7 @@ static void populateRoleMap()
roleMap[QAccessible::SpinBox] = NSAccessibilityIncrementorRole;
roleMap[QAccessible::Slider] = NSAccessibilitySliderRole;
roleMap[QAccessible::ProgressBar] = NSAccessibilityProgressIndicatorRole;
- roleMap[QAccessible::ComboBox] = NSAccessibilityPopUpButtonRole;
+ roleMap[QAccessible::ComboBox] = NSAccessibilityComboBoxRole;
roleMap[QAccessible::RadioButton] = NSAccessibilityRadioButtonRole;
roleMap[QAccessible::CheckBox] = NSAccessibilityCheckBoxRole;
roleMap[QAccessible::StaticText] = NSAccessibilityStaticTextRole;
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
index 00f5a1bf09..3fb9e83d35 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
@@ -79,19 +79,25 @@
#include "qcocoamenuitem.h"
#include "qcocoansmenu.h"
+#if QT_CONFIG(sessionmanager)
+# include "qcocoasessionmanager.h"
+#endif
+
#include <qevent.h>
#include <qurl.h>
#include <qdebug.h>
#include <qguiapplication.h>
-#include <private/qguiapplication_p.h>
#include "qt_mac_p.h"
#include <qpa/qwindowsysteminterface.h>
#include <qwindowdefs.h>
+QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcQpaApplication, "qt.qpa.application");
+QT_END_NAMESPACE
+
QT_USE_NAMESPACE
@implementation QCocoaApplicationDelegate {
- bool startedQuit;
NSObject <NSApplicationDelegate> *reflectionDelegate;
bool inLaunch;
}
@@ -140,67 +146,41 @@ QT_USE_NAMESPACE
return [[self.dockMenu retain] autorelease];
}
-- (BOOL)canQuit
-{
- [[NSApp mainMenu] cancelTracking];
-
- bool handle_quit = true;
- NSMenuItem *quitMenuItem = [[QCocoaMenuLoader sharedMenuLoader] quitMenuItem];
- if (!QGuiApplicationPrivate::instance()->modalWindowList.isEmpty()
- && [quitMenuItem isEnabled]) {
- int visible = 0;
- const QWindowList tlws = QGuiApplication::topLevelWindows();
- for (int i = 0; i < tlws.size(); ++i) {
- if (tlws.at(i)->isVisible())
- ++visible;
- }
- handle_quit = (visible <= 1);
- }
-
- if (handle_quit) {
- QCloseEvent ev;
- QGuiApplication::sendEvent(qGuiApp, &ev);
- if (ev.isAccepted()) {
- return YES;
- }
- }
-
- return NO;
-}
-
// This function will only be called when NSApp is actually running.
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
if ([reflectionDelegate respondsToSelector:_cmd])
return [reflectionDelegate applicationShouldTerminate:sender];
- if ([self canQuit]) {
- if (!startedQuit) {
- startedQuit = true;
- // Close open windows. This is done in order to deliver de-expose
- // events while the event loop is still running.
- const QWindowList topLevels = QGuiApplication::topLevelWindows();
- for (int i = 0; i < topLevels.size(); ++i) {
- QWindow *topLevelWindow = topLevels.at(i);
- // Already closed windows will not have a platform window, skip those
- if (topLevelWindow->handle())
- QWindowSystemInterface::handleCloseEvent(topLevelWindow);
- }
- QWindowSystemInterface::flushWindowSystemEvents();
-
- QGuiApplication::exit(0);
- startedQuit = false;
- }
+ if (QGuiApplicationPrivate::instance()->threadData.loadRelaxed()->eventLoops.isEmpty()) {
+ // No event loop is executing. This probably means that Qt is used as a plugin,
+ // or as a part of a native Cocoa application. In any case it should be fine to
+ // terminate now.
+ qCDebug(lcQpaApplication) << "No running event loops, terminating now";
+ return NSTerminateNow;
}
- if (QGuiApplicationPrivate::instance()->threadData->eventLoops.isEmpty()) {
- // INVARIANT: No event loop is executing. This probably
- // means that Qt is used as a plugin, or as a part of a native
- // Cocoa application. In any case it should be fine to
- // terminate now:
- return NSTerminateNow;
+#if QT_CONFIG(sessionmanager)
+ QCocoaSessionManager *cocoaSessionManager = QCocoaSessionManager::instance();
+ cocoaSessionManager->resetCancellation();
+ cocoaSessionManager->appCommitData();
+
+ if (cocoaSessionManager->wasCanceled()) {
+ qCDebug(lcQpaApplication) << "Session management canceled application termination";
+ return NSTerminateCancel;
+ }
+#endif
+
+ if (!QWindowSystemInterface::handleApplicationTermination<QWindowSystemInterface::SynchronousDelivery>()) {
+ qCDebug(lcQpaApplication) << "Application termination canceled";
+ return NSTerminateCancel;
}
+ // Even if the application termination was accepted by the application we can't
+ // return NSTerminateNow, as that would trigger AppKit to ultimately call exit().
+ // We need to ensure that the runloop continues spinning so that we can return
+ // from our own event loop back to main(), and exit from there.
+ qCDebug(lcQpaApplication) << "Termination accepted, but returning to runloop for exit through main()";
return NSTerminateCancel;
}
@@ -393,7 +373,7 @@ QT_USE_NAMESPACE
if (!platformItem || platformItem->menu())
return;
- QScopedScopeLevelCounter scopeLevelCounter(QGuiApplicationPrivate::instance()->threadData);
+ QScopedScopeLevelCounter scopeLevelCounter(QGuiApplicationPrivate::instance()->threadData.loadRelaxed());
QGuiApplicationPrivate::modifier_buttons = [QNSView convertKeyModifiers:[NSEvent modifierFlags]];
static QMetaMethod activatedSignal = QMetaMethod::fromSignal(&QCocoaMenuItem::activated);
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h
index a874936ce6..b57deacb57 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.h
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h
@@ -54,8 +54,6 @@ class QCocoaBackingStore : public QRasterBackingStore
protected:
QCocoaBackingStore(QWindow *window);
QCFType<CGColorSpaceRef> colorSpace() const;
- QMacNotificationObserver m_backingPropertiesObserver;
- virtual void backingPropertiesChanged() = 0;
};
class QNSWindowBackingStore : public QCocoaBackingStore
@@ -71,7 +69,6 @@ private:
bool windowHasUnifiedToolbar() const;
QImage::Format format() const override;
void redrawRoundedBottomCorners(CGRect) const;
- void backingPropertiesChanged() override;
};
class QCALayerBackingStore : public QCocoaBackingStore
@@ -118,7 +115,8 @@ private:
bool recreateBackBufferIfNeeded();
bool prepareForFlush();
- void backingPropertiesChanged() override;
+ void backingPropertiesChanged();
+ QMacNotificationObserver m_backingPropertiesObserver;
std::list<std::unique_ptr<GraphicsBuffer>> m_buffers;
};
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
index b17302a640..2e15d11564 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
@@ -51,17 +51,6 @@ QT_BEGIN_NAMESPACE
QCocoaBackingStore::QCocoaBackingStore(QWindow *window)
: QRasterBackingStore(window)
{
- // Ideally this would be plumbed from the platform layer to QtGui, and
- // the QBackingStore would be recreated, but we don't have that code yet,
- // so at least make sure we invalidate our backingstore when the backing
- // properties (color space e.g.) are changed.
- NSView *view = static_cast<QCocoaWindow *>(window->handle())->view();
- m_backingPropertiesObserver = QMacNotificationObserver(view.window,
- NSWindowDidChangeBackingPropertiesNotification, [this]() {
- qCDebug(lcQpaBackingStore) << "Backing properties for"
- << this->window() << "did change";
- backingPropertiesChanged();
- });
}
QCFType<CGColorSpaceRef> QCocoaBackingStore::colorSpace() const
@@ -341,11 +330,6 @@ void QNSWindowBackingStore::redrawRoundedBottomCorners(CGRect windowRect) const
#endif
}
-void QNSWindowBackingStore::backingPropertiesChanged()
-{
- m_image = QImage();
-}
-
// ----------------------------------------------------------------------------
QCALayerBackingStore::QCALayerBackingStore(QWindow *window)
@@ -353,6 +337,18 @@ QCALayerBackingStore::QCALayerBackingStore(QWindow *window)
{
qCDebug(lcQpaBackingStore) << "Creating QCALayerBackingStore for" << window;
m_buffers.resize(1);
+
+ // Ideally this would be plumbed from the platform layer to QtGui, and
+ // the QBackingStore would be recreated, but we don't have that code yet,
+ // so at least make sure we update our backingstore when the backing
+ // properties (color space e.g.) are changed.
+ NSView *view = static_cast<QCocoaWindow *>(window->handle())->view();
+ m_backingPropertiesObserver = QMacNotificationObserver(view.window,
+ NSWindowDidChangeBackingPropertiesNotification, [this]() {
+ qCDebug(lcQpaBackingStore) << "Backing properties for"
+ << this->window() << "did change";
+ backingPropertiesChanged();
+ });
}
QCALayerBackingStore::~QCALayerBackingStore()
@@ -620,8 +616,11 @@ QImage QCALayerBackingStore::toImage() const
void QCALayerBackingStore::backingPropertiesChanged()
{
- m_buffers.clear();
- m_buffers.resize(1);
+ qCDebug(lcQpaBackingStore) << "Updating color space of existing buffers";
+ for (auto &buffer : m_buffers) {
+ if (buffer)
+ buffer->setColorSpace(colorSpace());
+ }
}
QPlatformGraphicsBuffer *QCALayerBackingStore::graphicsBuffer() const
@@ -698,10 +697,11 @@ bool QCALayerBackingStore::prepareForFlush()
QCALayerBackingStore::GraphicsBuffer::GraphicsBuffer(const QSize &size, qreal devicePixelRatio,
const QPixelFormat &format, QCFType<CGColorSpaceRef> colorSpace)
- : QIOSurfaceGraphicsBuffer(size, format, colorSpace)
+ : QIOSurfaceGraphicsBuffer(size, format)
, dirtyRegion(0, 0, size.width() / devicePixelRatio, size.height() / devicePixelRatio)
, m_devicePixelRatio(devicePixelRatio)
{
+ setColorSpace(colorSpace);
}
QImage *QCALayerBackingStore::GraphicsBuffer::asImage()
diff --git a/src/plugins/platforms/cocoa/qcocoaclipboard.mm b/src/plugins/platforms/cocoa/qcocoaclipboard.mm
index a35c153084..141940cc50 100644
--- a/src/plugins/platforms/cocoa/qcocoaclipboard.mm
+++ b/src/plugins/platforms/cocoa/qcocoaclipboard.mm
@@ -67,7 +67,7 @@ void QCocoaClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
}
pasteBoard->sync();
- pasteBoard->setMimeData(data);
+ pasteBoard->setMimeData(data, QMacPasteboard::LazyRequest);
emitChanged(mode);
}
}
diff --git a/src/plugins/platforms/cocoa/qcocoacursor.h b/src/plugins/platforms/cocoa/qcocoacursor.h
index 58b9ef2151..5b008eff35 100644
--- a/src/plugins/platforms/cocoa/qcocoacursor.h
+++ b/src/plugins/platforms/cocoa/qcocoacursor.h
@@ -56,6 +56,9 @@ public:
void changeCursor(QCursor *cursor, QWindow *window) override;
QPoint pos() const override;
void setPos(const QPoint &position) override;
+
+ QSize size() const override;
+
private:
QHash<Qt::CursorShape, NSCursor *> m_cursors;
NSCursor *convertCursor(QCursor *cursor);
diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm
index 87a57c78c8..e0d623fc4c 100644
--- a/src/plugins/platforms/cocoa/qcocoacursor.mm
+++ b/src/plugins/platforms/cocoa/qcocoacursor.mm
@@ -85,6 +85,31 @@ void QCocoaCursor::setPos(const QPoint &position)
CFRelease(e);
}
+
+QSize QCocoaCursor::size() const
+{
+ NSCursor *cocoaCursor = NSCursor.currentSystemCursor;
+ if (!cocoaCursor)
+ return QPlatformCursor::size();
+ NSImage *cursorImage = cocoaCursor.image;
+ if (!cursorImage)
+ return QPlatformCursor::size();
+
+ QSizeF size = QSizeF::fromCGSize(cursorImage.size);
+ NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
+ NSDictionary *accessSettings = [defaults persistentDomainForName:@"com.apple.universalaccess"];
+ if (accessSettings == nil)
+ return size.toSize();
+
+ float sizeScale = [accessSettings[@"mouseDriverCursorSize"] floatValue];
+ if (sizeScale > 0) {
+ size.rwidth() *= sizeScale;
+ size.rheight() *= sizeScale;
+ }
+
+ return size.toSize();
+}
+
NSCursor *QCocoaCursor::convertCursor(QCursor *cursor)
{
if (!cursor)
diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm
index 09433194a6..95808b8a11 100644
--- a/src/plugins/platforms/cocoa/qcocoadrag.mm
+++ b/src/plugins/platforms/cocoa/qcocoadrag.mm
@@ -134,7 +134,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
NSImage *nsimage = qt_mac_create_nsimage(pm);
[nsimage setSize:NSSizeFromCGSize(pmDeviceIndependentSize.toCGSize())];
- QMacPasteboard dragBoard((CFStringRef) NSDragPboard, QMacInternalPasteboardMime::MIME_DND);
+ QMacPasteboard dragBoard(CFStringRef(NSPasteboardNameDrag), QMacInternalPasteboardMime::MIME_DND);
m_drag->mimeData()->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray("dummy"));
dragBoard.setMimeData(m_drag->mimeData(), QMacPasteboard::LazyRequest);
@@ -145,7 +145,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
CGFloat flippedY = pmDeviceIndependentSize.height() - hotSpot.y();
event_location.y -= flippedY;
NSSize mouseOffset_unused = NSMakeSize(0.0, 0.0);
- NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
+ NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSPasteboardNameDrag];
[theWindow dragImage:nsimage
at:event_location
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
index 69587a24be..b8d2532b8e 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
@@ -186,6 +186,7 @@ public:
QAtomicInt serialNumber;
int lastSerial;
bool interrupt;
+ bool propagateInterrupt = false;
static void postedEventsSourceCallback(void *info);
static void waitingObserverCallback(CFRunLoopObserverRef observer,
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
index e87fc39c42..94b9e62eab 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
@@ -84,13 +84,12 @@
#include "private/qthread_p.h"
#include "private/qguiapplication_p.h"
#include <qdebug.h>
+#include <qscopeguard.h>
#include <AppKit/AppKit.h>
QT_BEGIN_NAMESPACE
-QT_USE_NAMESPACE
-
static inline CFRunLoopRef mainRunLoop()
{
return CFRunLoopGetMain();
@@ -293,46 +292,42 @@ bool QCocoaEventDispatcher::hasPendingEvents()
return qGlobalPostedEventsCount() || (qt_is_gui_used && !CFRunLoopIsWaiting(CFRunLoopGetMain()));
}
-static bool IsMouseOrKeyEvent( NSEvent* event )
+static bool isUserInputEvent(NSEvent* event)
{
- bool result = false;
-
- switch( [event type] )
- {
- case NSEventTypeLeftMouseDown:
- case NSEventTypeLeftMouseUp:
- case NSEventTypeRightMouseDown:
- case NSEventTypeRightMouseUp:
- case NSEventTypeMouseMoved: // ??
- case NSEventTypeLeftMouseDragged:
- case NSEventTypeRightMouseDragged:
- case NSEventTypeMouseEntered:
- case NSEventTypeMouseExited:
- case NSEventTypeKeyDown:
- case NSEventTypeKeyUp:
- case NSEventTypeFlagsChanged: // key modifiers changed?
- case NSEventTypeCursorUpdate: // ??
- case NSEventTypeScrollWheel:
- case NSEventTypeTabletPoint:
- case NSEventTypeTabletProximity:
- case NSEventTypeOtherMouseDown:
- case NSEventTypeOtherMouseUp:
- case NSEventTypeOtherMouseDragged:
+ switch ([event type]) {
+ case NSEventTypeLeftMouseDown:
+ case NSEventTypeLeftMouseUp:
+ case NSEventTypeRightMouseDown:
+ case NSEventTypeRightMouseUp:
+ case NSEventTypeMouseMoved: // ??
+ case NSEventTypeLeftMouseDragged:
+ case NSEventTypeRightMouseDragged:
+ case NSEventTypeMouseEntered:
+ case NSEventTypeMouseExited:
+ case NSEventTypeKeyDown:
+ case NSEventTypeKeyUp:
+ case NSEventTypeFlagsChanged: // key modifiers changed?
+ case NSEventTypeCursorUpdate: // ??
+ case NSEventTypeScrollWheel:
+ case NSEventTypeTabletPoint:
+ case NSEventTypeTabletProximity:
+ case NSEventTypeOtherMouseDown:
+ case NSEventTypeOtherMouseUp:
+ case NSEventTypeOtherMouseDragged:
#ifndef QT_NO_GESTURES
- case NSEventTypeGesture: // touch events
- case NSEventTypeMagnify:
- case NSEventTypeSwipe:
- case NSEventTypeRotate:
- case NSEventTypeBeginGesture:
- case NSEventTypeEndGesture:
+ case NSEventTypeGesture: // touch events
+ case NSEventTypeMagnify:
+ case NSEventTypeSwipe:
+ case NSEventTypeRotate:
+ case NSEventTypeBeginGesture:
+ case NSEventTypeEndGesture:
#endif // QT_NO_GESTURES
- result = true;
+ return true;
break;
-
- default:
+ default:
break;
}
- return result;
+ return false;
}
static inline void qt_mac_waitForMoreEvents(NSString *runLoopMode = NSDefaultRunLoopMode)
@@ -352,6 +347,16 @@ static inline void qt_mac_waitForMoreEvents(NSString *runLoopMode = NSDefaultRun
bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
{
Q_D(QCocoaEventDispatcher);
+
+ // In rare rather corner cases a user's application messes with
+ // QEventLoop::exec()/exit() and QCoreApplication::processEvents(),
+ // we have to undo what bool blocker normally does.
+ d->propagateInterrupt = false;
+ const auto boolBlockerUndo = qScopeGuard([d](){
+ if (d->propagateInterrupt)
+ d->interrupt = true;
+ d->propagateInterrupt = false;
+ });
QBoolBlocker interruptBlocker(d->interrupt, false);
bool interruptLater = false;
@@ -465,7 +470,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
dequeue: YES];
if (event) {
- if (IsMouseOrKeyEvent(event)) {
+ if (isUserInputEvent(event)) {
[event retain];
d->queuedUserInputEvents.append(event);
continue;
@@ -485,7 +490,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
if (event) {
if (flags & QEventLoop::ExcludeUserInputEvents) {
- if (IsMouseOrKeyEvent(event)) {
+ if (isUserInputEvent(event)) {
[event retain];
d->queuedUserInputEvents.append(event);
continue;
@@ -500,7 +505,16 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
if ((d->processEventsFlags & QEventLoop::EventLoopExec) == 0) {
// When called "manually", always process posted events and timers
+ bool oldInterrupt = d->interrupt;
d->processPostedEvents();
+ if (!oldInterrupt && d->interrupt && !d->currentModalSession()) {
+ // We had direct processEvent call, coming not from QEventLoop::exec().
+ // One of the posted events triggered an application to interrupt the loop.
+ // But bool blocker will reset d->interrupt to false, so the real event
+ // loop will never notice it was interrupted. Now we'll have to fix it by
+ // enforcing the value of d->interrupt.
+ d->propagateInterrupt = true;
+ }
retVal = d->processTimers() || retVal;
}
@@ -515,7 +529,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
if (hadModalSession && !d->currentModalSessionCached)
interruptLater = true;
}
- bool canWait = (d->threadData->canWait
+ bool canWait = (d->threadData.loadRelaxed()->canWait
&& !retVal
&& !d->interrupt
&& (d->processEventsFlags & QEventLoop::WaitForMoreEvents));
@@ -882,7 +896,7 @@ void QCocoaEventDispatcherPrivate::processPostedEvents()
}
int serial = serialNumber.loadRelaxed();
- if (!threadData->canWait || (serial != lastSerial)) {
+ if (!threadData.loadRelaxed()->canWait || (serial != lastSerial)) {
lastSerial = serial;
QCoreApplication::sendPostedEvents();
QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents);
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h
index bb309c0713..238067568b 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.h
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h
@@ -50,6 +50,8 @@
QT_BEGIN_NAMESPACE
+class QCocoaWindow;
+
class QCocoaGLContext : public QPlatformOpenGLContext
{
public:
@@ -76,14 +78,18 @@ private:
static NSOpenGLPixelFormat *pixelFormatForSurfaceFormat(const QSurfaceFormat &format);
bool setDrawable(QPlatformSurface *surface);
+ void prepareDrawable(QCocoaWindow *platformWindow);
void updateSurfaceFormat();
NSOpenGLContext *m_context = nil;
NSOpenGLContext *m_shareContext = nil;
QSurfaceFormat m_format;
- bool m_didCheckForSoftwareContext = false;
QVarLengthArray<QMacNotificationObserver, 3> m_updateObservers;
QAtomicInt m_needsUpdate = false;
+
+#ifndef QT_NO_DEBUG_STREAM
+ friend QDebug operator<<(QDebug debug, const QCocoaGLContext *screen);
+#endif
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index ba7d12ce30..6db4bdb9fd 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -158,6 +158,8 @@ void QCocoaGLContext::initialize()
[m_context setValues:&order forParameter:NSOpenGLCPSurfaceOrder];
updateSurfaceFormat();
+
+ qCDebug(lcQpaOpenGLContext).verbosity(3) << "Created" << this << "based on requested" << context()->format();
}
NSOpenGLPixelFormat *QCocoaGLContext::pixelFormatForSurfaceFormat(const QSurfaceFormat &format)
@@ -223,12 +225,10 @@ NSOpenGLPixelFormat *QCocoaGLContext::pixelFormatForSurfaceFormat(const QSurface
attrs << NSOpenGLPFAAllowOfflineRenderers;
}
- // FIXME: Pull this information out of the NSView
- QByteArray useLayer = qgetenv("QT_MAC_WANTS_LAYER");
- if (!useLayer.isEmpty() && useLayer.toInt() > 0) {
- // Disable the software rendering fallback. This makes compositing
- // OpenGL and raster NSViews using Core Animation layers possible.
- attrs << NSOpenGLPFANoRecovery;
+ if (qGuiApp->testAttribute(Qt::AA_UseSoftwareOpenGL)) {
+ // kCGLRendererGenericFloatID is the modern software renderer on macOS,
+ // as opposed to kCGLRendererGenericID, which is deprecated.
+ attrs << NSOpenGLPFARendererID << kCGLRendererGenericFloatID;
}
attrs << 0; // 0-terminate array
@@ -357,7 +357,7 @@ QCocoaGLContext::~QCocoaGLContext()
bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface)
{
- qCDebug(lcQpaOpenGLContext) << "Making" << m_context << "current"
+ qCDebug(lcQpaOpenGLContext) << "Making" << this << "current"
<< "in" << QThread::currentThread() << "for" << surface;
Q_ASSERT(surface->surface()->supportsOpenGL());
@@ -368,23 +368,6 @@ bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface)
[m_context makeCurrentContext];
if (surface->surface()->surfaceClass() == QSurface::Window) {
- // Disable high-resolution surfaces when using the software renderer, which has the
- // problem that the system silently falls back to a to using a low-resolution buffer
- // when a high-resolution buffer is requested. This is not detectable using the NSWindow
- // convertSizeToBacking and backingScaleFactor APIs. A typical result of this is that Qt
- // will display a quarter of the window content when running in a virtual machine.
- if (!m_didCheckForSoftwareContext) {
- // FIXME: This ensures we check only once per context,
- // but the context may be used for multiple surfaces.
- m_didCheckForSoftwareContext = true;
-
- const GLubyte* renderer = glGetString(GL_RENDERER);
- if (qstrcmp((const char *)renderer, "Apple Software Renderer") == 0) {
- NSView *view = static_cast<QCocoaWindow *>(surface)->m_view;
- [view setWantsBestResolutionOpenGLSurface:NO];
- }
- }
-
if (m_needsUpdate.fetchAndStoreRelaxed(false))
update();
}
@@ -413,11 +396,14 @@ bool QCocoaGLContext::setDrawable(QPlatformSurface *surface)
}
Q_ASSERT(surface->surface()->surfaceClass() == QSurface::Window);
- QNSView *view = qnsview_cast(static_cast<QCocoaWindow *>(surface)->view());
+ auto *cocoaWindow = static_cast<QCocoaWindow *>(surface);
+ QNSView *view = qnsview_cast(cocoaWindow->view());
if (view == m_context.view)
return true;
+ prepareDrawable(cocoaWindow);
+
// Setting the drawable may happen on a separate thread as a result of
// a call to makeCurrent, so we need to set up the observers before we
// associate the view with the context. That way we will guarantee that
@@ -460,6 +446,30 @@ bool QCocoaGLContext::setDrawable(QPlatformSurface *surface)
return true;
}
+void QCocoaGLContext::prepareDrawable(QCocoaWindow *platformWindow)
+{
+ // We generally want high-DPI GL surfaces, unless the user has explicitly disabled them
+ bool prefersBestResolutionOpenGLSurface = qt_mac_resolveOption(YES,
+ platformWindow->window(), "_q_mac_wantsBestResolutionOpenGLSurface",
+ "QT_MAC_WANTS_BEST_RESOLUTION_OPENGL_SURFACE");
+
+ auto *view = platformWindow->view();
+
+ // The only case we have to opt out ourselves is when using the Apple software renderer
+ // in combination with surface-backed views, as these together do not support high-DPI.
+ if (prefersBestResolutionOpenGLSurface) {
+ int rendererID = 0;
+ [m_context getValues:&rendererID forParameter:NSOpenGLContextParameterCurrentRendererID];
+ bool isSoftwareRenderer = (rendererID & kCGLRendererIDMatchingMask) == kCGLRendererGenericFloatID;
+ if (isSoftwareRenderer && !view.layer) {
+ qCInfo(lcQpaOpenGLContext) << "Disabling high resolution GL surface due to software renderer";
+ prefersBestResolutionOpenGLSurface = false;
+ }
+ }
+
+ view.wantsBestResolutionOpenGLSurface = prefersBestResolutionOpenGLSurface;
+}
+
// NSOpenGLContext is not re-entrant. Even when using separate contexts per thread,
// view, and window, calls into the API will still deadlock. For more information
// see https://openradar.appspot.com/37064579
@@ -491,6 +501,21 @@ void QCocoaGLContext::swapBuffers(QPlatformSurface *surface)
return;
}
+ if (m_context.view.layer) {
+ // Flushing an NSOpenGLContext will hit the screen immediately, ignoring
+ // any Core Animation transactions in place. This may result in major
+ // visual artifacts if the flush happens out of sync with the size
+ // of the layer, view, and window reflected by other parts of the UI,
+ // e.g. if the application flushes in the resize event or a timer during
+ // window resizing, instead of in the expose event.
+ auto *cocoaWindow = static_cast<QCocoaWindow *>(surface);
+ if (cocoaWindow->geometry().size() != cocoaWindow->m_exposedRect.size()) {
+ qCInfo(lcQpaOpenGLContext) << "Window exposed size does not match geometry (yet)."
+ << "Skipping flush to avoid visual artifacts.";
+ return;
+ }
+ }
+
QMutexLocker locker(&s_reentrancyMutex);
[m_context flushBuffer];
}
@@ -532,4 +557,20 @@ QFunctionPointer QCocoaGLContext::getProcAddress(const char *procName)
return (QFunctionPointer)dlsym(RTLD_DEFAULT, procName);
}
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug debug, const QCocoaGLContext *context)
+{
+ QDebugStateSaver saver(debug);
+ debug.nospace();
+ debug << "QCocoaGLContext(" << (const void *)context;
+ if (context) {
+ if (debug.verbosity() > QDebug::DefaultVerbosity)
+ debug << ", " << context->format();
+ debug << ", " << context->nativeContext();
+ }
+ debug << ')';
+ return debug;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
index 0e2656e046..30838ba254 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -92,6 +92,10 @@ public:
QCocoaVulkanInstance *getCocoaVulkanInstance() const;
#endif
+#if QT_CONFIG(sessionmanager)
+ QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const override;
+#endif
+
QCoreTextFontDatabase *fontDatabase() const override;
QCocoaNativeInterface *nativeInterface() const override;
QPlatformInputContext *inputContext() const override;
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index 67ad0b3492..b2698b05fe 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -52,6 +52,9 @@
#include "qcocoamimetypes.h"
#include "qcocoaaccessibility.h"
#include "qcocoascreen.h"
+#if QT_CONFIG(sessionmanager)
+# include "qcocoasessionmanager.h"
+#endif
#include <qpa/qplatforminputcontextfactory_p.h>
#include <qpa/qplatformaccessibility.h>
@@ -65,6 +68,10 @@
#include <QtFontDatabaseSupport/private/qfontengine_coretext_p.h>
+#if QT_CONFIG(opengl)
+#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h>
+#endif
+
#ifdef QT_WIDGETS_LIB
#include <QtWidgets/qtwidgetsglobal.h>
#if QT_CONFIG(filedialog)
@@ -197,16 +204,6 @@ QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
[cocoaApplication setMenu:[qtMenuLoader menu]];
}
- // The presentation options such as whether or not the dock and/or menu bar is
- // hidden (automatically by the system) affects the main screen's available
- // geometry. Since we're initializing the screens synchronously at application
- // startup we need to ensure that the presentation options have been propagated
- // to the screen before we read out its properties. Normally OS X does this in
- // an asynchronous callback, but that's too late for us. We force the propagation
- // by explicitly setting the presentation option to the magic 'default value',
- // which will resolve to an actual value and result in screen invalidation.
- cocoaApplication.presentationOptions = NSApplicationPresentationDefault;
-
QCocoaScreen::initializeScreens();
QMacInternalPasteboardMime::initializeMimeTypes();
@@ -255,6 +252,13 @@ QCocoaIntegration::Options QCocoaIntegration::options() const
return mOptions;
}
+#if QT_CONFIG(sessionmanager)
+QPlatformSessionManager *QCocoaIntegration::createPlatformSessionManager(const QString &id, const QString &key) const
+{
+ return new QCocoaSessionManager(id, key);
+}
+#endif
+
bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{
switch (cap) {
@@ -324,10 +328,16 @@ QPlatformBackingStore *QCocoaIntegration::createPlatformBackingStore(QWindow *wi
return nullptr;
}
+ QPlatformBackingStore *backingStore = nullptr;
if (platformWindow->view().layer)
- return new QCALayerBackingStore(window);
+ backingStore = new QCALayerBackingStore(window);
else
- return new QNSWindowBackingStore(window);
+ backingStore = new QNSWindowBackingStore(window);
+
+#if QT_CONFIG(opengl)
+ backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
+#endif
+ return backingStore;
}
QAbstractEventDispatcher *QCocoaIntegration::createEventDispatcher() const
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm
index 8c4fca0d29..90d5180fed 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenu.mm
@@ -334,7 +334,7 @@ void QCocoaMenu::setEnabled(bool enabled)
bool QCocoaMenu::isEnabled() const
{
- return m_attachedItem ? m_attachedItem.enabled : m_enabled && m_parentEnabled;
+ return m_enabled && m_parentEnabled;
}
void QCocoaMenu::setVisible(bool visible)
diff --git a/src/plugins/platforms/cocoa/qcocoascreen.h b/src/plugins/platforms/cocoa/qcocoascreen.h
index 60243b79be..dcf6f1c753 100644
--- a/src/plugins/platforms/cocoa/qcocoascreen.h
+++ b/src/plugins/platforms/cocoa/qcocoascreen.h
@@ -53,9 +53,6 @@ class QCocoaIntegration;
class QCocoaScreen : public QPlatformScreen
{
public:
- static void initializeScreens();
- static void cleanupScreens();
-
~QCocoaScreen();
// ----------------------------------------------------
@@ -79,7 +76,6 @@ public:
// ----------------------------------------------------
NSScreen *nativeScreen() const;
- void updateProperties();
void requestUpdate();
void deliverUpdateRequests();
@@ -88,6 +84,7 @@ public:
static QCocoaScreen *primaryScreen();
static QCocoaScreen *get(NSScreen *nsScreen);
static QCocoaScreen *get(CGDirectDisplayID displayId);
+ static QCocoaScreen *get(CFUUIDRef uuid);
static CGPoint mapToNative(const QPointF &pos, QCocoaScreen *screen = QCocoaScreen::primaryScreen());
static CGRect mapToNative(const QRectF &rect, QCocoaScreen *screen = QCocoaScreen::primaryScreen());
@@ -95,27 +92,41 @@ public:
static QRectF mapFromNative(CGRect rect, QCocoaScreen *screen = QCocoaScreen::primaryScreen());
private:
- QCocoaScreen(CGDirectDisplayID displayId);
+ static void initializeScreens();
+ static void updateScreens();
+ static void cleanupScreens();
+
+ static bool updateScreensIfNeeded();
+ static NSArray *s_screenConfigurationBeforeUpdate;
+
static void add(CGDirectDisplayID displayId);
+ QCocoaScreen(CGDirectDisplayID displayId);
+ void update(CGDirectDisplayID displayId);
void remove();
- CGDirectDisplayID m_displayId = 0;
+ bool isOnline() const;
+ bool isMirroring() const;
+
+ CGDirectDisplayID m_displayId = kCGNullDirectDisplay;
+ CGDirectDisplayID displayId() const { return m_displayId; }
QRect m_geometry;
QRect m_availableGeometry;
QDpi m_logicalDpi;
- qreal m_refreshRate;
- int m_depth;
+ qreal m_refreshRate = 0;
+ int m_depth = 0;
QString m_name;
QImage::Format m_format;
QSizeF m_physicalSize;
QCocoaCursor *m_cursor;
- qreal m_devicePixelRatio;
+ qreal m_devicePixelRatio = 0;
CVDisplayLinkRef m_displayLink = nullptr;
dispatch_source_t m_displayLinkSource = nullptr;
QAtomicInt m_pendingUpdates;
+ friend class QCocoaIntegration;
+ friend class QCocoaWindow;
friend QDebug operator<<(QDebug debug, const QCocoaScreen *screen);
};
diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm
index 392099d083..e4dd4cf6c6 100644
--- a/src/plugins/platforms/cocoa/qcocoascreen.mm
+++ b/src/plugins/platforms/cocoa/qcocoascreen.mm
@@ -54,67 +54,183 @@
QT_BEGIN_NAMESPACE
-void QCocoaScreen::initializeScreens()
-{
- uint32_t displayCount = 0;
- if (CGGetActiveDisplayList(0, nullptr, &displayCount) != kCGErrorSuccess)
- qFatal("Failed to get number of active displays");
+namespace CoreGraphics {
+ Q_NAMESPACE
+ enum DisplayChange {
+ ReconfiguredWithFlagsMissing = 0,
+ Moved = kCGDisplayMovedFlag,
+ SetMain = kCGDisplaySetMainFlag,
+ SetMode = kCGDisplaySetModeFlag,
+ Added = kCGDisplayAddFlag,
+ Removed = kCGDisplayRemoveFlag,
+ Enabled = kCGDisplayEnabledFlag,
+ Disabled = kCGDisplayDisabledFlag,
+ Mirrored = kCGDisplayMirrorFlag,
+ UnMirrored = kCGDisplayUnMirrorFlag,
+ DesktopShapeChanged = kCGDisplayDesktopShapeChangedFlag
+ };
+ Q_ENUM_NS(DisplayChange)
+}
- CGDirectDisplayID activeDisplays[displayCount];
- if (CGGetActiveDisplayList(displayCount, &activeDisplays[0], &displayCount) != kCGErrorSuccess)
- qFatal("Failed to get active displays");
+NSArray *QCocoaScreen::s_screenConfigurationBeforeUpdate = nil;
- for (CGDirectDisplayID displayId : activeDisplays)
- QCocoaScreen::add(displayId);
+void QCocoaScreen::initializeScreens()
+{
+ updateScreens();
CGDisplayRegisterReconfigurationCallback([](CGDirectDisplayID displayId, CGDisplayChangeSummaryFlags flags, void *userInfo) {
- if (flags & kCGDisplayBeginConfigurationFlag)
- return; // Wait for changes to apply
-
Q_UNUSED(userInfo);
- QCocoaScreen *cocoaScreen = QCocoaScreen::get(displayId);
+ // Displays are reconfigured in batches, and we want to update our screens
+ // once a batch ends, so that all the states of the displays are up to date.
+ static int displayReconfigurationsInProgress = 0;
+
+ const bool beforeReconfigure = flags & kCGDisplayBeginConfigurationFlag;
+ qCDebug(lcQpaScreen).verbosity(0).nospace() << "Display " << displayId
+ << (beforeReconfigure ? " about to reconfigure" : " was ")
+ << QFlags<CoreGraphics::DisplayChange>(flags)
+ << " with " << displayReconfigurationsInProgress
+ << " display configuration(s) in progress";
+
+ if (!flags) {
+ // CGDisplayRegisterReconfigurationCallback has been observed to be called
+ // with flags unset. This seems like a bug. The callback is not paired with
+ // a matching "completion" callback either, so we don't know whether to treat
+ // it as a begin or end of reconfigure.
+ return;
+ }
- if ((flags & kCGDisplayAddFlag) || !cocoaScreen) {
- if (!CGDisplayIsActive(displayId)) {
- qCDebug(lcQpaScreen) << "Not adding inactive display" << displayId;
- return; // Will be added when activated
+ if (beforeReconfigure) {
+ if (!displayReconfigurationsInProgress++) {
+ // There might have been a screen reconfigure before this that
+ // we didn't process yet, so do that now if that's the case.
+ updateScreensIfNeeded();
+
+ Q_ASSERT(!s_screenConfigurationBeforeUpdate);
+ s_screenConfigurationBeforeUpdate = NSScreen.screens;
+ qCDebug(lcQpaScreen, "Display reconfigure transaction started"
+ " with screen configuration %p", s_screenConfigurationBeforeUpdate);
+
+ static void (^tryScreenUpdate)();
+ tryScreenUpdate = ^void () {
+ qCDebug(lcQpaScreen) << "Attempting screen update from runloop block";
+ if (!updateScreensIfNeeded())
+ CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopCommonModes, tryScreenUpdate);
+ };
+ CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopCommonModes, tryScreenUpdate);
}
- QCocoaScreen::add(displayId);
- } else if ((flags & kCGDisplayRemoveFlag) || !CGDisplayIsActive(displayId)) {
- cocoaScreen->remove();
} else {
- // Detect changes to the primary screen immediately, instead of
- // waiting for a display reconfigure with kCGDisplaySetMainFlag.
- // This ensures that any property updates to the other screens
- // will be in reference to the correct primary screen.
- QCocoaScreen *mainDisplay = QCocoaScreen::get(CGMainDisplayID());
- if (QGuiApplication::primaryScreen()->handle() != mainDisplay) {
- mainDisplay->updateProperties();
- qCInfo(lcQpaScreen) << "Primary screen changed to" << mainDisplay;
- QWindowSystemInterface::handlePrimaryScreenChanged(mainDisplay);
+ Q_ASSERT_X(displayReconfigurationsInProgress, "QCococaScreen",
+ "Display configuration transactions are expected to be balanced");
+
+ if (!--displayReconfigurationsInProgress) {
+ qCDebug(lcQpaScreen) << "Display reconfigure transaction completed";
+ // We optimistically update now, in case the NSScreens have changed
+ updateScreensIfNeeded();
}
+ }
+ }, nullptr);
+
+ static QMacNotificationObserver screenParameterObserver(NSApplication.sharedApplication,
+ NSApplicationDidChangeScreenParametersNotification, [&]() {
+ qCDebug(lcQpaScreen) << "Received screen parameter change notification";
+ updateScreensIfNeeded(); // As a last resort we update screens here
+ });
+}
- if (cocoaScreen == mainDisplay)
- return; // Already reconfigured
+bool QCocoaScreen::updateScreensIfNeeded()
+{
+ if (!s_screenConfigurationBeforeUpdate) {
+ qCDebug(lcQpaScreen) << "QScreens have already been updated, all good";
+ return true;
+ }
+
+ if (s_screenConfigurationBeforeUpdate == NSScreen.screens) {
+ qCDebug(lcQpaScreen) << "Still waiting for NSScreen configuration change";
+ return false;
+ }
- cocoaScreen->updateProperties();
- qCInfo(lcQpaScreen) << "Reconfigured" << cocoaScreen;
+ qCDebug(lcQpaScreen, "NSScreen configuration changed to %p", NSScreen.screens);
+ updateScreens();
+
+ s_screenConfigurationBeforeUpdate = nil;
+ return true;
+}
+
+/*
+ Update the list of available QScreens, and the properties of existing screens.
+
+ At this point we rely on the NSScreen.screens to be up to date.
+*/
+void QCocoaScreen::updateScreens()
+{
+ uint32_t displayCount = 0;
+ if (CGGetOnlineDisplayList(0, nullptr, &displayCount) != kCGErrorSuccess)
+ qFatal("Failed to get number of online displays");
+
+ QVector<CGDirectDisplayID> onlineDisplays(displayCount);
+ if (CGGetOnlineDisplayList(displayCount, onlineDisplays.data(), &displayCount) != kCGErrorSuccess)
+ qFatal("Failed to get online displays");
+
+ qCInfo(lcQpaScreen) << "Updating screens with" << displayCount
+ << "online displays:" << onlineDisplays;
+
+ // TODO: Verify whether we can always assume the main display is first
+ int mainDisplayIndex = onlineDisplays.indexOf(CGMainDisplayID());
+ if (mainDisplayIndex < 0) {
+ qCWarning(lcQpaScreen) << "Main display not in list of online displays!";
+ } else if (mainDisplayIndex > 0) {
+ qCWarning(lcQpaScreen) << "Main display not first display, making sure it is";
+ onlineDisplays.move(mainDisplayIndex, 0);
+ }
+
+ for (CGDirectDisplayID displayId : onlineDisplays) {
+ Q_ASSERT(CGDisplayIsOnline(displayId));
+
+ if (CGDisplayMirrorsDisplay(displayId))
+ continue;
+
+ // A single physical screen can map to multiple displays IDs,
+ // depending on which GPU is in use or which physical port the
+ // screen is connected to. By mapping the display ID to a UUID,
+ // which are shared between displays that target the same screen,
+ // we can pick an existing QScreen to update instead of needlessly
+ // adding and removing QScreens.
+ QCFType<CFUUIDRef> uuid = CGDisplayCreateUUIDFromDisplayID(displayId);
+ Q_ASSERT(uuid);
+
+ if (QCocoaScreen *existingScreen = QCocoaScreen::get(uuid)) {
+ existingScreen->update(displayId);
+ qCInfo(lcQpaScreen) << "Updated" << existingScreen;
+ if (CGDisplayIsMain(displayId) && existingScreen != qGuiApp->primaryScreen()->handle()) {
+ qCInfo(lcQpaScreen) << "Primary screen changed to" << existingScreen;
+ QWindowSystemInterface::handlePrimaryScreenChanged(existingScreen);
+ }
+ } else {
+ QCocoaScreen::add(displayId);
}
- }, nullptr);
+ }
+
+ for (QScreen *screen : QGuiApplication::screens()) {
+ QCocoaScreen *platformScreen = static_cast<QCocoaScreen*>(screen->handle());
+ if (!platformScreen->isOnline() || platformScreen->isMirroring())
+ platformScreen->remove();
+ }
}
void QCocoaScreen::add(CGDirectDisplayID displayId)
{
+ const bool isPrimary = CGDisplayIsMain(displayId);
QCocoaScreen *cocoaScreen = new QCocoaScreen(displayId);
- qCInfo(lcQpaScreen) << "Adding" << cocoaScreen;
- QWindowSystemInterface::handleScreenAdded(cocoaScreen, CGDisplayIsMain(displayId));
+ qCInfo(lcQpaScreen) << "Adding" << cocoaScreen
+ << (isPrimary ? "as new primary screen" : "");
+ QWindowSystemInterface::handleScreenAdded(cocoaScreen, isPrimary);
}
QCocoaScreen::QCocoaScreen(CGDirectDisplayID displayId)
: QPlatformScreen(), m_displayId(displayId)
{
- updateProperties();
+ update(m_displayId);
m_cursor = new QCocoaCursor;
}
@@ -127,8 +243,6 @@ void QCocoaScreen::cleanupScreens()
void QCocoaScreen::remove()
{
- m_displayId = 0; // Prevent stale references during removal
-
// This may result in the application responding to QGuiApplication::screenRemoved
// by moving the window to another screen, either by setGeometry, or by setScreen.
// If the window isn't moved by the application, Qt will as a fallback move it to
@@ -140,6 +254,7 @@ void QCocoaScreen::remove()
// QCocoaWindow::windowDidChangeScreen. At that point the window will appear to have
// already changed its screen, but that's only true if comparing the Qt screens,
// not when comparing the NSScreens.
+ qCInfo(lcQpaScreen) << "Removing " << this;
QWindowSystemInterface::handleScreenRemoved(this);
}
@@ -186,9 +301,14 @@ static QString displayName(CGDirectDisplayID displayID)
return QString();
}
-void QCocoaScreen::updateProperties()
+void QCocoaScreen::update(CGDirectDisplayID displayId)
{
- Q_ASSERT(m_displayId);
+ if (displayId != m_displayId) {
+ qCDebug(lcQpaScreen) << "Reconnecting" << this << "as display" << displayId;
+ m_displayId = displayId;
+ }
+
+ Q_ASSERT(isOnline());
const QRect previousGeometry = m_geometry;
const QRect previousAvailableGeometry = m_availableGeometry;
@@ -326,8 +446,8 @@ struct DeferredDebugHelper
void QCocoaScreen::deliverUpdateRequests()
{
- if (!m_displayId)
- return; // Screen removed
+ if (!isOnline())
+ return;
QMacAutoReleasePool pool;
@@ -351,15 +471,6 @@ void QCocoaScreen::deliverUpdateRequests()
// it on the main thread yet, because the processing of the update request is taking
// too long, or because the update request was deferred due to window live resizing.
qDeferredDebug(screenUpdates) << ", " << framesAheadOfDelivery << " frame(s) ahead";
-
- // We skip the frame completely if we're live-resizing, to not put any extra
- // strain on the main thread runloop. Otherwise we assume we should push frames
- // as fast as possible, and hopefully the callback will be delivered on the
- // main thread just when the previous finished.
- if (qt_apple_sharedApplication().keyWindow.inLiveResize) {
- qDeferredDebug(screenUpdates) << "; waiting for main thread to catch up";
- return;
- }
}
qDeferredDebug(screenUpdates) << "; signaling dispatch source";
@@ -547,15 +658,38 @@ QPixmap QCocoaScreen::grabWindow(WId view, int x, int y, int width, int height)
return windowPixmap;
}
+bool QCocoaScreen::isOnline() const
+{
+ // When a display is disconnected CGDisplayIsOnline and other CGDisplay
+ // functions that take a displayId will not return false, but will start
+ // returning -1 to signal that the displayId is invalid. Some functions
+ // will also assert or even crash in this case, so it's important that
+ // we double check if a display is online before calling other functions.
+ auto isOnline = CGDisplayIsOnline(m_displayId);
+ static const uint32_t kCGDisplayIsDisconnected = int32_t(-1);
+ return isOnline != kCGDisplayIsDisconnected && isOnline;
+}
+
+/*
+ Returns true if a screen is mirroring another screen
+*/
+bool QCocoaScreen::isMirroring() const
+{
+ if (!isOnline())
+ return false;
+
+ return CGDisplayMirrorsDisplay(m_displayId);
+}
+
/*!
The screen used as a reference for global window geometry
*/
QCocoaScreen *QCocoaScreen::primaryScreen()
{
- auto screen = static_cast<QCocoaScreen *>(QGuiApplication::primaryScreen()->handle());
- Q_ASSERT_X(screen == get(CGMainDisplayID()), "QCocoaScreen",
- "The application's primary screen should always be in sync with the main display");
- return screen;
+ // Note: The primary screen that Qt knows about may not match the current CGMainDisplayID()
+ // if macOS has not yet been able to inform us that the main display has changed, but we
+ // will update the primary screen accordingly once the reconfiguration callback comes in.
+ return static_cast<QCocoaScreen *>(QGuiApplication::primaryScreen()->handle());
}
QList<QPlatformScreen*> QCocoaScreen::virtualSiblings() const
@@ -571,6 +705,12 @@ QList<QPlatformScreen*> QCocoaScreen::virtualSiblings() const
QCocoaScreen *QCocoaScreen::get(NSScreen *nsScreen)
{
+ if (s_screenConfigurationBeforeUpdate) {
+ qCWarning(lcQpaScreen) << "Trying to resolve screen while waiting for screen reconfigure!";
+ if (!updateScreensIfNeeded())
+ qCWarning(lcQpaScreen) << "Failed to do last minute screen update. Expect crashes.";
+ }
+
return get(nsScreen.qt_displayId);
}
@@ -585,23 +725,34 @@ QCocoaScreen *QCocoaScreen::get(CGDirectDisplayID displayId)
return nullptr;
}
+QCocoaScreen *QCocoaScreen::get(CFUUIDRef uuid)
+{
+ for (QScreen *screen : QGuiApplication::screens()) {
+ auto *platformScreen = static_cast<QCocoaScreen*>(screen->handle());
+ if (!platformScreen->isOnline())
+ continue;
+
+ auto displayId = platformScreen->displayId();
+ QCFType<CFUUIDRef> candidateUuid(CGDisplayCreateUUIDFromDisplayID(displayId));
+ Q_ASSERT(candidateUuid);
+
+ if (candidateUuid == uuid)
+ return platformScreen;
+ }
+
+ return nullptr;
+}
+
NSScreen *QCocoaScreen::nativeScreen() const
{
if (!m_displayId)
return nil; // The display has been disconnected
- // A single display may have different displayIds depending on
- // which GPU is in use or which physical port the display is
- // connected to. By comparing UUIDs instead of display IDs we
- // ensure that we always pick up the appropriate NSScreen.
- QCFType<CFUUIDRef> uuid = CGDisplayCreateUUIDFromDisplayID(m_displayId);
-
- for (NSScreen *screen in [NSScreen screens]) {
- if (CGDisplayCreateUUIDFromDisplayID(screen.qt_displayId) == uuid)
+ for (NSScreen *screen in NSScreen.screens) {
+ if (screen.qt_displayId == m_displayId)
return screen;
}
- qCWarning(lcQpaScreen) << "Could not find NSScreen for display ID" << m_displayId;
return nil;
}
@@ -636,16 +787,29 @@ QDebug operator<<(QDebug debug, const QCocoaScreen *screen)
debug.nospace();
debug << "QCocoaScreen(" << (const void *)screen;
if (screen) {
- debug << ", geometry=" << screen->geometry();
+ debug << ", " << screen->name();
+ if (screen->isOnline()) {
+ if (CGDisplayIsAsleep(screen->displayId()))
+ debug << ", Sleeping";
+ if (auto mirroring = CGDisplayMirrorsDisplay(screen->displayId()))
+ debug << ", mirroring=" << mirroring;
+ } else {
+ debug << ", Offline";
+ }
+ debug << ", " << screen->geometry();
debug << ", dpr=" << screen->devicePixelRatio();
- debug << ", name=" << screen->name();
- debug << ", native=" << screen->nativeScreen();
+ debug << ", displayId=" << screen->displayId();
+
+ if (auto nativeScreen = screen->nativeScreen())
+ debug << ", " << nativeScreen;
}
debug << ')';
return debug;
}
#endif // !QT_NO_DEBUG_STREAM
+#include "qcocoascreen.moc"
+
QT_END_NAMESPACE
@implementation NSScreen (QtExtras)
diff --git a/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp b/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp
new file mode 100644
index 0000000000..74e318b5be
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Samuel Gaist <samuel.gaist@idiap.ch>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT_NO_SESSIONMANAGER
+#include <private/qsessionmanager_p.h>
+#include <private/qguiapplication_p.h>
+
+#include <qcocoasessionmanager.h>
+#include <qstring.h>
+
+QT_BEGIN_NAMESPACE
+
+QCocoaSessionManager::QCocoaSessionManager(const QString &id, const QString &key)
+ : QPlatformSessionManager(id, key),
+ m_canceled(false)
+{
+}
+
+QCocoaSessionManager::~QCocoaSessionManager()
+{
+}
+
+bool QCocoaSessionManager::allowsInteraction()
+{
+ return false;
+}
+
+void QCocoaSessionManager::resetCancellation()
+{
+ m_canceled = false;
+}
+
+void QCocoaSessionManager::cancel()
+{
+ m_canceled = true;
+}
+
+bool QCocoaSessionManager::wasCanceled() const
+{
+ return m_canceled;
+}
+
+QCocoaSessionManager *QCocoaSessionManager::instance()
+{
+ auto *qGuiAppPriv = QGuiApplicationPrivate::instance();
+ auto *managerPrivate = static_cast<QSessionManagerPrivate*>(QObjectPrivate::get(qGuiAppPriv->session_manager));
+ return static_cast<QCocoaSessionManager *>(managerPrivate->platformSessionManager);
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_SESSIONMANAGER
diff --git a/src/plugins/platforms/cocoa/qcocoasessionmanager.h b/src/plugins/platforms/cocoa/qcocoasessionmanager.h
new file mode 100644
index 0000000000..89ab7bd157
--- /dev/null
+++ b/src/plugins/platforms/cocoa/qcocoasessionmanager.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Samuel Gaist <samuel.gaist@idiap.ch>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOCOASESSIONMANAGER_H
+#define QCOCOASESSIONMANAGER_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is part of the QPA API and is not meant to be used
+// in applications. Usage of this API may make your code
+// source and binary incompatible with future versions of Qt.
+//
+
+#ifndef QT_NO_SESSIONMANAGER
+
+#include <qpa/qplatformsessionmanager.h>
+
+QT_BEGIN_NAMESPACE
+
+class QCocoaSessionManager : public QPlatformSessionManager
+{
+public:
+ QCocoaSessionManager(const QString &id, const QString &key);
+ virtual ~QCocoaSessionManager();
+
+ bool allowsInteraction() override;
+ void cancel() override;
+ void resetCancellation();
+ bool wasCanceled() const;
+
+ static QCocoaSessionManager *instance();
+
+private:
+ bool m_canceled;
+
+ Q_DISABLE_COPY(QCocoaSessionManager)
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_SESSIONMANAGER
+
+#endif // QCOCOASESSIONMANAGER_H
diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
deleted file mode 100644
index cb25bd7d81..0000000000
--- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
+++ /dev/null
@@ -1,245 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qcocoasystemsettings.h"
-
-#include "qcocoahelpers.h"
-
-#include <QtCore/private/qcore_mac_p.h>
-#include <QtGui/qfont.h>
-#include <QtGui/private/qcoregraphics_p.h>
-
-#if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_14)
-@interface NSColor (MojaveForwardDeclarations)
-@property (class, strong, readonly) NSColor *selectedContentBackgroundColor NS_AVAILABLE_MAC(10_14);
-@property (class, strong, readonly) NSColor *unemphasizedSelectedTextBackgroundColor NS_AVAILABLE_MAC(10_14);
-@property (class, strong, readonly) NSColor *unemphasizedSelectedTextColor NS_AVAILABLE_MAC(10_14);
-@property (class, strong, readonly) NSColor *unemphasizedSelectedContentBackgroundColor NS_AVAILABLE_MAC(10_14);
-@property (class, strong, readonly) NSArray<NSColor *> *alternatingContentBackgroundColors NS_AVAILABLE_MAC(10_14);
-// Missing from non-Mojave SDKs, even if introduced in 10.10
-@property (class, strong, readonly) NSColor *linkColor NS_AVAILABLE_MAC(10_10);
-@end
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QPalette * qt_mac_createSystemPalette()
-{
- QColor qc;
-
- // Standard palette initialization (copied from Qt 4 styles)
- QBrush backgroundBrush = qt_mac_toQBrush([NSColor windowBackgroundColor]);
- QColor background = backgroundBrush.color();
- QColor light(background.lighter(110));
- QColor dark(background.darker(160));
- QColor mid(background.darker(140));
- QPalette *palette = new QPalette(Qt::black, background, light, dark, mid, Qt::black, Qt::white);
-
- palette->setBrush(QPalette::Window, backgroundBrush);
-
- palette->setBrush(QPalette::Disabled, QPalette::WindowText, dark);
- palette->setBrush(QPalette::Disabled, QPalette::Text, dark);
- palette->setBrush(QPalette::Disabled, QPalette::ButtonText, dark);
- palette->setBrush(QPalette::Disabled, QPalette::Base, backgroundBrush);
- QBrush textBackgroundBrush = qt_mac_toQBrush([NSColor textBackgroundColor]);
- palette->setBrush(QPalette::Active, QPalette::Base, textBackgroundBrush);
- palette->setBrush(QPalette::Inactive, QPalette::Base, textBackgroundBrush);
- palette->setColor(QPalette::Disabled, QPalette::Dark, QColor(191, 191, 191));
- palette->setColor(QPalette::Active, QPalette::Dark, QColor(191, 191, 191));
- palette->setColor(QPalette::Inactive, QPalette::Dark, QColor(191, 191, 191));
-
- // System palette initialization:
- QBrush br = qt_mac_toQBrush([NSColor selectedControlColor]);
- palette->setBrush(QPalette::Active, QPalette::Highlight, br);
- if (__builtin_available(macOS 10.14, *)) {
- const auto inactiveHighlight = qt_mac_toQBrush([NSColor unemphasizedSelectedContentBackgroundColor]);
- palette->setBrush(QPalette::Inactive, QPalette::Highlight, inactiveHighlight);
- palette->setBrush(QPalette::Disabled, QPalette::Highlight, inactiveHighlight);
- } else {
- palette->setBrush(QPalette::Inactive, QPalette::Highlight, br);
- palette->setBrush(QPalette::Disabled, QPalette::Highlight, br);
- }
-
- palette->setBrush(QPalette::Shadow, qt_mac_toQColor([NSColor shadowColor]));
-
- qc = qt_mac_toQColor([NSColor controlTextColor]);
- palette->setColor(QPalette::Active, QPalette::Text, qc);
- palette->setColor(QPalette::Active, QPalette::WindowText, qc);
- palette->setColor(QPalette::Active, QPalette::HighlightedText, qc);
- palette->setColor(QPalette::Inactive, QPalette::Text, qc);
- palette->setColor(QPalette::Inactive, QPalette::WindowText, qc);
- palette->setColor(QPalette::Inactive, QPalette::HighlightedText, qc);
-
- qc = qt_mac_toQColor([NSColor disabledControlTextColor]);
- palette->setColor(QPalette::Disabled, QPalette::Text, qc);
- palette->setColor(QPalette::Disabled, QPalette::WindowText, qc);
- palette->setColor(QPalette::Disabled, QPalette::HighlightedText, qc);
-
- palette->setBrush(QPalette::ToolTipBase, qt_mac_toQBrush([NSColor controlColor]));
-
- palette->setColor(QPalette::Normal, QPalette::Link, qt_mac_toQColor([NSColor linkColor]));
-
- return palette;
-}
-
-struct QMacPaletteMap {
- inline QMacPaletteMap(QPlatformTheme::Palette p, NSColor *a, NSColor *i) :
- active(a), inactive(i), paletteRole(p) { }
-
- NSColor *active;
- NSColor *inactive;
- QPlatformTheme::Palette paletteRole;
-};
-
-#define MAC_PALETTE_ENTRY(pal, active, inactive) \
- QMacPaletteMap(pal, [NSColor active], [NSColor inactive])
-static QMacPaletteMap mac_widget_colors[] = {
- MAC_PALETTE_ENTRY(QPlatformTheme::ToolButtonPalette, controlTextColor, disabledControlTextColor),
- MAC_PALETTE_ENTRY(QPlatformTheme::ButtonPalette, controlTextColor, disabledControlTextColor),
- MAC_PALETTE_ENTRY(QPlatformTheme::HeaderPalette, headerTextColor, disabledControlTextColor),
- MAC_PALETTE_ENTRY(QPlatformTheme::ComboBoxPalette, controlTextColor, disabledControlTextColor),
- MAC_PALETTE_ENTRY(QPlatformTheme::ItemViewPalette, textColor, disabledControlTextColor),
- MAC_PALETTE_ENTRY(QPlatformTheme::MessageBoxLabelPalette, textColor, disabledControlTextColor),
- MAC_PALETTE_ENTRY(QPlatformTheme::TabBarPalette, controlTextColor, disabledControlTextColor),
- MAC_PALETTE_ENTRY(QPlatformTheme::LabelPalette, textColor, disabledControlTextColor),
- MAC_PALETTE_ENTRY(QPlatformTheme::GroupBoxPalette, textColor, disabledControlTextColor),
- MAC_PALETTE_ENTRY(QPlatformTheme::MenuPalette, controlTextColor, disabledControlTextColor),
- MAC_PALETTE_ENTRY(QPlatformTheme::MenuBarPalette, controlTextColor, disabledControlTextColor),
- MAC_PALETTE_ENTRY(QPlatformTheme::TextEditPalette, textColor, disabledControlTextColor),
- MAC_PALETTE_ENTRY(QPlatformTheme::TextLineEditPalette, textColor, disabledControlTextColor)
-};
-#undef MAC_PALETTE_ENTRY
-
-static const int mac_widget_colors_count = sizeof(mac_widget_colors) / sizeof(mac_widget_colors[0]);
-
-QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes()
-{
- QHash<QPlatformTheme::Palette, QPalette*> palettes;
- QColor qc;
- for (int i = 0; i < mac_widget_colors_count; i++) {
- QPalette &pal = *qt_mac_createSystemPalette();
- if (mac_widget_colors[i].active) {
- qc = qt_mac_toQColor(mac_widget_colors[i].active);
- pal.setColor(QPalette::Active, QPalette::Text, qc);
- pal.setColor(QPalette::Inactive, QPalette::Text, qc);
- pal.setColor(QPalette::Active, QPalette::WindowText, qc);
- pal.setColor(QPalette::Inactive, QPalette::WindowText, qc);
- pal.setColor(QPalette::Active, QPalette::HighlightedText, qc);
- pal.setColor(QPalette::Inactive, QPalette::HighlightedText, qc);
- pal.setColor(QPalette::Active, QPalette::ButtonText, qc);
- pal.setColor(QPalette::Inactive, QPalette::ButtonText, qc);
- qc = qt_mac_toQColor(mac_widget_colors[i].inactive);
- pal.setColor(QPalette::Disabled, QPalette::Text, qc);
- pal.setColor(QPalette::Disabled, QPalette::WindowText, qc);
- pal.setColor(QPalette::Disabled, QPalette::HighlightedText, qc);
- pal.setColor(QPalette::Disabled, QPalette::ButtonText, qc);
- }
- if (mac_widget_colors[i].paletteRole == QPlatformTheme::MenuPalette
- || mac_widget_colors[i].paletteRole == QPlatformTheme::MenuBarPalette) {
- NSColor *selectedMenuItemColor = nil;
- if (__builtin_available(macOS 10.14, *)) {
- // Cheap approximation for NSVisualEffectView (see deprecation note for selectedMenuItemTextColor)
- selectedMenuItemColor = [[NSColor selectedContentBackgroundColor] highlightWithLevel:0.4];
- } else {
- // selectedMenuItemColor would presumably be the correct color to use as the background
- // for selected menu items. But that color is always blue, and doesn't follow the
- // appearance color in system preferences. So we therefore deliberatly choose to use
- // keyboardFocusIndicatorColor instead, which appears to have the same color value.
- selectedMenuItemColor = [NSColor keyboardFocusIndicatorColor];
- }
- pal.setBrush(QPalette::Highlight, qt_mac_toQColor(selectedMenuItemColor));
- qc = qt_mac_toQColor([NSColor labelColor]);
- pal.setBrush(QPalette::ButtonText, qc);
- pal.setBrush(QPalette::Text, qc);
- qc = qt_mac_toQColor([NSColor selectedMenuItemTextColor]);
- pal.setBrush(QPalette::HighlightedText, qc);
- qc = qt_mac_toQColor([NSColor disabledControlTextColor]);
- pal.setBrush(QPalette::Disabled, QPalette::Text, qc);
- } else if ((mac_widget_colors[i].paletteRole == QPlatformTheme::ButtonPalette)
- || (mac_widget_colors[i].paletteRole == QPlatformTheme::HeaderPalette)
- || (mac_widget_colors[i].paletteRole == QPlatformTheme::TabBarPalette)) {
- pal.setColor(QPalette::Disabled, QPalette::ButtonText,
- pal.color(QPalette::Disabled, QPalette::Text));
- pal.setColor(QPalette::Inactive, QPalette::ButtonText,
- pal.color(QPalette::Inactive, QPalette::Text));
- pal.setColor(QPalette::Active, QPalette::ButtonText,
- pal.color(QPalette::Active, QPalette::Text));
- } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::ItemViewPalette) {
- NSArray<NSColor *> *baseColors = nil;
- NSColor *activeHighlightColor = nil;
- if (__builtin_available(macOS 10.14, *)) {
- baseColors = [NSColor alternatingContentBackgroundColors];
- activeHighlightColor = [NSColor selectedContentBackgroundColor];
- pal.setBrush(QPalette::Inactive, QPalette::HighlightedText,
- qt_mac_toQBrush([NSColor unemphasizedSelectedTextColor]));
- } else {
- baseColors = [NSColor controlAlternatingRowBackgroundColors];
- activeHighlightColor = [NSColor alternateSelectedControlColor];
- pal.setBrush(QPalette::Inactive, QPalette::HighlightedText,
- pal.brush(QPalette::Active, QPalette::Text));
- }
- pal.setBrush(QPalette::Base, qt_mac_toQBrush(baseColors[0]));
- pal.setBrush(QPalette::AlternateBase, qt_mac_toQBrush(baseColors[1]));
- pal.setBrush(QPalette::Active, QPalette::Highlight,
- qt_mac_toQBrush(activeHighlightColor));
- pal.setBrush(QPalette::Active, QPalette::HighlightedText,
- qt_mac_toQBrush([NSColor alternateSelectedControlTextColor]));
- pal.setBrush(QPalette::Inactive, QPalette::Text,
- pal.brush(QPalette::Active, QPalette::Text));
- } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::TextEditPalette) {
- pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor]));
- pal.setBrush(QPalette::Inactive, QPalette::Text,
- pal.brush(QPalette::Active, QPalette::Text));
- pal.setBrush(QPalette::Inactive, QPalette::HighlightedText,
- pal.brush(QPalette::Active, QPalette::Text));
- } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::TextLineEditPalette
- || mac_widget_colors[i].paletteRole == QPlatformTheme::ComboBoxPalette) {
- pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor]));
- pal.setBrush(QPalette::Disabled, QPalette::Base,
- pal.brush(QPalette::Active, QPalette::Base));
- } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::LabelPalette) {
- qc = qt_mac_toQColor([NSColor labelColor]);
- pal.setBrush(QPalette::Inactive, QPalette::ToolTipText, qc);
- }
- palettes.insert(mac_widget_colors[i].paletteRole, &pal);
- }
- return palettes;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.h b/src/plugins/platforms/cocoa/qcocoatheme.h
index a00cbdfea3..50e56ef1bf 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.h
+++ b/src/plugins/platforms/cocoa/qcocoatheme.h
@@ -70,7 +70,7 @@ public:
const QPalette *palette(Palette type = SystemPalette) const override;
const QFont *font(Font type = SystemFont) const override;
QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const override;
- QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions options = 0) const override;
+ QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions options = {}) const override;
QVariant themeHint(ThemeHint hint) const override;
QString standardButtonText(int button) const override;
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
index 7c10456824..a76ba300e9 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
@@ -45,7 +45,6 @@
#include <QtCore/QOperatingSystemVersion>
#include <QtCore/QVariant>
-#include "qcocoasystemsettings.h"
#include "qcocoasystemtrayicon.h"
#include "qcocoamenuitem.h"
#include "qcocoamenu.h"
@@ -80,8 +79,203 @@
#include <CoreServices/CoreServices.h>
+#if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_14)
+@interface NSColor (MojaveForwardDeclarations)
+@property (class, strong, readonly) NSColor *selectedContentBackgroundColor NS_AVAILABLE_MAC(10_14);
+@property (class, strong, readonly) NSColor *unemphasizedSelectedTextBackgroundColor NS_AVAILABLE_MAC(10_14);
+@property (class, strong, readonly) NSColor *unemphasizedSelectedTextColor NS_AVAILABLE_MAC(10_14);
+@property (class, strong, readonly) NSColor *unemphasizedSelectedContentBackgroundColor NS_AVAILABLE_MAC(10_14);
+@property (class, strong, readonly) NSArray<NSColor *> *alternatingContentBackgroundColors NS_AVAILABLE_MAC(10_14);
+// Missing from non-Mojave SDKs, even if introduced in 10.10
+@property (class, strong, readonly) NSColor *linkColor NS_AVAILABLE_MAC(10_10);
+@end
+#endif
+
QT_BEGIN_NAMESPACE
+static QPalette *qt_mac_createSystemPalette()
+{
+ QColor qc;
+
+ // Standard palette initialization (copied from Qt 4 styles)
+ QBrush backgroundBrush = qt_mac_toQBrush([NSColor windowBackgroundColor]);
+ QColor background = backgroundBrush.color();
+ QColor light(background.lighter(110));
+ QColor dark(background.darker(160));
+ QColor mid(background.darker(140));
+ QPalette *palette = new QPalette(Qt::black, background, light, dark, mid, Qt::black, Qt::white);
+
+ palette->setBrush(QPalette::Window, backgroundBrush);
+
+ palette->setBrush(QPalette::Disabled, QPalette::WindowText, dark);
+ palette->setBrush(QPalette::Disabled, QPalette::Text, dark);
+ palette->setBrush(QPalette::Disabled, QPalette::ButtonText, dark);
+ palette->setBrush(QPalette::Disabled, QPalette::Base, backgroundBrush);
+ QBrush textBackgroundBrush = qt_mac_toQBrush([NSColor textBackgroundColor]);
+ palette->setBrush(QPalette::Active, QPalette::Base, textBackgroundBrush);
+ palette->setBrush(QPalette::Inactive, QPalette::Base, textBackgroundBrush);
+ palette->setColor(QPalette::Disabled, QPalette::Dark, QColor(191, 191, 191));
+ palette->setColor(QPalette::Active, QPalette::Dark, QColor(191, 191, 191));
+ palette->setColor(QPalette::Inactive, QPalette::Dark, QColor(191, 191, 191));
+
+ // System palette initialization:
+ QBrush br = qt_mac_toQBrush([NSColor selectedControlColor]);
+ palette->setBrush(QPalette::Active, QPalette::Highlight, br);
+ if (__builtin_available(macOS 10.14, *)) {
+ const auto inactiveHighlight = qt_mac_toQBrush([NSColor unemphasizedSelectedContentBackgroundColor]);
+ palette->setBrush(QPalette::Inactive, QPalette::Highlight, inactiveHighlight);
+ palette->setBrush(QPalette::Disabled, QPalette::Highlight, inactiveHighlight);
+ } else {
+ palette->setBrush(QPalette::Inactive, QPalette::Highlight, br);
+ palette->setBrush(QPalette::Disabled, QPalette::Highlight, br);
+ }
+
+ palette->setBrush(QPalette::Shadow, qt_mac_toQColor([NSColor shadowColor]));
+
+ qc = qt_mac_toQColor([NSColor controlTextColor]);
+ palette->setColor(QPalette::Active, QPalette::Text, qc);
+ palette->setColor(QPalette::Active, QPalette::WindowText, qc);
+ palette->setColor(QPalette::Active, QPalette::HighlightedText, qc);
+ palette->setColor(QPalette::Inactive, QPalette::Text, qc);
+ palette->setColor(QPalette::Inactive, QPalette::WindowText, qc);
+ palette->setColor(QPalette::Inactive, QPalette::HighlightedText, qc);
+
+ qc = qt_mac_toQColor([NSColor disabledControlTextColor]);
+ palette->setColor(QPalette::Disabled, QPalette::Text, qc);
+ palette->setColor(QPalette::Disabled, QPalette::WindowText, qc);
+ palette->setColor(QPalette::Disabled, QPalette::HighlightedText, qc);
+
+ palette->setBrush(QPalette::ToolTipBase, qt_mac_toQBrush([NSColor controlColor]));
+
+ palette->setColor(QPalette::Normal, QPalette::Link, qt_mac_toQColor([NSColor linkColor]));
+
+ return palette;
+}
+
+struct QMacPaletteMap {
+ inline QMacPaletteMap(QPlatformTheme::Palette p, NSColor *a, NSColor *i) :
+ active(a), inactive(i), paletteRole(p) { }
+
+ NSColor *active;
+ NSColor *inactive;
+ QPlatformTheme::Palette paletteRole;
+};
+
+#define MAC_PALETTE_ENTRY(pal, active, inactive) \
+ QMacPaletteMap(pal, [NSColor active], [NSColor inactive])
+static QMacPaletteMap mac_widget_colors[] = {
+ MAC_PALETTE_ENTRY(QPlatformTheme::ToolButtonPalette, controlTextColor, disabledControlTextColor),
+ MAC_PALETTE_ENTRY(QPlatformTheme::ButtonPalette, controlTextColor, disabledControlTextColor),
+ MAC_PALETTE_ENTRY(QPlatformTheme::HeaderPalette, headerTextColor, disabledControlTextColor),
+ MAC_PALETTE_ENTRY(QPlatformTheme::ComboBoxPalette, controlTextColor, disabledControlTextColor),
+ MAC_PALETTE_ENTRY(QPlatformTheme::ItemViewPalette, textColor, disabledControlTextColor),
+ MAC_PALETTE_ENTRY(QPlatformTheme::MessageBoxLabelPalette, textColor, disabledControlTextColor),
+ MAC_PALETTE_ENTRY(QPlatformTheme::TabBarPalette, controlTextColor, disabledControlTextColor),
+ MAC_PALETTE_ENTRY(QPlatformTheme::LabelPalette, textColor, disabledControlTextColor),
+ MAC_PALETTE_ENTRY(QPlatformTheme::GroupBoxPalette, textColor, disabledControlTextColor),
+ MAC_PALETTE_ENTRY(QPlatformTheme::MenuPalette, controlTextColor, disabledControlTextColor),
+ MAC_PALETTE_ENTRY(QPlatformTheme::MenuBarPalette, controlTextColor, disabledControlTextColor),
+ MAC_PALETTE_ENTRY(QPlatformTheme::TextEditPalette, textColor, disabledControlTextColor),
+ MAC_PALETTE_ENTRY(QPlatformTheme::TextLineEditPalette, textColor, disabledControlTextColor)
+};
+#undef MAC_PALETTE_ENTRY
+
+static const int mac_widget_colors_count = sizeof(mac_widget_colors) / sizeof(mac_widget_colors[0]);
+
+static QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes()
+{
+ QHash<QPlatformTheme::Palette, QPalette*> palettes;
+ QColor qc;
+ for (int i = 0; i < mac_widget_colors_count; i++) {
+ QPalette &pal = *qt_mac_createSystemPalette();
+ if (mac_widget_colors[i].active) {
+ qc = qt_mac_toQColor(mac_widget_colors[i].active);
+ pal.setColor(QPalette::Active, QPalette::Text, qc);
+ pal.setColor(QPalette::Inactive, QPalette::Text, qc);
+ pal.setColor(QPalette::Active, QPalette::WindowText, qc);
+ pal.setColor(QPalette::Inactive, QPalette::WindowText, qc);
+ pal.setColor(QPalette::Active, QPalette::HighlightedText, qc);
+ pal.setColor(QPalette::Inactive, QPalette::HighlightedText, qc);
+ pal.setColor(QPalette::Active, QPalette::ButtonText, qc);
+ pal.setColor(QPalette::Inactive, QPalette::ButtonText, qc);
+ qc = qt_mac_toQColor(mac_widget_colors[i].inactive);
+ pal.setColor(QPalette::Disabled, QPalette::Text, qc);
+ pal.setColor(QPalette::Disabled, QPalette::WindowText, qc);
+ pal.setColor(QPalette::Disabled, QPalette::HighlightedText, qc);
+ pal.setColor(QPalette::Disabled, QPalette::ButtonText, qc);
+ }
+ if (mac_widget_colors[i].paletteRole == QPlatformTheme::MenuPalette
+ || mac_widget_colors[i].paletteRole == QPlatformTheme::MenuBarPalette) {
+ NSColor *selectedMenuItemColor = nil;
+ if (__builtin_available(macOS 10.14, *)) {
+ // Cheap approximation for NSVisualEffectView (see deprecation note for selectedMenuItemTextColor)
+ selectedMenuItemColor = [[NSColor selectedContentBackgroundColor] highlightWithLevel:0.4];
+ } else {
+ // selectedMenuItemColor would presumably be the correct color to use as the background
+ // for selected menu items. But that color is always blue, and doesn't follow the
+ // appearance color in system preferences. So we therefore deliberatly choose to use
+ // keyboardFocusIndicatorColor instead, which appears to have the same color value.
+ selectedMenuItemColor = [NSColor keyboardFocusIndicatorColor];
+ }
+ pal.setBrush(QPalette::Highlight, qt_mac_toQColor(selectedMenuItemColor));
+ qc = qt_mac_toQColor([NSColor labelColor]);
+ pal.setBrush(QPalette::ButtonText, qc);
+ pal.setBrush(QPalette::Text, qc);
+ qc = qt_mac_toQColor([NSColor selectedMenuItemTextColor]);
+ pal.setBrush(QPalette::HighlightedText, qc);
+ qc = qt_mac_toQColor([NSColor disabledControlTextColor]);
+ pal.setBrush(QPalette::Disabled, QPalette::Text, qc);
+ } else if ((mac_widget_colors[i].paletteRole == QPlatformTheme::ButtonPalette)
+ || (mac_widget_colors[i].paletteRole == QPlatformTheme::HeaderPalette)
+ || (mac_widget_colors[i].paletteRole == QPlatformTheme::TabBarPalette)) {
+ pal.setColor(QPalette::Disabled, QPalette::ButtonText,
+ pal.color(QPalette::Disabled, QPalette::Text));
+ pal.setColor(QPalette::Inactive, QPalette::ButtonText,
+ pal.color(QPalette::Inactive, QPalette::Text));
+ pal.setColor(QPalette::Active, QPalette::ButtonText,
+ pal.color(QPalette::Active, QPalette::Text));
+ } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::ItemViewPalette) {
+ NSArray<NSColor *> *baseColors = nil;
+ NSColor *activeHighlightColor = nil;
+ if (__builtin_available(macOS 10.14, *)) {
+ baseColors = [NSColor alternatingContentBackgroundColors];
+ activeHighlightColor = [NSColor selectedContentBackgroundColor];
+ pal.setBrush(QPalette::Inactive, QPalette::HighlightedText,
+ qt_mac_toQBrush([NSColor unemphasizedSelectedTextColor]));
+ } else {
+ baseColors = [NSColor controlAlternatingRowBackgroundColors];
+ activeHighlightColor = [NSColor alternateSelectedControlColor];
+ pal.setBrush(QPalette::Inactive, QPalette::HighlightedText,
+ pal.brush(QPalette::Active, QPalette::Text));
+ }
+ pal.setBrush(QPalette::Base, qt_mac_toQBrush(baseColors[0]));
+ pal.setBrush(QPalette::AlternateBase, qt_mac_toQBrush(baseColors[1]));
+ pal.setBrush(QPalette::Active, QPalette::Highlight,
+ qt_mac_toQBrush(activeHighlightColor));
+ pal.setBrush(QPalette::Active, QPalette::HighlightedText,
+ qt_mac_toQBrush([NSColor alternateSelectedControlTextColor]));
+ pal.setBrush(QPalette::Inactive, QPalette::Text,
+ pal.brush(QPalette::Active, QPalette::Text));
+ } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::TextEditPalette) {
+ pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor]));
+ pal.setBrush(QPalette::Inactive, QPalette::Text,
+ pal.brush(QPalette::Active, QPalette::Text));
+ pal.setBrush(QPalette::Inactive, QPalette::HighlightedText,
+ pal.brush(QPalette::Active, QPalette::Text));
+ } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::TextLineEditPalette
+ || mac_widget_colors[i].paletteRole == QPlatformTheme::ComboBoxPalette) {
+ pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor]));
+ pal.setBrush(QPalette::Disabled, QPalette::Base,
+ pal.brush(QPalette::Active, QPalette::Base));
+ } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::LabelPalette) {
+ qc = qt_mac_toQColor([NSColor labelColor]);
+ pal.setBrush(QPalette::Inactive, QPalette::ToolTipText, qc);
+ }
+ palettes.insert(mac_widget_colors[i].paletteRole, &pal);
+ }
+ return palettes;
+}
+
const char *QCocoaTheme::name = "cocoa";
QCocoaTheme::QCocoaTheme()
@@ -129,7 +323,7 @@ void QCocoaTheme::handleSystemThemeChange()
QFontCache::instance()->clear();
}
- QWindowSystemInterface::handleThemeChange(nullptr);
+ QWindowSystemInterface::handleThemeChange<QWindowSystemInterface::SynchronousDelivery>(nullptr);
}
bool QCocoaTheme::usePlatformNativeDialog(DialogType dialogType) const
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index f212b3e3f0..ad232d6d80 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -559,7 +559,10 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
if ((type & Qt::Popup) != Qt::Popup && (type & Qt::Dialog) != Qt::Dialog) {
NSWindowCollectionBehavior behavior = m_view.window.collectionBehavior;
- if ((flags & Qt::WindowFullscreenButtonHint) || m_view.window.qt_fullScreen) {
+ const bool enableFullScreen = m_view.window.qt_fullScreen
+ || !(flags & Qt::CustomizeWindowHint)
+ || (flags & Qt::WindowFullscreenButtonHint);
+ if (enableFullScreen) {
behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
behavior &= ~NSWindowCollectionBehaviorFullScreenAuxiliary;
} else {
@@ -1509,17 +1512,6 @@ bool QCocoaWindow::updatesWithDisplayLink() const
void QCocoaWindow::deliverUpdateRequest()
{
- // Don't send update requests for views that need display, as the update
- // request doesn't carry any information about dirty rects, so the app
- // may end up painting a smaller region than required. (For some reason
- // the layer and view's needsDisplay status isn't always in sync, even if
- // the view is layer-backed, not layer-hosted, so we check both).
- if (m_view.layer.needsDisplay || m_view.needsDisplay) {
- qCDebug(lcQpaDrawing) << "View needs display, deferring update request for" << window();
- requestUpdate();
- return;
- }
-
qCDebug(lcQpaDrawing) << "Delivering update request to" << window();
QPlatformWindow::deliverUpdateRequest();
}
@@ -1700,9 +1692,9 @@ void QCocoaWindow::registerTouch(bool enable)
{
m_registerTouchCount += enable ? 1 : -1;
if (enable && m_registerTouchCount == 1)
- [m_view setAcceptsTouchEvents:YES];
+ m_view.allowedTouchTypes |= NSTouchTypeMaskIndirect;
else if (m_registerTouchCount == 0)
- [m_view setAcceptsTouchEvents:NO];
+ m_view.allowedTouchTypes &= ~NSTouchTypeMaskIndirect;
}
void QCocoaWindow::setContentBorderThickness(int topThickness, int bottomThickness)
diff --git a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h
index 872773cb7a..e070ba977d 100644
--- a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h
+++ b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h
@@ -48,9 +48,11 @@ QT_BEGIN_NAMESPACE
class QIOSurfaceGraphicsBuffer : public QPlatformGraphicsBuffer
{
public:
- QIOSurfaceGraphicsBuffer(const QSize &size, const QPixelFormat &format, QCFType<CGColorSpaceRef> colorSpace);
+ QIOSurfaceGraphicsBuffer(const QSize &size, const QPixelFormat &format);
~QIOSurfaceGraphicsBuffer();
+ void setColorSpace(QCFType<CGColorSpaceRef> colorSpace);
+
const uchar *data() const override;
uchar *data() override;
int bytesPerLine() const override;
diff --git a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm
index a367487e85..fc187e0f51 100644
--- a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm
+++ b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcQpaIOSurface, "qt.qpa.backingstore.iosurface");
-QIOSurfaceGraphicsBuffer::QIOSurfaceGraphicsBuffer(const QSize &size, const QPixelFormat &format, QCFType<CGColorSpaceRef> colorSpace)
+QIOSurfaceGraphicsBuffer::QIOSurfaceGraphicsBuffer(const QSize &size, const QPixelFormat &format)
: QPlatformGraphicsBuffer(size, format)
{
const size_t width = size.width();
@@ -81,17 +81,26 @@ QIOSurfaceGraphicsBuffer::QIOSurfaceGraphicsBuffer(const QSize &size, const QPix
Q_ASSERT(size_t(bytesPerLine()) == bytesPerRow);
Q_ASSERT(size_t(byteCount()) == totalBytes);
-
- if (colorSpace) {
- IOSurfaceSetValue(m_surface, CFSTR("IOSurfaceColorSpace"),
- QCFType<CFPropertyListRef>(CGColorSpaceCopyPropertyList(colorSpace)));
- }
}
QIOSurfaceGraphicsBuffer::~QIOSurfaceGraphicsBuffer()
{
}
+void QIOSurfaceGraphicsBuffer::setColorSpace(QCFType<CGColorSpaceRef> colorSpace)
+{
+ static const auto kIOSurfaceColorSpace = CFSTR("IOSurfaceColorSpace");
+
+ qCDebug(lcQpaIOSurface) << "Tagging" << this << "with color space" << colorSpace;
+
+ if (colorSpace) {
+ IOSurfaceSetValue(m_surface, kIOSurfaceColorSpace,
+ QCFType<CFPropertyListRef>(CGColorSpaceCopyPropertyList(colorSpace)));
+ } else {
+ IOSurfaceRemoveValue(m_surface, kIOSurfaceColorSpace);
+ }
+}
+
const uchar *QIOSurfaceGraphicsBuffer::data() const
{
return (const uchar *)IOSurfaceGetBaseAddress(m_surface);
diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm
index 358a6b49fd..654647b35a 100644
--- a/src/plugins/platforms/cocoa/qmacclipboard.mm
+++ b/src/plugins/platforms/cocoa/qmacclipboard.mm
@@ -138,8 +138,12 @@ QMacPasteboard::QMacPasteboard(CFStringRef name, uchar mt)
QMacPasteboard::~QMacPasteboard()
{
- // commit all promises for paste after exit close
- resolvingBeforeDestruction = true;
+ /*
+ Commit all promises for paste when shutting down,
+ unless we are the stack-allocated clipboard used by QCocoaDrag.
+ */
+ if (mime_type == QMacInternalPasteboardMime::MIME_DND)
+ resolvingBeforeDestruction = true;
PasteboardResolvePromises(paste);
if (paste)
CFRelease(paste);
diff --git a/src/plugins/platforms/cocoa/qnsview_drawing.mm b/src/plugins/platforms/cocoa/qnsview_drawing.mm
index eb9286519d..2fd63fad67 100644
--- a/src/plugins/platforms/cocoa/qnsview_drawing.mm
+++ b/src/plugins/platforms/cocoa/qnsview_drawing.mm
@@ -44,17 +44,6 @@
- (void)initDrawing
{
[self updateLayerBacking];
-
- // Enable high-DPI OpenGL for retina displays. Enabling has the side
- // effect that Cocoa will start calling glViewport(0, 0, width, height),
- // overriding any glViewport calls in application code. This is usually not a
- // problem, except if the application wants to have a "custom" viewport.
- // (like the hellogl example)
- if (m_platformWindow->window()->supportsOpenGL()) {
- self.wantsBestResolutionOpenGLSurface = qt_mac_resolveOption(YES, m_platformWindow->window(),
- "_q_mac_wantsBestResolutionOpenGLSurface", "QT_MAC_WANTS_BEST_RESOLUTION_OPENGL_SURFACE");
- // See also QCocoaGLContext::makeCurrent for software renderer workarounds.
- }
}
- (BOOL)isOpaque
diff --git a/src/plugins/platforms/cocoa/qnsview_menus.mm b/src/plugins/platforms/cocoa/qnsview_menus.mm
index a55fd97eb7..b6cd832282 100644
--- a/src/plugins/platforms/cocoa/qnsview_menus.mm
+++ b/src/plugins/platforms/cocoa/qnsview_menus.mm
@@ -84,7 +84,8 @@ static bool selectorIsCutCopyPaste(SEL selector)
menuParent = menuObject->menuParent();
}
- if (menubar && menubar->cocoaWindow() != self.platformWindow)
+ // we have no menubar parent for the application menu items, e.g About and Preferences
+ if (!menubar || menubar->cocoaWindow() != self.platformWindow)
return NO;
}
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm
index 58ad53a6e1..dcb9a85a3c 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm
@@ -59,6 +59,8 @@ QMacPrintEngine::QMacPrintEngine(QPrinter::PrinterMode mode, const QString &devi
QString id = deviceId;
if (id.isEmpty())
id = QCocoaPrinterSupport().defaultPrintDeviceId();
+ else
+ setProperty(QPrintEngine::PPK_PrinterName, deviceId);
d->m_printDevice.reset(new QCocoaPrintDevice(id));
d->m_pageLayout.setPageSize(d->m_printDevice->defaultPageSize());
d->initialize();
diff --git a/src/plugins/platforms/directfb/.prev_CMakeLists.txt b/src/plugins/platforms/directfb/.prev_CMakeLists.txt
index 9c241c340c..33beaa3da4 100644
--- a/src/plugins/platforms/directfb/.prev_CMakeLists.txt
+++ b/src/plugins/platforms/directfb/.prev_CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from directfb.pro.
#####################################################################
-## qdirectfb Plugin:
+## QDirectFbIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qdirectfb
+qt_add_plugin(QDirectFbIntegrationPlugin
+ OUTPUT_NAME qdirectfb
TYPE platforms
- CLASS_NAME QDirectFbIntegrationPlugin
SOURCES
main.cpp
qdirectfbbackingstore.cpp qdirectfbbackingstore.h
@@ -18,40 +18,33 @@ add_qt_plugin(qdirectfb
qdirectfbintegration.cpp qdirectfbintegration.h
qdirectfbscreen.cpp qdirectfbscreen.h
qdirectfbwindow.cpp qdirectfbwindow.h
- LIBRARIES
+ PUBLIC_LIBRARIES
+ PkgConfig::DirectFB
+ Qt::Core
Qt::CorePrivate
Qt::EventDispatcherSupportPrivate
Qt::FontDatabaseSupportPrivate
+ Qt::Gui
Qt::GuiPrivate
Qt::ServiceSupportPrivate
- PUBLIC_LIBRARIES
- PkgConfig::DirectFB
- Qt::Core
- Qt::EventDispatcherSupport
- Qt::FontDatabaseSupport
- Qt::Gui
- Qt::ServiceSupport
)
#### Keys ignored in scope 1:.:.:directfb.pro:<TRUE>:
# OTHER_FILES = "directfb.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qdirectfb CONDITION QT_CONFIG___contains___directfb_egl
+qt_extend_target(QDirectFbIntegrationPlugin CONDITION QT_CONFIG___contains___directfb_egl
SOURCES
qdirectfb_egl.cpp qdirectfb_egl.h
DEFINES
DIRECTFB_GL_EGL
- LIBRARIES
- Qt::EglSupportPrivate
PUBLIC_LIBRARIES
- Qt::EglSupport
+ Qt::EglSupportPrivate
)
-extend_target(qdirectfb CONDITION NOT DIRECTFB_PLATFORM_HOOKS_SOURCES_ISEMPTY
+qt_extend_target(QDirectFbIntegrationPlugin CONDITION NOT DIRECTFB_PLATFORM_HOOKS_SOURCES_ISEMPTY
DEFINES
DIRECTFB_PLATFORM_HOOKS
)
@@ -59,7 +52,7 @@ extend_target(qdirectfb CONDITION NOT DIRECTFB_PLATFORM_HOOKS_SOURCES_ISEMPTY
#### Keys ignored in scope 3:.:.:directfb.pro:NOT DIRECTFB_PLATFORM_HOOKS_SOURCES_ISEMPTY:
# QMAKE_LIBDIR = "$$DIRECTFB_PLATFORM_HOOKS_LIBDIR"
-extend_target(qdirectfb CONDITION DIRECTFB_PLATFORM_HOOKS_SOURCES_ISEMPTY
+qt_extend_target(QDirectFbIntegrationPlugin CONDITION DIRECTFB_PLATFORM_HOOKS_SOURCES_ISEMPTY
SOURCES
qdirectfbeglhooks_stub.cpp
)
diff --git a/src/plugins/platforms/directfb/CMakeLists.txt b/src/plugins/platforms/directfb/CMakeLists.txt
index ca195d87d7..c723ca75f4 100644
--- a/src/plugins/platforms/directfb/CMakeLists.txt
+++ b/src/plugins/platforms/directfb/CMakeLists.txt
@@ -5,12 +5,12 @@ qt_find_package(DirectFB)
# end special case:
#####################################################################
-## qdirectfb Plugin:
+## QDirectFbIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qdirectfb
+qt_add_plugin(QDirectFbIntegrationPlugin
+ OUTPUT_NAME qdirectfb
TYPE platforms
- CLASS_NAME QDirectFbIntegrationPlugin
SOURCES
main.cpp
qdirectfbbackingstore.cpp qdirectfbbackingstore.h
@@ -22,40 +22,33 @@ add_qt_plugin(qdirectfb
qdirectfbintegration.cpp qdirectfbintegration.h
qdirectfbscreen.cpp qdirectfbscreen.h
qdirectfbwindow.cpp qdirectfbwindow.h
- LIBRARIES
+ PUBLIC_LIBRARIES
+ PkgConfig::DirectFB
+ Qt::Core
Qt::CorePrivate
Qt::EventDispatcherSupportPrivate
Qt::FontDatabaseSupportPrivate
+ Qt::Gui
Qt::GuiPrivate
Qt::ServiceSupportPrivate
- PUBLIC_LIBRARIES
- PkgConfig::DirectFB
- Qt::Core
- Qt::EventDispatcherSupport
- Qt::FontDatabaseSupport
- Qt::Gui
- Qt::ServiceSupport
)
#### Keys ignored in scope 1:.:.:directfb.pro:<TRUE>:
# OTHER_FILES = "directfb.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qdirectfb CONDITION QT_CONFIG___contains___directfb_egl
+qt_extend_target(QDirectFbIntegrationPlugin CONDITION QT_CONFIG___contains___directfb_egl
SOURCES
qdirectfb_egl.cpp qdirectfb_egl.h
DEFINES
DIRECTFB_GL_EGL
- LIBRARIES
- Qt::EglSupportPrivate
PUBLIC_LIBRARIES
- Qt::EglSupport
+ Qt::EglSupportPrivate
)
-extend_target(qdirectfb CONDITION NOT DIRECTFB_PLATFORM_HOOKS_SOURCES_ISEMPTY
+qt_extend_target(QDirectFbIntegrationPlugin CONDITION NOT DIRECTFB_PLATFORM_HOOKS_SOURCES_ISEMPTY
DEFINES
DIRECTFB_PLATFORM_HOOKS
)
@@ -63,7 +56,7 @@ extend_target(qdirectfb CONDITION NOT DIRECTFB_PLATFORM_HOOKS_SOURCES_ISEMPTY
#### Keys ignored in scope 3:.:.:directfb.pro:NOT DIRECTFB_PLATFORM_HOOKS_SOURCES_ISEMPTY:
# QMAKE_LIBDIR = "$$DIRECTFB_PLATFORM_HOOKS_LIBDIR"
-extend_target(qdirectfb CONDITION DIRECTFB_PLATFORM_HOOKS_SOURCES_ISEMPTY
+qt_extend_target(QDirectFbIntegrationPlugin CONDITION DIRECTFB_PLATFORM_HOOKS_SOURCES_ISEMPTY
SOURCES
qdirectfbeglhooks_stub.cpp
)
diff --git a/src/plugins/platforms/eglfs/.prev_CMakeLists.txt b/src/plugins/platforms/eglfs/.prev_CMakeLists.txt
index 79496058e3..4fed525392 100644
--- a/src/plugins/platforms/eglfs/.prev_CMakeLists.txt
+++ b/src/plugins/platforms/eglfs/.prev_CMakeLists.txt
@@ -4,7 +4,7 @@
## EglFSDeviceIntegration Module:
#####################################################################
-add_qt_module(EglFSDeviceIntegration
+qt_add_module(EglFSDeviceIntegration
INTERNAL_MODULE
SOURCES
api/qeglfsdeviceintegration.cpp api/qeglfsdeviceintegration_p.h
@@ -19,7 +19,7 @@ add_qt_module(EglFSDeviceIntegration
QT_EGL_NO_X11
INCLUDE_DIRECTORIES
api
- LIBRARIES
+ PUBLIC_LIBRARIES
Qt::CorePrivate
Qt::DeviceDiscoverySupportPrivate
Qt::EglSupportPrivate
@@ -29,94 +29,85 @@ add_qt_module(EglFSDeviceIntegration
Qt::GuiPrivate
Qt::ServiceSupportPrivate
Qt::ThemeSupportPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::DeviceDiscoverySupport
- Qt::EglSupport
- Qt::EventDispatcherSupport
- Qt::FbSupport
- Qt::FontDatabaseSupport
- Qt::Gui
- Qt::ServiceSupport
- Qt::ThemeSupport
)
#### Keys ignored in scope 2:.:.:eglfsdeviceintegration.pro:<TRUE>:
# MODULE = "eglfsdeviceintegration"
-# _LOADED = "qt_module"
## Scopes:
#####################################################################
-extend_target(EglFSDeviceIntegration CONDITION TARGET Qt::InputSupportPrivate
- LIBRARIES
- Qt::InputSupportPrivate
+qt_extend_target(EglFSDeviceIntegration CONDITION TARGET Qt::InputSupportPrivate
PUBLIC_LIBRARIES
- Qt::InputSupport
+ Qt::InputSupportPrivate
)
-extend_target(EglFSDeviceIntegration CONDITION TARGET Qt::PlatformCompositorSupportPrivate
- LIBRARIES
+qt_extend_target(EglFSDeviceIntegration CONDITION TARGET Qt::PlatformCompositorSupportPrivate
+ PUBLIC_LIBRARIES
Qt::PlatformCompositorSupportPrivate
+)
+
+qt_extend_target(EglFSDeviceIntegration CONDITION QT_FEATURE_vulkan
+ SOURCES
+ api/vulkan/qeglfsvulkaninstance.cpp api/vulkan/qeglfsvulkaninstance_p.h
+ api/vulkan/qeglfsvulkanwindow.cpp api/vulkan/qeglfsvulkanwindow_p.h
PUBLIC_LIBRARIES
- Qt::PlatformCompositorSupport
+ Qt::VulkanSupportPrivate
)
-extend_target(EglFSDeviceIntegration CONDITION NOT EGLFS_PLATFORM_HOOKS_SOURCES_ISEMPTY
+qt_extend_target(EglFSDeviceIntegration CONDITION NOT EGLFS_PLATFORM_HOOKS_SOURCES_ISEMPTY
DEFINES
EGLFS_PLATFORM_HOOKS
)
-extend_target(EglFSDeviceIntegration CONDITION NOT EGLFS_DEVICE_INTEGRATION_ISEMPTY
+qt_extend_target(EglFSDeviceIntegration CONDITION NOT EGLFS_DEVICE_INTEGRATION_ISEMPTY
DEFINES
EGLFS_PREFERRED_PLUGIN=
)
-# Resources:
-set(cursor_resource_files
- "cursor-atlas.png"
- "cursor.json"
-)
-
-add_qt_resource(EglFSDeviceIntegration "cursor"
- PREFIX
- "/"
- FILES
- ${cursor_resource_files}
-)
-
-
-extend_target(EglFSDeviceIntegration CONDITION QT_FEATURE_opengl
+if(QT_FEATURE_cursor)
+ # Resources:
+ set(cursor_resource_files
+ "cursor-atlas.png"
+ "cursor.json"
+ )
+
+ qt_add_resource(EglFSDeviceIntegration "cursor"
+ PREFIX
+ "/"
+ FILES
+ ${cursor_resource_files}
+ )
+endif()
+
+qt_extend_target(EglFSDeviceIntegration CONDITION QT_FEATURE_opengl
SOURCES
api/qeglfscontext.cpp api/qeglfscontext_p.h
api/qeglfscursor.cpp api/qeglfscursor_p.h
)
#####################################################################
-## qeglfs Plugin:
+## QEglFSIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qeglfs
+qt_add_plugin(QEglFSIntegrationPlugin
+ OUTPUT_NAME qeglfs
TYPE platforms
- CLASS_NAME QEglFSIntegrationPlugin
SOURCES
qeglfsmain.cpp
DEFINES
QT_EGL_NO_X11
INCLUDE_DIRECTORIES
api
- LIBRARIES
- Qt::EglFSDeviceIntegrationPrivate
PUBLIC_LIBRARIES
- Qt::EglFSDeviceIntegration
+ Qt::EglFSDeviceIntegrationPrivate
)
-#### Keys ignored in scope 11:.:.:eglfs-plugin.pro:<TRUE>:
+#### Keys ignored in scope 13:.:.:eglfs-plugin.pro:<TRUE>:
# OTHER_FILES = "$$PWD/eglfs.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-#### Keys ignored in scope 12:.:.:eglfs-plugin.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
+#### Keys ignored in scope 14:.:.:eglfs-plugin.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
# PLUGIN_EXTENDS = "-"
add_subdirectory(deviceintegration)
diff --git a/src/plugins/platforms/eglfs/CMakeLists.txt b/src/plugins/platforms/eglfs/CMakeLists.txt
index 26784ca291..03de79d6f0 100644
--- a/src/plugins/platforms/eglfs/CMakeLists.txt
+++ b/src/plugins/platforms/eglfs/CMakeLists.txt
@@ -5,7 +5,7 @@ qt_find_package(EGL) # special case
## EglFSDeviceIntegration Module:
#####################################################################
-add_qt_module(EglFSDeviceIntegration
+qt_add_module(EglFSDeviceIntegration
INTERNAL_MODULE
SOURCES
api/qeglfsdeviceintegration.cpp api/qeglfsdeviceintegration_p.h
@@ -20,7 +20,7 @@ add_qt_module(EglFSDeviceIntegration
QT_EGL_NO_X11
INCLUDE_DIRECTORIES
api
- LIBRARIES
+ PUBLIC_LIBRARIES
Qt::CorePrivate
Qt::DeviceDiscoverySupportPrivate
Qt::EglSupportPrivate
@@ -35,55 +35,59 @@ add_qt_module(EglFSDeviceIntegration
#### Keys ignored in scope 2:.:.:eglfsdeviceintegration.pro:<TRUE>:
# MODULE = "eglfsdeviceintegration"
-# _LOADED = "qt_module"
## Scopes:
#####################################################################
-extend_target(EglFSDeviceIntegration CONDITION TARGET Qt::InputSupportPrivate
- LIBRARIES
- Qt::InputSupportPrivate
+qt_extend_target(EglFSDeviceIntegration CONDITION TARGET Qt::InputSupportPrivate
PUBLIC_LIBRARIES
- Qt::InputSupport
+ Qt::InputSupportPrivate
)
-extend_target(EglFSDeviceIntegration CONDITION TARGET Qt::PlatformCompositorSupportPrivate
- LIBRARIES
+qt_extend_target(EglFSDeviceIntegration CONDITION TARGET Qt::PlatformCompositorSupportPrivate
+ PUBLIC_LIBRARIES
Qt::PlatformCompositorSupportPrivate
+)
+
+qt_extend_target(EglFSDeviceIntegration CONDITION QT_FEATURE_vulkan
+ SOURCES
+ api/vulkan/qeglfsvulkaninstance.cpp api/vulkan/qeglfsvulkaninstance_p.h
+ api/vulkan/qeglfsvulkanwindow.cpp api/vulkan/qeglfsvulkanwindow_p.h
PUBLIC_LIBRARIES
- Qt::PlatformCompositorSupport
+ Qt::VulkanSupportPrivate
)
# special case:
# extend_target(EglFSDeviceIntegration CONDITION NOT EGLFS_PLATFORM_HOOKS_SOURCES_ISEMPTY ...
# extend_target(EglFSDeviceIntegration CONDITION NOT EGLFS_DEVICE_INTEGRATION_ISEMPTY ...
-# Resources:
-set(cursor_resource_files
- "cursor-atlas.png"
- "cursor.json"
-)
+if(QT_FEATURE_cursor) # special case
+ # Resources:
+ set(cursor_resource_files
+ "cursor-atlas.png"
+ "cursor.json"
+ )
-add_qt_resource(EglFSDeviceIntegration "cursor"
- PREFIX
- "/"
- FILES
- ${cursor_resource_files}
-)
+ qt_add_resource(EglFSDeviceIntegration "cursor"
+ PREFIX
+ "/"
+ FILES
+ ${cursor_resource_files}
+ )
+endif()
-
-extend_target(EglFSDeviceIntegration CONDITION QT_FEATURE_opengl
+qt_extend_target(EglFSDeviceIntegration CONDITION QT_FEATURE_opengl
SOURCES
api/qeglfscontext.cpp api/qeglfscontext_p.h
api/qeglfscursor.cpp api/qeglfscursor_p.h
)
#####################################################################
-## qeglfs Plugin:
+## QEglFSIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qeglfs
+qt_add_plugin(QEglFSIntegrationPlugin
+ OUTPUT_NAME qeglfs
TYPE platforms
- CLASS_NAME QEglFSIntegrationPlugin
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES eglfs # special case
SOURCES
qeglfsmain.cpp
@@ -91,19 +95,18 @@ add_qt_plugin(qeglfs
QT_EGL_NO_X11
INCLUDE_DIRECTORIES
api
- LIBRARIES
+ PUBLIC_LIBRARIES
Qt::CorePrivate # special case
Qt::EglFSDeviceIntegrationPrivate
EGL::EGL # special case
)
-#### Keys ignored in scope 11:.:.:eglfs-plugin.pro:<TRUE>:
+#### Keys ignored in scope 13:.:.:eglfs-plugin.pro:<TRUE>:
# OTHER_FILES = "$$PWD/eglfs.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-#### Keys ignored in scope 12:.:.:eglfs-plugin.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
+#### Keys ignored in scope 14:.:.:eglfs-plugin.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
# PLUGIN_EXTENDS = "-"
add_subdirectory(deviceintegration)
diff --git a/src/plugins/platforms/eglfs/api/api.pri b/src/plugins/platforms/eglfs/api/api.pri
index a6d81016b6..68965b58d8 100644
--- a/src/plugins/platforms/eglfs/api/api.pri
+++ b/src/plugins/platforms/eglfs/api/api.pri
@@ -23,4 +23,13 @@ qtConfig(opengl) {
$$PWD/qeglfscontext_p.h
}
+qtConfig(vulkan) {
+ SOURCES += \
+ $$PWD/vulkan/qeglfsvulkaninstance.cpp \
+ $$PWD/vulkan/qeglfsvulkanwindow.cpp
+ HEADERS += \
+ $$PWD/vulkan/qeglfsvulkaninstance_p.h \
+ $$PWD/vulkan/qeglfsvulkanwindow_p.h
+}
+
INCLUDEPATH += $$PWD
diff --git a/src/plugins/platforms/eglfs/api/qeglfscontext.cpp b/src/plugins/platforms/eglfs/api/qeglfscontext.cpp
index c5cef34d8e..48fafbda8d 100644
--- a/src/plugins/platforms/eglfs/api/qeglfscontext.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfscontext.cpp
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
EGLConfig *config, const QVariant &nativeHandle)
: QEGLPlatformContext(format, share, display, config, nativeHandle,
- qt_egl_device_integration()->supportsSurfacelessContexts() ? Flags(0) : QEGLPlatformContext::NoSurfaceless),
+ qt_egl_device_integration()->supportsSurfacelessContexts() ? Flags() : QEGLPlatformContext::NoSurfaceless),
m_tempWindow(0)
{
}
@@ -78,7 +78,7 @@ EGLSurface QEglFSContext::createTemporaryOffscreenSurface()
}
}
EGLConfig config = q_configFromGLFormat(eglDisplay(), format());
- return eglCreateWindowSurface(eglDisplay(), config, m_tempWindow, 0);
+ return eglCreateWindowSurface(eglDisplay(), config, m_tempWindow, nullptr);
}
void QEglFSContext::destroyTemporaryOffscreenSurface(EGLSurface surface)
diff --git a/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
index 22319fcc66..98e05195ee 100644
--- a/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
@@ -62,7 +62,7 @@ QEglFSCursor::QEglFSCursor(QPlatformScreen *screen)
: m_visible(true),
m_screen(static_cast<QEglFSScreen *>(screen)),
m_activeScreen(nullptr),
- m_deviceListener(0),
+ m_deviceListener(nullptr),
m_updateRequested(false)
{
QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR");
diff --git a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
index 81bad45cd2..e3145aa0b0 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
@@ -52,6 +52,7 @@
#include <QScreen>
#include <QDir>
#if QT_CONFIG(regularexpression)
+# include <QFileInfo>
# include <QRegularExpression>
#endif
#include <QLoggingCategory>
@@ -144,7 +145,12 @@ int QEglFSDeviceIntegration::framebufferIndex() const
int fbIndex = 0;
#if QT_CONFIG(regularexpression)
QRegularExpression fbIndexRx(QLatin1String("fb(\\d+)"));
- QRegularExpressionMatch match = fbIndexRx.match(QString::fromLocal8Bit(fbDeviceName()));
+ QFileInfo fbinfo(QString::fromLocal8Bit(fbDeviceName()));
+ QRegularExpressionMatch match;
+ if (fbinfo.isSymLink())
+ match = fbIndexRx.match(fbinfo.symLinkTarget());
+ else
+ match = fbIndexRx.match(fbinfo.fileName());
if (match.hasMatch())
fbIndex = match.captured(1).toInt();
#endif
@@ -375,6 +381,14 @@ void *QEglFSDeviceIntegration::wlDisplay() const
return nullptr;
}
+#if QT_CONFIG(vulkan)
+QPlatformVulkanInstance *QEglFSDeviceIntegration::createPlatformVulkanInstance(QVulkanInstance *instance)
+{
+ Q_UNUSED(instance);
+ return nullptr;
+}
+#endif
+
EGLConfig QEglFSDeviceIntegration::chooseConfig(EGLDisplay display, const QSurfaceFormat &format)
{
class Chooser : public QEglConfigChooser {
diff --git a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration_p.h b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration_p.h
index 71ffb4c69a..08447a40ea 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration_p.h
+++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration_p.h
@@ -108,6 +108,10 @@ public:
virtual void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen);
virtual void *wlDisplay() const;
+#if QT_CONFIG(vulkan)
+ virtual QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance);
+#endif
+
static EGLConfig chooseConfig(EGLDisplay display, const QSurfaceFormat &format);
};
diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
index 674f579b4f..e26d984cc1 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
@@ -109,10 +109,10 @@ QT_BEGIN_NAMESPACE
QEglFSIntegration::QEglFSIntegration()
: m_display(EGL_NO_DISPLAY),
- m_inputContext(0),
+ m_inputContext(nullptr),
m_fontDb(new QGenericUnixFontDatabase),
m_services(new QGenericUnixServices),
- m_kbdMgr(0),
+ m_kbdMgr(nullptr),
m_disableInputHandlers(false)
{
m_disableInputHandlers = qEnvironmentVariableIntValue("QT_QPA_EGLFS_DISABLE_INPUT");
@@ -223,7 +223,7 @@ QPlatformOpenGLContext *QEglFSIntegration::createPlatformOpenGLContext(QOpenGLCo
EGLConfig config = QEglFSDeviceIntegration::chooseConfig(dpy, adjustedFormat);
ctx = new QEglFSContext(adjustedFormat, share, dpy, &config, QVariant());
} else {
- ctx = new QEglFSContext(adjustedFormat, share, dpy, 0, nativeHandle);
+ ctx = new QEglFSContext(adjustedFormat, share, dpy, nullptr, nativeHandle);
}
nativeHandle = QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(ctx->eglContext(), dpy));
@@ -236,7 +236,7 @@ QPlatformOffscreenSurface *QEglFSIntegration::createPlatformOffscreenSurface(QOf
EGLDisplay dpy = surface->screen() ? static_cast<QEglFSScreen *>(surface->screen()->handle())->display() : display();
QSurfaceFormat fmt = qt_egl_device_integration()->surfaceFormatFor(surface->requestedFormat());
if (qt_egl_device_integration()->supportsPBuffers()) {
- QEGLPlatformContext::Flags flags = 0;
+ QEGLPlatformContext::Flags flags;
if (!qt_egl_device_integration()->supportsSurfacelessContexts())
flags |= QEGLPlatformContext::NoSurfaceless;
return new QEGLPbuffer(dpy, fmt, surface, flags);
@@ -247,6 +247,13 @@ QPlatformOffscreenSurface *QEglFSIntegration::createPlatformOffscreenSurface(QOf
}
#endif // QT_NO_OPENGL
+#if QT_CONFIG(vulkan)
+QPlatformVulkanInstance *QEglFSIntegration::createPlatformVulkanInstance(QVulkanInstance *instance) const
+{
+ return qt_egl_device_integration()->createPlatformVulkanInstance(instance);
+}
+#endif
+
bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{
// We assume that devices will have more and not less capabilities
@@ -283,7 +290,8 @@ enum ResourceType {
NativeDisplay,
XlibDisplay,
WaylandDisplay,
- EglSurface
+ EglSurface,
+ VkSurface
};
static int resourceType(const QByteArray &key)
@@ -296,7 +304,8 @@ static int resourceType(const QByteArray &key)
QByteArrayLiteral("nativedisplay"),
QByteArrayLiteral("display"),
QByteArrayLiteral("server_wl_display"),
- QByteArrayLiteral("eglsurface")
+ QByteArrayLiteral("eglsurface"),
+ QByteArrayLiteral("vksurface")
};
const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
const QByteArray *result = std::find(names, end, key);
@@ -307,7 +316,7 @@ static int resourceType(const QByteArray &key)
void *QEglFSIntegration::nativeResourceForIntegration(const QByteArray &resource)
{
- void *result = 0;
+ void *result = nullptr;
switch (resourceType(resource)) {
case EglDisplay:
@@ -329,7 +338,7 @@ void *QEglFSIntegration::nativeResourceForIntegration(const QByteArray &resource
void *QEglFSIntegration::nativeResourceForScreen(const QByteArray &resource, QScreen *screen)
{
- void *result = 0;
+ void *result = nullptr;
switch (resourceType(resource)) {
case XlibDisplay:
@@ -347,7 +356,7 @@ void *QEglFSIntegration::nativeResourceForScreen(const QByteArray &resource, QSc
void *QEglFSIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
{
- void *result = 0;
+ void *result = nullptr;
switch (resourceType(resource)) {
case EglDisplay:
@@ -364,6 +373,12 @@ void *QEglFSIntegration::nativeResourceForWindow(const QByteArray &resource, QWi
if (window && window->handle())
result = reinterpret_cast<void*>(static_cast<QEglFSWindow *>(window->handle())->surface());
break;
+#if QT_CONFIG(vulkan)
+ case VkSurface:
+ if (window && window->handle() && window->surfaceType() == QSurface::VulkanSurface)
+ result = static_cast<QEglFSWindow *>(window->handle())->vulkanSurfacePtr();
+ break;
+#endif
default:
break;
}
@@ -374,7 +389,7 @@ void *QEglFSIntegration::nativeResourceForWindow(const QByteArray &resource, QWi
#ifndef QT_NO_OPENGL
void *QEglFSIntegration::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context)
{
- void *result = 0;
+ void *result = nullptr;
switch (resourceType(resource)) {
case EglContext:
@@ -402,7 +417,7 @@ static void *eglContextForContext(QOpenGLContext *context)
QEglFSContext *handle = static_cast<QEglFSContext *>(context->handle());
if (!handle)
- return 0;
+ return nullptr;
return handle->eglContext();
}
@@ -416,7 +431,7 @@ QPlatformNativeInterface::NativeResourceForContextFunction QEglFSIntegration::na
#else
Q_UNUSED(resource);
#endif
- return 0;
+ return nullptr;
}
QFunctionPointer QEglFSIntegration::platformFunction(const QByteArray &function) const
diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h b/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h
index 898b322834..b293651ce7 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h
+++ b/src/plugins/platforms/eglfs/api/qeglfsintegration_p.h
@@ -86,6 +86,9 @@ public:
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override;
QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override;
#endif
+#if QT_CONFIG(vulkan)
+ QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const override;
+#endif
bool hasCapability(QPlatformIntegration::Capability cap) const override;
QPlatformNativeInterface *nativeInterface() const override;
diff --git a/src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow.cpp b/src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow.cpp
index 864271cd3a..c96e329816 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow.cpp
@@ -67,7 +67,7 @@ QEglFSOffscreenWindow::QEglFSOffscreenWindow(EGLDisplay display, const QSurfaceF
return;
}
EGLConfig config = q_configFromGLFormat(m_display, m_format);
- m_surface = eglCreateWindowSurface(m_display, config, m_window, 0);
+ m_surface = eglCreateWindowSurface(m_display, config, m_window, nullptr);
if (m_surface != EGL_NO_SURFACE)
m_format = q_glFormatFromConfig(m_display, config);
}
diff --git a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
index 11b68c0589..8a8e8cd563 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
@@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE
QEglFSScreen::QEglFSScreen(EGLDisplay dpy)
: m_dpy(dpy),
m_surface(EGL_NO_SURFACE),
- m_cursor(0)
+ m_cursor(nullptr)
{
m_cursor = qt_egl_device_integration()->createCursor(this);
}
@@ -164,7 +164,7 @@ void QEglFSScreen::handleCursorMove(const QPoint &pos)
return;
}
- QWindow *enter = 0, *leave = 0;
+ QWindow *enter = nullptr, *leave = nullptr;
for (int i = windows.count() - 1; i >= 0; --i) {
QWindow *window = windows[i]->sourceWindow();
const QRect geom = window->geometry();
diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
index 1fed182882..f7e116eb88 100644
--- a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
@@ -61,13 +61,12 @@ QT_BEGIN_NAMESPACE
QEglFSWindow::QEglFSWindow(QWindow *w)
: QPlatformWindow(w),
#ifndef QT_NO_OPENGL
- m_backingStore(0),
- m_rasterCompositingContext(0),
+ m_backingStore(nullptr),
+ m_rasterCompositingContext(nullptr),
#endif
m_winId(0),
m_surface(EGL_NO_SURFACE),
- m_window(0),
- m_flags(0)
+ m_window(0)
{
}
@@ -186,7 +185,7 @@ void QEglFSWindow::destroy()
#endif
}
- m_flags = 0;
+ m_flags = { };
}
void QEglFSWindow::invalidateSurface()
@@ -208,7 +207,7 @@ void QEglFSWindow::resetSurface()
m_format = q_glFormatFromConfig(display, m_config, platformFormat);
const QSize surfaceSize = screen()->rawGeometry().size();
m_window = qt_egl_device_integration()->createNativeWindow(this, surfaceSize, m_format);
- m_surface = eglCreateWindowSurface(display, m_config, m_window, NULL);
+ m_surface = eglCreateWindowSurface(display, m_config, m_window, nullptr);
}
void QEglFSWindow::setVisible(bool visible)
@@ -338,7 +337,7 @@ const QPlatformTextureList *QEglFSWindow::textures() const
if (m_backingStore)
return m_backingStore->textures();
- return 0;
+ return nullptr;
}
void QEglFSWindow::endCompositing()
diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow_p.h b/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
index be2a0630d3..7bf74c25ee 100644
--- a/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
+++ b/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
@@ -64,6 +64,7 @@ QT_BEGIN_NAMESPACE
class QOpenGLCompositorBackingStore;
class QPlatformTextureList;
+
#ifndef QT_NO_OPENGL
class Q_EGLFS_EXPORT QEglFSWindow : public QPlatformWindow, public QOpenGLCompositorWindow
#else
@@ -96,6 +97,9 @@ public:
EGLNativeWindowType eglWindow() const;
EGLSurface surface() const;
QEglFSScreen *screen() const override;
+#if QT_CONFIG(vulkan)
+ virtual void *vulkanSurfacePtr() { return nullptr; }
+#endif
bool hasNativeWindow() const { return m_flags.testFlag(HasNativeWindow); }
diff --git a/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance.cpp b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance.cpp
new file mode 100644
index 0000000000..a75251ca5f
--- /dev/null
+++ b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance.cpp
@@ -0,0 +1,280 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfsvulkaninstance_p.h"
+#include "qeglfswindow_p.h"
+#include "qeglfshooks_p.h"
+#include <QLoggingCategory>
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(qLcEglDevDebug)
+
+QEglFSVulkanInstance::QEglFSVulkanInstance(QVulkanInstance *instance)
+ : m_instance(instance)
+{
+ loadVulkanLibrary(QStringLiteral("vulkan"));
+}
+
+void QEglFSVulkanInstance::createOrAdoptInstance()
+{
+ qCDebug(qLcEglDevDebug, "Creating Vulkan instance for VK_KHR_display");
+
+ const QByteArray extName = QByteArrayLiteral("VK_KHR_display");
+ initInstance(m_instance, { extName });
+ if (!m_vkInst)
+ return;
+ if (!enabledExtensions().contains(extName)) {
+ qWarning("Failed to enable VK_KHR_display extension");
+ return;
+ }
+
+#if VK_KHR_display
+ m_getPhysicalDeviceDisplayPropertiesKHR = (PFN_vkGetPhysicalDeviceDisplayPropertiesKHR)
+ m_vkGetInstanceProcAddr(m_vkInst, "vkGetPhysicalDeviceDisplayPropertiesKHR");
+ m_getDisplayModePropertiesKHR = (PFN_vkGetDisplayModePropertiesKHR)
+ m_vkGetInstanceProcAddr(m_vkInst, "vkGetDisplayModePropertiesKHR");
+ m_getPhysicalDeviceDisplayPlanePropertiesKHR = (PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR)
+ m_vkGetInstanceProcAddr(m_vkInst, "vkGetPhysicalDeviceDisplayPlanePropertiesKHR");
+
+ m_getDisplayPlaneSupportedDisplaysKHR = (PFN_vkGetDisplayPlaneSupportedDisplaysKHR)
+ m_vkGetInstanceProcAddr(m_vkInst, "vkGetDisplayPlaneSupportedDisplaysKHR");
+ m_getDisplayPlaneCapabilitiesKHR = (PFN_vkGetDisplayPlaneCapabilitiesKHR)
+ m_vkGetInstanceProcAddr(m_vkInst, "vkGetDisplayPlaneCapabilitiesKHR");
+
+ m_createDisplayPlaneSurfaceKHR = (PFN_vkCreateDisplayPlaneSurfaceKHR)
+ m_vkGetInstanceProcAddr(m_vkInst, "vkCreateDisplayPlaneSurfaceKHR");
+#endif
+
+ m_enumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices)
+ m_vkGetInstanceProcAddr(m_vkInst, "vkEnumeratePhysicalDevices");
+
+ // Use for first physical device, unless overridden by QT_VK_PHYSICAL_DEVICE_INDEX.
+ // This behavior matches what the Vulkan backend of QRhi would do.
+
+ uint32_t physDevCount = 0;
+ m_enumeratePhysicalDevices(m_vkInst, &physDevCount, nullptr);
+ if (!physDevCount) {
+ qWarning("No physical devices");
+ return;
+ }
+ QVarLengthArray<VkPhysicalDevice, 4> physDevs(physDevCount);
+ VkResult err = m_enumeratePhysicalDevices(m_vkInst, &physDevCount, physDevs.data());
+ if (err != VK_SUCCESS || !physDevCount) {
+ qWarning("Failed to enumerate physical devices: %d", err);
+ return;
+ }
+
+ if (qEnvironmentVariableIsSet("QT_VK_PHYSICAL_DEVICE_INDEX")) {
+ int requestedPhysDevIndex = qEnvironmentVariableIntValue("QT_VK_PHYSICAL_DEVICE_INDEX");
+ if (requestedPhysDevIndex >= 0 && uint32_t(requestedPhysDevIndex) < physDevCount)
+ m_physDev = physDevs[requestedPhysDevIndex];
+ }
+
+ if (m_physDev == VK_NULL_HANDLE)
+ m_physDev = physDevs[0];
+}
+
+bool QEglFSVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevice,
+ uint32_t queueFamilyIndex,
+ QWindow *window)
+{
+ Q_UNUSED(physicalDevice);
+ Q_UNUSED(queueFamilyIndex);
+ Q_UNUSED(window);
+ return true;
+}
+
+VkSurfaceKHR QEglFSVulkanInstance::createSurface(QEglFSWindow *window)
+{
+#if VK_KHR_display
+ qCDebug(qLcEglDevDebug, "Creating VkSurfaceKHR via VK_KHR_display for window %p", (void *) window);
+
+ if (!m_physDev) {
+ qWarning("No physical device, cannot create surface");
+ return VK_NULL_HANDLE;
+ }
+
+ uint32_t displayCount = 0;
+ VkResult err = m_getPhysicalDeviceDisplayPropertiesKHR(m_physDev, &displayCount, nullptr);
+ if (err != VK_SUCCESS) {
+ qWarning("Failed to get display properties: %d", err);
+ return VK_NULL_HANDLE;
+ }
+
+ qCDebug(qLcEglDevDebug, "Display count: %u", displayCount);
+
+ QVarLengthArray<VkDisplayPropertiesKHR, 4> displayProps(displayCount);
+ m_getPhysicalDeviceDisplayPropertiesKHR(m_physDev, &displayCount, displayProps.data());
+
+ VkDisplayKHR display = VK_NULL_HANDLE;
+ VkDisplayModeKHR displayMode = VK_NULL_HANDLE;
+ uint32_t width = 0;
+ uint32_t height = 0;
+
+ for (uint32_t i = 0; i < displayCount; ++i) {
+ const VkDisplayPropertiesKHR &disp(displayProps[i]);
+ qCDebug(qLcEglDevDebug, "Display #%u:\n display: %p\n name: %s\n dimensions: %ux%u\n resolution: %ux%u",
+ i, (void *) disp.display, disp.displayName,
+ disp.physicalDimensions.width, disp.physicalDimensions.height,
+ disp.physicalResolution.width, disp.physicalResolution.height);
+
+ // Just pick the first display and the first mode.
+ if (i == 0)
+ display = disp.display;
+
+ uint32_t modeCount = 0;
+ if (m_getDisplayModePropertiesKHR(m_physDev, disp.display, &modeCount, nullptr) != VK_SUCCESS) {
+ qWarning("Failed to get modes for display");
+ continue;
+ }
+ QVarLengthArray<VkDisplayModePropertiesKHR, 16> modeProps(modeCount);
+ m_getDisplayModePropertiesKHR(m_physDev, disp.display, &modeCount, modeProps.data());
+ for (uint32_t j = 0; j < modeCount; ++j) {
+ const VkDisplayModePropertiesKHR &mode(modeProps[j]);
+ qCDebug(qLcEglDevDebug, " Mode #%u:\n mode: %p\n visibleRegion: %ux%u\n refreshRate: %u",
+ j, (void *) mode.displayMode,
+ mode.parameters.visibleRegion.width, mode.parameters.visibleRegion.height,
+ mode.parameters.refreshRate);
+ if (j == 0) {
+ displayMode = mode.displayMode;
+ width = mode.parameters.visibleRegion.width;
+ height = mode.parameters.visibleRegion.height;
+ }
+ }
+ }
+
+ if (display == VK_NULL_HANDLE || displayMode == VK_NULL_HANDLE) {
+ qWarning("Failed to choose display and mode");
+ return VK_NULL_HANDLE;
+ }
+ uint32_t planeCount = 0;
+ err = m_getPhysicalDeviceDisplayPlanePropertiesKHR(m_physDev, &planeCount, nullptr);
+ if (err != VK_SUCCESS) {
+ qWarning("Failed to get plane properties: %d", err);
+ return VK_NULL_HANDLE;
+ }
+
+ qCDebug(qLcEglDevDebug, "Plane count: %u", planeCount);
+
+ QVarLengthArray<VkDisplayPlanePropertiesKHR, 4> planeProps(planeCount);
+ m_getPhysicalDeviceDisplayPlanePropertiesKHR(m_physDev, &planeCount, planeProps.data());
+
+ uint32_t planeIndex = UINT_MAX;
+ for (uint32_t i = 0; i < planeCount; ++i) {
+ uint32_t supportedDisplayCount = 0;
+ err = m_getDisplayPlaneSupportedDisplaysKHR(m_physDev, i, &supportedDisplayCount, nullptr);
+ if (err != VK_SUCCESS) {
+ qWarning("Failed to query supported displays for plane: %d", err);
+ return VK_NULL_HANDLE;
+ }
+
+ QVarLengthArray<VkDisplayKHR, 4> supportedDisplays(supportedDisplayCount);
+ m_getDisplayPlaneSupportedDisplaysKHR(m_physDev, i, &supportedDisplayCount, supportedDisplays.data());
+ qCDebug(qLcEglDevDebug, "Plane #%u supports %u displays, currently bound to display %p",
+ i, supportedDisplayCount, (void *) planeProps[i].currentDisplay);
+
+ VkDisplayPlaneCapabilitiesKHR caps;
+ err = m_getDisplayPlaneCapabilitiesKHR(m_physDev, displayMode, i, &caps);
+ if (err != VK_SUCCESS) {
+ qWarning("Failed to query plane capabilities: %d", err);
+ return VK_NULL_HANDLE;
+ }
+
+ qCDebug(qLcEglDevDebug, " supportedAlpha: %d (1=no, 2=global, 4=per pixel, 8=per pixel premul)\n"
+ " minSrc=%d, %d %ux%u\n"
+ " maxSrc=%d, %d %ux%u\n"
+ " minDst=%d, %d %ux%u\n"
+ " maxDst=%d, %d %ux%u",
+ int(caps.supportedAlpha),
+ caps.minSrcPosition.x, caps.minSrcPosition.y, caps.minSrcExtent.width, caps.minSrcExtent.height,
+ caps.maxSrcPosition.x, caps.maxSrcPosition.y, caps.maxSrcExtent.width, caps.maxSrcExtent.height,
+ caps.minDstPosition.x, caps.minDstPosition.y, caps.minDstExtent.width, caps.minDstExtent.height,
+ caps.maxDstPosition.x, caps.maxDstPosition.y, caps.maxDstExtent.width, caps.maxDstExtent.height);
+
+ // if the plane is not in use and supports our chosen display, use that plane
+ if (supportedDisplays.contains(display)
+ && (planeProps[i].currentDisplay == VK_NULL_HANDLE || planeProps[i].currentDisplay == display))
+ {
+ planeIndex = i;
+ }
+ }
+
+ if (planeIndex == UINT_MAX) {
+ qWarning("Failed to find a suitable plane");
+ return VK_NULL_HANDLE;
+ }
+
+ qCDebug(qLcEglDevDebug, "Using plane #%u", planeIndex);
+
+ VkDisplaySurfaceCreateInfoKHR surfaceCreateInfo = {};
+ surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR;
+ surfaceCreateInfo.displayMode = displayMode;
+ surfaceCreateInfo.planeIndex = planeIndex;
+ surfaceCreateInfo.planeStackIndex = planeProps[planeIndex].currentStackIndex;
+ surfaceCreateInfo.transform = VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR;
+ surfaceCreateInfo.globalAlpha = 1.0f;
+ surfaceCreateInfo.alphaMode = VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR;
+ surfaceCreateInfo.imageExtent = { width, height };
+
+ VkSurfaceKHR surface = VK_NULL_HANDLE;
+ err = m_createDisplayPlaneSurfaceKHR(m_vkInst, &surfaceCreateInfo, nullptr, &surface);
+ if (err != VK_SUCCESS || surface == VK_NULL_HANDLE) {
+ qWarning("Failed to create surface: %d", err);
+ return VK_NULL_HANDLE;
+ }
+
+ qCDebug(qLcEglDevDebug, "Created surface %p", (void *) surface);
+
+ return surface;
+
+#else
+ Q_UNUSED(window);
+ qWarning("VK_KHR_display support was not compiled in, cannot create surface");
+ return VK_NULL_HANDLE;
+#endif
+}
+
+void QEglFSVulkanInstance::presentAboutToBeQueued(QWindow *window)
+{
+ // support QT_QPA_EGLFS_FORCEVSYNC (i.MX8 with eglfs_viv)
+ qt_egl_device_integration()->waitForVSync(window->handle());
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance_p.h b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance_p.h
new file mode 100644
index 0000000000..9d6d47f439
--- /dev/null
+++ b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkaninstance_p.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLFSVULKANINSTANCE_H
+#define QEGLFSVULKANINSTANCE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qeglfsglobal_p.h"
+#include <QtVulkanSupport/private/qbasicvulkanplatforminstance_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QEglFSWindow;
+
+class Q_EGLFS_EXPORT QEglFSVulkanInstance : public QBasicPlatformVulkanInstance
+{
+public:
+ QEglFSVulkanInstance(QVulkanInstance *instance);
+
+ void createOrAdoptInstance() override;
+ bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) override;
+ void presentAboutToBeQueued(QWindow *window) override;
+
+ VkSurfaceKHR createSurface(QEglFSWindow *window);
+
+private:
+ QVulkanInstance *m_instance;
+ VkPhysicalDevice m_physDev = VK_NULL_HANDLE;
+ PFN_vkEnumeratePhysicalDevices m_enumeratePhysicalDevices = nullptr;
+#if VK_KHR_display
+ PFN_vkGetPhysicalDeviceDisplayPropertiesKHR m_getPhysicalDeviceDisplayPropertiesKHR = nullptr;
+ PFN_vkGetDisplayModePropertiesKHR m_getDisplayModePropertiesKHR = nullptr;
+ PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR m_getPhysicalDeviceDisplayPlanePropertiesKHR = nullptr;
+ PFN_vkGetDisplayPlaneSupportedDisplaysKHR m_getDisplayPlaneSupportedDisplaysKHR = nullptr;
+ PFN_vkGetDisplayPlaneCapabilitiesKHR m_getDisplayPlaneCapabilitiesKHR = nullptr;
+ PFN_vkCreateDisplayPlaneSurfaceKHR m_createDisplayPlaneSurfaceKHR = nullptr;
+#endif
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkanwindow.cpp b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkanwindow.cpp
new file mode 100644
index 0000000000..ae41ca00b6
--- /dev/null
+++ b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkanwindow.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfsvulkanwindow_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QEglFSVulkanWindow::QEglFSVulkanWindow(QWindow *window)
+ : QEglFSWindow(window),
+ m_surface(VK_NULL_HANDLE)
+{
+}
+
+QEglFSVulkanWindow::~QEglFSVulkanWindow()
+{
+ if (m_surface) {
+ QVulkanInstance *inst = window()->vulkanInstance();
+ if (inst)
+ static_cast<QEglFSVulkanInstance *>(inst->handle())->destroySurface(m_surface);
+ }
+}
+
+void *QEglFSVulkanWindow::vulkanSurfacePtr()
+{
+ if (m_surface)
+ return &m_surface;
+
+ QVulkanInstance *inst = window()->vulkanInstance();
+ if (!inst) {
+ qWarning("Attempted to create Vulkan surface without an instance; was QWindow::setVulkanInstance() called?");
+ return nullptr;
+ }
+ QEglFSVulkanInstance *eglfsInst = static_cast<QEglFSVulkanInstance *>(inst->handle());
+ m_surface = eglfsInst->createSurface(this);
+
+ return &m_surface;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.h b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkanwindow_p.h
index cf5688bbed..492fb41ca4 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemsettings.h
+++ b/src/plugins/platforms/eglfs/api/vulkan/qeglfsvulkanwindow_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
@@ -37,17 +37,37 @@
**
****************************************************************************/
-#ifndef QCOCOASYSTEMSETTINGS_H
-#define QCOCOASYSTEMSETTINGS_H
+#ifndef QEGLFSVULKANWINDOW_H
+#define QEGLFSVULKANWINDOW_H
-#include <QtCore/qhash.h>
-#include <QtGui/qpalette.h>
-#include <qpa/qplatformtheme.h>
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qeglfsglobal_p.h"
+#include "qeglfswindow_p.h"
+#include "qeglfsvulkaninstance_p.h"
QT_BEGIN_NAMESPACE
-QPalette * qt_mac_createSystemPalette();
-QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes();
+class Q_EGLFS_EXPORT QEglFSVulkanWindow : public QEglFSWindow
+{
+public:
+ QEglFSVulkanWindow(QWindow *window);
+ ~QEglFSVulkanWindow();
+
+ void *vulkanSurfacePtr() override;
+
+private:
+ VkSurfaceKHR m_surface;
+};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_emu/CMakeLists.txt b/src/plugins/platforms/eglfs/deviceintegration/eglfs_emu/CMakeLists.txt
index 3ebe169d33..a62b8bbb2b 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_emu/CMakeLists.txt
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_emu/CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from eglfs_emu.pro.
#####################################################################
-## qeglfs-emu-integration Plugin:
+## QEglFSEmulatorIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qeglfs-emu-integration
+qt_add_plugin(QEglFSEmulatorIntegrationPlugin
+ OUTPUT_NAME qeglfs-emu-integration
TYPE egldeviceintegrations
- CLASS_NAME QEglFSEmulatorIntegrationPlugin
SOURCES
qeglfsemulatorintegration.cpp qeglfsemulatorintegration.h
qeglfsemulatorscreen.cpp qeglfsemulatorscreen.h
@@ -15,17 +15,14 @@ add_qt_plugin(qeglfs-emu-integration
QT_EGL_NO_X11
INCLUDE_DIRECTORIES
../../api
- LIBRARIES
- Qt::CorePrivate
- Qt::EglFSDeviceIntegrationPrivate
- Qt::GuiPrivate
PUBLIC_LIBRARIES
Qt::Core
- Qt::EglFSDeviceIntegration
+ Qt::CorePrivate
+ Qt::EglFSDeviceIntegrationPrivate
Qt::Gui
+ Qt::GuiPrivate
)
#### Keys ignored in scope 1:.:.:eglfs_emu.pro:<TRUE>:
# DISTFILES = "eglfs_emu.json"
# OTHER_FILES = "$$PWD/eglfs_emu.json"
-# _LOADED = "qt_plugin"
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/CMakeLists.txt b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/CMakeLists.txt
index 57e0f1d248..55a1d71c07 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/CMakeLists.txt
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from eglfs_kms.pro.
#####################################################################
-## qeglfs-kms-integration Plugin:
+## QEglFSKmsGbmIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qeglfs-kms-integration
+qt_add_plugin(QEglFSKmsGbmIntegrationPlugin
+ OUTPUT_NAME qeglfs-kms-integration
TYPE egldeviceintegrations
- CLASS_NAME QEglFSKmsGbmIntegrationPlugin
SOURCES
qeglfskmsgbmcursor.cpp qeglfskmsgbmcursor.h
qeglfskmsgbmdevice.cpp qeglfskmsgbmdevice.h
@@ -19,24 +19,18 @@ add_qt_plugin(qeglfs-kms-integration
INCLUDE_DIRECTORIES
../../api
../eglfs_kms_support
- LIBRARIES
+ PUBLIC_LIBRARIES
+ Libdrm::Libdrm
+ Qt::Core
Qt::CorePrivate
Qt::EdidSupportPrivate
Qt::EglFSDeviceIntegrationPrivate
Qt::EglFsKmsSupportPrivate
+ Qt::Gui
Qt::GuiPrivate
Qt::KmsSupportPrivate
- PUBLIC_LIBRARIES
- Libdrm::Libdrm
- Qt::Core
- Qt::EdidSupport
- Qt::EglFSDeviceIntegration
- Qt::EglFsKmsSupport
- Qt::Gui
- Qt::KmsSupport
gbm::gbm
)
#### Keys ignored in scope 1:.:.:eglfs_kms.pro:<TRUE>:
# OTHER_FILES = "$$PWD/eglfs_kms.json"
-# _LOADED = "qt_plugin"
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp
index 4d0cf0c47e..dc98cdce4b 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp
@@ -69,7 +69,7 @@ QEglFSKmsGbmCursor::QEglFSKmsGbmCursor(QEglFSKmsGbmScreen *screen)
: m_screen(screen)
, m_cursorSize(64, 64) // 64x64 is the old standard size, we now try to query the real size below
, m_bo(nullptr)
- , m_cursorImage(0, 0, 0, 0, 0, 0)
+ , m_cursorImage(nullptr, nullptr, 0, 0, 0, 0)
, m_state(CursorPendingVisible)
, m_deviceListener(nullptr)
{
@@ -102,7 +102,7 @@ QEglFSKmsGbmCursor::QEglFSKmsGbmCursor(QEglFSKmsGbmScreen *screen)
#ifndef QT_NO_CURSOR
QCursor cursor(Qt::ArrowCursor);
- changeCursor(&cursor, 0);
+ changeCursor(&cursor, nullptr);
#endif
setPos(QPoint(0, 0));
}
@@ -214,7 +214,8 @@ void QEglFSKmsGbmCursor::changeCursor(QCursor *windowCursor, QWindow *window)
Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) {
QEglFSKmsScreen *kmsScreen = static_cast<QEglFSKmsScreen *>(screen);
-
+ if (kmsScreen->isCursorOutOfRange())
+ continue;
int status = drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, handle,
m_cursorSize.width(), m_cursorSize.height());
if (status != 0)
@@ -232,17 +233,36 @@ void QEglFSKmsGbmCursor::setPos(const QPoint &pos)
{
Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) {
QEglFSKmsScreen *kmsScreen = static_cast<QEglFSKmsScreen *>(screen);
- QPoint origin = kmsScreen->geometry().topLeft();
- QPoint localPos = pos - origin;
- QPoint adjustedPos = localPos - m_cursorImage.hotspot();
-
- int ret = drmModeMoveCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, adjustedPos.x(), adjustedPos.y());
- if (ret == 0)
- m_pos = pos;
- else
- qWarning("Failed to move cursor on screen %s: %d", kmsScreen->name().toLatin1().constData(), ret);
-
- kmsScreen->handleCursorMove(pos);
+ const QRect screenGeom = kmsScreen->geometry();
+ const QPoint origin = screenGeom.topLeft();
+ const QPoint localPos = pos - origin;
+ const QPoint adjustedLocalPos = localPos - m_cursorImage.hotspot();
+
+ if (localPos.x() < 0 || localPos.y() < 0
+ || localPos.x() >= screenGeom.width() || localPos.y() >= screenGeom.height())
+ {
+ if (!kmsScreen->isCursorOutOfRange()) {
+ kmsScreen->setCursorOutOfRange(true);
+ drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, 0, 0, 0);
+ }
+ } else {
+ int ret;
+ if (kmsScreen->isCursorOutOfRange()) {
+ kmsScreen->setCursorOutOfRange(false);
+ uint32_t handle = gbm_bo_get_handle(m_bo).u32;
+ ret = drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id,
+ handle, m_cursorSize.width(), m_cursorSize.height());
+ } else {
+ ret = drmModeMoveCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id,
+ adjustedLocalPos.x(), adjustedLocalPos.y());
+ }
+ if (ret == 0)
+ m_pos = pos;
+ else
+ qWarning("Failed to move cursor on screen %s: %d", kmsScreen->name().toLatin1().constData(), ret);
+
+ kmsScreen->handleCursorMove(pos);
+ }
}
}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h
index d47b579238..5d2dfedba2 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h
@@ -85,6 +85,8 @@ public:
void updateMouseStatus();
+ void reevaluateVisibilityForScreens() { setPos(pos()); }
+
private:
void initCursorAtlas();
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp
index 20127ae7f7..503419cf91 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp
@@ -83,6 +83,8 @@ bool QEglFSKmsGbmDevice::open()
setFd(fd);
+ m_eventReader.create(this);
+
return true;
}
@@ -90,6 +92,8 @@ void QEglFSKmsGbmDevice::close()
{
// Note: screens are gone at this stage.
+ m_eventReader.destroy();
+
if (m_gbm_device) {
gbm_device_destroy(m_gbm_device);
m_gbm_device = nullptr;
@@ -155,4 +159,14 @@ void QEglFSKmsGbmDevice::registerScreenCloning(QPlatformScreen *screen,
gbmScreen->initCloning(screenThisScreenClones, screensCloningThisScreen);
}
+void QEglFSKmsGbmDevice::registerScreen(QPlatformScreen *screen,
+ bool isPrimary,
+ const QPoint &virtualPos,
+ const QList<QPlatformScreen *> &virtualSiblings)
+{
+ QEglFSKmsDevice::registerScreen(screen, isPrimary, virtualPos, virtualSiblings);
+ if (screenConfig()->hwCursor() && m_globalCursor)
+ m_globalCursor->reevaluateVisibilityForScreens();
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h
index 518e2ce58b..f1476f8ffa 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h
@@ -70,6 +70,10 @@ public:
void registerScreenCloning(QPlatformScreen *screen,
QPlatformScreen *screenThisScreenClones,
const QVector<QPlatformScreen *> &screensCloningThisScreen) override;
+ void registerScreen(QPlatformScreen *screen,
+ bool isPrimary,
+ const QPoint &virtualPos,
+ const QList<QPlatformScreen *> &virtualSiblings) override;
private:
Q_DISABLE_COPY(QEglFSKmsGbmDevice)
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp
index f154520669..caa1187b40 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp
@@ -54,8 +54,6 @@
QT_BEGIN_NAMESPACE
-QMutex QEglFSKmsGbmScreen::m_waitForFlipMutex;
-
QEglFSKmsGbmIntegration::QEglFSKmsGbmIntegration()
{
qCDebug(qLcEglfsKmsDebug, "New DRM/KMS via GBM integration created");
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
index 16dbfe1522..6f5c3b6953 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
@@ -110,7 +110,7 @@ QEglFSKmsGbmScreen::FrameBuffer *QEglFSKmsGbmScreen::framebufferForBufferObject(
return fb.take();
}
-QEglFSKmsGbmScreen::QEglFSKmsGbmScreen(QKmsDevice *device, const QKmsOutput &output, bool headless)
+QEglFSKmsGbmScreen::QEglFSKmsGbmScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless)
: QEglFSKmsScreen(device, output, headless)
, m_gbm_surface(nullptr)
, m_gbm_bo_current(nullptr)
@@ -243,7 +243,7 @@ void QEglFSKmsGbmScreen::ensureModeSet(uint32_t fb)
if (device()->hasAtomicSupport()) {
#if QT_CONFIG(drm_atomic)
- drmModeAtomicReq *request = device()->atomic_request();
+ drmModeAtomicReq *request = device()->threadLocalAtomicRequest();
if (request) {
drmModeAtomicAddProperty(request, op.connector_id, op.crtcIdPropertyId, op.crtc_id);
drmModeAtomicAddProperty(request, op.crtc_id, op.modeIdPropertyId, op.mode_blob_id);
@@ -276,19 +276,15 @@ void QEglFSKmsGbmScreen::waitForFlip()
if (!m_gbm_bo_next)
return;
- QMutexLocker lock(&m_waitForFlipMutex);
- while (m_gbm_bo_next) {
- drmEventContext drmEvent;
- memset(&drmEvent, 0, sizeof(drmEvent));
- drmEvent.version = 2;
- drmEvent.vblank_handler = nullptr;
- drmEvent.page_flip_handler = pageFlipHandler;
- drmHandleEvent(device()->fd(), &drmEvent);
- }
+ m_flipMutex.lock();
+ device()->eventReader()->startWaitFlip(this, &m_flipMutex, &m_flipCond);
+ m_flipCond.wait(&m_flipMutex);
+ m_flipMutex.unlock();
+
+ flipFinished();
#if QT_CONFIG(drm_atomic)
- if (device()->hasAtomicSupport())
- device()->atomicReset();
+ device()->threadLocalAtomicReset();
#endif
}
@@ -324,16 +320,16 @@ void QEglFSKmsGbmScreen::flip()
if (device()->hasAtomicSupport()) {
#if QT_CONFIG(drm_atomic)
- drmModeAtomicReq *request = device()->atomic_request();
+ drmModeAtomicReq *request = device()->threadLocalAtomicRequest();
if (request) {
drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->framebufferPropertyId, fb->fb);
drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcPropertyId, op.crtc_id);
drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->srcwidthPropertyId,
- output().size.width() << 16);
+ op.size.width() << 16);
drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->srcXPropertyId, 0);
drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->srcYPropertyId, 0);
drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->srcheightPropertyId,
- output().size.height() << 16);
+ op.size.height() << 16);
drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcXPropertyId, 0);
drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcYPropertyId, 0);
drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcwidthPropertyId,
@@ -371,7 +367,7 @@ void QEglFSKmsGbmScreen::flip()
if (device()->hasAtomicSupport()) {
#if QT_CONFIG(drm_atomic)
- drmModeAtomicReq *request = device()->atomic_request();
+ drmModeAtomicReq *request = device()->threadLocalAtomicRequest();
if (request) {
drmModeAtomicAddProperty(request, d.screen->output().eglfs_plane->id,
d.screen->output().eglfs_plane->framebufferPropertyId, fb->fb);
@@ -394,22 +390,10 @@ void QEglFSKmsGbmScreen::flip()
}
#if QT_CONFIG(drm_atomic)
- if (device()->hasAtomicSupport())
- device()->atomicCommit(this);
+ device()->threadLocalAtomicCommit(this);
#endif
}
-void QEglFSKmsGbmScreen::pageFlipHandler(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data)
-{
- Q_UNUSED(fd);
- Q_UNUSED(sequence);
- Q_UNUSED(tv_sec);
- Q_UNUSED(tv_usec);
-
- QEglFSKmsGbmScreen *screen = static_cast<QEglFSKmsGbmScreen *>(user_data);
- screen->flipFinished();
-}
-
void QEglFSKmsGbmScreen::flipFinished()
{
if (m_cloneSource) {
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h
index b94f44b7b1..69feeee703 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h
@@ -43,7 +43,8 @@
#define QEGLFSKMSGBMSCREEN_H
#include "qeglfskmsscreen.h"
-#include <QtCore/QMutex>
+#include <QMutex>
+#include <QWaitCondition>
#include <gbm.h>
@@ -54,7 +55,7 @@ class QEglFSKmsGbmCursor;
class QEglFSKmsGbmScreen : public QEglFSKmsScreen
{
public:
- QEglFSKmsGbmScreen(QKmsDevice *device, const QKmsOutput &output, bool headless);
+ QEglFSKmsGbmScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless);
~QEglFSKmsGbmScreen();
QPlatformCursor *cursor() const override;
@@ -75,18 +76,15 @@ private:
void cloneDestFlipFinished(QEglFSKmsGbmScreen *cloneDestScreen);
void updateFlipStatus();
- static void pageFlipHandler(int fd,
- unsigned int sequence,
- unsigned int tv_sec,
- unsigned int tv_usec,
- void *user_data);
-
gbm_surface *m_gbm_surface;
gbm_bo *m_gbm_bo_current;
gbm_bo *m_gbm_bo_next;
bool m_flipPending;
+ QMutex m_flipMutex;
+ QWaitCondition m_flipCond;
+
QScopedPointer<QEglFSKmsGbmCursor> m_cursor;
struct FrameBuffer {
@@ -101,8 +99,6 @@ private:
bool cloneFlipPending = false;
};
QVector<CloneDestination> m_cloneDests;
-
- static QMutex m_waitForFlipMutex;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/CMakeLists.txt b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/CMakeLists.txt
index 07a72ce61f..a0b405c90c 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/CMakeLists.txt
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from eglfs_kms_egldevice.pro.
#####################################################################
-## qeglfs-kms-egldevice-integration Plugin:
+## QEglFSKmsEglDeviceIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qeglfs-kms-egldevice-integration
+qt_add_plugin(QEglFSKmsEglDeviceIntegrationPlugin
+ OUTPUT_NAME qeglfs-kms-egldevice-integration
TYPE egldeviceintegrations
- CLASS_NAME QEglFSKmsEglDeviceIntegrationPlugin
SOURCES
qeglfskmsegldevice.cpp qeglfskmsegldevice.h
qeglfskmsegldeviceintegration.cpp qeglfskmsegldeviceintegration.h
@@ -17,23 +17,17 @@ add_qt_plugin(qeglfs-kms-egldevice-integration
INCLUDE_DIRECTORIES
../../api
../eglfs_kms_support
- LIBRARIES
+ PUBLIC_LIBRARIES
+ Libdrm::Libdrm
+ Qt::Core
Qt::CorePrivate
Qt::EdidSupportPrivate
Qt::EglFSDeviceIntegrationPrivate
Qt::EglFsKmsSupportPrivate
+ Qt::Gui
Qt::GuiPrivate
Qt::KmsSupportPrivate
- PUBLIC_LIBRARIES
- Libdrm::Libdrm
- Qt::Core
- Qt::EdidSupport
- Qt::EglFSDeviceIntegration
- Qt::EglFsKmsSupport
- Qt::Gui
- Qt::KmsSupport
)
#### Keys ignored in scope 1:.:.:eglfs_kms_egldevice.pro:<TRUE>:
# OTHER_FILES = "$$PWD/eglfs_kms_egldevice.json"
-# _LOADED = "qt_plugin"
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp
index 1626c86239..5a62e437c4 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug)
-QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QKmsDevice *device, const QKmsOutput &output)
+QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QEglFSKmsDevice *device, const QKmsOutput &output)
: QEglFSKmsScreen(device, output)
{
}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h
index 5efe35f8b3..961398ba3e 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
class QEglFSKmsEglDeviceScreen : public QEglFSKmsScreen
{
public:
- QEglFSKmsEglDeviceScreen(QKmsDevice *device, const QKmsOutput &output);
+ QEglFSKmsEglDeviceScreen(QEglFSKmsDevice *device, const QKmsOutput &output);
~QEglFSKmsEglDeviceScreen();
QPlatformCursor *cursor() const override;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/CMakeLists.txt b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/CMakeLists.txt
index 0c51781475..abaad3930d 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/CMakeLists.txt
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/CMakeLists.txt
@@ -4,11 +4,12 @@
## EglFsKmsSupport Module:
#####################################################################
-add_qt_module(EglFsKmsSupport
+qt_add_module(EglFsKmsSupport
INTERNAL_MODULE
NO_MODULE_HEADERS
SOURCES
qeglfskmsdevice.cpp qeglfskmsdevice.h
+ qeglfskmseventreader.cpp qeglfskmseventreader.h
qeglfskmshelpers.h
qeglfskmsintegration.cpp qeglfskmsintegration.h
qeglfskmsscreen.cpp qeglfskmsscreen.h
@@ -16,20 +17,13 @@ add_qt_module(EglFsKmsSupport
QT_EGL_NO_X11
INCLUDE_DIRECTORIES
../../api
- LIBRARIES
+ PUBLIC_LIBRARIES
+ Libdrm::Libdrm
+ Qt::Core
Qt::CorePrivate
Qt::EdidSupportPrivate
Qt::EglFSDeviceIntegrationPrivate
+ Qt::Gui
Qt::GuiPrivate
Qt::KmsSupportPrivate
- PUBLIC_LIBRARIES
- Libdrm::Libdrm
- Qt::Core
- Qt::EdidSupport
- Qt::EglFSDeviceIntegration
- Qt::Gui
- Qt::KmsSupport
)
-
-#### Keys ignored in scope 1:.:.:eglfs_kms_support.pro:<TRUE>:
-# _LOADED = "qt_module"
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro
index 40806b6a9b..e51903ed96 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro
@@ -14,9 +14,11 @@ CONFIG += egl
SOURCES += $$PWD/qeglfskmsintegration.cpp \
$$PWD/qeglfskmsdevice.cpp \
- $$PWD/qeglfskmsscreen.cpp
+ $$PWD/qeglfskmsscreen.cpp \
+ $$PWD/qeglfskmseventreader.cpp
HEADERS += $$PWD/qeglfskmsintegration.h \
$$PWD/qeglfskmsdevice.h \
$$PWD/qeglfskmsscreen.h \
- $$PWD/qeglfskmshelpers.h
+ $$PWD/qeglfskmshelpers.h \
+ $$PWD/qeglfskmseventreader.h
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h
index fc83a620d9..34908aa60f 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h
@@ -42,6 +42,7 @@
#define QEGLFSKMSDEVICE_H
#include "private/qeglfsglobal_p.h"
+#include "qeglfskmseventreader.h"
#include <QtKmsSupport/private/qkmsdevice_p.h>
QT_BEGIN_NAMESPACE
@@ -55,6 +56,11 @@ public:
bool isPrimary,
const QPoint &virtualPos,
const QList<QPlatformScreen *> &virtualSiblings) override;
+
+ QEglFSKmsEventReader *eventReader() { return &m_eventReader; }
+
+protected:
+ QEglFSKmsEventReader m_eventReader;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
new file mode 100644
index 0000000000..645a0ae2e9
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeglfskmseventreader.h"
+#include "qeglfskmsdevice.h"
+#include <QSocketNotifier>
+#include <QCoreApplication>
+#include <QLoggingCategory>
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug)
+
+static void pageFlipHandler(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data)
+{
+ Q_UNUSED(fd);
+ Q_UNUSED(sequence);
+ Q_UNUSED(tv_sec);
+ Q_UNUSED(tv_usec);
+
+ QEglFSKmsEventReaderThread *t = static_cast<QEglFSKmsEventReaderThread *>(QThread::currentThread());
+ t->eventHost()->handlePageFlipCompleted(user_data);
+}
+
+class RegisterWaitFlipEvent : public QEvent
+{
+public:
+ static const QEvent::Type TYPE = QEvent::Type(QEvent::User + 1);
+ RegisterWaitFlipEvent(void *key, QMutex *mutex, QWaitCondition *cond)
+ : QEvent(TYPE), key(key), mutex(mutex), cond(cond)
+ { }
+ void *key;
+ QMutex *mutex;
+ QWaitCondition *cond;
+};
+
+bool QEglFSKmsEventHost::event(QEvent *event)
+{
+ if (event->type() == RegisterWaitFlipEvent::TYPE) {
+ RegisterWaitFlipEvent *e = static_cast<RegisterWaitFlipEvent *>(event);
+ PendingFlipWait *p = &pendingFlipWaits[0];
+ PendingFlipWait *end = p + MAX_FLIPS;
+ while (p < end) {
+ if (!p->key) {
+ p->key = e->key;
+ p->mutex = e->mutex;
+ p->cond = e->cond;
+ updateStatus();
+ return true;
+ }
+ ++p;
+ }
+ qWarning("Cannot queue page flip wait (more than %d screens?)", MAX_FLIPS);
+ e->mutex->lock();
+ e->cond->wakeOne();
+ e->mutex->unlock();
+ return true;
+ }
+ return QObject::event(event);
+}
+
+void QEglFSKmsEventHost::updateStatus()
+{
+ void **begin = &completedFlips[0];
+ void **end = begin + MAX_FLIPS;
+
+ for (int i = 0; i < MAX_FLIPS; ++i) {
+ PendingFlipWait *w = pendingFlipWaits + i;
+ if (!w->key)
+ continue;
+
+ void **p = begin;
+ while (p < end) {
+ if (*p == w->key) {
+ *p = nullptr;
+ w->key = nullptr;
+ w->mutex->lock();
+ w->cond->wakeOne();
+ w->mutex->unlock();
+ return;
+ }
+ ++p;
+ }
+ }
+}
+
+void QEglFSKmsEventHost::handlePageFlipCompleted(void *key)
+{
+ void **begin = &completedFlips[0];
+ void **end = begin + MAX_FLIPS;
+ void **p = begin;
+ while (p < end) {
+ if (*p == key) {
+ updateStatus();
+ return;
+ }
+ ++p;
+ }
+ p = begin;
+ while (p < end) {
+ if (!*p) {
+ *p = key;
+ updateStatus();
+ return;
+ }
+ ++p;
+ }
+ qWarning("Cannot store page flip status (more than %d screens?)", MAX_FLIPS);
+}
+
+void QEglFSKmsEventReaderThread::run()
+{
+ qCDebug(qLcEglfsKmsDebug, "Event reader thread: entering event loop");
+
+ QSocketNotifier notifier(m_fd, QSocketNotifier::Read);
+ QObject::connect(&notifier, &QSocketNotifier::activated, &notifier, [this] {
+ drmEventContext drmEvent;
+ memset(&drmEvent, 0, sizeof(drmEvent));
+ drmEvent.version = 2;
+ drmEvent.vblank_handler = nullptr;
+ drmEvent.page_flip_handler = pageFlipHandler;
+ drmHandleEvent(m_fd, &drmEvent);
+ });
+
+ exec();
+
+ m_ev.moveToThread(thread()); // move back to the thread where m_ev was created
+
+ qCDebug(qLcEglfsKmsDebug, "Event reader thread: event loop stopped");
+}
+
+QEglFSKmsEventReader::~QEglFSKmsEventReader()
+{
+ destroy();
+}
+
+void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+{
+ destroy();
+
+ if (!device)
+ return;
+
+ m_device = device;
+
+ qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
+ m_device, m_device->fd());
+
+ m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+ m_thread->start();
+
+ // Change thread affinity for the event host, so that postEvent()
+ // goes through the event reader thread's event loop for that object.
+ m_thread->eventHost()->moveToThread(m_thread);
+}
+
+void QEglFSKmsEventReader::destroy()
+{
+ if (!m_device)
+ return;
+
+ qCDebug(qLcEglfsKmsDebug, "Stopping event reader for device %p", m_device);
+
+ if (m_thread) {
+ m_thread->quit();
+ m_thread->wait();
+ delete m_thread;
+ m_thread = nullptr;
+ }
+
+ m_device = nullptr;
+}
+
+void QEglFSKmsEventReader::startWaitFlip(void *key, QMutex *mutex, QWaitCondition *cond)
+{
+ if (m_thread) {
+ QCoreApplication::postEvent(m_thread->eventHost(),
+ new RegisterWaitFlipEvent(key, mutex, cond));
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.h
new file mode 100644
index 0000000000..4aa285b0fe
--- /dev/null
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLFSKKMSEVENTREADER_H
+#define QEGLFSKKMSEVENTREADER_H
+
+#include "private/qeglfsglobal_p.h"
+#include <QObject>
+#include <QThread>
+#include <QMutex>
+#include <QWaitCondition>
+
+QT_BEGIN_NAMESPACE
+
+class QEglFSKmsDevice;
+
+struct QEglFSKmsEventHost : public QObject
+{
+ struct PendingFlipWait {
+ void *key;
+ QMutex *mutex;
+ QWaitCondition *cond;
+ };
+
+ static const int MAX_FLIPS = 32;
+ void *completedFlips[MAX_FLIPS] = {};
+ QEglFSKmsEventHost::PendingFlipWait pendingFlipWaits[MAX_FLIPS] = {};
+
+ bool event(QEvent *event) override;
+ void updateStatus();
+ void handlePageFlipCompleted(void *key);
+};
+
+class QEglFSKmsEventReaderThread : public QThread
+{
+public:
+ QEglFSKmsEventReaderThread(int fd) : m_fd(fd) { }
+ void run() override;
+ QEglFSKmsEventHost *eventHost() { return &m_ev; }
+
+private:
+ int m_fd;
+ QEglFSKmsEventHost m_ev;
+};
+
+class Q_EGLFS_EXPORT QEglFSKmsEventReader
+{
+public:
+ ~QEglFSKmsEventReader();
+
+ void create(QEglFSKmsDevice *device);
+ void destroy();
+
+ void startWaitFlip(void *key, QMutex *mutex, QWaitCondition *cond);
+
+private:
+ QEglFSKmsDevice *m_device = nullptr;
+ QEglFSKmsEventReaderThread *m_thread = nullptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QEGLFSKKMSEVENTREADER_H
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp
index a6aac61506..28b6b7df63 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp
@@ -140,7 +140,7 @@ void *QEglFSKmsIntegration::nativeResourceForIntegration(const QByteArray &name)
#if QT_CONFIG(drm_atomic)
if (name == QByteArrayLiteral("dri_atomic_request") && m_device)
- return (void *) (qintptr) m_device->atomic_request();
+ return (void *) (qintptr) m_device->threadLocalAtomicRequest();
#endif
return nullptr;
}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp
index e5354d97bd..959f17eba3 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qeglfskmsscreen.h"
+#include "qeglfskmsdevice.h"
#include "qeglfsintegration_p.h"
#include <QtCore/QLoggingCategory>
@@ -68,10 +69,11 @@ private:
QEglFSKmsScreen *m_screen;
};
-QEglFSKmsScreen::QEglFSKmsScreen(QKmsDevice *device, const QKmsOutput &output, bool headless)
+QEglFSKmsScreen::QEglFSKmsScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless)
: QEglFSScreen(static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration())->display())
, m_device(device)
, m_output(output)
+ , m_cursorOutOfRange(false)
, m_powerState(PowerStateOn)
, m_interruptHandler(new QEglFSKmsInterruptHandler(this))
, m_headless(headless)
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h
index 7f395aacb7..a5c8f5b4e8 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h
@@ -51,12 +51,13 @@
QT_BEGIN_NAMESPACE
+class QEglFSKmsDevice;
class QEglFSKmsInterruptHandler;
class Q_EGLFS_EXPORT QEglFSKmsScreen : public QEglFSScreen
{
public:
- QEglFSKmsScreen(QKmsDevice *device, const QKmsOutput &output, bool headless = false);
+ QEglFSKmsScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless = false);
~QEglFSKmsScreen();
void setVirtualPosition(const QPoint &pos);
@@ -87,7 +88,7 @@ public:
int currentMode() const override;
int preferredMode() const override;
- QKmsDevice *device() const { return m_device; }
+ QEglFSKmsDevice *device() const { return m_device; }
virtual void waitForFlip();
@@ -99,12 +100,16 @@ public:
QPlatformScreen::PowerState powerState() const override;
void setPowerState(QPlatformScreen::PowerState state) override;
+ bool isCursorOutOfRange() const { return m_cursorOutOfRange; }
+ void setCursorOutOfRange(bool b) { m_cursorOutOfRange = b; }
+
protected:
- QKmsDevice *m_device;
+ QEglFSKmsDevice *m_device;
QKmsOutput m_output;
QEdidParser m_edid;
QPoint m_pos;
+ bool m_cursorOutOfRange;
QList<QPlatformScreen *> m_siblings;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp
index 475d9d55dd..c255bc84b7 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp
@@ -99,7 +99,7 @@ QEglFSKmsVsp2Screen::DmaBuffer *QEglFSKmsVsp2Screen::dmaBufferForGbmBuffer(gbm_b
return fb.take();
}
-QEglFSKmsVsp2Screen::QEglFSKmsVsp2Screen(QKmsDevice *device, const QKmsOutput &output)
+QEglFSKmsVsp2Screen::QEglFSKmsVsp2Screen(QEglFSKmsDevice *device, const QKmsOutput &output)
: QEglFSKmsScreen(device, output)
, m_blender(new Blender(this))
{
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h
index 7618510333..378786643d 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
class QEglFSKmsVsp2Screen : public QEglFSKmsScreen
{
public:
- QEglFSKmsVsp2Screen(QKmsDevice *device, const QKmsOutput &output);
+ QEglFSKmsVsp2Screen(QEglFSKmsDevice *device, const QKmsOutput &output);
gbm_surface *createSurface();
void resetSurface();
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp
index 2fc076ad0c..5e1d28a353 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp
@@ -41,6 +41,11 @@
#include <EGL/eglvivante.h>
#include <QDebug>
+#if QT_CONFIG(vulkan)
+#include "private/qeglfsvulkaninstance_p.h"
+#include "private/qeglfsvulkanwindow_p.h"
+#endif
+
#ifdef Q_OS_INTEGRITY
extern "C" void VivanteInit(void);
#endif
@@ -97,4 +102,20 @@ void QEglFSVivIntegration::destroyNativeWindow(EGLNativeWindowType window)
fbDestroyWindow(window);
}
+#if QT_CONFIG(vulkan)
+
+QEglFSWindow *QEglFSVivIntegration::createWindow(QWindow *window) const
+{
+ if (window->surfaceType() == QSurface::VulkanSurface)
+ return new QEglFSVulkanWindow(window);
+ return QEglFSDeviceIntegration::createWindow(window);
+}
+
+QPlatformVulkanInstance *QEglFSVivIntegration::createPlatformVulkanInstance(QVulkanInstance *instance)
+{
+ return new QEglFSVulkanInstance(instance);
+}
+
+#endif // vulkan
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h
index 4d1718afcf..02b59c16b5 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h
@@ -53,6 +53,12 @@ public:
void destroyNativeWindow(EGLNativeWindowType window) override;
EGLNativeDisplayType platformDisplay() const override;
+ // Vulkan support with VK_KHR_display
+#if QT_CONFIG(vulkan)
+ QEglFSWindow *createWindow(QWindow *window) const override;
+ QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) override;
+#endif
+
private:
QSize mScreenSize;
EGLNativeDisplayType mNativeDisplay;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/CMakeLists.txt b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/CMakeLists.txt
index 816fe3fc13..29dcd0dab7 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/CMakeLists.txt
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from eglfs_x11.pro.
#####################################################################
-## qeglfs-x11-integration Plugin:
+## QEglFSX11IntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qeglfs-x11-integration
+qt_add_plugin(QEglFSX11IntegrationPlugin
+ OUTPUT_NAME qeglfs-x11-integration
TYPE egldeviceintegrations
- CLASS_NAME QEglFSX11IntegrationPlugin
SOURCES
qeglfsx11integration.cpp qeglfsx11integration.h
qeglfsx11main.cpp
@@ -14,18 +14,15 @@ add_qt_plugin(qeglfs-x11-integration
QT_EGL_NO_X11
INCLUDE_DIRECTORIES
../../api
- LIBRARIES
- Qt::CorePrivate
- Qt::EglFSDeviceIntegrationPrivate
- Qt::GuiPrivate
PUBLIC_LIBRARIES
Qt::Core
- Qt::EglFSDeviceIntegration
+ Qt::CorePrivate
+ Qt::EglFSDeviceIntegrationPrivate
Qt::Gui
+ Qt::GuiPrivate
X11::XCB
XCB::XCB
)
#### Keys ignored in scope 1:.:.:eglfs_x11.pro:<TRUE>:
# OTHER_FILES = "$$PWD/eglfs_x11.json"
-# _LOADED = "qt_plugin"
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp
index 07b2de7c58..ce5a721906 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp
@@ -75,7 +75,7 @@ void EventReader::run()
if (client->format == 32
&& client->type == atoms[Atoms::WM_PROTOCOLS]
&& client->data.data32[0] == atoms[Atoms::WM_DELETE_WINDOW]) {
- QWindow *window = m_integration->platformWindow() ? m_integration->platformWindow()->window() : 0;
+ QWindow *window = m_integration->platformWindow() ? m_integration->platformWindow()->window() : nullptr;
if (window)
QWindowSystemInterface::handleCloseEvent(window);
}
@@ -106,7 +106,7 @@ void QEglFSX11Integration::sendConnectionEvent(xcb_atom_t a)
void QEglFSX11Integration::platformInit()
{
- m_display = XOpenDisplay(0);
+ m_display = XOpenDisplay(nullptr);
if (Q_UNLIKELY(!m_display))
qFatal("Could not open display");
@@ -121,7 +121,7 @@ void QEglFSX11Integration::platformInit()
xcb_create_window(m_connection, XCB_COPY_FROM_PARENT,
m_connectionEventListener, it.data->root,
0, 0, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_ONLY,
- it.data->root_visual, 0, 0);
+ it.data->root_visual, 0, nullptr);
m_eventReader = new EventReader(this);
m_eventReader->start();
@@ -135,11 +135,11 @@ void QEglFSX11Integration::platformDestroy()
m_eventReader->wait();
delete m_eventReader;
- m_eventReader = 0;
+ m_eventReader = nullptr;
XCloseDisplay(DISPLAY);
- m_display = 0;
- m_connection = 0;
+ m_display = nullptr;
+ m_connection = nullptr;
}
EGLNativeDisplayType QEglFSX11Integration::platformDisplay() const
@@ -175,7 +175,7 @@ EGLNativeWindowType QEglFSX11Integration::createNativeWindow(QPlatformWindow *pl
xcb_create_window(m_connection, XCB_COPY_FROM_PARENT, m_window, it.data->root,
0, 0, size.width(), size.height(), 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT, it.data->root_visual,
- 0, 0);
+ 0, nullptr);
xcb_intern_atom_cookie_t cookies[Atoms::N_ATOMS];
static const char *atomNames[Atoms::N_ATOMS] = {
@@ -189,7 +189,7 @@ EGLNativeWindowType QEglFSX11Integration::createNativeWindow(QPlatformWindow *pl
for (int i = 0; i < Atoms::N_ATOMS; ++i) {
cookies[i] = xcb_intern_atom(m_connection, false, strlen(atomNames[i]), atomNames[i]);
- xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(m_connection, cookies[i], 0);
+ xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(m_connection, cookies[i], nullptr);
m_atoms[i] = reply->atom;
free(reply);
}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h
index bf431caaac..ebcc19b682 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h
@@ -67,7 +67,7 @@ class EventReader;
class QEglFSX11Integration : public QEglFSDeviceIntegration
{
public:
- QEglFSX11Integration() : m_connection(0), m_window(0), m_eventReader(0) {}
+ QEglFSX11Integration() : m_connection(nullptr), m_window(0), m_eventReader(nullptr) {}
void platformInit() override;
void platformDestroy() override;
diff --git a/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro b/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro
index 8bb7b614f1..bd02aea4d3 100644
--- a/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro
+++ b/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro
@@ -20,6 +20,9 @@ qtHaveModule(input_support-private): \
qtHaveModule(platformcompositor_support-private): \
QT += platformcompositor_support-private
+qtConfig(vulkan): \
+ QT += vulkan_support-private
+
# Avoid X11 header collision, use generic EGL native types
DEFINES += QT_EGL_NO_X11
diff --git a/src/plugins/platforms/eglfs/qeglfsmain.cpp b/src/plugins/platforms/eglfs/qeglfsmain.cpp
index 4f77b7cd17..b41bbec27d 100644
--- a/src/plugins/platforms/eglfs/qeglfsmain.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsmain.cpp
@@ -56,7 +56,7 @@ QPlatformIntegration* QEglFSIntegrationPlugin::create(const QString& system, con
if (!system.compare(QLatin1String("eglfs"), Qt::CaseInsensitive))
return new QEglFSIntegration;
- return 0;
+ return nullptr;
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/haiku/qhaikuapplication.cpp b/src/plugins/platforms/haiku/qhaikuapplication.cpp
index b75810c453..de4acdfd4a 100644
--- a/src/plugins/platforms/haiku/qhaikuapplication.cpp
+++ b/src/plugins/platforms/haiku/qhaikuapplication.cpp
@@ -42,6 +42,8 @@
#include <QCoreApplication>
#include <QFileOpenEvent>
+#include <qpa/qwindowsysteminterface.h>
+
#include <Entry.h>
#include <Path.h>
@@ -52,8 +54,7 @@ QHaikuApplication::QHaikuApplication(const char *signature)
bool QHaikuApplication::QuitRequested()
{
- QEvent quitEvent(QEvent::Quit);
- QCoreApplication::sendEvent(QCoreApplication::instance(), &quitEvent);
+ QWindowSystemInterface::handleApplicationTermination<QWindowSystemInterface::SynchronousDelivery>();
return true;
}
diff --git a/src/plugins/platforms/ios/.prev_CMakeLists.txt b/src/plugins/platforms/ios/.prev_CMakeLists.txt
new file mode 100644
index 0000000000..d7ff160ee0
--- /dev/null
+++ b/src/plugins/platforms/ios/.prev_CMakeLists.txt
@@ -0,0 +1,65 @@
+# Generated from ios.pro.
+
+#####################################################################
+## QIOSIntegrationPlugin Plugin:
+#####################################################################
+
+add_qt_plugin(QIOSIntegrationPlugin
+ OUTPUT_NAME qios
+ TYPE platforms
+ SOURCES
+ plugin.mm
+ qiosapplicationdelegate.h qiosapplicationdelegate.mm
+ qiosapplicationstate.h qiosapplicationstate.mm
+ qiosbackingstore.h qiosbackingstore.mm
+ qioscontext.h qioscontext.mm
+ qioseventdispatcher.h qioseventdispatcher.mm
+ qiosglobal.h qiosglobal.mm
+ qiosinputcontext.h qiosinputcontext.mm
+ qiosintegration.h qiosintegration.mm
+ qiosplatformaccessibility.h qiosplatformaccessibility.mm
+ qiosscreen.h qiosscreen.mm
+ qiosservices.h qiosservices.mm
+ qiostextresponder.h qiostextresponder.mm
+ qiostheme.h qiostheme.mm
+ qiosviewcontroller.h qiosviewcontroller.mm
+ qioswindow.h qioswindow.mm
+ quiaccessibilityelement.h quiaccessibilityelement.mm
+ quiview.h quiview.mm
+ PUBLIC_LIBRARIES
+ ${FWAudioToolbox}
+ ${FWFoundation}
+ ${FWQuartzCore}
+ ${FWUIKit}
+ Qt::ClipboardSupportPrivate
+ Qt::CorePrivate
+ Qt::FontDatabaseSupportPrivate
+ Qt::GraphicsSupportPrivate
+ Qt::GuiPrivate
+)
+
+#### Keys ignored in scope 2:.:.:kernel.pro:<TRUE>:
+# OTHER_FILES = "quiview_textinput.mm" "quiview_accessibility.mm"
+
+## Scopes:
+#####################################################################
+
+extend_target(QIOSIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate
+ PUBLIC_LIBRARIES
+ Qt::PlatformCompositorSupportPrivate
+)
+
+extend_target(QIOSIntegrationPlugin CONDITION NOT APPLE_TVOS
+ SOURCES
+ qiosclipboard.h qiosclipboard.mm
+ qiosfiledialog.h qiosfiledialog.mm
+ qiosmenu.h qiosmenu.mm
+ qiosmessagedialog.h qiosmessagedialog.mm
+ qiostextinputoverlay.h qiostextinputoverlay.mm
+ PUBLIC_LIBRARIES
+ ${FWAssetsLibrary}
+)
+
+#### Keys ignored in scope 6:.:.:kernel.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
+# PLUGIN_EXTENDS = "-"
+add_subdirectory(optional)
diff --git a/src/plugins/platforms/ios/CMakeLists.txt b/src/plugins/platforms/ios/CMakeLists.txt
new file mode 100644
index 0000000000..d7ff160ee0
--- /dev/null
+++ b/src/plugins/platforms/ios/CMakeLists.txt
@@ -0,0 +1,65 @@
+# Generated from ios.pro.
+
+#####################################################################
+## QIOSIntegrationPlugin Plugin:
+#####################################################################
+
+add_qt_plugin(QIOSIntegrationPlugin
+ OUTPUT_NAME qios
+ TYPE platforms
+ SOURCES
+ plugin.mm
+ qiosapplicationdelegate.h qiosapplicationdelegate.mm
+ qiosapplicationstate.h qiosapplicationstate.mm
+ qiosbackingstore.h qiosbackingstore.mm
+ qioscontext.h qioscontext.mm
+ qioseventdispatcher.h qioseventdispatcher.mm
+ qiosglobal.h qiosglobal.mm
+ qiosinputcontext.h qiosinputcontext.mm
+ qiosintegration.h qiosintegration.mm
+ qiosplatformaccessibility.h qiosplatformaccessibility.mm
+ qiosscreen.h qiosscreen.mm
+ qiosservices.h qiosservices.mm
+ qiostextresponder.h qiostextresponder.mm
+ qiostheme.h qiostheme.mm
+ qiosviewcontroller.h qiosviewcontroller.mm
+ qioswindow.h qioswindow.mm
+ quiaccessibilityelement.h quiaccessibilityelement.mm
+ quiview.h quiview.mm
+ PUBLIC_LIBRARIES
+ ${FWAudioToolbox}
+ ${FWFoundation}
+ ${FWQuartzCore}
+ ${FWUIKit}
+ Qt::ClipboardSupportPrivate
+ Qt::CorePrivate
+ Qt::FontDatabaseSupportPrivate
+ Qt::GraphicsSupportPrivate
+ Qt::GuiPrivate
+)
+
+#### Keys ignored in scope 2:.:.:kernel.pro:<TRUE>:
+# OTHER_FILES = "quiview_textinput.mm" "quiview_accessibility.mm"
+
+## Scopes:
+#####################################################################
+
+extend_target(QIOSIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate
+ PUBLIC_LIBRARIES
+ Qt::PlatformCompositorSupportPrivate
+)
+
+extend_target(QIOSIntegrationPlugin CONDITION NOT APPLE_TVOS
+ SOURCES
+ qiosclipboard.h qiosclipboard.mm
+ qiosfiledialog.h qiosfiledialog.mm
+ qiosmenu.h qiosmenu.mm
+ qiosmessagedialog.h qiosmessagedialog.mm
+ qiostextinputoverlay.h qiostextinputoverlay.mm
+ PUBLIC_LIBRARIES
+ ${FWAssetsLibrary}
+)
+
+#### Keys ignored in scope 6:.:.:kernel.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
+# PLUGIN_EXTENDS = "-"
+add_subdirectory(optional)
diff --git a/src/plugins/platforms/ios/kernel.pro b/src/plugins/platforms/ios/kernel.pro
index 71257d09f7..01e0105223 100644
--- a/src/plugins/platforms/ios/kernel.pro
+++ b/src/plugins/platforms/ios/kernel.pro
@@ -9,6 +9,8 @@ QT += \
core-private gui-private \
clipboard_support-private fontdatabase_support-private graphics_support-private
+qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private
+
LIBS += -framework Foundation -framework UIKit -framework QuartzCore -framework AudioToolbox
OBJECTIVE_SOURCES = \
diff --git a/src/plugins/platforms/ios/optional/CMakeLists.txt b/src/plugins/platforms/ios/optional/CMakeLists.txt
new file mode 100644
index 0000000000..3c84e61f26
--- /dev/null
+++ b/src/plugins/platforms/ios/optional/CMakeLists.txt
@@ -0,0 +1,5 @@
+# Generated from optional.pro.
+
+if(APPLE_IOS)
+ add_subdirectory(nsphotolibrarysupport)
+endif()
diff --git a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/CMakeLists.txt b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/CMakeLists.txt
new file mode 100644
index 0000000000..0fbb0fdbd8
--- /dev/null
+++ b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/CMakeLists.txt
@@ -0,0 +1,29 @@
+# Generated from nsphotolibrarysupport.pro.
+
+#####################################################################
+## QIosOptionalPlugin_NSPhotoLibrary Plugin:
+#####################################################################
+
+add_qt_plugin(QIosOptionalPlugin_NSPhotoLibrary
+ OUTPUT_NAME qiosnsphotolibrarysupport
+ TYPE platforms/darwin
+ SOURCES
+ plugin.mm
+ qiosfileengineassetslibrary.h qiosfileengineassetslibrary.mm
+ qiosfileenginefactory.h
+ qiosimagepickercontroller.h qiosimagepickercontroller.mm
+ PUBLIC_LIBRARIES
+ ${FWAssetsLibrary}
+ ${FWFoundation}
+ ${FWUIKit}
+ Qt::Core
+ Qt::Gui
+ Qt::GuiPrivate
+)
+
+#### Keys ignored in scope 1:.:.:nsphotolibrarysupport.pro:<TRUE>:
+# OTHER_FILES = "plugin.json"
+# PLUGIN_EXTENDS = "-"
+
+## Scopes:
+#####################################################################
diff --git a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm
index 54152aebf7..c5244a51ad 100644
--- a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm
+++ b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm
@@ -373,7 +373,7 @@ bool QIOSFileEngineAssetsLibrary::close()
QAbstractFileEngine::FileFlags QIOSFileEngineAssetsLibrary::fileFlags(QAbstractFileEngine::FileFlags type) const
{
- QAbstractFileEngine::FileFlags flags = 0;
+ QAbstractFileEngine::FileFlags flags;
const bool isDir = (m_assetUrl == QLatin1String("assets-library://"));
const bool exists = isDir || m_assetUrl == g_iteratorCurrentUrl.localData() || loadAsset();
diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm
index c9509ae599..cb1a8a96f8 100644
--- a/src/plugins/platforms/ios/qioscontext.mm
+++ b/src/plugins/platforms/ios/qioscontext.mm
@@ -332,11 +332,8 @@ bool QIOSContext::verifyGraphicsHardwareAvailability()
);
});
- if (applicationBackgrounded) {
- static const char warning[] = "OpenGL ES calls are not allowed while an application is backgrounded";
- Q_ASSERT_X(!applicationBackgrounded, "QIOSContext", warning);
- qCWarning(lcQpaGLContext, warning);
- }
+ if (applicationBackgrounded)
+ qCWarning(lcQpaGLContext, "OpenGL ES calls are not allowed while an application is backgrounded");
return !applicationBackgrounded;
}
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm
index 9eca0eaad3..d724e65717 100644
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -65,6 +65,10 @@
#import <AudioToolbox/AudioServices.h>
+#if QT_CONFIG(opengl)
+#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h>
+#endif
+
#include <QtDebug>
QT_BEGIN_NAMESPACE
@@ -186,7 +190,11 @@ QPlatformWindow *QIOSIntegration::createPlatformWindow(QWindow *window) const
// Used when the QWindow's surface type is set by the client to QSurface::RasterSurface
QPlatformBackingStore *QIOSIntegration::createPlatformBackingStore(QWindow *window) const
{
- return new QIOSBackingStore(window);
+ auto *backingStore = new QIOSBackingStore(window);
+#if QT_CONFIG(opengl)
+ backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
+#endif
+ return backingStore;
}
// Used when the QWindow's surface type is set by the client to QSurface::OpenGLSurface
diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm
index 396c769be8..a3350bda87 100644
--- a/src/plugins/platforms/ios/qiostextresponder.mm
+++ b/src/plugins/platforms/ios/qiostextresponder.mm
@@ -745,7 +745,11 @@
- (UITextPosition *)positionFromPosition:(UITextPosition *)position offset:(NSInteger)offset
{
int p = static_cast<QUITextPosition *>(position).index;
- return [QUITextPosition positionWithIndex:p + offset];
+ const int posWithIndex = p + offset;
+ const int textLength = [self currentImeState:Qt::ImSurroundingText].toString().length();
+ if (posWithIndex < 0 || posWithIndex > textLength)
+ return nil;
+ return [QUITextPosition positionWithIndex:posWithIndex];
}
- (UITextPosition *)positionFromPosition:(UITextPosition *)position inDirection:(UITextLayoutDirection)direction offset:(NSInteger)offset
@@ -781,12 +785,16 @@
- (UIView *)textInputView
{
+ auto *focusWindow = QGuiApplication::focusWindow();
+ if (!focusWindow)
+ return nil;
+
// iOS expects rects we return from other UITextInput methods
// to be relative to the view this method returns.
// Since QInputMethod returns rects relative to the top level
// QWindow, that is also the view we need to return.
- Q_ASSERT(qApp->focusWindow()->handle());
- QPlatformWindow *topLevel = qApp->focusWindow()->handle();
+ Q_ASSERT(focusWindow->handle());
+ QPlatformWindow *topLevel = focusWindow->handle();
while (QPlatformWindow *p = topLevel->parent())
topLevel = p;
return reinterpret_cast<UIView *>(topLevel->winId());
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index cdec57de71..1b6a802ca2 100644
--- a/src/plugins/platforms/ios/qioswindow.mm
+++ b/src/plugins/platforms/ios/qioswindow.mm
@@ -51,6 +51,9 @@
#include <qpa/qplatformintegration.h>
#import <QuartzCore/CAEAGLLayer.h>
+#ifdef Q_OS_IOS
+#import <QuartzCore/CAMetalLayer.h>
+#endif
#include <QtDebug>
@@ -58,9 +61,15 @@ QT_BEGIN_NAMESPACE
QIOSWindow::QIOSWindow(QWindow *window)
: QPlatformWindow(window)
- , m_view([[QUIView alloc] initWithQIOSWindow:this])
, m_windowLevel(0)
{
+#ifdef Q_OS_IOS
+ if (window->surfaceType() == QSurface::MetalSurface)
+ m_view = [[QUIMetalView alloc] initWithQIOSWindow:this];
+ else
+#endif
+ m_view = [[QUIView alloc] initWithQIOSWindow:this];
+
connect(qGuiApp, &QGuiApplication::applicationStateChanged, this, &QIOSWindow::applicationStateChanged);
setParent(QPlatformWindow::parent());
diff --git a/src/plugins/platforms/ios/quiview.h b/src/plugins/platforms/ios/quiview.h
index e1d5d5af0c..1ab9481dd6 100644
--- a/src/plugins/platforms/ios/quiview.h
+++ b/src/plugins/platforms/ios/quiview.h
@@ -70,3 +70,7 @@ QT_END_NAMESPACE
@property (nonatomic, readonly) UIEdgeInsets qt_safeAreaInsets;
@end
+#ifdef Q_OS_IOS
+@interface QUIMetalView : QUIView
+@end
+#endif
diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm
index e64c05d099..59eae07388 100644
--- a/src/plugins/platforms/ios/quiview.mm
+++ b/src/plugins/platforms/ios/quiview.mm
@@ -100,13 +100,15 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
- (instancetype)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame])) {
- // Set up EAGL layer
- CAEAGLLayer *eaglLayer = static_cast<CAEAGLLayer *>(self.layer);
- eaglLayer.opaque = TRUE;
- eaglLayer.drawableProperties = @{
- kEAGLDrawablePropertyRetainedBacking: @(YES),
- kEAGLDrawablePropertyColorFormat: kEAGLColorFormatRGBA8
- };
+ if ([self.layer isKindOfClass:[CAEAGLLayer class]]) {
+ // Set up EAGL layer
+ CAEAGLLayer *eaglLayer = static_cast<CAEAGLLayer *>(self.layer);
+ eaglLayer.opaque = TRUE;
+ eaglLayer.drawableProperties = @{
+ kEAGLDrawablePropertyRetainedBacking: @(YES),
+ kEAGLDrawablePropertyColorFormat: kEAGLColorFormatRGBA8
+ };
+ }
if (isQtApplication())
self.hidden = YES;
@@ -628,6 +630,14 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
#endif
}
+- (void)addInteraction:(id<UIInteraction>)interaction
+{
+ if ([NSStringFromClass(interaction.class) isEqualToString:@"UITextInteraction"])
+ return;
+
+ [super addInteraction:interaction];
+}
+
@end
@implementation UIView (QtHelpers)
@@ -667,6 +677,25 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
@end
+#ifdef Q_OS_IOS
+@implementation QUIMetalView
+
++ (Class)layerClass
+{
+#ifdef TARGET_IPHONE_SIMULATOR
+ if (@available(ios 13.0, *))
+#endif
+
+ return [CAMetalLayer class];
+
+#ifdef TARGET_IPHONE_SIMULATOR
+ return nil;
+#endif
+}
+
+@end
+#endif
+
#ifndef QT_NO_ACCESSIBILITY
// Include category as an alternative to using -ObjC (Apple QA1490)
#include "quiview_accessibility.mm"
diff --git a/src/plugins/platforms/linuxfb/.prev_CMakeLists.txt b/src/plugins/platforms/linuxfb/.prev_CMakeLists.txt
index 5354ed6e80..bcec98e1de 100644
--- a/src/plugins/platforms/linuxfb/.prev_CMakeLists.txt
+++ b/src/plugins/platforms/linuxfb/.prev_CMakeLists.txt
@@ -1,55 +1,45 @@
# Generated from linuxfb.pro.
#####################################################################
-## qlinuxfb Plugin:
+## QLinuxFbIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qlinuxfb
+qt_add_plugin(QLinuxFbIntegrationPlugin
+ OUTPUT_NAME qlinuxfb
TYPE platforms
- CLASS_NAME QLinuxFbIntegrationPlugin
SOURCES
main.cpp
qlinuxfbintegration.cpp qlinuxfbintegration.h
qlinuxfbscreen.cpp qlinuxfbscreen.h
DEFINES
QT_NO_FOREACH
- LIBRARIES
+ PUBLIC_LIBRARIES
+ Qt::Core
Qt::CorePrivate
Qt::EventDispatcherSupportPrivate
Qt::FbSupportPrivate
Qt::FontDatabaseSupportPrivate
+ Qt::Gui
Qt::GuiPrivate
Qt::ServiceSupportPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::EventDispatcherSupport
- Qt::FbSupport
- Qt::FontDatabaseSupport
- Qt::Gui
- Qt::ServiceSupport
)
#### Keys ignored in scope 1:.:.:linuxfb.pro:<TRUE>:
# OTHER_FILES = "linuxfb.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qlinuxfb CONDITION TARGET Qt::InputSupportPrivate
- LIBRARIES
- Qt::InputSupportPrivate
+qt_extend_target(QLinuxFbIntegrationPlugin CONDITION TARGET Qt::InputSupportPrivate
PUBLIC_LIBRARIES
- Qt::InputSupport
+ Qt::InputSupportPrivate
)
-extend_target(qlinuxfb CONDITION TARGET Qt::KmsSupportPrivate
+qt_extend_target(QLinuxFbIntegrationPlugin CONDITION TARGET Qt::KmsSupportPrivate
SOURCES
qlinuxfbdrmscreen.cpp qlinuxfbdrmscreen.h
- LIBRARIES
- Qt::KmsSupportPrivate
PUBLIC_LIBRARIES
- Qt::KmsSupport
+ Qt::KmsSupportPrivate
)
#### Keys ignored in scope 4:.:.:linuxfb.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
diff --git a/src/plugins/platforms/linuxfb/CMakeLists.txt b/src/plugins/platforms/linuxfb/CMakeLists.txt
index 935e683c27..8747894100 100644
--- a/src/plugins/platforms/linuxfb/CMakeLists.txt
+++ b/src/plugins/platforms/linuxfb/CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from linuxfb.pro.
#####################################################################
-## qlinuxfb Plugin:
+## QLinuxFbIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qlinuxfb
+qt_add_plugin(QLinuxFbIntegrationPlugin
+ OUTPUT_NAME qlinuxfb
TYPE platforms
- CLASS_NAME QLinuxFbIntegrationPlugin
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES linuxfb # special case
SOURCES
main.cpp
@@ -14,43 +14,33 @@ add_qt_plugin(qlinuxfb
qlinuxfbscreen.cpp qlinuxfbscreen.h
DEFINES
QT_NO_FOREACH
- LIBRARIES
+ PUBLIC_LIBRARIES
+ Qt::Core
Qt::CorePrivate
Qt::EventDispatcherSupportPrivate
Qt::FbSupportPrivate
Qt::FontDatabaseSupportPrivate
+ Qt::Gui
Qt::GuiPrivate
Qt::ServiceSupportPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::EventDispatcherSupport
- Qt::FbSupport
- Qt::FontDatabaseSupport
- Qt::Gui
- Qt::ServiceSupport
)
#### Keys ignored in scope 1:.:.:linuxfb.pro:<TRUE>:
# OTHER_FILES = "linuxfb.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qlinuxfb CONDITION TARGET Qt::InputSupportPrivate
- LIBRARIES
- Qt::InputSupportPrivate
+qt_extend_target(QLinuxFbIntegrationPlugin CONDITION TARGET Qt::InputSupportPrivate
PUBLIC_LIBRARIES
- Qt::InputSupport
+ Qt::InputSupportPrivate
)
-extend_target(qlinuxfb CONDITION TARGET Qt::KmsSupportPrivate
+qt_extend_target(QLinuxFbIntegrationPlugin CONDITION TARGET Qt::KmsSupportPrivate
SOURCES
qlinuxfbdrmscreen.cpp qlinuxfbdrmscreen.h
- LIBRARIES
- Qt::KmsSupportPrivate
PUBLIC_LIBRARIES
- Qt::KmsSupport
+ Qt::KmsSupportPrivate
)
#### Keys ignored in scope 4:.:.:linuxfb.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
diff --git a/src/plugins/platforms/minimal/.prev_CMakeLists.txt b/src/plugins/platforms/minimal/.prev_CMakeLists.txt
index de0f00415a..764c684932 100644
--- a/src/plugins/platforms/minimal/.prev_CMakeLists.txt
+++ b/src/plugins/platforms/minimal/.prev_CMakeLists.txt
@@ -1,38 +1,34 @@
# Generated from minimal.pro.
#####################################################################
-## qminimal Plugin:
+## QMinimalIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qminimal
+qt_add_plugin(QMinimalIntegrationPlugin
+ OUTPUT_NAME qminimal
TYPE platforms
- CLASS_NAME QMinimalIntegrationPlugin
SOURCES
main.cpp
qminimalbackingstore.cpp qminimalbackingstore.h
qminimalintegration.cpp qminimalintegration.h
DEFINES
QT_NO_FOREACH
- LIBRARIES
+ PUBLIC_LIBRARIES
+ Qt::Core
Qt::CorePrivate
Qt::EventDispatcherSupportPrivate
Qt::FontDatabaseSupportPrivate
- Qt::GuiPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::EventDispatcherSupport
- Qt::FontDatabaseSupport
Qt::Gui
+ Qt::GuiPrivate
)
#### Keys ignored in scope 1:.:.:minimal.pro:<TRUE>:
# OTHER_FILES = "minimal.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qminimal CONDITION QT_FEATURE_freetype
+qt_extend_target(QMinimalIntegrationPlugin CONDITION QT_FEATURE_freetype
LIBRARIES
WrapFreetype::WrapFreetype
)
diff --git a/src/plugins/platforms/minimal/CMakeLists.txt b/src/plugins/platforms/minimal/CMakeLists.txt
index 4898f7fd3b..4f4638b640 100644
--- a/src/plugins/platforms/minimal/CMakeLists.txt
+++ b/src/plugins/platforms/minimal/CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from minimal.pro.
#####################################################################
-## qminimal Plugin:
+## QMinimalIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qminimal
+qt_add_plugin(QMinimalIntegrationPlugin
+ OUTPUT_NAME qminimal
TYPE platforms
- CLASS_NAME QMinimalIntegrationPlugin
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES minimal # special case
SOURCES
main.cpp
@@ -14,26 +14,22 @@ add_qt_plugin(qminimal
qminimalintegration.cpp qminimalintegration.h
DEFINES
QT_NO_FOREACH
- LIBRARIES
+ PUBLIC_LIBRARIES
+ Qt::Core
Qt::CorePrivate
Qt::EventDispatcherSupportPrivate
Qt::FontDatabaseSupportPrivate
- Qt::GuiPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::EventDispatcherSupport
- Qt::FontDatabaseSupport
Qt::Gui
+ Qt::GuiPrivate
)
#### Keys ignored in scope 1:.:.:minimal.pro:<TRUE>:
# OTHER_FILES = "minimal.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qminimal CONDITION QT_FEATURE_freetype
+qt_extend_target(QMinimalIntegrationPlugin CONDITION QT_FEATURE_freetype
LIBRARIES
WrapFreetype::WrapFreetype
)
diff --git a/src/plugins/platforms/minimalegl/.prev_CMakeLists.txt b/src/plugins/platforms/minimalegl/.prev_CMakeLists.txt
index 9f9f4b2020..7a08af79a9 100644
--- a/src/plugins/platforms/minimalegl/.prev_CMakeLists.txt
+++ b/src/plugins/platforms/minimalegl/.prev_CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from minimalegl.pro.
#####################################################################
-## qminimalegl Plugin:
+## QMinimalEglIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qminimalegl
+qt_add_plugin(QMinimalEglIntegrationPlugin
+ OUTPUT_NAME qminimalegl
TYPE platforms
- CLASS_NAME QMinimalEglIntegrationPlugin
SOURCES
main.cpp
qminimaleglintegration.cpp qminimaleglintegration.h
@@ -14,30 +14,27 @@ add_qt_plugin(qminimalegl
qminimaleglwindow.cpp qminimaleglwindow.h
DEFINES
QT_EGL_NO_X11
- LIBRARIES
+ PUBLIC_LIBRARIES
+ Qt::Core
Qt::CorePrivate
Qt::EglSupportPrivate
Qt::EventDispatcherSupportPrivate
Qt::FontDatabaseSupportPrivate
- Qt::GuiPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::EglSupport
- Qt::EventDispatcherSupport
- Qt::FontDatabaseSupport
Qt::Gui
+ Qt::GuiPrivate
)
#### Keys ignored in scope 1:.:.:minimalegl.pro:<TRUE>:
# OTHER_FILES = "minimalegl.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qminimalegl CONDITION QT_FEATURE_opengl
+qt_extend_target(QMinimalEglIntegrationPlugin CONDITION QT_FEATURE_opengl
SOURCES
qminimaleglbackingstore.cpp qminimaleglbackingstore.h
+ PUBLIC_LIBRARIES
+ Qt::OpenGL
)
#### Keys ignored in scope 3:.:.:minimalegl.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
diff --git a/src/plugins/platforms/minimalegl/CMakeLists.txt b/src/plugins/platforms/minimalegl/CMakeLists.txt
index 87aa8bc15b..4c8856e35d 100644
--- a/src/plugins/platforms/minimalegl/CMakeLists.txt
+++ b/src/plugins/platforms/minimalegl/CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from minimalegl.pro.
#####################################################################
-## qminimalegl Plugin:
+## QMinimalEglIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qminimalegl
+qt_add_plugin(QMinimalEglIntegrationPlugin
+ OUTPUT_NAME qminimalegl
TYPE platforms
- CLASS_NAME QMinimalEglIntegrationPlugin
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES minimalegl # special case
SOURCES
main.cpp
@@ -15,30 +15,27 @@ add_qt_plugin(qminimalegl
qminimaleglwindow.cpp qminimaleglwindow.h
DEFINES
QT_EGL_NO_X11
- LIBRARIES
+ PUBLIC_LIBRARIES
+ Qt::Core
Qt::CorePrivate
Qt::EglSupportPrivate
Qt::EventDispatcherSupportPrivate
Qt::FontDatabaseSupportPrivate
- Qt::GuiPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::EglSupport
- Qt::EventDispatcherSupport
- Qt::FontDatabaseSupport
Qt::Gui
+ Qt::GuiPrivate
)
#### Keys ignored in scope 1:.:.:minimalegl.pro:<TRUE>:
# OTHER_FILES = "minimalegl.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qminimalegl CONDITION QT_FEATURE_opengl
+qt_extend_target(QMinimalEglIntegrationPlugin CONDITION QT_FEATURE_opengl
SOURCES
qminimaleglbackingstore.cpp qminimaleglbackingstore.h
+ PUBLIC_LIBRARIES
+ Qt::OpenGL
)
#### Keys ignored in scope 3:.:.:minimalegl.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
diff --git a/src/plugins/platforms/minimalegl/minimalegl.pro b/src/plugins/platforms/minimalegl/minimalegl.pro
index b7dde9069f..3f6ae4e248 100644
--- a/src/plugins/platforms/minimalegl/minimalegl.pro
+++ b/src/plugins/platforms/minimalegl/minimalegl.pro
@@ -21,6 +21,7 @@ HEADERS = qminimaleglintegration.h \
qminimaleglscreen.h
qtConfig(opengl) {
+ QT += opengl
SOURCES += qminimaleglbackingstore.cpp
HEADERS += qminimaleglbackingstore.h
}
diff --git a/src/plugins/platforms/minimalegl/qminimaleglbackingstore.cpp b/src/plugins/platforms/minimalegl/qminimaleglbackingstore.cpp
index dc8dd74312..2319762f31 100644
--- a/src/plugins/platforms/minimalegl/qminimaleglbackingstore.cpp
+++ b/src/plugins/platforms/minimalegl/qminimaleglbackingstore.cpp
@@ -40,7 +40,7 @@
#include "qminimaleglbackingstore.h"
#include <QtGui/QOpenGLContext>
-#include <QtGui/QOpenGLPaintDevice>
+#include <QtOpenGL/QOpenGLPaintDevice>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/offscreen/.prev_CMakeLists.txt b/src/plugins/platforms/offscreen/.prev_CMakeLists.txt
index 9dac294745..62d36ec449 100644
--- a/src/plugins/platforms/offscreen/.prev_CMakeLists.txt
+++ b/src/plugins/platforms/offscreen/.prev_CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from offscreen.pro.
#####################################################################
-## qoffscreen Plugin:
+## QOffscreenIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qoffscreen
+qt_add_plugin(QOffscreenIntegrationPlugin
+ OUTPUT_NAME qoffscreen
TYPE platforms
- CLASS_NAME QOffscreenIntegrationPlugin
SOURCES
main.cpp
qoffscreencommon.cpp qoffscreencommon.h
@@ -14,32 +14,26 @@ add_qt_plugin(qoffscreen
qoffscreenwindow.cpp qoffscreenwindow.h
DEFINES
QT_NO_FOREACH
- LIBRARIES
+ PUBLIC_LIBRARIES
+ Qt::Core
Qt::CorePrivate
Qt::EventDispatcherSupportPrivate
Qt::FontDatabaseSupportPrivate
- Qt::GuiPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::EventDispatcherSupport
- Qt::FontDatabaseSupport
Qt::Gui
+ Qt::GuiPrivate
)
#### Keys ignored in scope 1:.:.:offscreen.pro:<TRUE>:
# OTHER_FILES = "offscreen.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qoffscreen CONDITION QT_FEATURE_opengl AND QT_FEATURE_xlib AND NOT QT_FEATURE_opengles2
+qt_extend_target(QOffscreenIntegrationPlugin CONDITION QT_FEATURE_opengl AND QT_FEATURE_xlib AND NOT QT_FEATURE_opengles2
SOURCES
qoffscreenintegration_x11.cpp qoffscreenintegration_x11.h
- LIBRARIES
- Qt::GlxSupportPrivate
PUBLIC_LIBRARIES
- Qt::GlxSupport
+ Qt::GlxSupportPrivate
)
#### Keys ignored in scope 3:.:.:offscreen.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
diff --git a/src/plugins/platforms/offscreen/CMakeLists.txt b/src/plugins/platforms/offscreen/CMakeLists.txt
index 43c8bdc17b..63474c3760 100644
--- a/src/plugins/platforms/offscreen/CMakeLists.txt
+++ b/src/plugins/platforms/offscreen/CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from offscreen.pro.
#####################################################################
-## qoffscreen Plugin:
+## QOffscreenIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qoffscreen
+qt_add_plugin(QOffscreenIntegrationPlugin
+ OUTPUT_NAME qoffscreen
TYPE platforms
- CLASS_NAME QOffscreenIntegrationPlugin
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES offscreen # special case
SOURCES
main.cpp
@@ -15,32 +15,26 @@ add_qt_plugin(qoffscreen
qoffscreenwindow.cpp qoffscreenwindow.h
DEFINES
QT_NO_FOREACH
- LIBRARIES
+ PUBLIC_LIBRARIES
+ Qt::Core
Qt::CorePrivate
Qt::EventDispatcherSupportPrivate
Qt::FontDatabaseSupportPrivate
- Qt::GuiPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::EventDispatcherSupport
- Qt::FontDatabaseSupport
Qt::Gui
+ Qt::GuiPrivate
)
#### Keys ignored in scope 1:.:.:offscreen.pro:<TRUE>:
# OTHER_FILES = "offscreen.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qoffscreen CONDITION QT_FEATURE_opengl AND QT_FEATURE_xlib AND NOT QT_FEATURE_opengles2
+qt_extend_target(QOffscreenIntegrationPlugin CONDITION QT_FEATURE_opengl AND QT_FEATURE_xlib AND NOT QT_FEATURE_opengles2
SOURCES
qoffscreenintegration_x11.cpp qoffscreenintegration_x11.h
- LIBRARIES
- Qt::GlxSupportPrivate
PUBLIC_LIBRARIES
- Qt::GlxSupport
+ Qt::GlxSupportPrivate
)
#### Keys ignored in scope 3:.:.:offscreen.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
diff --git a/src/plugins/platforms/offscreen/main.cpp b/src/plugins/platforms/offscreen/main.cpp
index 207db60f3a..f364d9f004 100644
--- a/src/plugins/platforms/offscreen/main.cpp
+++ b/src/plugins/platforms/offscreen/main.cpp
@@ -57,7 +57,7 @@ QPlatformIntegration *QOffscreenIntegrationPlugin::create(const QString& system,
if (!system.compare(QLatin1String("offscreen"), Qt::CaseInsensitive))
return QOffscreenIntegration::createOffscreenIntegration();
- return 0;
+ return nullptr;
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/offscreen/qoffscreencommon.cpp b/src/plugins/platforms/offscreen/qoffscreencommon.cpp
index eae25012c1..de75a3e012 100644
--- a/src/plugins/platforms/offscreen/qoffscreencommon.cpp
+++ b/src/plugins/platforms/offscreen/qoffscreencommon.cpp
@@ -48,7 +48,7 @@
QT_BEGIN_NAMESPACE
-QPlatformWindow *QOffscreenScreen::windowContainingCursor = 0;
+QPlatformWindow *QOffscreenScreen::windowContainingCursor = nullptr;
class QOffscreenCursor : public QPlatformCursor
{
@@ -60,7 +60,7 @@ public:
{
m_pos = pos;
const QWindowList wl = QGuiApplication::topLevelWindows();
- QWindow *containing = 0;
+ QWindow *containing = nullptr;
for (QWindow *w : wl) {
if (w->type() != Qt::Desktop && w->isExposed() && w->geometry().contains(pos)) {
containing = w;
@@ -72,7 +72,7 @@ public:
if (containing)
local -= containing->position();
- QWindow *previous = QOffscreenScreen::windowContainingCursor ? QOffscreenScreen::windowContainingCursor->window() : 0;
+ QWindow *previous = QOffscreenScreen::windowContainingCursor ? QOffscreenScreen::windowContainingCursor->window() : nullptr;
if (containing != previous)
QWindowSystemInterface::handleEnterLeaveEvent(containing, previous, local, pos);
@@ -80,7 +80,7 @@ public:
QWindowSystemInterface::handleMouseEvent(containing, local, pos, QGuiApplication::mouseButtons(), Qt::NoButton,
QEvent::MouseMove, QGuiApplication::keyboardModifiers(), Qt::MouseEventSynthesizedByQt);
- QOffscreenScreen::windowContainingCursor = containing ? containing->handle() : 0;
+ QOffscreenScreen::windowContainingCursor = containing ? containing->handle() : nullptr;
}
#ifndef QT_NO_CURSOR
void changeCursor(QCursor *windowCursor, QWindow *window) override
@@ -106,7 +106,7 @@ QPixmap QOffscreenScreen::grabWindow(WId id, int x, int y, int width, int height
QOffscreenWindow *window = QOffscreenWindow::windowForWinId(id);
if (!window || window->window()->type() == Qt::Desktop) {
const QWindowList wl = QGuiApplication::topLevelWindows();
- QWindow *containing = 0;
+ QWindow *containing = nullptr;
for (QWindow *w : wl) {
if (w->type() != Qt::Desktop && w->isExposed() && w->geometry().contains(rect)) {
containing = w;
diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
index 869e9228cd..3a4494fc2e 100644
--- a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+++ b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
@@ -79,7 +79,7 @@ template <typename BaseEventDispatcher>
class QOffscreenEventDispatcher : public BaseEventDispatcher
{
public:
- explicit QOffscreenEventDispatcher(QObject *parent = 0)
+ explicit QOffscreenEventDispatcher(QObject *parent = nullptr)
: BaseEventDispatcher(parent)
{
}
diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp
index 92fc8aa57a..84991d751f 100644
--- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp
+++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp
@@ -206,7 +206,7 @@ QOffscreenX11GLXContext::QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGL
if (d->format.renderableType() != QSurfaceFormat::OpenGL)
return;
- d->shareContext = 0;
+ d->shareContext = nullptr;
if (context->shareHandle())
d->shareContext = static_cast<QOffscreenX11GLXContext *>(context->shareHandle())->d->context;
@@ -216,9 +216,9 @@ QOffscreenX11GLXContext::QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGL
if (config) {
d->context = glXCreateNewContext(x11->display(), config, GLX_RGBA_TYPE, d->shareContext, true);
if (!d->context && d->shareContext) {
- d->shareContext = 0;
+ d->shareContext = nullptr;
// re-try without a shared glx context
- d->context = glXCreateNewContext(x11->display(), config, GLX_RGBA_TYPE, 0, true);
+ d->context = glXCreateNewContext(x11->display(), config, GLX_RGBA_TYPE, nullptr, true);
}
// Get the basic surface format details
@@ -234,8 +234,8 @@ QOffscreenX11GLXContext::QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGL
d->context = glXCreateContext(x11->display(), visualInfo, d->shareContext, true);
if (!d->context && d->shareContext) {
// re-try without a shared glx context
- d->shareContext = 0;
- d->context = glXCreateContext(x11->display(), visualInfo, 0, true);
+ d->shareContext = nullptr;
+ d->context = glXCreateContext(x11->display(), visualInfo, nullptr, true);
}
d->window = createDummyWindow(x11, visualInfo);
@@ -269,7 +269,7 @@ bool QOffscreenX11GLXContext::makeCurrent(QPlatformSurface *surface)
void QOffscreenX11GLXContext::doneCurrent()
{
- glXMakeCurrent(d->x11->display(), 0, 0);
+ glXMakeCurrent(d->x11->display(), 0, nullptr);
}
void QOffscreenX11GLXContext::swapBuffers(QPlatformSurface *)
diff --git a/src/plugins/platforms/offscreen/qoffscreenwindow.cpp b/src/plugins/platforms/offscreen/qoffscreenwindow.cpp
index 832e94034d..53880c877e 100644
--- a/src/plugins/platforms/offscreen/qoffscreenwindow.cpp
+++ b/src/plugins/platforms/offscreen/qoffscreenwindow.cpp
@@ -69,7 +69,7 @@ QOffscreenWindow::QOffscreenWindow(QWindow *window)
QOffscreenWindow::~QOffscreenWindow()
{
if (QOffscreenScreen::windowContainingCursor == this)
- QOffscreenScreen::windowContainingCursor = 0;
+ QOffscreenScreen::windowContainingCursor = nullptr;
m_windowForWinIdHash.remove(m_winId);
}
diff --git a/src/plugins/platforms/qnx/qqnxglcontext.cpp b/src/plugins/platforms/qnx/qqnxglcontext.cpp
index 1d030ba1aa..69391c4fec 100644
--- a/src/plugins/platforms/qnx/qqnxglcontext.cpp
+++ b/src/plugins/platforms/qnx/qqnxglcontext.cpp
@@ -58,8 +58,6 @@
QT_BEGIN_NAMESPACE
-EGLDisplay QQnxGLContext::ms_eglDisplay = EGL_NO_DISPLAY;
-
static QEGLPlatformContext::Flags makeFlags()
{
QEGLPlatformContext::Flags result = 0;
@@ -71,7 +69,8 @@ static QEGLPlatformContext::Flags makeFlags()
}
QQnxGLContext::QQnxGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share)
- : QEGLPlatformContext(format, share, ms_eglDisplay, 0, QVariant(), makeFlags())
+ : QEGLPlatformContext(format, share, QQnxIntegration::instance()->eglDisplay(), 0, QVariant(),
+ makeFlags())
{
}
@@ -79,28 +78,6 @@ QQnxGLContext::~QQnxGLContext()
{
}
-void QQnxGLContext::initializeContext()
-{
- qGLContextDebug();
-
- // Initialize connection to EGL
- ms_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
- if (Q_UNLIKELY(ms_eglDisplay == EGL_NO_DISPLAY))
- qFatal("QQnxGLContext: failed to obtain EGL display: %x", eglGetError());
-
- EGLBoolean eglResult = eglInitialize(ms_eglDisplay, 0, 0);
- if (Q_UNLIKELY(eglResult != EGL_TRUE))
- qFatal("QQnxGLContext: failed to initialize EGL display, err=%d", eglGetError());
-}
-
-void QQnxGLContext::shutdownContext()
-{
- qGLContextDebug();
-
- // Close connection to EGL
- eglTerminate(ms_eglDisplay);
-}
-
EGLSurface QQnxGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface)
{
QQnxEglWindow *window = static_cast<QQnxEglWindow *>(surface);
diff --git a/src/plugins/platforms/qnx/qqnxglcontext.h b/src/plugins/platforms/qnx/qqnxglcontext.h
index 19179a80e2..5d807ee9e4 100644
--- a/src/plugins/platforms/qnx/qqnxglcontext.h
+++ b/src/plugins/platforms/qnx/qqnxglcontext.h
@@ -58,19 +58,12 @@ public:
QQnxGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share);
virtual ~QQnxGLContext();
- static void initializeContext();
- static void shutdownContext();
-
bool makeCurrent(QPlatformSurface *surface) override;
void swapBuffers(QPlatformSurface *surface) override;
void doneCurrent() override;
protected:
EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) override;
-
-private:
- //Can be static because different displays returne the same handle
- static EGLDisplay ms_eglDisplay;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp
index f479e94988..84baa6ec44 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.cpp
+++ b/src/plugins/platforms/qnx/qqnxintegration.cpp
@@ -170,6 +170,9 @@ QQnxIntegration::QQnxIntegration(const QStringList &paramList)
#if QT_CONFIG(draganddrop)
, m_drag(new QSimpleDrag())
#endif
+#if QT_CONFIG(opengl)
+ , m_eglDisplay(EGL_NO_DISPLAY)
+#endif
{
ms_instance = this;
m_options = parseOptions(paramList);
@@ -195,9 +198,8 @@ QQnxIntegration::QQnxIntegration(const QStringList &paramList)
QMetaObject::invokeMethod(m_navigatorEventNotifier, "start", Qt::QueuedConnection);
#endif
-#if !defined(QT_NO_OPENGL)
- // Initialize global OpenGL resources
- QQnxGLContext::initializeContext();
+#if QT_CONFIG(opengl)
+ createEglDisplay();
#endif
// Create/start event thread
@@ -284,9 +286,8 @@ QQnxIntegration::~QQnxIntegration()
// Close connection to QNX composition manager
screen_destroy_context(m_screenContext);
-#if !defined(QT_NO_OPENGL)
- // Cleanup global OpenGL resources
- QQnxGLContext::shutdownContext();
+#if QT_CONFIG(opengl)
+ destroyEglDisplay();
#endif
#if QT_CONFIG(qqnx_pps)
@@ -741,4 +742,28 @@ bool QQnxIntegration::supportsNavigatorEvents() const
return m_navigator != 0;
}
+#if QT_CONFIG(opengl)
+void QQnxIntegration::createEglDisplay()
+{
+ qIntegrationDebug();
+
+ // Initialize connection to EGL
+ m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ if (Q_UNLIKELY(m_eglDisplay == EGL_NO_DISPLAY))
+ qFatal("QQnxiIntegration: failed to obtain EGL display: %x", eglGetError());
+
+ EGLBoolean eglResult = eglInitialize(m_eglDisplay, 0, 0);
+ if (Q_UNLIKELY(eglResult != EGL_TRUE))
+ qFatal("QQnxIntegration: failed to initialize EGL display, err=%d", eglGetError());
+}
+
+void QQnxIntegration::destroyEglDisplay()
+{
+ qIntegrationDebug();
+
+ // Close connection to EGL
+ eglTerminate(m_eglDisplay);
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h
index 0bf37880d1..2596af3c45 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.h
+++ b/src/plugins/platforms/qnx/qqnxintegration.h
@@ -46,6 +46,10 @@
#include <screen/screen.h>
+#if QT_CONFIG(opengl)
+#include <EGL/egl.h>
+#endif
+
QT_BEGIN_NAMESPACE
class QQnxScreenEventThread;
@@ -96,7 +100,8 @@ public:
QPlatformWindow *createPlatformWindow(QWindow *window) const override;
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override;
-#if !defined(QT_NO_OPENGL)
+#if QT_CONFIG(opengl)
+ EGLDisplay eglDisplay() const { return m_eglDisplay; }
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override;
#endif
@@ -175,6 +180,12 @@ private:
Options m_options;
+#if QT_CONFIG(opengl)
+ EGLDisplay m_eglDisplay;
+ void createEglDisplay();
+ void destroyEglDisplay();
+#endif
+
static QQnxIntegration *ms_instance;
friend class QQnxWindow;
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
index a9b5860187..e3a6aea99f 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
@@ -257,7 +257,7 @@ void QQnxScreenEventHandler::injectKeyboardEvent(int flags, int sym, int modifie
capKeyString(cap, modifiers, key);
QWindowSystemInterface::handleExtendedKeyEvent(QGuiApplication::focusWindow(), type, key, qtMod,
- scan, virtualKey, modifiers, keyStr);
+ scan, virtualKey, modifiers, keyStr, flags & KEY_REPEAT);
qScreenEventDebug() << "Qt key t=" << type << ", k=" << key << ", s=" << keyStr;
}
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp b/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp
index 1b5f3b4954..491c314488 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp
@@ -60,6 +60,18 @@ static const int c_screenCode = _PULSE_CODE_MINAVAIL + 0;
static const int c_armCode = _PULSE_CODE_MINAVAIL + 1;
static const int c_quitCode = _PULSE_CODE_MINAVAIL + 2;
+#if !defined(screen_register_event)
+int screen_register_event(screen_context_t, struct sigevent *event)
+{
+ return MsgRegisterEvent(event, -1);
+}
+
+int screen_unregister_event(struct sigevent *event)
+{
+ return MsgUnregisterEvent(event);
+}
+#endif
+
QQnxScreenEventThread::QQnxScreenEventThread(screen_context_t context)
: QThread()
, m_screenContext(context)
@@ -75,10 +87,14 @@ QQnxScreenEventThread::QQnxScreenEventThread(screen_context_t context)
qFatal("QQnxScreenEventThread: Can't continue without a channel connection");
}
- struct sigevent screenEvent;
- SIGEV_PULSE_INIT(&screenEvent, m_connectionId, SIGEV_PULSE_PRIO_INHERIT, c_screenCode, 0);
+ SIGEV_PULSE_INIT(&m_screenEvent, m_connectionId, SIGEV_PULSE_PRIO_INHERIT, c_screenCode, 0);
+ if (screen_register_event(m_screenContext, &m_screenEvent) == -1) {
+ ConnectDetach(m_connectionId);
+ ChannelDestroy(m_channelId);
+ qFatal("QQnxScreenEventThread: Can't continue without a registered event");
+ }
- screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, &screenEvent);
+ screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, &m_screenEvent);
}
QQnxScreenEventThread::~QQnxScreenEventThread()
@@ -86,6 +102,8 @@ QQnxScreenEventThread::~QQnxScreenEventThread()
// block until thread terminates
shutdown();
+ screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, nullptr);
+ screen_unregister_event(&m_screenEvent);
ConnectDetach(m_connectionId);
ChannelDestroy(m_channelId);
}
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventthread.h b/src/plugins/platforms/qnx/qqnxscreeneventthread.h
index 3c8d197545..e5b762369c 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventthread.h
+++ b/src/plugins/platforms/qnx/qqnxscreeneventthread.h
@@ -45,6 +45,7 @@
#include <QtCore/QMutex>
#include <screen/screen.h>
+#include <sys/siginfo.h>
QT_BEGIN_NAMESPACE
@@ -73,6 +74,7 @@ private:
int m_channelId;
int m_connectionId;
+ struct sigevent m_screenEvent;
screen_context_t m_screenContext;
bool m_emitNeededOnNextScreenPulse = true;
int m_screenPulsesSinceLastArmPulse = 0;
diff --git a/src/plugins/platforms/vnc/.prev_CMakeLists.txt b/src/plugins/platforms/vnc/.prev_CMakeLists.txt
index d4bdcf98c5..a26cc0be2b 100644
--- a/src/plugins/platforms/vnc/.prev_CMakeLists.txt
+++ b/src/plugins/platforms/vnc/.prev_CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from vnc.pro.
#####################################################################
-## qvnc Plugin:
+## QVncIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qvnc
+qt_add_plugin(QVncIntegrationPlugin
+ OUTPUT_NAME qvnc
TYPE platforms
- CLASS_NAME QVncIntegrationPlugin
SOURCES
main.cpp
qvnc.cpp qvnc_p.h
@@ -15,37 +15,28 @@ add_qt_plugin(qvnc
qvncscreen.cpp qvncscreen.h
DEFINES
QT_NO_FOREACH
- LIBRARIES
+ PUBLIC_LIBRARIES
+ Qt::Core
Qt::CorePrivate
Qt::EventDispatcherSupportPrivate
Qt::FbSupportPrivate
Qt::FontDatabaseSupportPrivate
+ Qt::Gui
Qt::GuiPrivate
+ Qt::Network
Qt::ServiceSupportPrivate
Qt::ThemeSupportPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::EventDispatcherSupport
- Qt::FbSupport
- Qt::FontDatabaseSupport
- Qt::Gui
- Qt::Network
- Qt::ServiceSupport
- Qt::ThemeSupport
)
#### Keys ignored in scope 1:.:.:vnc.pro:<TRUE>:
# OTHER_FILES = "vnc.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qvnc CONDITION TARGET Qt::InputSupportPrivate
- LIBRARIES
- Qt::InputSupportPrivate
+qt_extend_target(QVncIntegrationPlugin CONDITION TARGET Qt::InputSupportPrivate
PUBLIC_LIBRARIES
- Qt::InputSupport
+ Qt::InputSupportPrivate
)
#### Keys ignored in scope 3:.:.:vnc.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
diff --git a/src/plugins/platforms/vnc/CMakeLists.txt b/src/plugins/platforms/vnc/CMakeLists.txt
index 03402d06e6..cb84355d81 100644
--- a/src/plugins/platforms/vnc/CMakeLists.txt
+++ b/src/plugins/platforms/vnc/CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from vnc.pro.
#####################################################################
-## qvnc Plugin:
+## QVncIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qvnc
+qt_add_plugin(QVncIntegrationPlugin
+ OUTPUT_NAME qvnc
TYPE platforms
- CLASS_NAME QVncIntegrationPlugin
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES vnc # special case
SOURCES
main.cpp
@@ -16,37 +16,28 @@ add_qt_plugin(qvnc
qvncscreen.cpp qvncscreen.h
DEFINES
QT_NO_FOREACH
- LIBRARIES
+ PUBLIC_LIBRARIES
+ Qt::Core
Qt::CorePrivate
Qt::EventDispatcherSupportPrivate
Qt::FbSupportPrivate
Qt::FontDatabaseSupportPrivate
+ Qt::Gui
Qt::GuiPrivate
+ Qt::Network
Qt::ServiceSupportPrivate
Qt::ThemeSupportPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::EventDispatcherSupport
- Qt::FbSupport
- Qt::FontDatabaseSupport
- Qt::Gui
- Qt::Network
- Qt::ServiceSupport
- Qt::ThemeSupport
)
#### Keys ignored in scope 1:.:.:vnc.pro:<TRUE>:
# OTHER_FILES = "vnc.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qvnc CONDITION TARGET Qt::InputSupportPrivate
- LIBRARIES
- Qt::InputSupportPrivate
+qt_extend_target(QVncIntegrationPlugin CONDITION TARGET Qt::InputSupportPrivate
PUBLIC_LIBRARIES
- Qt::InputSupport
+ Qt::InputSupportPrivate
)
#### Keys ignored in scope 3:.:.:vnc.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
diff --git a/src/plugins/platforms/vnc/main.cpp b/src/plugins/platforms/vnc/main.cpp
index 3ec0f0b78d..ac7e18e03f 100644
--- a/src/plugins/platforms/vnc/main.cpp
+++ b/src/plugins/platforms/vnc/main.cpp
@@ -56,7 +56,7 @@ QPlatformIntegration* QVncIntegrationPlugin::create(const QString& system, const
if (!system.compare(QLatin1String("vnc"), Qt::CaseInsensitive))
return new QVncIntegration(paramList);
- return 0;
+ return nullptr;
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/vnc/qvnc.cpp b/src/plugins/platforms/vnc/qvnc.cpp
index 32114c6443..8390fa19cd 100644
--- a/src/plugins/platforms/vnc/qvnc.cpp
+++ b/src/plugins/platforms/vnc/qvnc.cpp
@@ -537,7 +537,7 @@ QVncClientCursor::QVncClientCursor()
{
QWindow *w = QGuiApplication::focusWindow();
QCursor c = w ? w->cursor() : QCursor(Qt::ArrowCursor);
- changeCursor(&c, 0);
+ changeCursor(&c, nullptr);
}
QVncClientCursor::~QVncClientCursor()
@@ -595,7 +595,7 @@ void QVncClientCursor::changeCursor(QCursor *widgetCursor, QWindow *window)
cursor = widgetCursor->pixmap().toImage();
} else {
// system cursor
- QPlatformCursorImage platformImage(0, 0, 0, 0, 0, 0);
+ QPlatformCursorImage platformImage(nullptr, nullptr, 0, 0, 0, 0);
platformImage.set(shape);
cursor = *platformImage.image();
hotspot = platformImage.hotspot();
diff --git a/src/plugins/platforms/vnc/qvncclient.cpp b/src/plugins/platforms/vnc/qvncclient.cpp
index 3a373a5e4b..c5caddc58d 100644
--- a/src/plugins/platforms/vnc/qvncclient.cpp
+++ b/src/plugins/platforms/vnc/qvncclient.cpp
@@ -65,7 +65,6 @@ QVncClient::QVncClient(QTcpSocket *clientSocket, QVncServer *server)
, m_cutTextPending(0)
, m_supportHextile(false)
, m_wantUpdate(false)
- , m_keymod(0)
, m_dirtyCursor(false)
, m_updatePending(false)
, m_protocolVersion(V3_3)
@@ -618,7 +617,7 @@ void QVncClient::keyEvent()
m_keymod = ev.down ? m_keymod | Qt::AltModifier :
m_keymod & ~Qt::AltModifier;
if (ev.unicode || ev.keycode)
- QWindowSystemInterface::handleKeyEvent(0, ev.down ? QEvent::KeyPress : QEvent::KeyRelease, ev.keycode, m_keymod, QString(ev.unicode));
+ QWindowSystemInterface::handleKeyEvent(nullptr, ev.down ? QEvent::KeyPress : QEvent::KeyRelease, ev.keycode, m_keymod, QString(ev.unicode));
m_handleMsg = false;
}
}
diff --git a/src/plugins/platforms/vnc/qvncscreen.cpp b/src/plugins/platforms/vnc/qvncscreen.cpp
index 2eca18fb4d..5dc3919ff5 100644
--- a/src/plugins/platforms/vnc/qvncscreen.cpp
+++ b/src/plugins/platforms/vnc/qvncscreen.cpp
@@ -101,7 +101,7 @@ bool QVncScreen::initialize()
default:
qWarning("QVNCScreen::initDevice: No support for screen depth %d",
depth());
- dirty = 0;
+ dirty = nullptr;
return false;
}
diff --git a/src/plugins/platforms/wasm/qwasmbackingstore.cpp b/src/plugins/platforms/wasm/qwasmbackingstore.cpp
index 7e8a382512..a7423e9c47 100644
--- a/src/plugins/platforms/wasm/qwasmbackingstore.cpp
+++ b/src/plugins/platforms/wasm/qwasmbackingstore.cpp
@@ -31,7 +31,7 @@
#include "qwasmwindow.h"
#include "qwasmcompositor.h"
-#include <QtGui/qopengltexture.h>
+#include <QtOpenGL/qopengltexture.h>
#include <QtGui/qmatrix4x4.h>
#include <QtGui/qpainter.h>
#include <private/qguiapplication_p.h>
diff --git a/src/plugins/platforms/wasm/qwasmclipboard.cpp b/src/plugins/platforms/wasm/qwasmclipboard.cpp
index d4a1e4dd50..f02c2c6ccb 100644
--- a/src/plugins/platforms/wasm/qwasmclipboard.cpp
+++ b/src/plugins/platforms/wasm/qwasmclipboard.cpp
@@ -29,6 +29,7 @@
#include "qwasmclipboard.h"
#include "qwasmwindow.h"
+#include "qwasmstring.h"
#include <emscripten.h>
#include <emscripten/html5.h>
@@ -40,22 +41,22 @@
using namespace emscripten;
// there has got to be a better way...
-static QByteArray g_clipboardArray;
-static QByteArray g_clipboardFormat;
+static QString g_clipboardText;
+static QString g_clipboardFormat;
static val getClipboardData()
{
- return val(g_clipboardArray.constData());
+ return QWasmString::fromQString(g_clipboardText);
}
static val getClipboardFormat()
{
- return val(g_clipboardFormat.constData());
+ return QWasmString::fromQString(g_clipboardFormat);
}
static void pasteClipboardData(emscripten::val format, emscripten::val dataPtr)
{
- QString formatString = QString::fromStdString(format.as<std::string>());
+ QString formatString = QWasmString::toQString(format);
QByteArray dataArray = QByteArray::fromStdString(dataPtr.as<std::string>());
QMimeData *mMimeData = new QMimeData;
mMimeData->setData(formatString, dataArray);
@@ -102,11 +103,10 @@ static void qClipboardPasteTo(val event)
bool hasClipboardApi = QWasmIntegration::get()->getWasmClipboard()->hasClipboardApi;
val clipdata = hasClipboardApi ?
val::global("Module").call<val>("qtGetClipboardData") :
- event["clipboardData"].call<val>("getData", std::string("text"));
+ event["clipboardData"].call<val>("getData", val("text"));
- const std::string data = clipdata.as<std::string>();
- if (data.length() > 0) {
- QString qstr = QString::fromStdString(data);
+ const QString qstr = QWasmString::toQString(clipdata);
+ if (qstr.length() > 0) {
QMimeData *mMimeData = new QMimeData;
mMimeData->setText(qstr);
QWasmClipboard::qWasmClipboardPaste(mMimeData);
@@ -133,7 +133,7 @@ QWasmClipboard::QWasmClipboard()
QWasmClipboard::~QWasmClipboard()
{
- g_clipboardArray.clear();
+ g_clipboardText.clear();
g_clipboardFormat.clear();
}
@@ -148,11 +148,11 @@ QMimeData* QWasmClipboard::mimeData(QClipboard::Mode mode)
void QWasmClipboard::setMimeData(QMimeData* mimeData, QClipboard::Mode mode)
{
if (mimeData->hasText()) {
- g_clipboardFormat = mimeData->formats().at(0).toUtf8();
- g_clipboardArray = mimeData->text().toUtf8();
+ g_clipboardFormat = mimeData->formats().at(0);
+ g_clipboardText = mimeData->text();
} else if (mimeData->hasHtml()) {
- g_clipboardFormat =mimeData->formats().at(0).toUtf8();
- g_clipboardArray = mimeData->html().toUtf8();
+ g_clipboardFormat = mimeData->formats().at(0);
+ g_clipboardText = mimeData->html();
}
QPlatformClipboard::setMimeData(mimeData, mode);
@@ -198,12 +198,14 @@ void QWasmClipboard::installEventHandlers(const QString &canvasId)
return;
// Fallback path for browsers which do not support direct clipboard access
- val canvas = val::global(canvasId.toUtf8().constData());
- canvas.call<void>("addEventListener", std::string("cut"),
+ val document = val::global("document");
+ val canvas = document.call<val>("getElementById", QWasmString::fromQString(canvasId));
+
+ canvas.call<void>("addEventListener", val("cut"),
val::module_property("qtClipboardCutTo"));
- canvas.call<void>("addEventListener", std::string("copy"),
+ canvas.call<void>("addEventListener", val("copy"),
val::module_property("qtClipboardCopyTo"));
- canvas.call<void>("addEventListener", std::string("paste"),
+ canvas.call<void>("addEventListener", val("paste"),
val::module_property("qtClipboardPasteTo"));
}
@@ -224,6 +226,6 @@ void QWasmClipboard::writeTextToClipboard()
val txt = module.call<val>("qtGetClipboardData");
val format = module.call<val>("qtGetClipboardFormat");
val navigator = val::global("navigator");
- navigator["clipboard"].call<void>("writeText", txt.as<std::string>());
+ navigator["clipboard"].call<void>("writeText", txt);
}
}
diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp
index a810880c43..74890ead82 100644
--- a/src/plugins/platforms/wasm/qwasmcompositor.cpp
+++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp
@@ -31,12 +31,11 @@
#include "qwasmwindow.h"
#include "qwasmstylepixmaps_p.h"
-#include <QtGui/qopengltexture.h>
+#include <QtOpenGL/qopengltexture.h>
#include <QtGui/private/qwindow_p.h>
#include <QtGui/qopenglcontext.h>
#include <QtGui/qopenglfunctions.h>
-#include <QtGui/qopengltextureblitter.h>
#include <QtGui/qoffscreensurface.h>
#include <QtGui/qpainter.h>
#include <private/qpixmapcache_p.h>
@@ -694,7 +693,7 @@ void QWasmCompositor::frame()
if (m_context.isNull()) {
m_context.reset(new QOpenGLContext());
- //mContext->setFormat(mScreen->format());
+ m_context->setFormat(someWindow->window()->requestedFormat());
m_context->setScreen(screen()->screen());
m_context->create();
}
diff --git a/src/plugins/platforms/wasm/qwasmcompositor.h b/src/plugins/platforms/wasm/qwasmcompositor.h
index 98f4a79b27..250d244c9f 100644
--- a/src/plugins/platforms/wasm/qwasmcompositor.h
+++ b/src/plugins/platforms/wasm/qwasmcompositor.h
@@ -33,8 +33,7 @@
#include <QtGui/qregion.h>
#include <qpa/qplatformwindow.h>
-#include <QtGui/qopengltextureblitter.h>
-#include <QtGui/qopengltexture.h>
+#include <QtOpenGL/qopengltextureblitter.h>
#include <QtGui/qpalette.h>
#include <QtGui/qpainter.h>
@@ -43,7 +42,7 @@ QT_BEGIN_NAMESPACE
class QWasmWindow;
class QWasmScreen;
class QOpenGLContext;
-class QOpenGLTextureBlitter;
+class QOpenGLTexture;
class QWasmCompositedWindow
{
diff --git a/src/plugins/platforms/wasm/qwasmcursor.cpp b/src/plugins/platforms/wasm/qwasmcursor.cpp
index 2b3f37300d..616456b2fa 100644
--- a/src/plugins/platforms/wasm/qwasmcursor.cpp
+++ b/src/plugins/platforms/wasm/qwasmcursor.cpp
@@ -29,6 +29,7 @@
#include "qwasmcursor.h"
#include "qwasmscreen.h"
+#include "qwasmstring.h"
#include <QtCore/qdebug.h>
#include <QtGui/qwindow.h>
@@ -36,6 +37,8 @@
#include <emscripten/emscripten.h>
#include <emscripten/bind.h>
+using namespace emscripten;
+
void QWasmCursor::changeCursor(QCursor *windowCursor, QWindow *window)
{
if (!windowCursor || !window)
@@ -54,9 +57,11 @@ void QWasmCursor::changeCursor(QCursor *windowCursor, QWindow *window)
htmlCursorName = "auto";
// Set cursor on the canvas
- QString canvasId = QWasmScreen::get(screen)->canvasId();
- emscripten::val canvasStyle = emscripten::val::global(canvasId.toUtf8().constData())["style"];
- canvasStyle.set("cursor", emscripten::val(htmlCursorName.constData()));
+ val jsCanvasId = QWasmString::fromQString(QWasmScreen::get(screen)->canvasId());
+ val document = val::global("document");
+ val canvas = document.call<val>("getElementById", jsCanvasId);
+ val canvasStyle = canvas["style"];
+ canvasStyle.set("cursor", val(htmlCursorName.constData()));
}
QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape)
@@ -68,6 +73,7 @@ QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape)
cursorName = "default";
break;
case Qt::UpArrowCursor:
+ cursorName = "n-resize";
break;
case Qt::CrossCursor:
cursorName = "crosshair";
@@ -91,7 +97,8 @@ QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape)
cursorName = "nwse-resize";
break;
case Qt::SizeAllCursor:
- break; // no equivalent?
+ cursorName = "move";
+ break;
case Qt::BlankCursor:
cursorName = "none";
break;
@@ -111,18 +118,23 @@ QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape)
cursorName = "help";
break;
case Qt::BusyCursor:
- cursorName = "wait";
+ cursorName = "progress";
break;
case Qt::OpenHandCursor:
- break; // no equivalent?
+ cursorName = "grab";
+ break;
case Qt::ClosedHandCursor:
- break; // no equivalent?
+ cursorName = "grabbing";
+ break;
case Qt::DragCopyCursor:
- break; // no equivalent?
+ cursorName = "copy";
+ break;
case Qt::DragMoveCursor:
- break; // no equivalent?
+ cursorName = "default";
+ break;
case Qt::DragLinkCursor:
- break; // no equivalent?
+ cursorName = "alias";
+ break;
default:
break;
}
diff --git a/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp
index 41355d72ae..ca8db9b215 100644
--- a/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp
+++ b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp
@@ -33,6 +33,16 @@
#include <emscripten.h>
+#if QT_CONFIG(thread)
+#if (__EMSCRIPTEN_major__ > 1 || __EMSCRIPTEN_minor__ > 38 || __EMSCRIPTEN_minor__ == 38 && __EMSCRIPTEN_tiny__ >= 22)
+# define EMSCRIPTEN_HAS_ASYNC_RUN_IN_MAIN_RUNTIME_THREAD
+#endif
+#endif
+
+#ifdef EMSCRIPTEN_HAS_ASYNC_RUN_IN_MAIN_RUNTIME_THREAD
+#include <emscripten/threading.h>
+#endif
+
class QWasmEventDispatcherPrivate : public QEventDispatcherUNIXPrivate
{
@@ -179,3 +189,18 @@ void QWasmEventDispatcher::doMaintainTimers()
emscripten_async_call(callback, this, toWaitDuration);
m_currentTargetTime = newTargetTime;
}
+
+void QWasmEventDispatcher::wakeUp()
+{
+#ifdef EMSCRIPTEN_HAS_ASYNC_RUN_IN_MAIN_RUNTIME_THREAD
+ if (!emscripten_is_main_runtime_thread())
+ emscripten_async_run_in_main_runtime_thread_(EM_FUNC_SIG_VI, (void*)(&QWasmEventDispatcher::mainThreadWakeUp), this);
+#endif
+ QEventDispatcherUNIX::wakeUp();
+}
+
+void QWasmEventDispatcher::mainThreadWakeUp(void *eventDispatcher)
+{
+ emscripten_resume_main_loop(); // Service possible requestUpdate Calls
+ static_cast<QWasmEventDispatcher *>(eventDispatcher)->processEvents(QEventLoop::AllEvents);
+}
diff --git a/src/plugins/platforms/wasm/qwasmeventdispatcher.h b/src/plugins/platforms/wasm/qwasmeventdispatcher.h
index 5300b3de73..f72d92ce07 100644
--- a/src/plugins/platforms/wasm/qwasmeventdispatcher.h
+++ b/src/plugins/platforms/wasm/qwasmeventdispatcher.h
@@ -51,6 +51,8 @@ public:
protected:
bool processEvents(QEventLoop::ProcessEventsFlags flags) override;
void doMaintainTimers();
+ void wakeUp() override;
+ static void mainThreadWakeUp(void *eventDispatcher);
private:
bool m_hasMainLoop = false;
diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
index ad94ba9c77..d99c202c48 100644
--- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
+++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp
@@ -32,6 +32,7 @@
#include "qwasmcompositor.h"
#include "qwasmintegration.h"
#include "qwasmclipboard.h"
+#include "qwasmstring.h"
#include <QtGui/qevent.h>
#include <qpa/qwindowsysteminterface.h>
@@ -47,9 +48,10 @@
#include <iostream>
-QT_BEGIN_NAMESPACE
using namespace emscripten;
+QT_BEGIN_NAMESPACE
+
typedef struct emkb2qt {
const char *em;
unsigned int qt;
@@ -353,10 +355,12 @@ void QWasmEventTranslator::initEventHandlers()
g_useNaturalScrolling = false; // make this !default on macOS
if (emscripten::val::global("window")["safari"].isUndefined()) {
-
- emscripten::val::global(canvasId).call<void>("addEventListener",
- std::string("wheel"),
- val::module_property("qtMouseWheelEvent"));
+ val document = val::global("document");
+ val jsCanvasId = QWasmString::fromQString(screen()->canvasId());
+ val canvas = document.call<val>("getElementById", jsCanvasId);
+ canvas.call<void>("addEventListener",
+ val("wheel"),
+ val::module_property("qtMouseWheelEvent"));
}
}
@@ -544,7 +548,7 @@ void resizeWindow(QWindow *window, QWasmWindow::ResizeMode mode,
void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEvent *mouseEvent)
{
- auto timestamp = mouseEvent->timestamp;
+ auto timestamp = emscripten_date_now();
QPoint targetPoint(mouseEvent->targetX, mouseEvent->targetY);
QPoint globalPoint = screen()->geometry().topLeft() + targetPoint;
@@ -670,7 +674,7 @@ int QWasmEventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *wh
QWasmEventTranslator *translator = (QWasmEventTranslator*)userData;
Qt::KeyboardModifiers modifiers = translator->translateMouseEventModifier(&mouseEvent);
- auto timestamp = mouseEvent.timestamp;
+ auto timestamp = emscripten_date_now();
QPoint targetPoint(mouseEvent.targetX, mouseEvent.targetY);
QPoint globalPoint = eventTranslator->screen()->geometry().topLeft() + targetPoint;
diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp
index 1e9f68027c..ce83ad4e2f 100644
--- a/src/plugins/platforms/wasm/qwasmintegration.cpp
+++ b/src/plugins/platforms/wasm/qwasmintegration.cpp
@@ -36,10 +36,12 @@
#include "qwasmclipboard.h"
#include "qwasmservices.h"
#include "qwasmoffscreensurface.h"
+#include "qwasmstring.h"
#include "qwasmwindow.h"
#ifndef QT_NO_OPENGL
# include "qwasmbackingstore.h"
+# include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h>
#endif
#include "qwasmfontdatabase.h"
#if defined(Q_OS_UNIX)
@@ -67,19 +69,19 @@ static void browserBeforeUnload(emscripten::val)
static void addCanvasElement(emscripten::val canvas)
{
- QString canvasId = QString::fromStdString(canvas["id"].as<std::string>());
+ QString canvasId = QWasmString::toQString(canvas["id"]);
QWasmIntegration::get()->addScreen(canvasId);
}
static void removeCanvasElement(emscripten::val canvas)
{
- QString canvasId = QString::fromStdString(canvas["id"].as<std::string>());
+ QString canvasId = QWasmString::toQString(canvas["id"]);
QWasmIntegration::get()->removeScreen(canvasId);
}
static void resizeCanvasElement(emscripten::val canvas)
{
- QString canvasId = QString::fromStdString(canvas["id"].as<std::string>());
+ QString canvasId = QWasmString::toQString(canvas["id"]);
QWasmIntegration::get()->resizeScreen(canvasId);
}
@@ -115,11 +117,11 @@ QWasmIntegration::QWasmIntegration()
int screenCount = qtCanvaseElements["length"].as<int>();
for (int i = 0; i < screenCount; ++i) {
emscripten::val canvas = qtCanvaseElements[i].as<emscripten::val>();
- QString canvasId = QString::fromStdString(canvas["id"].as<std::string>());
+ QString canvasId = QWasmString::toQString(canvas["id"]);
addScreen(canvasId);
}
} else if (!canvas.isUndefined()){
- QString canvasId = QString::fromStdString(canvas["id"].as<std::string>());
+ QString canvasId = QWasmString::toQString(canvas["id"]);
addScreen(canvasId);
}
@@ -184,6 +186,7 @@ QPlatformBackingStore *QWasmIntegration::createPlatformBackingStore(QWindow *win
#ifndef QT_NO_OPENGL
QWasmCompositor *compositor = QWasmScreen::get(window->screen())->compositor();
QWasmBackingStore *backingStore = new QWasmBackingStore(compositor, window);
+ backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
m_backingStores.insert(window, backingStore);
return backingStore;
#else
diff --git a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp
index 62087f54bd..501ab99116 100644
--- a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp
+++ b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp
@@ -30,6 +30,7 @@
#include "qwasmopenglcontext.h"
#include "qwasmintegration.h"
#include <EGL/egl.h>
+#include <emscripten/val.h>
QT_BEGIN_NAMESPACE
@@ -50,7 +51,13 @@ QWasmOpenGLContext::QWasmOpenGLContext(const QSurfaceFormat &format)
QWasmOpenGLContext::~QWasmOpenGLContext()
{
if (m_context) {
+ // Destroy GL context. Work around bug in emscripten_webgl_destroy_context
+ // which removes all event handlers on the canvas by temporarily removing
+ // emscripten's JSEvents global object.
+ emscripten::val jsEvents = emscripten::val::global("window")["JSEvents"];
+ emscripten::val::global("window").set("JSEvents", emscripten::val::undefined());
emscripten_webgl_destroy_context(m_context);
+ emscripten::val::global("window").set("JSEvents", jsEvents);
m_context = 0;
}
}
@@ -99,7 +106,7 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE QWasmOpenGLContext::createEmscriptenContext(cons
attributes.depth = useDepthStencil;
attributes.stencil = useDepthStencil;
- EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(canvasId.toLocal8Bit().constData(), &attributes);
+ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(canvasId.toUtf8().constData(), &attributes);
return context;
}
diff --git a/src/plugins/platforms/wasm/qwasmscreen.cpp b/src/plugins/platforms/wasm/qwasmscreen.cpp
index e536bc0ee3..5e6f94b9ed 100644
--- a/src/plugins/platforms/wasm/qwasmscreen.cpp
+++ b/src/plugins/platforms/wasm/qwasmscreen.cpp
@@ -32,6 +32,8 @@
#include "qwasmeventtranslator.h"
#include "qwasmcompositor.h"
#include "qwasmintegration.h"
+#include "qwasmstring.h"
+
#include <emscripten/bind.h>
#include <emscripten/val.h>
@@ -44,6 +46,7 @@
#include <QtGui/qguiapplication.h>
#include <private/qhighdpiscaling_p.h>
+using namespace emscripten;
QT_BEGIN_NAMESPACE
@@ -54,6 +57,8 @@ QWasmScreen::QWasmScreen(const QString &canvasId)
m_compositor = new QWasmCompositor(this);
m_eventTranslator = new QWasmEventTranslator(this);
updateQScreenAndCanvasRenderSize();
+ emscripten::val canvas = emscripten::val::global(m_canvasId.toUtf8().constData());
+ canvas.call<void>("focus");
}
QWasmScreen::~QWasmScreen()
@@ -182,12 +187,18 @@ void QWasmScreen::updateQScreenAndCanvasRenderSize()
QSizeF cssSize(css_width, css_height);
QSizeF canvasSize = cssSize * devicePixelRatio();
- emscripten::val canvas = emscripten::val::global(canvasId.constData());
+ val document = val::global("document");
+ val canvas = document.call<val>("getElementById", QWasmString::fromQString(m_canvasId));
+
canvas.set("width", canvasSize.width());
canvas.set("height", canvasSize.height());
+ QPoint offset;
+ offset.setX(canvas["offsetTop"].as<int>());
+ offset.setY(canvas["offsetLeft"].as<int>());
+
emscripten::val rect = canvas.call<emscripten::val>("getBoundingClientRect");
- QPoint position(rect["left"].as<int>(), rect["top"].as<int>());
+ QPoint position(rect["left"].as<int>() - offset.x(), rect["top"].as<int>() - offset.y());
setGeometry(QRect(position, cssSize.toSize()));
m_compositor->redrawWindowContent();
diff --git a/src/plugins/platforms/wasm/qwasmservices.cpp b/src/plugins/platforms/wasm/qwasmservices.cpp
index 9328b8c065..4eee3fe972 100644
--- a/src/plugins/platforms/wasm/qwasmservices.cpp
+++ b/src/plugins/platforms/wasm/qwasmservices.cpp
@@ -28,6 +28,8 @@
****************************************************************************/
#include "qwasmservices.h"
+#include "qwasmstring.h"
+
#include <QtCore/QUrl>
#include <QtCore/QDebug>
@@ -37,8 +39,8 @@ QT_BEGIN_NAMESPACE
bool QWasmServices::openUrl(const QUrl &url)
{
- QByteArray utf8Url = url.toString().toUtf8();
- emscripten::val::global("window").call<void>("open", emscripten::val(utf8Url.constData()), emscripten::val("_blank"));
+ emscripten::val jsUrl = QWasmString::fromQString(url.toString());
+ emscripten::val::global("window").call<void>("open", jsUrl, emscripten::val("_blank"));
return true;
}
diff --git a/src/plugins/platforms/wasm/qwasmstring.cpp b/src/plugins/platforms/wasm/qwasmstring.cpp
new file mode 100644
index 0000000000..05b571c459
--- /dev/null
+++ b/src/plugins/platforms/wasm/qwasmstring.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwasmstring.h"
+
+QT_BEGIN_NAMESPACE
+
+using namespace emscripten;
+
+val QWasmString::fromQString(const QString &str)
+{
+ static const val UTF16ToString(
+ val::global("Module")["UTF16ToString"]);
+
+ auto ptr = quintptr(str.utf16());
+ return UTF16ToString(val(ptr));
+}
+
+QString QWasmString::toQString(const val &v)
+{
+ QString result;
+ if (!v.isString())
+ return result;
+
+ static const val stringToUTF16(
+ val::global("Module")["stringToUTF16"]);
+ static const val length("length");
+
+ result.resize(v[length].as<int>());
+ auto ptr = quintptr(result.utf16());
+ stringToUTF16(v, val(ptr));
+ return result;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wasm/qwasmstring.h b/src/plugins/platforms/wasm/qwasmstring.h
new file mode 100644
index 0000000000..de5da92830
--- /dev/null
+++ b/src/plugins/platforms/wasm/qwasmstring.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#pragma once
+
+#include <qstring.h>
+
+#include <emscripten/val.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWasmString
+{
+public:
+ static emscripten::val fromQString(const QString &str);
+ static QString toQString(const emscripten::val &v);
+};
+QT_END_NAMESPACE
+
diff --git a/src/plugins/platforms/wasm/wasm.pro b/src/plugins/platforms/wasm/wasm.pro
index f8c8175525..1aee4a3e58 100644
--- a/src/plugins/platforms/wasm/wasm.pro
+++ b/src/plugins/platforms/wasm/wasm.pro
@@ -4,6 +4,8 @@ QT += \
core-private gui-private \
eventdispatcher_support-private fontdatabase_support-private egl_support-private
+qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private
+
# Avoid X11 header collision, use generic EGL native types
DEFINES += QT_EGL_NO_X11
@@ -23,7 +25,8 @@ SOURCES = \
qwasmtheme.cpp \
qwasmclipboard.cpp \
qwasmservices.cpp \
- qwasmoffscreensurface.cpp
+ qwasmoffscreensurface.cpp \
+ qwasmstring.cpp
HEADERS = \
qwasmintegration.h \
@@ -39,7 +42,8 @@ HEADERS = \
qwasmtheme.h \
qwasmclipboard.h \
qwasmservices.h \
- qwasmoffscreensurface.h
+ qwasmoffscreensurface.h \
+ qwasmstring.h
wasmfonts.files = \
../../../3rdparty/wasm/Vera.ttf \
@@ -50,6 +54,7 @@ wasmfonts.base = ../../../3rdparty/wasm
RESOURCES += wasmfonts
qtConfig(opengl) {
+ QT += opengl
SOURCES += qwasmbackingstore.cpp
HEADERS += qwasmbackingstore.h
}
diff --git a/src/plugins/platforms/wasm/wasm_shell.html b/src/plugins/platforms/wasm/wasm_shell.html
index a118c217f3..d4bf632830 100644
--- a/src/plugins/platforms/wasm/wasm_shell.html
+++ b/src/plugins/platforms/wasm/wasm_shell.html
@@ -17,7 +17,7 @@
<body onload="init()">
<figure style="overflow:visible;" id="qtspinner">
<center style="margin-top:1.5em; line-height:150%">
- <img src="qtlogo.svg"; width=320; height=200; style="display:block"> </img>
+ <img src="qtlogo.svg" width="320" height="200" style="display:block"></img>
<strong>Qt for WebAssembly: @APPNAME@</strong>
<div id="qtstatus"></div>
<noscript>JavaScript is disabled. Please enable JavaScript to use this application.</noscript>
diff --git a/src/plugins/platforms/windows/.prev_CMakeLists.txt b/src/plugins/platforms/windows/.prev_CMakeLists.txt
index c5ea83e470..57b7fede9f 100644
--- a/src/plugins/platforms/windows/.prev_CMakeLists.txt
+++ b/src/plugins/platforms/windows/.prev_CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from windows.pro.
#####################################################################
-## qwindows Plugin:
+## QWindowsIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qwindows
+qt_add_plugin(QWindowsIntegrationPlugin
+ OUTPUT_NAME qwindows
TYPE platforms
- CLASS_NAME QWindowsIntegrationPlugin
SOURCES
main.cpp
qtwindowsglobal.h
@@ -41,11 +41,6 @@ add_qt_plugin(qwindows
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}
LIBRARIES
- Qt::CorePrivate
- Qt::EventDispatcherSupportPrivate
- Qt::FontDatabaseSupportPrivate
- Qt::GuiPrivate
- Qt::ThemeSupportPrivate
advapi32
d3d9
gdi32
@@ -55,10 +50,12 @@ add_qt_plugin(qwindows
winmm
PUBLIC_LIBRARIES
Qt::Core
- Qt::EventDispatcherSupport
- Qt::FontDatabaseSupport
+ Qt::CorePrivate
+ Qt::EventDispatcherSupportPrivate
+ Qt::FontDatabaseSupportPrivate
Qt::Gui
- Qt::ThemeSupport
+ Qt::GuiPrivate
+ Qt::ThemeSupportPrivate
dwmapi
imm32
oleaut32
@@ -75,7 +72,7 @@ set(openglblacklists_resource_files
"openglblacklists/default.json"
)
-add_qt_resource(qwindows "openglblacklists"
+qt_add_resource(QWindowsIntegrationPlugin "openglblacklists"
PREFIX
"/qt-project.org/windows/openglblacklists"
FILES
@@ -85,12 +82,16 @@ add_qt_resource(qwindows "openglblacklists"
#### Keys ignored in scope 1:.:.:windows.pro:<TRUE>:
# OTHER_FILES = "windows.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qwindows CONDITION QT_FEATURE_accessibility
+qt_extend_target(QWindowsIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate
+ PUBLIC_LIBRARIES
+ Qt::PlatformCompositorSupportPrivate
+)
+
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_accessibility
SOURCES
uiautomation/qwindowsuiaaccessibility.cpp uiautomation/qwindowsuiaaccessibility.h
uiautomation/qwindowsuiabaseprovider.cpp uiautomation/qwindowsuiabaseprovider.h
@@ -110,133 +111,128 @@ extend_target(qwindows CONDITION QT_FEATURE_accessibility
uiautomation/qwindowsuiautils.cpp uiautomation/qwindowsuiautils.h
uiautomation/qwindowsuiavalueprovider.cpp uiautomation/qwindowsuiavalueprovider.h
uiautomation/qwindowsuiawindowprovider.cpp uiautomation/qwindowsuiawindowprovider.h
- LIBRARIES
- Qt::AccessibilitySupportPrivate
PUBLIC_LIBRARIES
- Qt::AccessibilitySupport
+ Qt::AccessibilitySupportPrivate
)
-extend_target(qwindows CONDITION QT_FEATURE_vulkan
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_vulkan
SOURCES
qwindowsvulkaninstance.cpp qwindowsvulkaninstance.h
- LIBRARIES
- Qt::VulkanSupportPrivate
PUBLIC_LIBRARIES
- Qt::VulkanSupport
+ Qt::VulkanSupportPrivate
)
-#### Keys ignored in scope 4:.:.:windows.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
+#### Keys ignored in scope 5:.:.:windows.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
# PLUGIN_EXTENDS = "-"
-extend_target(qwindows CONDITION QT_FEATURE_opengl AND NOT QT_FEATURE_dynamicgl AND NOT QT_FEATURE_opengles2
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_opengl AND NOT QT_FEATURE_dynamicgl AND NOT QT_FEATURE_opengles2
PUBLIC_LIBRARIES
opengl32
)
-extend_target(qwindows CONDITION mingw
+qt_extend_target(QWindowsIntegrationPlugin CONDITION mingw
PUBLIC_LIBRARIES
uuid
)
-extend_target(qwindows CONDITION QT_FEATURE_opengl
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_opengl
SOURCES
qwindowsopenglcontext.h
)
-extend_target(qwindows CONDITION QT_FEATURE_opengles2
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_opengles2
SOURCES
qwindowseglcontext.cpp qwindowseglcontext.h
)
-extend_target(qwindows CONDITION QT_FEATURE_opengl AND NOT QT_FEATURE_opengles2
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_opengl AND NOT QT_FEATURE_opengles2
SOURCES
qwindowsglcontext.cpp qwindowsglcontext.h
)
-extend_target(qwindows CONDITION QT_FEATURE_dynamicgl
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_dynamicgl
SOURCES
qwindowseglcontext.cpp qwindowseglcontext.h
)
-extend_target(qwindows CONDITION QT_FEATURE_systemtrayicon
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_systemtrayicon
SOURCES
qwindowssystemtrayicon.cpp qwindowssystemtrayicon.h
)
-extend_target(qwindows CONDITION QT_FEATURE_clipboard
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_clipboard
SOURCES
qwindowsclipboard.cpp qwindowsclipboard.h
)
-extend_target(qwindows CONDITION QT_FEATURE_clipboard AND QT_FEATURE_draganddrop
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_clipboard AND QT_FEATURE_draganddrop
SOURCES
qwindowsdrag.cpp qwindowsdrag.h
)
-extend_target(qwindows CONDITION QT_FEATURE_tabletevent
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_tabletevent
SOURCES
qwindowstabletsupport.cpp qwindowstabletsupport.h
INCLUDE_DIRECTORIES
${QT_SOURCE_TREE}/src/3rdparty/wintab
)
-extend_target(qwindows CONDITION QT_FEATURE_sessionmanager
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_sessionmanager
SOURCES
qwindowssessionmanager.cpp qwindowssessionmanager.h
)
-# Resources:
-set(cursors_resource_files
- "images/closedhandcursor_32.png"
- "images/closedhandcursor_48.png"
- "images/closedhandcursor_64.png"
- "images/dragcopycursor_32.png"
- "images/dragcopycursor_48.png"
- "images/dragcopycursor_64.png"
- "images/draglinkcursor_32.png"
- "images/draglinkcursor_48.png"
- "images/draglinkcursor_64.png"
- "images/dragmovecursor_32.png"
- "images/dragmovecursor_48.png"
- "images/dragmovecursor_64.png"
- "images/openhandcursor_32.png"
- "images/openhandcursor_48.png"
- "images/openhandcursor_64.png"
- "images/splithcursor_32.png"
- "images/splithcursor_48.png"
- "images/splithcursor_64.png"
- "images/splitvcursor_32.png"
- "images/splitvcursor_48.png"
- "images/splitvcursor_64.png"
-)
-
-add_qt_resource(qwindows "cursors"
- PREFIX
- "/qt-project.org/windows/cursors"
- FILES
- ${cursors_resource_files}
-)
-
-
-extend_target(qwindows CONDITION QT_FEATURE_accessibility AND TARGET Qt::WindowsUIAutomationSupportPrivate
- LIBRARIES
- Qt::WindowsUIAutomationSupportPrivate
+if(QT_FEATURE_imageformat_png)
+ # Resources:
+ set(cursors_resource_files
+ "images/closedhandcursor_32.png"
+ "images/closedhandcursor_48.png"
+ "images/closedhandcursor_64.png"
+ "images/dragcopycursor_32.png"
+ "images/dragcopycursor_48.png"
+ "images/dragcopycursor_64.png"
+ "images/draglinkcursor_32.png"
+ "images/draglinkcursor_48.png"
+ "images/draglinkcursor_64.png"
+ "images/dragmovecursor_32.png"
+ "images/dragmovecursor_48.png"
+ "images/dragmovecursor_64.png"
+ "images/openhandcursor_32.png"
+ "images/openhandcursor_48.png"
+ "images/openhandcursor_64.png"
+ "images/splithcursor_32.png"
+ "images/splithcursor_48.png"
+ "images/splithcursor_64.png"
+ "images/splitvcursor_32.png"
+ "images/splitvcursor_48.png"
+ "images/splitvcursor_64.png"
+ )
+
+ qt_add_resource(QWindowsIntegrationPlugin "cursors"
+ PREFIX
+ "/qt-project.org/windows/cursors"
+ FILES
+ ${cursors_resource_files}
+ )
+endif()
+
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_accessibility AND TARGET Qt::WindowsUIAutomationSupportPrivate
PUBLIC_LIBRARIES
- Qt::WindowsUIAutomationSupport
+ Qt::WindowsUIAutomationSupportPrivate
)
-extend_target(qwindows CONDITION QT_FEATURE_accessibility AND mingw
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_accessibility AND mingw
PUBLIC_LIBRARIES
uuid
)
-extend_target(qwindows CONDITION QT_FEATURE_combined_angle_lib
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_combined_angle_lib
DEFINES
LIBEGL_NAME=
LIBGLESV2_NAME=
)
-extend_target(qwindows CONDITION NOT QT_FEATURE_combined_angle_lib
+qt_extend_target(QWindowsIntegrationPlugin CONDITION NOT QT_FEATURE_combined_angle_lib
DEFINES
LIBEGL_NAME=
LIBGLESV2_NAME=
diff --git a/src/plugins/platforms/windows/CMakeLists.txt b/src/plugins/platforms/windows/CMakeLists.txt
index 18764124e4..0c903d8757 100644
--- a/src/plugins/platforms/windows/CMakeLists.txt
+++ b/src/plugins/platforms/windows/CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from windows.pro.
#####################################################################
-## qwindows Plugin:
+## QWindowsIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qwindows
+qt_add_plugin(QWindowsIntegrationPlugin
+ OUTPUT_NAME qwindows
TYPE platforms
- CLASS_NAME QWindowsIntegrationPlugin
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES windows # special case
SOURCES
main.cpp
@@ -42,11 +42,6 @@ add_qt_plugin(qwindows
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}
LIBRARIES
- Qt::CorePrivate
- Qt::EventDispatcherSupportPrivate
- Qt::FontDatabaseSupportPrivate
- Qt::GuiPrivate
- Qt::ThemeSupportPrivate
advapi32
d3d9
gdi32
@@ -56,10 +51,12 @@ add_qt_plugin(qwindows
winmm
PUBLIC_LIBRARIES
Qt::Core
- Qt::EventDispatcherSupport
- Qt::FontDatabaseSupport
+ Qt::CorePrivate
+ Qt::EventDispatcherSupportPrivate
+ Qt::FontDatabaseSupportPrivate
Qt::Gui
- Qt::ThemeSupport
+ Qt::GuiPrivate
+ Qt::ThemeSupportPrivate
dwmapi
imm32
oleaut32
@@ -76,7 +73,7 @@ set(openglblacklists_resource_files
"openglblacklists/default.json"
)
-add_qt_resource(qwindows "openglblacklists"
+qt_add_resource(QWindowsIntegrationPlugin "openglblacklists"
PREFIX
"/qt-project.org/windows/openglblacklists"
FILES
@@ -86,12 +83,16 @@ add_qt_resource(qwindows "openglblacklists"
#### Keys ignored in scope 1:.:.:windows.pro:<TRUE>:
# OTHER_FILES = "windows.json"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-extend_target(qwindows CONDITION QT_FEATURE_accessibility
+qt_extend_target(QWindowsIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate
+ PUBLIC_LIBRARIES
+ Qt::PlatformCompositorSupportPrivate
+)
+
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_accessibility
SOURCES
uiautomation/qwindowsuiaaccessibility.cpp uiautomation/qwindowsuiaaccessibility.h
uiautomation/qwindowsuiabaseprovider.cpp uiautomation/qwindowsuiabaseprovider.h
@@ -111,126 +112,122 @@ extend_target(qwindows CONDITION QT_FEATURE_accessibility
uiautomation/qwindowsuiautils.cpp uiautomation/qwindowsuiautils.h
uiautomation/qwindowsuiavalueprovider.cpp uiautomation/qwindowsuiavalueprovider.h
uiautomation/qwindowsuiawindowprovider.cpp uiautomation/qwindowsuiawindowprovider.h
- LIBRARIES
- Qt::AccessibilitySupportPrivate
PUBLIC_LIBRARIES
- Qt::AccessibilitySupport
+ Qt::AccessibilitySupportPrivate
)
-extend_target(qwindows CONDITION QT_FEATURE_vulkan
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_vulkan
SOURCES
qwindowsvulkaninstance.cpp qwindowsvulkaninstance.h
- LIBRARIES
- Qt::VulkanSupportPrivate
PUBLIC_LIBRARIES
- Qt::VulkanSupport
+ Qt::VulkanSupportPrivate
)
-#### Keys ignored in scope 4:.:.:windows.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
+#### Keys ignored in scope 5:.:.:windows.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
# PLUGIN_EXTENDS = "-"
-extend_target(qwindows CONDITION QT_FEATURE_opengl AND NOT QT_FEATURE_dynamicgl AND NOT QT_FEATURE_opengles2
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_opengl AND NOT QT_FEATURE_dynamicgl AND NOT QT_FEATURE_opengles2
PUBLIC_LIBRARIES
opengl32
)
-extend_target(qwindows CONDITION mingw
+qt_extend_target(QWindowsIntegrationPlugin CONDITION mingw
PUBLIC_LIBRARIES
uuid
)
-extend_target(qwindows CONDITION QT_FEATURE_opengl
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_opengl
SOURCES
qwindowsopenglcontext.h
)
-extend_target(qwindows CONDITION QT_FEATURE_opengles2
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_opengles2
SOURCES
qwindowseglcontext.cpp qwindowseglcontext.h
)
-extend_target(qwindows CONDITION QT_FEATURE_opengl AND NOT QT_FEATURE_opengles2
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_opengl AND NOT QT_FEATURE_opengles2
SOURCES
qwindowsglcontext.cpp qwindowsglcontext.h
)
-extend_target(qwindows CONDITION QT_FEATURE_dynamicgl
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_dynamicgl
SOURCES
qwindowseglcontext.cpp qwindowseglcontext.h
)
-extend_target(qwindows CONDITION QT_FEATURE_systemtrayicon
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_systemtrayicon
SOURCES
qwindowssystemtrayicon.cpp qwindowssystemtrayicon.h
)
-extend_target(qwindows CONDITION QT_FEATURE_clipboard
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_clipboard
SOURCES
qwindowsclipboard.cpp qwindowsclipboard.h
)
-extend_target(qwindows CONDITION QT_FEATURE_clipboard AND QT_FEATURE_draganddrop
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_clipboard AND QT_FEATURE_draganddrop
SOURCES
qwindowsdrag.cpp qwindowsdrag.h
)
-extend_target(qwindows CONDITION QT_FEATURE_tabletevent
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_tabletevent
SOURCES
qwindowstabletsupport.cpp qwindowstabletsupport.h
INCLUDE_DIRECTORIES
${QT_SOURCE_TREE}/src/3rdparty/wintab
)
-extend_target(qwindows CONDITION QT_FEATURE_sessionmanager
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_sessionmanager
SOURCES
qwindowssessionmanager.cpp qwindowssessionmanager.h
)
-# Resources:
-set(cursors_resource_files
- "images/closedhandcursor_32.png"
- "images/closedhandcursor_48.png"
- "images/closedhandcursor_64.png"
- "images/dragcopycursor_32.png"
- "images/dragcopycursor_48.png"
- "images/dragcopycursor_64.png"
- "images/draglinkcursor_32.png"
- "images/draglinkcursor_48.png"
- "images/draglinkcursor_64.png"
- "images/dragmovecursor_32.png"
- "images/dragmovecursor_48.png"
- "images/dragmovecursor_64.png"
- "images/openhandcursor_32.png"
- "images/openhandcursor_48.png"
- "images/openhandcursor_64.png"
- "images/splithcursor_32.png"
- "images/splithcursor_48.png"
- "images/splithcursor_64.png"
- "images/splitvcursor_32.png"
- "images/splitvcursor_48.png"
- "images/splitvcursor_64.png"
-)
-
-add_qt_resource(qwindows "cursors"
- PREFIX
- "/qt-project.org/windows/cursors"
- FILES
- ${cursors_resource_files}
-)
-
-
-extend_target(qwindows CONDITION QT_FEATURE_accessibility AND TARGET Qt::WindowsUIAutomationSupportPrivate
- LIBRARIES
- Qt::WindowsUIAutomationSupportPrivate
+if(QT_FEATURE_imageformat_png)
+ # Resources:
+ set(cursors_resource_files
+ "images/closedhandcursor_32.png"
+ "images/closedhandcursor_48.png"
+ "images/closedhandcursor_64.png"
+ "images/dragcopycursor_32.png"
+ "images/dragcopycursor_48.png"
+ "images/dragcopycursor_64.png"
+ "images/draglinkcursor_32.png"
+ "images/draglinkcursor_48.png"
+ "images/draglinkcursor_64.png"
+ "images/dragmovecursor_32.png"
+ "images/dragmovecursor_48.png"
+ "images/dragmovecursor_64.png"
+ "images/openhandcursor_32.png"
+ "images/openhandcursor_48.png"
+ "images/openhandcursor_64.png"
+ "images/splithcursor_32.png"
+ "images/splithcursor_48.png"
+ "images/splithcursor_64.png"
+ "images/splitvcursor_32.png"
+ "images/splitvcursor_48.png"
+ "images/splitvcursor_64.png"
+ )
+
+ qt_add_resource(QWindowsIntegrationPlugin "cursors"
+ PREFIX
+ "/qt-project.org/windows/cursors"
+ FILES
+ ${cursors_resource_files}
+ )
+endif()
+
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_accessibility AND TARGET Qt::WindowsUIAutomationSupportPrivate
PUBLIC_LIBRARIES
- Qt::WindowsUIAutomationSupport
+ Qt::WindowsUIAutomationSupportPrivate
)
-extend_target(qwindows CONDITION QT_FEATURE_accessibility AND mingw
+qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_accessibility AND mingw
PUBLIC_LIBRARIES
uuid
)
# special case:
-# extend_target(qwindows CONDITION QT_FEATURE_combined_angle_lib ...
-# extend_target(qwindows CONDITION NOT QT_FEATURE_combined_angle_lib ...
+# qt_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_combined_angle_lib ...
+# qt_extend_target(QWindowsIntegrationPlugin CONDITION NOT QT_FEATURE_combined_angle_lib ...
+
diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp
index 4e6d3306e1..efcb0b6e6e 100644
--- a/src/plugins/platforms/windows/qwindowsclipboard.cpp
+++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp
@@ -82,7 +82,7 @@ static QDebug operator<<(QDebug d, const QMimeData *mimeData)
d << "QMimeData(";
if (mimeData) {
const QStringList formats = mimeData->formats();
- d << "formats=" << formats.join(QLatin1String(", "));
+ d << "formats=" << formats.join(u", ");
if (mimeData->hasText())
d << ", text=" << mimeData->text();
if (mimeData->hasHtml())
@@ -190,7 +190,7 @@ void QWindowsClipboard::releaseIData()
void QWindowsClipboard::registerViewer()
{
m_clipboardViewer = QWindowsContext::instance()->
- createDummyWindow(QStringLiteral("Qt5ClipboardView"), L"Qt5ClipboardView",
+ createDummyWindow(QStringLiteral("ClipboardView"), L"QtClipboardView",
qClipboardViewerWndProc, WS_OVERLAPPED);
// Try format listener API (Vista onwards) first.
@@ -339,7 +339,7 @@ void QWindowsClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode)
if (src != S_OK) {
QString mimeDataFormats = mimeData ?
- mimeData->formats().join(QLatin1String(", ")) : QString(QStringLiteral("NULL"));
+ mimeData->formats().join(u", ") : QString(QStringLiteral("NULL"));
qErrnoWarning("OleSetClipboard: Failed to set mime data (%s) on clipboard: %s",
qPrintable(mimeDataFormats),
QWindowsContext::comErrorString(src).constData());
diff --git a/src/plugins/platforms/windows/qwindowscombase.h b/src/plugins/platforms/windows/qwindowscombase.h
index 45cba9c68b..bb4b295395 100644
--- a/src/plugins/platforms/windows/qwindowscombase.h
+++ b/src/plugins/platforms/windows/qwindowscombase.h
@@ -107,6 +107,9 @@ private:
ULONG m_ref;
};
+// Clang does not consider __declspec(nothrow) as nothrow
+QT_WARNING_DISABLE_CLANG("-Wmicrosoft-exception-spec")
+
QT_END_NAMESPACE
#endif // QWINDOWSCOMBASE_H
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 9757fa5f3f..438a0fbaa4 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -42,6 +42,7 @@
#include "qwindowsintegration.h"
#include "qwindowswindow.h"
#include "qwindowskeymapper.h"
+#include "qwindowsnativeinterface.h"
#include "qwindowsmousehandler.h"
#include "qwindowspointerhandler.h"
#include "qtwindowsglobal.h"
@@ -72,6 +73,7 @@
#include <QtCore/qset.h>
#include <QtCore/qhash.h>
+#include <QtCore/qlibraryinfo.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qdebug.h>
#include <QtCore/qoperatingsystemversion.h>
@@ -274,8 +276,13 @@ struct QWindowsContextPrivate {
const HRESULT m_oleInitializeResult;
QWindow *m_lastActiveWindow = nullptr;
bool m_asyncExpose = false;
+ HPOWERNOTIFY m_powerNotification = nullptr;
+ HWND m_powerDummyWindow = nullptr;
+ static bool m_darkMode;
};
+bool QWindowsContextPrivate::m_darkMode = false;
+
QWindowsContextPrivate::QWindowsContextPrivate()
: m_oleInitializeResult(OleInitialize(nullptr))
{
@@ -290,6 +297,7 @@ QWindowsContextPrivate::QWindowsContextPrivate()
m_systemInfo |= QWindowsContext::SI_RTL_Extensions;
m_keyMapper.setUseRTLExtensions(true);
}
+ m_darkMode = QWindowsTheme::queryDarkMode();
if (FAILED(m_oleInitializeResult)) {
qWarning() << "QWindowsContext: OleInitialize() failed: "
<< QWindowsContext::comErrorString(m_oleInitializeResult);
@@ -314,6 +322,13 @@ QWindowsContext::~QWindowsContext()
#if QT_CONFIG(tabletevent)
d->m_tabletSupport.reset(); // Destroy internal window before unregistering classes.
#endif
+
+ if (d->m_powerNotification)
+ UnregisterPowerSettingNotification(d->m_powerNotification);
+
+ if (d->m_powerDummyWindow)
+ DestroyWindow(d->m_powerDummyWindow);
+
unregisterWindowClasses();
if (d->m_oleInitializeResult == S_OK || d->m_oleInitializeResult == S_FALSE)
OleUninitialize();
@@ -381,6 +396,55 @@ bool QWindowsContext::initPointer(unsigned integrationOptions)
return true;
}
+extern "C" LRESULT QT_WIN_CALLBACK qWindowsPowerWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ if (message != WM_POWERBROADCAST || wParam != PBT_POWERSETTINGCHANGE)
+ return DefWindowProc(hwnd, message, wParam, lParam);
+
+ static bool initialized = false; // ignore the initial change
+ if (!initialized) {
+ initialized = true;
+ return DefWindowProc(hwnd, message, wParam, lParam);
+ }
+
+ auto setting = reinterpret_cast<const POWERBROADCAST_SETTING *>(lParam);
+ if (setting) {
+ auto data = reinterpret_cast<const DWORD *>(&setting->Data);
+ if (*data == 1) {
+ // Repaint the windows when returning from sleeping display mode.
+ const auto tlw = QGuiApplication::topLevelWindows();
+ for (auto w : tlw) {
+ if (w->isVisible() && w->windowState() != Qt::WindowMinimized) {
+ if (auto tw = QWindowsWindow::windowsWindowOf(w)) {
+ if (HWND hwnd = tw->handle()) {
+ InvalidateRect(hwnd, nullptr, false);
+ }
+ }
+ }
+ }
+ }
+ }
+ return DefWindowProc(hwnd, message, wParam, lParam);
+}
+
+bool QWindowsContext::initPowerNotificationHandler()
+{
+ if (d->m_powerNotification)
+ return false;
+
+ d->m_powerDummyWindow = createDummyWindow(QStringLiteral("PowerDummyWindow"), L"QtPowerDummyWindow", qWindowsPowerWindowProc);
+ if (!d->m_powerDummyWindow)
+ return false;
+
+ d->m_powerNotification = RegisterPowerSettingNotification(d->m_powerDummyWindow, &GUID_MONITOR_POWER_ON, DEVICE_NOTIFY_WINDOW_HANDLE);
+ if (!d->m_powerNotification) {
+ DestroyWindow(d->m_powerDummyWindow);
+ d->m_powerDummyWindow = nullptr;
+ return false;
+ }
+ return true;
+}
+
void QWindowsContext::setTabletAbsoluteRange(int a)
{
#if QT_CONFIG(tabletevent)
@@ -426,6 +490,11 @@ void QWindowsContext::setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiA
}
}
+bool QWindowsContext::isDarkMode()
+{
+ return QWindowsContextPrivate::m_darkMode;
+}
+
QWindowsContext *QWindowsContext::instance()
{
return m_instance;
@@ -478,6 +547,23 @@ void QWindowsContext::setKeyGrabber(QWindow *w)
d->m_keyMapper.setKeyGrabber(w);
}
+QString QWindowsContext::classNamePrefix()
+{
+ static QString result;
+ if (result.isEmpty()) {
+ QTextStream str(&result);
+ str << "Qt" << QT_VERSION_MAJOR << QT_VERSION_MINOR << QT_VERSION_PATCH;
+ if (QLibraryInfo::isDebugBuild())
+ str << 'd';
+#ifdef QT_NAMESPACE
+# define xstr(s) str(s)
+# define str(s) #s
+ str << xstr(QT_NAMESPACE);
+#endif
+ }
+ return result;
+}
+
// Window class registering code (from qapplication_win.cpp)
QString QWindowsContext::registerWindowClass(const QWindow *w)
@@ -509,8 +595,8 @@ QString QWindowsContext::registerWindowClass(const QWindow *w)
break;
}
// Create a unique name for the flag combination
- QString cname;
- cname += QLatin1String("Qt5QWindow");
+ QString cname = classNamePrefix();
+ cname += QLatin1String("QWindow");
switch (type) {
case Qt::Tool:
cname += QLatin1String("Tool");
@@ -546,15 +632,12 @@ QString QWindowsContext::registerWindowClass(QString cname,
// each one has to have window class names with a unique name
// The first instance gets the unmodified name; if the class
// has already been registered by another instance of Qt then
- // add a UUID.
- static int classExists = -1;
-
+ // add a UUID. The check needs to be performed for each name
+ // in case new message windows are added (QTBUG-81347).
const auto appInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr));
- if (classExists == -1) {
- WNDCLASS wcinfo;
- classExists = GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(cname.utf16()), &wcinfo);
- classExists = classExists && wcinfo.lpfnWndProc != proc;
- }
+ WNDCLASS wcinfo;
+ const bool classExists = GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(cname.utf16()), &wcinfo) == TRUE
+ && wcinfo.lpfnWndProc != proc;
if (classExists)
cname += QUuid::createUuid().toString();
@@ -823,7 +906,7 @@ HWND QWindowsContext::createDummyWindow(const QString &classNameIn,
{
if (!wndProc)
wndProc = DefWindowProc;
- QString className = registerWindowClass(classNameIn, wndProc);
+ QString className = registerWindowClass(classNamePrefix() + classNameIn, wndProc);
return CreateWindowEx(0, reinterpret_cast<LPCWSTR>(className.utf16()),
windowName, style,
CW_USEDEFAULT, CW_USEDEFAULT,
@@ -1130,9 +1213,27 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
t->displayChanged();
QWindowsWindow::displayChanged();
return d->m_screenManager.handleDisplayChange(wParam, lParam);
- case QtWindows::SettingChangedEvent:
+ case QtWindows::SettingChangedEvent: {
QWindowsWindow::settingsChanged();
+ const bool darkMode = QWindowsTheme::queryDarkMode();
+ if (darkMode != QWindowsContextPrivate::m_darkMode) {
+ QWindowsContextPrivate::m_darkMode = darkMode;
+ auto nativeInterface =
+ static_cast<QWindowsNativeInterface *>(QWindowsIntegration::instance()->nativeInterface());
+ emit nativeInterface->darkModeChanged(darkMode);
+ const auto options = QWindowsIntegration::instance()->options();
+ if ((options & QWindowsIntegration::DarkModeWindowFrames) != 0) {
+ for (QWindowsWindow *w : d->m_windows)
+ w->setDarkBorder(QWindowsContextPrivate::m_darkMode);
+ }
+ if ((options & QWindowsIntegration::DarkModeStyle) != 0) {
+ QWindowsTheme::instance()->refresh();
+ for (QWindowsWindow *w : d->m_windows)
+ QWindowSystemInterface::handleThemeChange(w->window());
+ }
+ }
return d->m_screenManager.handleScreenChanges();
+ }
default:
break;
}
diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h
index d94ae3f73b..1831ac6ec0 100644
--- a/src/plugins/platforms/windows/qwindowscontext.h
+++ b/src/plugins/platforms/windows/qwindowscontext.h
@@ -176,8 +176,11 @@ public:
bool initTablet(unsigned integrationOptions);
bool initPointer(unsigned integrationOptions);
+ bool initPowerNotificationHandler();
+
int defaultDPI() const;
+ static QString classNamePrefix();
QString registerWindowClass(const QWindow *w);
QString registerWindowClass(QString cname, WNDPROC proc,
unsigned style = 0, HBRUSH brush = nullptr,
@@ -223,6 +226,8 @@ public:
void setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiAwareness);
static int processDpiAwareness();
+ static bool isDarkMode();
+
void setDetectAltGrModifier(bool a);
// Returns a combination of SystemInfoFlags
diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp
index 17e8cffb76..19de3d5939 100644
--- a/src/plugins/platforms/windows/qwindowscursor.cpp
+++ b/src/plugins/platforms/windows/qwindowscursor.cpp
@@ -50,6 +50,7 @@
#include <QtGui/qscreen.h>
#include <QtGui/private/qguiapplication_p.h> // getPixmapCursor()
#include <QtGui/private/qhighdpiscaling_p.h>
+#include <QtCore/private/qwinregistry_p.h>
#include <QtCore/qdebug.h>
#include <QtCore/qscopedpointer.h>
@@ -79,10 +80,10 @@ QWindowsPixmapCursorCacheKey::QWindowsPixmapCursorCacheKey(const QCursor &c)
: bitmapCacheKey(c.pixmap().cacheKey()), maskCacheKey(0)
{
if (!bitmapCacheKey) {
- Q_ASSERT(c.bitmap());
- Q_ASSERT(c.mask());
- bitmapCacheKey = c.bitmap()->cacheKey();
- maskCacheKey = c.mask()->cacheKey();
+ Q_ASSERT(!c.bitmap(Qt::ReturnByValue).isNull());
+ Q_ASSERT(!c.mask(Qt::ReturnByValue).isNull());
+ bitmapCacheKey = c.bitmap(Qt::ReturnByValue).cacheKey();
+ maskCacheKey = c.mask(Qt::ReturnByValue).cacheKey();
}
}
@@ -168,9 +169,9 @@ static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits,
// Create a cursor from image and mask of the format QImage::Format_Mono.
static HCURSOR createBitmapCursor(const QCursor &cursor, qreal scaleFactor = 1)
{
- Q_ASSERT(cursor.shape() == Qt::BitmapCursor && cursor.bitmap());
- QImage bbits = cursor.bitmap()->toImage();
- QImage mbits = cursor.mask()->toImage();
+ Q_ASSERT(cursor.shape() == Qt::BitmapCursor && !cursor.bitmap(Qt::ReturnByValue).isNull());
+ QImage bbits = cursor.bitmap(Qt::ReturnByValue).toImage();
+ QImage mbits = cursor.mask(Qt::ReturnByValue).toImage();
scaleFactor /= bbits.devicePixelRatioF();
if (!qFuzzyCompare(scaleFactor, 1)) {
const QSize scaledSize = (QSizeF(bbits.size()) * scaleFactor).toSize();
@@ -686,6 +687,30 @@ void QWindowsCursor::setPos(const QPoint &pos)
SetCursorPos(pos.x() , pos.y());
}
+/*
+ The standard size is 32x32, even though the cursor is actually just
+ 16 pixels large. If a large cursor is set in the accessibility settings,
+ then the cursor increases with 8 pixels for each step.
+*/
+QSize QWindowsCursor::size() const
+{
+ const QPair<DWORD,bool> cursorSizeSetting =
+ QWinRegistryKey(HKEY_CURRENT_USER, LR"(Control Panel\Cursors)")
+ .dwordValue(L"CursorBaseSize");
+ const int baseSize = screenCursorSize(m_screen).width() / 2;
+ if (!cursorSizeSetting.second)
+ return QSize(baseSize / 2, baseSize / 2);
+
+ // The registry values are dpi-independent, so we need to scale the result.
+ int cursorSizeValue = cursorSizeSetting.first * m_screen->logicalDpi().first
+ / m_screen->logicalBaseDpi().first;
+
+ // map from registry value 32-256 to 0-14, and from there to pixels
+ cursorSizeValue = (cursorSizeValue - 2 * baseSize) / baseSize;
+ const int cursorSize = baseSize + cursorSizeValue * (baseSize / 2);
+ return QSize(cursorSize, cursorSize);
+}
+
QPixmap QWindowsCursor::dragDefaultCursor(Qt::DropAction action) const
{
switch (action) {
diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h
index b896f4c7a9..cf3635bd6b 100644
--- a/src/plugins/platforms/windows/qwindowscursor.h
+++ b/src/plugins/platforms/windows/qwindowscursor.h
@@ -113,6 +113,8 @@ public:
QPoint pos() const override;
void setPos(const QPoint &pos) override;
+ QSize size() const override;
+
static HCURSOR createPixmapCursor(QPixmap pixmap, const QPoint &hotSpot, qreal scaleFactor = 1);
static HCURSOR createPixmapCursor(const PixmapCursor &pc, qreal scaleFactor = 1) { return createPixmapCursor(pc.pixmap, pc.hotSpot, scaleFactor); }
static PixmapCursor customCursor(Qt::CursorShape cursorShape, const QPlatformScreen *screen = nullptr);
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
index b7ab952a1d..b038e19689 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
@@ -91,7 +91,7 @@ static inline QString guidToString(const GUID &g)
str << '{' << g.Data1 << ", " << g.Data2 << ", " << g.Data3;
str.setFieldWidth(2);
str.setFieldAlignment(QTextStream::AlignRight);
- str.setPadChar(QLatin1Char('0'));
+ str.setPadChar(u'0');
str << ",{" << g.Data4[0] << ", " << g.Data4[1] << ", " << g.Data4[2] << ", " << g.Data4[3]
<< ", " << g.Data4[4] << ", " << g.Data4[5] << ", " << g.Data4[6] << ", " << g.Data4[7]
<< "}};";
@@ -466,14 +466,14 @@ inline void QWindowsFileDialogSharedData::setSelectedNameFilter(const QString &f
inline QList<QUrl> QWindowsFileDialogSharedData::selectedFiles() const
{
m_data->mutex.lock();
- const QList<QUrl> result = m_data->selectedFiles;
+ const auto result = m_data->selectedFiles;
m_data->mutex.unlock();
return result;
}
inline QString QWindowsFileDialogSharedData::selectedFile() const
{
- const QList<QUrl> files = selectedFiles();
+ const auto files = selectedFiles();
return files.isEmpty() ? QString() : files.front().toLocalFile();
}
@@ -915,7 +915,7 @@ IShellItem *QWindowsNativeFileDialogBase::shellItem(const QUrl &url)
return nullptr;
}
return result;
- } else if (url.scheme() == QLatin1String("clsid")) {
+ } else if (url.scheme() == u"clsid") {
// Support for virtual folders via GUID
// (see https://msdn.microsoft.com/en-us/library/windows/desktop/dd378457(v=vs.85).aspx)
// specified as "clsid:<GUID>" (without '{', '}').
@@ -1040,20 +1040,20 @@ static QList<FilterSpec> filterSpecs(const QStringList &filters,
// Split filter specification as 'Texts (*.txt[;] *.doc)', '*.txt[;] *.doc'
// into description and filters specification as '*.txt;*.doc'
for (const QString &filterString : filters) {
- const int openingParenPos = filterString.lastIndexOf(QLatin1Char('('));
+ const int openingParenPos = filterString.lastIndexOf(u'(');
const int closingParenPos = openingParenPos != -1 ?
- filterString.indexOf(QLatin1Char(')'), openingParenPos + 1) : -1;
+ filterString.indexOf(u')', openingParenPos + 1) : -1;
FilterSpec filterSpec;
filterSpec.filter = closingParenPos == -1 ?
filterString :
filterString.mid(openingParenPos + 1, closingParenPos - openingParenPos - 1).trimmed();
if (filterSpec.filter.isEmpty())
- filterSpec.filter += QLatin1Char('*');
+ filterSpec.filter += u'*';
filterSpec.filter.replace(filterSeparatorRE, separator);
filterSpec.description = filterString;
if (hideFilterDetails && openingParenPos != -1) { // Do not show pattern in description
filterSpec.description.truncate(openingParenPos);
- while (filterSpec.description.endsWith(QLatin1Char(' ')))
+ while (filterSpec.description.endsWith(u' '))
filterSpec.description.truncate(filterSpec.description.size() - 1);
}
*totalStringLength += filterSpec.filter.size() + filterSpec.description.size();
@@ -1084,8 +1084,8 @@ void QWindowsNativeFileDialogBase::setNameFilters(const QStringList &filters)
// 'AAA files (a.*) (a.*)'
QString description = specs[i].description;
const QString &filter = specs[i].filter;
- if (!m_hideFiltersDetails && !filter.startsWith(QLatin1String("*."))) {
- const int pos = description.lastIndexOf(QLatin1Char('('));
+ if (!m_hideFiltersDetails && !filter.startsWith(u"*.")) {
+ const int pos = description.lastIndexOf(u'(');
if (pos > 0)
description.truncate(pos);
}
@@ -1151,8 +1151,8 @@ static bool isHexRange(const QString& s, int start, int end)
for (;start < end; ++start) {
QChar ch = s.at(start);
if (!(ch.isDigit()
- || (ch >= QLatin1Char('a') && ch <= QLatin1Char('f'))
- || (ch >= QLatin1Char('A') && ch <= QLatin1Char('F'))))
+ || (ch >= u'a' && ch <= u'f')
+ || (ch >= u'A' && ch <= u'F')))
return false;
}
return true;
@@ -1161,7 +1161,7 @@ static bool isHexRange(const QString& s, int start, int end)
static inline bool isClsid(const QString &s)
{
// detect "374DE290-123F-4565-9164-39C4925E467B".
- const QChar dash(QLatin1Char('-'));
+ const QChar dash(u'-');
return s.size() == 36
&& isHexRange(s, 0, 8)
&& s.at(8) == dash
@@ -1204,7 +1204,7 @@ void QWindowsNativeFileDialogBase::selectNameFilter(const QString &filter)
if (index < 0) {
qWarning("%s: Invalid parameter '%s' not found in '%s'.",
__FUNCTION__, qPrintable(filter),
- qPrintable(m_nameFilters.join(QLatin1String(", "))));
+ qPrintable(m_nameFilters.join(u", ")));
return;
}
m_fileDialog->SetFileTypeIndex(index + 1); // one-based.
@@ -1313,15 +1313,15 @@ public:
// Also handles the simple name filter case "*.txt" -> "txt"
static inline QString suffixFromFilter(const QString &filter)
{
- int suffixPos = filter.indexOf(QLatin1String("*."));
+ int suffixPos = filter.indexOf(u"*.");
if (suffixPos < 0)
return QString();
suffixPos += 2;
- int endPos = filter.indexOf(QLatin1Char(' '), suffixPos + 1);
+ int endPos = filter.indexOf(u' ', suffixPos + 1);
if (endPos < 0)
- endPos = filter.indexOf(QLatin1Char(';'), suffixPos + 1);
+ endPos = filter.indexOf(u';', suffixPos + 1);
if (endPos < 0)
- endPos = filter.indexOf(QLatin1Char(')'), suffixPos + 1);
+ endPos = filter.indexOf(u')', suffixPos + 1);
if (endPos < 0)
endPos = filter.size();
return filter.mid(suffixPos, endPos - suffixPos);
@@ -1406,27 +1406,27 @@ static void cleanupTemporaryItemCopies()
static bool validFileNameCharacter(QChar c)
{
- return c.isLetterOrNumber() || c == QLatin1Char('_') || c == QLatin1Char('-');
+ return c.isLetterOrNumber() || c == u'_' || c == u'-';
}
QString tempFilePattern(QString name)
{
- const int lastSlash = qMax(name.lastIndexOf(QLatin1Char('/')),
- name.lastIndexOf(QLatin1Char('\\')));
+ const int lastSlash = qMax(name.lastIndexOf(u'/'),
+ name.lastIndexOf(u'\\'));
if (lastSlash != -1)
name.remove(0, lastSlash + 1);
- int lastDot = name.lastIndexOf(QLatin1Char('.'));
+ int lastDot = name.lastIndexOf(u'.');
if (lastDot < 0)
lastDot = name.size();
name.insert(lastDot, QStringLiteral("_XXXXXX"));
for (int i = lastDot - 1; i >= 0; --i) {
if (!validFileNameCharacter(name.at(i)))
- name[i] = QLatin1Char('_');
+ name[i] = u'_';
}
- name.prepend(QDir::tempPath() + QLatin1Char('/'));
+ name.prepend(QDir::tempPath() + u'/');
return name;
}
@@ -1456,7 +1456,7 @@ static QString createTemporaryItemCopy(QWindowsShellItem &qItem, QString *errorM
static QUrl itemToDialogUrl(QWindowsShellItem &qItem, QString *errorMessage)
{
QUrl url = qItem.url();
- if (url.isLocalFile() || url.scheme().startsWith(QLatin1String("http")))
+ if (url.isLocalFile() || url.scheme().startsWith(u"http"))
return url;
const QString path = qItem.path();
if (path.isEmpty() && !qItem.isDir() && qItem.canStream()) {
@@ -1859,10 +1859,12 @@ void QWindowsXpNativeFileDialog::populateOpenFileName(OPENFILENAME *ofn, HWND ow
// for the target. If it contains any invalid character, the dialog
// will not show.
ofn->nMaxFile = 65535;
- const QString initiallySelectedFile =
- QDir::toNativeSeparators(m_data.selectedFile()).remove(QLatin1Char('<')).
- remove(QLatin1Char('>')).remove(QLatin1Char('"')).remove(QLatin1Char('|'));
- ofn->lpstrFile = qStringToWCharArray(initiallySelectedFile, ofn->nMaxFile);
+ QString initiallySelectedFile = m_data.selectedFile();
+ initiallySelectedFile.remove(u'<');
+ initiallySelectedFile.remove(u'>');
+ initiallySelectedFile.remove(u'"');
+ initiallySelectedFile.remove(u'|');
+ ofn->lpstrFile = qStringToWCharArray(QDir::toNativeSeparators(initiallySelectedFile), ofn->nMaxFile);
ofn->lpstrInitialDir = qStringToWCharArray(QDir::toNativeSeparators(m_data.directory().toLocalFile()));
ofn->lpstrTitle = (wchar_t*)m_title.utf16();
// Determine lpstrDefExt. Note that the current MSDN docs document this
@@ -1872,7 +1874,7 @@ void QWindowsXpNativeFileDialog::populateOpenFileName(OPENFILENAME *ofn, HWND ow
// the extension of the current filter".
if (m_options->acceptMode() == QFileDialogOptions::AcceptSave) {
QString defaultSuffix = m_options->defaultSuffix();
- if (defaultSuffix.startsWith(QLatin1Char('.')))
+ if (defaultSuffix.startsWith(u'.'))
defaultSuffix.remove(0, 1);
// QTBUG-33156, also create empty strings to trigger the appending mechanism.
ofn->lpstrDefExt = qStringToWCharArray(defaultSuffix);
@@ -1905,7 +1907,7 @@ QList<QUrl> QWindowsXpNativeFileDialog::execFileNames(HWND owner, int *selectedF
wchar_t *ptr = ofn.lpstrFile + dir.size() + 1;
if (*ptr) {
result.pop_front();
- const QString path = dir + QLatin1Char('/');
+ const QString path = dir + u'/';
while (*ptr) {
const QString fileName = QString::fromWCharArray(ptr);
result.push_back(QUrl::fromLocalFile(path + fileName));
diff --git a/src/plugins/platforms/windows/qwindowsdropdataobject.cpp b/src/plugins/platforms/windows/qwindowsdropdataobject.cpp
index e1a41c0ede..c9dd1c7c17 100644
--- a/src/plugins/platforms/windows/qwindowsdropdataobject.cpp
+++ b/src/plugins/platforms/windows/qwindowsdropdataobject.cpp
@@ -95,7 +95,7 @@ bool QWindowsDropDataObject::shouldIgnore(LPFORMATETC pformatetc) const
|| pformatetc->cfFormat == CF_TEXT
|| formatName == QStringLiteral("UniformResourceLocator")
|| formatName == QStringLiteral("UniformResourceLocatorW")) {
- QList<QUrl> urls = dropData->urls();
+ const auto urls = dropData->urls();
return std::all_of(urls.cbegin(), urls.cend(), [] (const QUrl &u) { return u.isLocalFile(); });
}
}
diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp
index e9f3dc5189..76baa93d98 100644
--- a/src/plugins/platforms/windows/qwindowseglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp
@@ -88,7 +88,7 @@ static void *resolveFunc(HMODULE lib, const char *name)
while (!proc && argSize <= 64) {
nameStr = baseNameStr;
if (argSize >= 0)
- nameStr += QLatin1Char('@') + QString::number(argSize);
+ nameStr += u'@' + QString::number(argSize);
argSize = argSize < 0 ? 0 : argSize + 4;
proc = (void *) ::GetProcAddress(lib, nameStr.toLatin1().constData());
}
diff --git a/src/plugins/platforms/windows/qwindowsgdiintegration.cpp b/src/plugins/platforms/windows/qwindowsgdiintegration.cpp
index c88f669eb5..7e9595321a 100644
--- a/src/plugins/platforms/windows/qwindowsgdiintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsgdiintegration.cpp
@@ -45,6 +45,10 @@
#include <QtCore/qdebug.h>
#include <QtGui/private/qpixmap_raster_p.h>
+#if QT_CONFIG(opengl)
+#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h>
+#endif
+
QT_BEGIN_NAMESPACE
class QWindowsGdiIntegrationPrivate
@@ -73,7 +77,11 @@ QPlatformPixmap *QWindowsGdiIntegration::createPlatformPixmap(QPlatformPixmap::P
QPlatformBackingStore *QWindowsGdiIntegration::createPlatformBackingStore(QWindow *window) const
{
- return new QWindowsBackingStore(window);
+ auto *backingStore = new QWindowsBackingStore(window);
+#ifndef QT_NO_OPENGL
+ backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
+#endif
+ return backingStore;
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp
index d9521e7e08..7431f52e8a 100644
--- a/src/plugins/platforms/windows/qwindowsglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp
@@ -802,7 +802,7 @@ static HGLRC createContext(const QOpenGLStaticContext &staticContext,
static inline HWND createDummyGLWindow()
{
return QWindowsContext::instance()->
- createDummyWindow(QStringLiteral("QtOpenGLDummyWindow"),
+ createDummyWindow(QStringLiteral("OpenGLDummyWindow"),
L"OpenGLDummyWindow", nullptr, WS_OVERLAPPED | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
}
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.h b/src/plugins/platforms/windows/qwindowsglcontext.h
index e5f6fefd5a..8794368fe4 100644
--- a/src/plugins/platforms/windows/qwindowsglcontext.h
+++ b/src/plugins/platforms/windows/qwindowsglcontext.h
@@ -89,7 +89,7 @@ struct QWindowsOpenGLContextFormat
QSurfaceFormat::OpenGLContextProfile profile = QSurfaceFormat::NoProfile;
int version = 0; //! majorVersion<<8 + minorVersion
- QSurfaceFormat::FormatOptions options = nullptr;
+ QSurfaceFormat::FormatOptions options;
};
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
index d5258ca6a3..f1f5d3a96e 100644
--- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
@@ -280,13 +280,19 @@ void QWindowsInputContext::showInputPanel()
// with Windows 10 if the Windows IME is (re)enabled _after_ the caret is shown.
if (m_caretCreated) {
cursorRectChanged();
- // We only call ShowCaret() on Windows 10 as in earlier versions the caret
- // would actually be visible (QTBUG-74492) and the workaround for the
- // Surface seems unnecessary there anyway. But leave it hidden for IME.
- if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10)
+ // We only call ShowCaret() on Windows 10 after 1703 as in earlier versions
+ // the caret would actually be visible (QTBUG-74492) and the workaround for
+ // the Surface seems unnecessary there anyway. But leave it hidden for IME.
+ // Only trigger the native OSK if the Qt OSK is not in use.
+ static bool imModuleEmpty = qEnvironmentVariableIsEmpty("QT_IM_MODULE");
+ bool nativeVKDisabled = QCoreApplication::testAttribute(Qt::AA_MSWindowsDisableVirtualKeyboard);
+ if ((imModuleEmpty && !nativeVKDisabled)
+ && QOperatingSystemVersion::current()
+ >= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 16299)) {
ShowCaret(platformWindow->handle());
- else
+ } else {
HideCaret(platformWindow->handle());
+ }
setWindowsImeEnabled(platformWindow, false);
setWindowsImeEnabled(platformWindow, true);
}
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index eccf1c4928..77340387d8 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -48,6 +48,9 @@
#include "qwindowsscreen.h"
#include "qwindowstheme.h"
#include "qwindowsservices.h"
+#ifdef QT_USE_DIRECTWRITE3
+#include <QtFontDatabaseSupport/private/qwindowsdirectwritefontdatabase_p.h>
+#endif
#ifndef QT_NO_FREETYPE
# include <QtFontDatabaseSupport/private/qwindowsfontdatabase_ft_p.h>
#endif
@@ -162,7 +165,7 @@ bool parseIntOption(const QString &parameter,const QLatin1String &option,
IntType minimumValue, IntType maximumValue, IntType *target)
{
const int valueLength = parameter.size() - option.size() - 1;
- if (valueLength < 1 || !parameter.startsWith(option) || parameter.at(option.size()) != QLatin1Char('='))
+ if (valueLength < 1 || !parameter.startsWith(option) || parameter.at(option.size()) != u'=')
return false;
bool ok;
const QStringRef valueRef = parameter.rightRef(valueLength);
@@ -186,39 +189,45 @@ static inline unsigned parseOptions(const QStringList &paramList,
{
unsigned options = 0;
for (const QString &param : paramList) {
- if (param.startsWith(QLatin1String("fontengine="))) {
- if (param.endsWith(QLatin1String("freetype"))) {
+ if (param.startsWith(u"fontengine=")) {
+ if (param.endsWith(u"directwrite")) {
+ options |= QWindowsIntegration::FontDatabaseDirectWrite;
+ } else if (param.endsWith(u"freetype")) {
options |= QWindowsIntegration::FontDatabaseFreeType;
- } else if (param.endsWith(QLatin1String("native"))) {
+ } else if (param.endsWith(u"native")) {
options |= QWindowsIntegration::FontDatabaseNative;
}
- } else if (param.startsWith(QLatin1String("dialogs="))) {
- if (param.endsWith(QLatin1String("xp"))) {
+ } else if (param.startsWith(u"dialogs=")) {
+ if (param.endsWith(u"xp")) {
options |= QWindowsIntegration::XpNativeDialogs;
- } else if (param.endsWith(QLatin1String("none"))) {
+ } else if (param.endsWith(u"none")) {
options |= QWindowsIntegration::NoNativeDialogs;
}
- } else if (param == QLatin1String("altgr")) {
+ } else if (param == u"altgr") {
options |= QWindowsIntegration::DetectAltGrModifier;
- } else if (param == QLatin1String("gl=gdi")) {
+ } else if (param == u"gl=gdi") {
options |= QWindowsIntegration::DisableArb;
- } else if (param == QLatin1String("nodirectwrite")) {
+ } else if (param == u"nodirectwrite") {
options |= QWindowsIntegration::DontUseDirectWriteFonts;
- } else if (param == QLatin1String("nocolorfonts")) {
+ } else if (param == u"nocolorfonts") {
options |= QWindowsIntegration::DontUseColorFonts;
- } else if (param == QLatin1String("nomousefromtouch")) {
+ } else if (param == u"nomousefromtouch") {
options |= QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch;
} else if (parseIntOption(param, QLatin1String("verbose"), 0, INT_MAX, &QWindowsContext::verbose)
|| parseIntOption(param, QLatin1String("tabletabsoluterange"), 0, INT_MAX, tabletAbsoluteRange)
|| parseIntOption(param, QLatin1String("dpiawareness"), QtWindows::ProcessDpiUnaware, QtWindows::ProcessPerMonitorDpiAware, dpiAwareness)) {
- } else if (param == QLatin1String("menus=native")) {
+ } else if (param == u"menus=native") {
options |= QWindowsIntegration::AlwaysUseNativeMenus;
- } else if (param == QLatin1String("menus=none")) {
+ } else if (param == u"menus=none") {
options |= QWindowsIntegration::NoNativeMenus;
- } else if (param == QLatin1String("nowmpointer")) {
+ } else if (param == u"nowmpointer") {
options |= QWindowsIntegration::DontUseWMPointer;
- } else if (param == QLatin1String("reverse")) {
+ } else if (param == u"reverse") {
options |= QWindowsIntegration::RtlEnabled;
+ } else if (param == u"darkmode=1") {
+ options |= QWindowsIntegration::DarkModeWindowFrames;
+ } else if (param == u"darkmode=2") {
+ options |= QWindowsIntegration::DarkModeWindowFrames | QWindowsIntegration::DarkModeStyle;
} else {
qWarning() << "Unknown option" << param;
}
@@ -258,6 +267,8 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList &paramL
m_context.initTouch(m_options);
QPlatformCursor::setCapability(QPlatformCursor::OverrideCursor);
+
+ m_context.initPowerNotificationHandler();
}
QWindowsIntegrationPrivate::~QWindowsIntegrationPrivate()
@@ -498,14 +509,17 @@ QWindowsStaticOpenGLContext *QWindowsIntegration::staticOpenGLContext()
QPlatformFontDatabase *QWindowsIntegration::fontDatabase() const
{
if (!d->m_fontDatabase) {
-#ifdef QT_NO_FREETYPE
- d->m_fontDatabase = new QWindowsFontDatabase();
-#else // QT_NO_FREETYPE
+#ifdef QT_USE_DIRECTWRITE3
+ if (d->m_options & QWindowsIntegration::FontDatabaseDirectWrite)
+ d->m_fontDatabase = new QWindowsDirectWriteFontDatabase;
+ else
+#endif
+#ifndef QT_NO_FREETYPE
if (d->m_options & QWindowsIntegration::FontDatabaseFreeType)
d->m_fontDatabase = new QWindowsFontDatabaseFT;
else
- d->m_fontDatabase = new QWindowsFontDatabase;
#endif // QT_NO_FREETYPE
+ d->m_fontDatabase = new QWindowsFontDatabase();
}
return d->m_fontDatabase;
}
diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h
index b49d21022b..165472ad40 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.h
+++ b/src/plugins/platforms/windows/qwindowsintegration.h
@@ -70,7 +70,10 @@ public:
NoNativeMenus = 0x200,
DontUseWMPointer = 0x400,
DetectAltGrModifier = 0x800,
- RtlEnabled = 0x1000
+ RtlEnabled = 0x1000,
+ DarkModeWindowFrames = 0x2000,
+ DarkModeStyle = 0x4000,
+ FontDatabaseDirectWrite = 0x8000
};
explicit QWindowsIntegration(const QStringList &paramList);
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index 4f0f846749..e3edf7e81e 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -1019,14 +1019,14 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, MSG msg,
if (dirStatus == VK_LSHIFT
&& ((msg.wParam == VK_SHIFT && GetKeyState(VK_LCONTROL))
|| (msg.wParam == VK_CONTROL && GetKeyState(VK_LSHIFT)))) {
- sendExtendedPressRelease(receiver, Qt::Key_Direction_L, nullptr,
+ sendExtendedPressRelease(receiver, Qt::Key_Direction_L, {},
scancode, vk_key, nModifiers, QString(), false);
result = true;
dirStatus = 0;
} else if (dirStatus == VK_RSHIFT
&& ( (msg.wParam == VK_SHIFT && GetKeyState(VK_RCONTROL))
|| (msg.wParam == VK_CONTROL && GetKeyState(VK_RSHIFT)))) {
- sendExtendedPressRelease(receiver, Qt::Key_Direction_R, nullptr,
+ sendExtendedPressRelease(receiver, Qt::Key_Direction_R, {},
scancode, vk_key, nModifiers, QString(), false);
result = true;
dirStatus = 0;
@@ -1388,7 +1388,7 @@ QList<int> QWindowsKeyMapper::possibleKeys(const QKeyEvent *e) const
if (key && key != baseKey && ((keyMods & neededMods) == neededMods)) {
const Qt::KeyboardModifiers missingMods = keyMods & ~neededMods;
const int matchedKey = int(key) + missingMods;
- const QList<int>::iterator it =
+ const auto it =
std::find_if(result.begin(), result.end(),
[key] (int k) { return (k & ~Qt::KeyboardModifierMask) == key; });
// QTBUG-67200: Use the match with the least modifiers (prefer
diff --git a/src/plugins/platforms/windows/qwindowsmenu.cpp b/src/plugins/platforms/windows/qwindowsmenu.cpp
index d20edd685e..7c3e87eec1 100644
--- a/src/plugins/platforms/windows/qwindowsmenu.cpp
+++ b/src/plugins/platforms/windows/qwindowsmenu.cpp
@@ -445,7 +445,7 @@ QString QWindowsMenuItem::nativeText() const
QString result = m_text;
#if QT_CONFIG(shortcut)
if (!m_shortcut.isEmpty()) {
- result += QLatin1Char('\t');
+ result += u'\t';
result += m_shortcut.toString(QKeySequence::NativeText);
}
#endif
diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp
index b9d8b191f5..fe9e1fe31f 100644
--- a/src/plugins/platforms/windows/qwindowsmime.cpp
+++ b/src/plugins/platforms/windows/qwindowsmime.cpp
@@ -107,7 +107,7 @@ static inline QByteArray msgConversionError(const char *func, const char *format
msg += ": Unable to convert DIB image. The image converter plugin for '";
msg += format;
msg += "' is not available. Available formats: ";
- const QList<QByteArray> &formats = QImageReader::supportedImageFormats();
+ const auto &formats = QImageReader::supportedImageFormats();
for (const QByteArray &af : formats) {
msg += af;
msg += ' ';
@@ -635,11 +635,11 @@ bool QWindowsMimeText::convertFromMime(const FORMATETC &formatetc, const QMimeDa
int ri = 0;
bool cr = false;
for (int i=0; i < s; ++i) {
- if (*u == QLatin1Char('\r'))
+ if (*u == u'\r')
cr = true;
else {
- if (*u == QLatin1Char('\n') && !cr)
- res[ri++] = QLatin1Char('\r');
+ if (*u == u'\n' && !cr)
+ res[ri++] = u'\r';
cr = false;
}
res[ri++] = *u;
@@ -663,7 +663,7 @@ bool QWindowsMimeText::convertFromMime(const FORMATETC &formatetc, const QMimeDa
bool QWindowsMimeText::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const
{
- return mimeType.startsWith(QLatin1String("text/plain"))
+ return mimeType.startsWith(u"text/plain")
&& (canGetData(CF_UNICODETEXT, pDataObj)
|| canGetData(CF_TEXT, pDataObj));
}
@@ -680,7 +680,7 @@ QString QWindowsMimeText::mimeForFormat(const FORMATETC &formatetc) const
QVector<FORMATETC> QWindowsMimeText::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const
{
QVector<FORMATETC> formatics;
- if (mimeType.startsWith(QLatin1String("text/plain")) && mimeData->hasText()) {
+ if (mimeType.startsWith(u"text/plain") && mimeData->hasText()) {
formatics += setCf(CF_UNICODETEXT);
formatics += setCf(CF_TEXT);
}
@@ -747,7 +747,7 @@ QWindowsMimeURI::QWindowsMimeURI()
bool QWindowsMimeURI::canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const
{
if (mimeData->hasUrls() && getCf(formatetc) == CF_HDROP) {
- const QList<QUrl> urls = mimeData->urls();
+ const auto urls = mimeData->urls();
for (const QUrl &url : urls) {
if (url.isLocalFile())
return true;
@@ -760,7 +760,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
{
if (canConvertFromMime(formatetc, mimeData)) {
if (getCf(formatetc) == CF_HDROP) {
- const QList<QUrl> &urls = mimeData->urls();
+ const auto &urls = mimeData->urls();
QStringList fileNames;
int size = sizeof(DROPFILES)+2;
for (const QUrl &url : urls) {
@@ -791,7 +791,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
return setData(result, pmedium);
}
if (getCf(formatetc) == CF_INETURL_W) {
- QList<QUrl> urls = mimeData->urls();
+ const auto urls = mimeData->urls();
QByteArray result;
if (!urls.isEmpty()) {
QString url = urls.at(0).toString();
@@ -803,7 +803,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
return setData(result, pmedium);
}
if (getCf(formatetc) == CF_INETURL) {
- QList<QUrl> urls = mimeData->urls();
+ const auto urls = mimeData->urls();
QByteArray result;
if (!urls.isEmpty())
result = urls.at(0).toString().toLocal8Bit();
@@ -816,7 +816,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
bool QWindowsMimeURI::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const
{
- return mimeType == QLatin1String("text/uri-list")
+ return mimeType == u"text/uri-list"
&& (canGetData(CF_HDROP, pDataObj) || canGetData(CF_INETURL_W, pDataObj) || canGetData(CF_INETURL, pDataObj));
}
@@ -831,7 +831,7 @@ QString QWindowsMimeURI::mimeForFormat(const FORMATETC &formatetc) const
QVector<FORMATETC> QWindowsMimeURI::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const
{
QVector<FORMATETC> formatics;
- if (mimeType == QLatin1String("text/uri-list")) {
+ if (mimeType == u"text/uri-list") {
if (canConvertFromMime(setCf(CF_HDROP), mimeData))
formatics += setCf(CF_HDROP);
if (canConvertFromMime(setCf(CF_INETURL_W), mimeData))
@@ -844,7 +844,7 @@ QVector<FORMATETC> QWindowsMimeURI::formatsForMime(const QString &mimeType, cons
QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pDataObj, QVariant::Type preferredType) const
{
- if (mimeType == QLatin1String("text/uri-list")) {
+ if (mimeType == u"text/uri-list") {
if (canGetData(CF_HDROP, pDataObj)) {
QList<QVariant> urls;
@@ -916,7 +916,7 @@ QWindowsMimeHtml::QWindowsMimeHtml()
QVector<FORMATETC> QWindowsMimeHtml::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const
{
QVector<FORMATETC> formatetcs;
- if (mimeType == QLatin1String("text/html") && (!mimeData->html().isEmpty()))
+ if (mimeType == u"text/html" && (!mimeData->html().isEmpty()))
formatetcs += setCf(CF_HTML);
return formatetcs;
}
@@ -930,7 +930,7 @@ QString QWindowsMimeHtml::mimeForFormat(const FORMATETC &formatetc) const
bool QWindowsMimeHtml::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const
{
- return mimeType == QLatin1String("text/html") && canGetData(CF_HTML, pDataObj);
+ return mimeType == u"text/html" && canGetData(CF_HTML, pDataObj);
}
@@ -1053,7 +1053,7 @@ QWindowsMimeImage::QWindowsMimeImage()
QVector<FORMATETC> QWindowsMimeImage::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const
{
QVector<FORMATETC> formatetcs;
- if (mimeData->hasImage() && mimeType == QLatin1String("application/x-qt-image")) {
+ if (mimeData->hasImage() && mimeType == u"application/x-qt-image") {
//add DIBV5 if image has alpha channel. Do not add CF_PNG here as it will confuse MS Office (QTBUG47656).
auto image = qvariant_cast<QImage>(mimeData->imageData());
if (!image.isNull() && image.hasAlphaChannel())
@@ -1075,7 +1075,7 @@ QString QWindowsMimeImage::mimeForFormat(const FORMATETC &formatetc) const
bool QWindowsMimeImage::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const
{
- return mimeType == QLatin1String("application/x-qt-image")
+ return mimeType == u"application/x-qt-image"
&& (canGetData(CF_DIB, pDataObj) || canGetData(CF_PNG, pDataObj));
}
@@ -1149,7 +1149,7 @@ QVariant QWindowsMimeImage::convertToMime(const QString &mimeType, IDataObject *
{
Q_UNUSED(preferredType);
QVariant result;
- if (mimeType != QLatin1String("application/x-qt-image"))
+ if (mimeType != u"application/x-qt-image")
return result;
//Try to convert from a format which has more data
//DIBV5, use only if its is not synthesized
@@ -1220,7 +1220,7 @@ bool QBuiltInMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData
{
if (canConvertFromMime(formatetc, mimeData)) {
QByteArray data;
- if (outFormats.value(getCf(formatetc)) == QLatin1String("text/html")) {
+ if (outFormats.value(getCf(formatetc)) == u"text/html") {
// text/html is in wide chars on windows (compatible with mozillia)
QString html = mimeData->html();
// same code as in the text converter up above
@@ -1232,11 +1232,11 @@ bool QBuiltInMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData
int ri = 0;
bool cr = false;
for (int i=0; i < s; ++i) {
- if (*u == QLatin1Char('\r'))
+ if (*u == u'\r')
cr = true;
else {
- if (*u == QLatin1Char('\n') && !cr)
- res[ri++] = QLatin1Char('\r');
+ if (*u == u'\n' && !cr)
+ res[ri++] = u'\r';
cr = false;
}
res[ri++] = *u;
@@ -1285,7 +1285,7 @@ QVariant QBuiltInMimes::convertToMime(const QString &mimeType, IDataObject *pDat
QByteArray data = getData(inFormats.key(mimeType), pDataObj);
if (!data.isEmpty()) {
qCDebug(lcQpaMime) << __FUNCTION__;
- if (mimeType == QLatin1String("text/html") && preferredType == QVariant::String) {
+ if (mimeType == u"text/html" && preferredType == QVariant::String) {
// text/html is in wide chars on windows (compatible with Mozilla)
val = QString::fromWCharArray(reinterpret_cast<const wchar_t *>(data.constData()));
} else {
@@ -1404,12 +1404,12 @@ static bool isCustomMimeType(const QString &mimeType)
static QString customMimeType(const QString &mimeType, int *lindex = nullptr)
{
int len = sizeof(x_qt_windows_mime) - 1;
- int n = mimeType.lastIndexOf(QLatin1Char('\"')) - len;
+ int n = mimeType.lastIndexOf(u'\"') - len;
QString ret = mimeType.mid(len, n);
- const int beginPos = mimeType.indexOf(QLatin1String(";index="));
+ const int beginPos = mimeType.indexOf(u";index=");
if (beginPos > -1) {
- const int endPos = mimeType.indexOf(QLatin1Char(';'), beginPos + 1);
+ const int endPos = mimeType.indexOf(u';', beginPos + 1);
const int indexStartPos = beginPos + 7;
if (lindex)
*lindex = mimeType.midRef(indexStartPos, endPos == -1 ? endPos : endPos - indexStartPos).toInt();
@@ -1480,7 +1480,7 @@ QString QLastResortMimes::mimeForFormat(const FORMATETC &formatetc) const
}
}
if (!ianaType)
- format = QLatin1String(x_qt_windows_mime) + clipFormat + QLatin1Char('\"');
+ format = QLatin1String(x_qt_windows_mime) + clipFormat + u'"';
else
format = clipFormat;
}
diff --git a/src/plugins/platforms/windows/qwindowsmime.h b/src/plugins/platforms/windows/qwindowsmime.h
index 1c389e8800..f8708f1259 100644
--- a/src/plugins/platforms/windows/qwindowsmime.h
+++ b/src/plugins/platforms/windows/qwindowsmime.h
@@ -43,7 +43,6 @@
#include <QtCore/qt_windows.h>
#include <QtCore/qvector.h>
-#include <QtCore/qlist.h>
#include <QtCore/qvariant.h>
QT_BEGIN_NAMESPACE
@@ -95,7 +94,7 @@ public:
private:
void ensureInitialized() const;
- mutable QList<QWindowsMime *> m_mimes;
+ mutable QVector<QWindowsMime *> m_mimes;
mutable int m_internalMimeCount = 0;
};
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index 6df5e6aa27..b776efc942 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -165,7 +165,7 @@ void QWindowsMouseHandler::clearEvents()
Qt::MouseButtons QWindowsMouseHandler::queryMouseButtons()
{
- Qt::MouseButtons result = nullptr;
+ Qt::MouseButtons result;
const bool mouseSwapped = GetSystemMetrics(SM_SWAPBUTTON);
if (GetAsyncKeyState(VK_LBUTTON) < 0)
result |= mouseSwapped ? Qt::RightButton: Qt::LeftButton;
@@ -630,7 +630,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
QTouchPointList touchPoints;
touchPoints.reserve(winTouchPointCount);
- Qt::TouchPointStates allStates = nullptr;
+ Qt::TouchPointStates allStates;
GetTouchInputInfo(reinterpret_cast<HTOUCHINPUT>(msg.lParam),
UINT(msg.wParam), winTouchInputs.data(), sizeof(TOUCHINPUT));
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
index d1d181d66e..1195f15a59 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
@@ -47,6 +47,7 @@
#include "qwindowsopengltester.h"
#include "qwindowsintegration.h"
#include "qwindowsmime.h"
+#include "qwindowstheme.h"
#include "qwin10helpers.h"
#include <QtGui/qwindow.h>
@@ -316,4 +317,15 @@ QVariant QWindowsNativeInterface::gpuList() const
return result;
}
+bool QWindowsNativeInterface::isDarkMode() const
+{
+ return QWindowsContext::isDarkMode();
+}
+
+// Dark mode support level 2 (style)
+bool QWindowsNativeInterface::isDarkModeStyle() const
+{
+ return (QWindowsIntegration::instance()->options() & QWindowsIntegration::DarkModeStyle) != 0;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.h b/src/plugins/platforms/windows/qwindowsnativeinterface.h
index ce395dc5a4..90ba7a44c9 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.h
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.h
@@ -65,6 +65,8 @@ class QWindowsNativeInterface : public QPlatformNativeInterface
{
Q_OBJECT
Q_PROPERTY(bool asyncExpose READ asyncExpose WRITE setAsyncExpose)
+ Q_PROPERTY(bool darkMode READ isDarkMode STORED false NOTIFY darkModeChanged)
+ Q_PROPERTY(bool darkModeStyle READ isDarkModeStyle STORED false)
Q_PROPERTY(QVariant gpu READ gpu STORED false)
Q_PROPERTY(QVariant gpuList READ gpuList STORED false)
@@ -92,6 +94,9 @@ public:
bool asyncExpose() const;
void setAsyncExpose(bool value);
+ bool isDarkMode() const;
+ bool isDarkModeStyle() const;
+
QVariant gpu() const;
QVariant gpuList() const;
@@ -109,6 +114,9 @@ public:
QFunctionPointer platformFunction(const QByteArray &function) const override;
+Q_SIGNALS:
+ void darkModeChanged(bool);
+
private:
static QWindowsWindowFunctions::WindowActivationBehavior m_windowActivationBehavior;
};
diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp
index afc1991e2c..72092a4481 100644
--- a/src/plugins/platforms/windows/qwindowsopengltester.cpp
+++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp
@@ -206,7 +206,7 @@ QString GpuDescription::toString() const
str << " Card name : " << description
<< "\n Driver Name : " << driverName
<< "\n Driver Version : " << driverVersion.toString()
- << "\n Vendor ID : 0x" << qSetPadChar(QLatin1Char('0'))
+ << "\n Vendor ID : 0x" << qSetPadChar(u'0')
<< Qt::uppercasedigits << Qt::hex << qSetFieldWidth(4) << vendorId
<< "\n Device ID : 0x" << qSetFieldWidth(4) << deviceId
<< "\n SubSys ID : 0x" << qSetFieldWidth(8) << subSysId
@@ -285,7 +285,7 @@ static inline QString resolveBugListFile(const QString &fileName)
// then resolve via QStandardPaths::ConfigLocation.
const QString settingsPath = QLibraryInfo::location(QLibraryInfo::SettingsPath);
if (!settingsPath.isEmpty()) { // SettingsPath is empty unless specified in qt.conf.
- const QFileInfo fi(settingsPath + QLatin1Char('/') + fileName);
+ const QFileInfo fi(settingsPath + u'/' + fileName);
if (fi.isFile())
return fi.absoluteFilePath();
}
diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
index cffd8427a2..fba24d8696 100644
--- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp
+++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
@@ -482,7 +482,7 @@ bool QWindowsPointerHandler::translateTouchEvent(QWindow *window, HWND hwnd,
<< " message=" << Qt::hex << msg.message
<< " count=" << Qt::dec << count;
- Qt::TouchPointStates allStates = nullptr;
+ Qt::TouchPointStates allStates;
for (quint32 i = 0; i < count; ++i) {
if (QWindowsContext::verbose > 1)
@@ -579,7 +579,9 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin
const QTabletEvent::TabletDevice device = QTabletEvent::Stylus;
QTabletEvent::PointerType type;
- Qt::MouseButtons mouseButtons;
+ // Since it may be the middle button, so if the checks fail then it should
+ // be set to Middle if it was used.
+ Qt::MouseButtons mouseButtons = queryMouseButtons();
const bool pointerInContact = IS_POINTER_INCONTACT_WPARAM(msg.wParam);
if (pointerInContact)
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index df63adf558..c7a0c2e62e 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -73,7 +73,7 @@ static inline QDpi monitorDPI(HMONITOR hMonitor)
return {0, 0};
}
-using WindowsScreenDataList = QList<QWindowsScreenData>;
+using WindowsScreenDataList = QVector<QWindowsScreenData>;
static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data)
{
@@ -87,7 +87,7 @@ static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data)
data->geometry = QRect(QPoint(info.rcMonitor.left, info.rcMonitor.top), QPoint(info.rcMonitor.right - 1, info.rcMonitor.bottom - 1));
data->availableGeometry = QRect(QPoint(info.rcWork.left, info.rcWork.top), QPoint(info.rcWork.right - 1, info.rcWork.bottom - 1));
data->name = QString::fromWCharArray(info.szDevice);
- if (data->name == QLatin1String("WinDisc")) {
+ if (data->name == u"WinDisc") {
data->flags |= QWindowsScreenData::LockScreen;
} else {
if (const HDC hdc = CreateDC(info.szDevice, nullptr, nullptr, nullptr)) {
@@ -467,7 +467,7 @@ bool QWindowsScreenManager::handleDisplayChange(WPARAM wParam, LPARAM lParam)
return false;
}
-static inline int indexOfMonitor(const QList<QWindowsScreen *> &screens,
+static inline int indexOfMonitor(const QWindowsScreenManager::WindowsScreenList &screens,
const QString &monitorName)
{
for (int i= 0; i < screens.size(); ++i)
@@ -476,7 +476,7 @@ static inline int indexOfMonitor(const QList<QWindowsScreen *> &screens,
return -1;
}
-static inline int indexOfMonitor(const QList<QWindowsScreenData> &screenData,
+static inline int indexOfMonitor(const WindowsScreenDataList &screenData,
const QString &monitorName)
{
for (int i = 0; i < screenData.size(); ++i)
diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h
index 2fd56f53cf..5c095808f2 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.h
+++ b/src/plugins/platforms/windows/qwindowsscreen.h
@@ -127,7 +127,7 @@ private:
class QWindowsScreenManager
{
public:
- using WindowsScreenList = QList<QWindowsScreen *>;
+ using WindowsScreenList = QVector<QWindowsScreen *>;
QWindowsScreenManager();
diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp
index 83b052bb49..6a2708ee26 100644
--- a/src/plugins/platforms/windows/qwindowsservices.cpp
+++ b/src/plugins/platforms/windows/qwindowsservices.cpp
@@ -92,7 +92,7 @@ static inline QString mailCommand()
// "rundll32.exe .. url.dll,MailToProtocolHandler %l" is returned. Launching it
// silently fails or brings up a broken dialog after a long time, so exclude it and
// fall back to ShellExecute() which brings up the URL assocation dialog.
- if (command.isEmpty() || command.contains(QLatin1String(",MailToProtocolHandler")))
+ if (command.isEmpty() || command.contains(u",MailToProtocolHandler"))
return QString();
wchar_t expandedCommand[MAX_PATH] = {0};
return ExpandEnvironmentStrings(reinterpret_cast<const wchar_t *>(command.utf16()),
@@ -108,7 +108,7 @@ static inline bool launchMail(const QUrl &url)
return false;
}
//Make sure the path for the process is in quotes
- const QChar doubleQuote = QLatin1Char('"');
+ const QChar doubleQuote = u'"';
if (!command.startsWith(doubleQuote)) {
const int exeIndex = command.indexOf(QStringLiteral(".exe "), 0, Qt::CaseInsensitive);
if (exeIndex != -1) {
@@ -140,7 +140,7 @@ static inline bool launchMail(const QUrl &url)
bool QWindowsServices::openUrl(const QUrl &url)
{
const QString scheme = url.scheme();
- if (scheme == QLatin1String("mailto") && launchMail(url))
+ if (scheme == u"mailto" && launchMail(url))
return true;
return shellExecute(url);
}
diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
index f2dba4d06b..53562c87dd 100644
--- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
+++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
@@ -57,11 +57,13 @@
#include "qwindowsmenu.h"
#include "qwindowsscreen.h"
+#include <QtGui/qguiapplication.h>
#include <QtGui/qpixmap.h>
#include <QtCore/qdebug.h>
#include <QtCore/qrect.h>
#include <QtCore/qvector.h>
#include <QtCore/qsettings.h>
+#include <qpa/qwindowsysteminterface.h>
#include <qt_windows.h>
#include <commctrl.h>
@@ -134,9 +136,12 @@ static int indexOfHwnd(HWND hwnd)
extern "C" LRESULT QT_WIN_CALLBACK qWindowsTrayIconWndProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
+ // QTBUG-79248: Trigger screen update if there are no other windows.
+ if (message == WM_DPICHANGED && QGuiApplication::topLevelWindows().isEmpty())
+ QWindowsContext::instance()->screenManager().handleScreenChanges();
if (message == MYWM_TASKBARCREATED || message == MYWM_NOTIFYICON
|| message == WM_INITMENU || message == WM_INITMENUPOPUP
- || message == WM_COMMAND) {
+ || message == WM_CLOSE || message == WM_COMMAND) {
const int index = indexOfHwnd(hwnd);
if (index >= 0) {
MSG msg;
@@ -163,7 +168,7 @@ static inline HWND createTrayIconMessageWindow()
return nullptr;
// Register window class in the platform plugin.
const QString className =
- ctx->registerWindowClass(QStringLiteral("QTrayIconMessageWindowClass"),
+ ctx->registerWindowClass(QWindowsContext::classNamePrefix() + QStringLiteral("TrayIconMessageWindowClass"),
qWindowsTrayIconWndProc);
const wchar_t windowName[] = L"QTrayIconMessageWindow";
return CreateWindowEx(0, reinterpret_cast<const wchar_t *>(className.utf16()),
@@ -256,7 +261,7 @@ void QWindowsSystemTrayIcon::showMessage(const QString &title, const QString &me
// For empty messages, ensures that they show when only title is set
QString message = messageIn;
if (message.isEmpty() && !title.isEmpty())
- message.append(QLatin1Char(' '));
+ message.append(u' ');
NOTIFYICONDATA tnd;
initNotifyIconData(tnd);
@@ -439,6 +444,9 @@ bool QWindowsSystemTrayIcon::winEvent(const MSG &message, long *result)
case WM_INITMENUPOPUP:
QWindowsPopupMenu::notifyAboutToShow(reinterpret_cast<HMENU>(message.wParam));
break;
+ case WM_CLOSE:
+ QWindowSystemInterface::handleApplicationTermination<QWindowSystemInterface::SynchronousDelivery>();
+ break;
case WM_COMMAND:
QWindowsPopupMenu::notifyTriggered(LOWORD(message.wParam));
break;
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index 437c9562ab..325956b7ba 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -63,6 +63,7 @@
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdebug.h>
#include <QtCore/qtextstream.h>
+#include <QtCore/qoperatingsystemversion.h>
#include <QtCore/qsysinfo.h>
#include <QtCore/qcache.h>
#include <QtCore/qthread.h>
@@ -78,6 +79,7 @@
#include <QtFontDatabaseSupport/private/qwindowsfontdatabase_p.h>
#include <private/qhighdpiscaling_p.h>
#include <private/qsystemlibrary_p.h>
+#include <private/qwinregistry_p.h>
#include <algorithm>
@@ -96,7 +98,7 @@ static inline QTextStream& operator<<(QTextStream &str, const QColor &c)
{
str.setIntegerBase(16);
str.setFieldWidth(2);
- str.setPadChar(QLatin1Char('0'));
+ str.setPadChar(u'0');
str << " rgb: #" << c.red() << c.green() << c.blue();
str.setIntegerBase(10);
str.setFieldWidth(0);
@@ -164,7 +166,7 @@ public:
QMutexLocker readyLocker(&m_readyMutex);
while (!m_cancelled.loadRelaxed()) {
if (!m_params && !m_cancelled.loadRelaxed()
- && !m_readyCondition.wait(&m_readyMutex, 1000))
+ && !m_readyCondition.wait(&m_readyMutex, QDeadlineTimer(1000ll)))
continue;
if (m_params) {
@@ -189,7 +191,7 @@ public:
CoUninitialize();
}
- bool runWithParams(QShGetFileInfoParams *params, unsigned long timeOutMSecs)
+ bool runWithParams(QShGetFileInfoParams *params, qint64 timeOutMSecs)
{
QMutexLocker doneLocker(&m_doneMutex);
@@ -198,7 +200,7 @@ public:
m_readyCondition.wakeAll();
m_readyMutex.unlock();
- return m_doneCondition.wait(&m_doneMutex, timeOutMSecs);
+ return m_doneCondition.wait(&m_doneMutex, QDeadlineTimer(timeOutMSecs));
}
void cancel()
@@ -220,7 +222,7 @@ private:
static bool shGetFileInfoBackground(const QString &fileName, DWORD attributes,
SHFILEINFO *info, UINT flags,
- unsigned long timeOutMSecs = 5000)
+ qint64 timeOutMSecs = 5000)
{
static QShGetFileInfoThread *getFileInfoThread = nullptr;
if (!getFileInfoThread) {
@@ -241,6 +243,15 @@ static bool shGetFileInfoBackground(const QString &fileName, DWORD attributes,
return result;
}
+// Dark Mode constants
+enum DarkModeColors : QRgb {
+ darkModeBtnHighlightRgb = 0xc0c0c0,
+ darkModeBtnShadowRgb = 0x808080,
+ darkModeHighlightRgb = 0x0055ff, // deviating from 0x800080
+ darkModeMenuHighlightRgb = darkModeHighlightRgb,
+ darkModeGrayTextRgb = 0x00ff00
+};
+
// from QStyle::standardPalette
static inline QPalette standardPalette()
{
@@ -258,23 +269,55 @@ static inline QPalette standardPalette()
return palette;
}
-static inline QPalette systemPalette()
+static void populateLightSystemBasePalette(QPalette &result)
{
- QPalette result = standardPalette();
result.setColor(QPalette::WindowText, getSysColor(COLOR_WINDOWTEXT));
- result.setColor(QPalette::Button, getSysColor(COLOR_BTNFACE));
- result.setColor(QPalette::Light, getSysColor(COLOR_BTNHIGHLIGHT));
+ const QColor btnFace = getSysColor(COLOR_BTNFACE);
+ result.setColor(QPalette::Button, btnFace);
+ const QColor btnHighlight = getSysColor(COLOR_BTNHIGHLIGHT);
+ result.setColor(QPalette::Light, btnHighlight);
result.setColor(QPalette::Dark, getSysColor(COLOR_BTNSHADOW));
result.setColor(QPalette::Mid, result.button().color().darker(150));
result.setColor(QPalette::Text, getSysColor(COLOR_WINDOWTEXT));
- result.setColor(QPalette::BrightText, getSysColor(COLOR_BTNHIGHLIGHT));
+ result.setColor(QPalette::BrightText, btnHighlight);
result.setColor(QPalette::Base, getSysColor(COLOR_WINDOW));
- result.setColor(QPalette::Window, getSysColor(COLOR_BTNFACE));
+ result.setColor(QPalette::Window, btnFace);
result.setColor(QPalette::ButtonText, getSysColor(COLOR_BTNTEXT));
result.setColor(QPalette::Midlight, getSysColor(COLOR_3DLIGHT));
result.setColor(QPalette::Shadow, getSysColor(COLOR_3DDKSHADOW));
result.setColor(QPalette::Highlight, getSysColor(COLOR_HIGHLIGHT));
result.setColor(QPalette::HighlightedText, getSysColor(COLOR_HIGHLIGHTTEXT));
+}
+
+static void populateDarkSystemBasePalette(QPalette &result)
+{
+ const QColor darkModeWindowText = Qt::white;
+ result.setColor(QPalette::WindowText, darkModeWindowText);
+ const QColor darkModebtnFace = Qt::black;
+ result.setColor(QPalette::Button, darkModebtnFace);
+ const QColor btnHighlight = QColor(darkModeBtnHighlightRgb);
+ result.setColor(QPalette::Light, btnHighlight);
+ result.setColor(QPalette::Dark, QColor(darkModeBtnShadowRgb));
+ result.setColor(QPalette::Mid, result.button().color().darker(150));
+ result.setColor(QPalette::Text, darkModeWindowText);
+ result.setColor(QPalette::BrightText, btnHighlight);
+ result.setColor(QPalette::Base, darkModebtnFace);
+ result.setColor(QPalette::Window, darkModebtnFace);
+ result.setColor(QPalette::ButtonText, darkModeWindowText);
+ result.setColor(QPalette::Midlight, darkModeWindowText);
+ result.setColor(QPalette::Shadow, darkModeWindowText);
+ result.setColor(QPalette::Highlight, QColor(darkModeHighlightRgb));
+ result.setColor(QPalette::HighlightedText, darkModeWindowText);
+}
+
+static QPalette systemPalette(bool light)
+{
+ QPalette result = standardPalette();
+ if (light)
+ populateLightSystemBasePalette(result);
+ else
+ populateDarkSystemBasePalette(result);
+
result.setColor(QPalette::Link, Qt::blue);
result.setColor(QPalette::LinkVisited, Qt::magenta);
result.setColor(QPalette::Inactive, QPalette::Button, result.button().color());
@@ -300,19 +343,19 @@ static inline QPalette systemPalette()
result.setColor(QPalette::Disabled, QPalette::Text, disabled);
result.setColor(QPalette::Disabled, QPalette::ButtonText, disabled);
result.setColor(QPalette::Disabled, QPalette::Highlight,
- getSysColor(COLOR_HIGHLIGHT));
+ light ? getSysColor(COLOR_HIGHLIGHT) : QColor(darkModeHighlightRgb));
result.setColor(QPalette::Disabled, QPalette::HighlightedText,
- getSysColor(COLOR_HIGHLIGHTTEXT));
+ light ? getSysColor(COLOR_HIGHLIGHTTEXT) : QColor(Qt::white));
result.setColor(QPalette::Disabled, QPalette::Base,
result.window().color());
return result;
}
-static inline QPalette toolTipPalette(const QPalette &systemPalette)
+static inline QPalette toolTipPalette(const QPalette &systemPalette, bool light)
{
QPalette result(systemPalette);
- const QColor tipBgColor(getSysColor(COLOR_INFOBK));
- const QColor tipTextColor(getSysColor(COLOR_INFOTEXT));
+ const QColor tipBgColor = light ? getSysColor(COLOR_INFOBK) : QColor(Qt::black);
+ const QColor tipTextColor = light ? getSysColor(COLOR_INFOTEXT) : QColor(Qt::white);
result.setColor(QPalette::All, QPalette::Button, tipBgColor);
result.setColor(QPalette::All, QPalette::Window, tipBgColor);
@@ -337,12 +380,13 @@ static inline QPalette toolTipPalette(const QPalette &systemPalette)
return result;
}
-static inline QPalette menuPalette(const QPalette &systemPalette)
+static inline QPalette menuPalette(const QPalette &systemPalette, bool light)
{
QPalette result(systemPalette);
- const QColor menuColor(getSysColor(COLOR_MENU));
- const QColor menuTextColor(getSysColor(COLOR_MENUTEXT));
- const QColor disabled(getSysColor(COLOR_GRAYTEXT));
+ const QColor menuColor = light ? getSysColor(COLOR_MENU) : QColor(Qt::black);
+ const QColor menuTextColor = light ? getSysColor(COLOR_MENUTEXT) : QColor(Qt::white);
+ const QColor disabled = light
+ ? getSysColor(COLOR_GRAYTEXT) : QColor(darkModeGrayTextRgb);
// we might need a special color group for the result.
result.setColor(QPalette::Active, QPalette::Button, menuColor);
result.setColor(QPalette::Active, QPalette::Text, menuTextColor);
@@ -351,8 +395,10 @@ static inline QPalette menuPalette(const QPalette &systemPalette)
result.setColor(QPalette::Disabled, QPalette::WindowText, disabled);
result.setColor(QPalette::Disabled, QPalette::Text, disabled);
const bool isFlat = booleanSystemParametersInfo(SPI_GETFLATMENU, false);
- result.setColor(QPalette::Disabled, QPalette::Highlight,
- getSysColor(isFlat ? COLOR_MENUHILIGHT : COLOR_HIGHLIGHT));
+ const QColor highlightColor = light
+ ? (getSysColor(isFlat ? COLOR_MENUHILIGHT : COLOR_HIGHLIGHT))
+ : QColor(darkModeMenuHighlightRgb);
+ result.setColor(QPalette::Disabled, QPalette::Highlight, highlightColor);
result.setColor(QPalette::Disabled, QPalette::HighlightedText, disabled);
result.setColor(QPalette::Disabled, QPalette::Button,
result.color(QPalette::Active, QPalette::Button));
@@ -373,12 +419,12 @@ static inline QPalette menuPalette(const QPalette &systemPalette)
return result;
}
-static inline QPalette *menuBarPalette(const QPalette &menuPalette)
+static inline QPalette *menuBarPalette(const QPalette &menuPalette, bool light)
{
QPalette *result = nullptr;
if (booleanSystemParametersInfo(SPI_GETFLATMENU, false)) {
result = new QPalette(menuPalette);
- const QColor menubar(getSysColor(COLOR_MENUBAR));
+ const QColor menubar(light ? getSysColor(COLOR_MENUBAR) : QColor(Qt::black));
result->setColor(QPalette::Active, QPalette::Button, menubar);
result->setColor(QPalette::Disabled, QPalette::Button, menubar);
result->setColor(QPalette::Inactive, QPalette::Button, menubar);
@@ -466,6 +512,8 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const
result = int(scrollLines);
return QVariant(result);
}
+ case MouseDoubleClickDistance:
+ return GetSystemMetrics(SM_CXDOUBLECLK);
default:
break;
}
@@ -483,10 +531,26 @@ void QWindowsTheme::refreshPalettes()
if (!QGuiApplication::desktopSettingsAware())
return;
- m_palettes[SystemPalette] = new QPalette(systemPalette());
- m_palettes[ToolTipPalette] = new QPalette(toolTipPalette(*m_palettes[SystemPalette]));
- m_palettes[MenuPalette] = new QPalette(menuPalette(*m_palettes[SystemPalette]));
- m_palettes[MenuBarPalette] = menuBarPalette(*m_palettes[MenuPalette]);
+ const bool light =
+ !QWindowsContext::isDarkMode()
+ || (QWindowsIntegration::instance()->options() & QWindowsIntegration::DarkModeStyle) == 0;
+ m_palettes[SystemPalette] = new QPalette(systemPalette(light));
+ m_palettes[ToolTipPalette] = new QPalette(toolTipPalette(*m_palettes[SystemPalette], light));
+ m_palettes[MenuPalette] = new QPalette(menuPalette(*m_palettes[SystemPalette], light));
+ m_palettes[MenuBarPalette] = menuBarPalette(*m_palettes[MenuPalette], light);
+ if (!light) {
+ m_palettes[ButtonPalette] = new QPalette(*m_palettes[SystemPalette]);
+ m_palettes[ButtonPalette]->setColor(QPalette::Button, QColor(0x666666u));
+ const QColor checkBoxBlue(0x0078d7u);
+ const QColor white(Qt::white);
+ m_palettes[CheckBoxPalette] = new QPalette(*m_palettes[SystemPalette]);
+ m_palettes[CheckBoxPalette]->setColor(QPalette::Window, checkBoxBlue);
+ m_palettes[CheckBoxPalette]->setColor(QPalette::Base, checkBoxBlue);
+ m_palettes[CheckBoxPalette]->setColor(QPalette::Button, checkBoxBlue);
+ m_palettes[CheckBoxPalette]->setColor(QPalette::ButtonText, white);
+ m_palettes[RadioButtonPalette] = new QPalette(*m_palettes[CheckBoxPalette]);
+
+ }
}
void QWindowsTheme::clearFonts()
@@ -495,6 +559,12 @@ void QWindowsTheme::clearFonts()
std::fill(m_fonts, m_fonts + NFonts, nullptr);
}
+void QWindowsTheme::refresh()
+{
+ refreshPalettes();
+ refreshFonts();
+}
+
void QWindowsTheme::refreshFonts()
{
clearFonts();
@@ -729,13 +799,13 @@ static QString dirIconPixmapCacheKey(int iIcon, int iconSize, int imageListSize)
{
QString key = QLatin1String("qt_dir_") + QString::number(iIcon);
if (iconSize == SHGFI_LARGEICON)
- key += QLatin1Char('l');
+ key += u'l';
switch (imageListSize) {
case sHIL_EXTRALARGE:
- key += QLatin1Char('e');
+ key += u'e';
break;
case sHIL_JUMBO:
- key += QLatin1Char('j');
+ key += u'j';
break;
}
return key;
@@ -813,9 +883,9 @@ QString QWindowsFileIconEngine::cacheKey() const
// It is faster to just look at the file extensions;
// avoiding slow QFileInfo::isExecutable() (QTBUG-13182)
QString suffix = fileInfo().suffix();
- if (!suffix.compare(QLatin1String("exe"), Qt::CaseInsensitive)
- || !suffix.compare(QLatin1String("lnk"), Qt::CaseInsensitive)
- || !suffix.compare(QLatin1String("ico"), Qt::CaseInsensitive)) {
+ if (!suffix.compare(u"exe", Qt::CaseInsensitive)
+ || !suffix.compare(u"lnk", Qt::CaseInsensitive)
+ || !suffix.compare(u"ico", Qt::CaseInsensitive)) {
return QString();
}
return QLatin1String("qt_.")
@@ -944,6 +1014,23 @@ bool QWindowsTheme::useNativeMenus()
return result;
}
+bool QWindowsTheme::queryDarkMode()
+{
+ if (QOperatingSystemVersion::current()
+ < QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 17763)
+ || queryHighContrast()) {
+ return false;
+ }
+ const auto setting = QWinRegistryKey(HKEY_CURRENT_USER, LR"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)")
+ .dwordValue(L"AppsUseLightTheme");
+ return setting.second && setting.first == 0;
+}
+
+bool QWindowsTheme::queryHighContrast()
+{
+ return booleanSystemParametersInfo(SPI_GETHIGHCONTRAST, false);
+}
+
QPlatformMenuItem *QWindowsTheme::createPlatformMenuItem() const
{
qCDebug(lcQpaMenus) << __FUNCTION__;
diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h
index 07120230ce..af28f2878c 100644
--- a/src/plugins/platforms/windows/qwindowstheme.h
+++ b/src/plugins/platforms/windows/qwindowstheme.h
@@ -71,7 +71,7 @@ public:
QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const override;
- QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions = nullptr) const override;
+ QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions = {}) const override;
void windowsThemeChanged(QWindow *window);
void displayChanged() { refreshIconPixmapSizes(); }
@@ -84,13 +84,15 @@ public:
void showPlatformMenuBar() override;
static bool useNativeMenus();
+ static bool queryDarkMode();
+ static bool queryHighContrast();
void refreshFonts();
+ void refresh();
static const char *name;
private:
- void refresh() { refreshPalettes(); refreshFonts(); }
void clearPalettes();
void refreshPalettes();
void clearFonts();
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 5c13bd9650..d22cc75647 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -253,7 +253,7 @@ QDebug operator<<(QDebug d, const GUID &guid)
{
QDebugStateSaver saver(d);
d.nospace();
- d << '{' << Qt::hex << Qt::uppercasedigits << qSetPadChar(QLatin1Char('0'))
+ d << '{' << Qt::hex << Qt::uppercasedigits << qSetPadChar(u'0')
<< qSetFieldWidth(8) << guid.Data1
<< qSetFieldWidth(0) << '-' << qSetFieldWidth(4)
<< guid.Data2 << qSetFieldWidth(0) << '-' << qSetFieldWidth(4)
@@ -592,7 +592,7 @@ static QPoint calcPosition(const QWindow *w, const QWindowCreationContextPtr &co
return posFrame;
// Find the original screen containing the coordinates.
- const QList<QScreen *> screens = screenForGL->virtualSiblings();
+ const auto screens = screenForGL->virtualSiblings();
const QScreen *orgScreen = nullptr;
for (QScreen *screen : screens) {
if (screen->handle()->availableGeometry().contains(posFrame)) {
@@ -749,6 +749,11 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag
}
}
+static inline bool shouldApplyDarkFrame(const QWindow *w)
+{
+ return w->isTopLevel() && !w->flags().testFlag(Qt::FramelessWindowHint);
+}
+
QWindowsWindowData
WindowCreationData::create(const QWindow *w, const WindowData &data, QString title) const
{
@@ -759,7 +764,10 @@ QWindowsWindowData
const QString windowClassName = QWindowsContext::instance()->registerWindowClass(w);
- const QRect rect = QPlatformWindow::initialGeometry(w, data.geometry, defaultWindowWidth, defaultWindowHeight);
+ const QScreen *screen{};
+ const QRect rect = QPlatformWindow::initialGeometry(w, data.geometry,
+ defaultWindowWidth, defaultWindowHeight,
+ &screen);
if (title.isEmpty() && (result.flags & Qt::WindowTitleHint))
title = topLevel ? qAppName() : w->objectName();
@@ -769,7 +777,9 @@ QWindowsWindowData
// Capture events before CreateWindowEx() returns. The context is cleared in
// the QWindowsWindow constructor.
- const QWindowCreationContextPtr context(new QWindowCreationContext(w, data.geometry, rect, data.customMargins, style, exStyle));
+ const QWindowCreationContextPtr context(new QWindowCreationContext(w, screen, data.geometry,
+ rect, data.customMargins,
+ style, exStyle));
QWindowsContext::instance()->setWindowCreationContext(context);
const bool hasFrame = (style & (WS_DLGFRAME | WS_THICKFRAME));
@@ -811,6 +821,12 @@ QWindowsWindowData
return result;
}
+ if (QWindowsContext::isDarkMode()
+ && (QWindowsIntegration::instance()->options() & QWindowsIntegration::DarkModeWindowFrames) != 0
+ && shouldApplyDarkFrame(w)) {
+ QWindowsWindow::setDarkBorderToWindow(result.hwnd, true);
+ }
+
if (mirrorParentWidth != 0) {
context->obtainedPos.setX(mirrorParentWidth - context->obtainedSize.width()
- context->obtainedPos.x());
@@ -879,10 +895,10 @@ void WindowCreationData::initialize(const QWindow *w, HWND hwnd, bool frameChang
// Scaling helpers for size constraints.
-static QSize toNativeSizeConstrained(QSize dip, const QWindow *w)
+static QSize toNativeSizeConstrained(QSize dip, const QScreen *s)
{
if (QHighDpiScaling::isActive()) {
- const qreal factor = QHighDpiScaling::factor(w);
+ const qreal factor = QHighDpiScaling::factor(s);
if (!qFuzzyCompare(factor, qreal(1))) {
if (dip.width() > 0 && dip.width() < QWINDOWSIZE_MAX)
dip.setWidth(qRound(qreal(dip.width()) * factor));
@@ -995,11 +1011,12 @@ bool QWindowsGeometryHint::handleCalculateSize(const QMargins &customMargins, co
return true;
}
-void QWindowsGeometryHint::frameSizeConstraints(const QWindow *w, const QMargins &margins,
+void QWindowsGeometryHint::frameSizeConstraints(const QWindow *w, const QScreen *screen,
+ const QMargins &margins,
QSize *minimumSize, QSize *maximumSize)
{
- *minimumSize = toNativeSizeConstrained(w->minimumSize(), w);
- *maximumSize = toNativeSizeConstrained(w->maximumSize(), w);
+ *minimumSize = toNativeSizeConstrained(w->minimumSize(), screen);
+ *maximumSize = toNativeSizeConstrained(w->maximumSize(), screen);
const int maximumWidth = qMax(maximumSize->width(), minimumSize->width());
const int maximumHeight = qMax(maximumSize->height(), minimumSize->height());
@@ -1017,12 +1034,13 @@ void QWindowsGeometryHint::frameSizeConstraints(const QWindow *w, const QMargins
}
void QWindowsGeometryHint::applyToMinMaxInfo(const QWindow *w,
+ const QScreen *screen,
const QMargins &margins,
MINMAXINFO *mmi)
{
QSize minimumSize;
QSize maximumSize;
- frameSizeConstraints(w, margins, &minimumSize, &maximumSize);
+ frameSizeConstraints(w, screen, margins, &minimumSize, &maximumSize);
qCDebug(lcQpaWindows).nospace() << '>' << __FUNCTION__ << '<' << " min="
<< minimumSize.width() << ',' << minimumSize.height()
<< " max=" << maximumSize.width() << ',' << maximumSize.height()
@@ -1041,6 +1059,13 @@ void QWindowsGeometryHint::applyToMinMaxInfo(const QWindow *w,
qCDebug(lcQpaWindows).nospace() << '<' << __FUNCTION__ << " out " << *mmi;
}
+void QWindowsGeometryHint::applyToMinMaxInfo(const QWindow *w,
+ const QMargins &margins,
+ MINMAXINFO *mmi)
+{
+ applyToMinMaxInfo(w, w->screen(), margins, mmi);
+}
+
bool QWindowsGeometryHint::positionIncludesFrame(const QWindow *w)
{
return qt_window_private(const_cast<QWindow *>(w))->positionPolicy
@@ -1226,11 +1251,12 @@ void QWindowsForeignWindow::setVisible(bool visible)
\ingroup qt-lighthouse-win
*/
-QWindowCreationContext::QWindowCreationContext(const QWindow *w,
+QWindowCreationContext::QWindowCreationContext(const QWindow *w, const QScreen *s,
const QRect &geometryIn, const QRect &geometry,
const QMargins &cm,
DWORD style, DWORD exStyle) :
window(w),
+ screen(s),
requestedGeometryIn(geometryIn),
requestedGeometry(geometry),
obtainedPos(geometryIn.topLeft()),
@@ -1270,7 +1296,7 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w,
void QWindowCreationContext::applyToMinMaxInfo(MINMAXINFO *mmi) const
{
- QWindowsGeometryHint::applyToMinMaxInfo(window, margins + customMargins, mmi);
+ QWindowsGeometryHint::applyToMinMaxInfo(window, screen, margins + customMargins, mmi);
}
/*!
@@ -2877,6 +2903,39 @@ bool QWindowsWindow::isTopLevel() const
return window()->isTopLevel() && !m_data.embedded;
}
+enum : WORD {
+ DwmwaUseImmersiveDarkMode = 20,
+ DwmwaUseImmersiveDarkModeBefore20h1 = 19
+};
+
+static bool queryDarkBorder(HWND hwnd)
+{
+ BOOL result = FALSE;
+ const bool ok =
+ SUCCEEDED(DwmGetWindowAttribute(hwnd, DwmwaUseImmersiveDarkMode, &result, sizeof(result)))
+ || SUCCEEDED(DwmGetWindowAttribute(hwnd, DwmwaUseImmersiveDarkModeBefore20h1, &result, sizeof(result)));
+ if (!ok)
+ qWarning("%s: Unable to retrieve dark window border setting.", __FUNCTION__);
+ return result == TRUE;
+}
+
+bool QWindowsWindow::setDarkBorderToWindow(HWND hwnd, bool d)
+{
+ const BOOL darkBorder = d ? TRUE : FALSE;
+ const bool ok =
+ SUCCEEDED(DwmSetWindowAttribute(hwnd, DwmwaUseImmersiveDarkMode, &darkBorder, sizeof(darkBorder)))
+ || SUCCEEDED(DwmSetWindowAttribute(hwnd, DwmwaUseImmersiveDarkModeBefore20h1, &darkBorder, sizeof(darkBorder)));
+ if (!ok)
+ qWarning("%s: Unable to set dark window border.", __FUNCTION__);
+ return ok;
+}
+
+void QWindowsWindow::setDarkBorder(bool d)
+{
+ if (shouldApplyDarkFrame(window()) && queryDarkBorder(m_data.hwnd) != d)
+ setDarkBorderToWindow(m_data.hwnd, d);
+}
+
QWindowsMenuBar *QWindowsWindow::menuBar() const
{
return m_menuBar.data();
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
index 7efbcf900c..7c37c6b115 100644
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
@@ -66,9 +66,12 @@ struct QWindowsGeometryHint
static QMargins frame(const QWindow *w, const QRect &geometry,
DWORD style, DWORD exStyle);
static bool handleCalculateSize(const QMargins &customMargins, const MSG &msg, LRESULT *result);
+ static void applyToMinMaxInfo(const QWindow *w, const QScreen *screen,
+ const QMargins &margins, MINMAXINFO *mmi);
static void applyToMinMaxInfo(const QWindow *w, const QMargins &margins,
MINMAXINFO *mmi);
- static void frameSizeConstraints(const QWindow *w, const QMargins &margins,
+ static void frameSizeConstraints(const QWindow *w, const QScreen *screen,
+ const QMargins &margins,
QSize *minimumSize, QSize *maximumSize);
static inline QPoint mapToGlobal(HWND hwnd, const QPoint &);
static inline QPoint mapToGlobal(const QWindow *w, const QPoint &);
@@ -80,13 +83,16 @@ struct QWindowsGeometryHint
struct QWindowCreationContext
{
- explicit QWindowCreationContext(const QWindow *w,
+ explicit QWindowCreationContext(const QWindow *w, const QScreen *s,
const QRect &geometryIn, const QRect &geometry,
const QMargins &customMargins,
DWORD style, DWORD exStyle);
void applyToMinMaxInfo(MINMAXINFO *mmi) const;
const QWindow *window;
+ // The screen to use to scale size constraints, etc. Might differ from the
+ // screen of the window after QPlatformWindow::initialGeometry() (QTBUG-77307).
+ const QScreen *screen;
QRect requestedGeometryIn; // QWindow scaled
QRect requestedGeometry; // after QPlatformWindow::initialGeometry()
QPoint obtainedPos;
@@ -281,6 +287,9 @@ public:
HWND handle() const override { return m_data.hwnd; }
bool isTopLevel() const override;
+ static bool setDarkBorderToWindow(HWND hwnd, bool d);
+ void setDarkBorder(bool d);
+
QWindowsMenuBar *menuBar() const;
void setMenuBar(QWindowsMenuBar *mb);
diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp
index c7c0deab3f..32a57473ad 100644
--- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp
+++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp
@@ -52,6 +52,8 @@
#include <qpa/qplatformintegration.h>
#include <QtWindowsUIAutomationSupport/private/qwindowsuiawrapper_p.h>
+#include <QtCore/private/qwinregistry_p.h>
+
QT_BEGIN_NAMESPACE
using namespace QWindowsUiAutomation;
@@ -85,12 +87,63 @@ bool QWindowsUiaAccessibility::handleWmGetObject(HWND hwnd, WPARAM wParam, LPARA
return false;
}
+// Retrieve sound name by checking the icon property of a message box
+// should it be the event object.
+static QString alertSound(const QObject *object)
+{
+ if (object->inherits("QMessageBox")) {
+ enum MessageBoxIcon { // Keep in sync with QMessageBox::Icon
+ Information = 1,
+ Warning = 2,
+ Critical = 3
+ };
+ switch (object->property("icon").toInt()) {
+ case Information:
+ return QStringLiteral("SystemAsterisk");
+ case Warning:
+ return QStringLiteral("SystemExclamation");
+ case Critical:
+ return QStringLiteral("SystemHand");
+ }
+ }
+ return QStringLiteral("SystemAsterisk");
+}
+
+static QString soundFileName(const QString &soundName)
+{
+ const QString key = QStringLiteral("AppEvents\\Schemes\\Apps\\.Default\\")
+ + soundName + QStringLiteral("\\.Current");
+ return QWinRegistryKey(HKEY_CURRENT_USER, key).stringValue(L"");
+}
+
+static void playSystemSound(const QString &soundName)
+{
+ if (!soundName.isEmpty() && !soundFileName(soundName).isEmpty()) {
+ PlaySound(reinterpret_cast<const wchar_t *>(soundName.utf16()), nullptr,
+ SND_ALIAS | SND_ASYNC | SND_NODEFAULT | SND_NOWAIT);
+ }
+}
+
// Handles accessibility update notifications.
void QWindowsUiaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event)
{
if (!event)
return;
+ switch (event->type()) {
+ case QAccessible::PopupMenuStart:
+ playSystemSound(QStringLiteral("MenuPopup"));
+ break;
+ case QAccessible::MenuCommand:
+ playSystemSound(QStringLiteral("MenuCommand"));
+ break;
+ case QAccessible::Alert:
+ playSystemSound(alertSound(event->object()));
+ break;
+ default:
+ break;
+ }
+
QAccessibleInterface *accessible = event->accessibleInterface();
if (!isActive() || !accessible || !accessible->isValid())
return;
diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
index b2b401dd40..5f564f81c2 100644
--- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
+++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
@@ -277,8 +277,9 @@ HRESULT QWindowsUiaMainProvider::GetPatternProvider(PATTERNID idPattern, IUnknow
}
break;
case UIA_ValuePatternId:
- // All accessible controls return text(QAccessible::Value) (which may be empty).
- *pRetVal = new QWindowsUiaValueProvider(id());
+ // All non-static controls support the Value pattern.
+ if (accessible->role() != QAccessible::StaticText)
+ *pRetVal = new QWindowsUiaValueProvider(id());
break;
case UIA_RangeValuePatternId:
// Controls providing a numeric value within a range (e.g., sliders, scroll bars, dials).
@@ -288,7 +289,8 @@ HRESULT QWindowsUiaMainProvider::GetPatternProvider(PATTERNID idPattern, IUnknow
break;
case UIA_TogglePatternId:
// Checkbox controls.
- if (accessible->role() == QAccessible::CheckBox) {
+ if (accessible->role() == QAccessible::CheckBox
+ || (accessible->role() == QAccessible::MenuItem && accessible->state().checkable)) {
*pRetVal = new QWindowsUiaToggleProvider(id());
}
break;
@@ -389,7 +391,19 @@ HRESULT QWindowsUiaMainProvider::GetPropertyValue(PROPERTYID idProp, VARIANT *pR
setVariantI4(UIA_WindowControlTypeId, pRetVal);
} else {
// Control type converted from role.
- setVariantI4(roleToControlTypeId(accessible->role()), pRetVal);
+ auto controlType = roleToControlTypeId(accessible->role());
+
+ // The native OSK should be disbled if the Qt OSK is in use,
+ // or if disabled via application attribute.
+ static bool imModuleEmpty = qEnvironmentVariableIsEmpty("QT_IM_MODULE");
+ bool nativeVKDisabled = QCoreApplication::testAttribute(Qt::AA_MSWindowsDisableVirtualKeyboard);
+
+ // If we want to disable the native OSK auto-showing
+ // we have to report text fields as non-editable.
+ if (controlType == UIA_EditControlTypeId && (!imModuleEmpty || nativeVKDisabled))
+ controlType = UIA_TextControlTypeId;
+
+ setVariantI4(controlType, pRetVal);
}
break;
case UIA_HelpTextPropertyId:
@@ -461,7 +475,7 @@ QString QWindowsUiaMainProvider::automationIdForAccessible(const QAccessibleInte
if (name.isEmpty())
return QString();
if (!result.isEmpty())
- result.prepend(QLatin1Char('.'));
+ result.prepend(u'.');
result.prepend(name);
obj = obj->parent();
}
diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp
index 3305e9c5c4..fb41012cf4 100644
--- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp
+++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp
@@ -49,6 +49,7 @@
#include <QtCore/qloggingcategory.h>
#include <QtCore/qstring.h>
#include <QtCore/qlist.h>
+#include <QtCore/qvector.h>
QT_BEGIN_NAMESPACE
@@ -78,7 +79,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaSelectionProvider::GetSelection(SAFEARRAY *
return UIA_E_ELEMENTNOTAVAILABLE;
// First put selected items in a list, then build a safe array with the right size.
- QList<QAccessibleInterface *> selectedList;
+ QVector<QAccessibleInterface *> selectedList;
for (int i = 0; i < accessible->childCount(); ++i) {
if (QAccessibleInterface *child = accessible->child(i)) {
if (child->state().selected) {
diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp
index 2a94012590..1348ec7cc0 100644
--- a/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp
+++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp
@@ -80,7 +80,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetRowHeaderItems(SAFEAR
if (!tableCellInterface)
return UIA_E_ELEMENTNOTAVAILABLE;
- QList<QAccessibleInterface *> headers = tableCellInterface->rowHeaderCells();
+ const auto headers = tableCellInterface->rowHeaderCells();
if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) {
for (LONG i = 0; i < headers.size(); ++i) {
@@ -110,7 +110,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetColumnHeaderItems(SAF
if (!tableCellInterface)
return UIA_E_ELEMENTNOTAVAILABLE;
- QList<QAccessibleInterface *> headers = tableCellInterface->columnHeaderCells();
+ const auto headers = tableCellInterface->columnHeaderCells();
if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) {
for (LONG i = 0; i < headers.size(); ++i) {
diff --git a/src/plugins/platforms/windows/windows.pro b/src/plugins/platforms/windows/windows.pro
index 50a3bb41a9..8a27bd2770 100644
--- a/src/plugins/platforms/windows/windows.pro
+++ b/src/plugins/platforms/windows/windows.pro
@@ -5,6 +5,8 @@ QT += \
eventdispatcher_support-private \
fontdatabase_support-private theme_support-private
+qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private
+
qtConfig(accessibility): QT += accessibility_support-private
qtConfig(vulkan): QT += vulkan_support-private
diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp
index 27d3746933..dd8cd80fd9 100644
--- a/src/plugins/platforms/winrt/qwinrtintegration.cpp
+++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp
@@ -53,6 +53,9 @@
#if QT_CONFIG(accessibility)
# include "uiautomation/qwinrtuiaaccessibility.h"
#endif
+#if QT_CONFIG(opengl)
+#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h>
+#endif
#include <QtGui/QOffscreenSurface>
#include <QtGui/QOpenGLContext>
@@ -205,7 +208,11 @@ QPlatformWindow *QWinRTIntegration::createPlatformWindow(QWindow *window) const
QPlatformBackingStore *QWinRTIntegration::createPlatformBackingStore(QWindow *window) const
{
- return new QWinRTBackingStore(window);
+ auto *backingStore = new QWinRTBackingStore(window);
+#if QT_CONFIG(opengl)
+ backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
+#endif
+ return backingStore;
}
QPlatformOpenGLContext *QWinRTIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
diff --git a/src/plugins/platforms/winrt/winrt.pro b/src/plugins/platforms/winrt/winrt.pro
index 43dc8f074c..7ac49f73c4 100644
--- a/src/plugins/platforms/winrt/winrt.pro
+++ b/src/plugins/platforms/winrt/winrt.pro
@@ -6,6 +6,8 @@ QT += \
core-private gui-private \
fontdatabase_support-private egl_support-private
+qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private
+
DEFINES *= QT_NO_CAST_FROM_ASCII __WRL_NO_DEFAULT_LIB__
QMAKE_USE_PRIVATE += d3d11 ws2_32
diff --git a/src/plugins/platforms/xcb/.prev_CMakeLists.txt b/src/plugins/platforms/xcb/.prev_CMakeLists.txt
index a58d815db2..427997fc66 100644
--- a/src/plugins/platforms/xcb/.prev_CMakeLists.txt
+++ b/src/plugins/platforms/xcb/.prev_CMakeLists.txt
@@ -4,7 +4,7 @@
## XcbQpa Module:
#####################################################################
-add_qt_module(XcbQpa
+qt_add_module(XcbQpa
INTERNAL_MODULE
NO_MODULE_HEADERS
SOURCES
@@ -38,7 +38,7 @@ add_qt_module(XcbQpa
QT_NO_FOREACH
INCLUDE_DIRECTORIES
gl_integrations
- LIBRARIES
+ PUBLIC_LIBRARIES
Qt::CorePrivate
Qt::EdidSupportPrivate
Qt::FontDatabaseSupportPrivate
@@ -46,14 +46,6 @@ add_qt_module(XcbQpa
Qt::ServiceSupportPrivate
Qt::ThemeSupportPrivate
Qt::XkbCommonSupportPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::EdidSupport
- Qt::FontDatabaseSupport
- Qt::Gui
- Qt::ServiceSupport
- Qt::ThemeSupport
- Qt::XkbCommonSupport
XCB::ICCCM
XCB::IMAGE
XCB::KEYSYMS
@@ -71,62 +63,60 @@ add_qt_module(XcbQpa
XKB::XKB
)
-#### Keys ignored in scope 2:.:.:xcb_qpa_lib.pro:<TRUE>:
-# _LOADED = "qt_build_paths" "qt_module"
-
## Scopes:
#####################################################################
-extend_target(XcbQpa CONDITION TARGET Qt::LinuxAccessibilitySupportPrivate
- LIBRARIES
- Qt::LinuxAccessibilitySupportPrivate
+qt_extend_target(XcbQpa CONDITION TARGET Qt::PlatformCompositorSupportPrivate
+ PUBLIC_LIBRARIES
+ Qt::PlatformCompositorSupportPrivate
+)
+
+qt_extend_target(XcbQpa CONDITION TARGET Qt::LinuxAccessibilitySupportPrivate
PUBLIC_LIBRARIES
- Qt::LinuxAccessibilitySupport
+ Qt::LinuxAccessibilitySupportPrivate
)
-extend_target(XcbQpa CONDITION QT_FEATURE_vulkan
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_vulkan
SOURCES
qxcbvulkaninstance.cpp qxcbvulkaninstance.h
qxcbvulkanwindow.cpp qxcbvulkanwindow.h
- LIBRARIES
- Qt::VulkanSupportPrivate
PUBLIC_LIBRARIES
- Qt::VulkanSupport
+ Qt::VulkanSupportPrivate
)
-extend_target(XcbQpa CONDITION QT_FEATURE_glib
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_glib
LIBRARIES
GLIB2::GLIB2
)
-extend_target(XcbQpa CONDITION QT_FEATURE_draganddrop
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_draganddrop
SOURCES
qxcbdrag.cpp qxcbdrag.h
)
-extend_target(XcbQpa CONDITION QT_FEATURE_xcb_xlib
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_xcb_xlib
PUBLIC_LIBRARIES
X11::XCB
)
-extend_target(XcbQpa CONDITION QT_FEATURE_xcb_sm
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_xcb_sm
SOURCES
qxcbsessionmanager.cpp qxcbsessionmanager.h
PUBLIC_LIBRARIES
${X11_SM_LIB} ${X11_ICE_LIB}
)
-extend_target(XcbQpa CONDITION QT_FEATURE_dlopen
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_dlopen
PUBLIC_LIBRARIES
${CMAKE_DL_LIBS}
)
-extend_target(XcbQpa CONDITION CLANG AND NOT ICC
+qt_extend_target(XcbQpa CONDITION CLANG AND NOT ICC
COMPILE_OPTIONS
-ftemplate-depth=1024
)
-extend_target(XcbQpa CONDITION QT_FEATURE_xcb_native_painting
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_xcb_native_painting
SOURCES
nativepainting/qbackingstore_x11.cpp nativepainting/qbackingstore_x11_p.h
nativepainting/qcolormap_x11.cpp nativepainting/qcolormap_x11_p.h
@@ -139,43 +129,38 @@ extend_target(XcbQpa CONDITION QT_FEATURE_xcb_native_painting
nativepainting
)
-extend_target(XcbQpa CONDITION QT_FEATURE_xcb_native_painting AND QT_FEATURE_xrender
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_xcb_native_painting AND QT_FEATURE_xrender
PUBLIC_LIBRARIES
PkgConfig::XRender
)
-extend_target(XcbQpa CONDITION QT_FEATURE_fontconfig AND QT_FEATURE_xcb_native_painting
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_fontconfig AND QT_FEATURE_xcb_native_painting
LIBRARIES
WrapFreetype::WrapFreetype
)
#####################################################################
-## qxcb Plugin:
+## QXcbIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qxcb
+qt_add_plugin(QXcbIntegrationPlugin
+ OUTPUT_NAME qxcb
TYPE platforms
- CLASS_NAME QXcbIntegrationPlugin
SOURCES
qxcbmain.cpp
DEFINES
QT_NO_FOREACH
- LIBRARIES
+ PUBLIC_LIBRARIES
Qt::CorePrivate
Qt::GuiPrivate
Qt::XcbQpaPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::Gui
- Qt::XcbQpa
)
-#### Keys ignored in scope 19:.:.:xcb-plugin.pro:<TRUE>:
+#### Keys ignored in scope 20:.:.:xcb-plugin.pro:<TRUE>:
# OTHER_FILES = "xcb.json" "README"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-#### Keys ignored in scope 21:.:.:xcb-plugin.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
+#### Keys ignored in scope 22:.:.:xcb-plugin.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
# PLUGIN_EXTENDS = "-"
add_subdirectory(gl_integrations)
diff --git a/src/plugins/platforms/xcb/CMakeLists.txt b/src/plugins/platforms/xcb/CMakeLists.txt
index 194cbc79a9..d422d69891 100644
--- a/src/plugins/platforms/xcb/CMakeLists.txt
+++ b/src/plugins/platforms/xcb/CMakeLists.txt
@@ -26,7 +26,7 @@ qt_find_package(XKB_COMMON_X11 PROVIDED_TARGETS PkgConfig::XKB_COMMON_X11)
## XcbQpa Module:
#####################################################################
-add_qt_module(XcbQpa
+qt_add_module(XcbQpa
INTERNAL_MODULE
NO_MODULE_HEADERS
SOURCES
@@ -60,7 +60,7 @@ add_qt_module(XcbQpa
QT_NO_FOREACH
INCLUDE_DIRECTORIES
gl_integrations
- LIBRARIES
+ PUBLIC_LIBRARIES
Qt::CorePrivate
Qt::EdidSupportPrivate
Qt::FontDatabaseSupportPrivate
@@ -69,14 +69,6 @@ add_qt_module(XcbQpa
Qt::ThemeSupportPrivate
Qt::XkbCommonSupportPrivate
PkgConfig::XKB_COMMON_X11 # special case
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::EdidSupport
- Qt::FontDatabaseSupport
- Qt::Gui
- Qt::ServiceSupport
- Qt::ThemeSupport
- Qt::XkbCommonSupport
XCB::ICCCM
XCB::IMAGE
XCB::KEYSYMS
@@ -89,68 +81,66 @@ add_qt_module(XcbQpa
XCB::XCB
XCB::XFIXES
XCB::XINERAMA
- XCB::XINPUT
+ $<$<TARGET_EXISTS:XCB::XINPUT>:XCB::XINPUT> # special case
XCB::XKB
XKB::XKB
)
-#### Keys ignored in scope 2:.:.:xcb_qpa_lib.pro:<TRUE>:
-# _LOADED = "qt_build_paths" "qt_module"
-
## Scopes:
#####################################################################
-extend_target(XcbQpa CONDITION TARGET Qt::LinuxAccessibilitySupportPrivate
- LIBRARIES
- Qt::LinuxAccessibilitySupportPrivate
+qt_extend_target(XcbQpa CONDITION TARGET Qt::PlatformCompositorSupportPrivate
PUBLIC_LIBRARIES
- Qt::LinuxAccessibilitySupport
+ Qt::PlatformCompositorSupportPrivate
+)
+
+qt_extend_target(XcbQpa CONDITION TARGET Qt::LinuxAccessibilitySupportPrivate
+ PUBLIC_LIBRARIES
+ Qt::LinuxAccessibilitySupportPrivate
)
-extend_target(XcbQpa CONDITION QT_FEATURE_vulkan
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_vulkan
SOURCES
qxcbvulkaninstance.cpp qxcbvulkaninstance.h
qxcbvulkanwindow.cpp qxcbvulkanwindow.h
- LIBRARIES
- Qt::VulkanSupportPrivate
PUBLIC_LIBRARIES
- Qt::VulkanSupport
+ Qt::VulkanSupportPrivate
)
-extend_target(XcbQpa CONDITION QT_FEATURE_glib
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_glib
LIBRARIES
GLIB2::GLIB2
)
-extend_target(XcbQpa CONDITION QT_FEATURE_draganddrop
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_draganddrop
SOURCES
qxcbdrag.cpp qxcbdrag.h
)
-extend_target(XcbQpa CONDITION QT_FEATURE_xcb_xlib
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_xcb_xlib
PUBLIC_LIBRARIES
X11::XCB
X11::X11 # special case
)
-extend_target(XcbQpa CONDITION QT_FEATURE_xcb_sm
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_xcb_sm
SOURCES
qxcbsessionmanager.cpp qxcbsessionmanager.h
PUBLIC_LIBRARIES
${X11_SM_LIB} ${X11_ICE_LIB}
)
-extend_target(XcbQpa CONDITION QT_FEATURE_dlopen
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_dlopen
PUBLIC_LIBRARIES
${CMAKE_DL_LIBS}
)
-extend_target(XcbQpa CONDITION CLANG AND NOT ICC
+qt_extend_target(XcbQpa CONDITION CLANG AND NOT ICC
COMPILE_OPTIONS
-ftemplate-depth=1024
)
-extend_target(XcbQpa CONDITION QT_FEATURE_xcb_native_painting
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_xcb_native_painting
SOURCES
nativepainting/qbackingstore_x11.cpp nativepainting/qbackingstore_x11_p.h
nativepainting/qcolormap_x11.cpp nativepainting/qcolormap_x11_p.h
@@ -163,45 +153,55 @@ extend_target(XcbQpa CONDITION QT_FEATURE_xcb_native_painting
nativepainting
)
-extend_target(XcbQpa CONDITION QT_FEATURE_xcb_native_painting AND QT_FEATURE_xrender
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_xcb_native_painting AND QT_FEATURE_xrender
PUBLIC_LIBRARIES
PkgConfig::XRender
)
-extend_target(XcbQpa CONDITION QT_FEATURE_fontconfig AND QT_FEATURE_xcb_native_painting
+qt_extend_target(XcbQpa CONDITION QT_FEATURE_fontconfig AND QT_FEATURE_xcb_native_painting
LIBRARIES
WrapFreetype::WrapFreetype
)
+
+# special case begin
+if (NOT QT_FEATURE_system_xcb_input)
+ set(xinput_source "${PROJECT_SOURCE_DIR}/src/3rdparty/xcb/libxcb/xinput.c")
+ set_source_files_properties(
+ "${xinput_source}"
+ PROPERTIES COMPILE_OPTIONS "-w"
+ )
+ target_sources(XcbQpa PRIVATE "${xinput_source}")
+ target_include_directories(XcbQpa PRIVATE
+ "${PROJECT_SOURCE_DIR}/src/3rdparty/xcb/include"
+ )
+endif()
+# special case end
+
#####################################################################
-## qxcb Plugin:
+## QXcbIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qxcb
+qt_add_plugin(QXcbIntegrationPlugin
+ OUTPUT_NAME qxcb
TYPE platforms
- CLASS_NAME QXcbIntegrationPlugin
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES xcb # special case
SOURCES
qxcbmain.cpp
DEFINES
QT_NO_FOREACH
- LIBRARIES
+ PUBLIC_LIBRARIES
Qt::CorePrivate
Qt::GuiPrivate
Qt::XcbQpaPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::Gui
- Qt::XcbQpa
)
-#### Keys ignored in scope 19:.:.:xcb-plugin.pro:<TRUE>:
+#### Keys ignored in scope 20:.:.:xcb-plugin.pro:<TRUE>:
# OTHER_FILES = "xcb.json" "README"
-# _LOADED = "qt_plugin"
## Scopes:
#####################################################################
-#### Keys ignored in scope 21:.:.:xcb-plugin.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
+#### Keys ignored in scope 22:.:.:xcb-plugin.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
# PLUGIN_EXTENDS = "-"
add_subdirectory(gl_integrations)
if(OFF)
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/CMakeLists.txt b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/CMakeLists.txt
index 4452125e23..a78d01ec87 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/CMakeLists.txt
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from xcb_egl.pro.
#####################################################################
-## qxcb-egl-integration Plugin:
+## QXcbEglIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qxcb-egl-integration
+qt_add_plugin(QXcbEglIntegrationPlugin
+ OUTPUT_NAME qxcb-egl-integration
TYPE xcbglintegrations
- CLASS_NAME QXcbEglIntegrationPlugin
SOURCES
qxcbeglcontext.h
qxcbeglintegration.cpp qxcbeglintegration.h
@@ -18,17 +18,11 @@ add_qt_plugin(qxcb-egl-integration
INCLUDE_DIRECTORIES
..
../..
- LIBRARIES
+ PUBLIC_LIBRARIES
+ Qt::Core
Qt::CorePrivate
Qt::EglSupportPrivate
+ Qt::Gui
Qt::GuiPrivate
Qt::XcbQpaPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::EglSupport
- Qt::Gui
- Qt::XcbQpa
)
-
-#### Keys ignored in scope 1:.:.:xcb_egl.pro:<TRUE>:
-# _LOADED = "qt_plugin" "qt_build_paths"
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h
index c3ce8d8745..fda53f17a1 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h
@@ -52,7 +52,7 @@ class QXcbEglContext : public QEGLPlatformContext
public:
QXcbEglContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share,
EGLDisplay display, const QVariant &nativeHandle)
- : QEGLPlatformContext(glFormat, share, display, 0, nativeHandle)
+ : QEGLPlatformContext(glFormat, share, display, nullptr, nativeHandle)
{
}
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp
index 65beac227c..30e3381993 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp
@@ -93,7 +93,7 @@ void QXcbEglWindow::create()
{
QXcbWindow::create();
- m_surface = eglCreateWindowSurface(m_glIntegration->eglDisplay(), m_config, m_window, 0);
+ m_surface = eglCreateWindowSurface(m_glIntegration->eglDisplay(), m_config, m_window, nullptr);
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/CMakeLists.txt b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/CMakeLists.txt
index 940cbe12d1..b3361dbd99 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/CMakeLists.txt
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/CMakeLists.txt
@@ -1,12 +1,12 @@
# Generated from xcb_glx.pro.
#####################################################################
-## qxcb-glx-integration Plugin:
+## QXcbGlxIntegrationPlugin Plugin:
#####################################################################
-add_qt_plugin(qxcb-glx-integration
+qt_add_plugin(QXcbGlxIntegrationPlugin
+ OUTPUT_NAME qxcb-glx-integration
TYPE xcbglintegrations
- CLASS_NAME QXcbGlxIntegrationPlugin
SOURCES
qglxintegration.cpp qglxintegration.h
qxcbglxintegration.cpp qxcbglxintegration.h
@@ -18,30 +18,24 @@ add_qt_plugin(qxcb-glx-integration
INCLUDE_DIRECTORIES
..
../..
- LIBRARIES
+ PUBLIC_LIBRARIES
+ Qt::Core
Qt::CorePrivate
Qt::GlxSupportPrivate
+ Qt::Gui
Qt::GuiPrivate
Qt::XcbQpaPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::GlxSupport
- Qt::Gui
- Qt::XcbQpa
)
-#### Keys ignored in scope 1:.:.:xcb_glx.pro:<TRUE>:
-# _LOADED = "qt_plugin" "qt_build_paths"
-
## Scopes:
#####################################################################
-extend_target(qxcb-glx-integration CONDITION QT_FEATURE_xcb_glx
+qt_extend_target(QXcbGlxIntegrationPlugin CONDITION QT_FEATURE_xcb_glx
PUBLIC_LIBRARIES
XCB::GLX
)
-extend_target(qxcb-glx-integration CONDITION QT_FEATURE_dlopen AND NOT static
+qt_extend_target(QXcbGlxIntegrationPlugin CONDITION QT_FEATURE_dlopen AND NOT static
PUBLIC_LIBRARIES
${CMAKE_DL_LIBS}
)
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
index 2b77062b16..75189a9c80 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
@@ -223,13 +223,13 @@ QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlat
const QVariant &nativeHandle)
: QPlatformOpenGLContext()
, m_display(static_cast<Display *>(screen->connection()->xlib_display()))
- , m_config(0)
- , m_context(0)
- , m_shareContext(0)
+ , m_config(nullptr)
+ , m_context(nullptr)
+ , m_shareContext(nullptr)
, m_format(format)
, m_isPBufferCurrent(false)
, m_ownsContext(nativeHandle.isNull())
- , m_getGraphicsResetStatus(0)
+ , m_getGraphicsResetStatus(nullptr)
, m_lost(false)
{
if (nativeHandle.isNull())
@@ -254,14 +254,14 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share)
GLXFBConfig config = qglx_findConfig(m_display, screen->screenNumber(), m_format);
m_config = config;
- XVisualInfo *visualInfo = 0;
+ XVisualInfo *visualInfo = nullptr;
Window window = 0; // Temporary window used to query OpenGL context
if (config) {
const QByteArrayList glxExt = QByteArray(glXQueryExtensionsString(m_display, screen->screenNumber())).split(' ');
// Resolve entry point for glXCreateContextAttribsARB
- glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0;
+ glXCreateContextAttribsARBProc glXCreateContextAttribsARB = nullptr;
if (glxExt.contains("GLX_ARB_create_context"))
glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB");
@@ -271,7 +271,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share)
// Use glXCreateContextAttribsARB if available
// Also, GL ES context creation requires GLX_EXT_create_context_es2_profile
- if (glXCreateContextAttribsARB != 0
+ if (glXCreateContextAttribsARB != nullptr
&& (m_format.renderableType() != QSurfaceFormat::OpenGLES || (supportsProfiles && glxExt.contains("GLX_EXT_create_context_es2_profile")))) {
// Try to create an OpenGL context for each known OpenGL version in descending
// order from the requested version.
@@ -358,9 +358,9 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share)
m_context = glXCreateContextAttribsARB(m_display, config, m_shareContext, true, contextAttributes.data());
if (!m_context && m_shareContext) {
// re-try without a shared glx context
- m_context = glXCreateContextAttribsARB(m_display, config, 0, true, contextAttributes.data());
+ m_context = glXCreateContextAttribsARB(m_display, config, nullptr, true, contextAttributes.data());
if (m_context)
- m_shareContext = 0;
+ m_shareContext = nullptr;
}
}
}
@@ -375,9 +375,9 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share)
m_context = glXCreateNewContext(m_display, config, GLX_RGBA_TYPE, m_shareContext, true);
if (!m_context && m_shareContext) {
// re-try without a shared glx context
- m_context = glXCreateNewContext(m_display, config, GLX_RGBA_TYPE, 0, true);
+ m_context = glXCreateNewContext(m_display, config, GLX_RGBA_TYPE, nullptr, true);
if (m_context)
- m_shareContext = 0;
+ m_shareContext = nullptr;
}
}
@@ -399,7 +399,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share)
m_context = glXCreateContext(m_display, visualInfo, m_shareContext, true);
if (!m_context && m_shareContext) {
// re-try without a shared glx context
- m_shareContext = 0;
+ m_shareContext = nullptr;
m_context = glXCreateContext(m_display, visualInfo, nullptr, true);
}
@@ -429,7 +429,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share, const
qWarning("QGLXContext: Requires a QGLXNativeContext");
return;
}
- QGLXNativeContext handle = nativeHandle.value<QGLXNativeContext>();
+ QGLXNativeContext handle = qvariant_cast<QGLXNativeContext>(nativeHandle);
GLXContext context = handle.context();
if (!context) {
qWarning("QGLXContext: No GLXContext given");
@@ -444,7 +444,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share, const
// Legacy contexts created using glXCreateContext are created using a visual
// and the FBConfig cannot be queried. The only way to adapt these contexts
// is to figure out the visual id.
- XVisualInfo *vinfo = 0;
+ XVisualInfo *vinfo = nullptr;
// If the VisualID is provided use it.
VisualID vid = handle.visualId();
if (!vid) {
@@ -464,13 +464,13 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share, const
vinfo = XGetVisualInfo(dpy, VisualScreenMask | VisualIDMask, &v, &n);
if (n < 1) {
XFree(vinfo);
- vinfo = 0;
+ vinfo = nullptr;
}
}
// For contexts created with an FBConfig using the modern functions providing the
// visual or window is not mandatory. Just query the config from the context.
- GLXFBConfig config = 0;
+ GLXFBConfig config = nullptr;
if (!vinfo) {
int configId = 0;
if (glXQueryContext(dpy, context, GLX_FBCONFIG_ID, &configId) != Success) {
@@ -595,8 +595,8 @@ bool QGLXContext::makeCurrent(QPlatformSurface *surface)
if (interval >= 0 && interval != window->swapInterval() && screen) {
typedef void (*qt_glXSwapIntervalEXT)(Display *, GLXDrawable, int);
typedef void (*qt_glXSwapIntervalMESA)(unsigned int);
- static qt_glXSwapIntervalEXT glXSwapIntervalEXT = 0;
- static qt_glXSwapIntervalMESA glXSwapIntervalMESA = 0;
+ static qt_glXSwapIntervalEXT glXSwapIntervalEXT = nullptr;
+ static qt_glXSwapIntervalMESA glXSwapIntervalMESA = nullptr;
static bool resolved = false;
if (!resolved) {
resolved = true;
@@ -621,9 +621,9 @@ bool QGLXContext::makeCurrent(QPlatformSurface *surface)
void QGLXContext::doneCurrent()
{
if (m_isPBufferCurrent)
- glXMakeContextCurrent(m_display, 0, 0, 0);
+ glXMakeContextCurrent(m_display, 0, 0, nullptr);
else
- glXMakeCurrent(m_display, 0, 0);
+ glXMakeCurrent(m_display, 0, nullptr);
m_isPBufferCurrent = false;
}
@@ -658,12 +658,12 @@ QSurfaceFormat QGLXContext::format() const
bool QGLXContext::isSharing() const
{
- return m_shareContext != 0;
+ return m_shareContext != nullptr;
}
bool QGLXContext::isValid() const
{
- return m_context != 0 && !m_lost;
+ return m_context != nullptr && !m_lost;
}
bool QGLXContext::m_queriedDummyContext = false;
@@ -675,7 +675,7 @@ bool QGLXContext::m_supportsThreading = true;
// binary search.
static const char *qglx_threadedgl_blacklist_renderer[] = {
"Chromium", // QTBUG-32225 (initialization fails)
- 0
+ nullptr
};
static const char *qglx_threadedgl_blacklist_vendor[] = {
@@ -695,7 +695,7 @@ void QGLXContext::queryDummyContext()
return;
QOpenGLContext *oldContext = QOpenGLContext::currentContext();
- QSurface *oldSurface = 0;
+ QSurface *oldSurface = nullptr;
if (oldContext)
oldSurface = oldContext->surface();
@@ -732,7 +732,7 @@ void QGLXContext::queryDummyContext()
if (const char *renderer = (const char *) glGetString(GL_RENDERER)) {
for (int i = 0; qglx_threadedgl_blacklist_renderer[i]; ++i) {
- if (strstr(renderer, qglx_threadedgl_blacklist_renderer[i]) != 0) {
+ if (strstr(renderer, qglx_threadedgl_blacklist_renderer[i]) != nullptr) {
qCDebug(lcQpaGl).nospace() << "Multithreaded OpenGL disabled: "
"blacklisted renderer \""
<< qglx_threadedgl_blacklist_renderer[i]
@@ -744,7 +744,7 @@ void QGLXContext::queryDummyContext()
}
if (const char *vendor = (const char *) glGetString(GL_VENDOR)) {
for (int i = 0; qglx_threadedgl_blacklist_vendor[i]; ++i) {
- if (strstr(vendor, qglx_threadedgl_blacklist_vendor[i]) != 0) {
+ if (strstr(vendor, qglx_threadedgl_blacklist_vendor[i]) != nullptr) {
qCDebug(lcQpaGl).nospace() << "Multithreaded OpenGL disabled: "
"blacklisted vendor \""
<< qglx_threadedgl_blacklist_vendor[i]
@@ -759,7 +759,7 @@ void QGLXContext::queryDummyContext()
// Blacklist Mesa drivers due to QTCREATORBUG-10875 (crash in creator),
// QTBUG-34492 (flickering in fullscreen) and QTBUG-38221
const char *mesaVersionStr = nullptr;
- if (strstr(glxvendor, "Mesa Project") != 0) {
+ if (strstr(glxvendor, "Mesa Project") != nullptr) {
mesaVersionStr = (const char *) glGetString(GL_VERSION);
m_supportsThreading = false;
}
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp
index 34895caaa2..6814dbd844 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp
@@ -133,7 +133,7 @@ bool QXcbGlxIntegration::handleXcbEvent(xcb_generic_event_t *event, uint respons
Display *xdisplay = static_cast<Display *>(m_connection->xlib_display());
XLockDisplay(xdisplay);
bool locked = true;
- Bool (*proc)(Display*, XEvent*, xEvent*) = XESetWireToEvent(xdisplay, responseType, 0);
+ Bool (*proc)(Display*, XEvent*, xEvent*) = XESetWireToEvent(xdisplay, responseType, nullptr);
if (proc) {
XESetWireToEvent(xdisplay, responseType, proc);
XEvent dummy;
@@ -212,7 +212,7 @@ QPlatformOffscreenSurface *QXcbGlxIntegration::createPlatformOffscreenSurface(QO
if (glxPbufferUsable)
return new QGLXPbuffer(surface);
else
- return 0; // trigger fallback to hidden QWindow
+ return nullptr; // trigger fallback to hidden QWindow
}
diff --git a/src/plugins/platforms/xcb/qxcbatom.cpp b/src/plugins/platforms/xcb/qxcbatom.cpp
index ecb73cb90b..79b5ba06e6 100644
--- a/src/plugins/platforms/xcb/qxcbatom.cpp
+++ b/src/plugins/platforms/xcb/qxcbatom.cpp
@@ -265,7 +265,7 @@ void QXcbAtom::initializeAllAtoms(xcb_connection_t *connection) {
cookies[i] = xcb_intern_atom(connection, false, strlen(names[i]), names[i]);
for (i = 0; i < QXcbAtom::NAtoms; ++i) {
- xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, cookies[i], 0);
+ xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, cookies[i], nullptr);
m_allAtoms[i] = reply->atom;
free(reply);
}
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
index 741317d766..8f55bc2e96 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -229,7 +229,7 @@ void QXcbBackingStoreImage::resize(const QSize &size)
m_xcb_format->bits_per_pixel,
0, byteOrder,
XCB_IMAGE_ORDER_MSB_FIRST,
- 0, ~0, 0);
+ nullptr, ~0, nullptr);
const size_t segmentSize = imageDataSize(m_xcb_image);
@@ -412,13 +412,13 @@ bool QXcbBackingStoreImage::createSystemVShmSegment(xcb_connection_t *c, size_t
return false;
}
- void *addr = shmat(id, 0, 0);
+ void *addr = shmat(id, nullptr, 0);
if (addr == (void *)-1) {
qCWarning(lcQpaXcb, "shmat() failed (%d: %s) for id %d", errno, strerror(errno), id);
return false;
}
- if (shmctl(id, IPC_RMID, 0) == -1)
+ if (shmctl(id, IPC_RMID, nullptr) == -1)
qCWarning(lcQpaXcb, "Error while marking the shared memory segment to be destroyed");
const auto seg = xcb_generate_id(c);
@@ -780,7 +780,7 @@ QXcbBackingStore::~QXcbBackingStore()
QPaintDevice *QXcbBackingStore::paintDevice()
{
if (!m_image)
- return 0;
+ return nullptr;
return m_rgbImage.isNull() ? m_image->image() : &m_rgbImage;
}
@@ -1036,7 +1036,7 @@ void QXcbSystemTrayBackingStore::recreateImage(QXcbWindow *win, const QSize &siz
xcb_create_pixmap(xcb_connection(), 32, m_xrenderPixmap, screen->root(), size.width(), size.height());
m_xrenderPicture = xcb_generate_id(xcb_connection());
- xcb_render_create_picture(xcb_connection(), m_xrenderPicture, m_xrenderPixmap, m_xrenderPictFormat, 0, 0);
+ xcb_render_create_picture(xcb_connection(), m_xrenderPicture, m_xrenderPixmap, m_xrenderPictFormat, 0, nullptr);
// XRender expects premultiplied alpha
if (m_image)
@@ -1077,7 +1077,7 @@ void QXcbSystemTrayBackingStore::initXRenderMode()
m_windowPicture = xcb_generate_id(conn);
xcb_void_cookie_t cookie =
- xcb_render_create_picture_checked(conn, m_windowPicture, platformWindow->xcb_window(), vfmt->format, 0, 0);
+ xcb_render_create_picture_checked(conn, m_windowPicture, platformWindow->xcb_window(), vfmt->format, 0, nullptr);
xcb_generic_error_t *error = xcb_request_check(conn, cookie);
if (error) {
qWarning("QXcbSystemTrayBackingStore: Failed to create Picture with format %x for window %x, error code %d",
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp
index 2cb6720d40..fe9ddfece7 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp
@@ -123,8 +123,9 @@ protected:
return list.contains(format);
}
- QVariant retrieveData_sys(const QString &fmt, QVariant::Type requestedType) const override
+ QVariant retrieveData_sys(const QString &fmt, QVariant::Type type) const override
{
+ auto requestedType = QMetaType::Type(type);
if (fmt.isEmpty() || isEmpty())
return QByteArray();
@@ -226,8 +227,8 @@ QXcbClipboard::QXcbClipboard(QXcbConnection *c)
{
Q_ASSERT(QClipboard::Clipboard == 0);
Q_ASSERT(QClipboard::Selection == 1);
- m_clientClipboard[QClipboard::Clipboard] = 0;
- m_clientClipboard[QClipboard::Selection] = 0;
+ m_clientClipboard[QClipboard::Clipboard] = nullptr;
+ m_clientClipboard[QClipboard::Selection] = nullptr;
m_timestamp[QClipboard::Clipboard] = XCB_CURRENT_TIME;
m_timestamp[QClipboard::Selection] = XCB_CURRENT_TIME;
m_owner = connection()->getQtSelectionOwner();
@@ -316,7 +317,7 @@ QClipboard::Mode QXcbClipboard::modeForAtom(xcb_atom_t a) const
QMimeData * QXcbClipboard::mimeData(QClipboard::Mode mode)
{
if (mode > QClipboard::Selection)
- return 0;
+ return nullptr;
xcb_window_t clipboardOwner = getSelectionOwner(atomForMode(mode));
if (clipboardOwner == owner()) {
@@ -334,7 +335,7 @@ void QXcbClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
if (mode > QClipboard::Selection)
return;
- QXcbClipboardMime *xClipboard = 0;
+ QXcbClipboardMime *xClipboard = nullptr;
// verify if there is data to be cleared on global X Clipboard.
if (!data) {
xClipboard = qobject_cast<QXcbClipboardMime *>(mimeData(mode));
@@ -353,7 +354,7 @@ void QXcbClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
if (m_clientClipboard[mode]) {
if (m_clientClipboard[QClipboard::Clipboard] != m_clientClipboard[QClipboard::Selection])
delete m_clientClipboard[mode];
- m_clientClipboard[mode] = 0;
+ m_clientClipboard[mode] = nullptr;
m_timestamp[mode] = XCB_CURRENT_TIME;
}
@@ -416,7 +417,7 @@ xcb_window_t QXcbClipboard::requestor() const
XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class
platformScreen->screen()->root_visual, // visual
0, // value mask
- 0); // value list
+ nullptr); // value list
QXcbWindow::setWindowTitle(connection(), window,
QStringLiteral("Qt Clipboard Requestor Window"));
@@ -529,7 +530,7 @@ void QXcbClipboard::handleSelectionClearRequest(xcb_selection_clear_event_t *eve
if (newOwner != XCB_NONE) {
if (m_clientClipboard[QClipboard::Clipboard] != m_clientClipboard[QClipboard::Selection])
delete m_clientClipboard[mode];
- m_clientClipboard[mode] = 0;
+ m_clientClipboard[mode] = nullptr;
m_timestamp[mode] = XCB_CURRENT_TIME;
}
}
@@ -576,7 +577,7 @@ void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req)
xcb_atom_t multipleAtom = atom(QXcbAtom::MULTIPLE);
xcb_atom_t timestampAtom = atom(QXcbAtom::TIMESTAMP);
- struct AtomPair { xcb_atom_t target; xcb_atom_t property; } *multi = 0;
+ struct AtomPair { xcb_atom_t target; xcb_atom_t property; } *multi = nullptr;
xcb_atom_t multi_type = XCB_NONE;
int multi_format = 0;
int nmulti = 0;
@@ -587,7 +588,7 @@ void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req)
QByteArray multi_data;
if (req->property == XCB_NONE
|| !clipboardReadProperty(req->requestor, req->property, false, &multi_data,
- 0, &multi_type, &multi_format)
+ nullptr, &multi_type, &multi_format)
|| multi_format != 32) {
// MULTIPLE property not formatted correctly
xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
@@ -842,7 +843,7 @@ QByteArray QXcbClipboard::clipboardReadIncrementalProperty(xcb_window_t win, xcb
continue;
prev_time = event->time;
- if (clipboardReadProperty(win, property, true, &tmp_buf, &length, 0, 0)) {
+ if (clipboardReadProperty(win, property, true, &tmp_buf, &length, nullptr, nullptr)) {
if (length == 0) { // no more data, we're done
if (nullterm) {
buf.resize(offset+1);
@@ -900,7 +901,7 @@ QByteArray QXcbClipboard::getSelection(xcb_atom_t selection, xcb_atom_t target,
return buf;
xcb_atom_t type;
- if (clipboardReadProperty(win, property, true, &buf, 0, &type, 0)) {
+ if (clipboardReadProperty(win, property, true, &buf, nullptr, &type, nullptr)) {
if (type == atom(QXcbAtom::INCR)) {
int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0;
buf = clipboardReadIncrementalProperty(win, property, nbytes, false);
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index e51c3d0502..435c4aee93 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -184,7 +184,7 @@ QXcbWindow *QXcbConnection::platformWindowFromId(xcb_window_t id)
QXcbWindowEventListener *listener = m_mapper.value(id, 0);
if (listener)
return listener->toWindow();
- return 0;
+ return nullptr;
}
#define HANDLE_PLATFORM_WINDOW_EVENT(event_t, windowMember, handler) \
@@ -455,7 +455,7 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
static Qt::MouseButtons translateMouseButtons(int s)
{
- Qt::MouseButtons ret = 0;
+ Qt::MouseButtons ret;
if (s & XCB_BUTTON_MASK_1)
ret |= Qt::LeftButton;
if (s & XCB_BUTTON_MASK_2)
@@ -803,7 +803,7 @@ xcb_window_t QXcbConnection::getQtSelectionOwner()
XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class
xcbScreen->root_visual, // visual
0, // value mask
- 0); // value list
+ nullptr); // value list
QXcbWindow::setWindowTitle(connection(), m_qtSelectionOwner,
QLatin1String("Qt Selection Owner for ") + QCoreApplication::applicationName());
@@ -830,7 +830,7 @@ xcb_window_t QXcbConnection::clientLeader()
0,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
screen->screen()->root_visual,
- 0, 0);
+ 0, nullptr);
QXcbWindow::setWindowTitle(connection(), m_clientLeader,
@@ -1031,7 +1031,7 @@ void QXcbConnection::sync()
{
// from xcb_aux_sync
xcb_get_input_focus_cookie_t cookie = xcb_get_input_focus(xcb_connection());
- free(xcb_get_input_focus_reply(xcb_connection(), cookie, 0));
+ free(xcb_get_input_focus_reply(xcb_connection(), cookie, nullptr));
}
QXcbSystemTrayTracker *QXcbConnection::systemTrayTracker() const
@@ -1049,14 +1049,14 @@ QXcbSystemTrayTracker *QXcbConnection::systemTrayTracker() const
Qt::MouseButtons QXcbConnection::queryMouseButtons() const
{
int stateMask = 0;
- QXcbCursor::queryPointer(connection(), 0, 0, &stateMask);
+ QXcbCursor::queryPointer(connection(), nullptr, nullptr, &stateMask);
return translateMouseButtons(stateMask);
}
Qt::KeyboardModifiers QXcbConnection::queryKeyboardModifiers() const
{
int stateMask = 0;
- QXcbCursor::queryPointer(connection(), 0, 0, &stateMask);
+ QXcbCursor::queryPointer(connection(), nullptr, nullptr, &stateMask);
return keyboard()->translateModifiers(stateMask);
}
@@ -1114,7 +1114,7 @@ void QXcbSyncWindowRequest::invalidate()
{
if (m_window) {
m_window->clearSyncWindowRequest();
- m_window = 0;
+ m_window = nullptr;
}
}
@@ -1134,7 +1134,7 @@ void QXcbConnectionGrabber::release()
{
if (m_connection) {
m_connection->ungrabServer();
- m_connection = 0;
+ m_connection = nullptr;
}
}
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index a894944096..2d89b971dc 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -127,7 +127,7 @@ class Q_XCB_EXPORT QXcbConnection : public QXcbBasicConnection
{
Q_OBJECT
public:
- QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, xcb_visualid_t defaultVisualId, const char *displayName = 0);
+ QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, xcb_visualid_t defaultVisualId, const char *displayName = nullptr);
~QXcbConnection();
QXcbConnection *connection() const { return const_cast<QXcbConnection *>(this); }
@@ -294,7 +294,7 @@ private:
int deviceId = 0;
QTabletEvent::PointerType pointerType = QTabletEvent::UnknownPointer;
QTabletEvent::TabletDevice tool = QTabletEvent::Stylus;
- Qt::MouseButtons buttons = 0;
+ Qt::MouseButtons buttons;
qint64 serialId = 0;
bool inProximity = false;
struct ValuatorClassInfo {
@@ -318,8 +318,8 @@ private:
int horizontalIndex = 0;
double verticalIncrement = 0;
double horizontalIncrement = 0;
- Qt::Orientations orientations = 0;
- Qt::Orientations legacyOrientations = 0;
+ Qt::Orientations orientations;
+ Qt::Orientations legacyOrientations;
QPointF lastScrollPosition;
};
QHash<int, ScrollingDevice> m_scrollingDevices;
@@ -360,7 +360,7 @@ private:
WindowMapper m_mapper;
- Qt::MouseButtons m_buttonState = nullptr;
+ Qt::MouseButtons m_buttonState;
Qt::MouseButton m_button = Qt::NoButton;
QXcbWindow *m_focusWindow = nullptr;
diff --git a/src/plugins/platforms/xcb/qxcbconnection_basic.cpp b/src/plugins/platforms/xcb/qxcbconnection_basic.cpp
index 1ba4b4a1b9..18dee89adb 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_basic.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_basic.cpp
@@ -93,7 +93,7 @@ static int nullErrorHandler(Display *dpy, XErrorEvent *err)
static int ioErrorHandler(Display *dpy)
{
xcb_connection_t *conn = XGetXCBConnection(dpy);
- if (conn != NULL) {
+ if (conn != nullptr) {
/* Print a message with a textual description of the error */
int code = xcb_connection_has_error(conn);
const char *str = "Unknown error";
@@ -134,7 +134,7 @@ QXcbBasicConnection::QXcbBasicConnection(const char *displayName)
xcb_extension_t *extensions[] = {
&xcb_shm_id, &xcb_xfixes_id, &xcb_randr_id, &xcb_shape_id, &xcb_sync_id,
- &xcb_render_id, &xcb_xkb_id, &xcb_input_id, 0
+ &xcb_render_id, &xcb_xkb_id, &xcb_input_id, nullptr
};
for (xcb_extension_t **ext_it = extensions; *ext_it; ++ext_it)
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index 4639185416..2d114c51b3 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -166,7 +166,7 @@ void QXcbConnection::xi2SetupDevice(void *info, bool removeExisting)
}
case XCB_INPUT_DEVICE_CLASS_TYPE_BUTTON: {
auto *bci = reinterpret_cast<xcb_input_button_class_t *>(classinfo);
- xcb_atom_t *labels = 0;
+ xcb_atom_t *labels = nullptr;
if (bci->num_buttons >= 5) {
labels = xcb_input_button_class_labels(bci);
xcb_atom_t label4 = labels[3];
@@ -424,7 +424,7 @@ QXcbConnection::TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
QXcbConnection::TouchDeviceData *QXcbConnection::populateTouchDevices(void *info)
{
auto *deviceinfo = reinterpret_cast<xcb_input_xi_device_info_t *>(info);
- QTouchDevice::Capabilities caps = 0;
+ QTouchDevice::Capabilities caps;
int type = -1;
int maxTouchPoints = 1;
bool isTouchDevice = false;
@@ -527,7 +527,7 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event)
int sourceDeviceId = xiEvent->deviceid; // may be the master id
qt_xcb_input_device_event_t *xiDeviceEvent = nullptr;
xcb_input_enter_event_t *xiEnterEvent = nullptr;
- QXcbWindowEventListener *eventListener = 0;
+ QXcbWindowEventListener *eventListener = nullptr;
switch (xiEvent->event_type) {
case XCB_INPUT_BUTTON_PRESS:
@@ -1252,14 +1252,16 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD
if (Q_LIKELY(useValuators)) {
const qreal value = scaleOneValuator(normalizedValue, physicalScreenArea.x(), physicalScreenArea.width());
global.setX(value);
- local.setX(value - window->handle()->geometry().x());
+ // mapFromGlobal is ok for nested/embedded windows, but works only with whole-number QPoint;
+ // so map it first, then add back the sub-pixel position
+ local.setX(window->mapFromGlobal(QPoint(int(value), 0)).x() + (value - int(value)));
}
break;
case QXcbAtom::AbsY:
if (Q_LIKELY(useValuators)) {
qreal value = scaleOneValuator(normalizedValue, physicalScreenArea.y(), physicalScreenArea.height());
global.setY(value);
- local.setY(value - window->handle()->geometry().y());
+ local.setY(window->mapFromGlobal(QPoint(0, int(value))).y() + (value - int(value)));
}
break;
case QXcbAtom::AbsPressure:
diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp
index fbadab4d50..639e4f039c 100644
--- a/src/plugins/platforms/xcb/qxcbcursor.cpp
+++ b/src/plugins/platforms/xcb/qxcbcursor.cpp
@@ -67,10 +67,10 @@ enum {
};
#undef CursorShape
-static PtrXcursorLibraryLoadCursor ptrXcursorLibraryLoadCursor = 0;
-static PtrXcursorLibraryGetTheme ptrXcursorLibraryGetTheme = 0;
-static PtrXcursorLibrarySetTheme ptrXcursorLibrarySetTheme = 0;
-static PtrXcursorLibraryGetDefaultSize ptrXcursorLibraryGetDefaultSize = 0;
+static PtrXcursorLibraryLoadCursor ptrXcursorLibraryLoadCursor = nullptr;
+static PtrXcursorLibraryGetTheme ptrXcursorLibraryGetTheme = nullptr;
+static PtrXcursorLibrarySetTheme ptrXcursorLibrarySetTheme = nullptr;
+static PtrXcursorLibraryGetDefaultSize ptrXcursorLibraryGetDefaultSize = nullptr;
#endif
static xcb_font_t cursorFont = 0;
@@ -118,7 +118,7 @@ static const uint8_t mcur_fdiag_bits[] = {
static const uint8_t *cursor_bits16[] = {
cur_ver_bits, mcur_ver_bits, cur_hor_bits, mcur_hor_bits,
cur_bdiag_bits, mcur_bdiag_bits, cur_fdiag_bits, mcur_fdiag_bits,
- 0, 0, cur_blank_bits, cur_blank_bits };
+ nullptr, nullptr, cur_blank_bits, cur_blank_bits };
static const uint8_t vsplit_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -219,7 +219,7 @@ static const uint8_t busym_bits[] = {
static const uint8_t * const cursor_bits32[] = {
vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits,
- 0, 0, 0, 0, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits
+ nullptr, nullptr, nullptr, nullptr, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits
};
static const uint8_t forbidden_bits[] = {
@@ -452,19 +452,19 @@ xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape)
if (cshape == Qt::BlankCursor) {
xcb_pixmap_t cp = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), cur_blank_bits, 16, 16,
- 1, 0, 0, 0);
+ 1, 0, 0, nullptr);
xcb_pixmap_t mp = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), cur_blank_bits, 16, 16,
- 1, 0, 0, 0);
+ 1, 0, 0, nullptr);
cursor = xcb_generate_id(conn);
xcb_create_cursor(conn, cursor, cp, mp, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8);
} else if (cshape >= Qt::SizeVerCursor && cshape < Qt::SizeAllCursor) {
int i = (cshape - Qt::SizeVerCursor) * 2;
xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(),
const_cast<uint8_t*>(cursor_bits16[i]),
- 16, 16, 1, 0, 0, 0);
+ 16, 16, 1, 0, 0, nullptr);
xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(),
const_cast<uint8_t*>(cursor_bits16[i + 1]),
- 16, 16, 1, 0, 0, 0);
+ 16, 16, 1, 0, 0, nullptr);
cursor = xcb_generate_id(conn);
xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8);
} else if ((cshape >= Qt::SplitVCursor && cshape <= Qt::SplitHCursor)
@@ -472,10 +472,10 @@ xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape)
int i = (cshape - Qt::SplitVCursor) * 2;
xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(),
const_cast<uint8_t*>(cursor_bits32[i]),
- 32, 32, 1, 0, 0, 0);
+ 32, 32, 1, 0, 0, nullptr);
xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(),
const_cast<uint8_t*>(cursor_bits32[i + 1]),
- 32, 32, 1, 0, 0, 0);
+ 32, 32, 1, 0, 0, nullptr);
int hs = (cshape == Qt::PointingHandCursor || cshape == Qt::WhatsThisCursor
|| cshape == Qt::BusyCursor) ? 0 : 16;
cursor = xcb_generate_id(conn);
@@ -484,20 +484,20 @@ xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape)
int i = (cshape - Qt::ForbiddenCursor) * 2;
xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(),
const_cast<uint8_t*>(cursor_bits20[i]),
- 20, 20, 1, 0, 0, 0);
+ 20, 20, 1, 0, 0, nullptr);
xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(),
const_cast<uint8_t*>(cursor_bits20[i + 1]),
- 20, 20, 1, 0, 0, 0);
+ 20, 20, 1, 0, 0, nullptr);
cursor = xcb_generate_id(conn);
xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 10, 10);
} else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) {
bool open = cshape == Qt::OpenHandCursor;
xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(),
const_cast<uint8_t*>(open ? openhand_bits : closedhand_bits),
- 16, 16, 1, 0, 0, 0);
+ 16, 16, 1, 0, 0, nullptr);
xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(),
const_cast<uint8_t*>(open ? openhandm_bits : closedhandm_bits),
- 16, 16, 1, 0, 0, 0);
+ 16, 16, 1, 0, 0, nullptr);
cursor = xcb_generate_id(conn);
xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8);
} else if (cshape == Qt::DragCopyCursor || cshape == Qt::DragMoveCursor
@@ -660,14 +660,14 @@ void QXcbCursor::queryPointer(QXcbConnection *c, QXcbVirtualDesktop **virtualDes
QPoint QXcbCursor::pos() const
{
QPoint p;
- queryPointer(connection(), 0, &p);
+ queryPointer(connection(), nullptr, &p);
return p;
}
void QXcbCursor::setPos(const QPoint &pos)
{
QXcbVirtualDesktop *virtualDesktop = nullptr;
- queryPointer(connection(), &virtualDesktop, 0);
+ queryPointer(connection(), &virtualDesktop, nullptr);
xcb_warp_pointer(xcb_connection(), XCB_NONE, virtualDesktop->root(), 0, 0, 0, 0, pos.x(), pos.y());
xcb_flush(xcb_connection());
}
diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp
index 1ce947165d..e76fc8bd40 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.cpp
+++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
@@ -114,7 +114,7 @@ protected:
QStringList formats_sys() const override;
QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const override;
- QVariant xdndObtainData(const QByteArray &format, QVariant::Type requestedType) const;
+ QVariant xdndObtainData(const QByteArray &format, QMetaType::Type requestedType) const;
QXcbDrag *drag;
};
@@ -148,7 +148,7 @@ void QXcbDrag::init()
source_time = XCB_CURRENT_TIME;
target_time = XCB_CURRENT_TIME;
- QXcbCursor::queryPointer(connection(), &current_virtual_desktop, 0);
+ QXcbCursor::queryPointer(connection(), &current_virtual_desktop, nullptr);
drag_types.clear();
//current_embedding_widget = 0;
@@ -354,6 +354,11 @@ bool QXcbDrag::findXdndAwareTarget(const QPoint &globalPos, xcb_window_t *target
void QXcbDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
{
+ // currentDrag() might be deleted while 'drag' is progressing
+ if (!currentDrag()) {
+ cancel();
+ return;
+ }
// The source sends XdndEnter and XdndPosition to the target.
if (source_sameanswer.contains(globalPos) && source_sameanswer.isValid())
return;
@@ -379,13 +384,13 @@ void QXcbDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardMod
if (!findXdndAwareTarget(globalPos, &target))
return;
- QXcbWindow *w = 0;
+ QXcbWindow *w = nullptr;
if (target) {
w = connection()->platformWindowFromId(target);
if (w && (w->window()->type() == Qt::Desktop) /*&& !w->acceptDrops()*/)
- w = 0;
+ w = nullptr;
} else {
- w = 0;
+ w = nullptr;
target = current_virtual_desktop->root();
}
@@ -517,7 +522,7 @@ void QXcbDrag::drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardMod
QXcbWindow *w = connection()->platformWindowFromId(current_proxy_target);
if (w && w->window()->type() == Qt::Desktop) // && !w->acceptDrops()
- w = 0;
+ w = nullptr;
Transaction t = {
connection()->time(),
@@ -711,7 +716,7 @@ void QXcbDrag::handle_xdnd_position(QPlatformWindow *w, const xcb_client_message
target_time = e->data.data32[3];
}
- QMimeData *dropData = 0;
+ QMimeData *dropData = nullptr;
Qt::DropActions supported_actions = Qt::IgnoreAction;
if (currentDrag()) {
dropData = currentDrag()->mimeData();
@@ -878,7 +883,7 @@ void QXcbDrag::handleLeave(QPlatformWindow *w, const xcb_client_message_event_t
event->data.data32[0], xdnd_dragsource);
}
- QWindowSystemInterface::handleDrag(w->window(), nullptr, QPoint(), Qt::IgnoreAction, 0, 0);
+ QWindowSystemInterface::handleDrag(w->window(), nullptr, QPoint(), Qt::IgnoreAction, { }, { });
}
void QXcbDrag::send_leave()
@@ -906,7 +911,7 @@ void QXcbDrag::send_leave()
QXcbWindow *w = connection()->platformWindowFromId(current_proxy_target);
if (w && (w->window()->type() == Qt::Desktop) /*&& !w->acceptDrops()*/)
- w = 0;
+ w = nullptr;
qCDebug(lcQpaXDnd) << "sending XdndLeave to target:" << current_target;
@@ -940,7 +945,7 @@ void QXcbDrag::handleDrop(QPlatformWindow *, const xcb_client_message_event_t *e
target_time = l[2];
Qt::DropActions supported_drop_actions;
- QMimeData *dropData = 0;
+ QMimeData *dropData = nullptr;
if (currentDrag()) {
dropData = currentDrag()->mimeData();
supported_drop_actions = Qt::DropActions(l[4]);
@@ -1076,7 +1081,8 @@ void QXcbDrag::cancel()
send_leave();
// remove canceled object
- currentDrag()->deleteLater();
+ if (currentDrag())
+ currentDrag()->deleteLater();
canceled = true;
}
@@ -1146,7 +1152,7 @@ void QXcbDrag::handleSelectionRequest(const xcb_selection_request_event_t *event
}
}
- QDrag *transactionDrag = 0;
+ QDrag *transactionDrag = nullptr;
if (at >= 0) {
transactionDrag = transactions.at(at).drag;
} else if (at == -2) {
@@ -1216,7 +1222,7 @@ bool QXcbDrag::dndEnable(QXcbWindow *w, bool on)
if (w->window()->type() == Qt::Desktop) {
xcb_delete_property(xcb_connection(), w->xcb_window(), atom(QXcbAtom::XdndProxy));
delete desktop_proxy;
- desktop_proxy = 0;
+ desktop_proxy = nullptr;
} else {
qCDebug(lcQpaXDnd) << "not deleting XDndAware";
}
@@ -1242,11 +1248,11 @@ QXcbDropData::~QXcbDropData()
QVariant QXcbDropData::retrieveData_sys(const QString &mimetype, QVariant::Type requestedType) const
{
QByteArray mime = mimetype.toLatin1();
- QVariant data = xdndObtainData(mime, requestedType);
+ QVariant data = xdndObtainData(mime, QMetaType::Type(requestedType));
return data;
}
-QVariant QXcbDropData::xdndObtainData(const QByteArray &format, QVariant::Type requestedType) const
+QVariant QXcbDropData::xdndObtainData(const QByteArray &format, QMetaType::Type requestedType) const
{
QByteArray result;
diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h
index 1388e68acc..7bef7a818a 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.h
+++ b/src/plugins/platforms/xcb/qxcbdrag.h
@@ -86,7 +86,7 @@ public:
void handlePosition(QPlatformWindow *w, const xcb_client_message_event_t *event);
void handleLeave(QPlatformWindow *w, const xcb_client_message_event_t *event);
void handleDrop(QPlatformWindow *, const xcb_client_message_event_t *event,
- Qt::MouseButtons b = nullptr, Qt::KeyboardModifiers mods = nullptr);
+ Qt::MouseButtons b = { }, Qt::KeyboardModifiers mods = { });
void handleStatus(const xcb_client_message_event_t *event);
void handleSelectionRequest(const xcb_selection_request_event_t *event);
@@ -109,7 +109,7 @@ private:
void init();
void handle_xdnd_position(QPlatformWindow *w, const xcb_client_message_event_t *event,
- Qt::MouseButtons b = nullptr, Qt::KeyboardModifiers mods = nullptr);
+ Qt::MouseButtons b = { }, Qt::KeyboardModifiers mods = { });
void handle_xdnd_status(const xcb_client_message_event_t *event);
void send_leave();
diff --git a/src/plugins/platforms/xcb/qxcbeventqueue.h b/src/plugins/platforms/xcb/qxcbeventqueue.h
index 11d0b8e963..e7327b3fd6 100644
--- a/src/plugins/platforms/xcb/qxcbeventqueue.h
+++ b/src/plugins/platforms/xcb/qxcbeventqueue.h
@@ -49,6 +49,7 @@
#include <xcb/xcb.h>
#include <atomic>
+#include <limits>
QT_BEGIN_NAMESPACE
@@ -106,7 +107,7 @@ public:
bool peekEventQueue(PeekerCallback peeker, void *peekerData = nullptr,
PeekOptions option = PeekDefault, qint32 peekerId = -1);
- void waitForNewEvents(unsigned long time = ULONG_MAX);
+ void waitForNewEvents(unsigned long time = std::numeric_limits<unsigned long>::max());
private:
QXcbEventNode *qXcbEventNodeFactory(xcb_generic_event_t *event);
diff --git a/src/plugins/platforms/xcb/qxcbimage.cpp b/src/plugins/platforms/xcb/qxcbimage.cpp
index 8f33e6ed31..b0e610dd51 100644
--- a/src/plugins/platforms/xcb/qxcbimage.cpp
+++ b/src/plugins/platforms/xcb/qxcbimage.cpp
@@ -221,7 +221,7 @@ xcb_pixmap_t qt_xcb_XPixmapFromBitmap(QXcbScreen *screen, const QImage &image)
for (int i = 0; i < height; i++)
memcpy(buf + (destLineSize * i), map + (bytesPerLine * i), destLineSize);
xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, screen->root(), buf,
- width, height, 1, 0, 0, 0);
+ width, height, 1, 0, 0, nullptr);
delete[] buf;
return pm;
}
@@ -249,7 +249,7 @@ xcb_cursor_t qt_xcb_createCursorXRender(QXcbScreen *screen, const QImage &image,
32, 32, 32, 32,
QSysInfo::ByteOrder == QSysInfo::BigEndian ? XCB_IMAGE_ORDER_MSB_FIRST : XCB_IMAGE_ORDER_LSB_FIRST,
XCB_IMAGE_ORDER_MSB_FIRST,
- 0, 0, 0);
+ nullptr, 0, nullptr);
if (!xi) {
qWarning("qt_xcb_createCursorXRender: xcb_image_create failed");
return XCB_NONE;
@@ -266,10 +266,10 @@ xcb_cursor_t qt_xcb_createCursorXRender(QXcbScreen *screen, const QImage &image,
xcb_create_pixmap(conn, 32, pix, screen->root(), w, h);
xcb_render_picture_t pic = xcb_generate_id(conn);
- xcb_render_create_picture(conn, pic, pix, fmt->id, 0, 0);
+ xcb_render_create_picture(conn, pic, pix, fmt->id, 0, nullptr);
xcb_gcontext_t gc = xcb_generate_id(conn);
- xcb_create_gc(conn, gc, pix, 0, 0);
+ xcb_create_gc(conn, gc, pix, 0, nullptr);
xcb_image_put(conn, pix, gc, xi, 0, 0, 0);
xcb_free_gc(conn, gc);
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 95ca40fc95..cea0511822 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -61,6 +61,9 @@
#include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h>
#include <QtServiceSupport/private/qgenericunixservices_p.h>
+#if QT_CONFIG(opengl)
+#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h>
+#endif
#include <stdio.h>
@@ -130,7 +133,7 @@ QXcbIntegration *QXcbIntegration::m_instance = nullptr;
QXcbIntegration::QXcbIntegration(const QStringList &parameters, int &argc, char **argv)
: m_services(new QGenericUnixServices)
- , m_instanceName(0)
+ , m_instanceName(nullptr)
, m_canGrab(true)
, m_defaultVisualId(UINT_MAX)
{
@@ -146,7 +149,7 @@ QXcbIntegration::QXcbIntegration(const QStringList &parameters, int &argc, char
m_nativeInterface.reset(new QXcbNativeInterface);
// Parse arguments
- const char *displayName = 0;
+ const char *displayName = nullptr;
bool noGrabArg = false;
bool doGrabArg = false;
if (argc) {
@@ -288,16 +291,23 @@ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLCont
QPlatformBackingStore *QXcbIntegration::createPlatformBackingStore(QWindow *window) const
{
- const bool isTrayIconWindow = QXcbWindow::isTrayIconWindow(window);
- if (isTrayIconWindow)
- return new QXcbSystemTrayBackingStore(window);
+ QPlatformBackingStore *backingStore = nullptr;
+ const bool isTrayIconWindow = QXcbWindow::isTrayIconWindow(window);
+ if (isTrayIconWindow) {
+ backingStore = new QXcbSystemTrayBackingStore(window);
#if QT_CONFIG(xcb_native_painting)
- if (nativePaintingEnabled())
- return new QXcbNativeBackingStore(window);
+ } else if (nativePaintingEnabled()) {
+ backingStore = new QXcbNativeBackingStore(window);
#endif
-
- return new QXcbBackingStore(window);
+ } else {
+ backingStore = new QXcbBackingStore(window);
+ }
+ Q_ASSERT(backingStore);
+#ifndef QT_NO_OPENGL
+ backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore));
+#endif
+ return backingStore;
}
QPlatformOffscreenSurface *QXcbIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
@@ -317,8 +327,7 @@ bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const
case OpenGL:
case ThreadedOpenGL:
{
- const auto *connection = qAsConst(m_connections).first();
- if (const auto *integration = connection->glIntegration())
+ if (const auto *integration = defaultConnection()->glIntegration())
return cap != ThreadedOpenGL || integration->supportsThreadedOpenGL();
return false;
}
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index 3caee3f409..e8286381a2 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -579,7 +579,7 @@ void QXcbKeyboard::selectEvents()
required_events,
required_map_parts,
required_map_parts,
- 0);
+ nullptr);
xcb_generic_error_t *error = xcb_request_check(xcb_connection(), select);
if (error) {
@@ -620,7 +620,7 @@ void QXcbKeyboard::updateVModMapping()
vmod_mask = name_reply->virtualMods;
// find the virtual modifiers for which names are defined.
for (bit = 1; vmod_mask; bit <<= 1) {
- vmod_name = 0;
+ vmod_name = nullptr;
if (!(vmod_mask & bit))
continue;
diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp
index d611f86a9c..0b3219f792 100644
--- a/src/plugins/platforms/xcb/qxcbmime.cpp
+++ b/src/plugins/platforms/xcb/qxcbmime.cpp
@@ -159,7 +159,7 @@ QVector<xcb_atom_t> QXcbMime::mimeAtomsForFormat(QXcbConnection *connection, con
}
QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a, const QByteArray &d, const QString &format,
- QVariant::Type requestedType, const QByteArray &encoding)
+ QMetaType::Type requestedType, const QByteArray &encoding)
{
QByteArray data = d;
QString atomName = mimeAtomToString(connection, a);
@@ -169,7 +169,7 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a,
&& atomName == format + QLatin1String(";charset=") + QLatin1String(encoding)) {
#if QT_CONFIG(textcodec)
- if (requestedType == QVariant::String) {
+ if (requestedType == QMetaType::QString) {
QTextCodec *codec = QTextCodec::codecForName(encoding);
if (codec)
return codec->toUnicode(data);
@@ -264,7 +264,7 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a,
return QVariant();
}
-xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString &format, QVariant::Type requestedType,
+xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString &format, QMetaType::Type requestedType,
const QVector<xcb_atom_t> &atoms, QByteArray *requestedEncoding)
{
requestedEncoding->clear();
@@ -297,7 +297,7 @@ xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString
// for string/text requests try to use a format with a well-defined charset
// first to avoid encoding problems
- if (requestedType == QVariant::String
+ if (requestedType == QMetaType::QString
&& format.startsWith(QLatin1String("text/"))
&& !format.contains(QLatin1String("charset="))) {
diff --git a/src/plugins/platforms/xcb/qxcbmime.h b/src/plugins/platforms/xcb/qxcbmime.h
index f2136ec9f4..dcb4f6b6c6 100644
--- a/src/plugins/platforms/xcb/qxcbmime.h
+++ b/src/plugins/platforms/xcb/qxcbmime.h
@@ -60,8 +60,8 @@ public:
static bool mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeData *mimeData, QByteArray *data,
xcb_atom_t *atomFormat, int *dataFormat);
static QVariant mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a, const QByteArray &data, const QString &format,
- QVariant::Type requestedType, const QByteArray &encoding);
- static xcb_atom_t mimeAtomForFormat(QXcbConnection *connection, const QString &format, QVariant::Type requestedType,
+ QMetaType::Type requestedType, const QByteArray &encoding);
+ static xcb_atom_t mimeAtomForFormat(QXcbConnection *connection, const QString &format, QMetaType::Type requestedType,
const QVector<xcb_atom_t> &atoms, QByteArray *requestedEncoding);
};
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index 81b889a80f..30fa6864ac 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -268,7 +268,7 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbNativeInterfa
if (lowerCaseResource == "peekeventqueue")
return NativeResourceForIntegrationFunction(reinterpret_cast<void *>(peekEventQueue));
- return 0;
+ return nullptr;
}
QPlatformNativeInterface::NativeResourceForContextFunction QXcbNativeInterface::nativeResourceFunctionForContext(const QByteArray &resource)
@@ -291,7 +291,7 @@ QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::n
return NativeResourceForScreenFunction(reinterpret_cast<void *>(setAppTime));
else if (lowerCaseResource == "setappusertime")
return NativeResourceForScreenFunction(reinterpret_cast<void *>(setAppUserTime));
- return 0;
+ return nullptr;
}
QPlatformNativeInterface::NativeResourceForWindowFunction QXcbNativeInterface::nativeResourceFunctionForWindow(const QByteArray &resource)
@@ -365,7 +365,7 @@ void *QXcbNativeInterface::startupId()
QXcbConnection *defaultConnection = integration->defaultConnection();
if (defaultConnection)
return reinterpret_cast<void *>(const_cast<char *>(defaultConnection->startupId().constData()));
- return 0;
+ return nullptr;
}
void *QXcbNativeInterface::x11Screen()
@@ -374,7 +374,7 @@ void *QXcbNativeInterface::x11Screen()
QXcbConnection *defaultConnection = integration->defaultConnection();
if (defaultConnection)
return reinterpret_cast<void *>(defaultConnection->primaryScreenNumber());
- return 0;
+ return nullptr;
}
void *QXcbNativeInterface::rootWindow()
@@ -383,7 +383,7 @@ void *QXcbNativeInterface::rootWindow()
QXcbConnection *defaultConnection = integration->defaultConnection();
if (defaultConnection)
return reinterpret_cast<void *>(defaultConnection->rootWindow());
- return 0;
+ return nullptr;
}
void *QXcbNativeInterface::display()
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 8da299d491..2426b5243a 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -41,6 +41,7 @@
#include "qxcbwindow.h"
#include "qxcbcursor.h"
#include "qxcbimage.h"
+#include "qxcbintegration.h"
#include "qnamespace.h"
#include "qxcbxsettings.h"
@@ -49,6 +50,7 @@
#include <QDebug>
#include <QtAlgorithms>
+#include <qpa/qplatformservices.h>
#include <qpa/qwindowsysteminterface.h>
#include <private/qmath_p.h>
#include <QtGui/private/qhighdpiscaling_p.h>
@@ -318,12 +320,22 @@ bool QXcbVirtualDesktop::xResource(const QByteArray &identifier,
static bool parseXftInt(const QByteArray& stringValue, int *value)
{
- Q_ASSERT(value != 0);
+ Q_ASSERT(value);
bool ok;
*value = stringValue.toInt(&ok);
return ok;
}
+static bool parseXftDpi(const QByteArray& stringValue, int *value)
+{
+ Q_ASSERT(value);
+ bool ok = parseXftInt(stringValue, value);
+ // Support GNOME 3 bug that wrote DPI with fraction:
+ if (!ok)
+ *value = qRound(stringValue.toDouble(&ok));
+ return ok;
+}
+
static QFontEngine::HintStyle parseXftHintStyle(const QByteArray& stringValue)
{
if (stringValue == "hintfull")
@@ -356,6 +368,15 @@ static QFontEngine::SubpixelAntialiasingType parseXftRgba(const QByteArray& stri
void QXcbVirtualDesktop::readXResources()
{
+ const QPlatformServices *services = QXcbIntegration::instance()->services();
+ bool useXftConf = false;
+ if (services) {
+ const QList<QByteArray> desktopEnv = services->desktopEnvironment().split(':');
+ useXftConf = desktopEnv.contains("GNOME") || desktopEnv.contains("UNITY") || desktopEnv.contains("XFCE");
+ }
+ if (!useXftConf)
+ return;
+
int offset = 0;
QByteArray resources;
while (true) {
@@ -380,7 +401,7 @@ void QXcbVirtualDesktop::readXResources()
int value;
QByteArray stringValue;
if (xResource(r, "Xft.dpi:\t", stringValue)) {
- if (parseXftInt(stringValue, &value))
+ if (parseXftDpi(stringValue, &value))
m_forcedDpi = value;
} else if (xResource(r, "Xft.hintstyle:\t", stringValue)) {
m_hintStyle = parseXftHintStyle(stringValue);
@@ -457,7 +478,7 @@ const xcb_visualtype_t *QXcbVirtualDesktop::visualForId(xcb_visualid_t visualid)
{
QMap<xcb_visualid_t, xcb_visualtype_t>::const_iterator it = m_visuals.find(visualid);
if (it == m_visuals.constEnd())
- return 0;
+ return nullptr;
return &*it;
}
@@ -577,7 +598,7 @@ QWindow *QXcbScreen::topLevelAt(const QPoint &p) const
do {
auto translate_reply = Q_XCB_REPLY_UNCHECKED(xcb_translate_coordinates, xcb_connection(), parent, child, x, y);
if (!translate_reply) {
- return 0;
+ return nullptr;
}
parent = child;
@@ -586,14 +607,14 @@ QWindow *QXcbScreen::topLevelAt(const QPoint &p) const
y = translate_reply->dst_y;
if (!child || child == root)
- return 0;
+ return nullptr;
QPlatformWindow *platformWindow = connection()->platformWindowFromId(child);
if (platformWindow)
return platformWindow->window();
} while (parent != child);
- return 0;
+ return nullptr;
}
void QXcbScreen::windowShown(QXcbWindow *window)
diff --git a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp
index 2303ccf806..2eb32c069e 100644
--- a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp
+++ b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp
@@ -42,6 +42,8 @@
#ifndef QT_NO_SESSIONMANAGER
+#include <qpa/qwindowsysteminterface.h>
+
#include <qguiapplication.h>
#include <qdatetime.h>
#include <qfileinfo.h>
@@ -67,7 +69,7 @@ public Q_SLOTS:
};
-static SmcConn smcConnection = 0;
+static SmcConn smcConnection = nullptr;
static bool sm_interactionActive;
static bool sm_smActive;
static int sm_interactStyle;
@@ -79,7 +81,7 @@ static bool sm_phase2;
static bool sm_in_phase2;
bool qt_sm_blockUserInput = false;
-static QSmSocketReceiver* sm_receiver = 0;
+static QSmSocketReceiver* sm_receiver = nullptr;
static void resetSmState();
static void sm_setProperty(const char *name, const char *type,
@@ -189,7 +191,7 @@ static void sm_performSaveYourself(QXcbSessionManager *sm)
// generate a new session key
timeval tv;
- gettimeofday(&tv, 0);
+ gettimeofday(&tv, nullptr);
sm->setSessionKey(QString::number(qulonglong(tv.tv_sec)) +
QLatin1Char('_') +
QString::number(qulonglong(tv.tv_usec)));
@@ -201,7 +203,7 @@ static void sm_performSaveYourself(QXcbSessionManager *sm)
// tell the session manager about our program in best POSIX style
sm_setProperty(QString::fromLatin1(SmProgram), argument0);
// tell the session manager about our user as well.
- struct passwd *entryPtr = 0;
+ struct passwd *entryPtr = nullptr;
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0)
QVarLengthArray<char, 1024> buf(qMax<long>(sysconf(_SC_GETPW_R_SIZE_MAX), 1024L));
struct passwd entry;
@@ -289,8 +291,7 @@ static void sm_dieCallback(SmcConn smcConn, SmPointer /* clientData */)
if (smcConn != smcConnection)
return;
resetSmState();
- QEvent quitEvent(QEvent::Quit);
- QGuiApplication::sendEvent(qApp, &quitEvent);
+ QWindowSystemInterface::handleApplicationTermination<QWindowSystemInterface::SynchronousDelivery>();
}
static void sm_shutdownCancelledCallback(SmcConn smcConn, SmPointer clientData)
@@ -328,7 +329,7 @@ static void sm_saveYourselfPhase2Callback(SmcConn smcConn, SmPointer clientData)
void QSmSocketReceiver::socketActivated(int)
{
- IceProcessMessages(SmcGetIceConnection(smcConnection), 0, 0);
+ IceProcessMessages(SmcGetIceConnection(smcConnection), nullptr, nullptr);
}
@@ -336,11 +337,11 @@ void QSmSocketReceiver::socketActivated(int)
QXcbSessionManager::QXcbSessionManager(const QString &id, const QString &key)
: QPlatformSessionManager(id, key)
- , m_eventLoop(0)
+ , m_eventLoop(nullptr)
{
resetSmState();
char cerror[256];
- char* myId = 0;
+ char* myId = nullptr;
QByteArray b_id = id.toLatin1();
char* prevId = b_id.data();
@@ -358,7 +359,7 @@ QXcbSessionManager::QXcbSessionManager(const QString &id, const QString &key)
if (!qEnvironmentVariableIsSet("SESSION_MANAGER"))
return;
- smcConnection = SmcOpenConnection(0, 0, 1, 0,
+ smcConnection = SmcOpenConnection(nullptr, nullptr, 1, 0,
SmcSaveYourselfProcMask |
SmcDieProcMask |
SmcSaveCompleteProcMask |
@@ -381,8 +382,8 @@ QXcbSessionManager::QXcbSessionManager(const QString &id, const QString &key)
QXcbSessionManager::~QXcbSessionManager()
{
if (smcConnection)
- SmcCloseConnection(smcConnection, 0, 0);
- smcConnection = 0;
+ SmcCloseConnection(smcConnection, 0, nullptr);
+ smcConnection = nullptr;
delete sm_receiver;
}
@@ -410,7 +411,7 @@ bool QXcbSessionManager::allowsInteraction()
QEventLoop eventLoop;
m_eventLoop = &eventLoop;
eventLoop.exec();
- m_eventLoop = 0;
+ m_eventLoop = nullptr;
sm_waitingForInteraction = false;
if (sm_smActive) { // not cancelled
@@ -440,7 +441,7 @@ bool QXcbSessionManager::allowsErrorInteraction()
QEventLoop eventLoop;
m_eventLoop = &eventLoop;
eventLoop.exec();
- m_eventLoop = 0;
+ m_eventLoop = nullptr;
sm_waitingForInteraction = false;
if (sm_smActive) { // not cancelled
diff --git a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp
index 684e603fab..ff5ad98cd2 100644
--- a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp
+++ b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp
@@ -64,11 +64,11 @@ QXcbSystemTrayTracker *QXcbSystemTrayTracker::create(QXcbConnection *connection)
// Selection, tray atoms for GNOME, NET WM Specification
const xcb_atom_t trayAtom = connection->atom(QXcbAtom::_NET_SYSTEM_TRAY_OPCODE);
if (!trayAtom)
- return 0;
+ return nullptr;
const QByteArray netSysTray = QByteArrayLiteral("_NET_SYSTEM_TRAY_S") + QByteArray::number(connection->primaryScreenNumber());
const xcb_atom_t selection = connection->internAtom(netSysTray.constData());
if (!selection)
- return 0;
+ return nullptr;
return new QXcbSystemTrayTracker(connection, trayAtom, selection);
}
diff --git a/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp b/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp
index b3f8a5832d..bb82bcec39 100644
--- a/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp
+++ b/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp
@@ -93,7 +93,7 @@ bool QXcbVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevice,
VkSurfaceKHR QXcbVulkanInstance::createSurface(QXcbWindow *window)
{
- VkSurfaceKHR surface = 0;
+ VkSurfaceKHR surface = VK_NULL_HANDLE;
if (!m_createSurface) {
m_createSurface = reinterpret_cast<PFN_vkCreateXcbSurfaceKHR>(
diff --git a/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp b/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp
index 25bc340f97..a05ecab51d 100644
--- a/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp
@@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE
QXcbVulkanWindow::QXcbVulkanWindow(QWindow *window)
: QXcbWindow(window),
- m_surface(0)
+ m_surface(VK_NULL_HANDLE)
{
}
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 76d3545d35..adca902c69 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -174,13 +174,13 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
{
#include <X11/Xatom.h>
- static XTextProperty tp = { 0, 0, 0, 0 };
+ static XTextProperty tp = { nullptr, 0, 0, 0 };
static bool free_prop = true; // we can't free tp.value in case it references
// the data of the static QByteArray below.
if (tp.value) {
if (free_prop)
XFree(tp.value);
- tp.value = 0;
+ tp.value = nullptr;
free_prop = true;
}
@@ -191,7 +191,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
QByteArray mapped = mapper->fromUnicode(s);
char* tl[2];
tl[0] = mapped.data();
- tl[1] = 0;
+ tl[1] = nullptr;
errCode = XmbTextListToTextProperty(dpy, tl, 1, XStdICCTextStyle, &tp);
if (errCode < 0)
qCDebug(lcQpaXcb, "XmbTextListToTextProperty result code %d", errCode);
@@ -280,7 +280,7 @@ void QXcbWindow::create()
m_window = platformScreen->root();
m_depth = platformScreen->screen()->root_depth;
m_visualId = platformScreen->screen()->root_visual;
- const xcb_visualtype_t *visual = 0;
+ const xcb_visualtype_t *visual = nullptr;
if (connection()->hasDefaultVisualId()) {
visual = platformScreen->visualForId(connection()->defaultVisualId());
if (visual)
@@ -819,7 +819,7 @@ bool QXcbWindow::relayFocusToModalWindow() const
while (w && w->parent())
w = w->parent();
- QWindow *modalWindow = 0;
+ QWindow *modalWindow = nullptr;
const bool blocked = QGuiApplicationPrivate::instance()->isWindowBlocked(w, &modalWindow);
if (blocked && modalWindow != w) {
modalWindow->requestActivate();
@@ -876,7 +876,7 @@ enum {
QXcbWindow::NetWmStates QXcbWindow::netWmStates()
{
- NetWmStates result(0);
+ NetWmStates result;
auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, xcb_connection(),
0, m_window, atom(QXcbAtom::_NET_WM_STATE),
@@ -927,10 +927,10 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
xcb_change_window_attributes(xcb_connection(), xcb_window(), mask, values);
- QXcbWindowFunctions::WmWindowTypes wmWindowTypes = 0;
+ QXcbWindowFunctions::WmWindowTypes wmWindowTypes;
if (window()->dynamicPropertyNames().contains(wm_window_type_property_id)) {
wmWindowTypes = static_cast<QXcbWindowFunctions::WmWindowTypes>(
- window()->property(wm_window_type_property_id).value<int>());
+ qvariant_cast<int>(window()->property(wm_window_type_property_id)));
}
setWmWindowType(wmWindowTypes, flags);
@@ -1063,7 +1063,7 @@ void QXcbWindow::setNetWmStateOnUnmappedWindow()
if (Q_UNLIKELY(m_mapped))
qCWarning(lcQpaXcb()) << "internal error: " << Q_FUNC_INFO << "called on mapped window";
- NetWmStates states(0);
+ NetWmStates states;
const Qt::WindowFlags flags = window()->flags();
if (flags & Qt::WindowStaysOnTopHint) {
states |= NetWmStateAbove;
@@ -1193,7 +1193,7 @@ void QXcbWindow::updateNetWmUserTime(xcb_timestamp_t timestamp)
XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class
m_visualId, // visual
0, // value mask
- 0); // value list
+ nullptr); // value list
wid = m_netWmUserTimeWindow;
xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW),
XCB_ATOM_WINDOW, 32, 1, &m_netWmUserTimeWindow);
@@ -1223,7 +1223,7 @@ void QXcbWindow::setTransparentForMouseEvents(bool transparent)
xcb_rectangle_t rectangle;
- xcb_rectangle_t *rect = 0;
+ xcb_rectangle_t *rect = nullptr;
int nrect = 0;
if (!transparent) {
@@ -1394,6 +1394,8 @@ void QXcbWindow::propagateSizeHints()
}
xcb_icccm_set_wm_normal_hints(xcb_connection(), m_window, &hints);
+
+ m_sizeHintsScaleFactor = QHighDpiScaling::scaleAndOrigin(screen()).factor;
}
void QXcbWindow::requestActivateWindow()
@@ -1477,7 +1479,7 @@ uint QXcbWindow::visualIdStatic(QWindow *window)
QXcbWindowFunctions::WmWindowTypes QXcbWindow::wmWindowTypes() const
{
- QXcbWindowFunctions::WmWindowTypes result(0);
+ QXcbWindowFunctions::WmWindowTypes result;
auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, xcb_connection(),
0, m_window, atom(QXcbAtom::_NET_WM_WINDOW_TYPE),
@@ -1785,6 +1787,9 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *
// will make the comparison later.
QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen());
+ if (!qFuzzyCompare(QHighDpiScaling::scaleAndOrigin(newScreen).factor, m_sizeHintsScaleFactor))
+ propagateSizeHints();
+
// Send the synthetic expose event on resize only when the window is shrinked,
// because the "XCB_GRAVITY_NORTH_WEST" flag doesn't send it automatically.
if (!m_oldWindowSize.isEmpty()
@@ -1882,7 +1887,7 @@ void QXcbWindow::handleButtonPressEvent(int event_x, int event_y, int root_x, in
if (m_embedded && !m_trayIconWindow) {
if (window() != QGuiApplication::focusWindow()) {
const QXcbWindow *container = static_cast<const QXcbWindow *>(parent());
- Q_ASSERT(container != 0);
+ Q_ASSERT(container != nullptr);
sendXEmbedMessage(container->xcb_window(), XEMBED_REQUEST_FOCUS);
}
@@ -2087,7 +2092,7 @@ void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource
const Qt::MouseButton button = conn->xiToQtMouseButton(ev->detail);
- const char *sourceName = 0;
+ const char *sourceName = nullptr;
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) {
const QMetaObject *metaObject = qt_getEnumMetaObject(source);
const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(source)));
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index 13b37db028..976a442b11 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -278,6 +278,8 @@ protected:
QXcbSyncWindowRequest *m_pendingSyncRequest = nullptr;
int m_swapInterval = -1;
+
+ qreal m_sizeHintsScaleFactor = 1.0;
};
class QXcbForeignWindow : public QXcbWindow
diff --git a/src/plugins/platforms/xcb/qxcbxsettings.cpp b/src/plugins/platforms/xcb/qxcbxsettings.cpp
index 88f15e344f..902f196ba9 100644
--- a/src/plugins/platforms/xcb/qxcbxsettings.cpp
+++ b/src/plugins/platforms/xcb/qxcbxsettings.cpp
@@ -256,7 +256,7 @@ QXcbXSettings::QXcbXSettings(QXcbVirtualDesktop *screen)
QXcbXSettings::~QXcbXSettings()
{
delete d_ptr;
- d_ptr = 0;
+ d_ptr = nullptr;
}
bool QXcbXSettings::initialized() const
diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
index a5d05faa9c..1f651e7697 100644
--- a/src/plugins/platforms/xcb/xcb_qpa_lib.pro
+++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
@@ -9,6 +9,9 @@ QT += \
edid_support-private \
xkbcommon_support-private
+qtHaveModule(platformcompositor_support-private): \
+ QT += platformcompositor_support-private
+
qtHaveModule(linuxaccessibility_support-private): \
QT += linuxaccessibility_support-private