From: alx Date: Fri, 30 Dec 2016 00:28:43 +0000 (+0100) Subject: dtfile: added Xinerama support to dialog positioning routines X-Git-Tag: 2.2.4a~203 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=39031e9dea58c0dce29d188f2af628077f969aea;p=oweals%2Fcde.git dtfile: added Xinerama support to dialog positioning routines --- diff --git a/cde/programs/dtfile/Encaps.c b/cde/programs/dtfile/Encaps.c index 5314e0e9..7bfc6550 100644 --- a/cde/programs/dtfile/Encaps.c +++ b/cde/programs/dtfile/Encaps.c @@ -99,7 +99,9 @@ #include "FileMgr.h" #include "Main.h" #include "ModAttr.h" - +#ifdef USE_XINERAMA +#include +#endif #define MAX_NAME_LIST_SIZE 25 #define MAX_RESOURCE_LENGTH 256 @@ -232,6 +234,10 @@ static void IntDialogPutResources( char *dialogName, char *base, DialogResource *resource) ; +#ifdef USE_XINERAMA +static Boolean GetXineramaScreenDimensions( + Widget w,int *xorg, int *yorg, int *width,int *height); +#endif /* USE_XINERAMA */ /******** End Static Function Declarations ********/ @@ -1872,6 +1878,7 @@ _DtChildPosition( int pWidth, myWidth, sWidth; enum { posRight, posBelow, posLeft, posAbove } pos; int space; + int xOrg=0, yOrg=0; /* Xinerama screen origin */ /* get x, y offsets for the parent's window frame */ extData = _XmGetWidgetExtData(parent, XmSHELL_EXTENSION); @@ -1884,11 +1891,19 @@ _DtChildPosition( else xOffset = yOffset = 0; + #ifdef USE_XINERAMA + if(!GetXineramaScreenDimensions(parent,&xOrg,&yOrg,&sWidth,&sHeight)){ + sHeight = HeightOfScreen(XtScreen(parent)); + sWidth = WidthOfScreen(XtScreen(parent)); + } + #else /* get size/position of screen, parent, and widget */ - sHeight = HeightOfScreen(XtScreen(parent));; + sHeight = HeightOfScreen(XtScreen(parent)); sWidth = WidthOfScreen(XtScreen(parent)); - pX = XtX(parent) - xOffset; - pY = XtY(parent) - yOffset; + #endif /* USE_XINERAMA */ + + pX = XtX(parent) - xOffset - xOrg; + pY = XtY(parent) - yOffset - yOrg; pHeight = XtHeight(parent) + yOffset + xOffset; pWidth = XtWidth(parent) + 2*xOffset; myHeight = XtHeight(w) + yOffset + xOffset; @@ -1958,6 +1973,8 @@ _DtChildPosition( if ((*newY >= (sHeight - 10)) || (*newY < 0)) *newY = (sHeight - myHeight) / 2; + *newX+=xOrg; + *newY+=yOrg; } @@ -2457,3 +2474,36 @@ _DtFreeDialog( } } +#ifdef USE_XINERAMA +/* + * Retrieve dimensions of the Xinerama screen the given widget resides on. + * Returns True on success, False otherwise. + */ +static Boolean GetXineramaScreenDimensions( + Widget w, int *org_x, int *org_y, int *s_width, int *s_height) +{ + DtXineramaInfo_t *dt_xi; + unsigned int wx, wy; + unsigned int i, sx, sy, sw, sh; + + while(w && !XtIsShell(w)) w=XtParent (w); + + wx=XtX(w); + wy=XtY(w); + + if(!(dt_xi=_DtXineramaInit(XtDisplay(w)))) return False; + + for(i=0; inumscreens; i++){ + if(!_DtXineramaGetScreen(dt_xi,i,&sw,&sh,&sx,&sy))break; + + if(wx>=sx && wx<(sx+sw) && wy>=sy && wy<(sy+sh)){ + *s_width=(int)sw; + *s_height=(int)sh; + *org_x=(int)sx; + *org_y=(int)sy; + return True; + } + } + return False; +} +#endif /* USE_XINERAMA */ diff --git a/cde/programs/dtfile/Encaps.h b/cde/programs/dtfile/Encaps.h index 19ec4154..ebec8185 100644 --- a/cde/programs/dtfile/Encaps.h +++ b/cde/programs/dtfile/Encaps.h @@ -38,7 +38,7 @@ **************************************************************************** ************************************<+>*************************************/ -#ifndef _Encapsualte_h +#ifndef _Encapsulate_h #define _Encapsulate_h diff --git a/cde/programs/dtfile/Imakefile b/cde/programs/dtfile/Imakefile index 32f67865..88aecbdd 100644 --- a/cde/programs/dtfile/Imakefile +++ b/cde/programs/dtfile/Imakefile @@ -8,17 +8,21 @@ MakeSubdirs($(SUBDIRS)) ForceSubdirs($(SUBDIRS)) DependSubdirs($(SUBDIRS)) +#if CDE_USEXINERAMA +XINOPT = -DUSE_XINERAMA +XINLIB = -lDtXinerama -lXinerama +#endif DEPEND_DEFINES = $(DEPENDDEFINES) DEFINES = -DMULTIBYTE -DSHAPE -D_ILS_MACROS -DSUN_PERF \ -DCDE_INSTALLATION_TOP=\"$(CDE_INSTALLATION_TOP)\" \ -DCDE_CONFIGURATION_TOP=\"$(CDE_CONFIGURATION_TOP)\" \ - -DKORNSHELL=\"$(KORNSHELL)\" + -DKORNSHELL=\"$(KORNSHELL)\" $(XINOPT) INCLUDES = -I./dtcopy DEPLIBS = DepDtClientLibs -LOCAL_LIBRARIES = DtClientLibs +LOCAL_LIBRARIES = DtClientLibs $(XINLIB) SYS_LIBRARIES = DtClientSysLibs DtClientExtraLibs #ifdef AlphaArchitecture