Add basic Xinerama support via new lib/DtXinerama
authorJon Trulson <jon@radscan.com>
Wed, 27 Mar 2013 01:49:50 +0000 (19:49 -0600)
committerJon Trulson <jon@radscan.com>
Wed, 27 Mar 2013 01:49:50 +0000 (19:49 -0600)
This adds a basic library and support to dtsession and dtlogin to
support Xinerama/Twinview, where multimple monitors are used to make
up an X11 screen.

The main goal here is to draw dialogs and such centered on a monitor,
rather than spread out over multiple monitors.

Might need to add sorting - as on my test system, what I would
consider monitor 0, appears to actually be monitor 1.  So a sort might
need to be added to sort the screens according to increasing x and y
offsets so it make sense to a user.

Also, this library is built statically and not documented.  Maybe it
could be 'filled' out and refactored/redesigned in the futre if need
be and suppoerted.

It is enabled via a define, CDE_USEXINERAMA in site.def.  It's a very
simple lib, so I do not expect any issues with the BSD's - it should
build and work fine, assuming your X server has the XINERAMA
extension, which I think pretty much all of them do at this point.

19 files changed:
cde/config/cf/site.def
cde/lib/DtXinerama/DtXinerama.c [new file with mode: 0644]
cde/lib/DtXinerama/DtXinerama.h [new file with mode: 0644]
cde/lib/DtXinerama/Imakefile [new file with mode: 0644]
cde/lib/Imakefile
cde/programs/dtlogin/Imakefile
cde/programs/dtlogin/config/Xresources.src
cde/programs/dtlogin/dtchooser.c
cde/programs/dtlogin/vg.h
cde/programs/dtlogin/vgcallback.c
cde/programs/dtlogin/vgmain.c
cde/programs/dtsession/Dtsession.src
cde/programs/dtsession/Imakefile
cde/programs/dtsession/Sm.h
cde/programs/dtsession/SmGlobals.c
cde/programs/dtsession/SmMain.c
cde/programs/dtsession/SmResource.h
cde/programs/dtsession/SmStrDefs.c
cde/programs/dtsession/SmUI.c

index 4dce9f0e8b8c55fb6161f00a65a81d0f949fc69b..361166b840175e7d1dec53f3723f3e3eb3d8c3de 100644 (file)
@@ -82,6 +82,9 @@ XCOMM site:  $TOG: site.def /main/23 1998/03/19 18:43:26 mgreess $
 # define ProjectRoot   /usr/dt
 #endif
 
+XCOMM build the DtXinerama support
+#define CDE_USEXINERAMA         YES
+
 #ifdef SunArchitecture
 # define DtLocalesToBuild de_DE.ISO8859-1 es_ES.ISO8859-1 fr_FR.ISO8859-1 it_IT.ISO8859-1
 #endif
diff --git a/cde/lib/DtXinerama/DtXinerama.c b/cde/lib/DtXinerama/DtXinerama.c
new file mode 100644 (file)
index 0000000..a2d2a64
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * CDE - Common Desktop Environment
+ *
+ * Copyright (c) 1993-2013, The Open Group. All rights reserved.
+ *
+ * These libraries and programs are free software; you can
+ * redistribute them and/or modify them under the terms of the GNU
+ * Lesser General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * These libraries and programs are distributed in the hope that
+ * they will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with these librararies and programs; if not, write
+ * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA 02110-1301 USA
+ */
+/*
+ * Jon Trulson, Xi Graphics 4/11/2001
+ *
+ * $XiGId: DtXinerama.c,v 1.1 2001/04/12 03:01:14 jon Exp $
+ *
+ * A Xinerama wrapper for CDE
+ *
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <X11/Xlib.h>
+
+#include "DtXinerama.h"
+
+/* return a DtXineramaInfo_t (or NULL if no Xinerama) available */
+
+DtXineramaInfo_t *_DtXineramaInit(Display *dpy)
+{
+  DtXineramaInfo_t *tmpDtXI = NULL;
+  XineramaScreenInfo *XinerScrnInfo = NULL;
+  int number = 0;
+
+  if (!dpy)
+    return(NULL);
+
+  XinerScrnInfo = XineramaQueryScreens(dpy, &number);
+
+  if (number <= 0 || XinerScrnInfo == NULL) /* then we don't have it */
+    return(NULL);
+
+                               /* allocate some space for it */
+  if ((tmpDtXI = (DtXineramaInfo_t *)malloc(sizeof(DtXineramaInfo_t))) == NULL)
+    {                          /* malloc failure */
+#ifdef DEBUG
+      fprintf(stderr, "_DtXineramaInit: malloc failed\n");
+#endif
+      
+      free(XinerScrnInfo);
+      return(NULL);
+    }
+
+  tmpDtXI->numscreens = number;
+  tmpDtXI->ScreenInfo = XinerScrnInfo;
+
+  return(tmpDtXI);
+}
+
+
+/* Return w, h, xorg, and yorg for the specified screen.  Return True */
+/* if a valid screen, False otherwise */
+Bool _DtXineramaGetScreen(DtXineramaInfo_t *DtXI, unsigned int screen,
+                         unsigned int *w, unsigned int *h, 
+                         unsigned int *xorg, unsigned int *yorg)
+{
+
+  if (DtXI == NULL)
+    return(False);
+
+  if (DtXI->numscreens == 0)
+    return(False);             /* no screens or no Xinerama */
+
+  if (screen < 0 || screen >= DtXI->numscreens)
+    return(False);             /* invalid screen */
+
+                               /* now get the info from the XinerInfo */
+                               /* struct and return it */
+
+  if (w != NULL)
+    *w = (DtXI->ScreenInfo[screen]).width;
+  if (h != NULL)
+    *h = (DtXI->ScreenInfo[screen]).height;
+  if (xorg != NULL)
+    *xorg = (DtXI->ScreenInfo[screen]).x_org;
+  if (yorg != NULL)
+    *yorg = (DtXI->ScreenInfo[screen]).y_org;
+
+  return(True);
+}
+  
diff --git a/cde/lib/DtXinerama/DtXinerama.h b/cde/lib/DtXinerama/DtXinerama.h
new file mode 100644 (file)
index 0000000..0f119e8
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * CDE - Common Desktop Environment
+ *
+ * Copyright (c) 1993-2013, The Open Group. All rights reserved.
+ *
+ * These libraries and programs are free software; you can
+ * redistribute them and/or modify them under the terms of the GNU
+ * Lesser General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * These libraries and programs are distributed in the hope that
+ * they will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with these librararies and programs; if not, write
+ * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA 02110-1301 USA
+ */
+/*
+ * Jon Trulson, Xi Graphics 4/11/2001
+ *
+ * $XiGId: DtXinerama.h,v 1.1 2001/04/12 03:01:14 jon Exp $
+ *
+ * A Xinerama wrapper for CDE
+ *
+ */
+
+#ifndef DTXINERAMA_H_INCLUDED
+#define DTXINERAMA_H_INCLUDED
+
+#include <stdio.h>
+#include <X11/Xfuncs.h>
+
+#include <X11/extensions/Xinerama.h>
+
+typedef struct _DtXineramaInfo 
+{
+  int numscreens;      
+  XineramaScreenInfo *ScreenInfo;
+} DtXineramaInfo_t, *DtXineramaInfoPtr_t;
+
+
+DtXineramaInfo_t *_DtXineramaInit(Display *dpy);
+Bool _DtXineramaGetScreen(DtXineramaInfo_t *, unsigned int screen,
+                         unsigned int *w, unsigned int *h, 
+                         unsigned int *xorg, unsigned int *yorg);
+
+#endif /* DTXINERAMA_H_INCLUDED */
diff --git a/cde/lib/DtXinerama/Imakefile b/cde/lib/DtXinerama/Imakefile
new file mode 100644 (file)
index 0000000..21837dc
--- /dev/null
@@ -0,0 +1,43 @@
+XCOMM 
+XCOMM CDE - Common Desktop Environment
+XCOMM
+XCOMM Copyright (c) 1993-2013, The Open Group. All rights reserved.
+XCOMM
+XCOMM These libraries and programs are free software; you can
+XCOMM redistribute them and/or modify them under the terms of the GNU
+XCOMM Lesser General Public License as published by the Free Software
+XCOMM Foundation; either version 2 of the License, or (at your option)
+XCOMM any later version.
+XCOMM
+XCOMM These libraries and programs are distributed in the hope that
+XCOMM they will be useful, but WITHOUT ANY WARRANTY; without even the
+XCOMM implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+XCOMM PURPOSE. See the GNU Lesser General Public License for more
+XCOMM details.
+XCOMM
+XCOMM You should have received a copy of the GNU Lesser General Public
+XCOMM License along with these librararies and programs; if not, write
+XCOMM to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+XCOMM Floor, Boston, MA 02110-1301 USA
+XCOMM
+
+#define DoNormalLib   YES
+#define DoSharedLib   NO
+#define DoDebugLib    NO
+#define DoProfileLib  NO
+#define HasSharedData NO
+#define LibName       DtXinerama
+#define LibHeaders    YES
+
+HEADERS = DtXinerama.h
+
+SRCS = DtXinerama.c
+
+OBJS = DtXinerama.o
+
+#include <Library.tmpl>
+
+INCLUDES = -I.
+
+DependTarget()
+
index 595cff36882b03e2cd4bedd95a1c3d5f9a0cad8d..2d0bfac8d0d6d093985a8208eecf16892c58dd8d 100644 (file)
@@ -2,13 +2,18 @@ XCOMM $XConsortium: Imakefile /main/12 1996/04/24 14:31:52 lehors $
 #define IHaveSubdirs
 #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
 
+#if CDE_USEXINERAMA
+XINDIR = DtXinerama
+#endif
+
 #if defined(UsePamLibrary) && UsePamLibrary
 PAMDIR = pam
 #else
 PAMDIR =
 #endif
 
-SUBDIRS = $(PAMDIR) tt DtSvc DtSearch DtWidget DtHelp DtPrint DtTerm DtMrm csa
+SUBDIRS = $(PAMDIR) tt DtSvc DtSearch DtWidget DtHelp DtPrint DtTerm DtMrm \
+       csa $(XINDIR)
 
 MakeSubdirs($(SUBDIRS))
 DependSubdirs($(SUBDIRS))
index 33dc6f99aff67242099ea4dae18fd2f097979e9d..227a746218289c10f60c3653ba1806e3abb3eab4 100644 (file)
@@ -4,6 +4,11 @@ XCOMM $TOG: Imakefile /main/21 1999/03/01 18:26:06 mgreess $
 
 SUBDIRS = config $(XDMSUBDIRS) $(BLSSUBDIRS) $(AFSSUBDIRS)
 
+#if CDE_USEXINERAMA
+XINOPT = -DUSE_XINERAMA
+XINLIB = -lDtXinerama -lXinerama
+#endif
+
 MakeSubdirs($(SUBDIRS))
 DependSubdirs($(SUBDIRS))
 
@@ -122,6 +127,8 @@ SYS_LIBRARIES = -lm -lXdmcp
 
 #if defined(LinuxArchitecture) || defined(FreeBSDArchitecture)
 SYS_LIBRARIES = -lm -lcrypt
+EXTRA_DEFINES = $(XINOPT)
+LOGINXLIB = $(XLIB) $(XINLIB)
 /* just use the system provided Xau and Xdmcp*/
 DEPXAUTHLIB = 
 DEPXDMCPLIB = 
@@ -293,9 +300,9 @@ EXTRA_RES_DEFINES = \
 
     BASE_LIBS1  = $(XAUTHLIB) $(LOGINXMULIB) $(XDMCPLIB) $(LOGINXLIB)
     BASE_LIBS2  = $(DTWIDGETLIB) $(DTSVCLIB) $(TTLIB) $(XMLIB) \
-                 $(XTOOLLIB) $(XPLIB) $(XLIB)
+                 $(XTOOLLIB) $(XPLIB) $(XLIB) $(XINLIB)
     BASE_LIBS3  = $(DTWIDGETLIB) $(DTSVCLIB) $(TTLIB) $(XDMCPLIB) $(XMLIB) \
-                 $(XTOOLLIB) $(XPLIB) $(XLIB)
+                 $(XTOOLLIB) $(XPLIB) $(XLIB) $(XINLIB)
 
     LOCAL_LIBRARIES1 = $(BASE_LIBS1) $(IAFSYSLIB)
     LOCAL_LIBRARIES2 = $(BASE_LIBS2)
index 94f0e810cd6866b224cab43c72361d040a1d7abf..9930c982d08379d40d0d3a537053dc7bb4ba781f 100644 (file)
@@ -121,6 +121,17 @@ Dtlogin*MessageBox*labelFontList: %|nls-1-#labelFont#|
 XCOMM endif
 
 
+!!######################################################################
+!!
+!!  XINERAMA
+!!
+!!      Set this to the screen number where you would like the login
+!!      dialogs to show up in a Xinerama configuration.
+
+
+Dtlogin*xineramaPreferredScreen:       0
+
+
 !!######################################################################
 !!
 !!  CURSOR
index a2f24537099867671ebf48504a45c6d8374125e5..a6bc58a4a84d3be34a5d3fc85d474af52fee5d3c 100644 (file)
@@ -89,8 +89,9 @@
 #include       "vgmsg.h"
 #include        <Dt/MenuButton.h>
 
-
-
+#ifdef USE_XINERAMA
+#include <DtXinerama.h>
+#endif
 
 
 /***************************************************************************
@@ -264,6 +265,13 @@ static
        XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageList),
        XtRString, NULL                                                 },
 
+#if defined(USE_XINERAMA)
+    { "xineramaPreferredScreen",        "XineramaPreferredScreen",
+        XtRInt, sizeof(int), XtOffset(AppInfoPtr, xineramaPreferredScreen),
+        XtRImmediate, (XtPointer) 0
+        },
+#endif
+
 #if defined (ENABLE_DYNAMIC_LANGLIST)
     {"languageListCmd", "LanguageListCmd",
         XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageListCmd),
@@ -662,8 +670,9 @@ MakeDialog( DialogType dtype )
     Widget     w, text;
     Dimension  txt_width, txt_height;
     XmString   ok, cancel, nw, sv;
-    
-    
+
+    Widget      tlev;
+
     /*
      *  do things common to all dialogs...
      */
@@ -684,13 +693,25 @@ MakeDialog( DialogType dtype )
      *  create the various dialogs...
      */
 
+    /* JET - check the matte widget, and if non-null, well use that as
+     * the parent for dialogs.  Otherwise use table (the original
+     * toplevel widget for this func).  This is useful for Xinerama so
+     * that child dialogs are centered on the matte, and not the whole
+     * SLS screen.
+     */
+    if (matte != (Widget)NULL)
+      tlev = matte;
+    else
+      tlev = table;
+
+
     switch (dtype) {
 
     case error:
        xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, "");
        XtSetArg(argt[i], XmNmessageString,             xmstr           ); i++;
 
-       w = XmCreateErrorDialog(table, "error_message", argt, i);
+       w = XmCreateErrorDialog(tlev, "error_message", argt, i);
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
 
@@ -701,7 +722,7 @@ MakeDialog( DialogType dtype )
     case help:
        xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
        XtSetArg(argt[i], XmNmessageString,             xmstr           ); i++;
-       w = XmCreateInformationDialog(table, "help_message", argt, i);
+       w = XmCreateInformationDialog(tlev, "help_message", argt, i);
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
         XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
 
@@ -754,7 +775,7 @@ MakeDialog( DialogType dtype )
        fclose(fp);
        XtSetArg(argt[i], XmNmessageString,             xmstr           ); i++;
 
-       w = XmCreateInformationDialog(table, "copyright_msg", argt, i);
+       w = XmCreateInformationDialog(tlev, "copyright_msg", argt, i);
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
        
@@ -774,7 +795,7 @@ MakeDialog( DialogType dtype )
        XtSetArg(argt[i], XmNokLabelString,             nw              ); i++;
        XtSetArg(argt[i], XmNcancelLabelString,         sv              ); i++;
 
-       w = XmCreateWarningDialog(table, "hostname_msg", argt, i);
+       w = XmCreateWarningDialog(tlev, "hostname_msg", argt, i);
 
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
 
@@ -791,7 +812,7 @@ MakeDialog( DialogType dtype )
                            MC_DEF_PASSWD_EXPIRED);
        XtSetArg(argt[i], XmNmessageString,             xmstr           ); i++;
 
-       w = XmCreateQuestionDialog(table, "password_msg", argt, i);
+       w = XmCreateQuestionDialog(tlev, "password_msg", argt, i);
 
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
 
@@ -802,7 +823,7 @@ MakeDialog( DialogType dtype )
     case help_chooser:
        xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);
 
-       w = XmCreateInformationDialog(table, "help_message", argt, i);
+       w = XmCreateInformationDialog(tlev, "help_message", argt, i);
         XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
         XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
 
index 7fc895a7584d0fbf5df960ab893bd3344177388b..e31a62649f7bebca02336e571df1af65d7c9bb95 100644 (file)
@@ -66,6 +66,9 @@ extern int errno;
 #    include <sys/security.h>
 #endif
 
+#ifdef USE_XINERAMA
+# include <DtXinerama.h>
+#endif
 
 #ifdef SIGNALRETURNSINT
 #define SIGVAL int
@@ -264,6 +267,9 @@ typedef struct {
     char       *languageList;  /* list of languages to display in menu    */
     int        unitType;       /* widgets' unit type                      */
     char        *languageListCmd; /* command to produce language list      */
+#if defined(USE_XINERAMA)
+    int         xineramaPreferredScreen; /* preferred screen for xinerama */
+#endif
 } AppInfo, *AppInfoPtr;
 
 
@@ -278,6 +284,10 @@ typedef struct displayInfo {
     int                height;         /* initialized with DisplayHeight()        */
     Pixel      black_pixel;    /* initialized with BlackPixel()           */
     Visual     *visual;        /* initialized with DefaultVisual()        */
+#ifdef USE_XINERAMA            /* initialized with _DtXineramaInit()      */
+  DtXineramaInfoPtr_t DtXineramaInfo;
+#endif
+
 } DisplayInfo;
 
 
index 0cd89fbdccf500af2f603a0d43a952af8b8e3bdf..cc2fdff750192a3733f714c9e34d90e3ca6a0eb5 100644 (file)
@@ -552,11 +552,14 @@ FakeFocusIn( Widget focus_widget, XtPointer client_data, XEvent *eventprm,
 void
 LayoutCB( Widget w, XtPointer client_data, XtPointer call_data )
 {
-    register int       i, j;
+    int        i, j;
     Dimension  width, height;  /* size values returned by XtGetValues     */
     Dimension  shadowThickness;/* size values returned by XtGetValues     */
     Position   x, y;           /* position values returned by XtGetValues */
     
+    int dpwidth, dpheight;     /* JET - display w/h set according to */
+    int xorg, yorg;            /* xinerama usage */
+
     struct {                   /* position, size of widgets (pixels)      */
     int x, y;
     int        width;
@@ -585,6 +588,22 @@ LayoutCB( Widget w, XtPointer client_data, XtPointer call_data )
     vg_TRACE_EXECUTION("main:  entered LayoutCB ...");
 #endif /* VG_TRACE */
 
+#ifdef USE_XINERAMA
+                               /* get info on the prefered screen */
+    if (!_DtXineramaGetScreen(dpyinfo.DtXineramaInfo, 
+                              appInfo.xineramaPreferredScreen,
+                             &dpwidth, &dpheight, &xorg, &yorg))
+      {                                /* no joy here either - setup for normal */
+       dpwidth = dpyinfo.width;
+       dpheight = dpyinfo.height;
+       xorg = yorg = 0;
+      }
+#else  /* no Xinerama */
+    dpwidth = dpyinfo.width;
+    dpheight = dpyinfo.height;
+    xorg = yorg = 0;
+#endif    
+
     /*
      * - squeeze dialog to fit onto screen (if necessary)
      */
@@ -593,9 +612,9 @@ LayoutCB( Widget w, XtPointer client_data, XtPointer call_data )
     XtGetValues(matte, argt, i);
     mw.width  = ToPixel(matte, XmHORIZONTAL, (int)width  );
 #define HMARGIN 4 /* min sum horizontal margin of matte */
-    if (mw.width+HMARGIN > dpyinfo.width)
+    if (mw.width+HMARGIN > dpwidth)
     {
-      int delta = mw.width + HMARGIN - dpyinfo.width;
+      int delta = mw.width + HMARGIN - dpwidth;
      /*
       * Matte width greater than screen so shrink matteFrame
       * and matte1 width to compensate.
@@ -612,7 +631,7 @@ LayoutCB( Widget w, XtPointer client_data, XtPointer call_data )
       XtSetArg(argt[i], XmNwidth,       width1          ); i++;
       XtSetValues(matteFrame, argt, i);
 
-      width1 = dpyinfo.width - HMARGIN;
+      width1 = dpwidth - HMARGIN;
       mw.width = FromPixel(matte, XmHORIZONTAL, width1 );
 
       i=0;
@@ -661,10 +680,10 @@ LayoutCB( Widget w, XtPointer client_data, XtPointer call_data )
     mw.height = ToPixel(matte, XmVERTICAL,   (int)height );
 
     mw.x = ( x > 0 ? ToPixel(matte, XmHORIZONTAL, (int) x)
-           : (dpyinfo.width - mw.width)/2 );
+           : (dpwidth - mw.width)/2 );
     
     mw.y = ( y > 0 ? ToPixel(matte, XmVERTICAL, (int) y)
-           : (dpyinfo.height - mw.height)/2 );
+           : (dpheight - mw.height)/2 );
  
     if ( mw.x < 0 ) mw.x = 0;
     if ( mw.y < 0 ) mw.y = 0;
@@ -672,6 +691,10 @@ LayoutCB( Widget w, XtPointer client_data, XtPointer call_data )
     x1 = FromPixel(matte, XmHORIZONTAL, mw.x );
     y1 = FromPixel(matte, XmVERTICAL,   mw.y );
 
+    x1 += xorg;                        /* JET - adjust for xinerama */
+    y1 += yorg;
+
+
     i = 0;
     XtSetArg(argt[i], XmNx,                    x1                      ); i++;
     XtSetArg(argt[i], XmNy,                    y1                      ); i++;
@@ -733,7 +756,7 @@ LayoutCB( Widget w, XtPointer client_data, XtPointer call_data )
        XtGetValues(copyright_msg, argt, i);
 
        width1 = ToPixel(copyright_msg, XmHORIZONTAL, width);
-       width1 = (dpyinfo.width - (int) geometry.width - 2 * width1)/2;
+       width1 = (dpwidth - (int) geometry.width - 2 * width1)/2;
 
        x1 = FromPixel(copyright_msg, XmHORIZONTAL, width1);
        y1 = FromPixel(copyright_msg, XmVERTICAL, mw.y);
index 485b26fb3ffb9d018f4af7d9db2144f8bcca8585..06bf0eeede705c48d0e4b991c019f7f862173bca 100644 (file)
 #include       <Dt/MenuButton.h>
 
 
+#ifdef USE_XINERAMA
+#include <DtXinerama.h>
+#endif
+
 #if !defined(NL_CAT_LOCALE)
 #define NL_CAT_LOCALE 0
 #endif
@@ -318,6 +322,13 @@ static
        XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageList),
        XtRString, NULL                                                 },
 
+#if defined(USE_XINERAMA)
+    { "xineramaPreferredScreen",        "XineramaPreferredScreen",
+        XtRInt, sizeof(int), XtOffset(AppInfoPtr, xineramaPreferredScreen),
+        XtRImmediate, (XtPointer) 0
+        },
+#endif
+
 #if defined (ENABLE_DYNAMIC_LANGLIST)
     {"languageListCmd", "LanguageListCmd",
         XtRString, sizeof(char *), XtOffset(AppInfoPtr, languageListCmd),
@@ -493,6 +504,27 @@ main( int argc, char **argv )
     dpyinfo.black_pixel        = BlackPixel   (dpyinfo.dpy, dpyinfo.screen);
     dpyinfo.visual     = DefaultVisual(dpyinfo.dpy, dpyinfo.screen);
 
+                               /* JET - for Xinerama, see if the extension */
+                               /* is available and init accordingly. */
+
+#ifdef USE_XINERAMA
+
+    dpyinfo.DtXineramaInfo = _DtXineramaInit(dpyinfo.dpy);
+
+# ifdef DEBUG
+    if (dpyinfo.DtXineramaInfo == NULL)
+      {                                /* No xinerama, no joy. */
+       fprintf(stderr, "### JET VGMAIN: Xinerama NOT available.\n"); 
+      }
+    else
+      {
+       fprintf(stderr, "### JET VGMAIN: Xinerama available, scrns = %d\n",
+               dpyinfo.DtXineramaInfo->numscreens);
+      }
+# endif
+
+#endif
+
     /*
      *  check if any overrides were passed in the argv string...
      */
@@ -1180,6 +1212,10 @@ MakeDialog( DialogType dtype )
     Widget     w, text;
     Dimension txt_width, txt_height;
     XmString   ok, cancel, nw, sv;
+
+    Widget      tlev;          /* JET - warning, there be dragons here */
+    unsigned int dpwidth, dpheight, xorg, yorg;
+
     
     
 #ifdef VG_TRACE
@@ -1189,6 +1225,23 @@ MakeDialog( DialogType dtype )
      *  do things common to all dialogs...
      */
 
+#ifdef USE_XINERAMA
+                               /* get info on prefered screen */
+    if (!_DtXineramaGetScreen(dpyinfo.DtXineramaInfo, 
+                              appInfo.xineramaPreferredScreen,
+                             &dpwidth, &dpheight, &xorg, &yorg))
+      {                                /* no joy here either - setup for normal */
+       dpwidth = dpyinfo.width;
+       dpheight = dpyinfo.height;
+       xorg = yorg = 0;
+      }
+                               /* else, should be setup properly */
+#else  /* no Xinerama */
+    dpwidth = dpyinfo.width;
+    dpheight = dpyinfo.height;
+    xorg = yorg = 0;
+#endif    
+
     ok     = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL);
     cancel = ReadCatalogXms(MC_LABEL_SET, MC_CANCEL_LABEL, MC_DEF_CANCEL_LABEL);
 
@@ -1205,13 +1258,25 @@ MakeDialog( DialogType dtype )
      *  create the various dialogs...
      */
 
-    switch (dtype) {
+    /* JET - check the matte widget, and if non-null, well use that as
+     * the parent for dialogs.  Otherwise use table (the original
+     * toplevel widget for this func).  This is useful for Xinerama so
+     * that child dialogs are centered on the matte, and not the whole
+     * SLS screen.
+     */
+
+    if (matte != (Widget)NULL)
+      tlev = matte;
+    else
+      tlev = table;
+
+   switch (dtype) {
 
     case error:
        xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, "");
        XtSetArg(argt[i], XmNmessageString,             xmstr           ); i++;
 
-       w = XmCreateErrorDialog(table, "error_message", argt, i);
+       w = XmCreateErrorDialog(tlev, "error_message", argt, i);
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
 
@@ -1221,13 +1286,13 @@ MakeDialog( DialogType dtype )
 
     case help:
 
-        txt_width = (dpyinfo.width > 850) ? 800 : dpyinfo.width - 50;
-        txt_height = (dpyinfo.height > 900) ? 600 : dpyinfo.height - 300;
+        txt_width = (dpwidth > 850) ? 800 : dpwidth - 50;
+        txt_height = (dpheight > 900) ? 600 : dpheight - 300;
 
         xmstr = ReadCatalogXms(MC_LABEL_SET, MC_HELP_LABEL, MC_DEF_HELP_LABEL);
        XtSetArg(argt[i], XmNmessageString, xmstr); i++;
 
-        w = XmCreateInformationDialog(table, "help_message", argt, i);
+        w = XmCreateInformationDialog(tlev, "help_message", argt, i);
         XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
         XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
 
@@ -1277,7 +1342,7 @@ MakeDialog( DialogType dtype )
 
        XtSetArg(argt[i], XmNmessageString,             xmstr           ); i++;
 
-       w = XmCreateInformationDialog(table, "copyright_msg", argt, i);
+       w = XmCreateInformationDialog(tlev, "copyright_msg", argt, i);
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
        
@@ -1297,7 +1362,7 @@ MakeDialog( DialogType dtype )
        XtSetArg(argt[i], XmNokLabelString,             nw              ); i++;
        XtSetArg(argt[i], XmNcancelLabelString,         sv              ); i++;
 
-       w = XmCreateWarningDialog(table, "hostname_msg", argt, i);
+       w = XmCreateWarningDialog(tlev, "hostname_msg", argt, i);
 
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
 
@@ -1314,7 +1379,7 @@ MakeDialog( DialogType dtype )
                            MC_DEF_PASSWD_EXPIRED);
        XtSetArg(argt[i], XmNmessageString,             xmstr           ); i++;
 
-       w = XmCreateQuestionDialog(table, "password_msg", argt, i);
+       w = XmCreateQuestionDialog(tlev, "password_msg", argt, i);
 
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
 
index b05b7ce2e965200fa1b4e65dbd65ce0626a147cb..e4f12007c7be3d21234c81fa1794a47201a94fcf 100644 (file)
@@ -28,3 +28,8 @@ Dtsession*lockLabelPixmap.imageName: Dtlogo
 #endif
 
 Dtsession*ignoreEnvironment:   DISPLAY,SESSION_MANAGER,AUDIOSERVER
+
+!# Selects the desired screen for certain dialogs (exit confirmation, 
+!#  screen saver password, etc) for use in a Xinerama configuration.
+
+Dtsession*xineramaPreferredScreen:      0
index 5d0846528d46897264054683a29e136b67062222..9231d645625fcdc39744514667fdc8e76043dcd1 100644 (file)
@@ -16,6 +16,10 @@ LOCAL_LIBRARIES = $(DTHELPLIB) $(DTWIDGETLIB) $(DTSVCLIB) $(TTLIB) \
 #endif /* SunArchitecture */
 SYS_LIBRARIES = -lm
 
+#if CDE_USEXINERAMA
+XINOPT = -DUSE_XINERAMA
+XINLIB = -lDtXinerama -lXinerama
+#endif
 
 #ifdef AlphaArchitecture
 SYS_LIBRARIES = -lm
@@ -74,7 +78,7 @@ SYS_LIBRARIES = $(XPLIB) $(XINLIB) -ldl -lcrypt -lm
 
 #if defined(FreeBSDArchitecture)
 EXTRA_DEFINES = -D${PROGRAMS} $(XINOPT)
-SYS_LIBRARIES = $(XPLIB) -lcrypt -lm
+SYS_LIBRARIES = $(XPLIB) $(XINLIB) -lcrypt -lm
 #endif
 
 PROGRAMS=dtsession
index cd5483348ff449307dff67fa0e2914917397a8b4..1540895df751a84c0d75f417dbc282b2d3f45f6d 100644 (file)
 #include <Tt/tt_c.h>
 #include "SmError.h"
 
+#ifdef USE_XINERAMA
+# include <DtXinerama.h>
+#endif
+
 /* 
  *  #define statements 
  */
@@ -202,6 +206,9 @@ typedef struct
     Boolean     mergeXdefaults;
     int                numSessionsBackedup;
     char       *ignoreEnvironment;
+#if defined(USE_XINERAMA)
+    int         xineramaPreferredScreen; /* prefered xinerama screen */
+#endif
 } SessionResources, *SessionResourcesPtr;
 
 /*
@@ -337,6 +344,10 @@ typedef struct
     Boolean    loggingOut;     /* Is True if the current save is for
                                   a logout; False otherwise. */
 
+#ifdef USE_XINERAMA            /* JET - Xinerama.  Schwiing!  */
+  DtXineramaInfoPtr_t DtXineramaInfo;
+#endif
+
     Boolean ExitComplete;      /* JET - don't exit before we are ready... */
 
 } GeneralData;
index e721d19420e65d535fc2e23db21c9d8e50ab4fe5..40c870885fd4c3e42a35fb81b791cf055fc7fe63 100644 (file)
@@ -222,6 +222,12 @@ static XtResource sessionResources[]=
    {SmNignoreEnvironment, SmCignoreEnvironment, XtRString, sizeof(String),
         XtOffset(SessionResourcesPtr, ignoreEnvironment),
         XtRImmediate, (XtPointer) NULL},
+#if defined(USE_XINERAMA)      /* JET - Xinerama */
+   {SmNxineramaPreferredScreen, SmCxineramaPreferredScreen, XtRInt, sizeof(int),
+        XtOffset(SessionResourcesPtr, xineramaPreferredScreen),
+        XtRImmediate, (XtPointer) 0},
+#endif
+
 }
 ;
 
index 23ce151330e3a7984338a7ce5bc93b2b72090179..5d94de318d7ebc2b59735dbe5074ec9b3698d92b 100644 (file)
@@ -70,6 +70,9 @@
 #include <Dt/EnvControlP.h>
 #include <Dt/DtP.h>
 #include <Dt/Lock.h>
+#ifdef USE_XINERAMA
+#include <DtXinerama.h>                /* JET - Xinerama support */
+#endif
 #include "Sm.h"
 #include "SmError.h"
 #include "SmGlobals.h"
@@ -387,6 +390,25 @@ main (int argc, char **argv)
         SM_EXIT(-1);
     }
 
+    /* JET - initialize for Xinerama, if present 4/12/2001 */
+#ifdef USE_XINERAMA
+    smGD.DtXineramaInfo = _DtXineramaInit(smGD.display);
+
+# ifdef DEBUG
+    if (smGD.DtXineramaInfo == NULL)
+      {                         /* No xinerama, how... sad. */
+        fprintf(stderr, "### JET SmMain: Xinerama NOT available.\n");
+      }
+    else
+      {
+        fprintf(stderr, "### JET SmMain: Xinerama available, scrns = %d\n",
+                dpyinfo.DtXineramaInfo->numscreens);
+      }
+# endif
+
+#endif
+
+
    /*
     * Restore preferences
     */
index b4ae3edf3bc2f8a226c4b3f607d78ad4e98a2dfa..dd55f5adeb014ca9ac172b86403009ba52faeb16 100644 (file)
@@ -86,6 +86,7 @@ extern char SmNsaveYourselfTimeout[];
 extern char SmNmergeXdefaults[];
 extern char SmNnumSessionsBackedup[];
 extern char SmNignoreEnvironment[];
+extern char SmNxineramaPreferredScreen[];
 
 /* 
  * Resource names for settings information 
@@ -147,6 +148,8 @@ extern char SmCsaveYourselfTimeout[];
 extern char SmCmergeXdefaults[];
 extern char SmCnumSessionsBackedup[];
 extern char SmCignoreEnvironment[];
+extern char SmCxineramaPreferredScreen[];
+
 
 /*
  * Class names for session settings information
index e96e6d041e04ab1fff8160d011cfa8d2e06771d4..308d867f2769a2720371680c571813f76c9fed3b 100644 (file)
@@ -80,6 +80,7 @@ char SmNsaveYourselfTimeout[] = "saveYourselfTimeout";
 char SmNmergeXdefaults[] = "mergeXdefaults";
 char SmNnumSessionsBackedup[] = "numSessionsBackedup";
 char SmNignoreEnvironment[] = "ignoreEnvironment";
+char SmNxineramaPreferredScreen[] = "xineramaPreferredScreen";
 
 
 /* Resource names for settings information */
@@ -141,6 +142,7 @@ char SmCsaveYourselfTimeout[] = "SaveYourselfTimeout";
 char SmCmergeXdefaults[] = "MergeXdefaults";
 char SmCnumSessionsBackedup[] = "NumSessionsBackedup";
 char SmCignoreEnvironment[] = "IgnoreEnvironment";
+char SmCxineramaPreferredScreen[] = "XineramaPreferredScreen";
 
 /*
  * Class names for session settings information
index 5ce5ad28794c5bdae980e6702bd6e645cc703ab0..94c640d9ef23160aee3a461a33ec7b8d7a75a089 100644 (file)
 #include "SmHelp.h"
 #include "SmGlobals.h"
 
+#ifdef USE_XINERAMA
+#include <DtXinerama.h>
+#endif
+
 typedef enum {
        ConfirmationNone,
        ConfirmationOK,
@@ -1340,6 +1344,7 @@ DialogUp(
     int        i;
     Dimension  width, height;
     Position   x, y;
+    unsigned int dpwidth, dpheight, xorg, yorg; /* JET - Xinerama */
 
     /*
      * Get the size of the dialog box - then compute its position
@@ -1349,9 +1354,30 @@ DialogUp(
     XtSetArg(uiArgs[i], XmNheight, &height);i++;
     XtGetValues(w, uiArgs, i);
     
-    x = (DisplayWidth(smGD.display, smGD.screen) / 2) - (width / 2);
-    y = (DisplayHeight(smGD.display, smGD.screen) / 2) - (height / 2);
-    
+                               /* JET - get xinerama info */
+#ifdef USE_XINERAMA
+                                /* use the 'prefered' screen */
+    if (!_DtXineramaGetScreen(smGD.DtXineramaInfo, 
+                              smRes.xineramaPreferredScreen, 
+                             &dpwidth, &dpheight, &xorg, &yorg))
+      {                         /* no joy here either - setup for normal */
+        dpwidth = DisplayWidth(smGD.display, smGD.screen);
+        dpheight = DisplayHeight(smGD.display, smGD.screen);
+       xorg = yorg = 0;
+      }
+#else  /* no Xinerama */
+    dpwidth = DisplayWidth(smGD.display, smGD.screen);
+    dpheight = DisplayHeight(smGD.display, smGD.screen);
+    xorg = yorg = 0;
+#endif
+
+    x = (dpwidth / 2) - (width / 2);
+    y = (dpheight / 2) - (height / 2);
+
+                               /* add the x/y origins for Xinerama */
+    x += xorg;
+    y += yorg;
+
     i = 0;
     XtSetArg(uiArgs[i], XmNx, x);i++;
     XtSetArg(uiArgs[i], XmNy, y);i++;
@@ -1484,6 +1510,7 @@ LockDialogUp(
     register int       i;
     Dimension  width, height;  /* size values returned by XtGetValues     */
     Dimension  shadowThickness;/* size values returned by XtGetValues     */
+    unsigned int dpwidth, dpheight, xorg, yorg; /* JET - xinerama */
     
     struct
     {                  /* position, size of widgets (pixels)      */
@@ -1497,6 +1524,23 @@ LockDialogUp(
     int                x1, y1;         /* general position variables              */
     int                index;
     
+                               /* JET - get xinerama info */
+#ifdef USE_XINERAMA
+                                /* use the prefered screen */
+    if (!_DtXineramaGetScreen(smGD.DtXineramaInfo, 
+                              smRes.xineramaPreferredScreen, 
+                             &dpwidth, &dpheight, &xorg, &yorg))
+      {                         /* no joy here either - setup for normal */
+        dpwidth = DisplayWidth(smGD.display, smGD.screen);
+        dpheight = DisplayHeight(smGD.display, smGD.screen);
+       xorg = yorg = 0;
+      }
+#else  /* no Xinerama */
+    dpwidth = DisplayWidth(smGD.display, smGD.screen);
+    dpheight = DisplayHeight(smGD.display, smGD.screen);
+    xorg = yorg = 0;
+#endif
+
     /*
      * The partial cover has widgets of index 0 - the cover has
      * index 1
@@ -1522,14 +1566,15 @@ LockDialogUp(
     mw.shadow = shadowThickness;
     mw.width  = width;
     mw.height = height;
-    mw.x      = (DisplayWidth(smGD.display, smGD.screen)  - mw.width)/2;
-    mw.y      = (DisplayHeight(smGD.display, smGD.screen) - mw.height)/2;
+    mw.x      = (dpwidth  - mw.width)/2;
+    mw.y      = (dpheight - mw.height)/2;
 
     if ( mw.x < 0 ) mw.x = 0;
     if ( mw.y < 0 ) mw.y = 0;
     
-    x1 = mw.x;
-    y1 = mw.y;
+                               /* adjust origins if using Xinerama */
+    x1 = mw.x + xorg;
+    y1 = mw.y + yorg;
 
     i = 0;