From af7ba55f7827be3dcd06bb44f295e306bfd0d79f Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Tue, 26 Mar 2013 19:49:50 -0600 Subject: [PATCH] Add basic Xinerama support via new lib/DtXinerama 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. --- cde/config/cf/site.def | 3 + cde/lib/DtXinerama/DtXinerama.c | 103 +++++++++++++++++++++ cde/lib/DtXinerama/DtXinerama.h | 52 +++++++++++ cde/lib/DtXinerama/Imakefile | 43 +++++++++ cde/lib/Imakefile | 7 +- cde/programs/dtlogin/Imakefile | 11 ++- cde/programs/dtlogin/config/Xresources.src | 11 +++ cde/programs/dtlogin/dtchooser.c | 41 ++++++-- cde/programs/dtlogin/vg.h | 10 ++ cde/programs/dtlogin/vgcallback.c | 37 ++++++-- cde/programs/dtlogin/vgmain.c | 81 ++++++++++++++-- cde/programs/dtsession/Dtsession.src | 5 + cde/programs/dtsession/Imakefile | 6 +- cde/programs/dtsession/Sm.h | 11 +++ cde/programs/dtsession/SmGlobals.c | 6 ++ cde/programs/dtsession/SmMain.c | 22 +++++ cde/programs/dtsession/SmResource.h | 3 + cde/programs/dtsession/SmStrDefs.c | 2 + cde/programs/dtsession/SmUI.c | 59 ++++++++++-- 19 files changed, 477 insertions(+), 36 deletions(-) create mode 100644 cde/lib/DtXinerama/DtXinerama.c create mode 100644 cde/lib/DtXinerama/DtXinerama.h create mode 100644 cde/lib/DtXinerama/Imakefile diff --git a/cde/config/cf/site.def b/cde/config/cf/site.def index 4dce9f0e..361166b8 100644 --- a/cde/config/cf/site.def +++ b/cde/config/cf/site.def @@ -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 index 00000000..a2d2a642 --- /dev/null +++ b/cde/lib/DtXinerama/DtXinerama.c @@ -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 +#include +#include +#include + +#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 index 00000000..0f119e8b --- /dev/null +++ b/cde/lib/DtXinerama/DtXinerama.h @@ -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 +#include + +#include + +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 index 00000000..21837dc4 --- /dev/null +++ b/cde/lib/DtXinerama/Imakefile @@ -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 + +INCLUDES = -I. + +DependTarget() + diff --git a/cde/lib/Imakefile b/cde/lib/Imakefile index 595cff36..2d0bfac8 100644 --- a/cde/lib/Imakefile +++ b/cde/lib/Imakefile @@ -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)) diff --git a/cde/programs/dtlogin/Imakefile b/cde/programs/dtlogin/Imakefile index 33dc6f99..227a7462 100644 --- a/cde/programs/dtlogin/Imakefile +++ b/cde/programs/dtlogin/Imakefile @@ -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) diff --git a/cde/programs/dtlogin/config/Xresources.src b/cde/programs/dtlogin/config/Xresources.src index 94f0e810..9930c982 100644 --- a/cde/programs/dtlogin/config/Xresources.src +++ b/cde/programs/dtlogin/config/Xresources.src @@ -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 diff --git a/cde/programs/dtlogin/dtchooser.c b/cde/programs/dtlogin/dtchooser.c index a2f24537..a6bc58a4 100644 --- a/cde/programs/dtlogin/dtchooser.c +++ b/cde/programs/dtlogin/dtchooser.c @@ -89,8 +89,9 @@ #include "vgmsg.h" #include
- - +#ifdef USE_XINERAMA +#include +#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)); diff --git a/cde/programs/dtlogin/vg.h b/cde/programs/dtlogin/vg.h index 7fc895a7..e31a6264 100644 --- a/cde/programs/dtlogin/vg.h +++ b/cde/programs/dtlogin/vg.h @@ -66,6 +66,9 @@ extern int errno; # include #endif +#ifdef USE_XINERAMA +# include +#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; diff --git a/cde/programs/dtlogin/vgcallback.c b/cde/programs/dtlogin/vgcallback.c index 0cd89fbd..cc2fdff7 100644 --- a/cde/programs/dtlogin/vgcallback.c +++ b/cde/programs/dtlogin/vgcallback.c @@ -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); diff --git a/cde/programs/dtlogin/vgmain.c b/cde/programs/dtlogin/vgmain.c index 485b26fb..06bf0eee 100644 --- a/cde/programs/dtlogin/vgmain.c +++ b/cde/programs/dtlogin/vgmain.c @@ -90,6 +90,10 @@ #include
+#ifdef USE_XINERAMA +#include +#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)); diff --git a/cde/programs/dtsession/Dtsession.src b/cde/programs/dtsession/Dtsession.src index b05b7ce2..e4f12007 100644 --- a/cde/programs/dtsession/Dtsession.src +++ b/cde/programs/dtsession/Dtsession.src @@ -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 diff --git a/cde/programs/dtsession/Imakefile b/cde/programs/dtsession/Imakefile index 5d084652..9231d645 100644 --- a/cde/programs/dtsession/Imakefile +++ b/cde/programs/dtsession/Imakefile @@ -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 diff --git a/cde/programs/dtsession/Sm.h b/cde/programs/dtsession/Sm.h index cd548334..1540895d 100644 --- a/cde/programs/dtsession/Sm.h +++ b/cde/programs/dtsession/Sm.h @@ -61,6 +61,10 @@ #include #include "SmError.h" +#ifdef USE_XINERAMA +# include +#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; diff --git a/cde/programs/dtsession/SmGlobals.c b/cde/programs/dtsession/SmGlobals.c index e721d194..40c87088 100644 --- a/cde/programs/dtsession/SmGlobals.c +++ b/cde/programs/dtsession/SmGlobals.c @@ -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 + } ; diff --git a/cde/programs/dtsession/SmMain.c b/cde/programs/dtsession/SmMain.c index 23ce1513..5d94de31 100644 --- a/cde/programs/dtsession/SmMain.c +++ b/cde/programs/dtsession/SmMain.c @@ -70,6 +70,9 @@ #include
#include
#include
+#ifdef USE_XINERAMA +#include /* 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 */ diff --git a/cde/programs/dtsession/SmResource.h b/cde/programs/dtsession/SmResource.h index b4ae3edf..dd55f5ad 100644 --- a/cde/programs/dtsession/SmResource.h +++ b/cde/programs/dtsession/SmResource.h @@ -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 diff --git a/cde/programs/dtsession/SmStrDefs.c b/cde/programs/dtsession/SmStrDefs.c index e96e6d04..308d867f 100644 --- a/cde/programs/dtsession/SmStrDefs.c +++ b/cde/programs/dtsession/SmStrDefs.c @@ -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 diff --git a/cde/programs/dtsession/SmUI.c b/cde/programs/dtsession/SmUI.c index 5ce5ad28..94c640d9 100644 --- a/cde/programs/dtsession/SmUI.c +++ b/cde/programs/dtsession/SmUI.c @@ -86,6 +86,10 @@ #include "SmHelp.h" #include "SmGlobals.h" +#ifdef USE_XINERAMA +#include +#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; -- 2.25.1