Process motion events on stage to handle panle closing.

This commit is contained in:
Tomas Frydrych 2008-10-16 00:06:20 +01:00
parent f0364b2eed
commit 8d373e009d

View File

@ -623,22 +623,22 @@ xevent_filter (XEvent *xev)
guint height = clutter_actor_get_height (priv->panel); guint height = clutter_actor_get_height (priv->panel);
gint x = clutter_actor_get_x (priv->panel); gint x = clutter_actor_get_x (priv->panel);
if (xev->xmotion.y_root > (gint)height) if (xev->xmotion.y > (gint)height)
{ {
/* TODO -- slide back in, reset input on stage window */ /* TODO -- slide back in, reset input on stage window */
clutter_effect_scale (priv->panel_slide_effect, clutter_effect_move (priv->panel_slide_effect,
priv->panel, x, -height, priv->panel, x, -height,
NULL, NULL); NULL, NULL);
} }
return TRUE; return TRUE;
} }
else if (xev->xmotion.y_root < PANEL_SLIDE_THRESHOLD) else if (xev->xmotion.y < PANEL_SLIDE_THRESHOLD)
{ {
gint x = clutter_actor_get_x (priv->panel); gint x = clutter_actor_get_x (priv->panel);
/* TODO -- reset input on stage window */ /* TODO -- reset input on stage window */
clutter_effect_scale (priv->panel_slide_effect, clutter_effect_move (priv->panel_slide_effect,
priv->panel, x, 0, priv->panel, x, 0,
NULL, NULL); NULL, NULL);
@ -723,6 +723,48 @@ g_module_check_init (GModule *module)
} }
#endif #endif
static gboolean
stage_input_cb (ClutterActor *stage, ClutterEvent *event, gpointer data)
{
if (event->type == CLUTTER_MOTION)
{
ClutterMotionEvent *mev = (ClutterMotionEvent *) event;
MetaCompositorClutterPlugin *plugin = get_plugin ();
PluginPrivate *priv = plugin->plugin_private;
if (priv->panel_out)
{
guint height = clutter_actor_get_height (priv->panel);
gint x = clutter_actor_get_x (priv->panel);
if (mev->y > (gint)height)
{
/* TODO -- slide back in, reset input on stage window */
clutter_effect_move (priv->panel_slide_effect,
priv->panel, x, -height,
NULL, NULL);
}
return TRUE;
}
else if (mev->y < PANEL_SLIDE_THRESHOLD)
{
gint x = clutter_actor_get_x (priv->panel);
/* TODO -- reset input on stage window */
clutter_effect_move (priv->panel_slide_effect,
priv->panel, x, 0,
NULL, NULL);
return TRUE;
}
return FALSE;
}
return FALSE;
}
/* /*
* Core of the plugin init function, called for initial initialization and * Core of the plugin init function, called for initial initialization and
* by the reload() function. Returns TRUE on success. * by the reload() function. Returns TRUE on success.
@ -847,6 +889,9 @@ do_init ()
clutter_actor_set_position (background, 0, clutter_actor_set_position (background, 0,
-clutter_actor_get_height (background)); -clutter_actor_get_height (background));
g_signal_connect (meta_comp_clutter_plugin_get_stage (plugin),
"key-release-event", G_CALLBACK (stage_input_cb), NULL);
return TRUE; return TRUE;
} }