2008-02-20 Tomas Frydrych <tf@openedhand.com>

* clutter/x11/clutter-x11.h:
	* clutter/x11/clutter-backend-x11.c:
	(clutter_x11_set_display):
	Function to set X display connection prior to calling
	clutter_init(); stripped loads of trailing space.
This commit is contained in:
Tomas Frydrych 2008-02-20 14:16:54 +00:00
parent 0864743fd1
commit 9aba9710c1
4 changed files with 123 additions and 68 deletions

View File

@ -1,4 +1,12 @@
2008-02-20 Emmanuele Bassi <ebassi@openedhand.com>
2008-02-20 Tomas Frydrych <tf@openedhand.com>
* clutter/x11/clutter-x11.h:
* clutter/x11/clutter-backend-x11.c:
(clutter_x11_set_display):
Function to set X display connection prior to calling
clutter_init(); stripped loads of trailing space.
2008-02-20 Tomas Frydrych <tf@openedhand.com>
* clutter/clutter-marshal.list:
* clutter/glx/Makefile.am:

View File

@ -115,9 +115,9 @@ clutter_redraw (void)
{
ClutterMainContext *ctx;
ClutterActor *stage;
static GTimer *timer = NULL;
static GTimer *timer = NULL;
static guint timer_n_frames = 0;
ctx = clutter_context_get_default ();
stage = _clutter_backend_get_stage (ctx->backend);
@ -152,7 +152,7 @@ clutter_redraw (void)
CLUTTER_UNSET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_SYNC_MATRICES);
}
/* Call through to the actual backend to do the painting down from
/* Call through to the actual backend to do the painting down from
* the stage. It will likely need to swap buffers, vblank sync etc
* which will be windowing system dependant.
*/
@ -239,7 +239,7 @@ _clutter_do_pick (ClutterStage *stage,
/* Disable dithering (if any) when doing the painting in pick mode */
glDisable (GL_DITHER);
/* Render the entire scence in pick mode - just single colored silhouette's
/* Render the entire scence in pick mode - just single colored silhouette's
* are drawn offscreen (as we never swap buffers)
*/
context->pick_mode = mode;
@ -249,11 +249,11 @@ _clutter_do_pick (ClutterStage *stage,
/* Calls should work under both GL and GLES, note GLES needs RGBA */
glGetIntegerv(GL_VIEWPORT, viewport);
/* Below to be safe, particularly on GL ES. an EGL wait call or full
* could be nicer.
/* Below to be safe, particularly on GL ES. an EGL wait call or full
* could be nicer.
*/
glFinish();
/* glEnable (GL_DITHER); we never enabled this originally, so its
glFinish();
/* glEnable (GL_DITHER); we never enabled this originally, so its
probably not safe to then enable it */
glReadPixels(x, viewport[3] - y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
@ -480,7 +480,7 @@ clutter_threads_dispatch_free (gpointer data)
* removed from the list of event sources and will not be called again.
*
* This variant of g_idle_add_full() calls @function with the Clutter lock
* held. It can be thought of a MT-safe version for Clutter actors for the
* held. It can be thought of a MT-safe version for Clutter actors for the
* following use case, where you have to worry about idle_callback()
* running in thread A and accessing @self after it has been finalized
* in thread B:
@ -572,8 +572,8 @@ clutter_threads_add_idle (GSourceFunc func,
* @notify: function to call when the timeout source is removed
*
* Sets a function to be called at regular intervals holding the Clutter lock,
* with the given priority. The function is called repeatedly until it
* returns %FALSE, at which point the timeout is automatically destroyed
* with the given priority. The function is called repeatedly until it
* returns %FALSE, at which point the timeout is automatically destroyed
* and the function will not be called again. The @notify function is
* called when the timeout is destroyed. The first call to the
* function will be at the end of the first @interval.
@ -584,7 +584,7 @@ clutter_threads_add_idle (GSourceFunc func,
* timeout is recalculated based on the current time and the given interval
* (it does not try to 'catch up' time lost in delays).
*
* This variant of g_timeout_add_full() can be thought of a MT-safe version
* This variant of g_timeout_add_full() can be thought of a MT-safe version
* for Clutter actors. See also clutter_threads_add_idle_full().
*
* Return value: the ID (greater than 0) of the event source.
@ -669,7 +669,7 @@ clutter_threads_leave (void)
/**
* clutter_get_debug_enabled:
*
*
* Check if clutter has debugging turned on.
*
* Return value: TRUE if debugging is turned on, FALSE otherwise.
@ -872,7 +872,7 @@ post_parse_hook (GOptionContext *context,
retval = TRUE;
clutter_is_initialized = retval;
return retval;
}
@ -902,10 +902,10 @@ clutter_get_option_group (void)
"Show Clutter Options",
NULL,
NULL);
g_option_group_set_parse_hooks (group, pre_parse_hook, post_parse_hook);
g_option_group_add_entries (group, clutter_args);
/* add backend-specific options */
_clutter_backend_add_options (context->backend, group);
@ -964,7 +964,7 @@ clutter_init_with_args (int *argc,
return CLUTTER_INIT_SUCCESS;
clutter_base_init ();
if (argc && *argc > 0 && *argv)
g_set_prgname ((*argv)[0]);
@ -1018,7 +1018,7 @@ clutter_parse_args (int *argc,
option_context = g_option_context_new (NULL);
g_option_context_set_ignore_unknown_options (option_context, TRUE);
g_option_context_set_help_enabled (option_context, FALSE);
g_option_context_set_help_enabled (option_context, FALSE);
/* Initiate any command line options from the backend */
@ -1060,7 +1060,7 @@ clutter_init (int *argc,
return CLUTTER_INIT_SUCCESS;
clutter_base_init ();
if (argc && *argc > 0 && *argv)
g_set_prgname ((*argv)[0]);
@ -1075,7 +1075,7 @@ clutter_init (int *argc,
}
/* Note, creates backend if not already existing (though parse args will
* have likely created it)
* have likely created it)
*/
context = clutter_context_get_default ();
@ -1095,7 +1095,7 @@ clutter_init (int *argc,
/* finally features - will call to backend and cogl */
_clutter_feature_init ();
clutter_stage_set_title (CLUTTER_STAGE(clutter_stage_get_default()),
clutter_stage_set_title (CLUTTER_STAGE(clutter_stage_get_default()),
g_get_prgname());
return CLUTTER_INIT_SUCCESS;
@ -1109,7 +1109,7 @@ _clutter_boolean_handled_accumulator (GSignalInvocationHint *ihint,
{
gboolean continue_emission;
gboolean signal_handled;
signal_handled = g_value_get_boolean (handler_return);
g_value_set_boolean (return_accu, signal_handled);
continue_emission = !signal_handled;
@ -1143,7 +1143,7 @@ event_click_count_generate (ClutterEvent *event)
* existing click count
*/
if (event->button.time < previous_time + double_click_time &&
(ABS (event->button.x - previous_x) <= double_click_distance) &&
(ABS (event->button.x - previous_x) <= double_click_distance) &&
(ABS (event->button.y - previous_y) <= double_click_distance)
&& event->button.button == previous_button_number)
{
@ -1154,7 +1154,7 @@ event_click_count_generate (ClutterEvent *event)
click_count=1;
previous_button_number = event->button.button;
}
/* store time and position for this click for comparison with next event */
previous_time = event->button.time;
previous_x = event->button.x;
@ -1170,7 +1170,7 @@ event_click_count_generate (ClutterEvent *event)
}
static inline void
static inline void
emit_event (ClutterEvent *event,
gboolean is_key_event)
{
@ -1197,7 +1197,7 @@ emit_event (ClutterEvent *event,
while (actor && n_tree_events < MAX_EVENT_DEPTH)
{
ClutterActor *parent;
parent = clutter_actor_get_parent (actor);
if (clutter_actor_get_reactive (actor) ||
@ -1230,7 +1230,7 @@ done:
#undef MAX_EVENT_DEPTH
}
static inline void
static inline void
emit_pointer_event (ClutterEvent *event)
{
/* Using the global variable directly, since it has to be initialized
@ -1245,7 +1245,7 @@ emit_pointer_event (ClutterEvent *event)
emit_event (event, FALSE);
}
static inline void
static inline void
emit_keyboard_event (ClutterEvent *event)
{
ClutterMainContext *context = ClutterCntx;
@ -1280,20 +1280,20 @@ generate_enter_leave_events (ClutterEvent *event)
{
cev.crossing.type = CLUTTER_LEAVE;
cev.crossing.time = event->any.time;
cev.crossing.flags = 0;
cev.crossing.flags = 0;
cev.crossing.x = event->motion.x;
cev.crossing.y = event->motion.y;
cev.crossing.source = context->motion_last_actor;
/* unref in free */
cev.crossing.related = motion_current_actor;
g_queue_push_head (context->events_queue,
g_queue_push_head (context->events_queue,
clutter_event_copy (&cev));
}
cev.crossing.type = CLUTTER_ENTER;
cev.crossing.time = event->any.time;
cev.crossing.flags = 0;
cev.crossing.flags = 0;
cev.crossing.x = event->motion.x;
cev.crossing.y = event->motion.y;
cev.crossing.source = motion_current_actor;
@ -1308,7 +1308,7 @@ generate_enter_leave_events (ClutterEvent *event)
cev.crossing.related = NULL;
}
g_queue_push_head (context->events_queue,
g_queue_push_head (context->events_queue,
clutter_event_copy (&cev));
}
}
@ -1332,7 +1332,7 @@ generate_enter_leave_events (ClutterEvent *event)
context->motion_last_actor = motion_current_actor;
}
/**
/**
* clutter_do_event
* @event: a #ClutterEvent.
*
@ -1343,9 +1343,9 @@ generate_enter_leave_events (ClutterEvent *event)
void
clutter_do_event (ClutterEvent *event)
{
/* FIXME: This should probably be clutter_cook_event() - it would
* take a raw event from the backend and 'cook' it so its more tasty.
*
/* FIXME: This should probably be clutter_cook_event() - it would
* take a raw event from the backend and 'cook' it so its more tasty.
*
*/
ClutterMainContext *context;
ClutterBackend *backend;
@ -1481,15 +1481,15 @@ clutter_do_event (ClutterEvent *event)
}
/* Map the event to a reactive actor */
actor = _clutter_do_pick (CLUTTER_STAGE (stage),
x, y,
actor = _clutter_do_pick (CLUTTER_STAGE (stage),
x, y,
CLUTTER_PICK_REACTIVE);
event->any.source = actor;
if (!actor)
break;
}
else
else
{
/* use the source already set in the synthetic event */
actor = event->any.source;
@ -1501,7 +1501,7 @@ clutter_do_event (ClutterEvent *event)
* (signalling just the stage). Should be big help for gles.
*/
CLUTTER_NOTE (EVENT, "Reactive event received at %i, %i - actor: %p",
CLUTTER_NOTE (EVENT, "Reactive event received at %i, %i - actor: %p",
x, y, actor);
if (event->type == CLUTTER_MOTION)
@ -1529,7 +1529,7 @@ clutter_do_event (ClutterEvent *event)
}
}
/**
/**
* clutter_get_actor_by_gid
* @id: a #ClutterActor ID.
*
@ -1591,7 +1591,7 @@ clutter_get_default_frame_rate (void)
ClutterMainContext *context;
context = clutter_context_get_default ();
return context->frame_rate;
}
@ -1645,7 +1645,7 @@ clutter_grab_pointer (ClutterActor *actor)
ClutterMainContext *context;
g_return_if_fail (actor == NULL || CLUTTER_IS_ACTOR (actor));
context = clutter_context_get_default ();
if (context->pointer_grab_actor == actor)
@ -1730,7 +1730,7 @@ clutter_grab_keyboard (ClutterActor *actor)
ClutterMainContext *context;
g_return_if_fail (actor == NULL || CLUTTER_IS_ACTOR (actor));
context = clutter_context_get_default ();
if (context->keyboard_grab_actor == actor)
@ -1787,7 +1787,7 @@ clutter_get_keyboard_grab (void)
/**
* clutter_get_motion_events_frequency:
*
*
* Retrieves the number of motion events per second that are delivered
* to the stage.
*
@ -1805,7 +1805,7 @@ clutter_get_motion_events_frequency (void)
if (G_LIKELY (context->motion_frequency == 0))
{
guint frequency;
frequency = clutter_default_fps / 4;
frequency = CLAMP (frequency, 20, 45);

View File

@ -103,19 +103,27 @@ clutter_backend_x11_post_parse (ClutterBackend *backend,
{
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
if (clutter_display_name)
/*
* Only open connection if not already set by prior call to
* clutter_x11_set_display()
*/
if (!backend_x11->xdpy)
{
CLUTTER_NOTE (BACKEND, "XOpenDisplay on `%s'", clutter_display_name);
backend_x11->xdpy = XOpenDisplay (clutter_display_name);
}
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;
if (clutter_display_name)
{
CLUTTER_NOTE (BACKEND, "XOpenDisplay on `%s'",
clutter_display_name);
backend_x11->xdpy = XOpenDisplay (clutter_display_name);
}
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;
}
}
if (backend_x11->xdpy)
@ -130,12 +138,12 @@ clutter_backend_x11_post_parse (ClutterBackend *backend,
else
backend_x11->xscreen = ScreenOfDisplay (backend_x11->xdpy,
clutter_screen);
backend_x11->xscreen_num = XScreenNumberOfScreen (backend_x11->xscreen);
backend_x11->xwin_root = RootWindow (backend_x11->xdpy,
backend_x11->xscreen_num);
backend_x11->display_name = g_strdup (clutter_display_name);
dpi = (((double) DisplayHeight (backend_x11->xdpy, backend_x11->xscreen_num) * 25.4)
@ -163,7 +171,7 @@ clutter_backend_x11_post_parse (ClutterBackend *backend,
}
g_free (clutter_display_name);
CLUTTER_NOTE (BACKEND,
"X Display `%s'[%p] opened (screen:%d, root:%u, dpi:%f)",
backend_x11->display_name,
@ -244,7 +252,7 @@ clutter_backend_x11_dispose (GObject *gobject)
if (backend_x11->stage)
{
CLUTTER_NOTE (BACKEND, "Disposing the main stage");
/* we unset the private flag on the stage so we can safely
* destroy it without a warning from clutter_actor_destroy()
*/
@ -253,7 +261,7 @@ clutter_backend_x11_dispose (GObject *gobject)
clutter_actor_destroy (backend_x11->stage);
backend_x11->stage = NULL;
}
CLUTTER_NOTE (BACKEND, "Removing the event source");
_clutter_backend_x11_events_uninit (CLUTTER_BACKEND (backend_x11));
@ -280,7 +288,7 @@ clutter_backend_x11_constructor (GType gtype,
g_warning ("Attempting to create a new backend object. This should "
"never happen, so we return the singleton instance.");
return g_object_ref (backend_singleton);
}
@ -366,7 +374,7 @@ clutter_x11_untrap_x_errors (void)
/**
* clutter_x11_get_default_display:
*
*
* Retrieves the pointer to the default display.
*
* Return value: the default display
@ -385,9 +393,47 @@ clutter_x11_get_default_display (void)
return backend_singleton->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().
*
* Since: 0.8
*/
void
clutter_x11_set_display (Display *xdpy)
{
if (!xdpy)
return;
if (!backend_singleton)
{
/*
* This creates the singleton objects
*/
clutter_context_get_default ();
if (!backend_singleton)
{
g_critical ("X11 backend could not be initialised.");
return;
}
}
if (backend_singleton->xdpy)
{
g_critical ("Display connection already exists. You can only call "
"clutter_x11_set_display() once before clutter_init()\n");
return;
}
backend_singleton->xdpy = xdpy;
}
/**
* clutter_x11_get_default_screen:
*
*
* Gets the number of the default X Screen object.
*
* Return value: the number of the default screen
@ -408,7 +454,7 @@ clutter_x11_get_default_screen (void)
/**
* clutter_x11_get_root_window:
*
*
* Retrieves the root window.
*
* Return value: the id of the root window

View File

@ -85,6 +85,7 @@ gint clutter_x11_untrap_x_errors (void);
Display *clutter_x11_get_default_display (void);
int clutter_x11_get_default_screen (void);
Window clutter_x11_get_root_window (void);
void clutter_x11_set_display (Display * xdpy);
Window clutter_x11_get_stage_window (ClutterStage *stage);
XVisualInfo *clutter_x11_get_stage_visual (ClutterStage *stage);