4 * An object oriented GL/GLES Abstraction/Utility Layer
6 * Copyright (C) 2010,2011 Intel Corporation.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 * Robert Bragg <robert@linux.intel.com>
32 #include <cogl-xlib.h>
34 #include <cogl-internal.h>
35 #include <cogl-handle.h>
36 #include <cogl-context-private.h>
37 #include <cogl-framebuffer-private.h>
38 #include <cogl-display-private.h>
39 #include <cogl-renderer-private.h>
40 #include <cogl-xlib-renderer-private.h>
43 #include <X11/extensions/Xdamage.h>
45 #include "cogl-xlib.h"
47 /* FIXME: when we remove the last X11 based Clutter backend then we
48 * will get rid of these functions and instead rely on the equivalent
49 * _cogl_xlib_renderer API
52 /* This can't be in the Cogl context because it can be set before
54 static Display *_cogl_xlib_display = NULL;
57 cogl_xlib_get_display (void)
59 _COGL_GET_CONTEXT (ctx, NULL);
61 return cogl_xlib_renderer_get_display (ctx->display->renderer);
65 cogl_xlib_set_display (Display *display)
67 /* This can only be called once before the Cogl context is created */
68 g_assert (_cogl_xlib_display == NULL);
70 _cogl_xlib_display = display;
73 /* These three functions are wrappers around the equivalent renderer
74 functions. They can be removed once all xlib-based backends in
75 Clutter know about the renderer */
77 cogl_xlib_handle_event (XEvent *xevent)
79 _COGL_GET_CONTEXT (ctx, COGL_FILTER_CONTINUE);
81 /* Pass the event on to the renderer */
82 return cogl_xlib_renderer_handle_event (ctx->display->renderer, xevent);
86 _cogl_xlib_query_damage_extension (void)
90 _COGL_GET_CONTEXT (ctxt, NO_RETVAL);
92 /* Check whether damage events are supported on this display */
93 if (!XDamageQueryExtension (cogl_xlib_get_display (),
96 ctxt->damage_base = -1;
100 _cogl_xlib_get_damage_base (void)
102 CoglX11Renderer *x11_renderer;
103 _COGL_GET_CONTEXT (ctxt, -1);
106 (CoglX11Renderer *) _cogl_xlib_renderer_get_data (ctxt->display->renderer);
107 return x11_renderer->damage_base;