1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 extensions.c for the Openbox window manager
4 Copyright (c) 2003 Ben Jansens
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 See the COPYING file for a copy of the GNU General Public License.
21 #include "extensions.h"
24 gboolean extensions_xkb
= FALSE
;
25 gint extensions_xkb_event_basep
;
26 gboolean extensions_shape
= FALSE
;
27 gint extensions_shape_event_basep
;
28 gboolean extensions_xinerama
= FALSE
;
29 gint extensions_xinerama_event_basep
;
30 gboolean extensions_randr
= FALSE
;
31 gint extensions_randr_event_basep
;
33 void extensions_query_all()
40 XkbQueryExtension(ob_display
, &junk
, &extensions_xkb_event_basep
,
46 XShapeQueryExtension(ob_display
, &extensions_shape_event_basep
,
52 XineramaQueryExtension(ob_display
, &extensions_xinerama_event_basep
,
53 &junk
) && XineramaIsActive(ob_display
);
58 XRRQueryExtension(ob_display
, &extensions_randr_event_basep
,
63 void extensions_xinerama_screens(Rect
**xin_areas
, guint
*nxin
)
68 if (extensions_xinerama
) {
71 XineramaScreenInfo
*info
= XineramaQueryScreens(ob_display
, &n
);
73 *xin_areas
= g_new(Rect
, *nxin
+ 1);
74 for (i
= 0; i
< *nxin
; ++i
)
75 RECT_SET((*xin_areas
)[i
], info
[i
].x_org
, info
[i
].y_org
,
76 info
[i
].width
, info
[i
].height
);
81 *xin_areas
= g_new(Rect
, *nxin
+ 1);
82 RECT_SET((*xin_areas
)[0], 0, 0,
83 WidthOfScreen(ScreenOfDisplay(ob_display
, ob_screen
)),
84 HeightOfScreen(ScreenOfDisplay(ob_display
, ob_screen
)));
87 /* returns one extra with the total area in it */
88 l
= (*xin_areas
)[0].x
;
89 t
= (*xin_areas
)[0].y
;
90 r
= (*xin_areas
)[0].x
+ (*xin_areas
)[0].width
- 1;
91 b
= (*xin_areas
)[0].y
+ (*xin_areas
)[0].height
- 1;
92 for (i
= 1; i
< *nxin
; ++i
) {
93 l
= MIN(l
, (*xin_areas
)[i
].x
);
94 t
= MIN(l
, (*xin_areas
)[i
].y
);
95 r
= MAX(r
, (*xin_areas
)[i
].x
+ (*xin_areas
)[i
].width
- 1);
96 b
= MAX(b
, (*xin_areas
)[i
].y
+ (*xin_areas
)[i
].height
- 1);
98 RECT_SET((*xin_areas
)[*nxin
], l
, t
, r
- l
+ 1, b
- t
+ 1);