1947803a793dce8d7da389ce27ba015bdc97aa22
[profile/ivi/clutter.git] / clutter / x11 / clutter-backend-x11.h
1 /* Clutter.
2  * An OpenGL based 'interactive canvas' library.
3  * Authored By Matthew Allum  <mallum@openedhand.com>
4  * Copyright (C) 2006-2007 OpenedHand
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  *
20  */
21
22 #ifndef __CLUTTER_BACKEND_X11_H__
23 #define __CLUTTER_BACKEND_X11_H__
24
25 #include <glib-object.h>
26 #include <clutter/clutter-event.h>
27 #include <X11/Xlib.h>
28 #include <X11/Xatom.h>
29
30 #include "clutter-x11.h"
31 #include "clutter-backend-private.h"
32 #include "clutter-keymap-x11.h"
33 #include "xsettings/xsettings-client.h"
34
35 G_BEGIN_DECLS
36
37 #define CLUTTER_TYPE_BACKEND_X11                (clutter_backend_x11_get_type ())
38 #define CLUTTER_BACKEND_X11(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BACKEND_X11, ClutterBackendX11))
39 #define CLUTTER_IS_BACKEND_X11(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BACKEND_X11))
40 #define CLUTTER_BACKEND_X11_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND_X11, ClutterBackendX11Class))
41 #define CLUTTER_IS_BACKEND_X11_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_BACKEND_X11))
42 #define CLUTTER_BACKEND_X11_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_BACKEND_X11, ClutterBackendX11Class))
43
44 typedef struct _ClutterBackendX11       ClutterBackendX11;
45 typedef struct _ClutterBackendX11Class  ClutterBackendX11Class;
46
47 typedef struct _ClutterX11EventFilter
48 {
49   ClutterX11FilterFunc func;
50   gpointer             data;
51
52 } ClutterX11EventFilter;
53
54 struct _ClutterBackendX11
55 {
56   ClutterBackend parent_instance;
57
58   Display *xdpy;
59   Window   xwin_root;
60   Screen  *xscreen;
61   int      xscreen_num;
62   gchar   *display_name;
63
64   /* event source */
65   GSource *event_source;
66   GSList  *event_filters;
67
68   /* props */
69   Atom atom_NET_WM_PID;
70   Atom atom_NET_WM_PING;
71   Atom atom_NET_WM_STATE;
72   Atom atom_NET_WM_STATE_FULLSCREEN;
73   Atom atom_NET_WM_USER_TIME;
74   Atom atom_WM_PROTOCOLS;
75   Atom atom_WM_DELETE_WINDOW;
76   Atom atom_XEMBED;
77   Atom atom_XEMBED_INFO;
78   Atom atom_NET_WM_NAME;
79   Atom atom_UTF8_STRING;
80
81   int xi_event_base;
82   int event_types[CLUTTER_X11_XINPUT_LAST_EVENT];
83   gboolean have_xinput;
84
85   Time last_event_time;
86
87   ClutterDeviceManager *device_manager;
88
89   XSettingsClient *xsettings;
90   Window xsettings_xwin;
91
92   ClutterKeymapX11 *keymap;
93   int xkb_event_base;
94   gboolean use_xkb;
95   gboolean have_xkb_autorepeat;
96 };
97
98 struct _ClutterBackendX11Class
99 {
100   ClutterBackendClass parent_class;
101
102   /*
103    * To support foreign stage windows the we need a way to ask for an
104    * XVisualInfo that may be used by toolkits to create an XWindow, and this
105    * may need to be handled differently for different backends.
106    */
107   XVisualInfo *(* get_visual_info) (ClutterBackendX11 *backend);
108
109   /*
110    * Different X11 backends may care about some special events so they all have
111    * a chance to intercept them.
112    */
113   gboolean (*handle_event) (ClutterBackendX11 *backend,
114                             XEvent            *xevent);
115 };
116
117 /* platform-specific event data */
118 typedef struct _ClutterEventX11 ClutterEventX11;
119
120 void   _clutter_backend_x11_events_init (ClutterBackend *backend);
121 void   _clutter_backend_x11_events_uninit (ClutterBackend *backend);
122
123 GType clutter_backend_x11_get_type (void) G_GNUC_CONST;
124
125 /* Private to glx/eglx backends */
126 gboolean
127 clutter_backend_x11_pre_parse (ClutterBackend  *backend,
128                                GError         **error);
129
130 gboolean
131 clutter_backend_x11_post_parse (ClutterBackend  *backend,
132                                 GError         **error);
133
134 gboolean
135 clutter_backend_x11_init_stage (ClutterBackend  *backend,
136                                 GError         **error);
137
138 ClutterActor *
139 clutter_backend_x11_get_stage (ClutterBackend *backend);
140
141 void
142 clutter_backend_x11_add_options (ClutterBackend *backend,
143                                  GOptionGroup   *group);
144
145 ClutterFeatureFlags
146 clutter_backend_x11_get_features (ClutterBackend *backend);
147
148 XVisualInfo *
149 clutter_backend_x11_get_visual_info (ClutterBackendX11 *backend_x11);
150
151 ClutterInputDevice *
152 _clutter_x11_get_device_for_xid (XID id);
153
154 void
155 _clutter_x11_select_events (Window xwin);
156
157 ClutterEventX11 *
158 _clutter_event_x11_new (void);
159
160 ClutterEventX11 *
161 _clutter_event_x11_copy (ClutterEventX11 *event_x11);
162
163 void
164 _clutter_event_x11_free (ClutterEventX11 *event_x11);
165
166 G_END_DECLS
167
168 #endif /* __CLUTTER_BACKEND_X11_H__ */