CVS: seamlessrdp/ServerExe/HookDll hookdll.c,1.27,1.28

Pierre Ossman <[email protected]> Mon, 20 Mar 2006 01:36:26 -0800
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/seamlessrdp/ServerExe/HookDll
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4375/ServerExe/HookDll

Modified Files:
	hookdll.c 
Log Message:
Handle z order changes properly by waiting until the reordering is complete
and then examining the result.


Index: hookdll.c
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/HookDll/hookdll.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** hookdll.c	17 Mar 2006 16:34:46 -0000	1.27
--- hookdll.c	20 Mar 2006 09:36:23 -0000	1.28
***************
*** 94,97 ****
--- 94,127 ----
  }
  
+ static void
+ update_zorder(HWND hwnd)
+ {
+ 	HWND behind;
+ 	HWND block_hwnd, block_behind;
+ 
+ 	WaitForSingleObject(g_mutex, INFINITE);
+ 	block_hwnd = g_blocked_zchange[0];
+ 	block_behind = g_blocked_zchange[1];
+ 	ReleaseMutex(g_mutex);
+ 
+ 	behind = GetNextWindow(hwnd, GW_HWNDPREV);
+ 	while (behind)
+ 	{
+ 		LONG style;
+ 
+ 		style = GetWindowLong(behind, GWL_STYLE);
+ 
+ 		if ((!(style & WS_CHILD) || (style & WS_POPUP)) && (style & WS_VISIBLE))
+ 			break;
+ 
+ 		behind = GetNextWindow(behind, GW_HWNDPREV);
+ 	}
+ 
+ 	if ((hwnd == block_hwnd) && (behind == block_behind))
+ 		return;
+ 
+ 	vchannel_write("ZCHANGE,0x%p,0x%p,0x%x", hwnd, behind, 0);
+ }
+ 
  static LRESULT CALLBACK
  wndproc_hook_proc(int code, WPARAM cur_thread, LPARAM details)
***************
*** 167,188 ****
  					update_position(hwnd);
  
- 				if (!(wp->flags & SWP_NOZORDER))
- 				{
- 					HWND block_hwnd, block_behind;
- 					WaitForSingleObject(g_mutex, INFINITE);
- 					block_hwnd = g_blocked_zchange[0];
- 					block_behind = g_blocked_zchange[1];
- 					ReleaseMutex(g_mutex);
- 
- 					if ((hwnd != block_hwnd)
- 					    || (wp->hwndInsertAfter != block_behind))
- 					{
- 						vchannel_write("ZCHANGE,0x%p,0x%p,0x%x",
- 							       hwnd,
- 							       wp->flags & SWP_NOACTIVATE ? wp->
- 							       hwndInsertAfter : 0, 0);
- 					}
- 				}
- 
  				break;
  			}
--- 197,200 ----
***************
*** 250,253 ****
--- 262,279 ----
  	switch (msg)
  	{
+ 		case WM_WINDOWPOSCHANGED:
+ 			{
+ 				WINDOWPOS *wp = (WINDOWPOS *) lparam;
+ 
+ 				if (!(style & WS_VISIBLE) || (style & WS_MINIMIZE))
+ 					break;
+ 
+ 				if (!(wp->flags & SWP_NOZORDER))
+ 					update_zorder(hwnd);
+ 
+ 				break;
+ 			}
+ 
+ 
  		case WM_SETTEXT:
  			{
***************
*** 376,382 ****
  SafeZChange(HWND hwnd, HWND behind)
  {
- 	if (behind == NULL)
- 		behind = HWND_TOP;
- 
  	WaitForSingleObject(g_mutex, INFINITE);
  	g_blocked_zchange[0] = hwnd;
--- 402,405 ----
***************
*** 384,387 ****
--- 407,413 ----
  	ReleaseMutex(g_mutex);
  
+ 	if (behind == NULL)
+ 		behind = HWND_TOP;
+ 
  	SetWindowPos(hwnd, behind, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
  



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642