"Initial commit to Gerrit"
[profile/ivi/cogl.git] / cogl / cogl-xlib-renderer.h
1 /*
2  * Cogl
3  *
4  * An object oriented GL/GLES Abstraction/Utility Layer
5  *
6  * Copyright (C) 2011 Intel Corporation.
7  *
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.
12  *
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.
17  *
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.
22  */
23
24 #if !defined(__COGL_XLIB_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
25 #error "Only <cogl/cogl-xlib.h> can be included directly."
26 #endif
27
28 #ifndef __COGL_XLIB_RENDERER_H__
29 #define __COGL_XLIB_RENDERER_H__
30
31 #include <X11/Xlib.h>
32 #include <glib.h>
33
34 #define __COGL_H_INSIDE__
35 #include <cogl/cogl-renderer.h>
36
37 G_BEGIN_DECLS
38
39 #define cogl_xlib_renderer_handle_event \
40   cogl_xlib_renderer_handle_event_EXP
41 /*
42  * cogl_xlib_renderer_handle_event:
43  * @event: pointer to an XEvent structure
44  *
45  * This function processes a single event; it can be used to hook into
46  * external event retrieval (for example that done by Clutter or
47  * GDK).
48  *
49  * Return value: #CoglFilterReturn. %COGL_FILTER_REMOVE indicates that
50  * Cogl has internally handled the event and the caller should do no
51  * further processing. %COGL_FILTER_CONTINUE indicates that Cogl is
52  * either not interested in the event, or has used the event to update
53  * internal state without taking any exclusive action.
54  */
55 CoglFilterReturn
56 cogl_xlib_renderer_handle_event (CoglRenderer *renderer,
57                                  XEvent *event);
58
59 /*
60  * CoglXlibFilterFunc:
61  * @event: pointer to an XEvent structure
62  * @data: The data that was given when the filter was added
63  *
64  * A callback function that can be registered with
65  * cogl_xlib_renderer_add_filter(). The function should return
66  * %COGL_FILTER_REMOVE if it wants to prevent further processing or
67  * %COGL_FILTER_CONTINUE otherwise.
68  */
69 typedef CoglFilterReturn (* CoglXlibFilterFunc) (XEvent *event,
70                                                  void *data);
71
72 #define cogl_xlib_renderer_add_filter cogl_xlib_renderer_add_filter_EXP
73 /*
74  * cogl_xlib_renderer_add_filter:
75  *
76  * Adds a callback function that will receive all native events. The
77  * function can stop further processing of the event by return
78  * %COGL_FILTER_REMOVE.
79  */
80 void
81 cogl_xlib_renderer_add_filter (CoglRenderer *renderer,
82                                CoglXlibFilterFunc func,
83                                void *data);
84
85 #define cogl_xlib_renderer_remove_filter \
86   cogl_xlib_renderer_remove_filter_EXP
87 /*
88  * cogl_xlib_renderer_remove_filter:
89  *
90  * Removes a callback that was previously added with
91  * cogl_xlib_renderer_add_filter().
92  */
93 void
94 cogl_xlib_renderer_remove_filter (CoglRenderer *renderer,
95                                   CoglXlibFilterFunc func,
96                                   void *data);
97
98 #define cogl_xlib_renderer_get_foreign_display \
99   cogl_xlib_renderer_get_foreign_display_EXP
100 /*
101  * cogl_xlib_renderer_get_foreign_display:
102  *
103  * Return value: the foreign Xlib display that will be used by any Xlib based
104  * winsys backend. The display needs to be set with
105  * cogl_xlib_renderer_set_foreign_display() before this function is called.
106  */
107 Display *
108 cogl_xlib_renderer_get_foreign_display (CoglRenderer *renderer);
109
110 #define cogl_xlib_renderer_set_foreign_display \
111   cogl_xlib_renderer_set_foreign_display_EXP
112 /*
113  * cogl_xlib_renderer_set_foreign_display:
114  *
115  * Sets a foreign Xlib display that Cogl will use for and Xlib based winsys
116  * backend.
117  *
118  * Note that calling this function will automatically call
119  * cogl_xlib_renderer_set_event_retrieval_enabled() to disable Cogl's
120  * event retrieval. Cogl still needs to see all of the X events so the
121  * application should also use cogl_xlib_renderer_handle_event() if it
122  * uses this function.
123  */
124 void
125 cogl_xlib_renderer_set_foreign_display (CoglRenderer *renderer,
126                                         Display *display);
127
128 /**
129  * cogl_xlib_renderer_set_event_retrieval_enabled:
130  * @renderer: A #CoglRenderer
131  * @enable: The new value
132  *
133  * Sets whether Cogl should automatically retrieve events from the X
134  * display. This defaults to %TRUE unless
135  * cogl_xlib_renderer_set_foreign_display() is called. It can be set
136  * to %FALSE if the application wants to handle its own event
137  * retrieval. Note that Cogl still needs to see all of the X events to
138  * function properly so the application should call
139  * cogl_xlib_renderer_handle_event() for each event if it disables
140  * automatic event retrieval.
141  *
142  * Since: 1.10
143  * Stability: unstable
144  */
145 void
146 cogl_xlib_renderer_set_event_retrieval_enabled (CoglRenderer *renderer,
147                                                 gboolean enable);
148
149 #define cogl_xlib_renderer_get_display cogl_xlib_renderer_get_display_EXP
150 Display *
151 cogl_xlib_renderer_get_display (CoglRenderer *renderer);
152
153 G_END_DECLS
154
155 #endif /* __COGL_XLIB_RENDERER_H__ */