Changeset View
Changeset View
Standalone View
Standalone View
head/contrib/less/scrsize.c
Show All 39 Lines | |||||
* dealings in this Software without prior written authorization from the X | * dealings in this Software without prior written authorization from the X | ||||
* Consortium. | * Consortium. | ||||
*/ | */ | ||||
#include <X11/Xlib.h> | #include <X11/Xlib.h> | ||||
#include <X11/Xutil.h> | #include <X11/Xutil.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
static int get_winsize(dpy, window, p_width, p_height) | static int get_winsize(Display *dpy, Window window, int *p_width, int *p_height) | ||||
Display *dpy; | |||||
Window window; | |||||
int *p_width; | |||||
int *p_height; | |||||
{ | { | ||||
XWindowAttributes win_attributes; | XWindowAttributes win_attributes; | ||||
XSizeHints hints; | XSizeHints hints; | ||||
long longjunk; | long longjunk; | ||||
if (!XGetWindowAttributes(dpy, window, &win_attributes)) | if (!XGetWindowAttributes(dpy, window, &win_attributes)) | ||||
return 1; | return 1; | ||||
if (!XGetWMNormalHints(dpy, window, &hints, &longjunk)) | if (!XGetWMNormalHints(dpy, window, &hints, &longjunk)) | ||||
Show All 13 Lines | if (hints.flags & PBaseSize) | ||||
win_attributes.width -= hints.min_width; | win_attributes.width -= hints.min_width; | ||||
win_attributes.height -= hints.min_height; | win_attributes.height -= hints.min_height; | ||||
} | } | ||||
*p_width = win_attributes.width / hints.width_inc; | *p_width = win_attributes.width / hints.width_inc; | ||||
*p_height = win_attributes.height / hints.height_inc; | *p_height = win_attributes.height / hints.height_inc; | ||||
return 0; | return 0; | ||||
} | } | ||||
int main(argc, argv) | int main(int argc, char *argv[]) | ||||
int argc; | |||||
char *argv[]; | |||||
{ | { | ||||
char *cp; | char *cp; | ||||
Display *dpy; | Display *dpy; | ||||
int size[2]; | int size[2]; | ||||
_scrsize(size); | _scrsize(size); | ||||
cp = getenv("WINDOWID"); | cp = getenv("WINDOWID"); | ||||
if (cp != NULL) | if (cp != NULL) | ||||
Show All 11 Lines |