summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-05-22 20:31:47 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-05-22 20:31:47 +0300
commit23f21ae625b736b640d9258b2660111e38e21145 (patch)
tree3235143fe53089e5ef63786f740a3652038e37e1 /src/mir_app
parent05165317940d1c2fcb2b089e2fbf5f9bf6246f8e (diff)
fixes #3522 (headerbar.cpp: get rid of IsAeroMode)
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/headerbar.cpp89
1 files changed, 18 insertions, 71 deletions
diff --git a/src/mir_app/src/headerbar.cpp b/src/mir_app/src/headerbar.cpp
index f312b22145..b9b3f4256f 100644
--- a/src/mir_app/src/headerbar.cpp
+++ b/src/mir_app/src/headerbar.cpp
@@ -25,15 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
-typedef HRESULT(STDAPICALLTYPE* pfnDrawThemeTextEx)(HTHEME, HDC, int, int, LPCWSTR, int, uint32_t, LPRECT, const struct _DTTOPTS*);
-static pfnDrawThemeTextEx drawThemeTextEx;
-
-typedef HRESULT(STDAPICALLTYPE* pfnSetWindowThemeAttribute)(HWND, enum WINDOWTHEMEATTRIBUTETYPE, PVOID, uint32_t);
-static pfnSetWindowThemeAttribute setWindowThemeAttribute;
-
-typedef HRESULT(STDAPICALLTYPE* pfnDwmExtendFrameIntoClientArea)(HWND hwnd, const MARGINS* margins);
-static pfnDwmExtendFrameIntoClientArea dwmExtendFrameIntoClientArea;
-
typedef HRESULT(STDAPICALLTYPE* pfnDwmIsCompositionEnabled)(BOOL*);
static pfnDwmIsCompositionEnabled dwmIsCompositionEnabled;
@@ -122,7 +113,6 @@ static void MHeaderbar_DrawGradient(HDC hdc, int x, int y, int width, int height
static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit)
{
- int iTopSpace = IsAeroMode() ? 0 : 3;
PAINTSTRUCT ps;
int titleLength = GetWindowTextLength(hwndDlg) + 1;
@@ -147,26 +137,13 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit)
HBITMAP hOldBmp = (HBITMAP)SelectObject(tempDC, hBmp);
- if (IsAeroMode()) {
- RECT temprc = { 0, 0, mit->width, mit->width };
- FillRect(tempDC, &temprc, (HBRUSH)GetStockObject(BLACK_BRUSH));
-
- MARGINS margins = { 0, 0, mit->height, 0 };
- dwmExtendFrameIntoClientArea(GetParent(hwndDlg), &margins);
-
- WTA_OPTIONS opts;
- opts.dwFlags = opts.dwMask = WTNCA_NOSYSMENU | WTNCA_NODRAWICON;
- setWindowThemeAttribute(GetParent(hwndDlg), WTA_NONCLIENT, &opts, sizeof(opts));
- }
- else {
- if (IsVSMode())
- MHeaderbar_FillRect(tempDC, 0, 0, mit->width, mit->height, GetSysColor(COLOR_WINDOW));
- else
- MHeaderbar_DrawGradient(tempDC, 0, 0, mit->width, mit->height, &mit->rgbBkgTop, &mit->rgbBkgBottom);
+ if (IsVSMode())
+ MHeaderbar_FillRect(tempDC, 0, 0, mit->width, mit->height, GetSysColor(COLOR_WINDOW));
+ else
+ MHeaderbar_DrawGradient(tempDC, 0, 0, mit->width, mit->height, &mit->rgbBkgTop, &mit->rgbBkgBottom);
- MHeaderbar_FillRect(tempDC, 0, mit->height-2, mit->width, 1, GetSysColor(COLOR_BTNSHADOW));
- MHeaderbar_FillRect(tempDC, 0, mit->height-1, mit->width, 1, GetSysColor(COLOR_BTNHIGHLIGHT));
- }
+ MHeaderbar_FillRect(tempDC, 0, mit->height-2, mit->width, 1, GetSysColor(COLOR_BTNSHADOW));
+ MHeaderbar_FillRect(tempDC, 0, mit->height-1, mit->width, 1, GetSysColor(COLOR_BTNHIGHLIGHT));
HFONT hFont = mit->hFont;
SetBkMode(tempDC, TRANSPARENT);
@@ -178,50 +155,28 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit)
HFONT hFntBold = CreateFontIndirect(&lf), hOldFont;
if (mit->hIcon)
- DrawIcon(tempDC, 10, iTopSpace, mit->hIcon);
+ DrawIcon(tempDC, 10, 3, mit->hIcon);
else {
HICON hIcon = (HICON)SendMessage(GetParent(hwndDlg), WM_GETICON, ICON_BIG, 0);
if (hIcon == nullptr)
hIcon = (HICON)SendMessage(GetParent(hwndDlg), WM_GETICON, ICON_SMALL, 0);
- DrawIcon(tempDC, 10, iTopSpace, hIcon);
+ DrawIcon(tempDC, 10, 3, hIcon);
}
RECT textRect;
textRect.left = 50;
textRect.right = mit->width;
- textRect.top = 2 + iTopSpace;
- textRect.bottom = g_iIconY - 2 + iTopSpace;
-
- if (IsAeroMode()) {
- DTTOPTS dto = { 0 };
- dto.dwSize = sizeof(dto);
- dto.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE;
- dto.iGlowSize = 10;
-
- HANDLE hTheme = OpenThemeData(hwndDlg, L"Window");
- textRect.left = 50;
- hOldFont = (HFONT)SelectObject(tempDC, hFntBold);
+ textRect.top = 5;
+ textRect.bottom = g_iIconY + 1;
- drawThemeTextEx(hTheme, tempDC, WP_CAPTION, CS_ACTIVE, szTitle, -1, DT_TOP | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_END_ELLIPSIS, &textRect, &dto);
-
- if (szSubTitle) {
- textRect.left = 66;
- SelectObject(tempDC, hFont);
+ textRect.left = 50;
+ hOldFont = (HFONT)SelectObject(tempDC, hFntBold);
+ DrawText(tempDC, szTitle, -1, &textRect, DT_TOP | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_END_ELLIPSIS);
- drawThemeTextEx(hTheme, tempDC, WP_CAPTION, CS_ACTIVE, szSubTitle, -1, DT_BOTTOM | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_END_ELLIPSIS, &textRect, &dto);
- }
- CloseThemeData(hTheme);
- }
- else {
- textRect.left = 50;
- hOldFont = (HFONT)SelectObject(tempDC, hFntBold);
- DrawText(tempDC, szTitle, -1, &textRect, DT_TOP | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_END_ELLIPSIS);
-
- if (szSubTitle) {
- textRect.left = 66;
- SelectObject(tempDC, hFont);
- DrawText(tempDC, szSubTitle, -1, &textRect, DT_BOTTOM | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_END_ELLIPSIS);
- }
+ if (szSubTitle) {
+ textRect.left = 66;
+ SelectObject(tempDC, hFont);
+ DrawText(tempDC, szSubTitle, -1, &textRect, DT_BOTTOM | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_END_ELLIPSIS);
}
DeleteObject(hFntBold);
@@ -340,17 +295,9 @@ static LRESULT CALLBACK MHeaderbarWndProc(HWND hwndDlg, UINT msg, WPARAM wParam
int LoadHeaderbarModule()
{
if (IsWinVerVistaPlus()) {
- HINSTANCE hThemeAPI = LoadLibraryA("uxtheme.dll");
- if (hThemeAPI) {
- drawThemeTextEx = (pfnDrawThemeTextEx)GetProcAddress(hThemeAPI, "DrawThemeTextEx");
- setWindowThemeAttribute = (pfnSetWindowThemeAttribute)GetProcAddress(hThemeAPI, "SetWindowThemeAttribute");
- }
-
HINSTANCE hDwmApi = LoadLibrary(L"dwmapi.dll");
- if (hDwmApi) {
- dwmExtendFrameIntoClientArea = (pfnDwmExtendFrameIntoClientArea)GetProcAddress(hDwmApi, "DwmExtendFrameIntoClientArea");
+ if (hDwmApi)
dwmIsCompositionEnabled = (pfnDwmIsCompositionEnabled)GetProcAddress(hDwmApi, "DwmIsCompositionEnabled");
- }
}
WNDCLASSEX wc = { 0 };