]> Dogcows Code - chaz/openbox/blob - openbox/extensions.c
79e40c37fb131e6d353542973f65564bdf919c27
[chaz/openbox] / openbox / extensions.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3 extensions.c for the Openbox window manager
4 Copyright (c) 2003 Ben Jansens
5
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.
10
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.
15
16 See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #include "openbox.h"
20 #include "geom.h"
21 #include "extensions.h"
22 #include "screen.h"
23
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;
32
33 void extensions_query_all()
34 {
35 gint junk;
36 (void)junk;
37
38 #ifdef XKB
39 extensions_xkb =
40 XkbQueryExtension(ob_display, &junk, &extensions_xkb_event_basep,
41 &junk, NULL, NULL);
42 #endif
43
44 #ifdef SHAPE
45 extensions_shape =
46 XShapeQueryExtension(ob_display, &extensions_shape_event_basep,
47 &junk);
48 #endif
49
50 #ifdef XINERAMA
51 extensions_xinerama =
52 XineramaQueryExtension(ob_display, &extensions_xinerama_event_basep,
53 &junk) && XineramaIsActive(ob_display);
54 #endif
55
56 #ifdef XRANDR
57 extensions_randr =
58 XRRQueryExtension(ob_display, &extensions_randr_event_basep,
59 &junk);
60 #endif
61 }
62
63 void extensions_xinerama_screens(Rect **xin_areas, guint *nxin)
64 {
65 guint i;
66 gint l, r, t, b;
67 #ifdef XINERAMA
68 if (extensions_xinerama) {
69 guint i;
70 gint n;
71 XineramaScreenInfo *info = XineramaQueryScreens(ob_display, &n);
72 *nxin = 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);
77 } else
78 #endif
79 {
80 *nxin = 1;
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)));
85 }
86
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);
97 }
98 RECT_SET((*xin_areas)[*nxin], l, t, r - l + 1, b - t + 1);
99 }
This page took 0.036047 seconds and 3 git commands to generate.