2007-11-15 09:45:27 -05:00
|
|
|
/* Clutter.
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
|
|
|
* Copyright (C) 2006-2007 OpenedHand
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2009-01-06 07:11:07 -05:00
|
|
|
#include <glib/gi18n-lib.h>
|
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include "clutter-backend-x11.h"
|
|
|
|
#include "clutter-stage-x11.h"
|
|
|
|
#include "clutter-x11.h"
|
2008-06-30 10:36:49 -04:00
|
|
|
#include <X11/extensions/Xcomposite.h>
|
2008-06-23 05:55:42 -04:00
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
#include "../clutter-event.h"
|
|
|
|
#include "../clutter-main.h"
|
|
|
|
#include "../clutter-debug.h"
|
|
|
|
#include "../clutter-private.h"
|
|
|
|
|
2008-04-25 09:37:36 -04:00
|
|
|
#include "cogl/cogl.h"
|
2007-11-15 09:45:27 -05:00
|
|
|
|
|
|
|
G_DEFINE_TYPE (ClutterBackendX11, clutter_backend_x11, CLUTTER_TYPE_BACKEND);
|
|
|
|
|
2008-06-23 05:55:42 -04:00
|
|
|
struct _ClutterX11XInputDevice
|
|
|
|
{
|
|
|
|
ClutterInputDevice device;
|
|
|
|
#ifdef USE_XINPUT
|
|
|
|
XDevice *xdevice;
|
|
|
|
XEventClass xevent_list[5]; /* MAX 5 event types */
|
|
|
|
int num_events;
|
|
|
|
#endif
|
|
|
|
ClutterX11InputDeviceType type; /* FIXME: generic to ClutterInputDevice? */
|
2008-09-23 03:03:35 -04:00
|
|
|
};
|
2008-06-23 05:55:42 -04:00
|
|
|
|
|
|
|
#ifdef USE_XINPUT
|
|
|
|
void _clutter_x11_register_xinput ();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2007-11-17 13:11:14 -05:00
|
|
|
/* atoms; remember to add the code that assigns the atom value to
|
|
|
|
* the member of the ClutterBackendX11 structure if you add an
|
|
|
|
* atom name here. do not change the order!
|
|
|
|
*/
|
|
|
|
static const gchar *atom_names[] = {
|
|
|
|
"_NET_WM_PING",
|
|
|
|
"_NET_WM_STATE",
|
|
|
|
"_NET_WM_STATE_FULLSCREEN",
|
|
|
|
"_NET_WM_USER_TIME",
|
|
|
|
"WM_PROTOCOLS",
|
|
|
|
"WM_DELETE_WINDOW",
|
|
|
|
"_XEMBED",
|
|
|
|
"_XEMBED_INFO",
|
|
|
|
"_NET_WM_NAME",
|
|
|
|
"UTF8_STRING",
|
|
|
|
};
|
|
|
|
|
|
|
|
static const guint n_atom_names = G_N_ELEMENTS (atom_names);
|
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
/* singleton object */
|
|
|
|
static ClutterBackendX11 *backend_singleton = NULL;
|
|
|
|
|
2008-07-01 09:41:23 -04:00
|
|
|
/* various flags corresponding to pre init setup calls */
|
|
|
|
static gboolean _no_xevent_retrieval = FALSE;
|
|
|
|
static gboolean _enable_xinput = FALSE;
|
|
|
|
static Display *_foreign_dpy = NULL;
|
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
/* options */
|
|
|
|
static gchar *clutter_display_name = NULL;
|
|
|
|
static gint clutter_screen = 0;
|
|
|
|
static gboolean clutter_synchronise = FALSE;
|
|
|
|
|
|
|
|
/* X error trap */
|
|
|
|
static int TrappedErrorCode = 0;
|
|
|
|
static int (* old_error_handler) (Display *, XErrorEvent *);
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
clutter_backend_x11_pre_parse (ClutterBackend *backend,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
const gchar *env_string;
|
|
|
|
|
|
|
|
/* we don't fail here if DISPLAY is not set, as the user
|
|
|
|
* might pass the --display command line switch
|
|
|
|
*/
|
|
|
|
env_string = g_getenv ("DISPLAY");
|
|
|
|
if (env_string)
|
|
|
|
{
|
|
|
|
clutter_display_name = g_strdup (env_string);
|
|
|
|
env_string = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
clutter_backend_x11_post_parse (ClutterBackend *backend,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
|
|
|
|
|
2008-07-01 09:41:23 -04:00
|
|
|
if (_foreign_dpy)
|
|
|
|
backend_x11->xdpy = _foreign_dpy;
|
2008-02-20 09:16:54 -05:00
|
|
|
/*
|
|
|
|
* Only open connection if not already set by prior call to
|
|
|
|
* clutter_x11_set_display()
|
|
|
|
*/
|
|
|
|
if (!backend_x11->xdpy)
|
2007-11-15 09:45:27 -05:00
|
|
|
{
|
2008-02-20 09:16:54 -05:00
|
|
|
if (clutter_display_name)
|
|
|
|
{
|
|
|
|
CLUTTER_NOTE (BACKEND, "XOpenDisplay on `%s'",
|
|
|
|
clutter_display_name);
|
|
|
|
backend_x11->xdpy = XOpenDisplay (clutter_display_name);
|
2008-10-31 08:48:26 -04:00
|
|
|
if (backend_x11->xdpy == None)
|
|
|
|
{
|
|
|
|
g_set_error (error, CLUTTER_INIT_ERROR,
|
|
|
|
CLUTTER_INIT_ERROR_BACKEND,
|
|
|
|
"Unable to open display `%s'",
|
|
|
|
clutter_display_name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-02-20 09:16:54 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_set_error (error, CLUTTER_INIT_ERROR,
|
|
|
|
CLUTTER_INIT_ERROR_BACKEND,
|
|
|
|
"Unable to open display. You have to set the DISPLAY "
|
|
|
|
"environment variable, or use the --display command "
|
|
|
|
"line argument");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-11-15 09:45:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (backend_x11->xdpy)
|
|
|
|
{
|
2007-11-17 13:11:14 -05:00
|
|
|
Atom atoms[n_atom_names];
|
2007-11-15 09:45:27 -05:00
|
|
|
double dpi;
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND, "Getting the X screen");
|
|
|
|
|
|
|
|
if (clutter_screen == 0)
|
|
|
|
backend_x11->xscreen = DefaultScreenOfDisplay (backend_x11->xdpy);
|
|
|
|
else
|
|
|
|
backend_x11->xscreen = ScreenOfDisplay (backend_x11->xdpy,
|
|
|
|
clutter_screen);
|
2008-02-20 09:16:54 -05:00
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
backend_x11->xscreen_num = XScreenNumberOfScreen (backend_x11->xscreen);
|
|
|
|
|
|
|
|
backend_x11->xwin_root = RootWindow (backend_x11->xdpy,
|
|
|
|
backend_x11->xscreen_num);
|
2008-02-20 09:16:54 -05:00
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
backend_x11->display_name = g_strdup (clutter_display_name);
|
|
|
|
|
|
|
|
dpi = (((double) DisplayHeight (backend_x11->xdpy, backend_x11->xscreen_num) * 25.4)
|
|
|
|
/ (double) DisplayHeightMM (backend_x11->xdpy, backend_x11->xscreen_num));
|
|
|
|
|
|
|
|
clutter_backend_set_resolution (backend, dpi);
|
|
|
|
|
2008-06-23 05:55:42 -04:00
|
|
|
#ifdef USE_XINPUT
|
|
|
|
_clutter_x11_register_xinput ();
|
|
|
|
#endif
|
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
if (clutter_synchronise)
|
|
|
|
XSynchronize (backend_x11->xdpy, True);
|
2008-09-23 03:03:35 -04:00
|
|
|
|
2007-11-17 13:11:14 -05:00
|
|
|
XInternAtoms (backend_x11->xdpy,
|
|
|
|
(char **) atom_names, n_atom_names,
|
|
|
|
False, atoms);
|
|
|
|
|
|
|
|
backend_x11->atom_NET_WM_PING = atoms[0];
|
|
|
|
backend_x11->atom_NET_WM_STATE = atoms[1];
|
|
|
|
backend_x11->atom_NET_WM_STATE_FULLSCREEN = atoms[2];
|
|
|
|
backend_x11->atom_NET_WM_USER_TIME = atoms[3];
|
|
|
|
backend_x11->atom_WM_PROTOCOLS = atoms[4];
|
|
|
|
backend_x11->atom_WM_DELETE_WINDOW = atoms[5];
|
|
|
|
backend_x11->atom_XEMBED = atoms[6];
|
|
|
|
backend_x11->atom_XEMBED_INFO = atoms[7];
|
|
|
|
backend_x11->atom_NET_WM_NAME = atoms[8];
|
|
|
|
backend_x11->atom_UTF8_STRING = atoms[9];
|
2007-11-15 09:45:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (clutter_display_name);
|
2008-02-20 09:16:54 -05:00
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
CLUTTER_NOTE (BACKEND,
|
|
|
|
"X Display `%s'[%p] opened (screen:%d, root:%u, dpi:%f)",
|
|
|
|
backend_x11->display_name,
|
|
|
|
backend_x11->xdpy,
|
|
|
|
backend_x11->xscreen_num,
|
|
|
|
(unsigned int) backend_x11->xwin_root,
|
|
|
|
clutter_backend_get_resolution (backend));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_x11_init_events (ClutterBackend *backend)
|
|
|
|
{
|
|
|
|
CLUTTER_NOTE (EVENT, "initialising the event loop");
|
|
|
|
|
2008-07-01 09:41:23 -04:00
|
|
|
if (!_no_xevent_retrieval)
|
|
|
|
_clutter_backend_x11_events_init (backend);
|
2007-11-15 09:45:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static const GOptionEntry entries[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"display", 0,
|
|
|
|
G_OPTION_FLAG_IN_MAIN,
|
|
|
|
G_OPTION_ARG_STRING, &clutter_display_name,
|
2009-01-06 07:11:07 -05:00
|
|
|
N_("X display to use"), "DISPLAY"
|
2007-11-15 09:45:27 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"screen", 0,
|
|
|
|
G_OPTION_FLAG_IN_MAIN,
|
|
|
|
G_OPTION_ARG_INT, &clutter_screen,
|
2009-01-06 07:11:07 -05:00
|
|
|
N_("X screen to use"), "SCREEN"
|
2007-11-15 09:45:27 -05:00
|
|
|
},
|
|
|
|
{ "synch", 0,
|
|
|
|
0,
|
|
|
|
G_OPTION_ARG_NONE, &clutter_synchronise,
|
2009-01-06 07:11:07 -05:00
|
|
|
N_("Make X calls synchronous"), NULL,
|
2007-11-15 09:45:27 -05:00
|
|
|
},
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
clutter_backend_x11_add_options (ClutterBackend *backend,
|
|
|
|
GOptionGroup *group)
|
|
|
|
{
|
|
|
|
g_option_group_add_entries (group, entries);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_x11_finalize (GObject *gobject)
|
|
|
|
{
|
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (gobject);
|
|
|
|
|
|
|
|
g_free (backend_x11->display_name);
|
|
|
|
|
|
|
|
XCloseDisplay (backend_x11->xdpy);
|
|
|
|
|
|
|
|
if (backend_singleton)
|
|
|
|
backend_singleton = NULL;
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (clutter_backend_x11_parent_class)->finalize (gobject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_x11_dispose (GObject *gobject)
|
|
|
|
{
|
2008-03-28 18:50:55 -04:00
|
|
|
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (gobject);
|
|
|
|
ClutterMainContext *context;
|
|
|
|
ClutterStageManager *stage_manager;
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND, "Disposing the of stages");
|
|
|
|
|
|
|
|
context = clutter_context_get_default ();
|
|
|
|
stage_manager = context->stage_manager;
|
2007-11-15 09:45:27 -05:00
|
|
|
|
2008-04-09 05:33:32 -04:00
|
|
|
/* Destroy all of the stages. g_slist_foreach is used because the
|
|
|
|
finalizer for the stages will remove the stage from the
|
|
|
|
stage_manager's list and g_slist_foreach has some basic
|
|
|
|
protection against this */
|
|
|
|
g_slist_foreach (stage_manager->stages, (GFunc) clutter_actor_destroy, NULL);
|
2008-02-20 09:16:54 -05:00
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
CLUTTER_NOTE (BACKEND, "Removing the event source");
|
|
|
|
_clutter_backend_x11_events_uninit (CLUTTER_BACKEND (backend_x11));
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (clutter_backend_x11_parent_class)->dispose (gobject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
clutter_backend_x11_constructor (GType gtype,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
|
|
|
{
|
|
|
|
GObjectClass *parent_class;
|
|
|
|
GObject *retval;
|
|
|
|
|
|
|
|
if (!backend_singleton)
|
|
|
|
{
|
|
|
|
parent_class = G_OBJECT_CLASS (clutter_backend_x11_parent_class);
|
|
|
|
retval = parent_class->constructor (gtype, n_params, params);
|
|
|
|
|
|
|
|
backend_singleton = CLUTTER_BACKEND_X11 (retval);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_warning ("Attempting to create a new backend object. This should "
|
|
|
|
"never happen, so we return the singleton instance.");
|
2008-02-20 09:16:54 -05:00
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
return g_object_ref (backend_singleton);
|
|
|
|
}
|
|
|
|
|
|
|
|
ClutterFeatureFlags
|
|
|
|
clutter_backend_x11_get_features (ClutterBackend *backend)
|
|
|
|
{
|
2008-04-02 23:04:41 -04:00
|
|
|
return CLUTTER_FEATURE_STAGE_USER_RESIZE | CLUTTER_FEATURE_STAGE_CURSOR;
|
2007-11-15 09:45:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_x11_class_init (ClutterBackendX11Class *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass);
|
|
|
|
|
|
|
|
gobject_class->constructor = clutter_backend_x11_constructor;
|
|
|
|
gobject_class->dispose = clutter_backend_x11_dispose;
|
|
|
|
gobject_class->finalize = clutter_backend_x11_finalize;
|
|
|
|
|
2008-06-25 09:05:59 -04:00
|
|
|
backend_class->pre_parse = clutter_backend_x11_pre_parse;
|
|
|
|
backend_class->post_parse = clutter_backend_x11_post_parse;
|
|
|
|
backend_class->init_events = clutter_backend_x11_init_events;
|
|
|
|
backend_class->add_options = clutter_backend_x11_add_options;
|
|
|
|
backend_class->get_features = clutter_backend_x11_get_features;
|
2007-11-15 09:45:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_backend_x11_init (ClutterBackendX11 *backend_x11)
|
|
|
|
{
|
|
|
|
ClutterBackend *backend = CLUTTER_BACKEND (backend_x11);
|
|
|
|
|
|
|
|
/* FIXME: get from xsettings */
|
|
|
|
clutter_backend_set_double_click_time (backend, 250);
|
|
|
|
clutter_backend_set_double_click_distance (backend, 5);
|
|
|
|
clutter_backend_set_resolution (backend, 96.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
error_handler(Display *xdpy,
|
2008-01-31 06:24:11 -05:00
|
|
|
XErrorEvent *error)
|
2007-11-15 09:45:27 -05:00
|
|
|
{
|
|
|
|
TrappedErrorCode = error->error_code;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_trap_x_errors:
|
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Traps every X error until clutter_x11_untrap_x_errors() is called.
|
2007-11-15 09:45:27 -05:00
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Since: 0.6
|
2007-11-15 09:45:27 -05:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_x11_trap_x_errors (void)
|
|
|
|
{
|
|
|
|
TrappedErrorCode = 0;
|
|
|
|
old_error_handler = XSetErrorHandler (error_handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_untrap_x_errors:
|
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Removes the X error trap and returns the current status.
|
2007-11-15 09:45:27 -05:00
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Return value: the trapped error code, or 0 for success
|
2007-11-15 09:45:27 -05:00
|
|
|
*
|
|
|
|
* Since: 0.4
|
|
|
|
*/
|
|
|
|
gint
|
|
|
|
clutter_x11_untrap_x_errors (void)
|
|
|
|
{
|
|
|
|
XSetErrorHandler (old_error_handler);
|
|
|
|
|
|
|
|
return TrappedErrorCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_get_default_display:
|
2008-02-20 09:16:54 -05:00
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Retrieves the pointer to the default display.
|
2007-11-15 09:45:27 -05:00
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Return value: the default display
|
2007-11-15 09:45:27 -05:00
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Since: 0.6
|
2007-11-15 09:45:27 -05:00
|
|
|
*/
|
|
|
|
Display *
|
|
|
|
clutter_x11_get_default_display (void)
|
|
|
|
{
|
|
|
|
if (!backend_singleton)
|
|
|
|
{
|
|
|
|
g_critical ("X11 backend has not been initialised");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return backend_singleton->xdpy;
|
|
|
|
}
|
|
|
|
|
2008-02-20 09:16:54 -05:00
|
|
|
/**
|
|
|
|
* clutter_x11_set_display:
|
|
|
|
* @xdpy: pointer to a X display connection.
|
2008-05-15 10:31:43 -04:00
|
|
|
*
|
2008-09-19 06:28:51 -04:00
|
|
|
* Sets the display connection Clutter should use; must be called
|
|
|
|
* before clutter_init(), clutter_init_with_args() or other functions
|
|
|
|
* pertaining Clutter's initialization process.
|
|
|
|
*
|
|
|
|
* If you are parsing the command line arguments by retrieving Clutter's
|
|
|
|
* #GOptionGroup with clutter_get_option_group() and calling
|
|
|
|
* g_option_context_parse() yourself, you should also call
|
|
|
|
* clutter_x11_set_display() before g_option_context_parse().
|
2008-02-20 09:16:54 -05:00
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_x11_set_display (Display *xdpy)
|
|
|
|
{
|
2008-09-23 03:03:35 -04:00
|
|
|
ClutterMainContext *ctx = clutter_context_get_default ();
|
|
|
|
|
|
|
|
if (ctx->is_initialized)
|
2008-02-20 09:16:54 -05:00
|
|
|
{
|
2008-07-01 09:41:23 -04:00
|
|
|
g_critical ("Display connection already exists. You can only call "
|
|
|
|
"clutter_x11_set_display() once before clutter_init()\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-02-20 09:16:54 -05:00
|
|
|
|
2008-07-01 09:41:23 -04:00
|
|
|
_foreign_dpy= xdpy;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_enable_xinput:
|
|
|
|
*
|
|
|
|
* Enables the use of the XInput extension if present on connected
|
|
|
|
* XServer and support built into Clutter. XInput allows for multiple
|
|
|
|
* pointing devices to be used. This must be called before
|
|
|
|
* clutter_init().
|
|
|
|
*
|
|
|
|
* You should use #clutter_x11_has_xinput to see if support was enabled.
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_x11_enable_xinput ()
|
|
|
|
{
|
2008-09-23 03:03:35 -04:00
|
|
|
ClutterMainContext *ctx = clutter_context_get_default ();
|
|
|
|
|
|
|
|
if (ctx->is_initialized)
|
2008-07-01 09:41:23 -04:00
|
|
|
{
|
|
|
|
g_warning ("clutter_x11_enable_xinput should "
|
|
|
|
"be called before clutter_init");
|
2008-09-23 03:03:35 -04:00
|
|
|
return;
|
2008-02-20 09:16:54 -05:00
|
|
|
}
|
|
|
|
|
2008-07-01 09:41:23 -04:00
|
|
|
_enable_xinput = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_disable_event_retrieval
|
|
|
|
*
|
|
|
|
* Disables retrieval of X events in the main loop. Use to create event-less
|
|
|
|
* canvas or in conjunction with clutter_x11_handle_event.
|
|
|
|
*
|
|
|
|
* This function can only be called before calling clutter_init().
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_x11_disable_event_retrieval (void)
|
|
|
|
{
|
2008-09-23 03:03:35 -04:00
|
|
|
ClutterMainContext *ctx = clutter_context_get_default ();
|
|
|
|
|
|
|
|
if (ctx->is_initialized)
|
2008-02-20 09:16:54 -05:00
|
|
|
{
|
2008-07-01 09:41:23 -04:00
|
|
|
g_warning ("clutter_x11_disable_event_retrieval should "
|
|
|
|
"be called before clutter_init");
|
2008-09-23 03:03:35 -04:00
|
|
|
return;
|
2008-02-20 09:16:54 -05:00
|
|
|
}
|
|
|
|
|
2008-07-01 09:41:23 -04:00
|
|
|
_no_xevent_retrieval = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_has_event_retrieval
|
|
|
|
*
|
|
|
|
* Queries the X11 backend to check if event collection has been disabled.
|
|
|
|
*
|
|
|
|
* Return value: TRUE if event retrival has been disabled. FALSE otherwise.
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_x11_has_event_retrieval (void)
|
|
|
|
{
|
|
|
|
return !_no_xevent_retrieval;
|
2008-02-20 09:16:54 -05:00
|
|
|
}
|
|
|
|
|
2007-11-15 09:45:27 -05:00
|
|
|
/**
|
|
|
|
* clutter_x11_get_default_screen:
|
2008-02-20 09:16:54 -05:00
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Gets the number of the default X Screen object.
|
2007-11-15 09:45:27 -05:00
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Return value: the number of the default screen
|
2007-11-15 09:45:27 -05:00
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Since: 0.6
|
2007-11-15 09:45:27 -05:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
clutter_x11_get_default_screen (void)
|
|
|
|
{
|
|
|
|
if (!backend_singleton)
|
|
|
|
{
|
|
|
|
g_critical ("X11 backend has not been initialised");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return backend_singleton->xscreen_num;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_get_root_window:
|
2008-02-20 09:16:54 -05:00
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Retrieves the root window.
|
2007-11-15 09:45:27 -05:00
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Return value: the id of the root window
|
2007-11-15 09:45:27 -05:00
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Since: 0.6
|
2007-11-15 09:45:27 -05:00
|
|
|
*/
|
|
|
|
Window
|
|
|
|
clutter_x11_get_root_window (void)
|
|
|
|
{
|
|
|
|
if (!backend_singleton)
|
|
|
|
{
|
|
|
|
g_critical ("X11 backend has not been initialised");
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
return backend_singleton->xwin_root;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_add_filter:
|
2007-11-18 10:41:47 -05:00
|
|
|
* @func: a filter function
|
|
|
|
* @data: user data to be passed to the filter function, or %NULL
|
2007-11-15 09:45:27 -05:00
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Adds an event filter function.
|
2007-11-15 09:45:27 -05:00
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Since: 0.6
|
2007-11-15 09:45:27 -05:00
|
|
|
*/
|
|
|
|
void
|
2007-11-18 10:41:47 -05:00
|
|
|
clutter_x11_add_filter (ClutterX11FilterFunc func,
|
|
|
|
gpointer data)
|
2007-11-15 09:45:27 -05:00
|
|
|
{
|
|
|
|
ClutterX11EventFilter *filter;
|
|
|
|
|
|
|
|
g_return_if_fail (func != NULL);
|
|
|
|
|
|
|
|
if (!backend_singleton)
|
|
|
|
{
|
|
|
|
g_critical ("X11 backend has not been initialised");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-18 10:41:47 -05:00
|
|
|
filter = g_new0 (ClutterX11EventFilter, 1);
|
2007-11-15 09:45:27 -05:00
|
|
|
filter->func = func;
|
|
|
|
filter->data = data;
|
|
|
|
|
2007-11-18 10:41:47 -05:00
|
|
|
backend_singleton->event_filters =
|
|
|
|
g_slist_append (backend_singleton->event_filters, filter);
|
2007-11-15 09:45:27 -05:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_x11_remove_filter:
|
2007-11-18 10:41:47 -05:00
|
|
|
* @func: a filter function
|
|
|
|
* @data: user data to be passed to the filter function, or %NULL
|
2007-11-15 09:45:27 -05:00
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Removes the given filter function.
|
2007-11-15 09:45:27 -05:00
|
|
|
*
|
2007-11-18 10:41:47 -05:00
|
|
|
* Since: 0.6
|
2007-11-15 09:45:27 -05:00
|
|
|
*/
|
|
|
|
void
|
2007-11-18 10:41:47 -05:00
|
|
|
clutter_x11_remove_filter (ClutterX11FilterFunc func,
|
|
|
|
gpointer data)
|
2007-11-15 09:45:27 -05:00
|
|
|
{
|
|
|
|
GSList *tmp_list, *this;
|
|
|
|
ClutterX11EventFilter *filter;
|
|
|
|
|
2008-04-15 17:18:13 -04:00
|
|
|
g_return_if_fail (func != NULL);
|
2007-11-15 09:45:27 -05:00
|
|
|
|
|
|
|
tmp_list = backend_singleton->event_filters;
|
|
|
|
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
2007-11-18 10:41:47 -05:00
|
|
|
filter = tmp_list->data;
|
2007-11-15 09:45:27 -05:00
|
|
|
this = tmp_list;
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
|
|
|
|
if (filter->func == func && filter->data == data)
|
|
|
|
{
|
2008-01-31 06:24:11 -05:00
|
|
|
backend_singleton->event_filters =
|
|
|
|
g_slist_remove_link (backend_singleton->event_filters, this);
|
2007-11-15 09:45:27 -05:00
|
|
|
|
|
|
|
g_slist_free_1 (this);
|
|
|
|
g_free (filter);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-06-23 05:55:42 -04:00
|
|
|
|
|
|
|
#ifdef USE_XINPUT
|
|
|
|
|
2008-09-23 03:03:35 -04:00
|
|
|
void
|
2008-06-23 05:55:42 -04:00
|
|
|
_clutter_x11_register_xinput ()
|
|
|
|
{
|
|
|
|
XDeviceInfo *xdevices = NULL;
|
|
|
|
XDeviceInfo *info = NULL;
|
|
|
|
|
|
|
|
XDevice *xdevice = NULL;
|
|
|
|
|
|
|
|
XInputClassInfo *xclass_info = NULL;
|
|
|
|
XExtensionVersion *ext;
|
|
|
|
|
|
|
|
gint num_devices = 0;
|
|
|
|
gint num_events = 0;
|
|
|
|
gint i = 0, j = 0;
|
2008-06-25 08:02:11 -04:00
|
|
|
gboolean have_an_xpointer = FALSE;
|
2008-09-23 03:03:35 -04:00
|
|
|
|
2008-06-23 05:55:42 -04:00
|
|
|
ClutterBackendX11 *x11b;
|
|
|
|
ClutterX11XInputDevice *device = NULL;
|
|
|
|
|
|
|
|
ClutterMainContext *context;
|
|
|
|
|
|
|
|
if (!backend_singleton)
|
|
|
|
{
|
|
|
|
g_critical ("X11 backend has not been initialised");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-07-01 09:41:23 -04:00
|
|
|
if (!_enable_xinput)
|
|
|
|
{
|
|
|
|
CLUTTER_NOTE (BACKEND, "Not enabling XInput");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-23 05:55:42 -04:00
|
|
|
context = clutter_context_get_default ();
|
|
|
|
|
|
|
|
backend_singleton->have_xinput = TRUE;
|
|
|
|
|
|
|
|
ext = XGetExtensionVersion(backend_singleton->xdpy, INAME);
|
|
|
|
|
|
|
|
if (!ext || (ext == (XExtensionVersion*) NoSuchExtension))
|
|
|
|
{
|
|
|
|
backend_singleton->have_xinput = FALSE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
x11b = backend_singleton;
|
|
|
|
|
|
|
|
xdevices = XListInputDevices (x11b->xdpy, &num_devices);
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND, "%d XINPUT devices found", num_devices);
|
|
|
|
|
|
|
|
if (num_devices == 0)
|
|
|
|
{
|
|
|
|
backend_singleton->have_xinput = FALSE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-09-23 03:03:35 -04:00
|
|
|
for (i = 0; i < num_devices; i++)
|
2008-06-23 05:55:42 -04:00
|
|
|
{
|
|
|
|
num_events = 0;
|
|
|
|
info = xdevices + i;
|
|
|
|
|
2008-09-23 03:03:35 -04:00
|
|
|
CLUTTER_NOTE (BACKEND, "Considering %li with type %d",
|
2008-06-23 05:55:42 -04:00
|
|
|
info->id, info->use);
|
|
|
|
|
|
|
|
/* Only want 'raw' devices themselves not virtual ones */
|
|
|
|
if (info->use == IsXExtensionPointer ||
|
2008-06-30 10:01:03 -04:00
|
|
|
/*info->use == IsXExtensionKeyboard || XInput is broken */
|
2008-06-23 05:55:42 -04:00
|
|
|
info->use == IsXExtensionDevice)
|
|
|
|
{
|
2008-06-25 08:02:11 -04:00
|
|
|
clutter_x11_trap_x_errors ();
|
|
|
|
xdevice = XOpenDevice (x11b->xdpy, info->id);
|
|
|
|
if (clutter_x11_untrap_x_errors () || xdevice == NULL)
|
|
|
|
continue;
|
|
|
|
|
2008-06-23 05:55:42 -04:00
|
|
|
/* Create the appropriate Clutter device */
|
|
|
|
device = g_new0 (ClutterX11XInputDevice, 1);
|
|
|
|
context->input_devices = g_slist_append (context->input_devices, device);
|
|
|
|
|
|
|
|
device->device.id = info->id;
|
|
|
|
|
|
|
|
/* FIXME: some kind of general device_init() call should do below */
|
|
|
|
device->device.click_count = 0;
|
|
|
|
device->device.previous_time = 0;
|
|
|
|
device->device.previous_x = -1;
|
|
|
|
device->device.previous_y = -1;
|
|
|
|
device->device.previous_button_number = -1;
|
|
|
|
|
|
|
|
device->xdevice = xdevice;
|
|
|
|
device->num_events = 0;
|
|
|
|
|
|
|
|
switch (info->use)
|
|
|
|
{
|
|
|
|
case IsXExtensionPointer:
|
|
|
|
device->type = CLUTTER_X11_XINPUT_POINTER_DEVICE;
|
2008-06-25 08:02:11 -04:00
|
|
|
have_an_xpointer = TRUE;
|
2008-06-23 05:55:42 -04:00
|
|
|
break;
|
2008-06-30 10:01:03 -04:00
|
|
|
/* XInput is broken:
|
2008-06-23 05:55:42 -04:00
|
|
|
case IsXExtensionKeyboard:
|
|
|
|
device->type = CLUTTER_X11_XINPUT_KEYBOARD_DEVICE;
|
2008-06-30 10:01:03 -04:00
|
|
|
break;*/
|
2008-06-23 05:55:42 -04:00
|
|
|
case IsXExtensionDevice:
|
|
|
|
device->type = CLUTTER_X11_XINPUT_EXTENSION_DEVICE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-09-23 03:03:35 -04:00
|
|
|
CLUTTER_NOTE (BACKEND, "Registering XINPUT device with XID: %li",
|
2008-06-23 05:55:42 -04:00
|
|
|
xdevice->device_id);
|
|
|
|
|
|
|
|
/* We must go through all the classes supported by this device and
|
|
|
|
* register the appropriate events we want. Each class only appears
|
|
|
|
* once. We need to store the types with the stage since they are
|
|
|
|
* created dynamically by the server. They are not device specific.
|
|
|
|
*/
|
|
|
|
for (j = 0; j < xdevice->num_classes; j++)
|
|
|
|
{
|
|
|
|
xclass_info = xdevice->classes + j;
|
|
|
|
|
|
|
|
switch (xclass_info->input_class)
|
|
|
|
{
|
2008-06-30 10:01:03 -04:00
|
|
|
#if 0
|
|
|
|
/* We do not do XInput keyboard events yet, since it is broken */
|
2008-06-23 05:55:42 -04:00
|
|
|
case KeyClass:
|
2008-09-23 03:03:35 -04:00
|
|
|
DeviceKeyPress (xdevice,
|
|
|
|
x11b->event_types [CLUTTER_X11_XINPUT_KEY_PRESS_EVENT],
|
2008-06-23 05:55:42 -04:00
|
|
|
device->xevent_list [num_events]);
|
|
|
|
num_events++;
|
|
|
|
|
2008-09-23 03:03:35 -04:00
|
|
|
DeviceKeyRelease (xdevice,
|
|
|
|
x11b->event_types [CLUTTER_X11_XINPUT_KEY_RELEASE_EVENT],
|
2008-06-23 05:55:42 -04:00
|
|
|
device->xevent_list [num_events]);
|
|
|
|
num_events++;
|
|
|
|
break;
|
2008-06-30 10:01:03 -04:00
|
|
|
#endif
|
2008-06-23 05:55:42 -04:00
|
|
|
|
|
|
|
case ButtonClass:
|
2008-09-23 03:03:35 -04:00
|
|
|
DeviceButtonPress (xdevice,
|
|
|
|
x11b->event_types [CLUTTER_X11_XINPUT_BUTTON_PRESS_EVENT],
|
2008-06-23 05:55:42 -04:00
|
|
|
device->xevent_list [num_events]);
|
|
|
|
num_events++;
|
|
|
|
|
2008-09-23 03:03:35 -04:00
|
|
|
DeviceButtonRelease (xdevice,
|
|
|
|
x11b->event_types [CLUTTER_X11_XINPUT_BUTTON_RELEASE_EVENT],
|
2008-06-23 05:55:42 -04:00
|
|
|
device->xevent_list [num_events]);
|
|
|
|
num_events++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ValuatorClass:
|
2008-09-23 03:03:35 -04:00
|
|
|
DeviceMotionNotify (xdevice,
|
|
|
|
x11b->event_types [CLUTTER_X11_XINPUT_MOTION_NOTIFY_EVENT],
|
2008-06-23 05:55:42 -04:00
|
|
|
device->xevent_list [num_events]);
|
|
|
|
num_events++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-25 08:02:11 -04:00
|
|
|
if (info->use == IsXExtensionPointer && num_events > 0)
|
|
|
|
have_an_xpointer = TRUE;
|
|
|
|
|
2008-06-23 05:55:42 -04:00
|
|
|
device->num_events = num_events;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XFree (xdevices);
|
2008-06-25 08:02:11 -04:00
|
|
|
|
|
|
|
if (!have_an_xpointer)
|
|
|
|
{
|
|
|
|
/* Something is likely wrong with Xinput setup so we basically
|
|
|
|
* abort here and fall back to lofi regular xinput.
|
|
|
|
*/
|
|
|
|
g_warning ("No usuable XInput pointing devices found");
|
|
|
|
backend_singleton->have_xinput = FALSE;
|
|
|
|
g_slist_free (context->input_devices);
|
|
|
|
context->input_devices = NULL;
|
|
|
|
}
|
2008-06-23 05:55:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_clutter_x11_unregister_xinput ()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_clutter_x11_select_events (Window xwin)
|
|
|
|
{
|
|
|
|
GSList *list_it;
|
|
|
|
ClutterX11XInputDevice *device = NULL;
|
|
|
|
|
|
|
|
ClutterMainContext *context;
|
|
|
|
|
|
|
|
context = clutter_context_get_default ();
|
|
|
|
|
|
|
|
if (!backend_singleton)
|
|
|
|
{
|
|
|
|
g_critical ("X11 backend has not been initialised");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-09-23 03:03:35 -04:00
|
|
|
for (list_it = context->input_devices;
|
|
|
|
list_it != NULL;
|
2008-06-23 05:55:42 -04:00
|
|
|
list_it = list_it->next)
|
|
|
|
{
|
|
|
|
device = (ClutterX11XInputDevice *)list_it->data;
|
|
|
|
|
2008-09-23 03:03:35 -04:00
|
|
|
XSelectExtensionEvent (backend_singleton->xdpy,
|
2008-06-23 05:55:42 -04:00
|
|
|
xwin,
|
2008-09-23 03:03:35 -04:00
|
|
|
device->xevent_list,
|
2008-06-23 05:55:42 -04:00
|
|
|
device->num_events);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-27 17:13:19 -04:00
|
|
|
ClutterX11XInputDevice *
|
2008-06-23 05:55:42 -04:00
|
|
|
_clutter_x11_get_device_for_xid (XID id)
|
|
|
|
{
|
|
|
|
GSList *list_it;
|
|
|
|
ClutterX11XInputDevice *device = NULL;
|
|
|
|
ClutterMainContext *context;
|
|
|
|
|
|
|
|
context = clutter_context_get_default ();
|
|
|
|
|
|
|
|
if (!backend_singleton)
|
|
|
|
{
|
|
|
|
g_critical ("X11 backend has not been initialised");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-09-23 03:03:35 -04:00
|
|
|
for (list_it = context->input_devices;
|
|
|
|
list_it != NULL;
|
2008-06-23 05:55:42 -04:00
|
|
|
list_it = list_it->next)
|
|
|
|
{
|
|
|
|
device = (ClutterX11XInputDevice *)list_it->data;
|
|
|
|
|
|
|
|
if (device->xdevice->device_id == id)
|
|
|
|
return device;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* FIXME: This nasty little func needs moving elsewhere.. */
|
|
|
|
GSList*
|
|
|
|
clutter_x11_get_input_devices (void)
|
|
|
|
{
|
|
|
|
ClutterMainContext *context;
|
|
|
|
|
|
|
|
#ifdef USE_XINPUT
|
|
|
|
if (!backend_singleton)
|
|
|
|
{
|
|
|
|
g_critical ("X11 backend has not been initialised");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
context = clutter_context_get_default ();
|
|
|
|
|
|
|
|
return context->input_devices;
|
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-06-27 17:13:19 -04:00
|
|
|
/**
|
|
|
|
* clutter_x11_get_input_device_type:
|
|
|
|
* @device: a #ClutterX11XInputDevice
|
|
|
|
*
|
|
|
|
* Retrieves the type of @device.
|
|
|
|
*
|
|
|
|
* Return value: the type of the device
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
2008-06-23 05:55:42 -04:00
|
|
|
ClutterX11InputDeviceType
|
|
|
|
clutter_x11_get_input_device_type (ClutterX11XInputDevice *device)
|
|
|
|
{
|
|
|
|
return device->type;
|
|
|
|
}
|
|
|
|
|
2008-06-27 17:13:19 -04:00
|
|
|
/**
|
|
|
|
* clutter_x11_has_xinput:
|
2008-09-23 03:03:35 -04:00
|
|
|
*
|
2008-06-27 17:13:19 -04:00
|
|
|
* Gets whether Clutter has XInput support.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if Clutter was compiled with XInput support
|
|
|
|
* and XInput support is available at run time.
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
2008-06-23 05:55:42 -04:00
|
|
|
gboolean
|
|
|
|
clutter_x11_has_xinput (void)
|
|
|
|
{
|
|
|
|
#ifdef USE_XINPUT
|
|
|
|
if (!backend_singleton)
|
|
|
|
{
|
|
|
|
g_critical ("X11 backend has not been initialised");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return backend_singleton->have_xinput;
|
|
|
|
#else
|
|
|
|
return FALSE;
|
|
|
|
#endif
|
|
|
|
}
|
2008-06-30 10:36:49 -04:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
clutter_x11_has_composite_extension (void)
|
|
|
|
{
|
|
|
|
static gboolean have_composite = FALSE, done_check = FALSE;
|
|
|
|
int error = 0, event = 0;
|
|
|
|
Display *dpy;
|
|
|
|
|
|
|
|
if (done_check)
|
|
|
|
return have_composite;
|
|
|
|
|
|
|
|
if (!backend_singleton)
|
|
|
|
{
|
|
|
|
g_critical ("X11 backend has not been initialised");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dpy = clutter_x11_get_default_display();
|
|
|
|
|
|
|
|
if (XCompositeQueryExtension (dpy, &event, &error))
|
|
|
|
{
|
|
|
|
int major = 0, minor = 0;
|
2008-09-23 03:03:35 -04:00
|
|
|
if (XCompositeQueryVersion (dpy, &major, &minor))
|
2008-06-30 10:36:49 -04:00
|
|
|
{
|
2008-09-23 03:03:35 -04:00
|
|
|
if (major >= 0 && minor >= 3)
|
2008-06-30 10:36:49 -04:00
|
|
|
have_composite = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
done_check = TRUE;
|
|
|
|
|
|
|
|
return have_composite;
|
|
|
|
}
|
|
|
|
|