scrsize.c (1ea316270f1f75922ac53976d5d8808a41442f46) | scrsize.c (f6b74a7d164b5fada266d00e723155a178a4529f) |
---|---|
1/* | 1/* |
2 * Copyright (C) 1984-2015 Mark Nudelman | 2 * Copyright (C) 1984-2017 Mark Nudelman |
3 * 4 * You may distribute under the terms of either the GNU General Public 5 * License or the Less License, as specified in the README file. 6 * 7 * For more information, see the README file. 8 */ 9 10/* --- 29 unchanged lines hidden (view full) --- 40 * dealings in this Software without prior written authorization from the X 41 * Consortium. 42 */ 43#include <X11/Xlib.h> 44#include <X11/Xutil.h> 45#include <stdlib.h> 46#include <stdio.h> 47 | 3 * 4 * You may distribute under the terms of either the GNU General Public 5 * License or the Less License, as specified in the README file. 6 * 7 * For more information, see the README file. 8 */ 9 10/* --- 29 unchanged lines hidden (view full) --- 40 * dealings in this Software without prior written authorization from the X 41 * Consortium. 42 */ 43#include <X11/Xlib.h> 44#include <X11/Xutil.h> 45#include <stdlib.h> 46#include <stdio.h> 47 |
48static int get_winsize(Display *dpy, Window window, int *p_width, int *p_height) | 48static int get_winsize(dpy, window, p_width, p_height) 49 Display *dpy; 50 Window window; 51 int *p_width; 52 int *p_height; |
49{ 50 XWindowAttributes win_attributes; 51 XSizeHints hints; 52 long longjunk; 53 54 if (!XGetWindowAttributes(dpy, window, &win_attributes)) 55 return 1; 56 if (!XGetWMNormalHints(dpy, window, &hints, &longjunk)) --- 13 unchanged lines hidden (view full) --- 70 win_attributes.width -= hints.min_width; 71 win_attributes.height -= hints.min_height; 72 } 73 *p_width = win_attributes.width / hints.width_inc; 74 *p_height = win_attributes.height / hints.height_inc; 75 return 0; 76} 77 | 53{ 54 XWindowAttributes win_attributes; 55 XSizeHints hints; 56 long longjunk; 57 58 if (!XGetWindowAttributes(dpy, window, &win_attributes)) 59 return 1; 60 if (!XGetWMNormalHints(dpy, window, &hints, &longjunk)) --- 13 unchanged lines hidden (view full) --- 74 win_attributes.width -= hints.min_width; 75 win_attributes.height -= hints.min_height; 76 } 77 *p_width = win_attributes.width / hints.width_inc; 78 *p_height = win_attributes.height / hints.height_inc; 79 return 0; 80} 81 |
78int main(int argc, char *argv[]) | 82int main(argc, argv) 83 int argc; 84 char *argv[]; |
79{ 80 char *cp; 81 Display *dpy; 82 int size[2]; 83 84 _scrsize(size); 85 cp = getenv("WINDOWID"); 86 if (cp != NULL) 87 { 88 dpy = XOpenDisplay(NULL); 89 if (dpy != NULL) 90 { 91 get_winsize(dpy, (Window) atol(cp), &size[0], &size[1]); 92 XCloseDisplay(dpy); 93 } 94 } 95 printf("%i %i\n", size[0], size[1]); 96 return (0); 97} | 85{ 86 char *cp; 87 Display *dpy; 88 int size[2]; 89 90 _scrsize(size); 91 cp = getenv("WINDOWID"); 92 if (cp != NULL) 93 { 94 dpy = XOpenDisplay(NULL); 95 if (dpy != NULL) 96 { 97 get_winsize(dpy, (Window) atol(cp), &size[0], &size[1]); 98 XCloseDisplay(dpy); 99 } 100 } 101 printf("%i %i\n", size[0], size[1]); 102 return (0); 103} |