2
* utils_x11.h - X11 utilities
4
* vdpau-video (C) 2009-2011 Splitted-Desktop Systems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22
#include <X11/Xutil.h>
23
#include "utils_x11.h"
27
static int x11_error_code = 0;
28
static int (*old_error_handler)(Display *, XErrorEvent *);
30
static int error_handler(Display *dpy, XErrorEvent *error)
32
x11_error_code = error->error_code;
36
void x11_trap_errors(void)
39
old_error_handler = XSetErrorHandler(error_handler);
42
int x11_untrap_errors(void)
44
XSetErrorHandler(old_error_handler);
45
return x11_error_code;
60
unsigned int width, height, border_width, depth;
67
&x, &y, &width, &height,
71
if (x11_untrap_errors())
76
if (pwidth) *pwidth = width;
77
if (pheight) *pheight = height;