[ rdesktop-Bugs-1198931 ] Translucent cursors don't show up locally

"SourceForge.net" <[email protected]>
Newsgroups gmane.network.rdesktop.devel
Message-ID <[email protected]>
Bugs item #1198931, was opened at 2005-05-10 06:43
Message generated for change (Comment added) made by warrenfalk
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=381347&aid=1198931&group_id=24366

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jernej Simončič (jernejs)
Assigned to: Ilya Konstantinov (ikonst)
Summary: Translucent cursors don't show up locally

Initial Comment:
I'm occassionally connecting to a server that uses some cursors with 
alpha transparency. On Windows these cursors are brought over and 
used locally when using 256-color mode (so the mouse motion is 
smoorh; in 15-bit and higher modes RDP on Windows behaves the 
same as RDesktop). RDesktop never displays the cursors locally, but 
always uses the image from server, making the mouse motion jerky.

----------------------------------------------------------------------

Comment By: Warren Falk (warrenfalk)
Date: 2011-02-04 15:09

Message:
Here's a patch to trunk to enable this with the Xcursor library.  I was
going to add this as an attachment to the bug but see no way to do it
(using Chrome).  Does that need special access, or is sourceforge broken?


Index: Makefile.in
===================================================================
--- Makefile.in (revision 1609)
+++ Makefile.in (working copy)
@@ -35,7 +35,7 @@
 all: $(TARGETS)

 rdesktop: $(X11OBJ) $(SOUNDOBJ) $(RDPOBJ) $(SCARDOBJ)
-       $(CC) $(CFLAGS) -o rdesktop $(X11OBJ) $(SOUNDOBJ) $(RDPOBJ)
$(SCARDOBJ) $(LDFLAGS) -lX11
+       $(CC) $(CFLAGS) -o rdesktop $(X11OBJ) $(SOUNDOBJ) $(RDPOBJ)
$(SCARDOBJ) $(LDFLAGS) -lX11 -lXcolor

 rdp2vnc: $(VNCOBJ) $(SOUNDOBJ) $(RDPOBJ) $(SCARDOBJ)
        $(VNCLINK) $(CFLAGS) -o rdp2vnc $(VNCOBJ) $(SOUNDOBJ) $(RDPOBJ)
$(SCARDOBJ) $(LDFLAGS) $(LDVNC)
Index: xwin.c
===================================================================
--- xwin.c	(revision 1609)
+++ xwin.c	(working copy)
@@ -21,6 +21,7 @@
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include <X11/Xproto.h>
+#include <X11/Xcursor/Xcursor.h>
 #include <unistd.h>
 #include <sys/time.h>
 #include <time.h>
@@ -2853,7 +2854,7 @@
 			break;
 		case 32:
 			s8 = xormask + *k;
-			rv = (s8[1] << 16) | (s8[2] << 8) | s8[3];
+			rv = (s8[0] << 24) | (s8[1] << 16) | (s8[2] << 8) | s8[3];
 			(*k) += 4;
 			break;
 		default:
@@ -2875,16 +2876,13 @@
 	uint8 nextbit;
 	int scanline, offset, delta;
 	int i, j, k;
+	int pixel;
+	XcursorImage* pxc;
 
 	k = 0;
 	scanline = (width + 7) / 8;
 	offset = scanline * height;
 
-	cursor = (uint8 *) xmalloc(offset);
-	memset(cursor, 0, offset);
-
-	mask = (uint8 *) xmalloc(offset);
-	memset(mask, 0, offset);
 	if (bpp == 1)
 	{
 		offset = 0;
@@ -2895,50 +2893,86 @@
 		offset = scanline * height - scanline;
 		delta = -scanline;
 	}
-	/* approximate AND and XOR masks with a monochrome X pointer */
-	for (i = 0; i < height; i++)
+	if (bpp == 32)
 	{
-		pcursor = &cursor[offset];
-		pmask = &mask[offset];
+		pxc = XcursorImageCreate(width, height);
+		pxc->xhot = x;
+		pxc->yhot = y;
+		for (i = 0; i < height; i++)
+		{
+			nextbit = 0x80;
+			for (j = 0; j < width; j++)
+			{
+				pixel = get_next_xor_pixel(xormask, bpp, &k);
+				pixel = ((pixel & 0xFF) << 24) | ((pixel & 0xFF00) << 8) | ((pixel &
0xFF0000) >> 8) | ((pixel & 0xFF000000) >> 24);
+				/* The following will use the bit mask (lower quality) instead of
alpha */
+				/* 
+				maskpx = (*andmask & nextbit) ? 0x00000000 : 0xff000000; 
+				nextbit >>= 1;
+				if (nextbit == 0) {
+					nextbit = 0x80;
+					andmask++;
+				}
+				pixel = pixel & 0xFFFFFF | maskpx;
+				*/
+				pxc->pixels[(height - i - 1) * width + j] = pixel;
+			}
+		}
+		xcursor = XcursorImageLoadCursor (g_display, pxc);
+	}
+	else
+	{
+		cursor = (uint8 *) xmalloc(scanline * height);
+		memset(cursor, 0, scanline * height);
 
-		for (j = 0; j < scanline; j++)
+		mask = (uint8 *) xmalloc(scanline * height);
+		memset(mask, 0, scanline * height);
+		
+		/* approximate AND and XOR masks with a monochrome X pointer */
+		for (i = 0; i < height; i++)
 		{
-			for (nextbit = 0x80; nextbit != 0; nextbit >>= 1)
+			pcursor = &cursor[offset];
+			pmask = &mask[offset];
+
+			for (j = 0; j < scanline; j++)
 			{
-				if (get_next_xor_pixel(xormask, bpp, &k))
+				for (nextbit = 0x80; nextbit != 0; nextbit >>= 1)
 				{
-					*pcursor |= (~(*andmask) & nextbit);
-					*pmask |= nextbit;
+					if (get_next_xor_pixel(xormask, bpp, &k))
+					{
+						*pcursor |= (~(*andmask) & nextbit);
+						*pmask |= nextbit;
+					}
+					else
+					{
+						*pcursor |= ((*andmask) & nextbit);
+						*pmask |= (~(*andmask) & nextbit);
+					}
 				}
-				else
-				{
-					*pcursor |= ((*andmask) & nextbit);
-					*pmask |= (~(*andmask) & nextbit);
-				}
+
+				andmask++;
+				pcursor++;
+				pmask++;
 			}
-
-			andmask++;
-			pcursor++;
-			pmask++;
+			offset += delta;
 		}
-		offset += delta;
-	}
 
-	fg.red = fg.blue = fg.green = 0xffff;
-	bg.red = bg.blue = bg.green = 0x0000;
-	fg.flags = bg.flags = DoRed | DoBlue | DoGreen;
+		fg.red = fg.blue = fg.green = 0xffff;
+		bg.red = bg.blue = bg.green = 0x0000;
+		fg.flags = bg.flags = DoRed | DoBlue | DoGreen;
 
-	cursorglyph = ui_create_glyph(width, height, cursor);
-	maskglyph = ui_create_glyph(width, height, mask);
+		cursorglyph = ui_create_glyph(width, height, cursor);
+		maskglyph = ui_create_glyph(width, height, mask);
 
-	xcursor =
-		XCreatePixmapCursor(g_display, (Pixmap) cursorglyph,
-				    (Pixmap) maskglyph, &fg, &bg, x, y);
+		xcursor =
+			XCreatePixmapCursor(g_display, (Pixmap) cursorglyph,
+						(Pixmap) maskglyph, &fg, &bg, x, y);
 
-	ui_destroy_glyph(maskglyph);
-	ui_destroy_glyph(cursorglyph);
-	xfree(mask);
-	xfree(cursor);
+		ui_destroy_glyph(maskglyph);
+		ui_destroy_glyph(cursorglyph);
+		xfree(mask);
+		xfree(cursor);
+	}
 	return (RD_HCURSOR) xcursor;
 }
 


----------------------------------------------------------------------

Comment By: Jernej Simončič (jernejs)
Date: 2005-11-04 01:46

Message:
Logged In: YES 
user_id=632674

Translucent cursors work on Windows MSTSC, but only in 
256-color mode (in 15bit and higher modes they're rendered 
on server and thus lagging). I attached a cursor that uses 
translucency.


----------------------------------------------------------------------

Comment By: Jeroen Meijer (jdmeijer)
Date: 2005-11-03 16:07

Message:
Logged In: YES 
user_id=850718

Here's a patch that handles colour cursors using XRender (if
available). I don't understand how to write a configure
check, which is why I haven't included this in CVS yet.
Maybe someone can help me writing a configure check for XRender?

However I don't think there's support for translucent
cursors in RDP5.

----------------------------------------------------------------------

Comment By: Ilya Konstantinov (ikonst)
Date: 2005-11-03 07:02

Message:
Logged In: YES 
user_id=335423

Currently we use XCreatePixmapCursor which only accepts 1bpp
(black and white) pixmaps. I guess we'd have to use
XRenderCreateCursor when available... but do we even receive
the colorful cursor from RDP? process_colour_pointer_pdu
hints so, but we treat its 'data' chunk as a XOR mask of
some sort...

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=381347&aid=1198931&group_id=24366

------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
rdesktop-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdesktop-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.