コード例 #1
0
ファイル: st-icon.c プロジェクト: 2gud4u/Cinnamon
static gboolean
st_icon_update_icon_size (StIcon *icon)
{
  StIconPrivate *priv = icon->priv;
  int new_size;

  if (priv->prop_icon_size > 0)
    new_size = priv->prop_icon_size;
  else if (priv->theme_icon_size > 0)
    {
      gint scale;
      ClutterActor *stage;
      StThemeContext *context;

      /* The theme will give us an already-scaled size, so we
       * undo it here, as priv->icon_size is in unscaled pixels.
       */
      stage = clutter_actor_get_stage (CLUTTER_ACTOR (icon));
      context = st_theme_context_get_for_stage (CLUTTER_STAGE (stage));
      g_object_get (context, "scale-factor", &scale, NULL);
      new_size = (gint) (priv->theme_icon_size / scale);
    }
  else
    new_size = DEFAULT_ICON_SIZE;

  if (new_size != priv->icon_size)
    {
      clutter_actor_queue_relayout (CLUTTER_ACTOR (icon));
      priv->icon_size = new_size;
      return TRUE;
    }
  else
    return FALSE;
}
コード例 #2
0
ファイル: main.c プロジェクト: aalex/jasm
void on_texture_size_change (ClutterTexture *texture,
    gint width,
    gint height,
    gpointer user_data)
{
  ClutterActor *stage;
  gfloat new_x, new_y, new_width, new_height;
  gfloat stage_width, stage_height;
  stage = clutter_actor_get_stage (CLUTTER_ACTOR (texture));
  if (stage == NULL)
    return;
  clutter_actor_get_size (stage, &stage_width, &stage_height);
  new_height = (height * stage_width) / width;
  if (new_height <= stage_height)
    {
      new_width = stage_width;
      new_x = 0;
      new_y = (stage_height - new_height) / 2;
    }
  else
    {
      new_width  = (width * stage_height) / height;
      new_height = stage_height;
      new_x = (stage_width - new_width) / 2;
      new_y = 0;
    }
  clutter_actor_set_position (CLUTTER_ACTOR (texture), new_x, new_y);
  clutter_actor_set_size (CLUTTER_ACTOR (texture), new_width, new_height);
}
コード例 #3
0
ファイル: st-scroll-bar.c プロジェクト: Jem777/Cinnamon
static gboolean
handle_button_press_event_cb (ClutterActor       *actor,
                              ClutterButtonEvent *event,
                              StScrollBar        *bar)
{
  StScrollBarPrivate *priv = bar->priv;

  if (event->button != 1)
    return FALSE;

  if (!clutter_actor_transform_stage_point (priv->handle,
                                            event->x,
                                            event->y,
                                            &priv->x_origin,
                                            &priv->y_origin))
    return FALSE;

  /* Account for the scrollbar-trough-handle nesting. */
  priv->x_origin += clutter_actor_get_x (priv->trough);
  priv->y_origin += clutter_actor_get_y (priv->trough);

  /* Turn off picking for motion events */
  clutter_set_motion_events_enabled (FALSE);

  priv->capture_handler = g_signal_connect_after (
    clutter_actor_get_stage (priv->trough),
    "captured-event",
    G_CALLBACK (handle_capture_event_cb),
    bar);
  g_signal_emit (bar, signals[SCROLL_START], 0);

  return TRUE;
}
コード例 #4
0
ファイル: mx-slider.c プロジェクト: 3v1n0/mx
static gboolean
on_trough_bg_button_press_event (ClutterActor       *actor,
                                 ClutterButtonEvent *event,
                                 MxSlider           *self)
{
  MxSliderPrivate *priv = self->priv;
  ClutterActor *stage;

  if (event->button != 1)
    return FALSE;

  if (mx_widget_get_disabled (MX_WIDGET (actor)))
    return FALSE;


  move_handle (self, event->x, event->y);

  stage = clutter_actor_get_stage (priv->handle);

  /* Turn off picking for motion events */
  clutter_stage_set_motion_events_enabled (CLUTTER_STAGE (stage), FALSE);

  priv->capture_handler =
    g_signal_connect_after (stage,
                            "captured-event",
                            G_CALLBACK (on_handle_capture_event),
                            self);

  return TRUE;
}
コード例 #5
0
static void
mnp_clock_tile_drag_begin (MxDraggable *draggable, gfloat event_x, gfloat event_y, gint event_button, ClutterModifierType  modifiers)
{
	ClutterActor *self = CLUTTER_ACTOR (draggable);
	ClutterActor *stage = clutter_actor_get_stage (self);
	gfloat orig_x, orig_y;
	MnpClockTile *tile = (MnpClockTile *)draggable;
	gfloat width, height;
	MnpClockTilePriv *priv = tile->priv;
	clutter_actor_get_size (self, &width, &height);
	
	g_object_ref (self);

	if (priv->clone)
		clutter_actor_destroy (priv->clone);
	
	priv->clone = clutter_clone_new (self);

	tile->priv->depth = clutter_actor_get_depth (self);
	clutter_actor_get_transformed_position (self, &orig_x, &orig_y);
	//clutter_actor_reparent (self, stage);
	//clutter_actor_set_size (self, width, -1);
	//clutter_actor_raise_top (self);
	//clutter_actor_set_position (self, orig_x, orig_y);
	
	clutter_container_add_actor (CLUTTER_CONTAINER (stage), priv->clone);
	clutter_actor_set_position (priv->clone, orig_x, orig_y);
	clutter_actor_set_size (priv->clone, width, height);
	
	g_object_unref (self);

	clutter_actor_animate (self, CLUTTER_EASE_OUT_CUBIC, 250,
				"opacity", 0,
				NULL);
}
コード例 #6
0
ファイル: text-box.c プロジェクト: tydaikho/xfdashboard
/* Unset focus from actor */
static void _xfdashboard_text_box_focusable_unset_focus(XfdashboardFocusable *inFocusable)
{
	ClutterActor					*self;
	XfdashboardFocusableInterface	*selfIface;
	XfdashboardFocusableInterface	*parentIface;
	ClutterStage					*stage;

	g_return_if_fail(XFDASHBOARD_IS_FOCUSABLE(inFocusable));
	g_return_if_fail(XFDASHBOARD_IS_ACTOR(inFocusable));

	self=CLUTTER_ACTOR(inFocusable);

	/* Call parent class interface function */
	selfIface=XFDASHBOARD_FOCUSABLE_GET_IFACE(inFocusable);
	parentIface=g_type_interface_peek_parent(selfIface);

	if(parentIface && parentIface->unset_focus)
	{
		parentIface->unset_focus(inFocusable);
	}

	/* Get stage of actor to tell it where the keyboard focus to set to */
	stage=CLUTTER_STAGE(clutter_actor_get_stage(self));
	if(!stage)
	{
		g_warning(_("Focusable actor %s is not on a stage"),
					G_OBJECT_TYPE_NAME(self));
		return;
	}

	clutter_stage_set_key_focus(stage, NULL);
}
コード例 #7
0
/* Pointer left actor with tooltip */
static gboolean _xfdashboard_tooltip_action_on_leave_event(XfdashboardTooltipAction *self,
															ClutterEvent *inEvent,
															gpointer inUserData)
{
	XfdashboardTooltipActionPrivate		*priv;
	ClutterActor						*actor;
	ClutterActor						*stage;
	ClutterActor						*actorMeta;

	g_return_val_if_fail(XFDASHBOARD_IS_TOOLTIP_ACTION(self), CLUTTER_EVENT_PROPAGATE);
	g_return_val_if_fail(CLUTTER_IS_ACTOR(inUserData), CLUTTER_EVENT_PROPAGATE);

	priv=self->priv;
	actor=CLUTTER_ACTOR(inUserData);

	/* Get current actor this action belongs to */
	actorMeta=clutter_actor_meta_get_actor(CLUTTER_ACTOR_META(self));

	/* Release all sources and signal handler (except for enter event) */
	if(priv->motionSignalID!=0)
	{
		if(actorMeta) g_signal_handler_disconnect(actorMeta, priv->motionSignalID);
		priv->motionSignalID=0;
	}

	if(priv->leaveSignalID!=0)
	{
		if(actorMeta) g_signal_handler_disconnect(actorMeta, priv->leaveSignalID);
		priv->leaveSignalID=0;
	}

	if(priv->captureSignalID)
	{
		if(priv->captureSignalActor) g_signal_handler_disconnect(priv->captureSignalActor, priv->captureSignalID);
		priv->captureSignalActor=NULL;
		priv->captureSignalID=0;
	}

	if(priv->timeoutSourceID!=0)
	{
		g_source_remove(priv->timeoutSourceID);
		priv->timeoutSourceID=0;
	}

	/* Clear last actor we remembered if it is pointing to this actor */
	if(_xfdashboard_tooltip_last_event_actor==actor)
	{
		_xfdashboard_tooltip_last_event_actor=NULL;
	}

	/* Hide tooltip now */
	stage=clutter_actor_get_stage(actor);
	if(stage && XFDASHBOARD_IS_STAGE(stage))
	{
		g_signal_emit_by_name(stage, "hide-tooltip", self, NULL);
		priv->isVisible=FALSE;
	}

	return(CLUTTER_EVENT_PROPAGATE);
}
コード例 #8
0
static gboolean
actor_captured_event_cb (ClutterActor *actor,
                         ClutterEvent *event,
                         ClutterGestureAction *action)
{
  ClutterGestureActionPrivate *priv = action->priv;
  GesturePoint *point G_GNUC_UNUSED;

  if ((clutter_event_type (event) != CLUTTER_BUTTON_PRESS) &&
      (clutter_event_type (event) != CLUTTER_TOUCH_BEGIN))
    return CLUTTER_EVENT_PROPAGATE;

  if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (action)))
    return CLUTTER_EVENT_PROPAGATE;

  point = gesture_register_point (action, event);

  if (priv->stage == NULL)
    priv->stage = clutter_actor_get_stage (actor);

  if (priv->stage_capture_id == 0)
    priv->stage_capture_id =
      g_signal_connect_after (priv->stage, "captured-event",
                              G_CALLBACK (stage_captured_event_cb),
                              action);

  /* Start the gesture immediately if the gesture has no
   * _TRIGGER_EDGE_AFTER drag threshold. */
  if ((priv->points->len >= priv->requested_nb_points) &&
      (priv->edge != CLUTTER_GESTURE_TRIGGER_EDGE_AFTER))
    begin_gesture (action, actor);

  return CLUTTER_EVENT_PROPAGATE;
}
コード例 #9
0
ファイル: test-drag.c プロジェクト: nobled/clutter
static void
on_drag_begin (ClutterDragAction   *action,
               ClutterActor        *actor,
               gfloat               event_x,
               gfloat               event_y,
               ClutterModifierType  modifiers)
{
  gboolean is_copy = (modifiers & CLUTTER_SHIFT_MASK) ? TRUE : FALSE;
  ClutterActor *drag_handle = NULL;

  if (is_copy)
    {
      ClutterActor *stage = clutter_actor_get_stage (actor);

      drag_handle = clutter_rectangle_new ();
      clutter_actor_set_size (drag_handle, 48, 48);

      clutter_rectangle_set_color (CLUTTER_RECTANGLE (drag_handle),
                                   CLUTTER_COLOR_DarkSkyBlue);

      clutter_container_add_actor (CLUTTER_CONTAINER (stage), drag_handle);
      clutter_actor_set_position (drag_handle, event_x, event_y);
    }
  else
    drag_handle = actor;

  clutter_drag_action_set_drag_handle (action, drag_handle);

  /* fully desaturate the actor */
  clutter_actor_animate (actor, CLUTTER_LINEAR, 150,
                         "@effects.disable.factor", 1.0,
                         NULL);
}
コード例 #10
0
ファイル: fcitximcontext.c プロジェクト: fcitx/fcitx-clutter
void _fcitx_im_context_forward_key_cb(DBusGProxy* proxy, guint keyval, guint state, gint type, void* user_data)
{
    FcitxLog(LOG_LEVEL, "_fcitx_im_context_forward_key_cb");
    ClutterIMContext* context =  CLUTTER_IM_CONTEXT(user_data);
    const char* signal_name;
    gboolean consumed = FALSE;
    FcitxKeyEventType tp = (FcitxKeyEventType) type;
    ClutterKeyEvent clutter_key_event;
    clutter_key_event.flags = 0;
    clutter_key_event.source = NULL;
    clutter_key_event.keyval = keyval;
    clutter_key_event.hardware_keycode = 0;
    clutter_key_event.unicode_value = 0;
    clutter_key_event.modifier_state = state;
    clutter_key_event.device = NULL;
    
    struct timeval current_time;
    gettimeofday(&current_time, NULL);
    clutter_key_event.time = current_time.tv_sec * 1000 + current_time.tv_usec / 1000;
    
    if (tp == FCITX_PRESS_KEY) {
        clutter_key_event.type = CLUTTER_KEY_PRESS;
        signal_name = "key-press-event";
    }
    else {
        clutter_key_event.type = CLUTTER_KEY_RELEASE;
        clutter_key_event.modifier_state |= CLUTTER_RELEASE_MASK;
        signal_name = "key-release-event";
    }
    clutter_key_event.modifier_state |= FcitxKeyState_IgnoredMask;
    clutter_key_event.stage = CLUTTER_STAGE (clutter_actor_get_stage(context->actor));
    
    g_signal_emit_by_name(context->actor, signal_name, &clutter_key_event, &consumed);
    
}
コード例 #11
0
static void _xfdashboard_stage_interface_get_preferred_width(ClutterActor *inActor,
																gfloat inForHeight,
																gfloat *outMinWidth,
																gfloat *outNaturalWidth)
{
	XfdashboardStageInterface			*self=XFDASHBOARD_STAGE_INTERFACE(inActor);
	XfdashboardStageInterfacePrivate	*priv=self->priv;
	gfloat								minWidth, naturalWidth;
	gint								w;
	ClutterActor						 *stage;

	/* Set up default values */
	minWidth=naturalWidth=0.0f;

	/* Get monitor size if available otherwise get stage size */
	if(priv->monitor)
	{
		xfdashboard_window_tracker_monitor_get_geometry(priv->monitor, NULL, NULL, &w, NULL);
		minWidth=naturalWidth=w;
	}
		else
		{
			stage=clutter_actor_get_stage(inActor);
			minWidth=naturalWidth=clutter_actor_get_width(stage);
		}

	/* Store sizes computed */
	if(outMinWidth) *outMinWidth=minWidth;
	if(outNaturalWidth) *outNaturalWidth=naturalWidth;
}
コード例 #12
0
ファイル: mx-fade-effect.c プロジェクト: 3v1n0/mx
static void
mx_fade_effect_post_paint (ClutterEffect *effect)
{
  MxFadeEffectPrivate *priv = MX_FADE_EFFECT (effect)->priv;

  if (!priv->freeze_update)
    CLUTTER_EFFECT_CLASS (mx_fade_effect_parent_class)->post_paint (effect);
  else
    {
      CoglMatrix modelview;
      ClutterActor *actor, *stage;

      actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect));
      stage = clutter_actor_get_stage (actor);

      /* Set up the draw matrix so we draw the offscreen texture at the
       * absolute coordinates of the actor-box. We need to do this to
       * avoid transforming by the actor matrix twice, as when it's drawn
       * into the offscreen surface, it'll already be transformed.
       */
      cogl_push_matrix ();

      cogl_matrix_init_identity (&modelview);
      CLUTTER_ACTOR_CLASS (G_OBJECT_GET_CLASS (stage))->
        apply_transform (stage, &modelview);
      cogl_matrix_translate (&modelview, priv->x_offset, priv->y_offset, 0.f);
      cogl_set_modelview_matrix (&modelview);

      clutter_offscreen_effect_paint_target (CLUTTER_OFFSCREEN_EFFECT (effect));

      cogl_pop_matrix ();
    }
}
コード例 #13
0
ファイル: mx-droppable.c プロジェクト: 3v1n0/mx
static void
mx_droppable_real_enable (MxDroppable *droppable)
{
  ClutterActor *stage;
  DropContext *context;

  stage = clutter_actor_get_stage (CLUTTER_ACTOR (droppable));
  if (G_UNLIKELY (stage == NULL))
    {
      g_warning ("A MxDroppable must be on the stage before "
                 "being enabled.");
      return;
    }

  context = g_object_get_qdata (G_OBJECT (stage), quark_drop_context);
  if (context == NULL)
    {
      context = drop_context_create (stage, droppable);

      g_signal_connect_after (stage, "captured-event",
                              G_CALLBACK (on_stage_capture),
                              context);
    }
  else
    drop_context_update (context, droppable);
}
コード例 #14
0
/* Setup the video texture once its size is known */
void size_change (ClutterActor *texture, gint width, gint height, gpointer user_data) {
    ClutterActor *stage;
    gfloat new_x, new_y, new_width, new_height;
    gfloat stage_width, stage_height;
    ClutterAnimation *animation = NULL;

    stage = clutter_actor_get_stage (texture);
    if (stage == NULL)
        return;

    clutter_actor_get_size (stage, &stage_width, &stage_height);

    /* Center video on window and calculate new size preserving aspect ratio */
    new_height = (height * stage_width) / width;
    if (new_height <= stage_height) {
        new_width = stage_width;

        new_x = 0;
        new_y = (stage_height - new_height) / 2;
    } else {
        new_width  = (width * stage_height) / height;
        new_height = stage_height;

        new_x = (stage_width - new_width) / 2;
        new_y = 0;
    }
    clutter_actor_set_position (texture, new_x, new_y);
    clutter_actor_set_size (texture, new_width, new_height);
    clutter_actor_set_rotation (texture, CLUTTER_Y_AXIS, 0.0, stage_width / 2, 0, 0);
    /* Animate it */
    animation = clutter_actor_animate (texture, CLUTTER_LINEAR, 10000, "rotation-angle-y", 360.0, NULL);
    clutter_animation_set_loop (animation, TRUE);
}
コード例 #15
0
ファイル: mx-menu.c プロジェクト: jku/mx
static void
mx_menu_show (ClutterActor *actor)
{
  ClutterAnimation *animation = NULL;
  ClutterStage *stage;

  /* set reactive and opacity, since these may have been set by the fade-out
   * animation (e.g. from captured_event_handler or button_release_cb) */
  if ((animation = clutter_actor_get_animation (actor)))
    {
      clutter_animation_completed (animation);
    }
  clutter_actor_set_reactive (actor, TRUE);
  clutter_actor_set_opacity (actor, 0xff);

  /* chain up to run show after re-setting properties above */
  CLUTTER_ACTOR_CLASS (mx_menu_parent_class)->show (actor);

  clutter_actor_grab_key_focus (actor);

  stage = (ClutterStage*) clutter_actor_get_stage (actor);

  mx_focus_manager_push_focus (mx_focus_manager_get_for_stage (stage),
                               MX_FOCUSABLE (actor));

}
コード例 #16
0
ファイル: mx-menu.c プロジェクト: jonnylamb/mx
static void
mx_menu_map (ClutterActor *actor)
{
    gint i;
    MxMenuPrivate *priv = MX_MENU (actor)->priv;

    CLUTTER_ACTOR_CLASS (mx_menu_parent_class)->map (actor);

    clutter_actor_map (priv->up_button);
    clutter_actor_map (priv->down_button);
    for (i = 0; i < priv->children->len; i++)
    {
        MxMenuChild *child = &g_array_index (priv->children, MxMenuChild,
                                             i);
        clutter_actor_map (CLUTTER_ACTOR (child->box));
    }

    /* set up a capture so we can close the menu if the user clicks outside it */
    priv->stage = clutter_actor_get_stage (actor);
    g_object_weak_ref (G_OBJECT (priv->stage), (GWeakNotify) stage_weak_notify,
                       actor);

    priv->captured_event_handler =
        g_signal_connect (priv->stage,
                          "captured-event",
                          G_CALLBACK (mx_menu_captured_event_handler),
                          actor);
}
コード例 #17
0
static void
mpl_panel_background_get_preferred_height (ClutterActor *self,
                                           gfloat        for_width,
                                           gfloat       *min_height_p,
                                           gfloat       *natural_height_p)
{
  MplPanelBackgroundPrivate *priv = MPL_PANEL_BACKGROUND (self)->priv;
  ClutterActor              *stage = clutter_actor_get_stage (self);
  gfloat                     height = 0.0;

  /*
   * This is as good place to hook the ClutterStage::allocation callback as any.
   */
  if (!priv->stage_alloc_cb)
    {
      priv->stage = stage;

      priv->stage_alloc_cb =
        g_signal_connect (stage, "notify::allocation",
                          G_CALLBACK (mpl_panel_background_stage_allocation_cb),
                          self);
    }

  height = clutter_actor_get_height (stage);

  if (min_height_p)
    *min_height_p = height;

  if (natural_height_p)
    *natural_height_p = height;
}
コード例 #18
0
ファイル: st-scroll-bar.c プロジェクト: Jem777/Cinnamon
static gboolean
handle_capture_event_cb (ClutterActor *trough,
                         ClutterEvent *event,
                         StScrollBar  *bar)
{
  if (clutter_event_type (event) == CLUTTER_MOTION)
    {
      move_slider (bar,
                   ((ClutterMotionEvent*) event)->x,
                   ((ClutterMotionEvent*) event)->y);
    }
  else if (clutter_event_type (event) == CLUTTER_BUTTON_RELEASE
           && ((ClutterButtonEvent*) event)->button == 1)
    {
      ClutterActor *stage, *target;

      stop_scrolling (bar);

      /* check if the mouse pointer has left the handle during the drag and
       * remove the hover state if it has */
      stage = clutter_actor_get_stage (bar->priv->trough);
      target = clutter_stage_get_actor_at_pos ((ClutterStage*) stage,
                                               CLUTTER_PICK_REACTIVE,
                                               ((ClutterButtonEvent*) event)->x,
                                               ((ClutterButtonEvent*) event)->y);
      if (target != bar->priv->handle)
        {
          st_widget_remove_style_pseudo_class ((StWidget*) bar->priv->handle, "hover");
        }
    }

  return TRUE;
}
コード例 #19
0
static gboolean
_enter_event_cb (ClutterActor         *actor,
                 ClutterCrossingEvent *event,
                 gpointer              data)
{
  MxFocusable *focusable;
  MxFocusManager *f_manager;

  f_manager =
    mx_focus_manager_get_for_stage (CLUTTER_STAGE (clutter_actor_get_stage (actor)));

  focusable = mx_focus_manager_get_focused (f_manager);

  /* hide the hover state on a button that has accepted focus via the default
   * focus as we're navigating by mouse and not keys we don't want to move
   * the focus as we may still want it in the place e.g. search bar
   */
  if ((focusable) &&
      (MNB_IS_LAUNCHER_BUTTON (focusable)) &&
      (CLUTTER_ACTOR (focusable) != actor))
    mx_stylable_set_style_pseudo_class (MX_STYLABLE (focusable), NULL);

  mx_stylable_set_style_pseudo_class (MX_STYLABLE (actor), "hover");

  return FALSE;
}
コード例 #20
0
ファイル: utils.c プロジェクト: Pablohn26/xfdashboard
/* Callback function for xfdashboard_traverse_actor() to find stage interface
 * used in xfdashboard_notify().
 */
static gboolean _xfdashboard_notify_traverse_callback(ClutterActor *inActor, gpointer inUserData)
{
	XfdashboardStage					**outStageInterface;
	XfdashboardWindowTrackerMonitor		*stageMonitor;

	g_return_val_if_fail(CLUTTER_IS_ACTOR(inActor), XFDASHBOARD_TRAVERSAL_CONTINUE);
	g_return_val_if_fail(inUserData, XFDASHBOARD_TRAVERSAL_CONTINUE);

	outStageInterface=(XfdashboardStage**)inUserData;

	/* If actor currently traverse is a stage interface then store
	 * the actor in user-data and stop further traversal.
	 */
	if(XFDASHBOARD_IS_STAGE_INTERFACE(inActor))
	{
		stageMonitor=xfdashboard_stage_interface_get_monitor(XFDASHBOARD_STAGE_INTERFACE(inActor));
		if(xfdashboard_window_tracker_monitor_is_primary(stageMonitor))
		{
			*outStageInterface=XFDASHBOARD_STAGE(clutter_actor_get_stage(inActor));
			return(XFDASHBOARD_TRAVERSAL_STOP);
		}
	}

	/* If we get here a stage interface was not found so continue traversal */
	return(XFDASHBOARD_TRAVERSAL_CONTINUE);
}
コード例 #21
0
/* Class functions */
gboolean scim_bridge_client_imcontext_filter_key_event (ClutterIMContext *context, ClutterKeyEvent *event)
{
    scim_bridge_pdebugln (8, "scim_bridge_client_imcontext_filter_key_event ()");

    ScimBridgeClientIMContext *imcontext = SCIM_BRIDGE_CLIENT_IMCONTEXT (context);

    if (scim_bridge_client_is_messenger_opened () && imcontext != NULL ) {
        if (context->actor != NULL) {
	    ClutterActor *stage = clutter_actor_get_stage (context->actor);
	    Window current_window, root, parent, *childs;
	    unsigned int nchild;
	    XWindowAttributes winattr;
	    Display *xdpy;
            int new_window_x;
            int new_window_y;

            clutter_actor_get_transformed_position (context->actor, &new_window_x, &new_window_y);
	    xdpy = clutter_x11_get_default_display ();
	    current_window = clutter_x11_get_stage_window(CLUTTER_STAGE(stage));

	    while(1) {
                XGetWindowAttributes (xdpy, current_window, &winattr);
                new_window_x += winattr.x;
                new_window_y += winattr.y;

                XQueryTree(xdpy, current_window, &root, &parent, &childs, &nchild);
                current_window = parent;
                if (root == parent)
                    break;
            }

            if (imcontext->window_x != new_window_x || imcontext->window_y != new_window_y) {
                imcontext->window_x = new_window_x;
                imcontext->window_y = new_window_y;

                scim_bridge_pdebugln (1,
                    "The cursor location is changed: x = %d + %d\ty = %d + %d",
                    imcontext->window_x, imcontext->cursor_x, imcontext->window_y, imcontext->cursor_y);

                if (set_cursor_location (imcontext, new_window_x, new_window_y, imcontext->cursor_x, imcontext->cursor_y)) {
                    scim_bridge_perrorln ("An IOException occurred at scim_bridge_client_imcontext_filter_key_event ()");
                    return clutter_im_context_filter_keypress (fallback_imcontext, event);
                }
            }
        }

        boolean consumed = FALSE;
        if (filter_key_event (imcontext, event, &consumed)) {
            scim_bridge_perrorln ("An IOException occurred at scim_bridge_client_imcontext_filter_key_event ()");
        } else if (consumed) {
            return TRUE;
        }
    }

    if (imcontext == NULL || !imcontext->enabled) {
        return clutter_im_context_filter_keypress (fallback_imcontext, event);
    }

    return FALSE;
}
コード例 #22
0
ファイル: mex-player.c プロジェクト: dudochkin-victor/mex
static gboolean
mex_player_set_controls_visible (MexPlayer *player,
                                 gboolean   visible)
{
  MexPlayerPrivate *priv = player->priv;
  gfloat pos;
  ClutterStage *stage;
  MxFocusManager *fmanager;

  stage = (ClutterStage*) clutter_actor_get_stage (CLUTTER_ACTOR (player));
  fmanager = mx_focus_manager_get_for_stage (stage);

  pos = clutter_actor_get_height (priv->controls);
  if (visible)
    {
      priv->controls_prev_visible = FALSE;
      priv->controls_visible = TRUE;

      mx_widget_set_disabled (MX_WIDGET (priv->controls), FALSE);

      clutter_actor_animate (priv->controls, CLUTTER_EASE_IN_SINE, 250,
                             "opacity", 0xff,
                             "anchor-y", 0.0,
                             NULL);

      mex_player_restart_timer (player);

      if (priv->related_tile)
        {
          mx_focus_manager_push_focus_with_hint (fmanager,
                                                 MX_FOCUSABLE (priv->related_tile),
                                                 MX_FOCUS_HINT_PRIOR);

          g_object_unref (priv->related_tile);
          priv->related_tile = NULL;
        }
      else
        {
          mx_focus_manager_push_focus (fmanager, MX_FOCUSABLE (priv->controls));
        }
    }

  if (!visible)
    {
      priv->controls_visible = FALSE;
      clutter_actor_animate (priv->controls, CLUTTER_EASE_IN_SINE, 250,
                             "opacity", 0x00,
                             "anchor-y", -pos,
                             NULL);

      if (priv->hide_controls_source)
        {
          g_source_remove (priv->hide_controls_source);
          priv->hide_controls_source = 0;
        }
    }

  return TRUE;
}
コード例 #23
0
/* Get maximum (horizontal or vertical) size either by static size or fraction */
static gfloat _xfdashboard_workspace_selector_get_max_size_internal(XfdashboardWorkspaceSelector *self)
{
	XfdashboardWorkspaceSelectorPrivate		*priv;
	ClutterActor							*stage;
	gfloat									w, h;
	gfloat									size, fraction;

	g_return_val_if_fail(XFDASHBOARD_IS_WORKSPACE_SELECTOR(self), 0.0f);

	priv=self->priv;

	/* Get stage's size to either determine maximum size by fraction or
	 * to update maximum size or fraction and send notifications
	 */
	stage=clutter_actor_get_stage(CLUTTER_ACTOR(self));
	if(!stage) return(0.0f);

	clutter_actor_get_size(CLUTTER_ACTOR(stage), &w, &h);

	/* If fraction should be used to determine maximum size get width or height
	 * of stage depending on orientation and calculate size by fraction
	 */
	if(priv->usingFraction)
	{
		/* Calculate size by fraction */
		if(priv->orientation==CLUTTER_ORIENTATION_HORIZONTAL) size=h*priv->maxFraction;
			else size=w*priv->maxFraction;

		/* Update maximum size if it has changed */
		if(priv->maxSize!=size)
		{
			priv->maxSize=size;

			/* Notify about property change */
			g_object_notify_by_pspec(G_OBJECT(self), XfdashboardWorkspaceSelectorProperties[PROP_MAX_SIZE]);
		}

		return(size);
	}

	/* Calculate fraction from size */
	if(priv->orientation==CLUTTER_ORIENTATION_HORIZONTAL) fraction=priv->maxSize/h;
		else fraction=priv->maxSize/w;

	/* Update maximum fraction if it has changed */
	if(priv->maxFraction!=fraction)
	{
		priv->maxFraction=fraction;

		/* Notify about property change */
		g_object_notify_by_pspec(G_OBJECT(self), XfdashboardWorkspaceSelectorProperties[PROP_MAX_FRACTION]);
	}

	/* Otherwise return static maximum size configured */
	return(priv->maxSize);
}
コード例 #24
0
ファイル: mx-toolbar.c プロジェクト: 3v1n0/mx
static void
close_button_click_cb (MxButton  *button,
                       MxToolbar *toolbar)
{
  gboolean handled;
  g_signal_emit (toolbar, toolbar_signals[CLOSE_BUTTON_CLICKED], 0, &handled);

  if (!handled)
    clutter_actor_destroy (clutter_actor_get_stage (CLUTTER_ACTOR (toolbar)));
}
コード例 #25
0
ファイル: fcitximcontext.c プロジェクト: fcitx/fcitx-clutter
static void
_set_cursor_location_internal(FcitxIMContext *fcitxcontext)
{
    ClutterIMContext* context = CLUTTER_IM_CONTEXT(fcitxcontext);
    ClutterActor *stage = clutter_actor_get_stage (context->actor);
    Window current_window, root, parent, *childs;
    unsigned int nchild;
    XWindowAttributes winattr;
    Display *xdpy;
    float fx, fy;
    gint x, y;

    if (!stage)
        return;

    clutter_actor_get_transformed_position (context->actor, &fx, &fy);
    x = fx;
    y = fy;

    xdpy = clutter_x11_get_default_display ();
    current_window = clutter_x11_get_stage_window(CLUTTER_STAGE(stage));

    if (!xdpy || !current_window)
        return;

    while(1) {
        XGetWindowAttributes (xdpy, current_window, &winattr);
        x += winattr.x;
        y += winattr.y;

        XQueryTree(xdpy, current_window, &root, &parent, &childs, &nchild);
        current_window = parent;
        if (root == parent)
        break;
    }

    if (fcitxcontext->area.x != x || fcitxcontext->area.y != y) {
        fcitxcontext->area.x = x;
        fcitxcontext->area.y = y;
    }

    if (context->actor == NULL ||
        !IsFcitxIMClientValid(fcitxcontext->client)) {
        return;
    }

    ClutterIMRectangle area = fcitxcontext->area;
    if (area.x == -1 && area.y == -1 && area.width == 0 && area.height == 0) {
        area.y = 0;
        area.x = 0;
    }

    FcitxIMClientSetCursorLocation(fcitxcontext->client, area.x, area.y + area.height);
    return;
}
コード例 #26
0
static void
mex_content_box_unmap (ClutterActor *actor)
{
  ClutterActor *stage = clutter_actor_get_stage (actor);

  g_signal_handlers_disconnect_by_func (stage,
                                        mex_content_box_notify_key_focus_cb,
                                        actor);

  CLUTTER_ACTOR_CLASS (mex_content_box_parent_class)->unmap (actor);
}
コード例 #27
0
static void
mex_content_box_map (ClutterActor *actor)
{
  ClutterActor *stage;

  CLUTTER_ACTOR_CLASS (mex_content_box_parent_class)->map (actor);

  stage = clutter_actor_get_stage (actor);
  g_signal_connect (stage, "notify::key-focus",
                    G_CALLBACK (mex_content_box_notify_key_focus_cb), actor);
}
コード例 #28
0
static gboolean
hide_controls_cb (ClutterActor *controls)
{
    if (clutter_actor_has_pointer (controls) == FALSE) {
        g_object_set_data (G_OBJECT (controls), "hide-controls-id", NULL);

        clutter_actor_hide (controls);

        clutter_stage_hide_cursor (CLUTTER_STAGE (clutter_actor_get_stage (controls)));
    }
    return FALSE;
}
コード例 #29
0
void cs_selected_foreach (GCallback cb, gpointer data)
{
  void (*each)(ClutterActor *actor, gpointer data)=(void*)cb;
  GList *s;

  for (s = selected; s; s = s->next)
    {
      ClutterActor *actor = s->data;
      if (actor != clutter_actor_get_stage (actor))
        each(actor, data);
    }
}
コード例 #30
0
ファイル: mex-column.c プロジェクト: ocrete/media-explorer
static void
mex_column_unmap (ClutterActor *actor)
{
  MxFocusManager *manager =
    mx_focus_manager_get_for_stage ((ClutterStage *)
      clutter_actor_get_stage (actor));
  g_signal_handlers_disconnect_by_func (manager,
                                        mex_column_notify_focused_cb,
                                        actor);

  CLUTTER_ACTOR_CLASS (mex_column_parent_class)->unmap (actor);
}