Skip to content

Commit

Permalink
dll: Fix for vertical taskbar
Browse files Browse the repository at this point in the history
It seems that we cannot use the same method for arranging notify area
before Win10TH2 and after Win10RS1.  Version check is needed.
  • Loading branch information
k-takata committed Aug 31, 2016
1 parent c6f1c27 commit 5dc1615
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
6 changes: 6 additions & 0 deletions source/dll/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,12 @@ void DrawClock(HWND hwnd, HDC hdc, const SYSTEMTIME* pt)
GetClientRect(hwnd, &rcClock);
wclock = rcClock.right;
hclock = rcClock.bottom;
if(g_bTaskbarPosChanging)
{
g_OrigClockWidth = wclock;
g_OrigClockHeight = hclock;
g_bTaskbarPosChanging = FALSE;
}

size = (DWORD)CalcRect(hwnd, &wtext, &htext);
if(wclock < LOWORD(size) || hclock < HIWORD(size))
Expand Down
18 changes: 15 additions & 3 deletions source/dll/main2.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ BOOL g_bVisualStyle; // Windows XP theme is used
BOOL g_bNoClock; // don't customize clock
int g_OrigClockWidth; // original clock width
int g_OrigClockHeight; // original clock height
RECT g_rcTaskbar;
BOOL g_bTaskbarPosChanging;
BOOL g_bLMousePassThru; // pass through left button messages

#define SUBCLASS_ID 1
Expand Down Expand Up @@ -66,6 +68,9 @@ void InitClock(HWND hwnd)
GetWindowRect(hwnd, &rc);
g_OrigClockWidth = rc.right - rc.left;
g_OrigClockHeight = rc.bottom - rc.top;
// Save taskbar position
GetWindowRect(GetParent(GetParent(hwnd)), &g_rcTaskbar);
g_bTaskbarPosChanging = FALSE;

// tell tclock.exe clock's HWND
PostMessage(g_hwndTClockMain, TCM_HWNDCLOCK, 0, (LPARAM)hwnd);
Expand All @@ -77,8 +82,11 @@ void InitClock(HWND hwnd)
InitUserStr(); // userstr.c

// subclassfy the clock window !!
SetWindowSubclass(GetParent(hwnd), SubclassTrayProc, SUBCLASSTRAY_ID,
(DWORD_PTR)hwnd);
if(g_winver&WIN10RS1)
{
SetWindowSubclass(GetParent(hwnd), SubclassTrayProc,
SUBCLASSTRAY_ID, (DWORD_PTR)hwnd);
}
SetWindowSubclass(hwnd, SubclassProc, SUBCLASS_ID, 0);

// don't accept double clicks
Expand Down Expand Up @@ -171,7 +179,11 @@ void EndClock(HWND hwnd)

// restore window procedure
RemoveWindowSubclass(hwnd, SubclassProc, SUBCLASS_ID);
RemoveWindowSubclass(GetParent(hwnd), SubclassTrayProc, SUBCLASSTRAY_ID);
if(g_winver&WIN10RS1)
{
RemoveWindowSubclass(GetParent(hwnd), SubclassTrayProc,
SUBCLASSTRAY_ID);
}

#if TC_ENABLE_TASKBAR
RefreshTaskbar(hwnd); // taskbar.c
Expand Down
2 changes: 2 additions & 0 deletions source/dll/tcdll.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ extern BOOL g_bVisualStyle;
extern BOOL g_bNoClock;
extern int g_OrigClockWidth;
extern int g_OrigClockHeight;
extern RECT g_rcTaskbar;
extern BOOL g_bTaskbarPosChanging;
extern BOOL g_bLMousePassThru;

/* ---------- wndproc.c ----------- */
Expand Down
25 changes: 20 additions & 5 deletions source/dll/wndproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,9 @@ LRESULT CALLBACK SubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case WM_ERASEBKGND:
break;

#if 0
case (WM_USER+100): // a message requesting for clock size
if(g_bNoClock) break; // sent from parent window
return OnCalcRect(hwnd);
#endif
return OnCalcRect(hwnd); // (only before Win10RS1)

case WM_WINDOWPOSCHANGING: // size arrangement
if(g_bNoClock) break;
Expand Down Expand Up @@ -232,7 +230,7 @@ static void RearrangeNotifyArea(HWND hwnd, HWND hwndClock)
POINT posclk = {0, 0};
int wclock, hclock;
HWND hwndChild;

size = OnCalcRect(hwndClock);
wclock = LOWORD(size);
hclock = HIWORD(size);
Expand Down Expand Up @@ -289,12 +287,29 @@ LRESULT CALLBACK SubclassTrayProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
NMHDR *nmh = (NMHDR*)lParam;
HWND hwndClock = (HWND)dwRefData;

if(g_bNoClock || nmh->code != PGN_CALCSIZE)
if(g_bNoClock || nmh->code != PGN_CALCSIZE ||
g_bTaskbarPosChanging)
break;
ret = DefSubclassProc(hwnd, message, wParam, lParam);
RearrangeNotifyArea(hwnd, hwndClock);
return ret;
}
case WM_WINDOWPOSCHANGING:
{
RECT rc;

GetWindowRect(GetParent(hwnd), &rc);
if (!EqualRect(&rc, &g_rcTaskbar))
{
g_rcTaskbar = rc;
g_bTaskbarPosChanging = TRUE;
}
else
{
g_bTaskbarPosChanging = FALSE;
}
break;
}
}

return DefSubclassProc(hwnd, message, wParam, lParam);
Expand Down

0 comments on commit 5dc1615

Please sign in to comment.