--- sourceforge.net/trunk/seamlessrdp/ServerExe/HookDll/hookdll.c 2008/03/11 08:10:58 1448 +++ sourceforge.net/trunk/seamlessrdp/ServerExe/HookDll/hookdll.c 2008/03/11 08:21:33 1449 @@ -89,6 +89,16 @@ return toplevel; } +/* Returns true if a window is a menu window. */ +static BOOL +is_menu(HWND hwnd) +{ + HWND owner = GetWindow(hwnd, GW_OWNER); + LONG exstyle = GetWindowLong(hwnd, GWL_EXSTYLE); + return (exstyle & (WS_EX_TOOLWINDOW | WS_EX_TOPMOST)) && owner; + +} + /* Determine the "parent" field for the CREATE response. */ static HWND get_parent(HWND hwnd) @@ -589,9 +599,9 @@ if (msg == g_wm_seamless_focus) { - /* FIXME: SetForegroundWindow() kills menus. Need to find a - clean way to solve this. */ - if ((GetForegroundWindow() != hwnd) && !get_parent(hwnd)) + /* For some reason, SetForegroundWindow() on menus + closes them. Ignore focus requests for menu windows. */ + if ((GetForegroundWindow() != hwnd) && !is_menu(hwnd)) SetForegroundWindow(hwnd); vchannel_write("ACK", "%u", g_blocked_focus_serial);