diff --git a/3rdparty/ext_qt/CMakeLists.txt b/3rdparty/ext_qt/CMakeLists.txt --- a/3rdparty/ext_qt/CMakeLists.txt +++ b/3rdparty/ext_qt/CMakeLists.txt @@ -57,6 +57,10 @@ COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0027-Switch-stylus-pointer-type-when-the-tablet-is-in-the.patch ) endif() + set(ext_qt_PATCH_COMMAND ${ext_qt_PATCH_COMMAND} + COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/set-has-border-in-full-screen-default.patch + COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/remove-fullscreen-border-hack.patch + ) ExternalProject_Add( ext_qt diff --git a/3rdparty/ext_qt/remove-fullscreen-border-hack.patch b/3rdparty/ext_qt/remove-fullscreen-border-hack.patch new file mode 100644 --- /dev/null +++ b/3rdparty/ext_qt/remove-fullscreen-border-hack.patch @@ -0,0 +1,38 @@ +From e9b40ddf98af52f1c1866c766c9add6245e66a92 Mon Sep 17 00:00:00 2001 +From: Alvin Wong +Date: Thu, 18 Apr 2019 18:59:58 +0800 +Subject: [PATCH] Hack to hide 1px border with OpenGL fullscreen hack + +Unfortunately can't hide all four sides because the bug returns. Now we +leave the bottom border visible, which is probably the most we can do. + +Ref: https://bugreports.qt.io/browse/QTBUG-41309 +--- + src/plugins/platforms/windows/qwindowswindow.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp +index 9705eb7293..08c743aaae 100644 +--- a/src/plugins/platforms/windows/qwindowswindow.cpp ++++ b/src/plugins/platforms/windows/qwindowswindow.cpp +@@ -1995,7 +1995,7 @@ bool QWindowsWindow::isFullScreen_sys() const + return false; + QRect geometry = geometry_sys(); + if (testFlag(HasBorderInFullScreen)) +- geometry += QMargins(1, 1, 1, 1); ++ geometry += QMargins(0, 0, 0, 1); + QPlatformScreen *screen = screenForGeometry(geometry); + return screen && geometry == screen->geometry(); + } +@@ -2066,7 +2066,7 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowStates newState) + const UINT swpf = SWP_FRAMECHANGED | SWP_NOACTIVATE; + const bool wasSync = testFlag(SynchronousGeometryChangeEvent); + setFlag(SynchronousGeometryChangeEvent); +- SetWindowPos(m_data.hwnd, HWND_TOP, r.left(), r.top(), r.width(), r.height(), swpf); ++ SetWindowPos(m_data.hwnd, HWND_TOP, r.left() - 1, r.top() - 1, r.width() + 2, r.height() + 1, swpf); + if (!wasSync) + clearFlag(SynchronousGeometryChangeEvent); + clearFlag(MaximizeToFullScreen); +-- +2.18.0.windows.1 + diff --git a/3rdparty/ext_qt/set-has-border-in-full-screen-default.patch b/3rdparty/ext_qt/set-has-border-in-full-screen-default.patch new file mode 100644 --- /dev/null +++ b/3rdparty/ext_qt/set-has-border-in-full-screen-default.patch @@ -0,0 +1,162 @@ +From f377ab8da1acb279e5b23ab1d2ef4afabe5f481c Mon Sep 17 00:00:00 2001 +From: Friedemann Kleint +Date: Wed, 21 Nov 2018 09:06:50 +0100 +Subject: [PATCH] Windows: Add a default setting for hasBorderInFullScreen + +The hasBorderInFullScreen only has an effect when set before +the window is shown or switched to fullscreen. This is currently +not possible in the QML case since the window is only accessible +after all properties (including visibility) have been set. +Add a function to set a default value. + +[ChangeLog][QtPlatformHeaders][QWindowsWindowFunctions] Add a default +setting for hasBorderInFullScreen + +Task-number: QTBUG-47247 +Task-number: QTBUG-71855 +Change-Id: I3952e3f34bc4eb134cf1c5265b4489fc74112688 +Reviewed-by: Andre de la Rocha +Reviewed-by: Andy Shaw +(cherry picked from commit 7264bf19dbc47b805bb7af5df584ce1aae081962) +--- + .../qwindowswindowfunctions.h | 9 +++++ + .../qwindowswindowfunctions.qdoc | 33 +++++++++++++++++++ + .../windows/qwindowsnativeinterface.cpp | 2 ++ + .../platforms/windows/qwindowswindow.cpp | 8 ++++- + .../platforms/windows/qwindowswindow.h | 2 ++ + 5 files changed, 53 insertions(+), 1 deletion(-) + +diff --git a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h +index e51c2fde67..032dcafa6e 100644 +--- a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h ++++ b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h +@@ -81,6 +81,15 @@ public: + func(window, border); + } + ++ typedef void (*SetHasBorderInFullScreenDefault)(bool border); ++ static const QByteArray setHasBorderInFullScreenDefaultIdentifier() { return QByteArrayLiteral("WindowsSetHasBorderInFullScreenDefault"); } ++ static void setHasBorderInFullScreenDefault(bool border) ++ { ++ auto func = reinterpret_cast(QGuiApplication::platformFunction(setHasBorderInFullScreenDefaultIdentifier())); ++ if (func) ++ func(border); ++ } ++ + typedef void (*SetWindowActivationBehaviorType)(WindowActivationBehavior); + static const QByteArray setWindowActivationBehaviorIdentifier() { return QByteArrayLiteral("WindowsSetWindowActivationBehavior"); } + +diff --git a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc +index a52bbe061b..0c52cde753 100644 +--- a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc ++++ b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc +@@ -93,7 +93,40 @@ + is true then it will enable the WS_BORDER flag in full screen mode to enable other top level windows + inside the application to appear on top when required. + ++ \note The setting must be applied before showing the window or switching it ++ to full screen. For QML, setHasBorderInFullScreenDefault() can be used to ++ set a default value. ++ ++ See also \l [QtDoc] {Fullscreen OpenGL Based Windows} ++*/ ++ ++/*! ++ \typedef QWindowsWindowFunctions::SetHasBorderInFullScreenDefault ++ \since 5.13 ++ ++ This is the typedef for the function returned by QGuiApplication::platformFunction ++ when passed setHasBorderInFullScreenDefaultIdentifier. ++*/ ++ ++/*! ++ \fn QByteArray QWindowsWindowFunctions::setHasBorderInFullScreenDefaultIdentifier() ++ \since 5.13 ++ ++ This function returns the bytearray that can be used to query ++ QGuiApplication::platformFunction to retrieve the SetHasBorderInFullScreen function. ++*/ ++ ++/*! ++ \fn void QWindowsWindowFunctions::setHasBorderInFullScreenDefault(bool border) ++ \since 5.13 ++ ++ This is a convenience function that can be used directly instead of resolving ++ the function pointer. \a border will be relayed to the function retrieved by ++ QGuiApplication. When \a border is true, the WS_BORDER flag will be set ++ in full screen mode for all windows by default. ++ + See also \l [QtDoc] {Fullscreen OpenGL Based Windows} ++ \sa setHasBorderInFullScreen() + */ + + /*! +diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp +index 05d6ac9201..eeb1aa58a3 100644 +--- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp ++++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp +@@ -293,6 +293,8 @@ QFunctionPointer QWindowsNativeInterface::platformFunction(const QByteArray &fun + return QFunctionPointer(QWindowsWindow::setTouchWindowTouchTypeStatic); + if (function == QWindowsWindowFunctions::setHasBorderInFullScreenIdentifier()) + return QFunctionPointer(QWindowsWindow::setHasBorderInFullScreenStatic); ++ if (function == QWindowsWindowFunctions::setHasBorderInFullScreenDefaultIdentifier()) ++ return QFunctionPointer(QWindowsWindow::setHasBorderInFullScreenDefault); + if (function == QWindowsWindowFunctions::setWindowActivationBehaviorIdentifier()) + return QFunctionPointer(QWindowsNativeInterface::setWindowActivationBehavior); + if (function == QWindowsWindowFunctions::isTabletModeIdentifier()) +diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp +index 910d8dd209..9705eb7293 100644 +--- a/src/plugins/platforms/windows/qwindowswindow.cpp ++++ b/src/plugins/platforms/windows/qwindowswindow.cpp +@@ -1180,6 +1180,7 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w, + + const char *QWindowsWindow::embeddedNativeParentHandleProperty = "_q_embedded_native_parent_handle"; + const char *QWindowsWindow::hasBorderInFullScreenProperty = "_q_has_border_in_fullscreen"; ++bool QWindowsWindow::m_borderInFullScreenDefault = false; + + QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data) : + QWindowsBaseWindow(aWindow), +@@ -1217,7 +1218,7 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data) + + if (aWindow->isTopLevel()) + setWindowIcon(aWindow->icon()); +- if (aWindow->property(hasBorderInFullScreenProperty).toBool()) ++ if (m_borderInFullScreenDefault || aWindow->property(hasBorderInFullScreenProperty).toBool()) + setFlag(HasBorderInFullScreen); + clearFlag(WithinCreate); + } +@@ -2820,6 +2821,11 @@ void QWindowsWindow::setHasBorderInFullScreenStatic(QWindow *window, bool border + window->setProperty(hasBorderInFullScreenProperty, QVariant(border)); + } + ++void QWindowsWindow::setHasBorderInFullScreenDefault(bool border) ++{ ++ m_borderInFullScreenDefault = border; ++} ++ + void QWindowsWindow::setHasBorderInFullScreen(bool border) + { + if (testFlag(HasBorderInFullScreen) == border) +diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h +index b9b398b67b..b07bd15d2a 100644 +--- a/src/plugins/platforms/windows/qwindowswindow.h ++++ b/src/plugins/platforms/windows/qwindowswindow.h +@@ -341,6 +341,7 @@ public: + static void setTouchWindowTouchTypeStatic(QWindow *window, QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes); + void registerTouchWindow(QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes = QWindowsWindowFunctions::NormalTouch); + static void setHasBorderInFullScreenStatic(QWindow *window, bool border); ++ static void setHasBorderInFullScreenDefault(bool border); + void setHasBorderInFullScreen(bool border); + static QString formatWindowTitle(const QString &title); + +@@ -386,6 +387,7 @@ private: + // note: intentionally not using void * in order to avoid breaking x86 + VkSurfaceKHR m_vkSurface = 0; + #endif ++ static bool m_borderInFullScreenDefault; + }; + + #ifndef QT_NO_DEBUG_STREAM +-- +2.18.0.windows.1 + diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -339,6 +339,18 @@ ) configure_file(config-hdr.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-hdr.h) +if (WIN32) + CHECK_CXX_SOURCE_COMPILES(" +#include +int main(int argc, char *argv[]) { +QWindowsWindowFunctions::setHasBorderInFullScreenDefault(true); +} +" + HAVE_SET_HAS_BORDER_IN_FULL_SCREEN_DEFAULT + ) + configure_file(config-set-has-border-in-full-screen-default.h.in ${CMAKE_CURRENT_BINARY_DIR}/config-set-has-border-in-full-screen-default.h) +endif (WIN32) + unset(CMAKE_REQUIRED_INCLUDES) unset(CMAKE_REQUIRED_LIBRARIES) diff --git a/config-set-has-border-in-full-screen-default.h.in b/config-set-has-border-in-full-screen-default.h.in new file mode 100644 --- /dev/null +++ b/config-set-has-border-in-full-screen-default.h.in @@ -0,0 +1,4 @@ +/* config-hdr.h. Generated by cmake from config-set-has-border-in-full-screen-default.h.in */ + +/* Define if QWindowsWindowFunctions::setHasBorderInFullScreenDefault is available */ +#cmakedefine HAVE_SET_HAS_BORDER_IN_FULL_SCREEN_DEFAULT 1 diff --git a/krita/main.cc b/krita/main.cc --- a/krita/main.cc +++ b/krita/main.cc @@ -67,6 +67,10 @@ #else #include #endif +#include "config-set-has-border-in-full-screen-default.h" +#ifdef HAVE_SET_HAS_BORDER_IN_FULL_SCREEN_DEFAULT +#include +#endif #include #endif @@ -324,6 +328,12 @@ // first create the application so we can create a pixmap KisApplication app(key, argc, argv); +#ifdef HAVE_SET_HAS_BORDER_IN_FULL_SCREEN_DEFAULT + if (QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL)) { + QWindowsWindowFunctions::setHasBorderInFullScreenDefault(true); + } +#endif + KisUsageLogger::writeHeader(); if (!language.isEmpty()) { diff --git a/libs/ui/KisMainWindow.cpp b/libs/ui/KisMainWindow.cpp --- a/libs/ui/KisMainWindow.cpp +++ b/libs/ui/KisMainWindow.cpp @@ -148,10 +148,6 @@ #include #include -#ifdef Q_OS_WIN - #include -#endif - class ToolDockerFactory : public KoDockFactoryBase { public: @@ -508,11 +504,6 @@ d->viewManager->updateGUI(); d->viewManager->updateIcons(); -#ifdef Q_OS_WIN - auto w = qApp->activeWindow(); - if (w) QWindowsWindowFunctions::setHasBorderInFullScreen(w->windowHandle(), true); -#endif - QTimer::singleShot(1000, this, SLOT(checkSanity())); {