Skip to content

Commit 1253674

Browse files
authored
Merge pull request #13 from k-takata/adjust-window-positioning
Adjust window positioning
2 parents e4a6a1e + deabbd1 commit 1253674

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

source/dll/wndproc.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ static void RearrangeNotifyArea(HWND hwnd, HWND hwndClock)
229229
{
230230
LRESULT size;
231231
POINT posclk = {0, 0};
232-
int wclock, hclock;
232+
int wclock, hclock, lastx, lasty;
233233
HWND hwndChild;
234234

235235
size = OnCalcRect(hwndClock);
@@ -238,26 +238,36 @@ static void RearrangeNotifyArea(HWND hwnd, HWND hwndClock)
238238
SetWindowPos(hwndClock, NULL, 0, 0, wclock, hclock,
239239
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
240240
MapWindowPoints(hwndClock, hwnd, &posclk, 1);
241+
lastx = posclk.x + wclock;
242+
lasty = posclk.y + hclock;
241243
posclk.x += g_OrigClockWidth;
242244
posclk.y += g_OrigClockHeight;
243-
hwndChild = hwndClock;
244-
while((hwndChild = GetWindow(hwndChild, GW_HWNDNEXT)) != NULL)
245+
246+
// Loop for all the windows after the clock window.
247+
for(hwndChild = hwndClock;
248+
(hwndChild = GetWindow(hwndChild, GW_HWNDNEXT)) != NULL; )
245249
{
250+
RECT rc;
246251
POINT pos = {0, 0};
247252
MapWindowPoints(hwndChild, hwnd, &pos, 1);
253+
GetWindowRect(hwndChild, &rc);
248254
if(pos.x >= posclk.x)
249255
{
250256
// Horizontal taskbar
251-
pos.x += wclock - g_OrigClockWidth;
257+
//pos.x += wclock - g_OrigClockWidth;
258+
pos.x = lastx;
252259
SetWindowPos(hwndChild, NULL, pos.x, pos.y, 0, 0,
253260
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
261+
lastx = pos.x + rc.right - rc.left;
254262
}
255263
else if(pos.y >= posclk.y)
256264
{
257265
// Vertical taskbar
258-
pos.y += hclock - g_OrigClockHeight;
266+
//pos.y += hclock - g_OrigClockHeight;
267+
pos.y = lasty;
259268
SetWindowPos(hwndChild, NULL, pos.x, pos.y, 0, 0,
260269
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
270+
lasty = pos.y + rc.bottom - rc.top;
261271
}
262272
}
263273
}

0 commit comments

Comments
 (0)