Api to set specific input region on stage from plugins.

This commit is contained in:
Tomas Frydrych 2008-10-16 12:16:08 +01:00
parent 749698eb54
commit d185a84140
4 changed files with 60 additions and 14 deletions

View File

@ -97,7 +97,6 @@ MetaCompositorClutterPlugin META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT =
.maximize = maximize, .maximize = maximize,
.unmaximize = unmaximize, .unmaximize = unmaximize,
.switch_workspace = switch_workspace, .switch_workspace = switch_workspace,
.xevent_filter = xevent_filter,
.kill_effect = kill_effect, .kill_effect = kill_effect,
/* The reload handler */ /* The reload handler */
@ -614,7 +613,11 @@ on_panel_effect_complete (ClutterActor *panel, gpointer data)
gboolean reactive = GPOINTER_TO_INT (data); gboolean reactive = GPOINTER_TO_INT (data);
MetaCompositorClutterPlugin *plugin = get_plugin (); MetaCompositorClutterPlugin *plugin = get_plugin ();
meta_comp_clutter_plugin_set_stage_reactive (plugin, reactive); if (reactive)
meta_comp_clutter_plugin_set_stage_reactive (plugin, reactive);
else
meta_comp_clutter_plugin_set_stage_input_area (plugin, 0, 0,
plugin->screen_width, 1);
} }
static gboolean static gboolean
@ -626,14 +629,17 @@ xevent_filter (XEvent *xev)
if (xev->type != MotionNotify) if (xev->type != MotionNotify)
return FALSE; return FALSE;
printf ("got xevent type %d\n", xev->type); printf ("got xevent type %d on 0x%x @ y %d\n",
xev->type,
(gint) xev->xmotion.window,
xev->xmotion.y_root);
if (priv->panel_out) if (priv->panel_out)
{ {
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 > (gint)height) if (xev->xmotion.y_root > (gint)height)
{ {
clutter_effect_move (priv->panel_slide_effect, clutter_effect_move (priv->panel_slide_effect,
priv->panel, x, -height, priv->panel, x, -height,
@ -641,9 +647,11 @@ xevent_filter (XEvent *xev)
GINT_TO_POINTER (FALSE)); GINT_TO_POINTER (FALSE));
} }
priv->panel_out = FALSE;
return TRUE; return TRUE;
} }
else if (xev->xmotion.y < PANEL_SLIDE_THRESHOLD) else if (xev->xmotion.y_root < PANEL_SLIDE_THRESHOLD)
{ {
gint x = clutter_actor_get_x (priv->panel); gint x = clutter_actor_get_x (priv->panel);
@ -652,6 +660,8 @@ xevent_filter (XEvent *xev)
on_panel_effect_complete, on_panel_effect_complete,
GINT_TO_POINTER (TRUE )); GINT_TO_POINTER (TRUE ));
priv->panel_out = TRUE;
return TRUE; return TRUE;
} }
@ -736,12 +746,16 @@ g_module_check_init (GModule *module)
static gboolean static gboolean
stage_input_cb (ClutterActor *stage, ClutterEvent *event, gpointer data) stage_input_cb (ClutterActor *stage, ClutterEvent *event, gpointer data)
{ {
printf ("Got event, type %d\n", event->type);
if (event->type == CLUTTER_MOTION) if (event->type == CLUTTER_MOTION)
{ {
ClutterMotionEvent *mev = (ClutterMotionEvent *) event; ClutterMotionEvent *mev = (ClutterMotionEvent *) event;
MetaCompositorClutterPlugin *plugin = get_plugin (); MetaCompositorClutterPlugin *plugin = get_plugin ();
PluginPrivate *priv = plugin->plugin_private; PluginPrivate *priv = plugin->plugin_private;
printf ("got stage motion event at y %d\n", mev->y);
if (priv->panel_out) if (priv->panel_out)
{ {
guint height = clutter_actor_get_height (priv->panel); guint height = clutter_actor_get_height (priv->panel);
@ -755,6 +769,8 @@ stage_input_cb (ClutterActor *stage, ClutterEvent *event, gpointer data)
GINT_TO_POINTER (FALSE)); GINT_TO_POINTER (FALSE));
} }
priv->panel_out = FALSE;
return TRUE; return TRUE;
} }
else if (mev->y < PANEL_SLIDE_THRESHOLD) else if (mev->y < PANEL_SLIDE_THRESHOLD)
@ -766,6 +782,8 @@ stage_input_cb (ClutterActor *stage, ClutterEvent *event, gpointer data)
on_panel_effect_complete, on_panel_effect_complete,
GINT_TO_POINTER (TRUE )); GINT_TO_POINTER (TRUE ));
priv->panel_out = TRUE;
return TRUE; return TRUE;
} }
@ -900,7 +918,15 @@ do_init ()
-clutter_actor_get_height (background)); -clutter_actor_get_height (background));
g_signal_connect (meta_comp_clutter_plugin_get_stage (plugin), g_signal_connect (meta_comp_clutter_plugin_get_stage (plugin),
"key-release-event", G_CALLBACK (stage_input_cb), NULL); "motion-event", G_CALLBACK (stage_input_cb), NULL);
g_signal_connect (meta_comp_clutter_plugin_get_stage (plugin),
"button-press-event", G_CALLBACK (stage_input_cb), NULL);
meta_comp_clutter_plugin_set_stage_input_area (plugin, 0, 0,
plugin->screen_width, 60);
clutter_set_motion_events_enabled (TRUE);
return TRUE; return TRUE;
} }

View File

@ -743,3 +743,26 @@ meta_comp_clutter_plugin_set_stage_reactive (MetaCompositorClutterPlugin *plugin
} }
} }
void
meta_comp_clutter_plugin_set_stage_input_area (MetaCompositorClutterPlugin *plugin,
gint x, gint y, gint width, gint height)
{
MetaCompositorClutterPluginPrivate *priv = plugin->manager_private;
MetaCompositorClutterPluginManager *mgr = priv->self;
MetaDisplay *display = meta_screen_get_display (mgr->screen);
Display *xdpy = meta_display_get_xdisplay (display);
Window overlay;
XRectangle rect;
XserverRegion region;
overlay = meta_compositor_clutter_get_overlay_window (mgr->screen);
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
region = XFixesCreateRegion (xdpy, &rect, 1);
XFixesSetWindowShapeRegion (xdpy, overlay, ShapeInput, 0, 0, region);
}

View File

@ -1668,14 +1668,7 @@ get_output_window (MetaScreen *screen)
xroot = meta_screen_get_xroot (screen); xroot = meta_screen_get_xroot (screen);
output = XCompositeGetOverlayWindow (xdisplay, xroot); output = XCompositeGetOverlayWindow (xdisplay, xroot);
XSelectInput (xdisplay, output, XSelectInput (xdisplay, output, ExposureMask);
FocusChangeMask |
ExposureMask |
PointerMotionMask |
KeyPressMask |
KeyReleaseMask |
ButtonPressMask |
ButtonReleaseMask);
return output; return output;
} }

View File

@ -248,4 +248,8 @@ void
meta_comp_clutter_plugin_set_stage_reactive (MetaCompositorClutterPlugin *plugin, meta_comp_clutter_plugin_set_stage_reactive (MetaCompositorClutterPlugin *plugin,
gboolean reactive); gboolean reactive);
void
meta_comp_clutter_plugin_set_stage_input_area (MetaCompositorClutterPlugin *plugin,
gint x, gint y, gint width, gint height);
#endif #endif