backends: Shuffle ClutterBackendX11 code into MetaClutterBackendX11

We have a Clutter implementation of the X11, just to subclass it in
our backends. Move the implementation entirely to src/backends/x11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
This commit is contained in:
Carlos Garnacho 2021-05-10 23:40:49 +02:00
parent 1e84c00d86
commit dc6d3cead2
30 changed files with 832 additions and 1261 deletions

View File

@ -74,10 +74,6 @@
#include "clutter/clutter-actor-private.h"
#ifdef CLUTTER_WINDOWING_X11
#include <clutter/x11/clutter-x11.h>
#endif
#include <math.h>
#include "cally-actor.h"

View File

@ -26,6 +26,7 @@
#define __CLUTTER_H_INSIDE__
#include "clutter-backend.h"
#include "clutter-backend-private.h"
#include "clutter-damage-history.h"
#include "clutter-event-private.h"
#include "clutter-input-device-private.h"
@ -35,7 +36,7 @@
#include "clutter-stage-private.h"
#include "clutter-stage-view.h"
#include "clutter-stage-view-private.h"
#include "clutter/x11/clutter-backend-x11.h"
#include "clutter.h"
CLUTTER_EXPORT
GList * clutter_stage_peek_stage_views (ClutterStage *stage);

View File

@ -173,6 +173,7 @@ void _clutter_threads_dispatch_free (gpointer data);
ClutterMainContext * _clutter_context_get_default (void);
void _clutter_context_lock (void);
void _clutter_context_unlock (void);
CLUTTER_EXPORT
gboolean _clutter_context_is_initialized (void);
gboolean _clutter_context_get_show_fps (void);

View File

@ -236,23 +236,6 @@ clutter_backend_nonintrospected_sources = []
clutter_backend_headers = []
clutter_backend_private_headers = []
if have_x11
clutter_x11_sources = [
'x11/clutter-backend-x11.c',
]
clutter_backend_sources += clutter_x11_sources
clutter_x11_headers = [
'x11/clutter-x11.h',
]
clutter_backend_headers += clutter_x11_headers
clutter_x11_private_headers = [
'x11/clutter-backend-x11.h',
]
clutter_backend_private_headers += clutter_x11_private_headers
endif
cally_headers = [
'cally/cally-actor.h',
'cally/cally-clone.h',
@ -431,29 +414,6 @@ if have_introspection
install_dir_typelib: pkglibdir,
install: true
)
if have_x11
libmutter_clutter_x11_gir = gnome.generate_gir(libmutter_clutter,
sources: [
clutter_x11_sources,
clutter_x11_headers,
],
nsversion: libmutter_api_version,
namespace: 'ClutterX11',
export_packages: ['mutter-clutter-x11-' + libmutter_api_version],
includes: [
libmutter_cogl_gir[0],
libmutter_cogl_pango_gir[0],
libmutter_clutter_gir[0],
'xlib-2.0',
],
dependencies: [],
extra_args: clutter_introspection_args,
install_dir_gir: pkglibdir,
install_dir_typelib: pkglibdir,
install: true
)
endif
endif
install_headers(clutter_headers,
@ -465,9 +425,6 @@ install_headers(cally_headers,
install_headers(clutter_deprecated_headers,
subdir: join_paths(clutter_clutter_includesubdir, 'deprecated'))
install_headers(clutter_x11_headers,
subdir: join_paths(clutter_clutter_includesubdir, 'x11'))
pkg.generate(libmutter_clutter,
name: 'Mutters Clutter',
filebase: libmutter_clutter_name,

View File

@ -1,842 +0,0 @@
/* 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, see <http://www.gnu.org/licenses/>.
*
*
*/
#include "clutter-build-config.h"
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include "clutter-backend-x11.h"
#include "clutter-x11.h"
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/XInput2.h>
#include <cogl/cogl.h>
#include <cogl/cogl-xlib.h>
#include "clutter-backend.h"
#include "clutter-debug.h"
#include "clutter-event-private.h"
#include "clutter-main.h"
#include "clutter-private.h"
#include "clutter-settings-private.h"
G_DEFINE_TYPE (ClutterBackendX11, clutter_backend_x11, CLUTTER_TYPE_BACKEND)
GType
clutter_x11_filter_return_get_type (void)
{
static size_t g_define_type;
if (g_once_init_enter (&g_define_type))
{
static const GEnumValue values[] = {
{ CLUTTER_X11_FILTER_CONTINUE, "CLUTTER_X11_FILTER_CONTINUE", "continue" },
{ CLUTTER_X11_FILTER_TRANSLATE, "CLUTTER_X11_FILTER_TRANSLATE", "translate" },
{ CLUTTER_X11_FILTER_REMOVE, "CLUTTER_X11_FILTER_REMOVE", "remove" },
{ 0, NULL, NULL },
};
GType id =
g_enum_register_static (g_intern_static_string ("ClutterX11FilterReturn"), values);
g_once_init_leave (&g_define_type, id);
}
return g_define_type;
}
/* 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_PID",
"_NET_WM_PING",
"_NET_WM_STATE",
"_NET_WM_USER_TIME",
"WM_PROTOCOLS",
"WM_DELETE_WINDOW",
"_XEMBED",
"_XEMBED_INFO",
"_NET_WM_NAME",
"UTF8_STRING",
};
#define N_ATOM_NAMES G_N_ELEMENTS (atom_names)
/* various flags corresponding to pre init setup calls */
static gboolean clutter_enable_xinput = TRUE;
static gboolean clutter_enable_stereo = FALSE;
static Display *_foreign_dpy = NULL;
/* options */
static gchar *clutter_display_name = NULL;
static gint clutter_screen = -1;
static gboolean clutter_synchronise = FALSE;
/* X error trap */
static int TrappedErrorCode = 0;
static int (* old_error_handler) (Display *, XErrorEvent *);
static ClutterX11FilterReturn
cogl_xlib_filter (XEvent *xevent,
ClutterEvent *event,
gpointer data)
{
ClutterBackend *backend = data;
ClutterX11FilterReturn retval;
CoglFilterReturn ret;
ret = cogl_xlib_renderer_handle_event (backend->cogl_renderer, xevent);
switch (ret)
{
case COGL_FILTER_REMOVE:
retval = CLUTTER_X11_FILTER_REMOVE;
break;
case COGL_FILTER_CONTINUE:
default:
retval = CLUTTER_X11_FILTER_CONTINUE;
break;
}
return retval;
}
static 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;
}
env_string = g_getenv ("CLUTTER_DISABLE_XINPUT");
if (env_string)
{
clutter_enable_xinput = FALSE;
env_string = NULL;
}
return TRUE;
}
static gboolean
clutter_backend_x11_post_parse (ClutterBackend *backend,
GError **error)
{
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
Atom atoms[N_ATOM_NAMES];
if (_foreign_dpy)
backend_x11->xdpy = _foreign_dpy;
/* Only open connection if not already set by prior call to
* clutter_x11_set_display()
*/
if (backend_x11->xdpy == NULL)
{
if (clutter_display_name != NULL &&
*clutter_display_name != '\0')
{
CLUTTER_NOTE (BACKEND, "XOpenDisplay on '%s'", clutter_display_name);
backend_x11->xdpy = XOpenDisplay (clutter_display_name);
if (backend_x11->xdpy == NULL)
{
g_set_error (error, CLUTTER_INIT_ERROR,
CLUTTER_INIT_ERROR_BACKEND,
"Unable to open display '%s'",
clutter_display_name);
return FALSE;
}
}
else
{
g_set_error_literal (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;
}
}
g_assert (backend_x11->xdpy != NULL);
CLUTTER_NOTE (BACKEND, "Getting the X screen");
/* add event filter for Cogl events */
clutter_x11_add_filter (cogl_xlib_filter, backend);
if (clutter_screen == -1)
backend_x11->xscreen = DefaultScreenOfDisplay (backend_x11->xdpy);
else
backend_x11->xscreen = ScreenOfDisplay (backend_x11->xdpy,
clutter_screen);
backend_x11->xscreen_num = XScreenNumberOfScreen (backend_x11->xscreen);
backend_x11->xscreen_width = WidthOfScreen (backend_x11->xscreen);
backend_x11->xscreen_height = HeightOfScreen (backend_x11->xscreen);
backend_x11->xwin_root = RootWindow (backend_x11->xdpy,
backend_x11->xscreen_num);
backend_x11->display_name = g_strdup (clutter_display_name);
if (clutter_synchronise)
XSynchronize (backend_x11->xdpy, True);
XInternAtoms (backend_x11->xdpy,
(char **) atom_names, N_ATOM_NAMES,
False, atoms);
backend_x11->atom_NET_WM_PID = atoms[0];
backend_x11->atom_NET_WM_PING = atoms[1];
backend_x11->atom_NET_WM_STATE = 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];
g_free (clutter_display_name);
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 const GOptionEntry entries[] =
{
{
"display", 0,
G_OPTION_FLAG_IN_MAIN,
G_OPTION_ARG_STRING, &clutter_display_name,
N_("X display to use"), "DISPLAY"
},
{
"screen", 0,
G_OPTION_FLAG_IN_MAIN,
G_OPTION_ARG_INT, &clutter_screen,
N_("X screen to use"), "SCREEN"
},
{ "synch", 0,
0,
G_OPTION_ARG_NONE, &clutter_synchronise,
N_("Make X calls synchronous"), NULL
},
{
"disable-xinput", 0,
G_OPTION_FLAG_REVERSE,
G_OPTION_ARG_NONE, &clutter_enable_xinput,
N_("Disable XInput support"), NULL
},
{ NULL }
};
static 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);
clutter_x11_remove_filter (cogl_xlib_filter, gobject);
XCloseDisplay (backend_x11->xdpy);
G_OBJECT_CLASS (clutter_backend_x11_parent_class)->finalize (gobject);
}
static void
clutter_backend_x11_dispose (GObject *gobject)
{
G_OBJECT_CLASS (clutter_backend_x11_parent_class)->dispose (gobject);
}
static ClutterFeatureFlags
clutter_backend_x11_get_features (ClutterBackend *backend)
{
ClutterFeatureFlags flags = CLUTTER_FEATURE_STAGE_CURSOR;
flags |= CLUTTER_BACKEND_CLASS (clutter_backend_x11_parent_class)->get_features (backend);
return flags;
}
static void
update_last_event_time (ClutterBackendX11 *backend_x11,
XEvent *xevent)
{
Time current_time = CurrentTime;
Time last_time = backend_x11->last_event_time;
switch (xevent->type)
{
case KeyPress:
case KeyRelease:
current_time = xevent->xkey.time;
break;
case ButtonPress:
case ButtonRelease:
current_time = xevent->xbutton.time;
break;
case MotionNotify:
current_time = xevent->xmotion.time;
break;
case EnterNotify:
case LeaveNotify:
current_time = xevent->xcrossing.time;
break;
case PropertyNotify:
current_time = xevent->xproperty.time;
break;
default:
break;
}
/* only change the current event time if it's after the previous event
* time, or if it is at least 30 seconds earlier - in case the system
* clock was changed
*/
if ((current_time != CurrentTime) &&
(current_time > last_time || (last_time - current_time > (30 * 1000))))
backend_x11->last_event_time = current_time;
}
static gboolean
clutter_backend_x11_translate_event (ClutterBackend *backend,
gpointer native,
ClutterEvent *event)
{
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
XEvent *xevent = native;
/* X11 filter functions have a higher priority */
if (backend_x11->event_filters != NULL)
{
GSList *node = backend_x11->event_filters;
while (node != NULL)
{
ClutterX11EventFilter *filter = node->data;
switch (filter->func (xevent, event, filter->data))
{
case CLUTTER_X11_FILTER_CONTINUE:
break;
case CLUTTER_X11_FILTER_TRANSLATE:
return TRUE;
case CLUTTER_X11_FILTER_REMOVE:
return FALSE;
default:
break;
}
node = node->next;
}
}
/* we update the event time only for events that can
* actually reach Clutter's event queue
*/
update_last_event_time (backend_x11, xevent);
return FALSE;
}
static CoglRenderer *
clutter_backend_x11_get_renderer (ClutterBackend *backend,
GError **error)
{
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
Display *xdisplay = backend_x11->xdpy;
CoglRenderer *renderer;
CLUTTER_NOTE (BACKEND, "Creating a new Xlib renderer");
renderer = cogl_renderer_new ();
cogl_renderer_add_constraint (renderer, COGL_RENDERER_CONSTRAINT_USES_X11);
/* set the display object we're using */
cogl_xlib_renderer_set_foreign_display (renderer, xdisplay);
return renderer;
}
static gboolean
check_onscreen_template (CoglRenderer *renderer,
CoglOnscreenTemplate *onscreen_template,
gboolean enable_stereo,
GError **error)
{
GError *internal_error = NULL;
cogl_onscreen_template_set_stereo_enabled (onscreen_template,
clutter_enable_stereo);
/* cogl_renderer_check_onscreen_template() is actually just a
* shorthand for creating a CoglDisplay, and calling
* cogl_display_setup() on it, then throwing the display away. If we
* could just return that display, then it would be more efficient
* not to use cogl_renderer_check_onscreen_template(). However, the
* backend API requires that we return an CoglDisplay that has not
* yet been setup, so one way or the other we'll have to discard the
* first display and make a new fresh one.
*/
if (cogl_renderer_check_onscreen_template (renderer, onscreen_template, &internal_error))
{
clutter_enable_stereo = enable_stereo;
return TRUE;
}
else
{
if (enable_stereo) /* More possibilities to try */
CLUTTER_NOTE (BACKEND,
"Creation of a CoglDisplay with, stereo=%s failed: %s",
enable_stereo ? "enabled" : "disabled",
internal_error != NULL
? internal_error->message
: "Unknown reason");
else
g_set_error_literal (error, CLUTTER_INIT_ERROR,
CLUTTER_INIT_ERROR_BACKEND,
internal_error != NULL
? internal_error->message
: "Creation of a CoglDisplay failed");
g_clear_error (&internal_error);
return FALSE;
}
}
static CoglDisplay *
clutter_backend_x11_get_display (ClutterBackend *backend,
CoglRenderer *renderer,
CoglSwapChain *swap_chain,
GError **error)
{
CoglOnscreenTemplate *onscreen_template;
CoglDisplay *display = NULL;
gboolean res = FALSE;
CLUTTER_NOTE (BACKEND, "Creating CoglDisplay, stereo=%s",
clutter_enable_stereo ? "enabled" : "disabled");
onscreen_template = cogl_onscreen_template_new (swap_chain);
/* It's possible that the current renderer doesn't support transparency
* or doesn't support stereo, so we try the different combinations.
*/
if (clutter_enable_stereo)
res = check_onscreen_template (renderer, onscreen_template,
TRUE, error);
if (!res)
res = check_onscreen_template (renderer, onscreen_template,
FALSE, error);
if (res)
display = cogl_display_new (renderer, onscreen_template);
cogl_object_unref (onscreen_template);
return display;
}
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->dispose = clutter_backend_x11_dispose;
gobject_class->finalize = clutter_backend_x11_finalize;
backend_class->pre_parse = clutter_backend_x11_pre_parse;
backend_class->post_parse = clutter_backend_x11_post_parse;
backend_class->add_options = clutter_backend_x11_add_options;
backend_class->get_features = clutter_backend_x11_get_features;
backend_class->translate_event = clutter_backend_x11_translate_event;
backend_class->get_renderer = clutter_backend_x11_get_renderer;
backend_class->get_display = clutter_backend_x11_get_display;
}
static void
clutter_backend_x11_init (ClutterBackendX11 *backend_x11)
{
backend_x11->last_event_time = CurrentTime;
}
static int
error_handler(Display *xdpy,
XErrorEvent *error)
{
TrappedErrorCode = error->error_code;
return 0;
}
/**
* clutter_x11_trap_x_errors:
*
* Traps every X error until clutter_x11_untrap_x_errors() is called.
*
* Since: 0.6
*/
void
clutter_x11_trap_x_errors (void)
{
TrappedErrorCode = 0;
old_error_handler = XSetErrorHandler (error_handler);
}
/**
* clutter_x11_untrap_x_errors:
*
* Removes the X error trap and returns the current status.
*
* Return value: the trapped error code, or 0 for success
*
* Since: 0.4
*/
gint
clutter_x11_untrap_x_errors (void)
{
XSetErrorHandler (old_error_handler);
return TrappedErrorCode;
}
/**
* clutter_x11_get_default_display:
*
* Retrieves the pointer to the default display.
*
* Return value: (transfer none): the default display
*
* Since: 0.6
*/
Display *
clutter_x11_get_default_display (void)
{
ClutterBackend *backend = clutter_get_default_backend ();
if (backend == NULL)
{
g_critical ("The Clutter backend has not been initialised");
return NULL;
}
if (!CLUTTER_IS_BACKEND_X11 (backend))
{
g_critical ("The Clutter backend is not a X11 backend");
return NULL;
}
return CLUTTER_BACKEND_X11 (backend)->xdpy;
}
/**
* clutter_x11_set_display:
* @xdpy: pointer to a X display connection.
*
* 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().
*
* Since: 0.8
*/
void
clutter_x11_set_display (Display *xdpy)
{
if (_clutter_context_is_initialized ())
{
g_warning ("%s() can only be used before calling clutter_init()",
G_STRFUNC);
return;
}
_foreign_dpy= xdpy;
}
/**
* clutter_x11_get_default_screen:
*
* Gets the number of the default X Screen object.
*
* Return value: the number of the default screen
*
* Since: 0.6
*/
int
clutter_x11_get_default_screen (void)
{
ClutterBackend *backend = clutter_get_default_backend ();
if (backend == NULL)
{
g_critical ("The Clutter backend has not been initialised");
return 0;
}
if (!CLUTTER_IS_BACKEND_X11 (backend))
{
g_critical ("The Clutter backend is not a X11 backend");
return 0;
}
return CLUTTER_BACKEND_X11 (backend)->xscreen_num;
}
/**
* clutter_x11_get_root_window: (skip)
*
* Retrieves the root window.
*
* Return value: the id of the root window
*
* Since: 0.6
*/
Window
clutter_x11_get_root_window (void)
{
ClutterBackend *backend = clutter_get_default_backend ();
if (backend == NULL)
{
g_critical ("The Clutter backend has not been initialised");
return None;
}
if (!CLUTTER_IS_BACKEND_X11 (backend))
{
g_critical ("The Clutter backend is not a X11 backend");
return None;
}
return CLUTTER_BACKEND_X11 (backend)->xwin_root;
}
/**
* clutter_x11_add_filter: (skip)
* @func: a filter function
* @data: user data to be passed to the filter function, or %NULL
*
* Adds an event filter function.
*
* Since: 0.6
*/
void
clutter_x11_add_filter (ClutterX11FilterFunc func,
gpointer data)
{
ClutterX11EventFilter *filter;
ClutterBackend *backend = clutter_get_default_backend ();
ClutterBackendX11 *backend_x11;
g_return_if_fail (func != NULL);
if (backend == NULL)
{
g_critical ("The Clutter backend has not been initialised");
return;
}
if (!CLUTTER_IS_BACKEND_X11 (backend))
{
g_critical ("The Clutter backend is not a X11 backend");
return;
}
backend_x11 = CLUTTER_BACKEND_X11 (backend);
filter = g_new0 (ClutterX11EventFilter, 1);
filter->func = func;
filter->data = data;
backend_x11->event_filters =
g_slist_append (backend_x11->event_filters, filter);
return;
}
/**
* clutter_x11_remove_filter: (skip)
* @func: a filter function
* @data: user data to be passed to the filter function, or %NULL
*
* Removes the given filter function.
*
* Since: 0.6
*/
void
clutter_x11_remove_filter (ClutterX11FilterFunc func,
gpointer data)
{
GSList *tmp_list, *this;
ClutterX11EventFilter *filter;
ClutterBackend *backend = clutter_get_default_backend ();
ClutterBackendX11 *backend_x11;
g_return_if_fail (func != NULL);
if (backend == NULL)
{
g_critical ("The Clutter backend has not been initialised");
return;
}
if (!CLUTTER_IS_BACKEND_X11 (backend))
{
g_critical ("The Clutter backend is not a X11 backend");
return;
}
backend_x11 = CLUTTER_BACKEND_X11 (backend);
tmp_list = backend_x11->event_filters;
while (tmp_list)
{
filter = tmp_list->data;
this = tmp_list;
tmp_list = tmp_list->next;
if (filter->func == func && filter->data == data)
{
backend_x11->event_filters =
g_slist_remove_link (backend_x11->event_filters, this);
g_slist_free_1 (this);
g_free (filter);
return;
}
}
}
/**
* clutter_x11_set_use_stereo_stage:
* @use_stereo: %TRUE if the stereo stages should be used if possible.
*
* Sets whether the backend object for Clutter stages, will,
* if possible, be created with the ability to support stereo drawing
* (drawing separate images for the left and right eyes).
*
* This function must be called before clutter_init() is called.
* During paint callbacks, cogl_framebuffer_is_stereo() can be called
* on the framebuffer retrieved by cogl_get_draw_framebuffer() to
* determine if stereo support was successfully enabled, and
* cogl_framebuffer_set_stereo_mode() to determine which buffers
* will be drawn to.
*
* Note that this function *does not* cause the stage to be drawn
* multiple times with different perspective transformations and thus
* appear in 3D, it simply enables individual ClutterActors to paint
* different images for the left and and right eye.
*
* Since: 1.22
*/
void
clutter_x11_set_use_stereo_stage (gboolean use_stereo)
{
if (_clutter_context_is_initialized ())
{
g_warning ("%s() can only be used before calling clutter_init()",
G_STRFUNC);
return;
}
CLUTTER_NOTE (BACKEND, "STEREO stages are %s",
use_stereo ? "enabled" : "disabled");
clutter_enable_stereo = use_stereo;
}
/**
* clutter_x11_get_use_stereo_stage:
*
* Retrieves whether the Clutter X11 backend will create stereo
* stages if possible.
*
* Return value: %TRUE if stereo stages are used if possible
*
* Since: 1.22
*/
gboolean
clutter_x11_get_use_stereo_stage (void)
{
return clutter_enable_stereo;
}

View File

@ -1,98 +0,0 @@
/* 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, see <http://www.gnu.org/licenses/>.
*
*
*/
#ifndef __CLUTTER_BACKEND_X11_H__
#define __CLUTTER_BACKEND_X11_H__
#include <glib-object.h>
#include <clutter/clutter-event.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include "clutter-x11.h"
#include "clutter-backend-private.h"
G_BEGIN_DECLS
#define CLUTTER_TYPE_BACKEND_X11 (clutter_backend_x11_get_type ())
#define CLUTTER_BACKEND_X11(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BACKEND_X11, ClutterBackendX11))
#define CLUTTER_IS_BACKEND_X11(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BACKEND_X11))
#define CLUTTER_BACKEND_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND_X11, ClutterBackendX11Class))
#define CLUTTER_IS_BACKEND_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_BACKEND_X11))
#define CLUTTER_BACKEND_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_BACKEND_X11, ClutterBackendX11Class))
typedef struct _ClutterBackendX11 ClutterBackendX11;
typedef struct _ClutterBackendX11Class ClutterBackendX11Class;
typedef struct _ClutterX11EventFilter ClutterX11EventFilter;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBackendX11, g_object_unref)
struct _ClutterX11EventFilter
{
ClutterX11FilterFunc func;
gpointer data;
};
struct _ClutterBackendX11
{
ClutterBackend parent_instance;
Display *xdpy;
gchar *display_name;
Screen *xscreen;
int xscreen_num;
int xscreen_width;
int xscreen_height;
Window xwin_root;
/* event source */
GSList *event_filters;
/* props */
Atom atom_NET_WM_PID;
Atom atom_NET_WM_PING;
Atom atom_NET_WM_STATE;
Atom atom_NET_WM_USER_TIME;
Atom atom_WM_PROTOCOLS;
Atom atom_WM_DELETE_WINDOW;
Atom atom_XEMBED;
Atom atom_XEMBED_INFO;
Atom atom_NET_WM_NAME;
Atom atom_UTF8_STRING;
Time last_event_time;
};
struct _ClutterBackendX11Class
{
ClutterBackendClass parent_class;
};
CLUTTER_EXPORT
GType clutter_backend_x11_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __CLUTTER_BACKEND_X11_H__ */

View File

@ -1,119 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Authored By Matthew Allum <mallum@openedhand.com>
*
* Copyright (C) 2006 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, see <http://www.gnu.org/licenses/>.
*
*
*/
/**
* SECTION:clutter-x11
* @short_description: X11 specific API
*
* The X11 backend for Clutter provides some specific API, allowing
* integration with the Xlibs API for embedding and manipulating the
* stage window, or for trapping X errors.
*
* The ClutterX11 API is available since Clutter 0.6
*/
#ifndef __CLUTTER_X11_H__
#define __CLUTTER_X11_H__
#include <glib.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <clutter/clutter.h>
G_BEGIN_DECLS
/**
* ClutterX11FilterReturn:
* @CLUTTER_X11_FILTER_CONTINUE: The event was not handled, continues the
* processing
* @CLUTTER_X11_FILTER_TRANSLATE: Native event translated into a Clutter
* event, stops the processing
* @CLUTTER_X11_FILTER_REMOVE: Remove the event, stops the processing
*
* Return values for the #ClutterX11FilterFunc function.
*
* Since: 0.6
*/
typedef enum
{
CLUTTER_X11_FILTER_CONTINUE,
CLUTTER_X11_FILTER_TRANSLATE,
CLUTTER_X11_FILTER_REMOVE
} ClutterX11FilterReturn;
CLUTTER_EXPORT
GType clutter_x11_filter_return_get_type (void) G_GNUC_CONST;
/*
* This is not used any more
*/
typedef struct _ClutterX11XInputDevice ClutterX11XInputDevice;
/**
* ClutterX11FilterFunc:
* @xev: Native X11 event structure
* @cev: Clutter event structure
* @data: (closure): user data passed to the filter function
*
* Filter function for X11 native events.
*
* Return value: the result of the filtering
*
* Since: 0.6
*/
typedef ClutterX11FilterReturn (*ClutterX11FilterFunc) (XEvent *xev,
ClutterEvent *cev,
gpointer data);
CLUTTER_EXPORT
void clutter_x11_trap_x_errors (void);
CLUTTER_EXPORT
gint clutter_x11_untrap_x_errors (void);
CLUTTER_EXPORT
Display *clutter_x11_get_default_display (void);
CLUTTER_EXPORT
int clutter_x11_get_default_screen (void);
CLUTTER_EXPORT
Window clutter_x11_get_root_window (void);
CLUTTER_EXPORT
void clutter_x11_set_display (Display * xdpy);
CLUTTER_EXPORT
void clutter_x11_add_filter (ClutterX11FilterFunc func,
gpointer data);
CLUTTER_EXPORT
void clutter_x11_remove_filter (ClutterX11FilterFunc func,
gpointer data);
CLUTTER_EXPORT
void clutter_x11_set_use_stereo_stage (gboolean use_stereo);
CLUTTER_EXPORT
gboolean clutter_x11_get_use_stereo_stage (void);
G_END_DECLS
#endif /* __CLUTTER_X11_H__ */

View File

@ -52,7 +52,6 @@
#include "backends/x11/meta-renderer-x11.h"
#include "backends/x11/meta-xkb-a11y-x11.h"
#include "clutter/clutter.h"
#include "clutter/x11/clutter-x11.h"
#include "compositor/compositor-private.h"
#include "core/display-private.h"
#include "meta/meta-cursor-tracker.h"
@ -868,7 +867,7 @@ meta_backend_x11_initable_init (GInitable *initable,
priv->xdisplay = xdisplay;
priv->xcb = XGetXCBConnection (priv->xdisplay);
clutter_x11_set_display (xdisplay);
meta_clutter_x11_set_display (xdisplay);
init_xkb_state (x11);

View File

@ -35,16 +35,374 @@
#include "backends/x11/nested/meta-stage-x11-nested.h"
#include "clutter/clutter-mutter.h"
#include "clutter/clutter.h"
#include "cogl/cogl-xlib.h"
#include "core/bell.h"
#include "meta/meta-backend.h"
struct _MetaClutterBackendX11
typedef struct _MetaX11EventFilter MetaX11EventFilter;
struct _MetaX11EventFilter
{
ClutterBackendX11 parent;
MetaX11FilterFunc func;
gpointer data;
};
G_DEFINE_TYPE (MetaClutterBackendX11, meta_clutter_backend_x11,
CLUTTER_TYPE_BACKEND_X11)
CLUTTER_TYPE_BACKEND)
/* atoms; remember to add the code that assigns the atom value to
* the member of the MetaClutterBackendX11 structure if you add an
* atom name here. do not change the order!
*/
static const gchar *atom_names[] = {
"_NET_WM_PID",
"_NET_WM_PING",
"_NET_WM_STATE",
"_NET_WM_USER_TIME",
"WM_PROTOCOLS",
"WM_DELETE_WINDOW",
"_XEMBED",
"_XEMBED_INFO",
"_NET_WM_NAME",
"UTF8_STRING",
};
#define N_ATOM_NAMES G_N_ELEMENTS (atom_names)
/* various flags corresponding to pre init setup calls */
static gboolean clutter_enable_xinput = TRUE;
static gboolean clutter_enable_stereo = FALSE;
static Display *_foreign_dpy = NULL;
/* options */
static gchar *clutter_display_name = NULL;
static gint clutter_screen = -1;
static gboolean clutter_synchronise = FALSE;
/* X error trap */
static int TrappedErrorCode = 0;
static int (* old_error_handler) (Display *, XErrorEvent *);
static MetaX11FilterReturn
cogl_xlib_filter (XEvent *xevent,
ClutterEvent *event,
gpointer data)
{
ClutterBackend *backend = data;
MetaX11FilterReturn retval;
CoglFilterReturn ret;
ret = cogl_xlib_renderer_handle_event (backend->cogl_renderer, xevent);
switch (ret)
{
case COGL_FILTER_REMOVE:
retval = META_X11_FILTER_REMOVE;
break;
case COGL_FILTER_CONTINUE:
default:
retval = META_X11_FILTER_CONTINUE;
break;
}
return retval;
}
static gboolean
meta_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;
}
env_string = g_getenv ("CLUTTER_DISABLE_XINPUT");
if (env_string)
{
clutter_enable_xinput = FALSE;
env_string = NULL;
}
return TRUE;
}
static gboolean
meta_clutter_backend_x11_post_parse (ClutterBackend *backend,
GError **error)
{
MetaClutterBackendX11 *backend_x11 = META_CLUTTER_BACKEND_X11 (backend);
Atom atoms[N_ATOM_NAMES];
if (_foreign_dpy)
backend_x11->xdisplay = _foreign_dpy;
/* Only open connection if not already set by prior call to
* clutter_x11_set_display()
*/
if (backend_x11->xdisplay == NULL)
{
if (clutter_display_name != NULL &&
*clutter_display_name != '\0')
{
g_debug ("XOpenDisplay on '%s'", clutter_display_name);
backend_x11->xdisplay = XOpenDisplay (clutter_display_name);
if (backend_x11->xdisplay == NULL)
{
g_set_error (error, CLUTTER_INIT_ERROR,
CLUTTER_INIT_ERROR_BACKEND,
"Unable to open display '%s'",
clutter_display_name);
return FALSE;
}
}
else
{
g_set_error_literal (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;
}
}
g_assert (backend_x11->xdisplay != NULL);
g_debug ("Getting the X screen");
/* add event filter for Cogl events */
meta_clutter_x11_add_filter (cogl_xlib_filter, backend);
if (clutter_screen == -1)
backend_x11->xscreen = DefaultScreenOfDisplay (backend_x11->xdisplay);
else
backend_x11->xscreen = ScreenOfDisplay (backend_x11->xdisplay,
clutter_screen);
backend_x11->xscreen_num = XScreenNumberOfScreen (backend_x11->xscreen);
backend_x11->xscreen_width = WidthOfScreen (backend_x11->xscreen);
backend_x11->xscreen_height = HeightOfScreen (backend_x11->xscreen);
backend_x11->xwin_root = RootWindow (backend_x11->xdisplay,
backend_x11->xscreen_num);
backend_x11->display_name = g_strdup (clutter_display_name);
if (clutter_synchronise)
XSynchronize (backend_x11->xdisplay, True);
XInternAtoms (backend_x11->xdisplay,
(char **) atom_names, N_ATOM_NAMES,
False, atoms);
backend_x11->atom_NET_WM_PID = atoms[0];
backend_x11->atom_NET_WM_PING = atoms[1];
backend_x11->atom_NET_WM_STATE = 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];
g_free (clutter_display_name);
g_debug ("X Display '%s'[%p] opened (screen:%d, root:%u, dpi:%f)",
backend_x11->display_name,
backend_x11->xdisplay,
backend_x11->xscreen_num,
(unsigned int) backend_x11->xwin_root,
clutter_backend_get_resolution (backend));
return TRUE;
}
static const GOptionEntry entries[] =
{
{
"display", 0,
G_OPTION_FLAG_IN_MAIN,
G_OPTION_ARG_STRING, &clutter_display_name,
N_("X display to use"), "DISPLAY"
},
{
"screen", 0,
G_OPTION_FLAG_IN_MAIN,
G_OPTION_ARG_INT, &clutter_screen,
N_("X screen to use"), "SCREEN"
},
{ "synch", 0,
0,
G_OPTION_ARG_NONE, &clutter_synchronise,
N_("Make X calls synchronous"), NULL
},
{
"disable-xinput", 0,
G_OPTION_FLAG_REVERSE,
G_OPTION_ARG_NONE, &clutter_enable_xinput,
N_("Disable XInput support"), NULL
},
{ NULL }
};
static void
meta_clutter_backend_x11_add_options (ClutterBackend *backend,
GOptionGroup *group)
{
g_option_group_add_entries (group, entries);
}
static void
meta_clutter_backend_x11_finalize (GObject *gobject)
{
MetaClutterBackendX11 *backend_x11 = META_CLUTTER_BACKEND_X11 (gobject);
g_free (backend_x11->display_name);
meta_clutter_x11_remove_filter (cogl_xlib_filter, gobject);
XCloseDisplay (backend_x11->xdisplay);
G_OBJECT_CLASS (meta_clutter_backend_x11_parent_class)->finalize (gobject);
}
static ClutterFeatureFlags
meta_clutter_backend_x11_get_features (ClutterBackend *backend)
{
ClutterFeatureFlags flags = CLUTTER_FEATURE_STAGE_CURSOR;
flags |=
CLUTTER_BACKEND_CLASS (meta_clutter_backend_x11_parent_class)->get_features (backend);
return flags;
}
static void
update_last_event_time (MetaClutterBackendX11 *backend_x11,
XEvent *xevent)
{
Time current_time = CurrentTime;
Time last_time = backend_x11->last_event_time;
switch (xevent->type)
{
case KeyPress:
case KeyRelease:
current_time = xevent->xkey.time;
break;
case ButtonPress:
case ButtonRelease:
current_time = xevent->xbutton.time;
break;
case MotionNotify:
current_time = xevent->xmotion.time;
break;
case EnterNotify:
case LeaveNotify:
current_time = xevent->xcrossing.time;
break;
case PropertyNotify:
current_time = xevent->xproperty.time;
break;
default:
break;
}
/* only change the current event time if it's after the previous event
* time, or if it is at least 30 seconds earlier - in case the system
* clock was changed
*/
if ((current_time != CurrentTime) &&
(current_time > last_time || (last_time - current_time > (30 * 1000))))
backend_x11->last_event_time = current_time;
}
static gboolean
check_onscreen_template (CoglRenderer *renderer,
CoglOnscreenTemplate *onscreen_template,
gboolean enable_stereo,
GError **error)
{
GError *internal_error = NULL;
cogl_onscreen_template_set_stereo_enabled (onscreen_template,
clutter_enable_stereo);
/* cogl_renderer_check_onscreen_template() is actually just a
* shorthand for creating a CoglDisplay, and calling
* cogl_display_setup() on it, then throwing the display away. If we
* could just return that display, then it would be more efficient
* not to use cogl_renderer_check_onscreen_template(). However, the
* backend API requires that we return an CoglDisplay that has not
* yet been setup, so one way or the other we'll have to discard the
* first display and make a new fresh one.
*/
if (cogl_renderer_check_onscreen_template (renderer, onscreen_template, &internal_error))
{
clutter_enable_stereo = enable_stereo;
return TRUE;
}
else
{
g_set_error_literal (error, CLUTTER_INIT_ERROR,
CLUTTER_INIT_ERROR_BACKEND,
internal_error != NULL
? internal_error->message
: "Creation of a CoglDisplay failed");
g_clear_error (&internal_error);
return FALSE;
}
}
static CoglDisplay *
meta_clutter_backend_x11_get_display (ClutterBackend *backend,
CoglRenderer *renderer,
CoglSwapChain *swap_chain,
GError **error)
{
CoglOnscreenTemplate *onscreen_template;
CoglDisplay *display = NULL;
gboolean res = FALSE;
onscreen_template = cogl_onscreen_template_new (swap_chain);
/* It's possible that the current renderer doesn't support transparency
* or doesn't support stereo, so we try the different combinations.
*/
if (clutter_enable_stereo)
res = check_onscreen_template (renderer, onscreen_template,
TRUE, error);
if (!res)
res = check_onscreen_template (renderer, onscreen_template,
FALSE, error);
if (res)
display = cogl_display_new (renderer, onscreen_template);
cogl_object_unref (onscreen_template);
return display;
}
static CoglRenderer *
meta_clutter_backend_x11_get_renderer (ClutterBackend *clutter_backend,
@ -76,21 +434,65 @@ meta_clutter_backend_x11_create_stage (ClutterBackend *backend,
return stage;
}
static gboolean
meta_clutter_backend_x11_process_event_filters (MetaClutterBackendX11 *backend_x11,
gpointer native,
ClutterEvent *event)
{
XEvent *xevent = native;
/* X11 filter functions have a higher priority */
if (backend_x11->event_filters != NULL)
{
GSList *node = backend_x11->event_filters;
while (node != NULL)
{
MetaX11EventFilter *filter = node->data;
switch (filter->func (xevent, event, filter->data))
{
case META_X11_FILTER_CONTINUE:
break;
case META_X11_FILTER_TRANSLATE:
return TRUE;
case META_X11_FILTER_REMOVE:
return FALSE;
default:
break;
}
node = node->next;
}
}
return FALSE;
}
static gboolean
meta_clutter_backend_x11_translate_event (ClutterBackend *clutter_backend,
gpointer native,
ClutterEvent *event)
{
MetaClutterBackendX11 *backend_x11 =
META_CLUTTER_BACKEND_X11 (clutter_backend);
MetaBackend *backend = meta_get_backend ();
MetaStageX11 *stage_x11;
ClutterBackendClass *clutter_backend_class;
ClutterSeat *seat;
clutter_backend_class =
CLUTTER_BACKEND_CLASS (meta_clutter_backend_x11_parent_class);
if (clutter_backend_class->translate_event (clutter_backend, native, event))
if (meta_clutter_backend_x11_process_event_filters (backend_x11,
native,
event))
return TRUE;
/* we update the event time only for events that can
* actually reach Clutter's event queue
*/
update_last_event_time (backend_x11, native);
stage_x11 =
META_STAGE_X11 (clutter_backend_get_stage_window (clutter_backend));
if (meta_stage_x11_translate_event (stage_x11, native, event))
@ -120,16 +522,224 @@ meta_clutter_backend_x11_is_display_server (ClutterBackend *backend)
static void
meta_clutter_backend_x11_init (MetaClutterBackendX11 *clutter_backend_x11)
{
clutter_backend_x11->last_event_time = CurrentTime;
}
static void
meta_clutter_backend_x11_class_init (MetaClutterBackendX11Class *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterBackendClass *clutter_backend_class = CLUTTER_BACKEND_CLASS (klass);
gobject_class->finalize = meta_clutter_backend_x11_finalize;
clutter_backend_class->pre_parse = meta_clutter_backend_x11_pre_parse;
clutter_backend_class->post_parse = meta_clutter_backend_x11_post_parse;
clutter_backend_class->add_options = meta_clutter_backend_x11_add_options;
clutter_backend_class->get_features = meta_clutter_backend_x11_get_features;
clutter_backend_class->get_display = meta_clutter_backend_x11_get_display;
clutter_backend_class->get_renderer = meta_clutter_backend_x11_get_renderer;
clutter_backend_class->create_stage = meta_clutter_backend_x11_create_stage;
clutter_backend_class->translate_event = meta_clutter_backend_x11_translate_event;
clutter_backend_class->get_default_seat = meta_clutter_backend_x11_get_default_seat;
clutter_backend_class->is_display_server = meta_clutter_backend_x11_is_display_server;
}
static int
error_handler (Display *xdisplay,
XErrorEvent *error)
{
TrappedErrorCode = error->error_code;
return 0;
}
void
meta_clutter_x11_trap_x_errors (void)
{
TrappedErrorCode = 0;
old_error_handler = XSetErrorHandler (error_handler);
}
gint
meta_clutter_x11_untrap_x_errors (void)
{
XSetErrorHandler (old_error_handler);
return TrappedErrorCode;
}
Display *
meta_clutter_x11_get_default_display (void)
{
ClutterBackend *backend = clutter_get_default_backend ();
if (backend == NULL)
{
g_critical ("The Clutter backend has not been initialised");
return NULL;
}
if (!META_IS_CLUTTER_BACKEND_X11 (backend))
{
g_critical ("The Clutter backend is not a X11 backend");
return NULL;
}
return META_CLUTTER_BACKEND_X11 (backend)->xdisplay;
}
void
meta_clutter_x11_set_display (Display *xdisplay)
{
if (_clutter_context_is_initialized ())
{
g_warning ("%s() can only be used before calling clutter_init()",
G_STRFUNC);
return;
}
_foreign_dpy= xdisplay;
}
int
meta_clutter_x11_get_default_screen (void)
{
ClutterBackend *backend = clutter_get_default_backend ();
if (backend == NULL)
{
g_critical ("The Clutter backend has not been initialised");
return 0;
}
if (!META_IS_CLUTTER_BACKEND_X11 (backend))
{
g_critical ("The Clutter backend is not a X11 backend");
return 0;
}
return META_CLUTTER_BACKEND_X11 (backend)->xscreen_num;
}
Window
meta_clutter_x11_get_root_window (void)
{
ClutterBackend *backend = clutter_get_default_backend ();
if (backend == NULL)
{
g_critical ("The Clutter backend has not been initialised");
return None;
}
if (!META_IS_CLUTTER_BACKEND_X11 (backend))
{
g_critical ("The Clutter backend is not a X11 backend");
return None;
}
return META_CLUTTER_BACKEND_X11 (backend)->xwin_root;
}
void
meta_clutter_x11_add_filter (MetaX11FilterFunc func,
gpointer data)
{
MetaX11EventFilter *filter;
ClutterBackend *backend = clutter_get_default_backend ();
MetaClutterBackendX11 *backend_x11;
g_return_if_fail (func != NULL);
if (backend == NULL)
{
g_critical ("The Clutter backend has not been initialised");
return;
}
if (!META_IS_CLUTTER_BACKEND_X11 (backend))
{
g_critical ("The Clutter backend is not a X11 backend");
return;
}
backend_x11 = META_CLUTTER_BACKEND_X11 (backend);
filter = g_new0 (MetaX11EventFilter, 1);
filter->func = func;
filter->data = data;
backend_x11->event_filters =
g_slist_append (backend_x11->event_filters, filter);
return;
}
void
meta_clutter_x11_remove_filter (MetaX11FilterFunc func,
gpointer data)
{
GSList *tmp_list, *this;
MetaX11EventFilter *filter;
ClutterBackend *backend = clutter_get_default_backend ();
MetaClutterBackendX11 *backend_x11;
g_return_if_fail (func != NULL);
if (backend == NULL)
{
g_critical ("The Clutter backend has not been initialised");
return;
}
if (!META_IS_CLUTTER_BACKEND_X11 (backend))
{
g_critical ("The Clutter backend is not a X11 backend");
return;
}
backend_x11 = META_CLUTTER_BACKEND_X11 (backend);
tmp_list = backend_x11->event_filters;
while (tmp_list)
{
filter = tmp_list->data;
this = tmp_list;
tmp_list = tmp_list->next;
if (filter->func == func && filter->data == data)
{
backend_x11->event_filters =
g_slist_remove_link (backend_x11->event_filters, this);
g_slist_free_1 (this);
g_free (filter);
return;
}
}
}
void
meta_clutter_x11_set_use_stereo_stage (gboolean use_stereo)
{
if (_clutter_context_is_initialized ())
{
g_warning ("%s() can only be used before calling clutter_init()",
G_STRFUNC);
return;
}
g_debug ("STEREO stages are %s",
use_stereo ? "enabled" : "disabled");
clutter_enable_stereo = use_stereo;
}
gboolean
meta_clutter_x11_get_use_stereo_stage (void)
{
return clutter_enable_stereo;
}

View File

@ -27,12 +27,70 @@
#include <glib-object.h>
#include "clutter/clutter.h"
#include "clutter/x11/clutter-backend-x11.h"
#include "clutter/clutter-mutter.h"
struct _MetaClutterBackendX11
{
ClutterBackend parent_instance;
Display *xdisplay;
char *display_name;
Screen *xscreen;
int xscreen_num;
int xscreen_width;
int xscreen_height;
Window xwin_root;
/* event source */
GSList *event_filters;
/* props */
Atom atom_NET_WM_PID;
Atom atom_NET_WM_PING;
Atom atom_NET_WM_STATE;
Atom atom_NET_WM_USER_TIME;
Atom atom_WM_PROTOCOLS;
Atom atom_WM_DELETE_WINDOW;
Atom atom_XEMBED;
Atom atom_XEMBED_INFO;
Atom atom_NET_WM_NAME;
Atom atom_UTF8_STRING;
Time last_event_time;
};
#define META_TYPE_CLUTTER_BACKEND_X11 (meta_clutter_backend_x11_get_type ())
G_DECLARE_FINAL_TYPE (MetaClutterBackendX11, meta_clutter_backend_x11,
META, CLUTTER_BACKEND_X11,
ClutterBackendX11)
ClutterBackend)
typedef enum
{
META_X11_FILTER_CONTINUE,
META_X11_FILTER_TRANSLATE,
META_X11_FILTER_REMOVE
} MetaX11FilterReturn;
typedef MetaX11FilterReturn (*MetaX11FilterFunc) (XEvent *xev,
ClutterEvent *cev,
gpointer data);
void meta_clutter_x11_trap_x_errors (void);
gint meta_clutter_x11_untrap_x_errors (void);
Display *meta_clutter_x11_get_default_display (void);
int meta_clutter_x11_get_default_screen (void);
Window meta_clutter_x11_get_root_window (void);
void meta_clutter_x11_set_display (Display * xdpy);
void meta_clutter_x11_add_filter (MetaX11FilterFunc func,
gpointer data);
void meta_clutter_x11_remove_filter (MetaX11FilterFunc func,
gpointer data);
void meta_clutter_x11_set_use_stereo_stage (gboolean use_stereo);
gboolean meta_clutter_x11_get_use_stereo_stage (void);
#endif /* META_CLUTTER_BACKEND_X11_H */

View File

@ -28,7 +28,6 @@
#include "backends/x11/meta-event-x11.h"
#include "clutter/clutter-mutter.h"
#include "clutter/x11/clutter-x11.h"
/**
* meta_x11_handle_event:
@ -38,44 +37,44 @@
* into external X11 event processing (for example, a GDK filter
* function).
*
* Return value: #ClutterX11FilterReturn. %CLUTTER_X11_FILTER_REMOVE
* Return value: #MetaX11FilterReturn. %META_X11_FILTER_REMOVE
* indicates that Clutter has internally handled the event and the
* caller should do no further processing. %CLUTTER_X11_FILTER_CONTINUE
* caller should do no further processing. %META_X11_FILTER_CONTINUE
* indicates that Clutter is either not interested in the event,
* or has used the event to update internal state without taking
* any exclusive action. %CLUTTER_X11_FILTER_TRANSLATE will not
* any exclusive action. %META_X11_FILTER_TRANSLATE will not
* occur.
*
* Since: 0.8
*/
ClutterX11FilterReturn
MetaX11FilterReturn
meta_x11_handle_event (XEvent *xevent)
{
ClutterX11FilterReturn result;
MetaX11FilterReturn result;
ClutterBackend *backend;
ClutterEvent *event;
gint spin = 1;
ClutterBackendX11 *backend_x11;
MetaClutterBackendX11 *backend_x11;
Display *xdisplay;
gboolean allocated_event;
/* The return values here are someone approximate; we return
* CLUTTER_X11_FILTER_REMOVE if a clutter event is
* META_X11_FILTER_REMOVE if a clutter event is
* generated for the event. This mostly, but not entirely,
* corresponds to whether other event processing should be
* excluded. As long as the stage window is not shared with another
* toolkit it should be safe, and never return
* %CLUTTER_X11_FILTER_REMOVE when more processing is needed.
* %META_X11_FILTER_REMOVE when more processing is needed.
*/
result = CLUTTER_X11_FILTER_CONTINUE;
result = META_X11_FILTER_CONTINUE;
backend = clutter_get_default_backend ();
event = clutter_event_new (CLUTTER_NOTHING);
backend_x11 = CLUTTER_BACKEND_X11 (backend);
xdisplay = backend_x11->xdpy;
backend_x11 = META_CLUTTER_BACKEND_X11 (backend);
xdisplay = backend_x11->xdisplay;
allocated_event = XGetEventData (xdisplay, &xevent->xcookie);
@ -83,7 +82,7 @@ meta_x11_handle_event (XEvent *xevent)
{
_clutter_event_push (event, FALSE);
result = CLUTTER_X11_FILTER_REMOVE;
result = META_X11_FILTER_REMOVE;
}
else
{

View File

@ -26,8 +26,8 @@
#include <X11/Xlib.h>
#include "clutter/x11/clutter-x11.h"
#include "backends/x11/meta-clutter-backend-x11.h"
ClutterX11FilterReturn meta_x11_handle_event (XEvent *xevent);
MetaX11FilterReturn meta_x11_handle_event (XEvent *xevent);
#endif /* META_EVENT_X11_H */

View File

@ -22,7 +22,7 @@
#include <X11/extensions/XInput2.h>
#include "clutter/clutter-mutter.h"
#include "clutter/x11/clutter-x11.h"
#include "backends/x11/meta-clutter-backend-x11.h"
#include "backends/x11/meta-input-device-x11.h"
struct _MetaInputDeviceX11
@ -406,10 +406,10 @@ meta_input_device_x11_query_pointer_location (MetaInputDeviceX11 *device_xi2)
XIGroupState group_state;
int result;
clutter_x11_trap_x_errors ();
result = XIQueryPointer (clutter_x11_get_default_display (),
meta_clutter_x11_trap_x_errors ();
result = XIQueryPointer (meta_clutter_x11_get_default_display (),
device_xi2->device_id,
clutter_x11_get_root_window (),
meta_clutter_x11_get_root_window (),
&xroot_window,
&xchild_window,
&xroot_x, &xroot_y,
@ -417,7 +417,7 @@ meta_input_device_x11_query_pointer_location (MetaInputDeviceX11 *device_xi2)
&button_state,
&mod_state,
&group_state);
clutter_x11_untrap_x_errors ();
meta_clutter_x11_untrap_x_errors ();
g_free (button_state.mask);

View File

@ -118,11 +118,11 @@ get_property (ClutterInputDevice *device,
device_id = meta_input_device_x11_get_device_id (device);
clutter_x11_trap_x_errors ();
meta_clutter_x11_trap_x_errors ();
rc = XIGetProperty (xdisplay, device_id, property_atom,
0, 10, False, type, &type_ret, &format_ret,
&nitems_ret, &bytes_after_ret, &data_ret);
clutter_x11_untrap_x_errors ();
meta_clutter_x11_untrap_x_errors ();
if (rc == Success && type_ret == type && format_ret == format && nitems_ret >= nitems)
{

View File

@ -28,11 +28,11 @@
#include "backends/meta-backend-private.h"
#include "backends/meta-input-settings-private.h"
#include "backends/x11/meta-clutter-backend-x11.h"
#include "backends/x11/meta-keymap-x11.h"
#include "clutter/clutter.h"
#include "clutter/clutter-keymap-private.h"
#include "clutter/clutter-mutter.h"
#include "clutter/x11/clutter-x11.h"
typedef struct _DirectionCacheEntry DirectionCacheEntry;
typedef struct _ClutterKeymapKey ClutterKeymapKey;
@ -144,7 +144,7 @@ update_modmap (Display *display,
static XkbDescPtr
get_xkb (MetaKeymapX11 *keymap_x11)
{
Display *xdisplay = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
if (keymap_x11->max_keycode == 0)
XDisplayKeycodes (xdisplay,
@ -356,7 +356,7 @@ static void
meta_keymap_x11_constructed (GObject *object)
{
MetaKeymapX11 *keymap_x11 = META_KEYMAP_X11 (object);
Display *xdisplay = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
int xkb_major = XkbMajorVersion;
int xkb_minor = XkbMinorVersion;
@ -420,7 +420,7 @@ meta_keymap_x11_set_property (GObject *object,
static void
meta_keymap_x11_refresh_reserved_keycodes (MetaKeymapX11 *keymap_x11)
{
Display *dpy = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
GHashTableIter iter;
gpointer key, value;
@ -429,7 +429,7 @@ meta_keymap_x11_refresh_reserved_keycodes (MetaKeymapX11 *keymap_x11)
{
uint32_t reserved_keycode = GPOINTER_TO_UINT (key);
uint32_t reserved_keysym = GPOINTER_TO_UINT (value);
uint32_t actual_keysym = XkbKeycodeToKeysym (dpy, reserved_keycode, 0, 0);
uint32_t actual_keysym = XkbKeycodeToKeysym (xdisplay, reserved_keycode, 0, 0);
/* If an available keycode is no longer mapped to the stored keysym, then
* the keycode should not be considered available anymore and should be
@ -450,11 +450,11 @@ meta_keymap_x11_replace_keycode (MetaKeymapX11 *keymap_x11,
{
if (keymap_x11->use_xkb)
{
Display *dpy = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
XkbDescPtr xkb = get_xkb (keymap_x11);
XkbMapChangesRec changes;
XFlush (dpy);
XFlush (xdisplay);
xkb->device_spec = XkbUseCoreKbd;
memset (&changes, 0, sizeof(changes));
@ -476,9 +476,9 @@ meta_keymap_x11_replace_keycode (MetaKeymapX11 *keymap_x11,
changes.num_key_syms = 1;
changes.first_type = 0;
changes.num_types = xkb->map->num_types;
XkbChangeMap (dpy, xkb, &changes);
XkbChangeMap (xdisplay, xkb, &changes);
XFlush (dpy);
XFlush (xdisplay);
return TRUE;
}
@ -527,7 +527,7 @@ meta_keymap_x11_get_direction (ClutterKeymap *keymap)
{
XkbStateRec state_rec;
XkbGetState (clutter_x11_get_default_display (),
XkbGetState (meta_clutter_x11_get_default_display (),
XkbUseCoreKbd, &state_rec);
update_direction (keymap_x11, XkbStateGroup (&state_rec));
}
@ -638,7 +638,7 @@ translate_keysym (MetaKeymapX11 *keymap,
{
int retval;
retval = XKeycodeToKeysym (clutter_x11_get_default_display (),
retval = XKeycodeToKeysym (meta_clutter_x11_get_default_display (),
hardware_keycode, 0);
return retval;
}
@ -796,13 +796,13 @@ meta_keymap_x11_get_available_keycode (MetaKeymapX11 *keymap_x11)
if (g_hash_table_size (keymap_x11->reserved_keycodes) < 5)
{
Display *dpy = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
XkbDescPtr xkb = get_xkb (keymap_x11);
uint32_t i;
for (i = xkb->max_key_code; i >= xkb->min_key_code; --i)
{
if (XkbKeycodeToKeysym (dpy, i, 0, 0) == NoSymbol)
if (XkbKeycodeToKeysym (xdisplay, i, 0, 0) == NoSymbol)
return i;
}
}
@ -878,7 +878,7 @@ meta_keymap_x11_latch_modifiers (MetaKeymapX11 *keymap_x11,
else
value = 0;
XkbLatchModifiers (clutter_x11_get_default_display (),
XkbLatchModifiers (meta_clutter_x11_get_default_display (),
XkbUseCoreKbd, modifiers[level],
value);
}
@ -891,7 +891,7 @@ meta_keymap_x11_get_current_group (MetaKeymapX11 *keymap_x11)
if (keymap_x11->current_group >= 0)
return keymap_x11->current_group;
XkbGetState (clutter_x11_get_default_display (),
XkbGetState (meta_clutter_x11_get_default_display (),
XkbUseCoreKbd, &state_rec);
return XkbStateGroup (&state_rec);
}

View File

@ -30,8 +30,8 @@
#include "backends/meta-logical-monitor.h"
#include "backends/meta-renderer-view.h"
#include "backends/meta-renderer.h"
#include "backends/x11/meta-clutter-backend-x11.h"
#include "backends/x11/meta-renderer-x11.h"
#include "clutter/x11/clutter-x11.h"
#include "cogl/cogl-xlib.h"
#include "cogl/cogl.h"
#include "core/boxes-private.h"
@ -82,7 +82,7 @@ static CoglRenderer *
meta_renderer_x11_create_cogl_renderer (MetaRenderer *renderer)
{
CoglRenderer *cogl_renderer;
Display *xdisplay = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
cogl_renderer = cogl_renderer_new ();
cogl_renderer_set_custom_winsys (cogl_renderer, get_x11_cogl_winsys_vtable,

View File

@ -24,6 +24,7 @@
#include "backends/meta-input-settings-private.h"
#include "backends/x11/meta-backend-x11.h"
#include "backends/x11/meta-clutter-backend-x11.h"
#include "backends/x11/meta-event-x11.h"
#include "backends/x11/meta-input-device-tool-x11.h"
#include "backends/x11/meta-input-device-x11.h"
@ -32,7 +33,6 @@
#include "backends/x11/meta-virtual-input-device-x11.h"
#include "backends/x11/meta-xkb-a11y-x11.h"
#include "clutter/clutter-mutter.h"
#include "clutter/x11/clutter-x11.h"
#include "core/bell.h"
#include "meta-seat-x11.h"
@ -254,17 +254,18 @@ is_touchpad_device (XIDeviceInfo *info)
Atom type;
Atom prop;
prop = XInternAtom (clutter_x11_get_default_display (), "libinput Tapping Enabled", True);
prop = XInternAtom (meta_clutter_x11_get_default_display (),
"libinput Tapping Enabled", True);
if (prop == None)
return FALSE;
clutter_x11_trap_x_errors ();
rc = XIGetProperty (clutter_x11_get_default_display (),
meta_clutter_x11_trap_x_errors ();
rc = XIGetProperty (meta_clutter_x11_get_default_display (),
info->deviceid,
prop,
0, 1, False, XA_INTEGER, &type, &format, &nitems, &bytes_after,
(guchar **) &data);
clutter_x11_untrap_x_errors ();
meta_clutter_x11_untrap_x_errors ();
/* We don't care about the data */
XFree (data);
@ -285,13 +286,13 @@ get_device_ids (XIDeviceInfo *info,
int rc, format;
Atom type;
clutter_x11_trap_x_errors ();
rc = XIGetProperty (clutter_x11_get_default_display (),
meta_clutter_x11_trap_x_errors ();
rc = XIGetProperty (meta_clutter_x11_get_default_display (),
info->deviceid,
XInternAtom (clutter_x11_get_default_display (), "Device Product ID", False),
XInternAtom (meta_clutter_x11_get_default_display (), "Device Product ID", False),
0, 2, False, XA_INTEGER, &type, &format, &nitems, &bytes_after,
(guchar **) &data);
clutter_x11_untrap_x_errors ();
meta_clutter_x11_untrap_x_errors ();
if (rc != Success || type != XA_INTEGER || format != 32 || nitems != 2)
{
@ -318,18 +319,18 @@ get_device_node_path (XIDeviceInfo *info)
Atom prop, type;
char *node_path;
prop = XInternAtom (clutter_x11_get_default_display (), "Device Node", False);
prop = XInternAtom (meta_clutter_x11_get_default_display (), "Device Node", False);
if (prop == None)
return NULL;
clutter_x11_trap_x_errors ();
meta_clutter_x11_trap_x_errors ();
rc = XIGetProperty (clutter_x11_get_default_display (),
rc = XIGetProperty (meta_clutter_x11_get_default_display (),
info->deviceid, prop, 0, 1024, False,
XA_STRING, &type, &format, &nitems, &bytes_after,
(guchar **) &data);
if (clutter_x11_untrap_x_errors ())
if (meta_clutter_x11_untrap_x_errors ())
return NULL;
if (rc != Success || type != XA_STRING || format != 8)
@ -388,17 +389,17 @@ guess_source_from_wacom_type (XIDeviceInfo *info,
Atom device_type;
Atom types[N_WACOM_TYPE_ATOMS];
prop = XInternAtom (clutter_x11_get_default_display (), "Wacom Tool Type", True);
prop = XInternAtom (meta_clutter_x11_get_default_display (), "Wacom Tool Type", True);
if (prop == None)
return FALSE;
clutter_x11_trap_x_errors ();
rc = XIGetProperty (clutter_x11_get_default_display (),
meta_clutter_x11_trap_x_errors ();
rc = XIGetProperty (meta_clutter_x11_get_default_display (),
info->deviceid,
prop,
0, 1, False, XA_ATOM, &type, &format, &nitems, &bytes_after,
(guchar **) &data);
clutter_x11_untrap_x_errors ();
meta_clutter_x11_untrap_x_errors ();
if (rc != Success || type != XA_ATOM || format != 32 || nitems != 1)
{
@ -412,7 +413,7 @@ guess_source_from_wacom_type (XIDeviceInfo *info,
if (device_type == 0)
return FALSE;
rc = XInternAtoms (clutter_x11_get_default_display (),
rc = XInternAtoms (meta_clutter_x11_get_default_display (),
(char **)wacom_type_atoms,
N_WACOM_TYPE_ATOMS,
False,
@ -544,7 +545,7 @@ create_device (MetaSeatX11 *seat_x11,
"seat", seat_x11,
NULL);
translate_device_classes (clutter_x11_get_default_display (), retval,
translate_device_classes (meta_clutter_x11_get_default_display (), retval,
info->classes,
info->num_classes);
@ -577,10 +578,10 @@ pad_passive_button_grab (ClutterInputDevice *device)
XISetMask (xi_event_mask.mask, XI_ButtonPress);
XISetMask (xi_event_mask.mask, XI_ButtonRelease);
clutter_x11_trap_x_errors ();
rc = XIGrabButton (clutter_x11_get_default_display (),
meta_clutter_x11_trap_x_errors ();
rc = XIGrabButton (meta_clutter_x11_get_default_display (),
device_id, XIAnyButton,
clutter_x11_get_root_window (), None,
meta_clutter_x11_get_root_window (), None,
XIGrabModeSync, XIGrabModeSync,
True, &xi_event_mask, 1, &xi_grab_mods);
if (rc != 0)
@ -590,12 +591,12 @@ pad_passive_button_grab (ClutterInputDevice *device)
}
else
{
XIAllowEvents (clutter_x11_get_default_display (),
XIAllowEvents (meta_clutter_x11_get_default_display (),
device_id, XIAsyncDevice,
CLUTTER_CURRENT_TIME);
}
clutter_x11_untrap_x_errors ();
meta_clutter_x11_untrap_x_errors ();
g_free (xi_event_mask.mask);
}
@ -737,16 +738,17 @@ device_get_tool_serial (ClutterInputDevice *device)
Atom type;
Atom prop;
prop = XInternAtom (clutter_x11_get_default_display (), "Wacom Serial IDs", True);
prop = XInternAtom (meta_clutter_x11_get_default_display (),
"Wacom Serial IDs", True);
if (prop == None)
return 0;
clutter_x11_trap_x_errors ();
rc = XIGetProperty (clutter_x11_get_default_display (),
meta_clutter_x11_trap_x_errors ();
rc = XIGetProperty (meta_clutter_x11_get_default_display (),
meta_input_device_x11_get_device_id (device),
prop, 0, 4, FALSE, XA_INTEGER, &type, &format, &nitems, &bytes_after,
(guchar **) &data);
clutter_x11_untrap_x_errors ();
meta_clutter_x11_untrap_x_errors ();
if (rc == Success && type == XA_INTEGER && format == 32 && nitems >= 4)
serial_id = data[3];
@ -776,11 +778,11 @@ translate_hierarchy_event (ClutterBackend *backend,
g_debug ("Hierarchy event: device enabled");
clutter_x11_trap_x_errors ();
info = XIQueryDevice (clutter_x11_get_default_display (),
meta_clutter_x11_trap_x_errors ();
info = XIQueryDevice (meta_clutter_x11_get_default_display (),
ev->info[i].deviceid,
&n_devices);
clutter_x11_untrap_x_errors ();
meta_clutter_x11_untrap_x_errors ();
if (info != NULL)
{
ClutterInputDevice *device;
@ -834,9 +836,14 @@ translate_property_event (MetaSeatX11 *seat_x11,
XIEvent *event)
{
XIPropertyEvent *xev = (XIPropertyEvent *) event;
Atom serial_ids_prop = XInternAtom (clutter_x11_get_default_display (), "Wacom Serial IDs", True);
Atom serial_ids_prop;
ClutterInputDevice *device;
serial_ids_prop = XInternAtom (meta_clutter_x11_get_default_display (),
"Wacom Serial IDs", True);
if (serial_ids_prop == None)
return;
device = g_hash_table_lookup (seat_x11->devices_by_id,
GINT_TO_POINTER (xev->deviceid));
if (!device)
@ -1362,10 +1369,9 @@ meta_seat_x11_constructed (GObject *object)
int n_devices, i;
Display *xdisplay;
xdisplay = clutter_x11_get_default_display ();
xdisplay = meta_clutter_x11_get_default_display ();
info = XIQueryDevice (clutter_x11_get_default_display (),
XIAllDevices, &n_devices);
info = XIQueryDevice (xdisplay, XIAllDevices, &n_devices);
for (i = 0; i < n_devices; i++)
{
@ -1387,7 +1393,7 @@ meta_seat_x11_constructed (GObject *object)
event_mask.mask_len = sizeof (mask);
event_mask.mask = mask;
XISelectEvents (xdisplay, clutter_x11_get_root_window (),
XISelectEvents (xdisplay, meta_clutter_x11_get_root_window (),
&event_mask, 1);
memset(mask, 0, sizeof (mask));
@ -1399,7 +1405,7 @@ meta_seat_x11_constructed (GObject *object)
event_mask.mask_len = sizeof (mask);
event_mask.mask = mask;
XISelectEvents (xdisplay, clutter_x11_get_root_window (),
XISelectEvents (xdisplay, meta_clutter_x11_get_root_window (),
&event_mask, 1);
XSync (xdisplay, False);
@ -1493,14 +1499,14 @@ meta_seat_x11_warp_pointer (ClutterSeat *seat,
{
MetaSeatX11 *seat_x11 = META_SEAT_X11 (seat);
clutter_x11_trap_x_errors ();
XIWarpPointer (clutter_x11_get_default_display (),
meta_clutter_x11_trap_x_errors ();
XIWarpPointer (meta_clutter_x11_get_default_display (),
seat_x11->pointer_id,
None,
clutter_x11_get_root_window (),
meta_clutter_x11_get_root_window (),
0, 0, 0, 0,
x, y);
clutter_x11_untrap_x_errors ();
meta_clutter_x11_untrap_x_errors ();
}
static uint32_t
@ -1565,14 +1571,14 @@ meta_seat_x11_query_state (ClutterSeat *seat,
XIModifierState modifier_state;
XIGroupState group_state;
clutter_x11_trap_x_errors ();
XIQueryPointer (clutter_x11_get_default_display (),
meta_clutter_x11_trap_x_errors ();
XIQueryPointer (meta_clutter_x11_get_default_display (),
seat_x11->pointer_id,
meta_backend_x11_get_xwindow (backend_x11),
&root_ret, &child_ret,
&root_x, &root_y, &win_x, &win_y,
&button_state, &modifier_state, &group_state);
if (clutter_x11_untrap_x_errors ())
if (meta_clutter_x11_untrap_x_errors ())
{
g_free (button_state.mask);
return FALSE;
@ -1831,7 +1837,7 @@ meta_seat_x11_translate_event (MetaSeatX11 *seat,
if (device)
{
meta_input_device_x11_reset_axes (device);
translate_device_classes (clutter_x11_get_default_display (),
translate_device_classes (meta_clutter_x11_get_default_display (),
device,
xev->classes,
xev->num_classes);
@ -1930,7 +1936,7 @@ meta_seat_x11_translate_event (MetaSeatX11 *seat,
if (clutter_input_device_get_device_type (source_device) == CLUTTER_PAD_DEVICE)
{
/* We got these events because of the passive button grab */
XIAllowEvents (clutter_x11_get_default_display (),
XIAllowEvents (meta_clutter_x11_get_default_display (),
xev->sourceid,
XIAsyncDevice,
xev->time);
@ -2409,7 +2415,7 @@ meta_seat_x11_select_stage_events (MetaSeatX11 *seat,
xi_event_mask.mask = mask;
xi_event_mask.mask_len = len;
XISelectEvents (clutter_x11_get_default_display (),
XISelectEvents (meta_clutter_x11_get_default_display (),
stage_x11->xwin, &xi_event_mask, 1);
g_free (mask);

View File

@ -30,12 +30,11 @@
#include "backends/x11/cm/meta-backend-x11-cm.h"
#include "backends/x11/cm/meta-renderer-x11-cm.h"
#include "backends/x11/meta-backend-x11.h"
#include "backends/x11/meta-clutter-backend-x11.h"
#include "backends/x11/meta-seat-x11.h"
#include "backends/x11/meta-stage-x11.h"
#include "backends/x11/nested/meta-stage-x11-nested.h"
#include "clutter/clutter-mutter.h"
#include "clutter/x11/clutter-x11.h"
#include "clutter/x11/clutter-backend-x11.h"
#include "cogl/cogl-mutter.h"
#include "cogl/cogl.h"
#include "core/display-private.h"
@ -85,7 +84,7 @@ meta_stage_x11_fix_window_size (MetaStageX11 *stage_x11,
if (stage_x11->xwin != None)
{
Display *xdisplay = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
uint32_t min_width, min_height;
XSizeHints *size_hints;
@ -117,8 +116,9 @@ static void
meta_stage_x11_set_wm_protocols (MetaStageX11 *stage_x11)
{
MetaStageImpl *stage_impl = META_STAGE_IMPL (stage_x11);
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (stage_impl->backend);
Display *xdisplay = clutter_x11_get_default_display ();
MetaClutterBackendX11 *backend_x11 =
META_CLUTTER_BACKEND_X11 (stage_impl->backend);
Display *xdisplay = meta_clutter_x11_get_default_display ();
Atom protocols[2];
int n = 0;
@ -163,7 +163,7 @@ meta_stage_x11_resize (ClutterStageWindow *stage_window,
if (width != stage_x11->xwin_width ||
height != stage_x11->xwin_height)
{
Display *xdisplay = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
/* XXX: in this case we can rely on a subsequent
* ConfigureNotify that will result in the stage
@ -189,8 +189,9 @@ static inline void
set_wm_pid (MetaStageX11 *stage_x11)
{
MetaStageImpl *stage_impl = META_STAGE_IMPL (stage_x11);
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (stage_impl->backend);
Display *xdisplay = clutter_x11_get_default_display ();
MetaClutterBackendX11 *backend_x11 =
META_CLUTTER_BACKEND_X11 (stage_impl->backend);
Display *xdisplay = meta_clutter_x11_get_default_display ();
long pid;
if (stage_x11->xwin == None)
@ -215,8 +216,9 @@ static inline void
set_wm_title (MetaStageX11 *stage_x11)
{
MetaStageImpl *stage_impl = META_STAGE_IMPL (stage_x11);
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (stage_impl->backend);
Display *xdisplay = clutter_x11_get_default_display ();
MetaClutterBackendX11 *backend_x11 =
META_CLUTTER_BACKEND_X11 (stage_impl->backend);
Display *xdisplay = meta_clutter_x11_get_default_display ();
if (stage_x11->xwin == None)
return;
@ -295,7 +297,7 @@ meta_stage_x11_realize (ClutterStageWindow *stage_window)
MetaStageImpl *stage_impl = META_STAGE_IMPL (stage_window);
ClutterBackend *backend = CLUTTER_BACKEND (stage_impl->backend);
MetaSeatX11 *seat_x11 = META_SEAT_X11 (clutter_backend_get_default_seat (backend));
Display *xdisplay = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
float width, height;
GError *error = NULL;
@ -345,7 +347,7 @@ meta_stage_x11_realize (ClutterStageWindow *stage_window)
/* we unconditionally select input events even with event retrieval
* disabled because we need to guarantee that the Clutter internal
* state is maintained when calling clutter_x11_handle_event() without
* state is maintained when calling meta_clutter_x11_handle_event() without
* requiring applications or embedding toolkits to select events
* themselves. if we did that, we'd have to document the events to be
* selected, and also update applications and embedding toolkits each
@ -386,7 +388,7 @@ meta_stage_x11_set_title (ClutterStageWindow *stage_window,
static inline void
update_wm_hints (MetaStageX11 *stage_x11)
{
Display *xdisplay = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
XWMHints wm_hints;
if (stage_x11->wm_state & STAGE_X11_WITHDRAWN)
@ -427,7 +429,7 @@ meta_stage_x11_show (ClutterStageWindow *stage_window,
if (stage_x11->xwin != None)
{
Display *xdisplay = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
if (do_raise)
{
@ -457,7 +459,7 @@ meta_stage_x11_hide (ClutterStageWindow *stage_window)
if (stage_x11->xwin != None)
{
Display *xdisplay = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
if (STAGE_X11_IS_MAPPED (stage_x11))
set_stage_x11_state (stage_x11, 0, STAGE_X11_WITHDRAWN);
@ -550,13 +552,13 @@ clutter_stage_window_iface_init (ClutterStageWindowInterface *iface)
}
static inline void
set_user_time (ClutterBackendX11 *backend_x11,
MetaStageX11 *stage_x11,
long timestamp)
set_user_time (MetaClutterBackendX11 *backend_x11,
MetaStageX11 *stage_x11,
long timestamp)
{
if (timestamp != CLUTTER_CURRENT_TIME)
{
Display *xdisplay = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
XChangeProperty (xdisplay,
stage_x11->xwin,
@ -568,9 +570,9 @@ set_user_time (ClutterBackendX11 *backend_x11,
}
static gboolean
handle_wm_protocols_event (ClutterBackendX11 *backend_x11,
MetaStageX11 *stage_x11,
XEvent *xevent)
handle_wm_protocols_event (MetaClutterBackendX11 *backend_x11,
MetaStageX11 *stage_x11,
XEvent *xevent)
{
Atom atom = (Atom) xevent->xclient.data.l[0];
@ -585,7 +587,7 @@ handle_wm_protocols_event (ClutterBackendX11 *backend_x11,
xevent->xany.window == stage_x11->xwin)
{
XClientMessageEvent xclient = xevent->xclient;
Display *xdisplay = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
xclient.window = backend_x11->xwin_root;
XSendEvent (xdisplay, xclient.window,
@ -616,7 +618,7 @@ meta_stage_x11_translate_event (MetaStageX11 *stage_x11,
{
MetaStageImpl *stage_impl;
gboolean res = FALSE;
ClutterBackendX11 *clutter_backend_x11;
MetaClutterBackendX11 *clutter_backend_x11;
ClutterStage *stage;
MetaBackend *backend;
@ -626,7 +628,7 @@ meta_stage_x11_translate_event (MetaStageX11 *stage_x11,
stage = stage_impl->wrapper;
backend = stage_x11->backend;
clutter_backend_x11 = CLUTTER_BACKEND_X11 (stage_impl->backend);
clutter_backend_x11 = META_CLUTTER_BACKEND_X11 (stage_impl->backend);
switch (xevent->type)
{
@ -844,7 +846,8 @@ meta_stage_x11_set_user_time (MetaStageX11 *stage_x11,
uint32_t user_time)
{
MetaStageImpl *stage_impl = META_STAGE_IMPL (stage_x11);
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (stage_impl->backend);
MetaClutterBackendX11 *backend_x11 =
META_CLUTTER_BACKEND_X11 (stage_impl->backend);
set_user_time (backend_x11, stage_x11, user_time);
}

View File

@ -26,8 +26,8 @@
#include <X11/Xatom.h>
#include "backends/meta-backend-private.h"
#include "backends/x11/meta-clutter-backend-x11.h"
#include "clutter/clutter-mutter.h"
#include "clutter/x11/clutter-x11.h"
G_BEGIN_DECLS

View File

@ -23,8 +23,8 @@
#include <X11/extensions/XTest.h>
#include "backends/x11/meta-clutter-backend-x11.h"
#include "clutter/clutter.h"
#include "clutter/x11/clutter-x11.h"
#include "meta-keymap-x11.h"
#include "meta-virtual-input-device-x11.h"
@ -48,7 +48,7 @@ meta_virtual_input_device_x11_notify_relative_motion (ClutterVirtualInputDevice
double dx,
double dy)
{
XTestFakeRelativeMotionEvent (clutter_x11_get_default_display (),
XTestFakeRelativeMotionEvent (meta_clutter_x11_get_default_display (),
(int) dx,
(int) dy,
0);
@ -60,8 +60,8 @@ meta_virtual_input_device_x11_notify_absolute_motion (ClutterVirtualInputDevice
double x,
double y)
{
XTestFakeMotionEvent (clutter_x11_get_default_display (),
clutter_x11_get_default_screen (),
XTestFakeMotionEvent (meta_clutter_x11_get_default_display (),
meta_clutter_x11_get_default_screen (),
(int) x,
(int) y,
0);
@ -73,7 +73,7 @@ meta_virtual_input_device_x11_notify_button (ClutterVirtualInputDevice *virtual_
uint32_t button,
ClutterButtonState button_state)
{
XTestFakeButtonEvent (clutter_x11_get_default_display (),
XTestFakeButtonEvent (meta_clutter_x11_get_default_display (),
button, button_state == CLUTTER_BUTTON_STATE_PRESSED, 0);
}
@ -83,7 +83,7 @@ meta_virtual_input_device_x11_notify_discrete_scroll (ClutterVirtualInputDevice
ClutterScrollDirection direction,
ClutterScrollSource scroll_source)
{
Display *xdisplay = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
int button;
switch (direction)
@ -158,7 +158,7 @@ meta_virtual_input_device_x11_notify_key (ClutterVirtualInputDevice *virtual_dev
uint32_t key,
ClutterKeyState key_state)
{
XTestFakeKeyEvent (clutter_x11_get_default_display (),
XTestFakeKeyEvent (meta_clutter_x11_get_default_display (),
key + 8, key_state == CLUTTER_KEY_STATE_PRESSED, 0);
}
@ -188,7 +188,7 @@ meta_virtual_input_device_x11_notify_keyval (ClutterVirtualInputDevice *virtual_
key_state == CLUTTER_KEY_STATE_PRESSED)
meta_keymap_x11_latch_modifiers (keymap, level, TRUE);
XTestFakeKeyEvent (clutter_x11_get_default_display (),
XTestFakeKeyEvent (meta_clutter_x11_get_default_display (),
(KeyCode) keycode,
key_state == CLUTTER_KEY_STATE_PRESSED, 0);

View File

@ -25,8 +25,8 @@
#include <X11/XKBlib.h>
#include <X11/extensions/XKBstr.h>
#include "backends/x11/meta-clutter-backend-x11.h"
#include "backends/x11/meta-xkb-a11y-x11.h"
#include "clutter/x11/clutter-x11.h"
#include "core/display-private.h"
#include "meta/meta-x11-errors.h"
@ -48,14 +48,14 @@ get_xkb_desc_rec (Display *xdisplay)
XkbDescRec *desc;
Status status = Success;
clutter_x11_trap_x_errors ();
meta_clutter_x11_trap_x_errors ();
desc = XkbGetMap (xdisplay, XkbAllMapComponentsMask, XkbUseCoreKbd);
if (desc != NULL)
{
desc->ctrls = NULL;
status = XkbGetControls (xdisplay, XkbAllControlsMask, desc);
}
clutter_x11_untrap_x_errors ();
meta_clutter_x11_untrap_x_errors ();
g_return_val_if_fail (desc != NULL, NULL);
g_return_val_if_fail (desc->ctrls != NULL, NULL);
@ -68,16 +68,16 @@ static void
set_xkb_desc_rec (Display *xdisplay,
XkbDescRec *desc)
{
clutter_x11_trap_x_errors ();
meta_clutter_x11_trap_x_errors ();
XkbSetControls (xdisplay, DEFAULT_XKB_SET_CONTROLS_MASK, desc);
XSync (xdisplay, FALSE);
clutter_x11_untrap_x_errors ();
meta_clutter_x11_untrap_x_errors ();
}
static void
check_settings_changed (ClutterSeat *seat)
{
Display *xdisplay = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
MetaKbdA11ySettings kbd_a11y_settings;
MetaKeyboardA11yFlags what_changed = 0;
MetaInputSettings *input_settings;
@ -131,7 +131,7 @@ check_settings_changed (ClutterSeat *seat)
XkbFreeKeyboard (desc, XkbAllComponentsMask, TRUE);
}
static ClutterX11FilterReturn
static MetaX11FilterReturn
xkb_a11y_event_filter (XEvent *xevent,
ClutterEvent *clutter_event,
gpointer data)
@ -151,7 +151,7 @@ xkb_a11y_event_filter (XEvent *xevent,
xkbev->any.xkb_type == XkbControlsNotify && xkbev->ctrls.event_type != 0)
check_settings_changed (seat);
return CLUTTER_X11_FILTER_CONTINUE;
return META_X11_FILTER_CONTINUE;
}
static gboolean
@ -205,7 +205,7 @@ void
meta_seat_x11_apply_kbd_a11y_settings (ClutterSeat *seat,
MetaKbdA11ySettings *kbd_a11y_settings)
{
Display *xdisplay = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
XkbDescRec *desc;
gboolean enable_accessX;
@ -323,7 +323,7 @@ meta_seat_x11_apply_kbd_a11y_settings (ClutterSeat *seat,
gboolean
meta_seat_x11_a11y_init (ClutterSeat *seat)
{
Display *xdisplay = clutter_x11_get_default_display ();
Display *xdisplay = meta_clutter_x11_get_default_display ();
guint event_mask;
if (!is_xkb_available (xdisplay))
@ -333,7 +333,7 @@ meta_seat_x11_a11y_init (ClutterSeat *seat)
XkbSelectEvents (xdisplay, XkbUseCoreKbd, event_mask, event_mask);
clutter_x11_add_filter (xkb_a11y_event_filter, seat);
meta_clutter_x11_add_filter (xkb_a11y_event_filter, seat);
return TRUE;
}

View File

@ -26,12 +26,12 @@
#include <glib-object.h>
#include "clutter/x11/clutter-x11.h"
#include "backends/meta-backend-private.h"
#include "backends/meta-logical-monitor.h"
#include "backends/meta-output.h"
#include "backends/meta-renderer.h"
#include "backends/meta-renderer-view.h"
#include "backends/x11/meta-clutter-backend-x11.h"
#include "core/boxes-private.h"
#include "meta/meta-backend.h"
#include "meta/util.h"

View File

@ -26,8 +26,8 @@
#include <X11/extensions/Xcomposite.h>
#include "backends/x11/meta-backend-x11.h"
#include "backends/x11/meta-clutter-backend-x11.h"
#include "backends/x11/meta-event-x11.h"
#include "clutter/x11/clutter-x11.h"
#include "compositor/meta-sync-ring.h"
#include "compositor/meta-window-actor-x11.h"
#include "core/display-private.h"

View File

@ -21,12 +21,12 @@
#include <gdk/gdkx.h>
#include "clutter/x11/clutter-x11.h"
#include "meta/meta-backend.h"
#include "compositor/compositor-private.h"
#include "core/display-private.h"
#include "backends/meta-dnd-private.h"
#include "backends/x11/meta-backend-x11.h"
#include "backends/x11/meta-clutter-backend-x11.h"
#include "backends/x11/meta-stage-x11.h"
#include "meta/meta-dnd.h"
#include "x11/meta-x11-display-private.h"

View File

@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include "clutter/x11/clutter-x11.h"
#include "backends/x11/meta-clutter-backend-x11.h"
#include "compositor/compositor-private.h"
#include "compositor/meta-module.h"
#include "core/meta-close-dialog-default-private.h"

View File

@ -36,7 +36,7 @@
#include <X11/extensions/shape.h>
#include "backends/meta-monitor-manager-private.h"
#include "clutter/x11/clutter-x11.h"
#include "backends/x11/meta-clutter-backend-x11.h"
#include "compositor/compositor-private.h"
#include "compositor/meta-window-actor-private.h"
#include "compositor/meta-plugin-manager.h"

View File

@ -47,10 +47,10 @@
#include "backends/meta-input-mapper-private.h"
#include "backends/meta-stage-private.h"
#include "backends/x11/meta-backend-x11.h"
#include "backends/x11/meta-clutter-backend-x11.h"
#include "backends/x11/meta-event-x11.h"
#include "backends/x11/cm/meta-backend-x11-cm.h"
#include "backends/x11/nested/meta-backend-x11-nested.h"
#include "clutter/x11/clutter-x11.h"
#include "compositor/compositor-private.h"
#include "compositor/meta-compositor-x11.h"
#include "cogl/cogl.h"

View File

@ -2,10 +2,6 @@
#include <gmodule.h>
#include <clutter/clutter.h>
#ifdef CLUTTER_WINDOWING_X11
#include <clutter/x11/clutter-x11.h>
#endif
#include "test-utils.h"
#include "tests/clutter-test-utils.h"

View File

@ -18,6 +18,8 @@
#include "config.h"
#include <X11/Xatom.h>
#include "core/frame.h"
#include "meta/meta-x11-errors.h"
#include "x11/window-x11.h"

View File

@ -18,6 +18,8 @@
#include "config.h"
#include <X11/Xatom.h>
#include "core/frame.h"
#include "core/stack.h"
#include "core/window-private.h"