CVS: seamlessrdp/ServerExe/HookDll hookdll.c,1.29,1.30

Pierre Ossman <[email protected]> Mon, 20 Mar 2006 04:28:05 -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-serv17080/ServerExe/HookDll

Modified Files:
	hookdll.c 
Log Message:
Send an ACK for all client commands.


Index: hookdll.c
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/HookDll/hookdll.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** hookdll.c	20 Mar 2006 10:30:25 -0000	1.29
--- hookdll.c	20 Mar 2006 12:28:03 -0000	1.30
***************
*** 47,53 ****
--- 47,60 ----
  // blocks for locally generated events
  HWND g_block_move_hwnd SHARED = NULL;
+ unsigned int g_block_move_serial SHARED = 0;
  RECT g_block_move SHARED = { 0, 0, 0, 0 };
+ 
+ unsigned int g_blocked_zchange_serial SHARED = 0;
  HWND g_blocked_zchange[2] SHARED = { NULL, NULL };
+ 
+ unsigned int g_blocked_focus_serial SHARED = 0;
  HWND g_blocked_focus SHARED = NULL;
+ 
+ unsigned int g_blocked_state_serial SHARED = 0;
  HWND g_blocked_state_hwnd SHARED = NULL;
  int g_blocked_state SHARED = -1;
***************
*** 73,76 ****
--- 80,84 ----
  	RECT rect, blocked;
  	HWND blocked_hwnd;
+ 	unsigned int serial;
  
  	if (!GetWindowRect(hwnd, &rect))
***************
*** 81,85 ****
  
  	WaitForSingleObject(g_mutex, INFINITE);
! 	blocked_hwnd = hwnd;
  	memcpy(&blocked, &g_block_move, sizeof(RECT));
  	ReleaseMutex(g_mutex);
--- 89,94 ----
  
  	WaitForSingleObject(g_mutex, INFINITE);
! 	blocked_hwnd = g_block_move_hwnd;
! 	serial = g_block_move_serial;
  	memcpy(&blocked, &g_block_move, sizeof(RECT));
  	ReleaseMutex(g_mutex);
***************
*** 87,95 ****
  	if ((hwnd == blocked_hwnd) && (rect.left == blocked.left) && (rect.top == blocked.top)
  	    && (rect.right == blocked.right) && (rect.bottom == blocked.bottom))
! 		return;
! 
! 	vchannel_write("POSITION", "0x%p,%d,%d,%d,%d,0x%x",
! 		       hwnd,
! 		       rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0);
  }
  
--- 96,105 ----
  	if ((hwnd == blocked_hwnd) && (rect.left == blocked.left) && (rect.top == blocked.top)
  	    && (rect.right == blocked.right) && (rect.bottom == blocked.bottom))
! 		vchannel_write("ACK", "%u", serial);
! 	else
! 		vchannel_write("POSITION", "0x%p,%d,%d,%d,%d,0x%x",
! 			       hwnd,
! 			       rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
! 			       0);
  }
  
***************
*** 99,104 ****
--- 109,116 ----
  	HWND behind;
  	HWND block_hwnd, block_behind;
+ 	unsigned int serial;
  
  	WaitForSingleObject(g_mutex, INFINITE);
+ 	serial = g_blocked_zchange_serial;
  	block_hwnd = g_blocked_zchange[0];
  	block_behind = g_blocked_zchange[1];
***************
*** 119,125 ****
  
  	if ((hwnd == block_hwnd) && (behind == block_behind))
! 		return;
! 
! 	vchannel_write("ZCHANGE", "0x%p,0x%p,0x%x", hwnd, behind, 0);
  }
  
--- 131,137 ----
  
  	if ((hwnd == block_hwnd) && (behind == block_behind))
! 		vchannel_write("ACK", "%u", serial);
! 	else
! 		vchannel_write("ZCHANGE", "0x%p,0x%p,0x%x", hwnd, behind, 0);
  }
  
***************
*** 299,302 ****
--- 311,316 ----
  		if ((GetActiveWindow() != hwnd) && !parent)
  			SetActiveWindow(hwnd);
+ 
+ 		vchannel_write("ACK", "%u", g_blocked_focus_serial);
  	}
  
***************
*** 317,323 ****
--- 331,339 ----
  				int show, state, blocked;
  				HWND blocked_hwnd;
+ 				unsigned int serial;
  
  				WaitForSingleObject(g_mutex, INFINITE);
  				blocked_hwnd = g_blocked_state_hwnd;
+ 				serial = g_blocked_state_serial;
  				blocked = g_blocked_state;
  				ReleaseMutex(g_mutex);
***************
*** 338,342 ****
  				}
  
! 				if ((blocked_hwnd != (HWND) wparam) || (blocked != state))
  					vchannel_write("STATE", "0x%p,0x%x,0x%x", (HWND) wparam,
  						       state, 0);
--- 354,360 ----
  				}
  
! 				if ((blocked_hwnd == (HWND) wparam) && (blocked == state))
! 					vchannel_write("ACK", "%u", serial);
! 				else
  					vchannel_write("STATE", "0x%p,0x%x,0x%x", (HWND) wparam,
  						       state, 0);
***************
*** 381,388 ****
  
  DLL_EXPORT void
! SafeMoveWindow(HWND hwnd, int x, int y, int width, int height)
  {
  	WaitForSingleObject(g_mutex, INFINITE);
  	g_block_move_hwnd = hwnd;
  	g_block_move.left = x;
  	g_block_move.top = y;
--- 399,425 ----
  
  DLL_EXPORT void
! SafeMoveWindow(unsigned int serial, HWND hwnd, int x, int y, int width, int height)
  {
+ 	RECT rect;
+ 
+ 	vchannel_block();
+ 
+ 	if (!GetWindowRect(hwnd, &rect))
+ 	{
+ 		vchannel_unblock();
+ 		debug("GetWindowRect failed!\n");
+ 		return;
+ 	}
+ 
+ 	if ((rect.left == x) && (rect.top == y) && (rect.right == x + width)
+ 	    && (rect.bottom == y + height))
+ 	{
+ 		vchannel_write("ACK", "%u", serial);
+ 		vchannel_unblock();
+ 	}
+ 
  	WaitForSingleObject(g_mutex, INFINITE);
  	g_block_move_hwnd = hwnd;
+ 	g_block_move_serial = serial;
  	g_block_move.left = x;
  	g_block_move.top = y;
***************
*** 391,394 ****
--- 428,433 ----
  	ReleaseMutex(g_mutex);
  
+ 	vchannel_unblock();
+ 
  	SetWindowPos(hwnd, NULL, x, y, width, height, SWP_NOACTIVATE | SWP_NOZORDER);
  
***************
*** 400,406 ****
  
  DLL_EXPORT void
! SafeZChange(HWND hwnd, HWND behind)
  {
  	WaitForSingleObject(g_mutex, INFINITE);
  	g_blocked_zchange[0] = hwnd;
  	g_blocked_zchange[1] = behind;
--- 439,446 ----
  
  DLL_EXPORT void
! SafeZChange(unsigned int serial, HWND hwnd, HWND behind)
  {
  	WaitForSingleObject(g_mutex, INFINITE);
+ 	g_blocked_zchange_serial = serial;
  	g_blocked_zchange[0] = hwnd;
  	g_blocked_zchange[1] = behind;
***************
*** 419,425 ****
  
  DLL_EXPORT void
! SafeFocus(HWND hwnd)
  {
  	WaitForSingleObject(g_mutex, INFINITE);
  	g_blocked_focus = hwnd;
  	ReleaseMutex(g_mutex);
--- 459,466 ----
  
  DLL_EXPORT void
! SafeFocus(unsigned int serial, HWND hwnd)
  {
  	WaitForSingleObject(g_mutex, INFINITE);
+ 	g_blocked_focus_serial = serial;
  	g_blocked_focus = hwnd;
  	ReleaseMutex(g_mutex);
***************
*** 433,443 ****
  
  DLL_EXPORT void
! SafeSetState(HWND hwnd, int state)
  {
  	WaitForSingleObject(g_mutex, INFINITE);
  	g_blocked_state_hwnd = hwnd;
  	g_blocked_state = state;
  	ReleaseMutex(g_mutex);
  
  	if (state == 0)
  		ShowWindow(hwnd, SW_RESTORE);
--- 474,507 ----
  
  DLL_EXPORT void
! SafeSetState(unsigned int serial, HWND hwnd, int state)
  {
+ 	LONG style;
+ 	int curstate;
+ 
+ 	vchannel_block();
+ 
+ 	style = GetWindowLong(hwnd, GWL_STYLE);
+ 
+ 	if (style & WS_MAXIMIZE)
+ 		curstate = 2;
+ 	else if (style & WS_MINIMIZE)
+ 		curstate = 1;
+ 	else
+ 		curstate = 0;
+ 
+ 	if (state == curstate)
+ 	{
+ 		vchannel_write("ACK", "%u", serial);
+ 		vchannel_unblock();
+ 	}
+ 
  	WaitForSingleObject(g_mutex, INFINITE);
  	g_blocked_state_hwnd = hwnd;
+ 	g_blocked_state_serial = serial;
  	g_blocked_state = state;
  	ReleaseMutex(g_mutex);
  
+ 	vchannel_unblock();
+ 
  	if (state == 0)
  		ShowWindow(hwnd, SW_RESTORE);



-------------------------------------------------------
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