Add preliminary support for Qt for visionOS

Qt already runs on Vision Pro as "Designed for iPad", using Qt
for iOS. This change enables building Qt for visionOS directly,
which opens the door to visionOS specific APIs and use-cases
such as volumes and immersive spaces.

The platform removes some APIs we depend on, notably UIScreen,
so some code paths have been disabled or mocked to get something
up and running.

As our current window management approach on UIKit platforms
depends on UIWindow and UIScreen there is currently no way to
bring up QWindows. This will improve once we refactor our
window management to use window scenes.

To configure for visionOS, pass -platform macx-visionos-clang,
and optionally add -sdk xrsimulator to build for the simulator.

Change-Id: I4eda55fc3fd06e12d30a188928487cf68940ee07
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Tor Arne Vestbø 2024-03-18 19:35:52 +01:00
parent bf2ed62409
commit d5bf42f75b
58 changed files with 469 additions and 126 deletions

View File

@ -45,3 +45,8 @@ set(QT_SUPPORTED_MIN_MACOS_XCODE_VERSION "14")
set(QT_SUPPORTED_MIN_IOS_SDK_VERSION "16") set(QT_SUPPORTED_MIN_IOS_SDK_VERSION "16")
set(QT_SUPPORTED_MAX_IOS_SDK_VERSION "17") set(QT_SUPPORTED_MAX_IOS_SDK_VERSION "17")
set(QT_SUPPORTED_MIN_IOS_XCODE_VERSION "14") set(QT_SUPPORTED_MIN_IOS_XCODE_VERSION "14")
set(QT_SUPPORTED_MIN_VISIONOS_SDK_VERSION "1")
set(QT_SUPPORTED_MAX_VISIONOS_SDK_VERSION "1")
set(QT_SUPPORTED_MIN_VISIONOS_XCODE_VERSION "15")

View File

@ -184,6 +184,8 @@ function(qt_auto_detect_apple)
if("${QT_QMAKE_TARGET_MKSPEC}" STREQUAL "macx-ios-clang") if("${QT_QMAKE_TARGET_MKSPEC}" STREQUAL "macx-ios-clang")
set(CMAKE_SYSTEM_NAME "iOS" CACHE STRING "") set(CMAKE_SYSTEM_NAME "iOS" CACHE STRING "")
elseif("${QT_QMAKE_TARGET_MKSPEC}" STREQUAL "macx-visionos-clang")
set(CMAKE_SYSTEM_NAME "visionOS" CACHE STRING "")
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL iOS) if(CMAKE_SYSTEM_NAME STREQUAL iOS)
@ -226,13 +228,14 @@ function(qt_auto_detect_apple)
endif() endif()
endif() endif()
# For non simulator_and_device builds, we need to explicitly set the SYSROOT aka the sdk set(CMAKE_OSX_ARCHITECTURES "${osx_architectures}" CACHE STRING "")
# value. endif()
if(QT_APPLE_SDK) if(QT_APPLE_SDK)
set(CMAKE_OSX_SYSROOT "${QT_APPLE_SDK}" CACHE STRING "") set(CMAKE_OSX_SYSROOT "${QT_APPLE_SDK}" CACHE STRING "")
endif() endif()
set(CMAKE_OSX_ARCHITECTURES "${osx_architectures}" CACHE STRING "")
if(CMAKE_SYSTEM_NAME STREQUAL iOS OR CMAKE_SYSTEM_NAME STREQUAL visionOS)
if(NOT DEFINED BUILD_SHARED_LIBS) if(NOT DEFINED BUILD_SHARED_LIBS)
qt_internal_ensure_static_qt_config() qt_internal_ensure_static_qt_config()
endif() endif()

View File

@ -321,6 +321,7 @@ qt_copy_or_install(DIRECTORY cmake/
PATTERN "3rdparty" EXCLUDE PATTERN "3rdparty" EXCLUDE
PATTERN "macos" EXCLUDE PATTERN "macos" EXCLUDE
PATTERN "ios" EXCLUDE PATTERN "ios" EXCLUDE
PATTERN "visionos" EXCLUDE
PATTERN "platforms" EXCLUDE PATTERN "platforms" EXCLUDE
PATTERN "QtBuildInternals" EXCLUDE PATTERN "QtBuildInternals" EXCLUDE
) )
@ -335,6 +336,7 @@ if(QT_WILL_INSTALL)
PATTERN "3rdparty" EXCLUDE PATTERN "3rdparty" EXCLUDE
PATTERN "macos" EXCLUDE PATTERN "macos" EXCLUDE
PATTERN "ios" EXCLUDE PATTERN "ios" EXCLUDE
PATTERN "visionos" EXCLUDE
PATTERN "platforms" EXCLUDE PATTERN "platforms" EXCLUDE
PATTERN "QtBuildInternals" EXCLUDE PATTERN "QtBuildInternals" EXCLUDE
) )
@ -345,6 +347,8 @@ if(APPLE)
set(platform_shortname "macos") set(platform_shortname "macos")
elseif(IOS) elseif(IOS)
set(platform_shortname "ios") set(platform_shortname "ios")
elseif(VISIONOS)
set(platform_shortname "visionos")
endif() endif()
# Info.plist # Info.plist

View File

@ -214,6 +214,8 @@ macro(qt_internal_set_qt_apple_support_files_path)
set(__qt_internal_cmake_apple_support_files_path "${QT_CMAKE_DIR}/macos") set(__qt_internal_cmake_apple_support_files_path "${QT_CMAKE_DIR}/macos")
elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS") elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(__qt_internal_cmake_apple_support_files_path "${QT_CMAKE_DIR}/ios") set(__qt_internal_cmake_apple_support_files_path "${QT_CMAKE_DIR}/ios")
elseif(CMAKE_SYSTEM_NAME STREQUAL "visionOS")
set(__qt_internal_cmake_apple_support_files_path "${QT_CMAKE_DIR}/visionos")
endif() endif()
endif() endif()
endmacro() endmacro()

View File

@ -44,6 +44,8 @@ if(APPLE)
set(__qt_internal_cmake_apple_support_files_path "${_qt_import_prefix}/macos") set(__qt_internal_cmake_apple_support_files_path "${_qt_import_prefix}/macos")
elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS") elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(__qt_internal_cmake_apple_support_files_path "${_qt_import_prefix}/ios") set(__qt_internal_cmake_apple_support_files_path "${_qt_import_prefix}/ios")
elseif(CMAKE_SYSTEM_NAME STREQUAL "visionOS")
set(__qt_internal_cmake_apple_support_files_path "${_qt_import_prefix}/visionos")
endif() endif()
endif() endif()

View File

@ -32,7 +32,8 @@ qt_set01(BSD APPLE OR OPENBSD OR FREEBSD OR NETBSD)
qt_set01(IOS APPLE AND CMAKE_SYSTEM_NAME STREQUAL "iOS") qt_set01(IOS APPLE AND CMAKE_SYSTEM_NAME STREQUAL "iOS")
qt_set01(TVOS APPLE AND CMAKE_SYSTEM_NAME STREQUAL "tvOS") qt_set01(TVOS APPLE AND CMAKE_SYSTEM_NAME STREQUAL "tvOS")
qt_set01(WATCHOS APPLE AND CMAKE_SYSTEM_NAME STREQUAL "watchOS") qt_set01(WATCHOS APPLE AND CMAKE_SYSTEM_NAME STREQUAL "watchOS")
qt_set01(UIKIT APPLE AND (IOS OR TVOS OR WATCHOS)) qt_set01(VISIONOS APPLE AND CMAKE_SYSTEM_NAME STREQUAL "visionOS")
qt_set01(UIKIT APPLE AND (IOS OR TVOS OR WATCHOS OR VISIONOS))
qt_set01(MACOS APPLE AND NOT UIKIT) qt_set01(MACOS APPLE AND NOT UIKIT)
qt_set01(GCC CMAKE_CXX_COMPILER_ID STREQUAL "GNU") qt_set01(GCC CMAKE_CXX_COMPILER_ID STREQUAL "GNU")

View File

@ -681,6 +681,12 @@ function(_qt_internal_export_apple_sdk_and_xcode_version_requirements out_var)
QT_SUPPORTED_MAX_IOS_SDK_VERSION QT_SUPPORTED_MAX_IOS_SDK_VERSION
QT_SUPPORTED_MIN_IOS_XCODE_VERSION QT_SUPPORTED_MIN_IOS_XCODE_VERSION
) )
elseif(VISIONOS)
set(vars_to_assign
QT_SUPPORTED_MIN_VISIONOS_SDK_VERSION
QT_SUPPORTED_MAX_VISIONOS_SDK_VERSION
QT_SUPPORTED_MIN_VISIONOS_XCODE_VERSION
)
else() else()
set(vars_to_assign set(vars_to_assign
QT_SUPPORTED_MIN_MACOS_SDK_VERSION QT_SUPPORTED_MIN_MACOS_SDK_VERSION
@ -707,6 +713,8 @@ function(_qt_internal_get_apple_sdk_version out_var)
if(APPLE) if(APPLE)
if(CMAKE_SYSTEM_NAME STREQUAL iOS) if(CMAKE_SYSTEM_NAME STREQUAL iOS)
set(sdk_name "iphoneos") set(sdk_name "iphoneos")
elseif(CMAKE_SYSTEM_NAME STREQUAL visionOS)
set(sdk_name "xros")
else() else()
# Default to macOS # Default to macOS
set(sdk_name "macosx") set(sdk_name "macosx")
@ -804,6 +812,10 @@ function(_qt_internal_check_apple_sdk_and_xcode_versions)
set(min_sdk_version "${QT_SUPPORTED_MIN_IOS_SDK_VERSION}") set(min_sdk_version "${QT_SUPPORTED_MIN_IOS_SDK_VERSION}")
set(max_sdk_version "${QT_SUPPORTED_MAX_IOS_SDK_VERSION}") set(max_sdk_version "${QT_SUPPORTED_MAX_IOS_SDK_VERSION}")
set(min_xcode_version "${QT_SUPPORTED_MIN_IOS_XCODE_VERSION}") set(min_xcode_version "${QT_SUPPORTED_MIN_IOS_XCODE_VERSION}")
elseif(VISIONOS)
set(min_sdk_version "${QT_SUPPORTED_MIN_VISIONOS_SDK_VERSION}")
set(max_sdk_version "${QT_SUPPORTED_MAX_VISIONOS_SDK_VERSION}")
set(min_xcode_version "${QT_SUPPORTED_MIN_VISIONOS_XCODE_VERSION}")
else() else()
set(min_sdk_version "${QT_SUPPORTED_MIN_MACOS_SDK_VERSION}") set(min_sdk_version "${QT_SUPPORTED_MIN_MACOS_SDK_VERSION}")
set(max_sdk_version "${QT_SUPPORTED_MAX_MACOS_SDK_VERSION}") set(max_sdk_version "${QT_SUPPORTED_MAX_MACOS_SDK_VERSION}")
@ -885,7 +897,7 @@ function(_qt_internal_check_apple_sdk_and_xcode_versions)
endfunction() endfunction()
function(_qt_internal_finalize_apple_app target) function(_qt_internal_finalize_apple_app target)
# Shared between macOS and iOS apps # Shared between macOS and UIKit apps
_qt_internal_copy_info_plist("${target}") _qt_internal_copy_info_plist("${target}")
_qt_internal_set_apple_localizations("${target}") _qt_internal_set_apple_localizations("${target}")
@ -905,6 +917,14 @@ function(_qt_internal_finalize_apple_app target)
_qt_internal_set_placeholder_apple_bundle_version("${target}") _qt_internal_set_placeholder_apple_bundle_version("${target}")
endfunction() endfunction()
function(_qt_internal_finalize_uikit_app target)
if(CMAKE_SYSTEM_NAME STREQUAL iOS)
_qt_internal_finalize_ios_app("${target}")
else()
_qt_internal_finalize_apple_app("${target}")
endif()
endfunction()
function(_qt_internal_finalize_ios_app target) function(_qt_internal_finalize_ios_app target)
# Must be called before we generate the Info.plist # Must be called before we generate the Info.plist
_qt_internal_handle_ios_launch_screen("${target}") _qt_internal_handle_ios_launch_screen("${target}")

View File

@ -22,7 +22,7 @@ function(qt_internal_create_wrapper_scripts)
set(extra_qt_cmake_code "") set(extra_qt_cmake_code "")
if(generate_unix) if(generate_unix)
if(IOS) if(UIKIT)
set(extra_qt_cmake_code [=[ set(extra_qt_cmake_code [=[
# Specify Xcode as the default generator by assigning it to the CMAKE_GENERATOR env var. # Specify Xcode as the default generator by assigning it to the CMAKE_GENERATOR env var.
# An explicit -G or -D CMAKE_GENERATOR given on the command line will still take precedence. # An explicit -G or -D CMAKE_GENERATOR given on the command line will still take precedence.

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>CFBundleDisplayName</key>
<string>${QT_INTERNAL_DOLLAR_VAR}{PRODUCT_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
<key>CFBundleIconFile</key>
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleAllowMixedLocalizations</key>
<true/>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>XROS</string>
</array>
</dict>
</plist>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTrackingDomains</key>
<array/>
<key>NSPrivacyAccessedAPITypes</key>
<array/>
</dict>
</plist>

View File

@ -605,7 +605,7 @@ if(APPLE)
endif() endif()
qt_feature("simulator_and_device" PUBLIC qt_feature("simulator_and_device" PUBLIC
LABEL "Build for both simulator and device" LABEL "Build for both simulator and device"
CONDITION UIKIT AND NOT QT_APPLE_SDK CONDITION IOS AND NOT QT_APPLE_SDK
) )
qt_feature_config("simulator_and_device" QMAKE_PUBLIC_QT_CONFIG) qt_feature_config("simulator_and_device" QMAKE_PUBLIC_QT_CONFIG)
qt_feature("rpath" PUBLIC qt_feature("rpath" PUBLIC

View File

@ -120,10 +120,12 @@ macx-xcode {
QMAKE_XCODE_ARCHS = QMAKE_XCODE_ARCHS =
!isEmpty(QMAKE_APPLE_DEVICE_ARCHS) {
arch_device.name = "ARCHS[sdk=$${device.sdk}*]" arch_device.name = "ARCHS[sdk=$${device.sdk}*]"
arch_device.value = $$QMAKE_APPLE_DEVICE_ARCHS arch_device.value = $$QMAKE_APPLE_DEVICE_ARCHS
QMAKE_XCODE_ARCHS += $$QMAKE_APPLE_DEVICE_ARCHS QMAKE_XCODE_ARCHS += $$QMAKE_APPLE_DEVICE_ARCHS
QMAKE_MAC_XCODE_SETTINGS += arch_device QMAKE_MAC_XCODE_SETTINGS += arch_device
}
ios:simulator { ios:simulator {
arch_simulator.name = "ARCHS[sdk=$${simulator.sdk}*]" arch_simulator.name = "ARCHS[sdk=$${simulator.sdk}*]"
@ -224,10 +226,16 @@ macx-xcode {
platform_identifier = $$device.sdk platform_identifier = $$device.sdk
sysroot_path = $$xcodeSDKInfo(Path, $$device.sdk) sysroot_path = $$xcodeSDKInfo(Path, $$device.sdk)
} }
QMAKE_CFLAGS += -isysroot $$sysroot_path
QMAKE_CXXFLAGS += -isysroot $$sysroot_path
QMAKE_LFLAGS += -isysroot $$sysroot_path
!isEmpty(version_identifier):!isEmpty(deployment_target) {
version_min_flag = -m$${version_identifier}-version-min=$$deployment_target version_min_flag = -m$${version_identifier}-version-min=$$deployment_target
QMAKE_CFLAGS += -isysroot $$sysroot_path $$version_min_flag QMAKE_CFLAGS += $$version_min_flag
QMAKE_CXXFLAGS += -isysroot $$sysroot_path $$version_min_flag QMAKE_CXXFLAGS += $$version_min_flag
QMAKE_LFLAGS += -isysroot $$sysroot_path $$version_min_flag QMAKE_LFLAGS += $$version_min_flag
}
} }
# Enable precompiled headers for multiple architectures # Enable precompiled headers for multiple architectures

View File

@ -182,7 +182,7 @@ isEmpty($${target_prefix}.INCDIRS) {
# UIKit simulator platforms will see the device SDK's sysroot in # UIKit simulator platforms will see the device SDK's sysroot in
# QMAKE_DEFAULT_*DIRS, because they're handled in a single build pass. # QMAKE_DEFAULT_*DIRS, because they're handled in a single build pass.
darwin { darwin {
uikit { uikit:!isEmpty(QMAKE_APPLE_DEVICE_ARCHS) {
# Clang doesn't automatically pick up the architecture, just because # Clang doesn't automatically pick up the architecture, just because
# we're passing the iOS sysroot below, and we will end up building the # we're passing the iOS sysroot below, and we will end up building the
# test for the host architecture, resulting in linker errors when # test for the host architecture, resulting in linker errors when

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>${ASSETCATALOG_COMPILER_APPICON_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${QMAKE_SHORT_VERSION}</string>
<key>CFBundleVersion</key>
<string>${QMAKE_FULL_VERSION}</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleAllowMixedLocalizations</key>
<true/>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>XROS</string>
</array>
</dict>
</plist>

View File

@ -0,0 +1,18 @@
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<plist version=\"1.0\">
<dict>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.$${BUNDLEIDENTIFIER}</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
!!IF !isEmpty(VERSION)
<key>CFBundleShortVersionString</key>
<string>$${VER_MAJ}.$${VER_MIN}</string>
<key>CFBundleVersion</key>
<string>$${VER_MAJ}.$${VER_MIN}.$${VER_PAT}</string>
!!ENDIF
</dict>
</plist>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>${QMAKE_SHORT_VERSION}</string>
<key>CFBundleSignature</key>
<string>${QMAKE_PKGINFO_TYPEINFO}</string>
<key>CFBundleVersion</key>
<string>${QMAKE_FULL_VERSION}</string>
<key>NOTE</key>
<string>Please, do NOT change this file -- It was generated by Qt/QMake.</string>
</dict>
</plist>

View File

@ -0,0 +1,29 @@
#
# qmake configuration for visionOS
#
QMAKE_PLATFORM += visionos
QMAKE_MAC_SDK = xros
device.sdk = xros
device.target = device
device.dir_affix = $${device.sdk}
device.CONFIG = $${device.sdk}
device.deployment_identifier =
simulator.sdk = xrsimulator
simulator.target = simulator
simulator.dir_affix = $${simulator.sdk}
simulator.CONFIG = $${simulator.sdk}
simulator.deployment_identifier =
QMAKE_APPLE_TARGETED_DEVICE_FAMILY = 7
include(../common/uikit.conf)
include(../common/gcc-base-mac.conf)
include(../common/clang.conf)
include(../common/clang-mac.conf)
include(../common/uikit/clang.conf)
include(../common/uikit/qmake.conf)
load(qt_config)

View File

@ -0,0 +1,4 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "../common/mac/qplatformdefs.h"

View File

@ -1124,7 +1124,7 @@ qt_internal_extend_target(Core CONDITION QT_FEATURE_dlopen
${CMAKE_DL_LIBS} ${CMAKE_DL_LIBS}
) )
qt_internal_extend_target(Core CONDITION APPLE AND (IOS OR TVOS) qt_internal_extend_target(Core CONDITION APPLE AND UIKIT
LIBRARIES LIBRARIES
${FWUIKit} ${FWUIKit}
) )
@ -1382,7 +1382,7 @@ qt_internal_apply_gc_binaries_conditional(Core PUBLIC)
# Add entry-point on platforms that need it. A project can opt-out of using the # Add entry-point on platforms that need it. A project can opt-out of using the
# entrypoint by setting the qt_no_entrypoint property to TRUE on a target. # entrypoint by setting the qt_no_entrypoint property to TRUE on a target.
if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "iOS") if(WIN32 OR UIKIT)
# find_package(Qt6Core) should call find_package(Qt6EntryPointPrivate) so that we can # find_package(Qt6Core) should call find_package(Qt6EntryPointPrivate) so that we can
# link against EntryPointPrivate. Normally this is handled automatically for deps, but # link against EntryPointPrivate. Normally this is handled automatically for deps, but
# for some reason it doesn't work for the EntryPointPrivate, so we need to add it manually. # for some reason it doesn't work for the EntryPointPrivate, so we need to add it manually.

View File

@ -732,10 +732,14 @@ function(_qt_internal_finalize_executable target)
_qt_internal_add_wasm_extra_exported_methods("${target}") _qt_internal_add_wasm_extra_exported_methods("${target}")
_qt_internal_set_wasm_export_name("${target}") _qt_internal_set_wasm_export_name("${target}")
endif() endif()
if(IOS)
_qt_internal_finalize_ios_app("${target}") if(APPLE)
elseif(APPLE) if(NOT CMAKE_SYSTEM_NAME OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# macOS
_qt_internal_finalize_macos_app("${target}") _qt_internal_finalize_macos_app("${target}")
else()
_qt_internal_finalize_uikit_app("${target}")
endif()
endif() endif()
# For finalizer mode of plugin importing to work safely, we need to know the list of Qt # For finalizer mode of plugin importing to work safely, we need to know the list of Qt

View File

@ -34,7 +34,7 @@ QT_BEGIN_NAMESPACE
operating system version (as opposed to the kernel version number or operating system version (as opposed to the kernel version number or
marketing version). marketing version).
Presently, Android, Apple Platforms (iOS, macOS, tvOS, and watchOS), Presently, Android, Apple Platforms (iOS, macOS, tvOS, watchOS, and visionOS),
and Windows are supported. and Windows are supported.
The \a majorVersion(), \a minorVersion(), and \a microVersion() functions The \a majorVersion(), \a minorVersion(), and \a microVersion() functions
@ -98,6 +98,7 @@ QT_BEGIN_NAMESPACE
\value MacOS The Apple macOS operating system. \value MacOS The Apple macOS operating system.
\value TvOS The Apple tvOS operating system. \value TvOS The Apple tvOS operating system.
\value WatchOS The Apple watchOS operating system. \value WatchOS The Apple watchOS operating system.
\value VisionOS The Apple visionOS operating system.
\value Windows The Microsoft Windows operating system. \value Windows The Microsoft Windows operating system.
\value Unknown An unknown or unsupported operating system. \value Unknown An unknown or unsupported operating system.
@ -325,6 +326,8 @@ QString QOperatingSystemVersionBase::name(QOperatingSystemVersionBase osversion)
return QStringLiteral("tvOS"); return QStringLiteral("tvOS");
case QOperatingSystemVersionBase::WatchOS: case QOperatingSystemVersionBase::WatchOS:
return QStringLiteral("watchOS"); return QStringLiteral("watchOS");
case QOperatingSystemVersionBase::VisionOS:
return QStringLiteral("visionOS");
case QOperatingSystemVersionBase::Android: case QOperatingSystemVersionBase::Android:
return QStringLiteral("Android"); return QStringLiteral("Android");
case QOperatingSystemVersionBase::Unknown: case QOperatingSystemVersionBase::Unknown:

View File

@ -30,7 +30,8 @@ public:
IOS, IOS,
TvOS, TvOS,
WatchOS, WatchOS,
Android Android,
VisionOS
}; };
constexpr QOperatingSystemVersionBase(OSType osType, constexpr QOperatingSystemVersionBase(OSType osType,
@ -57,6 +58,8 @@ public:
return TvOS; return TvOS;
#elif defined(Q_OS_WATCHOS) #elif defined(Q_OS_WATCHOS)
return WatchOS; return WatchOS;
#elif defined(Q_OS_VISIONOS)
return VisionOS;
#elif defined(Q_OS_ANDROID) #elif defined(Q_OS_ANDROID)
return Android; return Android;
#else #else
@ -158,7 +161,8 @@ public:
IOS, IOS,
TvOS, TvOS,
WatchOS, WatchOS,
Android Android,
VisionOS
}; };
#endif #endif

View File

@ -784,6 +784,8 @@ QString QSysInfo::productType()
return QStringLiteral("tvos"); return QStringLiteral("tvos");
#elif defined(Q_OS_WATCHOS) #elif defined(Q_OS_WATCHOS)
return QStringLiteral("watchos"); return QStringLiteral("watchos");
#elif defined(Q_OS_VISIONOS)
return QStringLiteral("visionos");
#elif defined(Q_OS_MACOS) #elif defined(Q_OS_MACOS)
return QStringLiteral("macos"); return QStringLiteral("macos");
#elif defined(Q_OS_DARWIN) #elif defined(Q_OS_DARWIN)

View File

@ -19,6 +19,7 @@
IOS - iOS IOS - iOS
WATCHOS - watchOS WATCHOS - watchOS
TVOS - tvOS TVOS - tvOS
VISIONOS - visionOS
WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008) WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008)
CYGWIN - Cygwin CYGWIN - Cygwin
SOLARIS - Sun Solaris SOLARIS - Sun Solaris
@ -61,6 +62,8 @@
# define Q_OS_WATCHOS # define Q_OS_WATCHOS
# elif defined(TARGET_OS_TV) && TARGET_OS_TV # elif defined(TARGET_OS_TV) && TARGET_OS_TV
# define Q_OS_TVOS # define Q_OS_TVOS
# elif defined(TARGET_OS_VISION) && TARGET_OS_VISION
# define Q_OS_VISIONOS
# else # else
# // TARGET_OS_IOS is only available in newer SDKs, # // TARGET_OS_IOS is only available in newer SDKs,
# // so assume any other iOS-based platform is iOS for now # // so assume any other iOS-based platform is iOS for now

View File

@ -77,6 +77,13 @@
Defined on tvOS. Defined on tvOS.
*/ */
/*!
\macro Q_OS_VISIONOS
\relates <QtSystemDetection>
Defined on visionOS.
*/
/*! /*!
\macro Q_OS_WIN \macro Q_OS_WIN
\relates <QtSystemDetection> \relates <QtSystemDetection>

View File

@ -567,6 +567,9 @@ void qt_apple_check_os_version()
#elif defined(__TV_OS_VERSION_MIN_REQUIRED) #elif defined(__TV_OS_VERSION_MIN_REQUIRED)
const char *os = "tvOS"; const char *os = "tvOS";
const int version = __TV_OS_VERSION_MIN_REQUIRED; const int version = __TV_OS_VERSION_MIN_REQUIRED;
#elif defined(__VISION_OS_VERSION_MIN_REQUIRED)
const char *os = "visionOS";
const int version = __VISION_OS_VERSION_MIN_REQUIRED;
#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED) #elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
const char *os = "iOS"; const char *os = "iOS";
const int version = __IPHONE_OS_VERSION_MIN_REQUIRED; const int version = __IPHONE_OS_VERSION_MIN_REQUIRED;

View File

@ -73,6 +73,11 @@ struct PermissionRequest
return Qt::PermissionStatus::Denied; return Qt::PermissionStatus::Denied;
} }
#if defined(Q_OS_VISIONOS)
if (permission.availability() == QLocationPermission::Always)
return Qt::PermissionStatus::Denied;
#endif
auto status = [self authorizationStatus]; auto status = [self authorizationStatus];
switch (status) { switch (status) {
case kCLAuthorizationStatusRestricted: case kCLAuthorizationStatusRestricted:
@ -80,9 +85,11 @@ struct PermissionRequest
return Qt::PermissionStatus::Denied; return Qt::PermissionStatus::Denied;
case kCLAuthorizationStatusNotDetermined: case kCLAuthorizationStatusNotDetermined:
return Qt::PermissionStatus::Undetermined; return Qt::PermissionStatus::Undetermined;
#if !defined(Q_OS_VISIONOS)
case kCLAuthorizationStatusAuthorizedAlways: case kCLAuthorizationStatusAuthorizedAlways:
return Qt::PermissionStatus::Granted; return Qt::PermissionStatus::Granted;
#ifdef Q_OS_IOS #endif
#if defined(Q_OS_IOS) || defined(Q_OS_VISIONOS)
case kCLAuthorizationStatusAuthorizedWhenInUse: case kCLAuthorizationStatusAuthorizedWhenInUse:
if (permission.availability() == QLocationPermission::Always) if (permission.availability() == QLocationPermission::Always)
return Qt::PermissionStatus::Denied; return Qt::PermissionStatus::Denied;
@ -177,6 +184,9 @@ struct PermissionRequest
} }
break; break;
case QLocationPermission::Always: case QLocationPermission::Always:
#if defined(Q_OS_VISIONOS)
[self deliverResult]; // Not supported
#else
// The documentation specifies that requestAlwaysAuthorization can only // The documentation specifies that requestAlwaysAuthorization can only
// be called when the current authorization status is either undetermined, // be called when the current authorization status is either undetermined,
// or authorized when in use. // or authorized when in use.
@ -199,6 +209,7 @@ struct PermissionRequest
default: default:
[self deliverResult]; [self deliverResult];
} }
#endif
break; break;
} }
} }

View File

@ -1,7 +1,7 @@
# Copyright (C) 2022 The Qt Company Ltd. # Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
if (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "iOS") if (NOT (WIN32 OR UIKIT))
return() return()
endif() endif()
@ -111,7 +111,7 @@ if(WIN32)
qt_internal_add_sync_header_dependencies(EntryPointImplementation Core) qt_internal_add_sync_header_dependencies(EntryPointImplementation Core)
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "iOS") if(UIKIT)
set_target_properties(EntryPointPrivate PROPERTIES set_target_properties(EntryPointPrivate PROPERTIES
INTERFACE_LINK_OPTIONS "-Wl,-e,_qt_main_wrapper" INTERFACE_LINK_OPTIONS "-Wl,-e,_qt_main_wrapper"
) )

View File

@ -13,7 +13,7 @@ if (QT_FEATURE_gui)
set(_default_platform "android") set(_default_platform "android")
elseif(MACOS) elseif(MACOS)
set(_default_platform "cocoa") set(_default_platform "cocoa")
elseif(TVOS OR IOS) elseif(UIKIT)
set(_default_platform "ios") set(_default_platform "ios")
elseif(WATCHOS) elseif(WATCHOS)
set(_default_platform "minimal") set(_default_platform "minimal")

View File

@ -813,7 +813,7 @@ qt_feature("vulkan" PUBLIC
) )
qt_feature("metal" PUBLIC qt_feature("metal" PUBLIC
LABEL "Metal" LABEL "Metal"
CONDITION MACOS OR IOS CONDITION MACOS OR IOS OR VISIONOS
) )
qt_feature("vkkhrdisplay" PRIVATE qt_feature("vkkhrdisplay" PRIVATE
SECTION "Platform plugins" SECTION "Platform plugins"
@ -1255,6 +1255,7 @@ qt_feature("wayland" PUBLIC
LABEL "Wayland" LABEL "Wayland"
CONDITION TARGET Wayland::Client CONDITION TARGET Wayland::Client
) )
qt_configure_add_summary_section(NAME "Qt Gui") qt_configure_add_summary_section(NAME "Qt Gui")
qt_configure_add_summary_entry(ARGS "accessibility") qt_configure_add_summary_entry(ARGS "accessibility")
qt_configure_add_summary_entry(ARGS "freetype") qt_configure_add_summary_entry(ARGS "freetype")
@ -1371,7 +1372,7 @@ qt_configure_add_report_entry(
qt_configure_add_report_entry( qt_configure_add_report_entry(
TYPE ERROR TYPE ERROR
MESSAGE "The OpenGL functionality tests failed! You might need to modify the OpenGL package search path by setting the OpenGL_DIR CMake variable to the OpenGL library's installation directory." MESSAGE "The OpenGL functionality tests failed! You might need to modify the OpenGL package search path by setting the OpenGL_DIR CMake variable to the OpenGL library's installation directory."
CONDITION QT_FEATURE_gui AND NOT WATCHOS AND ( NOT INPUT_opengl STREQUAL 'no' ) AND NOT QT_FEATURE_opengl_desktop AND NOT QT_FEATURE_opengles2 AND NOT QT_FEATURE_opengl_dynamic CONDITION QT_FEATURE_gui AND NOT WATCHOS AND NOT VISIONOS AND ( NOT INPUT_opengl STREQUAL 'no' ) AND NOT QT_FEATURE_opengl_desktop AND NOT QT_FEATURE_opengles2 AND NOT QT_FEATURE_opengl_dynamic
) )
qt_configure_add_report_entry( qt_configure_add_report_entry(
TYPE WARNING TYPE WARNING

View File

@ -185,7 +185,7 @@ QPixmap qt_mac_toQPixmap(const NSImage *image, const QSizeF &size)
#endif // Q_OS_MACOS #endif // Q_OS_MACOS
#ifdef Q_OS_IOS #ifdef QT_PLATFORM_UIKIT
QImage qt_mac_toQImage(const UIImage *image, QSizeF size) QImage qt_mac_toQImage(const UIImage *image, QSizeF size)
{ {
@ -202,7 +202,7 @@ QImage qt_mac_toQImage(const UIImage *image, QSizeF size)
return ret; return ret;
} }
#endif // Q_OS_IOS #endif // QT_PLATFORM_UIKIT
// ---------------------- Colors and Brushes ---------------------- // ---------------------- Colors and Brushes ----------------------

View File

@ -26,10 +26,8 @@
#if defined(__OBJC__) #if defined(__OBJC__)
# if defined(Q_OS_MACOS) # if defined(Q_OS_MACOS)
# include <AppKit/AppKit.h> # include <AppKit/AppKit.h>
# define HAVE_APPKIT # elif defined(QT_PLATFORM_UIKIT)
# elif defined(Q_OS_IOS)
# include <UIKit/UIKit.h> # include <UIKit/UIKit.h>
# define HAVE_UIKIT
# endif # endif
#endif #endif
@ -37,11 +35,11 @@ QT_BEGIN_NAMESPACE
Q_GUI_EXPORT CGBitmapInfo qt_mac_bitmapInfoForImage(const QImage &image); Q_GUI_EXPORT CGBitmapInfo qt_mac_bitmapInfoForImage(const QImage &image);
#ifdef HAVE_UIKIT #ifdef QT_PLATFORM_UIKIT
Q_GUI_EXPORT QImage qt_mac_toQImage(const UIImage *image, QSizeF size); Q_GUI_EXPORT QImage qt_mac_toQImage(const UIImage *image, QSizeF size);
#endif #endif
#ifdef HAVE_APPKIT #ifdef Q_OS_MACOS
Q_GUI_EXPORT QPixmap qt_mac_toQPixmap(const NSImage *image, const QSizeF &size); Q_GUI_EXPORT QPixmap qt_mac_toQPixmap(const NSImage *image, const QSizeF &size);
QT_END_NAMESPACE QT_END_NAMESPACE
@ -66,7 +64,7 @@ Q_GUI_EXPORT void qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBou
Q_GUI_EXPORT void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransform *orig_xform); Q_GUI_EXPORT void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransform *orig_xform);
#ifdef HAVE_APPKIT #ifdef Q_OS_MACOS
Q_GUI_EXPORT QColor qt_mac_toQColor(const NSColor *color); Q_GUI_EXPORT QColor qt_mac_toQColor(const NSColor *color);
Q_GUI_EXPORT QBrush qt_mac_toQBrush(const NSColor *color, QPalette::ColorGroup colorGroup = QPalette::Normal); Q_GUI_EXPORT QBrush qt_mac_toQBrush(const NSColor *color, QPalette::ColorGroup colorGroup = QPalette::Normal);
#endif #endif
@ -90,6 +88,4 @@ private:
QT_END_NAMESPACE QT_END_NAMESPACE
#undef HAVE_APPKIT
#endif // QCOREGRAPHICS_P_H #endif // QCOREGRAPHICS_P_H

View File

@ -5,7 +5,7 @@
#if defined(Q_OS_MACOS) #if defined(Q_OS_MACOS)
# include <AppKit/AppKit.h> # include <AppKit/AppKit.h>
#elif defined (Q_OS_IOS) #elif defined(QT_PLATFORM_UIKIT)
# include <UIKit/UIKit.h> # include <UIKit/UIKit.h>
#endif #endif
@ -280,7 +280,7 @@ auto *loadImage(const QString &iconName)
NSString *systemIconName = it != std::end(iconMap) ? it->second : iconName.toNSString(); NSString *systemIconName = it != std::end(iconMap) ? it->second : iconName.toNSString();
#if defined(Q_OS_MACOS) #if defined(Q_OS_MACOS)
return [NSImage imageWithSystemSymbolName:systemIconName accessibilityDescription:nil]; return [NSImage imageWithSystemSymbolName:systemIconName accessibilityDescription:nil];
#elif defined(Q_OS_IOS) #elif defined(QT_PLATFORM_UIKIT)
return [UIImage systemImageNamed:systemIconName]; return [UIImage systemImageNamed:systemIconName];
#endif #endif
} }
@ -374,7 +374,7 @@ auto *configuredImage(const NSImage *image, const QColor &color)
return [image imageWithSymbolConfiguration:config]; return [image imageWithSymbolConfiguration:config];
} }
#elif defined(Q_OS_IOS) #elif defined(QT_PLATFORM_UIKIT)
auto *configuredImage(const UIImage *image, const QColor &color) auto *configuredImage(const UIImage *image, const QColor &color)
{ {
auto *config = [UIImageSymbolConfiguration configurationWithPointSize:48 auto *config = [UIImageSymbolConfiguration configurationWithPointSize:48
@ -453,7 +453,7 @@ void QAppleIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode m
[image drawInRect:iconRect fromRect:sourceRect operation:NSCompositingOperationSourceOver fraction:1.0 respectFlipped:YES hints:nil]; [image drawInRect:iconRect fromRect:sourceRect operation:NSCompositingOperationSourceOver fraction:1.0 respectFlipped:YES hints:nil];
[NSGraphicsContext restoreGraphicsState]; [NSGraphicsContext restoreGraphicsState];
#elif defined(Q_OS_IOS) #elif defined(QT_PLATFORM_UIKIT)
UIGraphicsPushContext(ctx); UIGraphicsPushContext(ctx);
const CGRect cgrect = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()); const CGRect cgrect = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
[image drawInRect:cgrect]; [image drawInRect:cgrect];

View File

@ -51,7 +51,7 @@ private:
const QString m_iconName; const QString m_iconName;
#if defined(Q_OS_MACOS) #if defined(Q_OS_MACOS)
const NSImage *m_image; const NSImage *m_image;
#elif defined(Q_OS_IOS) #elif defined(QT_PLATFORM_UIKIT)
const UIImage *m_image; const UIImage *m_image;
#endif #endif
mutable QPixmap m_pixmap; mutable QPixmap m_pixmap;

View File

@ -567,9 +567,7 @@ bool QRhiMetal::create(QRhi::Flags flags)
// suitable as deviceId because it does not seem stable on macOS and can // suitable as deviceId because it does not seem stable on macOS and can
// apparently change when the system is rebooted. // apparently change when the system is rebooted.
#ifdef Q_OS_IOS #ifdef Q_OS_MACOS
driverInfoStruct.deviceType = QRhiDriverInfo::IntegratedDevice;
#else
if (@available(macOS 10.15, *)) { if (@available(macOS 10.15, *)) {
const MTLDeviceLocation deviceLocation = [d->dev location]; const MTLDeviceLocation deviceLocation = [d->dev location];
switch (deviceLocation) { switch (deviceLocation) {
@ -586,6 +584,8 @@ bool QRhiMetal::create(QRhi::Flags flags)
break; break;
} }
} }
#else
driverInfoStruct.deviceType = QRhiDriverInfo::IntegratedDevice;
#endif #endif
const QOperatingSystemVersion ver = QOperatingSystemVersion::current(); const QOperatingSystemVersion ver = QOperatingSystemVersion::current();
@ -6465,12 +6465,12 @@ QRhiSwapChainHdrInfo QMetalSwapChain::hdrInfo()
if (m_window) { if (m_window) {
// Must use m_window, not window, given this may be called before createOrResize(). // Must use m_window, not window, given this may be called before createOrResize().
#ifdef Q_OS_MACOS #if defined(Q_OS_MACOS)
NSView *view = reinterpret_cast<NSView *>(m_window->winId()); NSView *view = reinterpret_cast<NSView *>(m_window->winId());
NSScreen *screen = view.window.screen; NSScreen *screen = view.window.screen;
info.limits.colorComponentValue.maxColorComponentValue = screen.maximumExtendedDynamicRangeColorComponentValue; info.limits.colorComponentValue.maxColorComponentValue = screen.maximumExtendedDynamicRangeColorComponentValue;
info.limits.colorComponentValue.maxPotentialColorComponentValue = screen.maximumPotentialExtendedDynamicRangeColorComponentValue; info.limits.colorComponentValue.maxPotentialColorComponentValue = screen.maximumPotentialExtendedDynamicRangeColorComponentValue;
#else #elif defined(Q_OS_IOS)
if (@available(iOS 16.0, *)) { if (@available(iOS 16.0, *)) {
UIView *view = reinterpret_cast<UIView *>(m_window->winId()); UIView *view = reinterpret_cast<UIView *>(m_window->winId());
UIScreen *screen = view.window.windowScene.screen; UIScreen *screen = view.window.windowScene.screen;

View File

@ -896,7 +896,7 @@ static CTFontDescriptorRef fontDescriptorFromTheme(QPlatformTheme::Font f)
UIFontDescriptor *desc = [UIFontDescriptor preferredFontDescriptorWithTextStyle:textStyle]; UIFontDescriptor *desc = [UIFontDescriptor preferredFontDescriptorWithTextStyle:textStyle];
return static_cast<CTFontDescriptorRef>(CFBridgingRetain(desc)); return static_cast<CTFontDescriptorRef>(CFBridgingRetain(desc));
} }
#endif // Q_OS_IOS, Q_OS_TVOS, Q_OS_WATCHOS #endif // QT_PLATFORM_UIKIT
// macOS default case and iOS fallback case // macOS default case and iOS fallback case
return descriptorForFontType(fontTypeFromTheme(f)); return descriptorForFontType(fontTypeFromTheme(f));

View File

@ -244,7 +244,7 @@ qt_internal_extend_target(Network CONDITION QT_FEATURE_dnslookup AND NOT QT_FEAT
kernel/qdnslookup_dummy.cpp kernel/qdnslookup_dummy.cpp
) )
qt_internal_extend_target(Network CONDITION IOS OR MACOS qt_internal_extend_target(Network CONDITION APPLE
SOURCES SOURCES
kernel/qnetconmonitor_darwin.mm kernel/qnetconmonitor_darwin.mm
LIBRARIES LIBRARIES
@ -256,7 +256,7 @@ qt_internal_extend_target(Network CONDITION QT_FEATURE_networklistmanager AND NO
kernel/qnetconmonitor_win.cpp kernel/qnetconmonitor_win.cpp
) )
qt_internal_extend_target(Network CONDITION NOT IOS AND NOT MACOS AND NOT QT_FEATURE_networklistmanager qt_internal_extend_target(Network CONDITION NOT APPLE AND NOT QT_FEATURE_networklistmanager
SOURCES SOURCES
kernel/qnetconmonitor_stub.cpp kernel/qnetconmonitor_stub.cpp
) )
@ -271,7 +271,7 @@ qt_internal_extend_target(Network CONDITION UIKIT
kernel/qnetworkinterface_uikit_p.h kernel/qnetworkinterface_uikit_p.h
) )
qt_internal_extend_target(Network CONDITION APPLE qt_internal_extend_target(Network CONDITION APPLE AND NOT VISIONOS
SOURCES SOURCES
kernel/qnetworkproxy_darwin.cpp kernel/qnetworkproxy_darwin.cpp
) )
@ -289,7 +289,7 @@ qt_internal_extend_target(Network CONDITION ANDROID
kernel/qnetworkproxy_android.cpp kernel/qnetworkproxy_android.cpp
) )
qt_internal_extend_target(Network CONDITION UNIX AND NOT ANDROID AND NOT APPLE AND NOT QT_FEATURE_libproxy AND (UNIX OR WINRT) qt_internal_extend_target(Network CONDITION UNIX AND NOT ANDROID AND NOT (APPLE AND NOT VISIONOS) AND NOT QT_FEATURE_libproxy AND (UNIX OR WINRT)
SOURCES SOURCES
kernel/qnetworkproxy_generic.cpp kernel/qnetworkproxy_generic.cpp
) )

View File

@ -57,20 +57,31 @@ qt_internal_extend_target(QIOSIntegrationPlugin CONDITION QT_FEATURE_opengl
Qt::OpenGLPrivate Qt::OpenGLPrivate
) )
qt_internal_extend_target(QIOSIntegrationPlugin CONDITION NOT TVOS qt_internal_extend_target(QIOSIntegrationPlugin CONDITION QT_FEATURE_clipboard
SOURCES SOURCES
qiosclipboard.h qiosclipboard.mm qiosclipboard.h qiosclipboard.mm
qiosdocumentpickercontroller.h qiosdocumentpickercontroller.mm )
qt_internal_extend_target(QIOSIntegrationPlugin CONDITION NOT TVOS
SOURCES
qiosfiledialog.h qiosfiledialog.mm qiosfiledialog.h qiosfiledialog.mm
qioscolordialog.h qioscolordialog.mm qiosdocumentpickercontroller.h qiosdocumentpickercontroller.mm
qiosfontdialog.h qiosfontdialog.mm
qiosmenu.h qiosmenu.mm
qiosmessagedialog.h qiosmessagedialog.mm
qiostextinputoverlay.h qiostextinputoverlay.mm
LIBRARIES LIBRARIES
${FWAssetsLibrary}
${FWUniformTypeIdentifiers} ${FWUniformTypeIdentifiers}
${FWPhotos} ${FWPhotos}
) )
qt_internal_extend_target(QIOSIntegrationPlugin CONDITION NOT TVOS
SOURCES
qioscolordialog.h qioscolordialog.mm
qiosfontdialog.h qiosfontdialog.mm
qiosmessagedialog.h qiosmessagedialog.mm
)
qt_internal_extend_target(QIOSIntegrationPlugin CONDITION NOT (TVOS OR VISIONOS)
SOURCES
qiosmenu.h qiosmenu.mm
qiostextinputoverlay.h qiostextinputoverlay.mm
)
add_subdirectory(optional) add_subdirectory(optional)

View File

@ -8,6 +8,7 @@
#include <QtCore/private/qcore_mac_p.h> #include <QtCore/private/qcore_mac_p.h>
#include "qiosglobal.h"
#include "qioscolordialog.h" #include "qioscolordialog.h"
#include "qiosintegration.h" #include "qiosintegration.h"
@ -117,8 +118,7 @@ bool QIOSColorDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality windo
if (windowModality == Qt::ApplicationModal || windowModality == Qt::WindowModal) if (windowModality == Qt::ApplicationModal || windowModality == Qt::WindowModal)
m_viewController.modalInPresentation = YES; m_viewController.modalInPresentation = YES;
UIWindow *window = parent ? reinterpret_cast<UIView *>(parent->winId()).window UIWindow *window = presentationWindow(parent);
: qt_apple_sharedApplication().keyWindow;
if (!window) if (!window)
return false; return false;

View File

@ -11,6 +11,7 @@
#include <QtCore/private/qcore_mac_p.h> #include <QtCore/private/qcore_mac_p.h>
#include "qiosglobal.h"
#include "qiosfiledialog.h" #include "qiosfiledialog.h"
#include "qiosintegration.h" #include "qiosintegration.h"
#include "qiosoptionalplugininterface.h" #include "qiosoptionalplugininterface.h"
@ -59,8 +60,7 @@ bool QIOSFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality window
void QIOSFileDialog::showImagePickerDialog_helper(QWindow *parent) void QIOSFileDialog::showImagePickerDialog_helper(QWindow *parent)
{ {
UIWindow *window = parent ? reinterpret_cast<UIView *>(parent->winId()).window UIWindow *window = presentationWindow(parent);
: qt_apple_sharedApplication().keyWindow;
[window.rootViewController presentViewController:m_viewController animated:YES completion:nil]; [window.rootViewController presentViewController:m_viewController animated:YES completion:nil];
} }
@ -123,8 +123,7 @@ bool QIOSFileDialog::showNativeDocumentPickerDialog(QWindow *parent)
#ifndef Q_OS_TVOS #ifndef Q_OS_TVOS
m_viewController = [[QIOSDocumentPickerController alloc] initWithQIOSFileDialog:this]; m_viewController = [[QIOSDocumentPickerController alloc] initWithQIOSFileDialog:this];
UIWindow *window = parent ? reinterpret_cast<UIView *>(parent->winId()).window UIWindow *window = presentationWindow(parent);
: qt_apple_sharedApplication().keyWindow;
[window.rootViewController presentViewController:m_viewController animated:YES completion:nil]; [window.rootViewController presentViewController:m_viewController animated:YES completion:nil];
return true; return true;

View File

@ -11,6 +11,7 @@
#include <QtGui/private/qfont_p.h> #include <QtGui/private/qfont_p.h>
#include <QtGui/private/qfontengine_p.h> #include <QtGui/private/qfontengine_p.h>
#include "qiosglobal.h"
#include "qiosfontdialog.h" #include "qiosfontdialog.h"
#include "qiosintegration.h" #include "qiosintegration.h"
@ -144,8 +145,7 @@ bool QIOSFontDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality window
if (windowModality == Qt::ApplicationModal || windowModality == Qt::WindowModal) if (windowModality == Qt::ApplicationModal || windowModality == Qt::WindowModal)
m_viewController.modalInPresentation = YES; m_viewController.modalInPresentation = YES;
UIWindow *window = parent ? reinterpret_cast<UIView *>(parent->winId()).window UIWindow *window = presentationWindow(parent);
: qt_apple_sharedApplication().keyWindow;
if (!window) if (!window)
return false; return false;

View File

@ -34,6 +34,9 @@ UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation)
int infoPlistValue(NSString* key, int defaultValue); int infoPlistValue(NSString* key, int defaultValue);
class QWindow;
UIWindow *presentationWindow(QWindow *);
QT_END_NAMESPACE QT_END_NAMESPACE
@interface UIResponder (QtFirstResponder) @interface UIResponder (QtFirstResponder)

View File

@ -85,6 +85,16 @@ int infoPlistValue(NSString* key, int defaultValue)
return value ? [value intValue] : defaultValue; return value ? [value intValue] : defaultValue;
} }
UIWindow *presentationWindow(QWindow *window)
{
UIWindow *uiWindow = window ? reinterpret_cast<UIView *>(window->winId()).window : nullptr;
#if !defined(Q_OS_VISIONOS)
if (!uiWindow)
uiWindow = qt_apple_sharedApplication().keyWindow;
#endif
return uiWindow;
}
QT_END_NAMESPACE QT_END_NAMESPACE
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@ -22,11 +22,13 @@
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
#if !defined(Q_OS_VISIONOS)
static QUIView *focusView() static QUIView *focusView()
{ {
return qApp->focusWindow() ? return qApp->focusWindow() ?
reinterpret_cast<QUIView *>(qApp->focusWindow()->winId()) : 0; reinterpret_cast<QUIView *>(qApp->focusWindow()->winId()) : 0;
} }
#endif
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@ -352,7 +354,7 @@ void QIOSInputContext::clearCurrentFocusObject()
void QIOSInputContext::updateKeyboardState(NSNotification *notification) void QIOSInputContext::updateKeyboardState(NSNotification *notification)
{ {
#ifdef Q_OS_TVOS #if defined(Q_OS_TVOS) || defined(Q_OS_VISIONOS)
Q_UNUSED(notification); Q_UNUSED(notification);
#else #else
static CGRect currentKeyboardRect = CGRectZero; static CGRect currentKeyboardRect = CGRectZero;
@ -442,6 +444,7 @@ UIView *QIOSInputContext::scrollableRootView()
void QIOSInputContext::scrollToCursor() void QIOSInputContext::scrollToCursor()
{ {
#if !defined(Q_OS_VISIONOS)
if (!isQtApplication()) if (!isQtApplication())
return; return;
@ -498,6 +501,7 @@ void QIOSInputContext::scrollToCursor()
} else { } else {
scroll(0); scroll(0);
} }
#endif
} }
void QIOSInputContext::scroll(int y) void QIOSInputContext::scroll(int y)

View File

@ -11,7 +11,8 @@
#include <QtCore/private/qfactoryloader_p.h> #include <QtCore/private/qfactoryloader_p.h>
#include "qiosapplicationstate.h" #include "qiosapplicationstate.h"
#ifndef Q_OS_TVOS
#if !defined(Q_OS_TVOS) && !defined(Q_OS_VISIONOS)
#include "qiostextinputoverlay.h" #include "qiostextinputoverlay.h"
#endif #endif
@ -41,9 +42,11 @@ public:
QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override; QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override;
QPlatformFontDatabase *fontDatabase() const override; QPlatformFontDatabase *fontDatabase() const override;
#ifndef QT_NO_CLIPBOARD
#if QT_CONFIG(clipboard)
QPlatformClipboard *clipboard() const override; QPlatformClipboard *clipboard() const override;
#endif #endif
QPlatformInputContext *inputContext() const override; QPlatformInputContext *inputContext() const override;
QPlatformServices *services() const override; QPlatformServices *services() const override;
@ -76,7 +79,7 @@ public:
private: private:
QPlatformFontDatabase *m_fontDatabase; QPlatformFontDatabase *m_fontDatabase;
#ifndef Q_OS_TVOS #if QT_CONFIG(clipboard)
QPlatformClipboard *m_clipboard; QPlatformClipboard *m_clipboard;
#endif #endif
QPlatformInputContext *m_inputContext; QPlatformInputContext *m_inputContext;
@ -84,7 +87,7 @@ private:
QIOSServices *m_platformServices; QIOSServices *m_platformServices;
mutable QPlatformAccessibility *m_accessibility; mutable QPlatformAccessibility *m_accessibility;
QFactoryLoader *m_optionalPlugins; QFactoryLoader *m_optionalPlugins;
#ifndef Q_OS_TVOS #if !defined(Q_OS_TVOS) && !defined(Q_OS_VISIONOS)
QIOSTextInputOverlay m_textInputOverlay; QIOSTextInputOverlay m_textInputOverlay;
#endif #endif
}; };

View File

@ -9,7 +9,7 @@
#include "qioswindow.h" #include "qioswindow.h"
#include "qiosscreen.h" #include "qiosscreen.h"
#include "qiosplatformaccessibility.h" #include "qiosplatformaccessibility.h"
#ifndef Q_OS_TVOS #if QT_CONFIG(clipboard)
#include "qiosclipboard.h" #include "qiosclipboard.h"
#endif #endif
#include "qiosinputcontext.h" #include "qiosinputcontext.h"
@ -51,7 +51,7 @@ QIOSIntegration *QIOSIntegration::instance()
QIOSIntegration::QIOSIntegration() QIOSIntegration::QIOSIntegration()
: m_fontDatabase(new QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>) : m_fontDatabase(new QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>)
#if !defined(Q_OS_TVOS) && !defined(QT_NO_CLIPBOARD) #if QT_CONFIG(clipboard)
, m_clipboard(new QIOSClipboard) , m_clipboard(new QIOSClipboard)
#endif #endif
, m_inputContext(0) , m_inputContext(0)
@ -72,6 +72,10 @@ QIOSIntegration::QIOSIntegration()
void QIOSIntegration::initialize() void QIOSIntegration::initialize()
{ {
#if defined(Q_OS_VISIONOS)
// Qt requires a screen, so let's give it a dummy one
QWindowSystemInterface::handleScreenAdded(new QIOSScreen);
#else
UIScreen *mainScreen = [UIScreen mainScreen]; UIScreen *mainScreen = [UIScreen mainScreen];
NSMutableArray<UIScreen *> *screens = [[[UIScreen screens] mutableCopy] autorelease]; NSMutableArray<UIScreen *> *screens = [[[UIScreen screens] mutableCopy] autorelease];
if (![screens containsObject:mainScreen]) { if (![screens containsObject:mainScreen]) {
@ -81,6 +85,7 @@ void QIOSIntegration::initialize()
for (UIScreen *screen in screens) for (UIScreen *screen in screens)
QWindowSystemInterface::handleScreenAdded(new QIOSScreen(screen)); QWindowSystemInterface::handleScreenAdded(new QIOSScreen(screen));
#endif
// Depends on a primary screen being present // Depends on a primary screen being present
m_inputContext = new QIOSInputContext; m_inputContext = new QIOSInputContext;
@ -88,8 +93,10 @@ void QIOSIntegration::initialize()
m_touchDevice = new QPointingDevice; m_touchDevice = new QPointingDevice;
m_touchDevice->setType(QInputDevice::DeviceType::TouchScreen); m_touchDevice->setType(QInputDevice::DeviceType::TouchScreen);
QPointingDevice::Capabilities touchCapabilities = QPointingDevice::Capability::Position | QPointingDevice::Capability::NormalizedPosition; QPointingDevice::Capabilities touchCapabilities = QPointingDevice::Capability::Position | QPointingDevice::Capability::NormalizedPosition;
#if !defined(Q_OS_VISIONOS)
if (mainScreen.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) if (mainScreen.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)
touchCapabilities |= QPointingDevice::Capability::Pressure; touchCapabilities |= QPointingDevice::Capability::Pressure;
#endif
m_touchDevice->setCapabilities(touchCapabilities); m_touchDevice->setCapabilities(touchCapabilities);
QWindowSystemInterface::registerInputDevice(m_touchDevice); QWindowSystemInterface::registerInputDevice(m_touchDevice);
#if QT_CONFIG(tabletevent) #if QT_CONFIG(tabletevent)
@ -107,7 +114,7 @@ QIOSIntegration::~QIOSIntegration()
delete m_fontDatabase; delete m_fontDatabase;
m_fontDatabase = 0; m_fontDatabase = 0;
#if !defined(Q_OS_TVOS) && !defined(QT_NO_CLIPBOARD) #if QT_CONFIG(clipboard)
delete m_clipboard; delete m_clipboard;
m_clipboard = 0; m_clipboard = 0;
#endif #endif
@ -208,14 +215,10 @@ QPlatformFontDatabase * QIOSIntegration::fontDatabase() const
return m_fontDatabase; return m_fontDatabase;
} }
#ifndef QT_NO_CLIPBOARD #if QT_CONFIG(clipboard)
QPlatformClipboard *QIOSIntegration::clipboard() const QPlatformClipboard *QIOSIntegration::clipboard() const
{ {
#ifndef Q_OS_TVOS
return m_clipboard; return m_clipboard;
#else
return QPlatformIntegration::clipboard();
#endif
} }
#endif #endif

View File

@ -116,7 +116,7 @@ bool QIOSMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality win
[m_alertController addAction:createAction(NoButton)]; [m_alertController addAction:createAction(NoButton)];
} }
UIWindow *window = parent ? reinterpret_cast<UIView *>(parent->winId()).window : qt_apple_sharedApplication().keyWindow; UIWindow *window = presentationWindow(parent);
if (!window) { if (!window) {
qCDebug(lcQpaWindow, "Attempting to exec a dialog without any window/widget visible."); qCDebug(lcQpaWindow, "Attempting to exec a dialog without any window/widget visible.");

View File

@ -21,7 +21,11 @@ class QIOSScreen : public QObject, public QPlatformScreen
Q_OBJECT Q_OBJECT
public: public:
#if !defined(Q_OS_VISIONOS)
QIOSScreen(UIScreen *screen); QIOSScreen(UIScreen *screen);
#else
QIOSScreen();
#endif
~QIOSScreen(); ~QIOSScreen();
QString name() const override; QString name() const override;
@ -40,7 +44,9 @@ public:
QPixmap grabWindow(WId window, int x, int y, int width, int height) const override; QPixmap grabWindow(WId window, int x, int y, int width, int height) const override;
#if !defined(Q_OS_VISIONOS)
UIScreen *uiScreen() const; UIScreen *uiScreen() const;
#endif
UIWindow *uiWindow() const; UIWindow *uiWindow() const;
void setUpdatesPaused(bool); void setUpdatesPaused(bool);
@ -50,15 +56,19 @@ public:
private: private:
void deliverUpdateRequests() const; void deliverUpdateRequests() const;
UIScreen *m_uiScreen; #if !defined(Q_OS_VISIONOS)
UIWindow *m_uiWindow; UIScreen *m_uiScreen = nullptr;
#endif
UIWindow *m_uiWindow = nullptr;
QRect m_geometry; QRect m_geometry;
QRect m_availableGeometry; QRect m_availableGeometry;
int m_depth; int m_depth;
#if !defined(Q_OS_VISIONOS)
uint m_physicalDpi; uint m_physicalDpi;
#endif
QSizeF m_physicalSize; QSizeF m_physicalSize;
QIOSOrientationListener *m_orientationListener; QIOSOrientationListener *m_orientationListener = nullptr;
CADisplayLink *m_displayLink; CADisplayLink *m_displayLink = nullptr;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -46,6 +46,7 @@ typedef void (^DisplayLinkBlock)(CADisplayLink *displayLink);
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
#if !defined(Q_OS_VISIONOS)
static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen) static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
{ {
foreach (QScreen *screen, QGuiApplication::screens()) { foreach (QScreen *screen, QGuiApplication::screens()) {
@ -149,6 +150,8 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
@end @end
#endif // !defined(Q_OS_VISIONOS)
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@implementation QUIWindow @implementation QUIWindow
@ -167,6 +170,7 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
[super sendEvent:event]; [super sendEvent:event];
} }
#if !defined(Q_OS_VISIONOS)
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection
{ {
[super traitCollectionDidChange:previousTraitCollection]; [super traitCollectionDidChange:previousTraitCollection];
@ -189,6 +193,7 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
} }
} }
} }
#endif
@end @end
@ -198,6 +203,7 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals; using namespace Qt::StringLiterals;
#if !defined(Q_OS_VISIONOS)
/*! /*!
Returns the model identifier of the device. Returns the model identifier of the device.
*/ */
@ -217,12 +223,14 @@ static QString deviceModelIdentifier()
return QString::fromLatin1(QByteArrayView(value, qsizetype(size))); return QString::fromLatin1(QByteArrayView(value, qsizetype(size)));
#endif #endif
} }
#endif // !defined(Q_OS_VISIONOS)
#if defined(Q_OS_VISIONOS)
QIOSScreen::QIOSScreen()
{
#else
QIOSScreen::QIOSScreen(UIScreen *screen) QIOSScreen::QIOSScreen(UIScreen *screen)
: QPlatformScreen() : m_uiScreen(screen)
, m_uiScreen(screen)
, m_uiWindow(0)
, m_orientationListener(0)
{ {
QString deviceIdentifier = deviceModelIdentifier(); QString deviceIdentifier = deviceModelIdentifier();
@ -273,11 +281,13 @@ QIOSScreen::QIOSScreen(UIScreen *screen)
m_orientationListener = [[QIOSOrientationListener alloc] initWithQIOSScreen:this]; m_orientationListener = [[QIOSOrientationListener alloc] initWithQIOSScreen:this];
updateProperties();
m_displayLink = [m_uiScreen displayLinkWithBlock:^(CADisplayLink *) { deliverUpdateRequests(); }]; m_displayLink = [m_uiScreen displayLinkWithBlock:^(CADisplayLink *) { deliverUpdateRequests(); }];
m_displayLink.paused = YES; // Enabled when clients call QWindow::requestUpdate() m_displayLink.paused = YES; // Enabled when clients call QWindow::requestUpdate()
[m_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; [m_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
#endif // !defined(Q_OS_VISIONOS))
updateProperties();
} }
QIOSScreen::~QIOSScreen() QIOSScreen::~QIOSScreen()
@ -290,13 +300,17 @@ QIOSScreen::~QIOSScreen()
QString QIOSScreen::name() const QString QIOSScreen::name() const
{ {
#if defined(Q_OS_VISIONOS)
return {};
#else
if (m_uiScreen == [UIScreen mainScreen]) if (m_uiScreen == [UIScreen mainScreen])
return QString::fromNSString([UIDevice currentDevice].model) + " built-in display"_L1; return QString::fromNSString([UIDevice currentDevice].model) + " built-in display"_L1;
else else
return "External display"_L1; return "External display"_L1;
#endif
} }
static bool isRunningOnVisionOS() [[maybe_unused]] static bool isRunningOnVisionOS()
{ {
static bool result = []{ static bool result = []{
// This class is documented to only be available on visionOS // This class is documented to only be available on visionOS
@ -310,8 +324,13 @@ void QIOSScreen::updateProperties()
QRect previousGeometry = m_geometry; QRect previousGeometry = m_geometry;
QRect previousAvailableGeometry = m_availableGeometry; QRect previousAvailableGeometry = m_availableGeometry;
#if defined(Q_OS_VISIONOS)
// Based on what iPad app reports
m_geometry = QRect(0, 0, 1194, 834);
m_availableGeometry = m_geometry;
m_depth = 24;
#else
m_geometry = QRectF::fromCGRect(m_uiScreen.bounds).toRect(); m_geometry = QRectF::fromCGRect(m_uiScreen.bounds).toRect();
m_availableGeometry = m_geometry; m_availableGeometry = m_geometry;
// For convenience, we reflect the safe area margins of the screen's UIWindow // For convenience, we reflect the safe area margins of the screen's UIWindow
@ -369,6 +388,8 @@ void QIOSScreen::updateProperties()
m_physicalSize = physicalGeometry.size() / m_physicalDpi * millimetersPerInch; m_physicalSize = physicalGeometry.size() / m_physicalDpi * millimetersPerInch;
} }
#endif // defined(Q_OS_VISIONOS)
// At construction time, we don't yet have an associated QScreen, but we still want // At construction time, we don't yet have an associated QScreen, but we still want
// to compute the properties above so they are ready for when the QScreen attaches. // to compute the properties above so they are ready for when the QScreen attaches.
// Also, at destruction time the QScreen has already been torn down, so notifying // Also, at destruction time the QScreen has already been torn down, so notifying
@ -453,16 +474,28 @@ QDpi QIOSScreen::logicalBaseDpi() const
qreal QIOSScreen::devicePixelRatio() const qreal QIOSScreen::devicePixelRatio() const
{ {
#if defined(Q_OS_VISIONOS)
return 2.0; // Based on what iPad app reports
#else
return [m_uiScreen scale]; return [m_uiScreen scale];
#endif
} }
qreal QIOSScreen::refreshRate() const qreal QIOSScreen::refreshRate() const
{ {
#if defined(Q_OS_VISIONOS)
return 120.0; // Based on what iPad app reports
#else
return m_uiScreen.maximumFramesPerSecond; return m_uiScreen.maximumFramesPerSecond;
#endif
} }
Qt::ScreenOrientation QIOSScreen::nativeOrientation() const Qt::ScreenOrientation QIOSScreen::nativeOrientation() const
{ {
#if defined(Q_OS_VISIONOS)
// Based on iPad app reporting native bounds 1668x2388
return Qt::PortraitOrientation;
#else
CGRect nativeBounds = CGRect nativeBounds =
#if defined(Q_OS_IOS) #if defined(Q_OS_IOS)
m_uiScreen.nativeBounds; m_uiScreen.nativeBounds;
@ -474,11 +507,12 @@ Qt::ScreenOrientation QIOSScreen::nativeOrientation() const
// be on the safe side we compare the width and height of the bounds. // be on the safe side we compare the width and height of the bounds.
return nativeBounds.size.width >= nativeBounds.size.height ? return nativeBounds.size.width >= nativeBounds.size.height ?
Qt::LandscapeOrientation : Qt::PortraitOrientation; Qt::LandscapeOrientation : Qt::PortraitOrientation;
#endif
} }
Qt::ScreenOrientation QIOSScreen::orientation() const Qt::ScreenOrientation QIOSScreen::orientation() const
{ {
#ifdef Q_OS_TVOS #if defined(Q_OS_TVOS) || defined(Q_OS_VISIONOS)
return Qt::PrimaryOrientation; return Qt::PrimaryOrientation;
#else #else
// Auxiliary screens are always the same orientation as their primary orientation // Auxiliary screens are always the same orientation as their primary orientation
@ -540,10 +574,12 @@ QPixmap QIOSScreen::grabWindow(WId window, int x, int y, int width, int height)
return QPixmap::fromImage(qt_mac_toQImage(screenshot.CGImage)); return QPixmap::fromImage(qt_mac_toQImage(screenshot.CGImage));
} }
#if !defined(Q_OS_VISIONOS)
UIScreen *QIOSScreen::uiScreen() const UIScreen *QIOSScreen::uiScreen() const
{ {
return m_uiScreen; return m_uiScreen;
} }
#endif
UIWindow *QIOSScreen::uiWindow() const UIWindow *QIOSScreen::uiWindow() const
{ {

View File

@ -401,7 +401,7 @@
if (UIView *accessoryView = static_cast<UIView *>(platformData.value(kImePlatformDataInputAccessoryView).value<void *>())) if (UIView *accessoryView = static_cast<UIView *>(platformData.value(kImePlatformDataInputAccessoryView).value<void *>()))
self.inputAccessoryView = [[[WrapperView alloc] initWithView:accessoryView] autorelease]; self.inputAccessoryView = [[[WrapperView alloc] initWithView:accessoryView] autorelease];
#ifndef Q_OS_TVOS #if !defined(Q_OS_TVOS) && !defined(Q_OS_VISIONOS)
if (platformData.value(kImePlatformDataHideShortcutsBar).toBool()) { if (platformData.value(kImePlatformDataHideShortcutsBar).toBool()) {
// According to the docs, leadingBarButtonGroups/trailingBarButtonGroups should be set to nil to hide the shortcuts bar. // According to the docs, leadingBarButtonGroups/trailingBarButtonGroups should be set to nil to hide the shortcuts bar.
// However, starting with iOS 10, the API has been surrounded with NS_ASSUME_NONNULL, which contradicts this and causes // However, starting with iOS 10, the API has been surrounded with NS_ASSUME_NONNULL, which contradicts this and causes

View File

@ -23,8 +23,10 @@ public:
Qt::ColorScheme colorScheme() const override; Qt::ColorScheme colorScheme() const override;
#if !defined(Q_OS_TVOS) && !defined(Q_OS_VISIONOS)
QPlatformMenuItem* createPlatformMenuItem() const override; QPlatformMenuItem* createPlatformMenuItem() const override;
QPlatformMenu* createPlatformMenu() const override; QPlatformMenu* createPlatformMenu() const override;
#endif
bool usePlatformNativeDialog(DialogType type) const override; bool usePlatformNativeDialog(DialogType type) const override;
QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const override; QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const override;

View File

@ -18,12 +18,15 @@
#include <UIKit/UIFont.h> #include <UIKit/UIFont.h>
#include <UIKit/UIInterface.h> #include <UIKit/UIInterface.h>
#ifndef Q_OS_TVOS #if !defined(Q_OS_TVOS) && !defined(Q_OS_VISIONOS)
#include "qiosmenu.h" #include "qiosmenu.h"
#endif
#if !defined(Q_OS_TVOS)
#include "qiosfiledialog.h" #include "qiosfiledialog.h"
#include "qiosmessagedialog.h"
#include "qioscolordialog.h" #include "qioscolordialog.h"
#include "qiosfontdialog.h" #include "qiosfontdialog.h"
#include "qiosmessagedialog.h"
#include "qiosscreen.h" #include "qiosscreen.h"
#endif #endif
@ -82,23 +85,17 @@ const QPalette *QIOSTheme::palette(QPlatformTheme::Palette type) const
return 0; return 0;
} }
#if !defined(Q_OS_TVOS) && !defined(Q_OS_VISIONOS)
QPlatformMenuItem* QIOSTheme::createPlatformMenuItem() const QPlatformMenuItem* QIOSTheme::createPlatformMenuItem() const
{ {
#ifdef Q_OS_TVOS return new QIOSMenuItem;
return 0;
#else
return new QIOSMenuItem();
#endif
} }
QPlatformMenu* QIOSTheme::createPlatformMenu() const QPlatformMenu* QIOSTheme::createPlatformMenu() const
{ {
#ifdef Q_OS_TVOS return new QIOSMenu;
return 0;
#else
return new QIOSMenu();
#endif
} }
#endif
bool QIOSTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const bool QIOSTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const
{ {
@ -149,6 +146,13 @@ QVariant QIOSTheme::themeHint(ThemeHint hint) const
Qt::ColorScheme QIOSTheme::colorScheme() const Qt::ColorScheme QIOSTheme::colorScheme() const
{ {
#if defined(Q_OS_VISIONOS)
// On visionOS the concept of light or dark mode does not
// apply, as the UI is constantly changing based on what
// the lighting conditions are outside the headset, but
// the OS reports itself as always being in dark mode.
return Qt::ColorScheme::Dark;
#else
// Set the appearance based on the QUIWindow // Set the appearance based on the QUIWindow
// Fallback to the UIScreen if no window is created yet // Fallback to the UIScreen if no window is created yet
UIUserInterfaceStyle appearance = UIScreen.mainScreen.traitCollection.userInterfaceStyle; UIUserInterfaceStyle appearance = UIScreen.mainScreen.traitCollection.userInterfaceStyle;
@ -163,6 +167,7 @@ Qt::ColorScheme QIOSTheme::colorScheme() const
return appearance == UIUserInterfaceStyleDark return appearance == UIUserInterfaceStyleDark
? Qt::ColorScheme::Dark ? Qt::ColorScheme::Dark
: Qt::ColorScheme::Light; : Qt::ColorScheme::Light;
#endif
} }
const QFont *QIOSTheme::font(Font type) const const QFont *QIOSTheme::font(Font type) const

View File

@ -88,6 +88,7 @@
- (void)didAddSubview:(UIView *)subview - (void)didAddSubview:(UIView *)subview
{ {
#if !defined(Q_OS_VISIONOS)
Q_UNUSED(subview); Q_UNUSED(subview);
QT_PREPEND_NAMESPACE(QIOSScreen) *screen = self.qtViewController.platformScreen; QT_PREPEND_NAMESPACE(QIOSScreen) *screen = self.qtViewController.platformScreen;
@ -103,10 +104,12 @@
uiWindow.screen = screen->uiScreen(); uiWindow.screen = screen->uiScreen();
uiWindow.hidden = NO; uiWindow.hidden = NO;
} }
#endif
} }
- (void)willRemoveSubview:(UIView *)subview - (void)willRemoveSubview:(UIView *)subview
{ {
#if !defined(Q_OS_VISIONOS)
Q_UNUSED(subview); Q_UNUSED(subview);
UIWindow *uiWindow = self.window; UIWindow *uiWindow = self.window;
@ -124,6 +127,7 @@
uiWindow.screen = [UIScreen mainScreen]; uiWindow.screen = [UIScreen mainScreen];
}); });
} }
#endif
} }
- (void)layoutSubviews - (void)layoutSubviews
@ -285,7 +289,7 @@
Q_ASSERT(!qt_apple_isApplicationExtension()); Q_ASSERT(!qt_apple_isApplicationExtension());
#ifndef Q_OS_TVOS #if !defined(Q_OS_TVOS) && !defined(Q_OS_VISIONOS)
NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(willChangeStatusBarFrame:) [center addObserver:self selector:@selector(willChangeStatusBarFrame:)
name:UIApplicationWillChangeStatusBarFrameNotification name:UIApplicationWillChangeStatusBarFrameNotification
@ -307,7 +311,7 @@
- (BOOL)shouldAutorotate - (BOOL)shouldAutorotate
{ {
#ifndef Q_OS_TVOS #if !defined(Q_OS_TVOS) && !defined(Q_OS_VISIONOS)
return self.platformScreen && self.platformScreen->uiScreen() == [UIScreen mainScreen] && !self.lockedOrientation; return self.platformScreen && self.platformScreen->uiScreen() == [UIScreen mainScreen] && !self.lockedOrientation;
#else #else
return NO; return NO;
@ -339,6 +343,7 @@
[super didRotateFromInterfaceOrientation:orientation]; [super didRotateFromInterfaceOrientation:orientation];
} }
#if !defined(Q_OS_VISIONOS)
- (void)willChangeStatusBarFrame:(NSNotification*)notification - (void)willChangeStatusBarFrame:(NSNotification*)notification
{ {
Q_UNUSED(notification); Q_UNUSED(notification);
@ -382,6 +387,7 @@
[self.view setNeedsLayout]; [self.view setNeedsLayout];
} }
#endif
- (void)viewWillLayoutSubviews - (void)viewWillLayoutSubviews
{ {
@ -402,10 +408,12 @@
if (!self.platformScreen || !self.platformScreen->screen()) if (!self.platformScreen || !self.platformScreen->screen())
return; return;
#if !defined(Q_OS_VISIONOS)
// For now we only care about the main screen, as both the statusbar // For now we only care about the main screen, as both the statusbar
// visibility and orientation is only appropriate for the main screen. // visibility and orientation is only appropriate for the main screen.
if (self.platformScreen->uiScreen() != [UIScreen mainScreen]) if (self.platformScreen->uiScreen() != [UIScreen mainScreen])
return; return;
#endif
// Prevent recursion caused by updating the status bar appearance (position // Prevent recursion caused by updating the status bar appearance (position
// or visibility), which in turn may cause a layout of our subviews, and // or visibility), which in turn may cause a layout of our subviews, and
@ -432,7 +440,7 @@
// All decisions are based on the top level window // All decisions are based on the top level window
focusWindow = qt_window_private(focusWindow)->topLevelWindow(); focusWindow = qt_window_private(focusWindow)->topLevelWindow();
#ifndef Q_OS_TVOS #if !defined(Q_OS_TVOS) && !defined(Q_OS_VISIONOS)
// -------------- Status bar style and visbility --------------- // -------------- Status bar style and visbility ---------------

View File

@ -21,7 +21,7 @@
#import <QuartzCore/CAEAGLLayer.h> #import <QuartzCore/CAEAGLLayer.h>
#endif #endif
#ifdef Q_OS_IOS #if QT_CONFIG(metal)
#import <QuartzCore/CAMetalLayer.h> #import <QuartzCore/CAMetalLayer.h>
#endif #endif
@ -42,7 +42,7 @@ QIOSWindow::QIOSWindow(QWindow *window, WId nativeHandle)
m_view = reinterpret_cast<UIView *>(nativeHandle); m_view = reinterpret_cast<UIView *>(nativeHandle);
[m_view retain]; [m_view retain];
} else { } else {
#ifdef Q_OS_IOS #if QT_CONFIG(metal)
if (window->surfaceType() == QSurface::RasterSurface) if (window->surfaceType() == QSurface::RasterSurface)
window->setSurfaceType(QSurface::MetalSurface); window->setSurfaceType(QSurface::MetalSurface);
@ -304,7 +304,6 @@ void QIOSWindow::requestActivateWindow()
if (blockedByModal()) if (blockedByModal())
return; return;
Q_ASSERT(m_view.window);
[m_view.window makeKeyWindow]; [m_view.window makeKeyWindow];
[m_view becomeFirstResponder]; [m_view becomeFirstResponder];

View File

@ -34,7 +34,7 @@ QT_END_NAMESPACE
- (QIOSViewController*)qtViewController; - (QIOSViewController*)qtViewController;
@end @end
#ifdef Q_OS_IOS #if QT_CONFIG(metal)
@interface QUIMetalView : QUIView @interface QUIMetalView : QUIView
@end @end
#endif #endif

View File

@ -61,7 +61,7 @@ inline ulong getTimeStamp(UIEvent *event)
+ (void)load + (void)load
{ {
#ifndef Q_OS_TVOS #if !defined(Q_OS_TVOS) && !defined(Q_OS_VISIONOS)
if (QOperatingSystemVersion::current() < QOperatingSystemVersion(QOperatingSystemVersion::IOS, 11)) { if (QOperatingSystemVersion::current() < QOperatingSystemVersion(QOperatingSystemVersion::IOS, 11)) {
// iOS 11 handles this though [UIView safeAreaInsetsDidChange], but there's no signal for // iOS 11 handles this though [UIView safeAreaInsetsDidChange], but there's no signal for
// the corresponding top and bottom layout guides that we use on earlier versions. Note // the corresponding top and bottom layout guides that we use on earlier versions. Note
@ -197,6 +197,7 @@ inline ulong getTimeStamp(UIEvent *event)
return description; return description;
} }
#if !defined(Q_OS_VISIONOS)
- (void)willMoveToWindow:(UIWindow *)newWindow - (void)willMoveToWindow:(UIWindow *)newWindow
{ {
// UIKIt will normally set the scale factor of a view to match the corresponding // UIKIt will normally set the scale factor of a view to match the corresponding
@ -206,6 +207,7 @@ inline ulong getTimeStamp(UIEvent *event)
// FIXME: Allow the scale factor to be customized through QSurfaceFormat. // FIXME: Allow the scale factor to be customized through QSurfaceFormat.
} }
#endif
- (void)didAddSubview:(UIView *)subview - (void)didAddSubview:(UIView *)subview
{ {
@ -700,7 +702,7 @@ inline ulong getTimeStamp(UIEvent *event)
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{ {
#ifndef Q_OS_TVOS #if !defined(Q_OS_TVOS) && !defined(Q_OS_VISIONOS)
// Check first if QIOSMenu should handle the action before continuing up the responder chain // Check first if QIOSMenu should handle the action before continuing up the responder chain
return [QIOSMenu::menuActionTarget() targetForAction:action withSender:sender] != 0; return [QIOSMenu::menuActionTarget() targetForAction:action withSender:sender] != 0;
#else #else
@ -713,7 +715,7 @@ inline ulong getTimeStamp(UIEvent *event)
- (id)forwardingTargetForSelector:(SEL)selector - (id)forwardingTargetForSelector:(SEL)selector
{ {
Q_UNUSED(selector); Q_UNUSED(selector);
#ifndef Q_OS_TVOS #if !defined(Q_OS_TVOS) && !defined(Q_OS_VISIONOS)
return QIOSMenu::menuActionTarget(); return QIOSMenu::menuActionTarget();
#else #else
return nil; return nil;
@ -831,7 +833,7 @@ inline ulong getTimeStamp(UIEvent *event)
@end @end
#ifdef Q_OS_IOS #if QT_CONFIG(metal)
@implementation QUIMetalView @implementation QUIMetalView
+ (Class)layerClass + (Class)layerClass

View File

@ -118,6 +118,9 @@ static QSet<QByteArray> keywords()
#ifdef Q_OS_WATCHOS #ifdef Q_OS_WATCHOS
<< "watchos" << "watchos"
#endif #endif
#ifdef Q_OS_VISIONOS
<< "visionos"
#endif
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID
<< "android" << "android"
#endif #endif

View File

@ -1289,7 +1289,7 @@ void QWidgetPrivate::create()
Qt::WindowFlags &flags = data.window_flags; Qt::WindowFlags &flags = data.window_flags;
#if defined(Q_OS_IOS) || defined(Q_OS_TVOS) #if defined(QT_PLATFORM_UIKIT)
if (q->testAttribute(Qt::WA_ContentsMarginsRespectsSafeArea)) if (q->testAttribute(Qt::WA_ContentsMarginsRespectsSafeArea))
flags |= Qt::MaximizeUsingFullscreenGeometryHint; flags |= Qt::MaximizeUsingFullscreenGeometryHint;
#endif #endif