+ 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);
+}
+
+void sys_focus(win_t *win)
+{
+ printf("sys_focus: %p\n", win);
+
+ /* Windows prevents a thread from using SetForegroundInput under
+ * certain circumstnaces and instead flashes the windows toolbar icon.
+ * Attaching the htread input queues avoids this behavior */
+ DWORD oldId = GetWindowThreadProcessId(GetForegroundWindow(), NULL);
+ DWORD newId = GetWindowThreadProcessId(win->sys->hwnd, NULL);
+ AttachThreadInput(oldId, newId, TRUE);
+ SetForegroundWindow(win->sys->hwnd);
+ AttachThreadInput(oldId, newId, FALSE);
+}
+
+void sys_show(win_t *win, state_t state)
+{
+ static struct {
+ char *str;
+ int cmd;
+ } map[] = {
+ [st_show ] {"show" , SW_SHOW },
+ [st_full ] {"full" , SW_MAXIMIZE},
+ [st_shade] {"shade", SW_SHOW },
+ [st_icon ] {"icon" , SW_MINIMIZE},
+ [st_hide ] {"hide" , SW_HIDE },
+ };
+ win->sys->state = state;
+ printf("sys_show: %s\n", map[state].str);
+ ShowWindow(win->sys->hwnd, map[state].cmd);