Switched Windows builds to Qt 6. (Combined commit.)

This commit is contained in:
23rd
2026-09-16 09:58:41 +03:00
parent bac5a64087
commit cab00cd8b8
11 changed files with 170 additions and 18 deletions

View File

@@ -55,6 +55,32 @@ include(cmake/validate_d3d_compiler.cmake)
include(cmake/target_prepare_qrc.cmake)
include(cmake/options.cmake)
# Nested: `if' expands all arguments, QT must be read only when set.
if (WIN32 AND NOT build_winarm AND NOT build_winstore AND DEFINED ENV{QT})
if (NOT "$ENV{QT}" VERSION_LESS 6)
# Windows 7 and 8 need ANGLE, Qt is already built with EGL.
set(DESKTOP_APP_WIN7_BASELINE TRUE)
set(angle_loc ${libs_loc}/tg_angle)
set(angle_lib ${angle_loc}/out/Release/tg_angle.lib)
set(HAVE_EGL ON CACHE BOOL "ANGLE provides EGL")
set(EGL_INCLUDE_DIR ${angle_loc}/include CACHE PATH "ANGLE headers")
set(EGL_LIBRARY ${angle_lib} CACHE FILEPATH "ANGLE library")
set(HAVE_GLESv2 ON CACHE BOOL "ANGLE provides OpenGL ES 2")
set(GLESv2_INCLUDE_DIR ${angle_loc}/include CACHE PATH "ANGLE headers")
set(GLESv2_LIBRARY ${angle_lib} CACHE FILEPATH "ANGLE library")
# Qt plugin links EGL::EGL, per-config target keeps Debug on Debug ANGLE.
add_library(EGL::EGL STATIC IMPORTED)
set_target_properties(EGL::EGL PROPERTIES
IMPORTED_LOCATION ${angle_lib}
IMPORTED_LOCATION_DEBUG ${angle_loc}/out/Debug/tg_angle.lib
INTERFACE_INCLUDE_DIRECTORIES ${angle_loc}/include
)
endif()
endif()
include(cmake/external/qt/package.cmake)
set(desktop_app_skip_libs

View File

@@ -2295,11 +2295,37 @@ if (WIN32)
# $<IF:${release},"Appending compatibility manifest.","Finalizing build.">
# )
if (QT_VERSION LESS 6)
if (QT_VERSION LESS 6 OR DESKTOP_APP_WIN7_BASELINE)
target_link_libraries(Telegram PRIVATE desktop-app::win_directx_helper)
endif()
if (DESKTOP_APP_WIN7_BASELINE)
# ANGLE loads d3dcompiler_47.dll from modules folder next to exe.
if (build_win64)
set(d3d_modules_subdir x64)
else()
set(d3d_modules_subdir x86)
endif()
set(d3d_modules_dir $<TARGET_FILE_DIR:Telegram>/modules/${d3d_modules_subdir}/d3d)
add_custom_command(TARGET Telegram POST_BUILD
COMMAND
${CMAKE_COMMAND} -E make_directory ${d3d_modules_dir}
COMMAND
${CMAKE_COMMAND} -E copy_if_different
${cmake_helpers_loc}/win_directx_helper/modules/${d3d_modules_subdir}/d3d/d3dcompiler_47.dll
${d3d_modules_dir}/d3dcompiler_47.dll
COMMENT
"Copying d3dcompiler_47.dll for ANGLE."
VERBATIM
)
endif()
target_link_options(Telegram PRIVATE /PDBPAGESIZE:8192)
if (DESKTOP_APP_WIN7_BASELINE)
# The loader reads the subsystem version as the minimal Windows.
target_link_options(Telegram PRIVATE /SUBSYSTEM:WINDOWS,6.01)
endif()
elseif (APPLE)
if (NOT DESKTOP_APP_USE_PACKAGED)
target_link_libraries(Telegram PRIVATE desktop-app::external_iconv)
@@ -2589,6 +2615,9 @@ if (NOT DESKTOP_APP_DISABLE_AUTOUPDATE AND NOT build_macstore AND NOT build_wins
else()
target_link_options(Updater PRIVATE -municode)
endif()
if (DESKTOP_APP_WIN7_BASELINE)
target_link_options(Updater PRIVATE /SUBSYSTEM:WINDOWS,6.01)
endif()
elseif (APPLE)
add_custom_command(TARGET Updater
POST_BUILD
@@ -2625,6 +2654,12 @@ if (NOT DESKTOP_APP_DISABLE_AUTOUPDATE AND NOT build_macstore AND NOT build_wins
target_compile_definitions(Packer PRIVATE PACKER_USE_PACKAGED)
endif()
if (WIN32 AND DESKTOP_APP_WIN7_BASELINE)
# WindowsApp.lib is off the link line, WinRT stubs come from lib_base.
target_link_libraries(Packer PRIVATE desktop-app::lib_base)
target_link_options(Packer PRIVATE /SUBSYSTEM:CONSOLE,6.01)
endif()
set_target_properties(Packer PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${output_folder})
endif()
elseif (build_winstore)

View File

@@ -39,6 +39,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/layers/layer_manager.h"
#include "ui/text/text_utilities.h"
#include "ui/chat/chat_style.h"
#include "ui/platform/ui_platform_utility.h"
#include "ui/platform/ui_platform_window_title.h"
#include "ui/toast/toast.h"
#include "ui/text/format_values.h"
@@ -759,17 +760,21 @@ OverlayWidget::OverlayWidget()
DEBUG_LOG(("Viewer Pos: Moved to %1, %2")
.arg(position.x())
.arg(position.y()));
if (_windowed) {
savePosition();
} else {
// Native maximize moves before state change, don't save that geometry.
if (!_windowed) {
moveToScreen(true);
} else if (!Platform::IsWindows()
|| !Ui::Platform::IsMaximizedNatively(_window)) {
savePosition();
}
} else if (type == QEvent::Resize) {
const auto size = static_cast<QResizeEvent*>(e.get())->size();
DEBUG_LOG(("Viewer Pos: Resized to %1, %2")
.arg(size.width())
.arg(size.height()));
if (_windowed) {
if (_windowed
&& (!Platform::IsWindows()
|| !Ui::Platform::IsMaximizedNatively(_window))) {
savePosition();
}
} else if (type == QEvent::Close
@@ -796,6 +801,21 @@ OverlayWidget::OverlayWidget()
if (_fullscreen || _windowed) {
_fullscreen = _windowed = false;
savePosition();
if constexpr (Platform::IsWindows()) {
// Aero Snap maximizes inside move loop, convert to full screen after.
InvokeQueued(_window, [=] {
if (!_fullscreen
&& !_windowed
&& _window->isMaximized()) {
_helper->clearState();
_fullscreen = true;
_restoreFromSystemNormal = true;
_window->showFullScreen();
savePosition();
_helper->clearState();
}
});
}
}
} else if (_fullscreen || _windowed) {
} else if (state == Qt::WindowFullScreen) {
@@ -1069,6 +1089,19 @@ void OverlayWidget::setupWindow() {
_window->setAttribute(Qt::WA_NoSystemBackground, true);
_window->setAttribute(Qt::WA_TranslucentBackground, true);
// System maximize means full screen here, system restore leaves it.
_window->systemCommandRequests(
) | rpl::on_next([=](not_null<Ui::Platform::SystemCommandRequest*> r) {
using Command = Ui::Platform::SystemCommand;
if (r->command == Command::Maximize && !_fullscreen) {
r->handled = true;
toggleFullScreen(true);
} else if (r->command == Command::Restore && _fullscreen) {
r->handled = true;
toggleFullScreen(false);
}
}, lifetime());
_window->setMinimumSize(
{ st::mediaviewMinWidth, st::mediaviewMinHeight });
@@ -1254,6 +1287,12 @@ void OverlayWidget::updateGeometryToScreen(bool inMove) {
if (!screen) {
return;
}
if constexpr (Platform::IsWindows()) {
// Qt sets screen rect in showFullScreen(), earlier one makes DWM shift content.
if (!_window->isHidden() && !_window->isFullScreen()) {
return;
}
}
const auto available = screen->geometry();
if (_window->geometry() == available) {
return;
@@ -3163,11 +3202,17 @@ void OverlayWidget::toggleFullScreen(bool fullscreen) {
updateGeometry();
_helper->afterShow(_fullscreen);
} else if (_fullscreen) {
_restoreFromSystemNormal = false;
updateGeometry();
_window->showFullScreen();
} else {
_wasWindowedMode = false;
_window->showNormal();
if (base::take(_restoreFromSystemNormal)) {
// Native maximize restored pre-drag rect, keep it over drag-end one.
_normalGeometry = _window->body()->mapToGlobal(
_window->body()->rect());
}
updateGeometry();
_wasWindowedMode = true;
}

View File

@@ -635,6 +635,7 @@ private:
const not_null<QWidget*> _widget;
QRect _normalGeometry;
bool _wasWindowedMode = false;
bool _restoreFromSystemNormal = false;
bool _fullscreenInited = false;
bool _normalGeometryInited = false;
bool _fullscreen = true;

View File

@@ -58,6 +58,7 @@ thirdPartyDir = os.path.realpath(os.path.join(rootDir, 'ThirdParty'))
usedPrefix = os.path.realpath(os.path.join(libsDir, 'local'))
optionsList = [
'qt5',
'qt6',
'skip-release',
'build-stackwalk',
@@ -458,7 +459,7 @@ if customRunCommand:
stage('patches', """
git clone https://github.com/desktop-app/patches.git
cd patches
git checkout f08e9082964e39be74f2ae6d2398011f6226f078
git checkout 8da10389496c066844538a75801166b3f8a2b8fc
mac:
git clone https://github.com/desktop-app/qt6_highsierra_patches.git qt6_highsierra
cd qt6_highsierra
@@ -1529,10 +1530,18 @@ release:
lipo -create Release.arm64/libcrashpad_client.a Release.x86_64/libcrashpad_client.a -output Release/libcrashpad_client.a
""")
if qt < '6':
if win:
stage('tg_angle', """
win:
if win and qt >= '6':
# Windows 7 and 8 support for qtbase, and the ANGLE backend Qt 6 dropped.
stage('qt6_windows7', """
win32_win64:
git clone https://github.com/desktop-app/qt6_windows7_patches.git qt6_windows7
cd qt6_windows7
git checkout 4366991164017d68c0dfc32e01c603da0e5c50e9
""")
if win:
stage('tg_angle', """
win32_win64:
git clone https://github.com/desktop-app/tg_angle.git
cd tg_angle
git checkout 48bc60bdb1
@@ -1544,6 +1553,7 @@ release:
cmake --build out --config Release
""")
if qt < '6':
stage('qt_' + qt, """
git clone -b v$QT-lts-lgpl https://github.com/qt/qt5.git qt_$QT
cd qt_$QT
@@ -1618,6 +1628,8 @@ else: # qt > '6'
cd qt_$QT
git submodule update --init --recursive --progress qtbase qtimageformats qtshadertools qtsvg
depends:patches/qtbase_""" + qt + """/*.patch
win32_win64:
depends:qt6_windows7/*.patch
mac:
if [ -d "../patches/qt6_highsierra" ]; then
find "$PWD/../patches/qt6_highsierra" -maxdepth 1 -name "*.patch" -print0 | sort -z | xargs -0 git -C qtbase apply -v
@@ -1659,8 +1671,17 @@ mac:
win:
cd qtbase
setlocal enabledelayedexpansion
win32_win64:
for %%i in (..\\..\\qt6_windows7\\*.patch) do (
git apply %%i --ignore-whitespace -v
if errorlevel 1 (
echo ERROR: Applying patch %%~nxi failed!
exit /b 1
)
)
win:
for /r %%i in (..\\..\\patches\\qtbase_%QT%\\*) do (
git apply %%i -v
git apply %%i --ignore-whitespace -v
if errorlevel 1 (
echo ERROR: Applying patch %%~nxi failed!
exit /b 1
@@ -1695,9 +1716,25 @@ win:
-system-webp ^
-system-zlib ^
-system-libjpeg ^
win32_win64:
# ANGLE is restored by qt6_windows7 series, tracing pulls Windows 10 ETW.
-trace no ^
-feature-egl ^
win32:
# qioring_win.cpp static_asserts on 64-bit pointers, so no IoRing on x86.
-no-feature-windows-ioring ^
win:
-platform win32-msvc ^
-D ZLIB_WINAPI ^
-- ^
win32_win64:
-D EGL_INCLUDE_DIR:PATH="%LIBS_DIR%\\tg_angle\\include" ^
-D EGL_LIBRARY:FILEPATH="%LIBS_DIR%\\tg_angle\\out\\Release\\tg_angle.lib" ^
-D HAVE_EGL:BOOL=ON ^
-D GLESv2_INCLUDE_DIR:PATH="%LIBS_DIR%\\tg_angle\\include" ^
-D GLESv2_LIBRARY:FILEPATH="%LIBS_DIR%\\tg_angle\\out\\Release\\tg_angle.lib" ^
-D HAVE_GLESv2:BOOL=ON ^
win:
-D OPENSSL_FOUND=1 ^
-D OPENSSL_INCLUDE_DIR="%OPENSSL_DIR%\\include" ^
-D LIB_EAY_DEBUG="%OPENSSL_LIBS_DIR%.dbg\\libcrypto.lib" ^

View File

@@ -4,10 +4,10 @@ def resolve(arch):
if sys.platform == 'darwin':
os.environ['QT'] = '6.11.2'
elif sys.platform == 'win32':
if arch == 'arm' or 'qt6' in sys.argv:
print('Choosing Qt 6.')
os.environ['QT'] = '6.11.2'
else:
if arch != 'arm' and 'qt5' in sys.argv:
print('Choosing Qt 5.')
os.environ['QT'] = '5.15.19'
else:
print('Choosing Qt 6.')
os.environ['QT'] = '6.11.2'
return True

View File

@@ -32,6 +32,11 @@ PRIVATE
desktop-app::external_openssl
)
if (WIN32 AND DESKTOP_APP_WIN7_BASELINE)
# WindowsApp.lib is off the link line, WinRT stubs come from lib_base.
target_link_libraries(test_update_verify PRIVATE desktop-app::lib_base)
endif()
set_target_properties(test_update_verify PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
add_dependencies(Telegram test_update_verify)

View File

@@ -51,6 +51,9 @@ if not qt_version.resolve(arch):
if 'qt6' in arguments:
arguments.remove('qt6')
if 'qt5' in arguments:
arguments.remove('qt5')
if officialTarget != '':
officialApiIdFile = scriptPath + '/../../DesktopPrivate/custom_api_id.h'
if not os.path.isfile(officialApiIdFile):

2
cmake

Submodule cmake updated: 5e21e7ac35...6e19b51106