CVS: seamlessrdp/ServerExe main.c,1.30,1.31 vchannel.h,1.8,1.9

Pierre Ossman <[email protected]> Wed, 22 Mar 2006 08:19:43 -0800
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/seamlessrdp/ServerExe
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24774/ServerExe

Modified Files:
	main.c vchannel.h 
Log Message:
Detect when another desktop is activated and tell the connected client.


Index: main.c
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/main.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** main.c	22 Mar 2006 13:32:01 -0000	1.30
--- main.c	22 Mar 2006 16:19:41 -0000	1.31
***************
*** 51,54 ****
--- 51,56 ----
  static int g_startup_num_procs;
  
+ static BOOL g_desktop_hidden;
+ 
  typedef void (*set_hooks_proc_t) ();
  typedef void (*remove_hooks_proc_t) ();
***************
*** 235,243 ****
  		if (wparam == WTS_REMOTE_CONNECT)
  		{
  			/* These get reset on each reconnect */
  			SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, TRUE, NULL, 0);
  			SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0);
  			SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, 0);
! 			vchannel_write("HELLO", "0x%08x", 1);
  		}
  	}
--- 237,250 ----
  		if (wparam == WTS_REMOTE_CONNECT)
  		{
+ 			int flags;
  			/* These get reset on each reconnect */
  			SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, TRUE, NULL, 0);
  			SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0);
  			SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, 0);
! 
! 			flags = SEAMLESS_HELLO_RECONNECT;
! 			if (g_desktop_hidden)
! 				flags |= SEAMLESS_HELLO_HIDDEN;
! 			vchannel_write("HELLO", "0x%08x", flags);
  		}
  	}
***************
*** 358,361 ****
--- 365,383 ----
  }
  
+ static BOOL
+ is_desktop_hidden(void)
+ {
+ 	HDESK desk;
+ 
+ 	/* We cannot get current desktop. But we can try to open the current
+ 	   desktop, which will most likely be a secure desktop (if it isn't
+ 	   ours), and will thus fail. */
+ 	desk = OpenInputDesktop(0, FALSE, GENERIC_READ);
+ 	if (desk)
+ 		CloseDesktop(desk);
+ 
+ 	return desk == NULL;
+ }
+ 
  int WINAPI
  WinMain(HINSTANCE instance, HINSTANCE prev_instance, LPSTR cmdline, int cmdshow)
***************
*** 415,419 ****
  	vchannel_open();
  
! 	vchannel_write("HELLO", "0x%08x", 0);
  
  	set_hooks_fn();
--- 437,443 ----
  	vchannel_open();
  
! 	g_desktop_hidden = is_desktop_hidden();
! 
! 	vchannel_write("HELLO", "0x%08x", g_desktop_hidden ? SEAMLESS_HELLO_HIDDEN : 0);
  
  	set_hooks_fn();
***************
*** 458,462 ****
--- 482,498 ----
  			{
  				if (check_counter < 0)
+ 				{
+ 					BOOL hidden;
+ 
+ 					hidden = is_desktop_hidden();
+ 					if (hidden && !g_desktop_hidden)
+ 						vchannel_write("HIDE", "0x%08x", 0);
+ 					else if (!hidden && g_desktop_hidden)
+ 						vchannel_write("UNHIDE", "0x%08x", 0);
+ 
+ 					g_desktop_hidden = hidden;
+ 
  					check_counter = 5;
+ 				}
  
  				while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))

Index: vchannel.h
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/vchannel.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** vchannel.h	21 Mar 2006 14:38:38 -0000	1.8
--- vchannel.h	22 Mar 2006 16:19:41 -0000	1.9
***************
*** 29,32 ****
--- 29,35 ----
  #define SEAMLESS_CREATE_MODAL	0x0001
  
+ #define SEAMLESS_HELLO_RECONNECT	0x0001
+ #define SEAMLESS_HELLO_HIDDEN		0x0002
+ 
  DLL_EXPORT void debug(char *format, ...);
  



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