RDesktop no-motion improvements

Aus Ethersex_Wiki
Wechseln zu: Navigation, Suche

If I use rdesktop to connect to a Windows Vista Business box the mouse pointers moves rather jerky. Looking around for a solution I stumbled over the -m command line flag. However, if enabled, the local mouse pointer still disappears over the RDP-window, while the remote cursor isn't moved due to the suppressed motion events.

This patch makes sure that the local cursor isn't ever touched. Besides it enables sending of motion events while on of the first three buttons is pressed nonetheless, to account for drag'n'drop etc.

#
# Patch against rdesktop 1.6.0 improving behaviour of the
# `do not send motion events' command line option.
#
# a) Don't touch the local cursor if '-m' is set, i.e. don't make it
#    disappear or the like.
#
# b) Send motion-events if one of the first three mouse buttons is
#    pressed no matter what.  This allows to conveniently drag'n'drop
#    even with -m option being set.
#
Index: rdesktop-1.6.0/rdp5.c
===================================================================
--- rdesktop-1.6.0.orig/rdp5.c	2009-08-13 20:09:45.521923603 +0200
+++ rdesktop-1.6.0/rdp5.c	2009-08-13 20:32:54.390530954 +0200
@@ -24,6 +24,7 @@
 extern uint8 *g_next_packet;
 
 extern RDPCOMP g_mppc_dict;
+extern RD_BOOL g_sendmotion;
 
 void
 rdp5_process(STREAM s)
@@ -95,7 +96,8 @@
 			case 3:	/* update synchronize */
 				break;
 			case 5:	/* null pointer */
-				ui_set_null_cursor();
+				if (g_sendmotion)
+					ui_set_null_cursor();
 				break;
 			case 6:	/* default pointer */
 				break;
Index: rdesktop-1.6.0/rdp.c
===================================================================
--- rdesktop-1.6.0.orig/rdp.c	2009-08-13 20:27:56.017920433 +0200
+++ rdesktop-1.6.0/rdp.c	2009-08-13 20:32:16.742236987 +0200
@@ -52,6 +52,7 @@
 extern RD_BOOL g_bitmap_cache;
 extern RD_BOOL g_bitmap_cache_persist_enable;
 extern RD_BOOL g_numlock_sync;
+extern RD_BOOL g_sendmotion;
 
 uint8 *g_next_packet;
 uint32 g_rdp_shareid;
@@ -1029,7 +1030,12 @@
 	in_uint8p(s, data, datalen);
 	in_uint8p(s, mask, masklen);
 	cursor = ui_create_cursor(x, y, width, height, mask, data);
-	ui_set_cursor(cursor);
+
+	/* Don't really set the cursor if sending of motions is suppressed,
+	   just keep the arrow forever. */
+	if (g_sendmotion)
+		ui_set_cursor(cursor);
+
 	cache_put_cursor(cache_idx, cursor);
 }
 
@@ -1040,7 +1046,11 @@
 	uint16 cache_idx;
 
 	in_uint16_le(s, cache_idx);
-	ui_set_cursor(cache_get_cursor(cache_idx));
+
+	/* Don't really set the cursor if sending of motions is suppressed,
+	   just keep the arrow forever. */
+	if (g_sendmotion)
+		ui_set_cursor(cache_get_cursor(cache_idx));
 }
 
 /* Process a system pointer PDU */
@@ -1053,7 +1063,8 @@
 	switch (system_pointer_type)
 	{
 		case RDP_NULL_POINTER:
-			ui_set_null_cursor();
+			if (g_sendmotion)
+				ui_set_null_cursor();
 			break;
 
 		default:
Index: rdesktop-1.6.0/xwin.c
===================================================================
--- rdesktop-1.6.0.orig/xwin.c	2009-08-13 20:43:39.937924920 +0200
+++ rdesktop-1.6.0/xwin.c	2009-08-13 20:46:14.473917780 +0200
@@ -1976,10 +1976,9 @@
 get_input_mask(long *input_mask)
 {
 	*input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
-		VisibilityChangeMask | FocusChangeMask | StructureNotifyMask;
+		VisibilityChangeMask | FocusChangeMask | StructureNotifyMask | 
+		PointerMotionMask;
 
-	if (g_sendmotion)
-		*input_mask |= PointerMotionMask;
 	if (g_ownbackstore)
 		*input_mask |= ExposureMask;
 	if (g_fullscreen || g_grab_keyboard)
@@ -2374,6 +2373,12 @@
 				break;
 
 			case MotionNotify:
+				if (!g_sendmotion && (xevent.xmotion.state 
+						      & (Button1Mask 
+						         | Button2Mask
+						         | Button3Mask)) == 0)
+					break;
+
 				if (g_moving_wnd)
 				{
 					XMoveWindow(g_display, g_wnd,