1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 extensions.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
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.
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.
17 See the COPYING file for a copy of the GNU General Public License.
22 #include "extensions.h"
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
;
37 void extensions_query_all(void)
44 XkbQueryExtension(ob_display
, &junk
, &extensions_xkb_event_basep
,
47 ob_debug("XKB extension is not present on the server\n");
52 XShapeQueryExtension(ob_display
, &extensions_shape_event_basep
,
54 if (!extensions_shape
)
55 ob_debug("X Shape extension is not present on the server\n");
60 XineramaQueryExtension(ob_display
, &extensions_xinerama_event_basep
,
61 &junk
) && XineramaIsActive(ob_display
);
62 if (!extensions_xinerama
)
63 ob_debug("Xinerama extension is not present on the server\n");
68 XRRQueryExtension(ob_display
, &extensions_randr_event_basep
,
70 if (!extensions_randr
)
71 ob_debug("XRandR extension is not present on the server\n");
76 XSyncQueryExtension(ob_display
, &extensions_sync_event_basep
,
78 XSyncInitialize(ob_display
, &junk
, &junk
);
80 ob_debug("X Sync extension is not present on the server or is an "
81 "incompatible version\n");
85 void extensions_xinerama_screens(Rect
**xin_areas
, guint
*nxin
)
89 if (ob_debug_xinerama
) {
90 g_print("Using fake xinerama !\n");
91 gint w
= WidthOfScreen(ScreenOfDisplay(ob_display
, ob_screen
));
92 gint h
= HeightOfScreen(ScreenOfDisplay(ob_display
, ob_screen
));
94 *xin_areas
= g_new(Rect
, *nxin
+ 1);
95 RECT_SET((*xin_areas
)[0], 0, 0, w
/2, h
);
96 RECT_SET((*xin_areas
)[1], w
/2, 0, w
-(w
/2), h
);
100 if (extensions_xinerama
) {
103 XineramaScreenInfo
*info
= XineramaQueryScreens(ob_display
, &n
);
105 *xin_areas
= g_new(Rect
, *nxin
+ 1);
106 for (i
= 0; i
< *nxin
; ++i
)
107 RECT_SET((*xin_areas
)[i
], info
[i
].x_org
, info
[i
].y_org
,
108 info
[i
].width
, info
[i
].height
);
115 *xin_areas
= g_new(Rect
, *nxin
+ 1);
116 RECT_SET((*xin_areas
)[0], 0, 0,
117 WidthOfScreen(ScreenOfDisplay(ob_display
, ob_screen
)),
118 HeightOfScreen(ScreenOfDisplay(ob_display
, ob_screen
)));
121 /* returns one extra with the total area in it */
122 l
= (*xin_areas
)[0].x
;
123 t
= (*xin_areas
)[0].y
;
124 r
= (*xin_areas
)[0].x
+ (*xin_areas
)[0].width
- 1;
125 b
= (*xin_areas
)[0].y
+ (*xin_areas
)[0].height
- 1;
126 for (i
= 1; i
< *nxin
; ++i
) {
127 l
= MIN(l
, (*xin_areas
)[i
].x
);
128 t
= MIN(l
, (*xin_areas
)[i
].y
);
129 r
= MAX(r
, (*xin_areas
)[i
].x
+ (*xin_areas
)[i
].width
- 1);
130 b
= MAX(b
, (*xin_areas
)[i
].y
+ (*xin_areas
)[i
].height
- 1);
132 RECT_SET((*xin_areas
)[*nxin
], l
, t
, r
- l
+ 1, b
- t
+ 1);