Ok, I fixed the bug.

Please see the attached patch (which is the last patch plus the
additional fixes).

I fixed it by adding a nego->flags variable to the NEGO structure that
stored the returned value from the server of
EXTENDED_CLIENT_DATA_SUPPORTED.

This is probably important for other things, as well.

Then, I simply return out of the function if this flag is not set.

-Gadi

On Thu, May 26, 2011 at 11:59 AM, Gideon Romm
<l...@symbio-technologies.com> wrote:
> I don't know if this is useful, but it was to me.
>
> I needed the multi-monitor support as Josh originally attached as a
> diff. But, it did not patch against the latest git pull. So, I
> reworked the code and created a git diff of just the same code he
> submitted.
>
> This is the xinerama-dependent code and not the command line
> xinerama-free code discussed in this thread.
>
> Perhaps this code can be merged while the command line version is
> worked out? This version works great for my needs.
>
> -Gadi
>
> On Tue, Mar 22, 2011 at 10:47 AM, Mike Gilbert <floppymas...@gmail.com> wrote:
>> On Tue, Mar 22, 2011 at 5:22 AM, Jay Sorg <jay.s...@gmail.com> wrote:
>>> I agree.
>>> If configure finds xinerama and -f is used then use all the screens
>>> like the patch.
>>>
>>
>> Please use ac_arg_with or ac_arg_enable to allow manual control of
>> optional dependencies. Gentoo Linux thanks you. :)
>>
>> ------------------------------------------------------------------------------
>> Enable your software for Intel(R) Active Management Technology to meet the
>> growing manageability and security demands of your customers. Businesses
>> are taking advantage of Intel(R) vPro (TM) technology - will your software
>> be a part of the solution? Download the Intel(R) Manageability Checker
>> today! http://p.sf.net/sfu/intel-dev2devmar
>> _______________________________________________
>> Freerdp-devel mailing list
>> Freerdp-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/freerdp-devel
>>
>
>
>
diff --git a/X11/xf_win.c b/X11/xf_win.c
index ba33e01..33906aa 100644
--- a/X11/xf_win.c
+++ b/X11/xf_win.c
@@ -37,6 +37,10 @@
 #include "xf_win.h"
 #include "gdi_color.h"
 
+#ifdef HAVE_LIBXINERAMA
+#include <X11/extensions/Xinerama.h>
+#endif
+
 #define MWM_HINTS_DECORATIONS   (1L << 1)
 #define PROP_MOTIF_WM_HINTS_ELEMENTS    5
 
@@ -1178,6 +1182,12 @@ xf_get_pixmap_info(xfInfo * xfi)
 int
 xf_pre_connect(xfInfo * xfi)
 {
+#ifdef HAVE_LIBXINERAMA
+	XineramaScreenInfo * screen_info = NULL;
+	int ignored, ignored2;
+	int n;
+#endif
+
 	int i1;
 
 	xf_assign_callbacks(xfi->inst);
@@ -1206,8 +1216,34 @@ xf_pre_connect(xfInfo * xfi)
 
 	if (xfi->fs_toggle)
 	{
-		xfi->settings->width = WidthOfScreen(xfi->screen);
-		xfi->settings->height = HeightOfScreen(xfi->screen);
+        	xfi->settings->num_monitors = 0;
+ 		xfi->settings->width = WidthOfScreen(xfi->screen);
+ 		xfi->settings->height = HeightOfScreen(xfi->screen);
+
+#ifdef HAVE_LIBXINERAMA
+		if (XineramaQueryExtension(xfi->display, &ignored, &ignored2))
+		{
+			if (XineramaIsActive(xfi->display))
+			{
+				screen_info = XineramaQueryScreens(xfi->display, &xfi->settings->num_monitors);
+				if (xfi->settings->num_monitors > 16)
+					xfi->settings->num_monitors = 0;
+
+				if (xfi->settings->num_monitors)
+				{
+					for (n = 0; n < xfi->settings->num_monitors; n++)
+					{
+						xfi->settings->monitors[n].x = screen_info[n].x_org;
+						xfi->settings->monitors[n].y = screen_info[n].y_org;
+						xfi->settings->monitors[n].width = screen_info[n].width;
+						xfi->settings->monitors[n].height = screen_info[n].height;
+						xfi->settings->monitors[n].is_primary = screen_info[n].x_org == 0 && screen_info[n].y_org == 0;
+					}
+				}
+				XFree(screen_info);
+			}
+		}
+#endif
 	}
 
 	i1 = xfi->settings->width;
@@ -1220,6 +1256,7 @@ xf_pre_connect(xfInfo * xfi)
 		return 1;
 	}
 
+
 	return 0;
 }
 
diff --git a/configure.ac b/configure.ac
index 75b10e8..317db70 100644
--- a/configure.ac
+++ b/configure.ac
@@ -999,6 +999,19 @@ AS_IF([test "x$with_xkbfile" != xno], [
 ])
 
 #
+# Xinerama
+#
+xinerama="yes"
+AM_CONDITIONAL(WITH_XINERAMA, true)
+AC_PATH_XTRA
+if test "$no_x" = "yes"; then
+	xinerama="no"
+	AM_CONDITIONAL(WITH_XINERAMA, false)
+else
+	AC_CHECK_LIB(Xinerama, XineramaIsActive)
+fi
+
+#
 # DirectFB (optionally built when --with-dfb specified)
 #
 dfb="no"
@@ -1081,4 +1094,5 @@ echo "X11          : $x11"
 echo "XVideo       : $xv"
 echo "xkbfile      : $xkbfile"
 echo "DirectFB     : $dfb"
+echo "Xinerama     : $xinerama"
 echo "Smart card   : $smartcard"
diff --git a/include/freerdp/rdpset.h b/include/freerdp/rdpset.h
index ddbce34..82ab082 100644
--- a/include/freerdp/rdpset.h
+++ b/include/freerdp/rdpset.h
@@ -34,6 +34,15 @@ struct rdp_ext_set
 	void * data; /* plugin data */
 };
 
+struct rdp_monitor
+{
+	int x;
+	int y;
+	int width;
+	int height;
+	int is_primary;
+};
+
 struct rdp_set
 {
 	int width;
@@ -79,6 +88,8 @@ struct rdp_set
 	int num_channels;
 	struct rdp_chan channels[16];
 	struct rdp_ext_set extensions[16];
+	int num_monitors;
+	struct rdp_monitor monitors[16];
 };
 
 #endif
diff --git a/libfreerdp/nego.c b/libfreerdp/nego.c
index e707b89..91b7e17 100644
--- a/libfreerdp/nego.c
+++ b/libfreerdp/nego.c
@@ -223,6 +223,9 @@ void nego_process_negotiation_response(NEGO *nego, STREAM s)
 	in_uint16_le(s, length);
 	in_uint32_le(s, selectedProtocol);
 
+        if (flags == EXTENDED_CLIENT_DATA_SUPPORTED)
+                nego->flags = EXTENDED_CLIENT_DATA_SUPPORTED;
+
 	if (selectedProtocol == PROTOCOL_NLA)
 		nego->selected_protocol = PROTOCOL_NLA;
 	else if (selectedProtocol == PROTOCOL_TLS)
diff --git a/libfreerdp/nego.h b/libfreerdp/nego.h
index e1a5bfc..b63a62d 100644
--- a/libfreerdp/nego.h
+++ b/libfreerdp/nego.h
@@ -45,6 +45,7 @@ struct _NEGO
 	uint32 selected_protocol;
 	uint32 requested_protocols;
 	uint8 enabled_protocols[3];
+	uint8 flags;
 };
 typedef struct _NEGO NEGO;
 
@@ -64,4 +65,5 @@ NEGO* nego_new(rdpIso * iso);
 void nego_init(NEGO *nego);
 void nego_free(NEGO *nego);
 
+#define EXTENDED_CLIENT_DATA_SUPPORTED 0x01
 #endif /* __NEGO_H */
diff --git a/libfreerdp/secure.c b/libfreerdp/secure.c
index c80b36a..8aff83a 100644
--- a/libfreerdp/secure.c
+++ b/libfreerdp/secure.c
@@ -504,6 +504,38 @@ sec_out_client_cluster_data(rdpSec * sec, rdpSet * settings, STREAM s)
 	out_uint32_le(s, sec->rdp->redirect_session_id); /* RedirectedSessionID */
 }
 
+static void
+sec_out_client_monitor_data(rdpSec * sec, rdpSet * settings, STREAM s)
+{
+	int length, n;
+        NEGO *nego = sec->mcs->iso->nego;
+
+	printf("Setting monitor data... num_monitors: %d\n", settings->num_monitors);
+	if (settings->num_monitors <= 1)
+		return;
+
+	if (!(nego->flags & EXTENDED_CLIENT_DATA_SUPPORTED))
+		return;
+
+	DEBUG("Setting monitor data...\n");
+	out_uint16_le(s, UDH_CS_MONITOR);	/* User Data Header type */
+
+	length = 12 + (20 * settings->num_monitors);
+	out_uint16_le(s, length);
+	out_uint32_le(s, 0); /* flags (unused) */
+	out_uint32_le(s, settings->num_monitors); /* monitorCount */
+	for (n = 0; n < settings->num_monitors; n++)
+	{
+		out_uint32_le(s, settings->monitors[n].x); /* left */
+		out_uint32_le(s, settings->monitors[n].y); /* top */
+		out_uint32_le(s, settings->monitors[n].x + 
+						 settings->monitors[n].width-1); /* right */
+		out_uint32_le(s, settings->monitors[n].y +
+						 settings->monitors[n].height-1); /* bottom */
+		out_uint32_le(s, settings->monitors[n].is_primary ? 1 : 0); /* isPrimary */
+	}
+}
+
 void
 sec_out_gcc_conference_create_request(rdpSec * sec, STREAM s)
 {
@@ -518,6 +550,7 @@ sec_out_gcc_conference_create_request(rdpSec * sec, STREAM s)
 	sec_out_client_cluster_data(sec, settings, s);
 	sec_out_client_security_data(sec, settings, s);
 	sec_out_client_network_data(sec, settings, s);
+	sec_out_client_monitor_data(sec, settings, s);
 	length = (s->p - s->data) - 23;
 	s->p = s->data;
 
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Freerdp-devel mailing list
Freerdp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freerdp-devel

Reply via email to