| 1 |
|
| 2 |
/* |
| 3 |
|
| 4 |
Copyright 1985, 1998 The Open Group |
| 5 |
|
| 6 |
Permission to use, copy, modify, distribute, and sell this software and its |
| 7 |
documentation for any purpose is hereby granted without fee, provided that |
| 8 |
the above copyright notice appear in all copies and that both that |
| 9 |
copyright notice and this permission notice appear in supporting |
| 10 |
documentation. |
| 11 |
|
| 12 |
The above copyright notice and this permission notice shall be included |
| 13 |
in all copies or substantial portions of the Software. |
| 14 |
|
| 15 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 16 |
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 18 |
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 19 |
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 20 |
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 21 |
OTHER DEALINGS IN THE SOFTWARE. |
| 22 |
|
| 23 |
Except as contained in this notice, the name of The Open Group shall |
| 24 |
not be used in advertising or otherwise to promote the sale, use or |
| 25 |
other dealings in this Software without prior written authorization |
| 26 |
from The Open Group. |
| 27 |
|
| 28 |
*/ |
| 29 |
|
| 30 |
#ifdef HAVE_CONFIG_H |
| 31 |
#include <config.h> |
| 32 |
#endif |
| 33 |
#include "Xlibint.h" |
| 34 |
#include "Xutil.h" |
| 35 |
|
| 36 |
/* |
| 37 |
* This routine given a user supplied positional argument and a default |
| 38 |
* argument (fully qualified) will return the position the window should take |
| 39 |
* returns 0 if there was some problem, else the position bitmask. |
| 40 |
*/ |
| 41 |
|
| 42 |
int |
| 43 |
XGeometry ( |
| 44 |
Display *dpy, /* user's display connection */ |
| 45 |
int screen, /* screen on which to do computation */ |
| 46 |
_Xconst char *pos, /* user provided geometry spec */ |
| 47 |
_Xconst char *def, /* default geometry spec for window */ |
| 48 |
unsigned int bwidth, /* border width */ |
| 49 |
unsigned int fwidth, /* size of position units */ |
| 50 |
unsigned int fheight, |
| 51 |
int xadd, /* any additional interior space */ |
| 52 |
int yadd, |
| 53 |
register int *x, /* always set on successful RETURN */ |
| 54 |
register int *y, /* always set on successful RETURN */ |
| 55 |
register int *width, /* always set on successful RETURN */ |
| 56 |
register int *height) /* always set on successful RETURN */ |
| 57 |
{ |
| 58 |
int px, py; /* returned values from parse */ |
| 59 |
unsigned int pwidth, pheight; /* returned values from parse */ |
| 60 |
int dx, dy; /* default values from parse */ |
| 61 |
unsigned int dwidth, dheight; /* default values from parse */ |
| 62 |
int pmask, dmask; /* values back from parse */ |
| 63 |
|
| 64 |
pmask = XParseGeometry(pos, &px, &py, &pwidth, &pheight); |
| 65 |
dmask = XParseGeometry(def, &dx, &dy, &dwidth, &dheight); |
| 66 |
|
| 67 |
/* set default values */ |
| 68 |
*x = (dmask & XNegative) ? |
| 69 |
DisplayWidth(dpy, screen) + dx - dwidth * fwidth - |
| 70 |
2 * bwidth - xadd : dx; |
| 71 |
*y = (dmask & YNegative) ? |
| 72 |
DisplayHeight(dpy, screen) + dy - dheight * fheight - |
| 73 |
2 * bwidth - yadd : dy; |
| 74 |
*width = dwidth; |
| 75 |
*height = dheight; |
| 76 |
|
| 77 |
if (pmask & WidthValue) *width = pwidth; |
| 78 |
if (pmask & HeightValue) *height = pheight; |
| 79 |
|
| 80 |
if (pmask & XValue) |
| 81 |
*x = (pmask & XNegative) ? |
| 82 |
DisplayWidth(dpy, screen) + px - *width * fwidth - |
| 83 |
2 * bwidth - xadd : px; |
| 84 |
if (pmask & YValue) |
| 85 |
*y = (pmask & YNegative) ? |
| 86 |
DisplayHeight(dpy, screen) + py - *height * fheight - |
| 87 |
2 * bwidth - yadd : py; |
| 88 |
return (pmask); |
| 89 |
} |