CVS: rdesktop xclip.c,1.35,1.36

Pierre Ossman <[email protected]> Mon, 27 Mar 2006 05:03:31 -0800
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21306

Modified Files:
	xclip.c 
Log Message:
Examine the magic root window property on startup so that we correctly handle
when another rdesktop owns the clipboard when we start.


Index: xclip.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/xclip.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** xclip.c	27 Mar 2006 12:29:29 -0000	1.35
--- xclip.c	27 Mar 2006 13:03:27 -0000	1.36
***************
*** 248,251 ****
--- 248,280 ----
  }
  
+ /* Examines the special root window property that contains the native Windows
+    formats if another rdesktop process owns the clipboard. */
+ static void
+ xclip_get_root_property()
+ {
+ 	unsigned long nitems;
+ 	unsigned long bytes_left;
+ 	int format, res;
+ 	uint8 *data;
+ 	Atom type;
+ 
+ 	res = XGetWindowProperty(g_display, DefaultRootWindow(g_display),
+ 				 rdesktop_clipboard_formats_atom, 0,
+ 				 XMaxRequestSize(g_display), False, XA_STRING,
+ 				 &type, &format, &nitems, &bytes_left, &data);
+ 
+ 	if ((res == Success) && (nitems > 0))
+ 	{
+ 		DEBUG_CLIPBOARD(("xclip_get_root_property: got fellow rdesktop formats\n"));
+ 		cliprdr_send_native_format_announce(data, nitems);
+ 		rdesktop_is_selection_owner = 1;
+ 		return;
+ 	}
+ 
+ 	/* For some reason, we couldn't announce the native formats */
+ 	cliprdr_send_simple_native_format_announce(RDP_CF_TEXT);
+ 	rdesktop_is_selection_owner = 0;
+ }
+ 
  /* Wrapper for cliprdr_send_data which also cleans the request state. */
  static void
***************
*** 706,710 ****
  	unsigned long offset = 0;
  	unsigned long bytes_left = 1;
! 	int format, res;
  	XWindowAttributes wa;
  	uint8 *data;
--- 735,739 ----
  	unsigned long offset = 0;
  	unsigned long bytes_left = 1;
! 	int format;
  	XWindowAttributes wa;
  	uint8 *data;
***************
*** 767,792 ****
  	    (event->window == DefaultRootWindow(g_display)) &&
  	    !have_primary /* not interested in our own events */ )
! 	{
! 		if (event->state == PropertyNewValue)
! 		{
! 			DEBUG_CLIPBOARD(("xclip_handle_PropertyNotify: getting fellow rdesktop formats\n"));
! 
! 			res = XGetWindowProperty(g_display, DefaultRootWindow(g_display),
! 						 rdesktop_clipboard_formats_atom, 0,
! 						 XMaxRequestSize(g_display), False, XA_STRING,
! 						 &type, &format, &nitems, &bytes_left, &data);
! 
! 			if ((res == Success) && (nitems > 0))
! 			{
! 				cliprdr_send_native_format_announce(data, nitems);
! 				rdesktop_is_selection_owner = 1;
! 				return;
! 			}
! 		}
! 
! 		/* For some reason, we couldn't announce the native formats */
! 		cliprdr_send_simple_native_format_announce(RDP_CF_TEXT);
! 		rdesktop_is_selection_owner = 0;
! 	}
  }
  #endif
--- 796,800 ----
  	    (event->window == DefaultRootWindow(g_display)) &&
  	    !have_primary /* not interested in our own events */ )
! 		xclip_get_root_property();
  }
  #endif
***************
*** 968,972 ****
  ui_clip_sync(void)
  {
! 	cliprdr_send_simple_native_format_announce(RDP_CF_TEXT);
  }
  
--- 976,980 ----
  ui_clip_sync(void)
  {
! 	xclip_get_root_property();
  }
  



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