Subject: Solaris Xinerama support

From: Chris Ross <[email-masked]>
Date: Fri, 13 Aug 2004 11:52:01 -0400

Okay.  I don't know how many of you know this, but Solaris ships
an Xsun that has Xinerama support in it (as of the last dist.
of Solaris 7).  *But*, in typical Sun Microsystems style, there
is no Xinerama library, nor header file.

   So, in doing some research, it appears there are a few functions
in libXext, that while providing a totally different API, will
allow the needed access to the Xinerama extension in the server.

   So, I updated acconfig.h, configure.in, fvwm/fvwm.c (which
is an avoidable change, if you want to ignore it), and
libs/FScreen.c.

   Patch for the above is attached.  Should I gen diffs to
configure and config.h.in, or will those get taken care
of (either automatically, or by someone else with the "blessed"
autoconf installation)?

   Thanks...

                            - Chris

Index: acconfig.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/acconfig.h,v
retrieving revision 1.72
diff -u -u -r1.72 acconfig.h
--- acconfig.h	8 Jul 2004 10:08:09 -0000	1.72
+++ acconfig.h	13 Aug 2004 15:31:23 -0000
@@ -32,6 +32,9 @@
 /* Define if Xinerama library is used. */
 #undef HAVE_XINERAMA
 
+/* Define if Solaris' Xinerama calls are being used. */
+#undef HAVE_SOLARIS_XINERAMA
+
 /* Define if Xrender library is used. */
 #undef HAVE_XRENDER
 
Index: configure.in
===================================================================
RCS file: /home/cvs/fvwm/fvwm/configure.in,v
retrieving revision 1.294
diff -u -u -r1.294 configure.in
--- configure.in	23 May 2004 16:20:23 -0000	1.294
+++ configure.in	13 Aug 2004 15:31:23 -0000
@@ -298,9 +298,13 @@
   $UNSET ac_cv_lib_Xinerama_XineramaIsActive
   AC_CHECK_LIB(Xinerama, XineramaIsActive,
     with_xinerama=yes; Xinerama_LIBS=-lXinerama; AC_DEFINE(HAVE_XINERAMA),
+    AC_CHECK_LIB(Xext, XineramaGetState,
+    with_xinerama=yes; Xinerama_LIBS=-lXext; AC_DEFINE(HAVE_XINERAMA)
+    AC_DEFINE(HAVE_SOLARIS_XINERAMA)
+    problem_xinerama=" (Using Solaris Xinerama calls)",
     with_xinerama=no; Xinerama_LIBS=
     problem_xinerama=": Failed to detect libXinerama",
-    [$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS])
+    [$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS]))
 fi
 AC_SUBST(Xinerama_LIBS)
 AC_SUBST(Xinerama_CFLAGS)
Index: fvwm/fvwm.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/fvwm.c,v
retrieving revision 1.368
diff -u -u -r1.368 fvwm.c
--- fvwm/fvwm.c	15 Jul 2004 13:12:28 -0000	1.368
+++ fvwm/fvwm.c	13 Aug 2004 15:31:23 -0000
@@ -1312,6 +1312,9 @@
 	strcat(support_str, " Bidi text,");
 #endif
 #ifdef HAVE_XINERAMA
+# ifdef HAVE_SOLARIS_XINERAMA
+	strcat(support_str, " [Solaris' odd-ball]");
+# endif
 	strcat(support_str, " Xinerama,");
 #endif
 #ifdef HAVE_XRENDER
Index: libs/FScreen.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/libs/FScreen.c,v
retrieving revision 1.22
diff -u -u -r1.22 FScreen.c
--- libs/FScreen.c	17 Mar 2004 14:42:54 -0000	1.22
+++ libs/FScreen.c	13 Aug 2004 15:31:23 -0000
@@ -69,8 +69,54 @@
 #include "PictureBase.h"
 
 #ifdef HAVE_XINERAMA
-#define FScreenHaveXinerama 1
-#include <X11/extensions/Xinerama.h>
+# define FScreenHaveXinerama 1
+# ifdef HAVE_SOLARIS_XINERAMA
+#  include <X11/extensions/xinerama.h>
+typedef struct
+{
+	int   screen_number;
+	short x_org;
+	short y_org;
+	short width;
+	short height;
+} XineramaScreenInfo;
+#  define XineramaIsActive(d)		XineramaGetState((d),0)
+#  define XineramaQueryScreens(d,b)	solaris_XineramaQueryScreens((d),(b))
+#  define XineramaQueryExtension(d,b,c)	1	/* Lie, for now */
+static XineramaScreenInfo *
+solaris_XineramaQueryScreens(Display *d, int *xin_nscreens)
+{
+	XineramaScreenInfo *screens = NULL;
+	XRectangle monitors[MAXFRAMEBUFFERS];
+	unsigned char hints[16];
+
+	int result = XineramaGetInfo(d, DefaultScreen(d), monitors, hints,
+				     xin_nscreens);
+	if (result)
+	{
+		int m;
+
+		screens = (XineramaScreenInfo *)malloc(sizeof(XineramaScreenInfo) * (*xin_nscreens));
+		for (m = 0; m < *xin_nscreens; ++m)
+		{
+			screens[m].screen_number = m;
+			screens[m].x_org = monitors[m].x;
+			screens[m].y_org = monitors[m].y;
+			screens[m].width = monitors[m].width;
+			screens[m].height = monitors[m].height;
+		}
+	}
+	else
+	{
+	    fprintf(stderr, "Error getting Xinerama information\n");
+	    *xin_nscreens = 0;
+	}
+
+	return (screens);
+}
+# else	/* Must be XFree86 Xinerama */
+#  include <X11/extensions/Xinerama.h>
+# endif
 #else
 #define FScreenHaveXinerama 0
 typedef struct

---

From: Chris Ross <[email-masked]>
Date: Fri, 13 Aug 2004 12:45:52 -0400

> is no Xinerama library, nor header file.

   Oops.  I should've mentioned that this patch was tested
with Solaris 8, but will only work on Solaris 8 with
the X11/extensions/xinerama.h header copied from Solaris 9.
Solaris' 9 and 10 ship with this header in place, so
will work with no additional effort.

   That should be noted somewhere, I'm sure.  :-)

                        - Chris
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Dan Espen <[email-masked]>
Date: Sun, 15 Aug 2004 11:10:14 -0400

> will work with no additional effort.

On my Solaris 8 machine without that header, I got:

With Xinerama multi-head support?   yes (Using Solaris Xinerama calls)

In what sense won't it work?

-- 
Dan Espen                           E-mail: [email-masked]

---

From: Dan Espen <[email-masked]>
Date: Sun, 15 Aug 2004 11:44:22 -0400

> In what sense won't it work?

I guess I can answer my own question, it configures but doesn't
compile:

gcc -DHAVE_CONFIG_H -I. -I../../version-2_5_11/libs -I.. -I../../version-2_5_11 -I/opt/public/include  -I/usr/openwin/include      -I/opt/public/include     -g -O2 -Wall -Wno-implicit-int -c ../../version-2_5_11/libs/FScreen.c
../../version-2_5_11/libs/FScreen.c:74: X11/extensions/xinerama.h: No such file or directory

You can send any additional patches to the list.

---

From: Chris Ross <[email-masked]>
Date: Mon, 16 Aug 2004 12:28:38 -0400

> You can send any additional patches to the list.

   I'm not sure what to do to fix that.  I suppose there may
be some way to check for the header in configure, and if
it's not present (Solaris 7 11/99, or Solaris 8) I could
just sub in the contents.  They're quite minimal.

   This seem to objectionable to people?

                        - Chris

---

From: Dan Espen <[email-masked]>
Date: Mon, 16 Aug 2004 13:17:46 -0400

Chris Ross <[email-masked]> writes:
> > gcc -DHAVE_CONFIG_H -I. -I../../version-2_5_11/libs -I.. -I../../version-2_
> 5_11 -I/opt/public/include  -I/usr/openwin/include      -I/opt/public/include
>      -g -O2 -Wall -Wno-implicit-int -c ../../version-2_5_11/libs/FScreen.c

I don't see any problem with Xinerama only working on only Sol 9 or later.
In other words, requiring the header.

Getting compile errors on a default configure on Sol 8 is no good.