Use native rounded corners and title colors.
This commit is contained in:
parent
40fc5b35f0
commit
a827d9436e
7 changed files with 73 additions and 25 deletions
|
|
@ -89,7 +89,7 @@ tooltipBg: #eef2f5; // tooltip background (like when you put mouse over the mess
|
||||||
tooltipFg: #5d6c80; // tooltip text
|
tooltipFg: #5d6c80; // tooltip text
|
||||||
tooltipBorderFg: #c9d1db; // tooltip border
|
tooltipBorderFg: #c9d1db; // tooltip border
|
||||||
|
|
||||||
// custom title bar for Windows and macOS
|
// custom title bar
|
||||||
titleShadow: #00000003; // one pixel line shadow at the bottom of custom window title
|
titleShadow: #00000003; // one pixel line shadow at the bottom of custom window title
|
||||||
titleBg: windowBgOver; // custom window title background when window is inactive
|
titleBg: windowBgOver; // custom window title background when window is inactive
|
||||||
titleBgActive: titleBg; // custom window title background when window is active
|
titleBgActive: titleBg; // custom window title background when window is active
|
||||||
|
|
@ -109,8 +109,8 @@ titleButtonCloseBgActive: titleButtonCloseBg; // custom window title close butto
|
||||||
titleButtonCloseFgActive: titleButtonCloseFg; // custom window title close button icon when window is active (Windows only)
|
titleButtonCloseFgActive: titleButtonCloseFg; // custom window title close button icon when window is active (Windows only)
|
||||||
titleButtonCloseBgActiveOver: titleButtonCloseBgOver; // custom window title close button background with mouse over when window is active (Windows only)
|
titleButtonCloseBgActiveOver: titleButtonCloseBgOver; // custom window title close button background with mouse over when window is active (Windows only)
|
||||||
titleButtonCloseFgActiveOver: titleButtonCloseFgOver; // custom window title close button icon with mouse over when window is active (Windows only)
|
titleButtonCloseFgActiveOver: titleButtonCloseFgOver; // custom window title close button icon with mouse over when window is active (Windows only)
|
||||||
titleFg: #acacac; // custom window title text when window is inactive (macOS only)
|
titleFg: #acacac; // custom window title text when window is inactive (Windows 11 and macOS)
|
||||||
titleFgActive: #3e3c3e; // custom window title text when window is active (macOS only)
|
titleFgActive: #3e3c3e; // custom window title text when window is active (Windows 11 and macOS)
|
||||||
|
|
||||||
// tray icon
|
// tray icon
|
||||||
trayCounterBg: #f23c34; // tray icon counter background
|
trayCounterBg: #f23c34; // tray icon counter background
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "ui/rp_widget.h"
|
#include "ui/rp_widget.h"
|
||||||
#include "ui/platform/win/ui_window_win.h"
|
#include "ui/platform/win/ui_window_win.h"
|
||||||
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "styles/style_widgets.h"
|
#include "styles/style_widgets.h"
|
||||||
|
|
||||||
#include <QtGui/QPainter>
|
#include <QtGui/QPainter>
|
||||||
|
|
@ -42,7 +43,8 @@ base::flat_map<HWND, not_null<WindowShadow*>> ShadowByHandle;
|
||||||
|
|
||||||
WindowShadow::WindowShadow(not_null<RpWidget*> window, QColor color)
|
WindowShadow::WindowShadow(not_null<RpWidget*> window, QColor color)
|
||||||
: _window(window)
|
: _window(window)
|
||||||
, _handle(GetWindowHandle(window)) {
|
, _handle(GetWindowHandle(window))
|
||||||
|
, _windows11(::Platform::IsWindows11OrGreater()) {
|
||||||
init(color);
|
init(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -315,7 +317,7 @@ void WindowShadow::horCorners(int w, Gdiplus::Graphics *pgraphics0, Gdiplus::Gra
|
||||||
}
|
}
|
||||||
|
|
||||||
Gdiplus::Color WindowShadow::getColor(uchar alpha) const {
|
Gdiplus::Color WindowShadow::getColor(uchar alpha) const {
|
||||||
return Gdiplus::Color(BYTE(alpha), _r, _g, _b);
|
return Gdiplus::Color(BYTE(_windows11 ? 1 : alpha), _r, _g, _b);
|
||||||
}
|
}
|
||||||
|
|
||||||
Gdiplus::SolidBrush WindowShadow::getBrush(uchar alpha) const {
|
Gdiplus::SolidBrush WindowShadow::getBrush(uchar alpha) const {
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ private:
|
||||||
|
|
||||||
const not_null<RpWidget*> _window;
|
const not_null<RpWidget*> _window;
|
||||||
const HWND _handle;
|
const HWND _handle;
|
||||||
|
const bool _windows11 = false;
|
||||||
|
|
||||||
int _x = 0;
|
int _x = 0;
|
||||||
int _y = 0;
|
int _y = 0;
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,10 @@ void TitleWidget::setStyle(const style::WindowTitle &st) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
not_null<const style::WindowTitle*> TitleWidget::st() const {
|
||||||
|
return _controls.st();
|
||||||
|
}
|
||||||
|
|
||||||
void TitleWidget::setResizeEnabled(bool enabled) {
|
void TitleWidget::setResizeEnabled(bool enabled) {
|
||||||
_controls.setResizeEnabled(enabled);
|
_controls.setResizeEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ public:
|
||||||
|
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
void setStyle(const style::WindowTitle &st);
|
void setStyle(const style::WindowTitle &st);
|
||||||
|
[[nodiscard]] not_null<const style::WindowTitle*> st() const;
|
||||||
[[nodiscard]] HitTestResult hitTest(QPoint point) const;
|
[[nodiscard]] HitTestResult hitTest(QPoint point) const;
|
||||||
void setResizeEnabled(bool enabled);
|
void setResizeEnabled(bool enabled);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include "base/integration.h"
|
#include "base/integration.h"
|
||||||
#include "base/debug_log.h"
|
#include "base/debug_log.h"
|
||||||
#include "styles/palette.h"
|
#include "styles/palette.h"
|
||||||
|
#include "styles/style_widgets.h"
|
||||||
|
|
||||||
#include <QtCore/QAbstractNativeEventFilter>
|
#include <QtCore/QAbstractNativeEventFilter>
|
||||||
#include <QtGui/QWindow>
|
#include <QtGui/QWindow>
|
||||||
|
|
@ -29,7 +30,13 @@ namespace Ui {
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool IsCompositionEnabled() {
|
constexpr auto kDWMWCP_ROUND = DWORD(2);
|
||||||
|
constexpr auto kDWMWA_WINDOW_CORNER_PREFERENCE = DWORD(33);
|
||||||
|
constexpr auto kDWMWA_BORDER_COLOR = DWORD(34);
|
||||||
|
constexpr auto kDWMWA_CAPTION_COLOR = DWORD(35);
|
||||||
|
constexpr auto kDWMWA_TEXT_COLOR = DWORD(36);
|
||||||
|
|
||||||
|
[[nodiscard]] bool IsCompositionEnabled() {
|
||||||
auto result = BOOL(FALSE);
|
auto result = BOOL(FALSE);
|
||||||
const auto success = (DwmIsCompositionEnabled(&result) == S_OK);
|
const auto success = (DwmIsCompositionEnabled(&result) == S_OK);
|
||||||
return success && result;
|
return success && result;
|
||||||
|
|
@ -85,23 +92,6 @@ bool IsTaskbarAutoHidden(LPRECT rcMon = nullptr, PUINT pEdge = nullptr) {
|
||||||
return bAutoHidden;
|
return bAutoHidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WinApiSetWindowTheme(
|
|
||||||
HWND hWnd,
|
|
||||||
LPCWSTR pszSubAppName,
|
|
||||||
LPCWSTR pszSubIdList) {
|
|
||||||
static const auto method = [&] {
|
|
||||||
using f_SetWindowTheme = HRESULT(FAR STDAPICALLTYPE*)(
|
|
||||||
HWND hWnd,
|
|
||||||
LPCWSTR pszSubAppName,
|
|
||||||
LPCWSTR pszSubIdList);
|
|
||||||
auto result = f_SetWindowTheme();
|
|
||||||
const auto loaded = base::Platform::SafeLoadLibrary(L"uxtheme.dll");
|
|
||||||
base::Platform::LoadMethod(loaded, "SetWindowTheme", result);
|
|
||||||
return result;
|
|
||||||
}();
|
|
||||||
return method ? method(hWnd, pszSubAppName, pszSubIdList) : HRESULT();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FixAeroSnap(HWND handle) {
|
void FixAeroSnap(HWND handle) {
|
||||||
SetWindowLongPtr(
|
SetWindowLongPtr(
|
||||||
handle,
|
handle,
|
||||||
|
|
@ -198,6 +188,7 @@ void WindowHelper::setTitle(const QString &title) {
|
||||||
|
|
||||||
void WindowHelper::setTitleStyle(const style::WindowTitle &st) {
|
void WindowHelper::setTitleStyle(const style::WindowTitle &st) {
|
||||||
_title->setStyle(st);
|
_title->setStyle(st);
|
||||||
|
updateWindowFrameColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowHelper::setNativeFrame(bool enabled) {
|
void WindowHelper::setNativeFrame(bool enabled) {
|
||||||
|
|
@ -216,6 +207,7 @@ void WindowHelper::setNativeFrame(bool enabled) {
|
||||||
initialShadowUpdate();
|
initialShadowUpdate();
|
||||||
}
|
}
|
||||||
updateMargins();
|
updateMargins();
|
||||||
|
updateWindowFrameColors();
|
||||||
fixMaximizedWindow();
|
fixMaximizedWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,6 +219,15 @@ void WindowHelper::initialShadowUpdate() {
|
||||||
} else {
|
} else {
|
||||||
_shadow->update(Change::Moved | Change::Resized | Change::Shown);
|
_shadow->update(Change::Moved | Change::Resized | Change::Shown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (::Platform::IsWindows11OrGreater()) {
|
||||||
|
auto preference = kDWMWCP_ROUND;
|
||||||
|
DwmSetWindowAttribute(
|
||||||
|
_handle,
|
||||||
|
kDWMWA_WINDOW_CORNER_PREFERENCE,
|
||||||
|
&preference,
|
||||||
|
sizeof(preference));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowHelper::setMinimumSize(QSize size) {
|
void WindowHelper::setMinimumSize(QSize size) {
|
||||||
|
|
@ -270,6 +271,7 @@ void WindowHelper::init() {
|
||||||
if (_shadow) {
|
if (_shadow) {
|
||||||
_shadow->setColor(st::windowShadowFg->c);
|
_shadow->setColor(st::windowShadowFg->c);
|
||||||
}
|
}
|
||||||
|
updateWindowFrameColors();
|
||||||
Ui::ForceFullRepaint(window());
|
Ui::ForceFullRepaint(window());
|
||||||
}, window()->lifetime());
|
}, window()->lifetime());
|
||||||
|
|
||||||
|
|
@ -291,9 +293,10 @@ void WindowHelper::init() {
|
||||||
updateMargins();
|
updateMargins();
|
||||||
|
|
||||||
if (!::Platform::IsWindows8OrGreater()) {
|
if (!::Platform::IsWindows8OrGreater()) {
|
||||||
WinApiSetWindowTheme(_handle, L" ", L" ");
|
SetWindowTheme(_handle, L" ", L" ");
|
||||||
QApplication::setStyle(QStyleFactory::create("Windows"));
|
QApplication::setStyle(QStyleFactory::create("Windows"));
|
||||||
}
|
}
|
||||||
|
updateWindowFrameColors();
|
||||||
|
|
||||||
_menu = GetSystemMenu(_handle, FALSE);
|
_menu = GetSystemMenu(_handle, FALSE);
|
||||||
updateSystemMenu();
|
updateSystemMenu();
|
||||||
|
|
@ -326,13 +329,15 @@ bool WindowHelper::handleNativeEvent(
|
||||||
if (LOWORD(wParam) == WA_CLICKACTIVE) {
|
if (LOWORD(wParam) == WA_CLICKACTIVE) {
|
||||||
Ui::MarkInactivePress(window(), true);
|
Ui::MarkInactivePress(window(), true);
|
||||||
}
|
}
|
||||||
|
const auto active = (LOWORD(wParam) != WA_INACTIVE);
|
||||||
if (_shadow) {
|
if (_shadow) {
|
||||||
if (LOWORD(wParam) != WA_INACTIVE) {
|
if (active) {
|
||||||
_shadow->update(WindowShadow::Change::Activate);
|
_shadow->update(WindowShadow::Change::Activate);
|
||||||
} else {
|
} else {
|
||||||
_shadow->update(WindowShadow::Change::Deactivate);
|
_shadow->update(WindowShadow::Change::Deactivate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateWindowFrameColors(active);
|
||||||
window()->update();
|
window()->update();
|
||||||
} return false;
|
} return false;
|
||||||
|
|
||||||
|
|
@ -553,6 +558,39 @@ int WindowHelper::titleHeight() const {
|
||||||
return _title->isHidden() ? 0 : _title->height();
|
return _title->isHidden() ? 0 : _title->height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowHelper::updateWindowFrameColors() {
|
||||||
|
updateWindowFrameColors(window()->isActiveWindow());
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowHelper::updateWindowFrameColors(bool active) {
|
||||||
|
if (!::Platform::IsWindows11OrGreater()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto bg = active
|
||||||
|
? _title->st()->bgActive->c
|
||||||
|
: _title->st()->bg->c;
|
||||||
|
COLORREF bgRef = RGB(bg.red(), bg.green(), bg.blue());
|
||||||
|
DwmSetWindowAttribute(
|
||||||
|
_handle,
|
||||||
|
kDWMWA_BORDER_COLOR,
|
||||||
|
&bgRef,
|
||||||
|
sizeof(COLORREF));
|
||||||
|
DwmSetWindowAttribute(
|
||||||
|
_handle,
|
||||||
|
kDWMWA_CAPTION_COLOR,
|
||||||
|
&bgRef,
|
||||||
|
sizeof(COLORREF));
|
||||||
|
const auto fg = active
|
||||||
|
? _title->st()->fgActive->c
|
||||||
|
: _title->st()->fg->c;
|
||||||
|
COLORREF fgRef = RGB(fg.red(), fg.green(), fg.blue());
|
||||||
|
DwmSetWindowAttribute(
|
||||||
|
_handle,
|
||||||
|
kDWMWA_TEXT_COLOR,
|
||||||
|
&fgRef,
|
||||||
|
sizeof(COLORREF));
|
||||||
|
}
|
||||||
|
|
||||||
void WindowHelper::updateMargins() {
|
void WindowHelper::updateMargins() {
|
||||||
if (_updatingMargins) return;
|
if (_updatingMargins) return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ private:
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void updateMargins();
|
void updateMargins();
|
||||||
|
void updateWindowFrameColors();
|
||||||
|
void updateWindowFrameColors(bool active);
|
||||||
void updateSystemMenu();
|
void updateSystemMenu();
|
||||||
void updateSystemMenu(Qt::WindowState state);
|
void updateSystemMenu(Qt::WindowState state);
|
||||||
void initialShadowUpdate();
|
void initialShadowUpdate();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue