1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

dtfile: added Xinerama support to dialog positioning routines

This commit is contained in:
alx 2016-12-30 01:28:43 +01:00 committed by Jon Trulson
parent c855ee9765
commit 39031e9dea
3 changed files with 61 additions and 7 deletions

View file

@ -99,7 +99,9 @@
#include "FileMgr.h" #include "FileMgr.h"
#include "Main.h" #include "Main.h"
#include "ModAttr.h" #include "ModAttr.h"
#ifdef USE_XINERAMA
#include <DtXinerama.h>
#endif
#define MAX_NAME_LIST_SIZE 25 #define MAX_NAME_LIST_SIZE 25
#define MAX_RESOURCE_LENGTH 256 #define MAX_RESOURCE_LENGTH 256
@ -232,6 +234,10 @@ static void IntDialogPutResources(
char *dialogName, char *dialogName,
char *base, char *base,
DialogResource *resource) ; 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 ********/ /******** End Static Function Declarations ********/
@ -1872,6 +1878,7 @@ _DtChildPosition(
int pWidth, myWidth, sWidth; int pWidth, myWidth, sWidth;
enum { posRight, posBelow, posLeft, posAbove } pos; enum { posRight, posBelow, posLeft, posAbove } pos;
int space; int space;
int xOrg=0, yOrg=0; /* Xinerama screen origin */
/* get x, y offsets for the parent's window frame */ /* get x, y offsets for the parent's window frame */
extData = _XmGetWidgetExtData(parent, XmSHELL_EXTENSION); extData = _XmGetWidgetExtData(parent, XmSHELL_EXTENSION);
@ -1884,11 +1891,19 @@ _DtChildPosition(
else else
xOffset = yOffset = 0; 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 */ /* get size/position of screen, parent, and widget */
sHeight = HeightOfScreen(XtScreen(parent));; sHeight = HeightOfScreen(XtScreen(parent));
sWidth = WidthOfScreen(XtScreen(parent)); sWidth = WidthOfScreen(XtScreen(parent));
pX = XtX(parent) - xOffset; #endif /* USE_XINERAMA */
pY = XtY(parent) - yOffset;
pX = XtX(parent) - xOffset - xOrg;
pY = XtY(parent) - yOffset - yOrg;
pHeight = XtHeight(parent) + yOffset + xOffset; pHeight = XtHeight(parent) + yOffset + xOffset;
pWidth = XtWidth(parent) + 2*xOffset; pWidth = XtWidth(parent) + 2*xOffset;
myHeight = XtHeight(w) + yOffset + xOffset; myHeight = XtHeight(w) + yOffset + xOffset;
@ -1958,6 +1973,8 @@ _DtChildPosition(
if ((*newY >= (sHeight - 10)) || (*newY < 0)) if ((*newY >= (sHeight - 10)) || (*newY < 0))
*newY = (sHeight - myHeight) / 2; *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; i<dt_xi->numscreens; 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 */

View file

@ -38,7 +38,7 @@
**************************************************************************** ****************************************************************************
************************************<+>*************************************/ ************************************<+>*************************************/
#ifndef _Encapsualte_h #ifndef _Encapsulate_h
#define _Encapsulate_h #define _Encapsulate_h

View file

@ -8,17 +8,21 @@ MakeSubdirs($(SUBDIRS))
ForceSubdirs($(SUBDIRS)) ForceSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS)) DependSubdirs($(SUBDIRS))
#if CDE_USEXINERAMA
XINOPT = -DUSE_XINERAMA
XINLIB = -lDtXinerama -lXinerama
#endif
DEPEND_DEFINES = $(DEPENDDEFINES) DEPEND_DEFINES = $(DEPENDDEFINES)
DEFINES = -DMULTIBYTE -DSHAPE -D_ILS_MACROS -DSUN_PERF \ DEFINES = -DMULTIBYTE -DSHAPE -D_ILS_MACROS -DSUN_PERF \
-DCDE_INSTALLATION_TOP=\"$(CDE_INSTALLATION_TOP)\" \ -DCDE_INSTALLATION_TOP=\"$(CDE_INSTALLATION_TOP)\" \
-DCDE_CONFIGURATION_TOP=\"$(CDE_CONFIGURATION_TOP)\" \ -DCDE_CONFIGURATION_TOP=\"$(CDE_CONFIGURATION_TOP)\" \
-DKORNSHELL=\"$(KORNSHELL)\" -DKORNSHELL=\"$(KORNSHELL)\" $(XINOPT)
INCLUDES = -I./dtcopy INCLUDES = -I./dtcopy
DEPLIBS = DepDtClientLibs DEPLIBS = DepDtClientLibs
LOCAL_LIBRARIES = DtClientLibs LOCAL_LIBRARIES = DtClientLibs $(XINLIB)
SYS_LIBRARIES = DtClientSysLibs DtClientExtraLibs SYS_LIBRARIES = DtClientSysLibs DtClientExtraLibs
#ifdef AlphaArchitecture #ifdef AlphaArchitecture