From: Andy Spencer Date: Mon, 3 Oct 2011 08:55:21 +0000 (+0000) Subject: Win32 updates X-Git-Url: http://pileus.org/git/?p=wmpus;a=commitdiff_plain;h=d447b5fbe067f469132cc8e02b583a55789ccb16 Win32 updates - Force sys_raise - Reset stacking order for sys_focus --- diff --git a/sys-win32.c b/sys-win32.c index 0e52935..463b6ff 100644 --- a/sys-win32.c +++ b/sys-win32.c @@ -325,12 +325,15 @@ void sys_move(win_t *win, int x, int y, int w, int h) void sys_raise(win_t *win) { printf("sys_raise: %p\n", win); - SetForegroundWindow(win->sys->hwnd); - //HWND hwnd = win->sys->hwnd; - //HWND top = GetAncestor(hwnd,GA_ROOT); - //SetWindowPos(top, HWND_TOPMOST, 0, 0, 0, 0, - // SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); + /* See note in sys_focus */ + DWORD oldId = GetWindowThreadProcessId(GetForegroundWindow(), NULL); + DWORD newId = GetCurrentThreadId(); + AttachThreadInput(oldId, newId, TRUE); + + SetWindowPos(win->sys->hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); + + AttachThreadInput(oldId, newId, FALSE); } void sys_focus(win_t *win) @@ -344,9 +347,10 @@ void sys_focus(win_t *win) DWORD newId = GetCurrentThreadId(); AttachThreadInput(oldId, newId, TRUE); - BringWindowToTop(win->sys->hwnd); - SetForegroundWindow(win->sys->hwnd); - SetFocus(win->sys->hwnd); + HWND next = GetWindow(win->sys->hwnd, GW_HWNDNEXT); + SetWindowPos(win->sys->hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); + if (next) + SetWindowPos(win->sys->hwnd, next, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); AttachThreadInput(oldId, newId, FALSE); } diff --git a/wm-wmii.c b/wm-wmii.c index ad114eb..df88527 100644 --- a/wm-wmii.c +++ b/wm-wmii.c @@ -657,10 +657,10 @@ static void wm_update_cols(dpy_t *dpy) case tab: sys_move(win, x+MARGIN, 0+MARGIN, col->width, dpy->geom->h-2*MARGIN); - if (focus == win) - sys_raise(win); break; } + if (focus == win) + sys_raise(win); ROW(lrow)->height = win->h; } x += col->width + MARGIN;