4 #include "obt/display.h"
6 static void find_visuals(LocoScreen *sc);
8 static guint window_hash(Window *w) { return *w; }
9 static gboolean window_comp(Window *w1, Window *w2) { return *w1 == *w2; }
11 static const int drawable_tfp_attrs[] = {
12 GLX_CONFIG_CAVEAT, GLX_NONE,
13 GLX_DOUBLEBUFFER, FALSE,
19 GLX_RENDER_TYPE, GLX_RGBA_BIT,
20 GLX_BIND_TO_TEXTURE_RGBA_EXT, TRUE, /* For TextureFromPixmap */
24 LocoScreen* loco_screen_new(gint number)
28 /* try get the root redirect */
29 obt_display_ignore_errors(TRUE);
30 XCompositeRedirectSubwindows(obt_display, obt_root(number),
31 CompositeRedirectManual);
32 obt_display_ignore_errors(FALSE);
33 if (obt_display_error_occured) {
34 g_message("Another composite manager is running on screen %d", number);
38 sc = g_new0(LocoScreen, 1);
41 sc->root = obt_root(number);
42 //sc->root = loco_window_new(obt_root(number));
43 sc->stacking_map = g_hash_table_new((GHashFunc)window_hash,
44 (GEqualFunc)window_comp);
45 sc->stacking_map_ptr = g_hash_table_new((GHashFunc)g_direct_hash,
46 (GEqualFunc)g_direct_equal);
47 sc->bindTexImageEXT = (BindEXTFunc)
48 glXGetProcAddress((const guchar*)"glXBindTexImageEXT");
49 sc->releaseTexImageEXT = (ReleaseEXTFunc)
50 glXGetProcAddress((const guchar*)"glXReleaseTexImageEXT");
54 sc->overlay = XCompositeGetOverlayWindow(obt_display, sc->root);
59 region = XFixesCreateRegion(obt_display, NULL, 0);
60 XFixesSetWindowShapeRegion(obt_display, sc->overlay,
61 ShapeBounding, 0, 0, 0);
62 XFixesSetWindowShapeRegion(obt_display, sc->overlay,
63 ShapeInput, 0, 0, region);
64 XFixesDestroyRegion(obt_display, region);
67 loco_screen_redraw(sc);
72 void loco_screen_ref(LocoScreen *sc)
77 void loco_screen_unref(LocoScreen *sc)
79 if (sc && --sc->ref == 0) {
80 /*XXX loco_window_unref(sc->root);*/
83 XCompositeReleaseOverlayWindow(obt_display, sc->overlay);
85 g_hash_table_destroy(sc->stacking_map);
86 g_hash_table_destroy(sc->stacking_map_ptr);
92 static void find_visuals(LocoScreen *sc)
94 gint db, stencil, depth;
95 gint i, j, value, count;
96 XVisualInfo tvis, *visinfo;
100 fbcons = glXChooseFBConfig(obt_display, sc->number,
101 drawable_tfp_attrs, &numfb);
106 for (i = 0; i <= LOCO_SCREEN_MAX_DEPTH; i++) {
110 sc->glxFBConfig[i] = 0;
113 visinfo = XGetVisualInfo(obt_display, VisualDepthMask, &tvis, &count);
114 /* pick the nicest visual for the depth */
115 for (j = 0; j < count; j++) {
116 glXGetConfig(obt_display, &visinfo[j], GLX_USE_GL, &value);
120 glXGetConfig(obt_display, &visinfo[j], GLX_DOUBLEBUFFER, &value);
125 glXGetConfig(obt_display, &visinfo[j], GLX_STENCIL_SIZE, &value);
130 glXGetConfig(obt_display, &visinfo[j], GLX_DEPTH_SIZE, &value);
135 /* use this visual */
136 vid = visinfo[j].visualid;
142 g_print("found visual %d\n", i);
144 /* find the fbconfig for this depth/visual */
145 for(j = 0; j < numfb; ++j) {
146 glXGetFBConfigAttrib(obt_display, fbcons[j],
147 GLX_VISUAL_ID, &value);
148 if (value == (int)vid) {
149 sc->glxFBConfig[i] = fbcons[j]; /* save it */
150 g_print("supporting depth %d\n", i);
151 break; /* next depth */
159 void loco_screen_add_window(LocoScreen *sc, LocoWindow *lw)
163 g_print("add window 0x%lx\n", lw->id);
165 /* new windows are at the top */
166 it = loco_list_prepend(&sc->stacking_top, &sc->stacking_bottom, lw);
167 g_hash_table_insert(sc->stacking_map, &lw->id, it);
168 g_hash_table_insert(sc->stacking_map_ptr, &lw, it);
173 void loco_screen_zombie_window(LocoScreen *sc, LocoWindow *lw)
175 g_print("zombie window 0x%lx\n", lw->id);
177 /* the id will no longer be useful, so remove it from the hash */
178 g_hash_table_remove(sc->stacking_map, &lw->id);
181 void loco_screen_remove_window(LocoScreen *sc, LocoWindow *lw)
185 g_print("remove window 0x%lx\n", lw->id);
187 pos = loco_screen_find_stacking_ptr(sc, lw);
189 loco_list_delete_link(&sc->stacking_top, &sc->stacking_bottom, pos);
190 g_hash_table_remove(sc->stacking_map, &lw->id);
191 g_hash_table_remove(sc->stacking_map_ptr, &lw);
193 loco_window_unref(lw);
196 struct _LocoWindow* loco_screen_find_window(LocoScreen *sc, Window xwin)
200 it = g_hash_table_lookup(sc->stacking_map, &xwin);
201 return (it ? it->window : NULL);
204 struct _LocoList* loco_screen_find_stacking(LocoScreen *sc, Window xwin)
206 return g_hash_table_lookup(sc->stacking_map, &xwin);
209 struct _LocoList* loco_screen_find_stacking_ptr(LocoScreen *sc, LocoWindow *lw)
211 return g_hash_table_lookup(sc->stacking_map_ptr, &lw);
214 void loco_screen_redraw(LocoScreen *sc)
219 void loco_screen_redraw_done(LocoScreen *sc)