CVS: seamlessrdp/ServerExe/HookDll hookdll.c, 1.38, 1.39
Peter Ã
strand <[email protected]> Thu, 21 Feb 2008 02:16:21 -0800
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
--===============0657745251==
Update of /cvsroot/rdesktop/seamlessrdp/ServerExe/HookDll
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv5395
Modified Files:
hookdll.c
Log Message:
Re-worked the logic for determining which windows to ignore (all but
toplevel ones). Also, rewrote get_parent to use a simpler and
documented approach.
A side effect of these changes is that combobox windows are now
correctly handled as top-level windows and thus can appear outside
application windows.
Index: hookdll.c
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/HookDll/hookdll.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** hookdll.c 18 Jun 2007 11:59:38 -0000 1.38
--- hookdll.c 21 Feb 2008 10:16:19 -0000 1.39
***************
*** 5,10 ****
Based on code copyright (C) 2004-2005 Martin Wickett
! Copyright 2005-2006 Peter Åstrand <[email protected]> for Cendio AB
! Copyright 2006-2007 Pierre Ossman <[email protected]> for Cendio AB
This program is free software; you can redistribute it and/or modify
--- 5,10 ----
Based on code copyright (C) 2004-2005 Martin Wickett
! Copyright 2005-2008 Peter Åstrand <[email protected]> for Cendio AB
! Copyright 2006-2008 Pierre Ossman <[email protected]> for Cendio AB
This program is free software; you can redistribute it and/or modify
***************
*** 76,79 ****
--- 76,123 ----
static HANDLE g_mutex = NULL;
+ static BOOL is_toplevel(HWND hwnd)
+ {
+ BOOL toplevel;
+ HWND parent;
+ parent = GetAncestor(hwnd, GA_PARENT);
+
+ /* According to MS: "A window that has no parent, or whose
+ parent is the desktop window, is called a top-level
+ window." See http://msdn2.microsoft.com/en-us/library/ms632597(VS.85).aspx. */
+ toplevel = (!parent || parent == GetDesktopWindow());
+ return toplevel;
+ }
+
+ /* Determine the "parent" field for the CREATE response. */
+ static HWND
+ get_parent(HWND hwnd)
+ {
+ HWND result;
+ HWND owner;
+ LONG exstyle;
+
+ /* Use the same logic to determine if the window should be
+ "transient" (ie have no task icon) as MS uses. This is documented at
+ http://msdn2.microsoft.com/en-us/library/bb776822.aspx */
+ owner = GetWindow(hwnd, GW_OWNER);
+ exstyle = GetWindowLong(hwnd, GWL_EXSTYLE);
+ if (!owner && !(exstyle & WS_EX_TOOLWINDOW)) {
+ /* display taskbar icon */
+ HWND parent;
+ parent = GetAncestor(hwnd, GA_PARENT);
+ if (parent == GetDesktopWindow()) {
+ /* top-level without parent */
+ result = NULL;
+ } else {
+ result = parent;
+ }
+ } else {
+ /* no taskbar icon */
+ result = (HWND) - 1;
+ }
+
+ return result;
+ }
+
static void
update_position(HWND hwnd)
***************
*** 145,186 ****
}
- static HWND
- get_parent(HWND hwnd)
- {
- LONG style;
- HWND parent;
-
- style = GetWindowLong(hwnd, GWL_STYLE);
-
- if (style & (WS_POPUP | DS_MODALFRAME))
- {
- parent = (HWND) GetWindowLong(hwnd, GWL_HWNDPARENT);
-
- if (parent)
- {
- style = GetWindowLong(parent, GWL_STYLE);
- if (((style & WS_CHILD) && !(style & WS_POPUP)) || !(style & WS_VISIBLE))
- parent = NULL;
- }
-
- if (!parent)
- parent = GetWindow(hwnd, GW_OWNER);
-
- if (parent)
- {
- style = GetWindowLong(parent, GWL_STYLE);
- if (((style & WS_CHILD) && !(style & WS_POPUP)) || !(style & WS_VISIBLE))
- parent = NULL;
- }
-
- if (!parent)
- parent = (HWND) - 1;
- }
- else
- parent = NULL;
-
- return parent;
- }
-
static HICON
get_icon(HWND hwnd, int large)
--- 189,192 ----
***************
*** 352,356 ****
wndproc_hook_proc(int code, WPARAM cur_thread, LPARAM details)
{
! HWND hwnd, parent;
UINT msg;
WPARAM wparam;
--- 358,362 ----
wndproc_hook_proc(int code, WPARAM cur_thread, LPARAM details)
{
! HWND hwnd;
UINT msg;
WPARAM wparam;
***************
*** 369,378 ****
style = GetWindowLong(hwnd, GWL_STYLE);
! /* Docs say that WS_CHILD and WS_POPUP is an illegal combination,
! but they exist nonetheless. */
! if ((style & WS_CHILD) && !(style & WS_POPUP))
goto end;
!
! parent = get_parent(hwnd);
switch (msg)
--- 375,381 ----
style = GetWindowLong(hwnd, GWL_STYLE);
! if (!is_toplevel(hwnd)) {
goto end;
! }
switch (msg)
***************
*** 397,401 ****
vchannel_write("CREATE", "0x%08lx,0x%08lx,0x%08lx,0x%08x",
! (long) hwnd, (long) pid, (long) parent,
flags);
--- 400,404 ----
vchannel_write("CREATE", "0x%08lx,0x%08lx,0x%08lx,0x%08x",
! (long) hwnd, (long) pid, (long) get_parent(hwnd),
flags);
***************
*** 500,504 ****
wndprocret_hook_proc(int code, WPARAM cur_thread, LPARAM details)
{
! HWND hwnd, parent;
UINT msg;
WPARAM wparam;
--- 503,507 ----
wndprocret_hook_proc(int code, WPARAM cur_thread, LPARAM details)
{
! HWND hwnd;
UINT msg;
WPARAM wparam;
***************
*** 517,526 ****
style = GetWindowLong(hwnd, GWL_STYLE);
! /* Docs say that WS_CHILD and WS_POPUP is an illegal combination,
! but they exist nonetheless. */
! if ((style & WS_CHILD) && !(style & WS_POPUP))
goto end;
!
! parent = get_parent(hwnd);
switch (msg)
--- 520,526 ----
style = GetWindowLong(hwnd, GWL_STYLE);
! if (!is_toplevel(hwnd)) {
goto end;
! }
switch (msg)
***************
*** 578,582 ****
/* FIXME: SetForegroundWindow() kills menus. Need to find a
clean way to solve this. */
! if ((GetForegroundWindow() != hwnd) && !parent)
SetForegroundWindow(hwnd);
--- 578,582 ----
/* FIXME: SetForegroundWindow() kills menus. Need to find a
clean way to solve this. */
! if ((GetForegroundWindow() != hwnd) && !get_parent(hwnd))
SetForegroundWindow(hwnd);
--===============0657745251==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
--===============0657745251==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
rdesktop-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdesktop-cvs
--===============0657745251==--