2 * Copyright (c) 1999, NBG01720@nifty.ne.jp
4 * To compile this program:
5 * gcc -D__ST_MT_ERRNO__ -O2 -s -Zomf -Zmtd -lX11 scrsize.c
7 * When I wrote this routine, I consulted some part of the source code of the
8 * xwininfo utility by X Consortium.
10 * Copyright (c) 1987, X Consortium
12 * Permission is hereby granted, free of charge, to any person obtaining a copy
13 * of this software and associated documentation files (the "Software"), to
14 * deal in the Software without restriction, including without limitation the
15 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 * sell copies of the Software, and to permit persons to whom the Software is
17 * furnished to do so, subject to the following conditions:
19 * The above copyright notice and this permission notice shall be included in
20 * all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 * X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * Except as contained in this notice, the name of the X Consortium shall not
30 * be used in advertising or otherwise to promote the sale, use or other
31 * dealings in this Software without prior written authorization from the X
35 #include <X11/Xutil.h>
45 XWindowAttributes win_attributes;
51 cp = getenv("WINDOWID");
53 dpy = XOpenDisplay(NULL);
55 if (XGetWindowAttributes(dpy, window = atol(cp), &win_attributes))
56 if (XGetWMNormalHints(dpy, window, &hints, &longjunk))
57 if (hints.flags & PResizeInc && hints.width_inc
58 && hints.height_inc) {
59 if (hints.flags & (PBaseSize | PMinSize)) {
60 if (hints.flags & PBaseSize) {
61 win_attributes.width -= hints.base_width;
62 win_attributes.height -= hints.base_height;
65 win_attributes.width -= hints.min_width;
66 win_attributes.height -= hints.min_height;
69 dst[0] = win_attributes.width / hints.width_inc;
70 dst[1] = win_attributes.height / hints.height_inc;
75 printf("%i %i\n", dst[0], dst[1]);