diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3d99c06..034a350 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,6 +5,14 @@ project(FramelessHelper LANGUAGES CXX)
option(FRAMELESSHELPER_BUILD_STATIC "Build FramelessHelper as a static library." OFF)
option(FRAMELESSHELPER_BUILD_EXAMPLES "Build FramelessHelper demo applications." ON)
+if(NOT DEFINED CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Release)
+endif()
+
+if(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug") AND NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
+ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
+endif()
+
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
diff --git a/examples/images/dark/chrome-close.svg b/examples/images/dark/chrome-close.svg
index 0b61504..c83f76e 100644
--- a/examples/images/dark/chrome-close.svg
+++ b/examples/images/dark/chrome-close.svg
@@ -1,3 +1,3 @@
diff --git a/examples/images/dark/chrome-maximize.svg b/examples/images/dark/chrome-maximize.svg
index 40db442..0bbb16e 100644
--- a/examples/images/dark/chrome-maximize.svg
+++ b/examples/images/dark/chrome-maximize.svg
@@ -1,3 +1,3 @@
diff --git a/examples/images/dark/chrome-minimize.svg b/examples/images/dark/chrome-minimize.svg
index da89f42..a7b65d7 100644
--- a/examples/images/dark/chrome-minimize.svg
+++ b/examples/images/dark/chrome-minimize.svg
@@ -1,3 +1,3 @@
diff --git a/examples/images/dark/chrome-restore.svg b/examples/images/dark/chrome-restore.svg
index c0715cd..99ef5ba 100644
--- a/examples/images/dark/chrome-restore.svg
+++ b/examples/images/dark/chrome-restore.svg
@@ -1,4 +1,4 @@
diff --git a/examples/images/light/chrome-close.svg b/examples/images/light/chrome-close.svg
index 5a1ff32..131368e 100644
--- a/examples/images/light/chrome-close.svg
+++ b/examples/images/light/chrome-close.svg
@@ -1,3 +1,3 @@
diff --git a/examples/images/light/chrome-maximize.svg b/examples/images/light/chrome-maximize.svg
index a72b77b..344ee29 100644
--- a/examples/images/light/chrome-maximize.svg
+++ b/examples/images/light/chrome-maximize.svg
@@ -1,3 +1,3 @@
diff --git a/examples/images/light/chrome-minimize.svg b/examples/images/light/chrome-minimize.svg
index 75b9915..613acfa 100644
--- a/examples/images/light/chrome-minimize.svg
+++ b/examples/images/light/chrome-minimize.svg
@@ -1,3 +1,3 @@
diff --git a/examples/images/light/chrome-restore.svg b/examples/images/light/chrome-restore.svg
index 25a00d1..2f6fe3c 100644
--- a/examples/images/light/chrome-restore.svg
+++ b/examples/images/light/chrome-restore.svg
@@ -1,4 +1,4 @@
diff --git a/examples/mainwindow/mainwindow.cpp b/examples/mainwindow/mainwindow.cpp
index bdb3afc..3727086 100644
--- a/examples/mainwindow/mainwindow.cpp
+++ b/examples/mainwindow/mainwindow.cpp
@@ -92,8 +92,7 @@ void MainWindow::resetContentsMargins()
{
#ifdef Q_OS_WINDOWS
if (Utilities::isWin10OrGreater()) {
- const int frameBorderThickness = 1;
- setContentsMargins(0, frameBorderThickness, 0, 0);
+ setContentsMargins(0, 1, 0, 0);
}
#endif
}
@@ -107,10 +106,9 @@ void MainWindow::paintEvent(QPaintEvent *event)
painter.save();
QPen pen = {};
pen.setColor(Utilities::getFrameBorderColor(isActiveWindow()));
- const int frameBorderThickness = 1;
- pen.setWidth(frameBorderThickness);
+ pen.setWidth(1);
painter.setPen(pen);
- painter.drawLine(0, frameBorderThickness, width(), frameBorderThickness);
+ painter.drawLine(0, 0, width(), 0);
painter.restore();
}
#endif
diff --git a/examples/quick/main.cpp b/examples/quick/main.cpp
index aaf42e0..a58c9eb 100644
--- a/examples/quick/main.cpp
+++ b/examples/quick/main.cpp
@@ -24,6 +24,7 @@
#include
#include
+#include
#include
#include
@@ -43,6 +44,14 @@ int main(int argc, char *argv[])
QGuiApplication application(argc, argv);
+#ifdef Q_OS_WINDOWS
+# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
+ QQuickWindow::setGraphicsApi(QSGRendererInterface::Direct3D11);
+# elif (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Direct3D11Rhi);
+# endif
+#endif
+
QScopedPointer framelessHelper(new FramelessQuickHelper);
QScopedPointer framelessUtils(new FramelessQuickUtils);
diff --git a/examples/quick/qml/CloseButton.qml b/examples/quick/qml/CloseButton.qml
index 509591d..5353409 100644
--- a/examples/quick/qml/CloseButton.qml
+++ b/examples/quick/qml/CloseButton.qml
@@ -44,7 +44,8 @@ Button {
Image {
anchors.centerIn: parent
- source: FramelessUtils.darkModeEnabled ? "qrc:/images/light/chrome-close.svg" : "qrc:/images/dark/chrome-close.svg"
+ source: FramelessUtils.darkModeEnabled || FramelessUtils.titleBarColorVisible
+ ? "qrc:/images/light/chrome-close.svg" : "qrc:/images/dark/chrome-close.svg"
}
}
diff --git a/examples/quick/qml/MainWindow.qml b/examples/quick/qml/MainWindow.qml
index 7b3d8f0..fcb97db 100644
--- a/examples/quick/qml/MainWindow.qml
+++ b/examples/quick/qml/MainWindow.qml
@@ -46,9 +46,9 @@ Window {
Rectangle {
id: titleBar
height: 30
- color: window.active ? (FramelessUtils.titleBarColorVisible ? FramelessUtils.systemAccentColor :
- (FramelessUtils.darkModeEnabled ? "white" : "black")) :
- (FramelessUtils.darkModeEnabled ? "#202020" : "white")
+ color: window.active ? (FramelessUtils.titleBarColorVisible ? FramelessUtils.systemAccentColor
+ : (FramelessUtils.darkModeEnabled ? "black" : "white"))
+ : (FramelessUtils.darkModeEnabled ? "#202020" : "white")
anchors {
top: parent.top
topMargin: windowTopBorder.height
@@ -59,10 +59,11 @@ Window {
Text {
id: titleBarText
text: window.title
- font.pointSize: 13
- color: window.active ? (FramelessUtils.darkModeEnabled ? "white" : "black") : "darkGray"
+ font.pointSize: 11
+ color: window.active ? ((FramelessUtils.darkModeEnabled
+ || FramelessUtils.titleBarColorVisible) ? "white" : "black") : "darkGray"
anchors.left: parent.left
- anchors.leftMargin: 15
+ anchors.leftMargin: 10
anchors.verticalCenter: parent.verticalCenter
}
diff --git a/examples/quick/qml/MaximizeButton.qml b/examples/quick/qml/MaximizeButton.qml
index ba4dada..c259df0 100644
--- a/examples/quick/qml/MaximizeButton.qml
+++ b/examples/quick/qml/MaximizeButton.qml
@@ -47,8 +47,10 @@ Button {
Image {
anchors.centerIn: parent
source: button.maximized ?
- (FramelessUtils.darkModeEnabled ? "qrc:/images/light/chrome-restore.svg" : "qrc:/images/dark/chrome-restore.svg") :
- (FramelessUtils.darkModeEnabled ? "qrc:/images/light/chrome-maximize.svg" : "qrc:/images/dark/chrome-maximize.svg")
+ (FramelessUtils.darkModeEnabled || FramelessUtils.titleBarColorVisible
+ ? "qrc:/images/light/chrome-restore.svg" : "qrc:/images/dark/chrome-restore.svg") :
+ (FramelessUtils.darkModeEnabled || FramelessUtils.titleBarColorVisible
+ ? "qrc:/images/light/chrome-maximize.svg" : "qrc:/images/dark/chrome-maximize.svg")
}
}
diff --git a/examples/quick/qml/MinimizeButton.qml b/examples/quick/qml/MinimizeButton.qml
index 821a3e2..6801030 100644
--- a/examples/quick/qml/MinimizeButton.qml
+++ b/examples/quick/qml/MinimizeButton.qml
@@ -44,7 +44,8 @@ Button {
Image {
anchors.centerIn: parent
- source: FramelessUtils.darkModeEnabled ? "qrc:/images/light/chrome-minimize.svg" : "qrc:/images/dark/chrome-minimize.svg"
+ source: FramelessUtils.darkModeEnabled || FramelessUtils.titleBarColorVisible
+ ? "qrc:/images/light/chrome-minimize.svg" : "qrc:/images/dark/chrome-minimize.svg"
}
}
diff --git a/examples/widget/widget.cpp b/examples/widget/widget.cpp
index b537332..ff5462b 100644
--- a/examples/widget/widget.cpp
+++ b/examples/widget/widget.cpp
@@ -75,6 +75,12 @@ static const QString mainStyleSheet = QStringLiteral(R"(#MainWidget {
}
)");
+[[nodiscard]] static inline bool isTitleBarColorized()
+{
+ const DwmColorizationArea area = Utilities::getDwmColorizationArea();
+ return ((area == DwmColorizationArea::TitleBar_WindowBorder) || (area == DwmColorizationArea::All));
+}
+
Widget::Widget(QWidget *parent) : QWidget(parent)
{
setAttribute(Qt::WA_DontCreateNativeAncestors);
@@ -132,10 +138,9 @@ void Widget::paintEvent(QPaintEvent *event)
painter.save();
QPen pen = {};
pen.setColor(Utilities::getFrameBorderColor(isActiveWindow()));
- const int frameBorderThickness = 1;
- pen.setWidth(frameBorderThickness);
+ pen.setWidth(1);
painter.setPen(pen);
- painter.drawLine(0, frameBorderThickness, width(), frameBorderThickness);
+ painter.drawLine(0, 0, width(), 0);
painter.restore();
}
#endif
@@ -285,14 +290,11 @@ void Widget::updateStyleSheet()
{
const bool active = isActiveWindow();
const bool dark = Utilities::shouldAppsUseDarkMode();
- const DwmColorizationArea area = Utilities::getDwmColorizationArea();
- const bool colorizedTitleBar = ((area == DwmColorizationArea::TitleBar_WindowBorder) || (area == DwmColorizationArea::All));
- const QColor colorizationColor = Utilities::getDwmColorizationColor();
- const QColor mainWidgetBackgroundColor = (dark ? systemDarkColor : systemLightColor);
- const QColor titleBarWidgetBackgroundColor = [active, colorizedTitleBar, &colorizationColor, dark]() -> QColor {
+ const bool colorizedTitleBar = isTitleBarColorized();
+ const QColor titleBarWidgetBackgroundColor = [active, colorizedTitleBar, dark]() -> QColor {
if (active) {
if (colorizedTitleBar) {
- return colorizationColor;
+ return Utilities::getDwmColorizationColor();
} else {
if (dark) {
return QColor(Qt::black);
@@ -308,8 +310,9 @@ void Widget::updateStyleSheet()
}
}
}();
- const QColor windowTitleLabelTextColor = (active ? (dark ? Qt::white : Qt::black) : Qt::darkGray);
+ const QColor windowTitleLabelTextColor = (active ? ((dark || colorizedTitleBar) ? Qt::white : Qt::black) : Qt::darkGray);
const QColor clockLabelTextColor = (dark ? Qt::white : Qt::black);
+ const QColor mainWidgetBackgroundColor = (dark ? systemDarkColor : systemLightColor);
setStyleSheet(mainStyleSheet.arg(mainWidgetBackgroundColor.name(), titleBarWidgetBackgroundColor.name(),
windowTitleLabelTextColor.name(), clockLabelTextColor.name()));
update();
@@ -317,7 +320,7 @@ void Widget::updateStyleSheet()
void Widget::updateSystemButtonIcons()
{
- const QString prefix = (Utilities::shouldAppsUseDarkMode() ? QStringLiteral("light") : QStringLiteral("dark"));
+ const QString prefix = ((Utilities::shouldAppsUseDarkMode() || isTitleBarColorized()) ? QStringLiteral("light") : QStringLiteral("dark"));
m_minimizeButton->setIcon(QIcon(QStringLiteral(":/images/%1/chrome-minimize.svg").arg(prefix)));
if (isMaximized() || isFullScreen()) {
m_maximizeButton->setIcon(QIcon(QStringLiteral(":/images/%1/chrome-restore.svg").arg(prefix)));
@@ -331,8 +334,7 @@ void Widget::resetContentsMargins()
{
#ifdef Q_OS_WINDOWS
if (Utilities::isWin10OrGreater()) {
- const int frameBorderThickness = 1;
- setContentsMargins(0, frameBorderThickness, 0, 0);
+ setContentsMargins(0, 1, 0, 0);
}
#endif
}
diff --git a/framelesshelper_win32.cpp b/framelesshelper_win32.cpp
index 4892693..1eec47a 100644
--- a/framelesshelper_win32.cpp
+++ b/framelesshelper_win32.cpp
@@ -24,6 +24,7 @@
#include "framelesshelper_win32.h"
#include
+#include
#include
#include
#include
@@ -39,6 +40,8 @@ struct FramelessHelperWinData
{
QMutex mutex = {};
QScopedPointer instance;
+ QList acceptableWinIds = {};
+ QHash qtWindowProcs = {};
explicit FramelessHelperWinData() = default;
~FramelessHelperWinData() = default;
@@ -49,6 +52,127 @@ private:
Q_GLOBAL_STATIC(FramelessHelperWinData, g_helper)
+[[nodiscard]] static inline LRESULT CALLBACK HookWindowProc
+ (const HWND hWnd, const UINT uMsg, const WPARAM wParam, const LPARAM lParam)
+{
+ g_helper()->mutex.lock();
+ if (!g_helper()->qtWindowProcs.contains(hWnd)) {
+ g_helper()->mutex.unlock();
+ return DefWindowProcW(hWnd, uMsg, wParam, lParam);
+ }
+ g_helper()->mutex.unlock();
+ const auto winId = reinterpret_cast(hWnd);
+ const auto getGlobalPosFromMouse = [lParam]() -> QPointF {
+ return {qreal(GET_X_LPARAM(lParam)), qreal(GET_Y_LPARAM(lParam))};
+ };
+ const auto getGlobalPosFromKeyboard = [hWnd, winId]() -> QPointF {
+ RECT rect = {};
+ if (GetWindowRect(hWnd, &rect) == FALSE) {
+ qWarning() << Utilities::getSystemErrorMessage(QStringLiteral("GetWindowRect"));
+ return {};
+ }
+ const bool maxOrFull = (IsMaximized(hWnd) || Utilities::isFullScreen(winId));
+ const int frameSizeX = Utilities::getResizeBorderThickness(winId, true, true);
+ const int frameSizeY = Utilities::getResizeBorderThickness(winId, false, true);
+ const int titleBarHeight = Utilities::getTitleBarHeight(winId, true);
+ const int horizontalOffset = (maxOrFull ? 0 : frameSizeX);
+ const int verticalOffset = (maxOrFull ? titleBarHeight : (titleBarHeight - frameSizeY));
+ return {qreal(rect.left + horizontalOffset), qreal(rect.top + verticalOffset)};
+ };
+ bool shouldShowSystemMenu = false;
+ QPointF globalPos = {};
+ if (uMsg == WM_NCRBUTTONUP) {
+ if (wParam == HTCAPTION) {
+ shouldShowSystemMenu = true;
+ globalPos = getGlobalPosFromMouse();
+ }
+ } else if (uMsg == WM_SYSCOMMAND) {
+ const WPARAM filteredWParam = (wParam & 0xFFF0);
+ if ((filteredWParam == SC_KEYMENU) && (lParam == VK_SPACE)) {
+ shouldShowSystemMenu = true;
+ globalPos = getGlobalPosFromKeyboard();
+ }
+ } else if ((uMsg == WM_KEYDOWN) || (uMsg == WM_SYSKEYDOWN)) {
+ const bool altPressed = ((wParam == VK_MENU) || (GetKeyState(VK_MENU) < 0));
+ const bool spacePressed = ((wParam == VK_SPACE) || (GetKeyState(VK_SPACE) < 0));
+ if (altPressed && spacePressed) {
+ shouldShowSystemMenu = true;
+ globalPos = getGlobalPosFromKeyboard();
+ }
+ }
+ if (shouldShowSystemMenu) {
+ Utilities::showSystemMenu(winId, globalPos);
+ // QPA's internal code will handle system menu events separately, and its
+ // behavior is not what we would want to see because it doesn't know our
+ // window doesn't have any window frame now, so return early here to avoid
+ // entering Qt's own handling logic.
+ return 0; // Return 0 means we have handled this event.
+ }
+ g_helper()->mutex.lock();
+ const WNDPROC originalWindowProc = g_helper()->qtWindowProcs.value(hWnd);
+ g_helper()->mutex.unlock();
+ Q_ASSERT(originalWindowProc);
+ if (originalWindowProc) {
+ // Hand over to Qt's original window proc function for events we are not
+ // interested in.
+ return CallWindowProcW(originalWindowProc, hWnd, uMsg, wParam, lParam);
+ } else {
+ return DefWindowProcW(hWnd, uMsg, wParam, lParam);
+ }
+}
+
+[[nodiscard]] static inline bool installWindowHook(const WId winId)
+{
+ Q_ASSERT(winId);
+ if (!winId) {
+ return false;
+ }
+ const auto hwnd = reinterpret_cast(winId);
+ QMutexLocker locker(&g_helper()->mutex);
+ if (g_helper()->qtWindowProcs.contains(hwnd)) {
+ return false;
+ }
+ SetLastError(ERROR_SUCCESS);
+ const auto originalWindowProc = reinterpret_cast(GetWindowLongPtrW(hwnd, GWLP_WNDPROC));
+ Q_ASSERT(originalWindowProc);
+ if (!originalWindowProc) {
+ qWarning() << Utilities::getSystemErrorMessage(QStringLiteral("GetWindowLongPtrW"));
+ return false;
+ }
+ SetLastError(ERROR_SUCCESS);
+ if (SetWindowLongPtrW(hwnd, GWLP_WNDPROC, reinterpret_cast(HookWindowProc)) == 0) {
+ qWarning() << Utilities::getSystemErrorMessage(QStringLiteral("SetWindowLongPtrW"));
+ return false;
+ }
+ g_helper()->qtWindowProcs.insert(hwnd, originalWindowProc);
+ return true;
+}
+
+[[nodiscard]] static inline bool uninstallWindowHook(const WId winId)
+{
+ Q_ASSERT(winId);
+ if (!winId) {
+ return false;
+ }
+ const auto hwnd = reinterpret_cast(winId);
+ QMutexLocker locker(&g_helper()->mutex);
+ if (!g_helper()->qtWindowProcs.contains(hwnd)) {
+ return false;
+ }
+ const WNDPROC originalWindowProc = g_helper()->qtWindowProcs.value(hwnd);
+ Q_ASSERT(originalWindowProc);
+ if (!originalWindowProc) {
+ return false;
+ }
+ SetLastError(ERROR_SUCCESS);
+ if (SetWindowLongPtrW(hwnd, GWLP_WNDPROC, reinterpret_cast(originalWindowProc)) == 0) {
+ qWarning() << Utilities::getSystemErrorMessage(QStringLiteral("SetWindowLongPtrW"));
+ return false;
+ }
+ g_helper()->qtWindowProcs.remove(hwnd);
+ return true;
+}
+
FramelessHelperWin::FramelessHelperWin() : QAbstractNativeEventFilter() {}
FramelessHelperWin::~FramelessHelperWin()
@@ -62,17 +186,26 @@ void FramelessHelperWin::addWindow(QWindow *window)
if (!window) {
return;
}
- QMutexLocker locker(&g_helper()->mutex);
+ const WId winId = window->winId();
+ g_helper()->mutex.lock();
+ if (g_helper()->acceptableWinIds.contains(winId)) {
+ g_helper()->mutex.unlock();
+ return;
+ }
+ g_helper()->acceptableWinIds.append(winId);
if (g_helper()->instance.isNull()) {
g_helper()->instance.reset(new FramelessHelperWin);
qApp->installNativeEventFilter(g_helper()->instance.data());
}
- const WId winId = window->winId();
+ g_helper()->mutex.unlock();
Utilities::fixupQtInternals(winId);
Utilities::updateInternalWindowFrameMargins(window, true);
Utilities::updateWindowFrameMargins(winId, false);
const bool dark = Utilities::shouldAppsUseDarkMode();
Utilities::updateWindowFrameBorderColor(winId, dark);
+ if (!installWindowHook(winId)) {
+ qWarning() << "Failed to hook the window proc function.";
+ }
}
void FramelessHelperWin::removeWindow(QWindow *window)
@@ -81,8 +214,18 @@ void FramelessHelperWin::removeWindow(QWindow *window)
if (!window) {
return;
}
+ const WId winId = window->winId();
+ g_helper()->mutex.lock();
+ if (!g_helper()->acceptableWinIds.contains(winId)) {
+ g_helper()->mutex.unlock();
+ return;
+ }
+ g_helper()->mutex.unlock();
+ if (!uninstallWindowHook(winId)) {
+ qWarning() << "Failed to un-hook the window proc function.";
+ }
Utilities::updateInternalWindowFrameMargins(window, false);
- Utilities::updateWindowFrameMargins(window->winId(), true);
+ Utilities::updateWindowFrameMargins(winId, true);
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
@@ -106,8 +249,15 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
return false;
}
const WId winId = reinterpret_cast(msg->hwnd);
+ g_helper()->mutex.lock();
+ if (!g_helper()->acceptableWinIds.contains(winId)) {
+ g_helper()->mutex.unlock();
+ return false;
+ }
+ g_helper()->mutex.unlock();
const FramelessManagerPrivate * const manager = FramelessManagerPrivate::instance();
const QUuid id = manager->findIdByWinId(winId);
+ Q_ASSERT(!id.isNull());
if (id.isNull()) {
return false;
}
diff --git a/utilities_win32.cpp b/utilities_win32.cpp
index 827a9f4..7865221 100644
--- a/utilities_win32.cpp
+++ b/utilities_win32.cpp
@@ -24,6 +24,7 @@
#include "utilities.h"
#include
+#include
#include
#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
# include
@@ -32,7 +33,6 @@
#endif
#include
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
-# include
# include
#else
# include
@@ -396,39 +396,41 @@ void Utilities::showSystemMenu(const WId winId, const QPointF &pos)
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STATE;
mii.fType = MFT_STRING;
- const auto setState = [&mii, menu](const UINT item, const bool enabled) -> bool {
- mii.fState = (enabled ? MF_ENABLED : MF_DISABLED);
+ const auto setState = [&mii, menu](const UINT item, const bool enabled, const bool highlight) -> bool {
+ mii.fState = ((enabled ? MFS_ENABLED : MFS_DISABLED) | (highlight ? MFS_HILITE : 0));
if (SetMenuItemInfoW(menu, item, FALSE, &mii) == FALSE) {
+ Q_ASSERT(false);
qWarning() << getSystemErrorMessage(QStringLiteral("SetMenuItemInfoW"));
return false;
}
return true;
};
- const bool max = IsMaximized(hWnd);
- if (!setState(SC_RESTORE, max)) {
+ const bool maxOrFull = (IsMaximized(hWnd) || isFullScreen(reinterpret_cast(hWnd)));
+ if (!setState(SC_RESTORE, maxOrFull, true)) {
return;
}
- if (!setState(SC_MOVE, !max)) {
+ if (!setState(SC_MOVE, !maxOrFull, false)) {
return;
}
- if (!setState(SC_SIZE, !max)) {
+ if (!setState(SC_SIZE, !maxOrFull, false)) {
return;
}
- if (!setState(SC_MINIMIZE, true)) {
+ if (!setState(SC_MINIMIZE, true, false)) {
return;
}
- if (!setState(SC_MAXIMIZE, !max)) {
+ if (!setState(SC_MAXIMIZE, !maxOrFull, false)) {
return;
}
- if (!setState(SC_CLOSE, true)) {
+ if (!setState(SC_CLOSE, true, false)) {
return;
}
- if (SetMenuDefaultItem(menu, UINT_MAX, FALSE) == FALSE) {
+ if (SetMenuDefaultItem(menu, SC_CLOSE, FALSE) == FALSE) {
qWarning() << getSystemErrorMessage(QStringLiteral("SetMenuDefaultItem"));
return;
}
const QPoint roundedPos = pos.toPoint();
- const auto ret = TrackPopupMenu(menu, TPM_RETURNCMD, roundedPos.x(), roundedPos.y(), 0, hWnd, nullptr);
+ const auto ret = TrackPopupMenu(menu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft()
+ ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), roundedPos.x(), roundedPos.y(), 0, hWnd, nullptr);
if (ret != 0) {
if (PostMessageW(hWnd, WM_SYSCOMMAND, ret, 0) == FALSE) {
qWarning() << getSystemErrorMessage(QStringLiteral("PostMessageW"));
@@ -730,7 +732,7 @@ QColor Utilities::getFrameBorderColor(const bool active)
return (dark ? QColor(QStringLiteral("#4d4d4d")) : QColor(Qt::white));
}
} else {
- return (dark ? QColor(QStringLiteral("#575959")) : QColor(QStringLiteral("#999999")));
+ return (dark ? QColor(QStringLiteral("#575959")) : QColor(QStringLiteral("#b3b3b3")));
}
}