Disable Win11 rounded window corners when the status bar is hidden

This commit is contained in:
Alexander Babikov
2025-03-01 15:54:50 +05:00
parent 1973289de3
commit c1c4bcc889

View File

@@ -122,6 +122,19 @@ extern int qt_nvr_save(void);
#include "x11_util.h"
#endif
#ifdef Q_OS_WINDOWS
#include <dwmapi.h>
#ifndef DWMWA_WINDOW_CORNER_PREFERENCE
#define DWMWA_WINDOW_CORNER_PREFERENCE 33
#endif
#ifndef DWMWCP_DEFAULT
#define DWMWCP_DEFAULT 0
#endif
#ifndef DWMWCP_DONOTROUND
#define DWMWCP_DONOTROUND 1
#endif
#endif
#ifdef Q_OS_MACOS
# include "cocoa_keyboard.hpp"
// The namespace is required to avoid clashing typedefs; we only use this
@@ -181,6 +194,10 @@ MainWindow::MainWindow(QWidget *parent)
status->setSoundGainAction(ui->actionSound_gain);
ui->stackedWidget->setMouseTracking(true);
statusBar()->setVisible(!hide_status_bar);
#ifdef Q_OS_WINDOWS
auto cornerPreference = (hide_status_bar ? DWMWCP_DONOTROUND : DWMWCP_DEFAULT);
DwmSetWindowAttribute((HWND) this->winId(), DWMWA_WINDOW_CORNER_PREFERENCE, (LPCVOID) &cornerPreference, sizeof(cornerPreference));
#endif
statusBar()->setStyleSheet("QStatusBar::item {border: None; } QStatusBar QLabel { margin-right: 2px; margin-bottom: 1px; }");
this->centralWidget()->setStyleSheet("background-color: black;");
ui->toolBar->setVisible(!hide_tool_bar);
@@ -1833,6 +1850,10 @@ MainWindow::on_actionHide_status_bar_triggered()
hide_status_bar ^= 1;
ui->actionHide_status_bar->setChecked(hide_status_bar);
statusBar()->setVisible(!hide_status_bar);
#ifdef Q_OS_WINDOWS
auto cornerPreference = (hide_status_bar ? DWMWCP_DONOTROUND : DWMWCP_DEFAULT);
DwmSetWindowAttribute((HWND) main_window->winId(), DWMWA_WINDOW_CORNER_PREFERENCE, (LPCVOID) &cornerPreference, sizeof(cornerPreference));
#endif
if (vid_resize >= 2) {
setFixedSize(fixed_size_x, fixed_size_y + menuBar()->height() + (hide_status_bar ? 0 : statusBar()->height()) + (hide_tool_bar ? 0 : ui->toolBar->height()));
} else {