]> Dogcows Code - chaz/openbox/blob - openbox/extensions.c
2fdc686316321b278b188ee411a7104e5e8b957d
[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) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 See the COPYING file for a copy of the GNU General Public License.
18 */
19
20 #include "openbox.h"
21 #include "geom.h"
22 #include "extensions.h"
23 #include "screen.h"
24 #include "debug.h"
25
26 gboolean extensions_xkb = FALSE;
27 gint extensions_xkb_event_basep;
28 gboolean extensions_shape = FALSE;
29 gint extensions_shape_event_basep;
30 gboolean extensions_xinerama = FALSE;
31 gint extensions_xinerama_event_basep;
32 gboolean extensions_randr = FALSE;
33 gint extensions_randr_event_basep;
34 gboolean extensions_sync = FALSE;
35 gint extensions_sync_event_basep;
36 gboolean extensions_comp = FALSE;
37 gint extensions_comp_event_basep;
38
39 void extensions_query_all()
40 {
41 gint junk;
42 (void)junk;
43
44 #ifdef XKB
45 extensions_xkb =
46 XkbQueryExtension(ob_display, &junk, &extensions_xkb_event_basep,
47 &junk, NULL, NULL);
48 if (!extensions_xkb)
49 ob_debug("XKB extension is not present on the server\n");
50 #endif
51
52 #ifdef SHAPE
53 extensions_shape =
54 XShapeQueryExtension(ob_display, &extensions_shape_event_basep,
55 &junk);
56 if (!extensions_shape)
57 ob_debug("X Shape extension is not present on the server\n");
58 #endif
59
60 #ifdef XINERAMA
61 extensions_xinerama =
62 XineramaQueryExtension(ob_display, &extensions_xinerama_event_basep,
63 &junk) && XineramaIsActive(ob_display);
64 if (!extensions_xinerama)
65 ob_debug("Xinerama extension is not present on the server\n");
66 #endif
67
68 #ifdef XRANDR
69 extensions_randr =
70 XRRQueryExtension(ob_display, &extensions_randr_event_basep,
71 &junk);
72 if (!extensions_randr)
73 ob_debug("XRandR extension is not present on the server\n");
74 #endif
75
76 #ifdef SYNC
77 extensions_sync =
78 XSyncQueryExtension(ob_display, &extensions_sync_event_basep,
79 &junk) &&
80 XSyncInitialize(ob_display, &junk, &junk);
81 if (!extensions_sync)
82 ob_debug("X Sync extension is not present on the server or is an "
83 "incompatible version\n");
84 #endif
85
86 #ifdef USE_XCOMPOSITE
87 if (XCompositeQueryExtension(ob_display, &extensions_comp_event_basep,
88 &junk))
89 {
90 gint major = 0, minor = 2;
91 XCompositeQueryVersion(ob_display, &major, &minor);
92 /* Version 0.2 is the first version to have the
93 XCompositeNameWindowPixmap() request. */
94 if (major > 0 || minor >= 2)
95 extensions_comp = TRUE;
96 }
97 if (!extensions_comp)
98 ob_debug("X Composite extension is not present on the server or is an "
99 "incompatible version\n");
100 #endif
101 }
102
103 void extensions_xinerama_screens(Rect **xin_areas, guint *nxin)
104 {
105 guint i;
106 gint l, r, t, b;
107 #ifdef XINERAMA
108 if (extensions_xinerama) {
109 guint i;
110 gint n;
111 XineramaScreenInfo *info = XineramaQueryScreens(ob_display, &n);
112 *nxin = n;
113 *xin_areas = g_new(Rect, *nxin + 1);
114 for (i = 0; i < *nxin; ++i)
115 RECT_SET((*xin_areas)[i], info[i].x_org, info[i].y_org,
116 info[i].width, info[i].height);
117 XFree(info);
118 } else
119 #endif
120 if (ob_debug_xinerama) {
121 gint w = WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen));
122 gint h = HeightOfScreen(ScreenOfDisplay(ob_display, ob_screen));
123 *nxin = 2;
124 *xin_areas = g_new(Rect, *nxin + 1);
125 RECT_SET((*xin_areas)[0], 0, 0, w/2, h);
126 RECT_SET((*xin_areas)[1], w/2, 0, w-(w/2), h);
127 }
128 else {
129 *nxin = 1;
130 *xin_areas = g_new(Rect, *nxin + 1);
131 RECT_SET((*xin_areas)[0], 0, 0,
132 WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen)),
133 HeightOfScreen(ScreenOfDisplay(ob_display, ob_screen)));
134 }
135
136 /* returns one extra with the total area in it */
137 l = (*xin_areas)[0].x;
138 t = (*xin_areas)[0].y;
139 r = (*xin_areas)[0].x + (*xin_areas)[0].width - 1;
140 b = (*xin_areas)[0].y + (*xin_areas)[0].height - 1;
141 for (i = 1; i < *nxin; ++i) {
142 l = MIN(l, (*xin_areas)[i].x);
143 t = MIN(l, (*xin_areas)[i].y);
144 r = MAX(r, (*xin_areas)[i].x + (*xin_areas)[i].width - 1);
145 b = MAX(b, (*xin_areas)[i].y + (*xin_areas)[i].height - 1);
146 }
147 RECT_SET((*xin_areas)[*nxin], l, t, r - l + 1, b - t + 1);
148 }
149
150 #ifdef USE_XCOMPOSITE
151 Picture extensions_create_composite_picture(Window win, Visual *vis,
152 gboolean *has_alpha)
153 {
154 }
155 #endif
This page took 0.046354 seconds and 3 git commands to generate.