예제 #1
0
static gboolean
input_cb (ClutterActor *stage,
          ClutterEvent *event,
          gpointer      data)
{
    SuperOH *oh = data;

    if (event->type == CLUTTER_KEY_RELEASE)
    {
        g_print ("*** key press event (key:%c) ***\n",
                 clutter_event_get_key_symbol (event));

        if (clutter_event_get_key_symbol (event) == CLUTTER_q)
        {
            clutter_main_quit ();

            return TRUE;
        }
        else if (clutter_event_get_key_symbol (event) == CLUTTER_r)
        {
            gint i;

            for (i = 0; i < n_hands; i++)
                clutter_actor_show (oh->hand[i]);

            return TRUE;
        }
    }

    return FALSE;
}
/* input handler */
void 
input_cb (ClutterStage *stage,
	  ClutterEvent *event,
	  gpointer      data)
{
  if (event->type == CLUTTER_BUTTON_PRESS)
    {
      ClutterActor *a;
      gfloat x, y;

      clutter_event_get_coords (event, &x, &y);

      a = clutter_stage_get_actor_at_pos (stage, CLUTTER_PICK_ALL, x, y);
      if (a && (CLUTTER_IS_TEXTURE (a) || CLUTTER_IS_CLONE (a)))
	clutter_actor_hide (a);
    }
  else if (event->type == CLUTTER_KEY_PRESS)
    {
      g_print ("*** key press event (key:%c) ***\n",
	       clutter_event_get_key_symbol (event));
      
      if (clutter_event_get_key_symbol (event) == CLUTTER_q)
	gtk_main_quit ();
    }
}
예제 #3
0
static gboolean on_key_press(ClutterActor *actor, ClutterEvent *event, MosesOverview* self)
{
    MosesOverviewPrivate* priv = self->priv;
    MetaScreen* screen = meta_plugin_get_screen(priv->plugin);
    g_debug("%s", __func__);

    guint keysym = clutter_event_get_key_symbol(event);

    if (priv->ready) {
        if (keysym == CLUTTER_KEY_Escape) {
            overview_animated_destroy(self, MOSES_OV_REASON_NORMAL, FALSE);
            return TRUE;

        } else if (keysym >= CLUTTER_KEY_1 && keysym <= CLUTTER_KEY_9) {
            //TODO: what if size of clones is greater than 9
            for (int i = 0; i < priv->clones->len; i++) {
                ClutterActor* clone = g_ptr_array_index(priv->clones, i);
                int order = GPOINTER_TO_INT(g_object_get_qdata(G_OBJECT(clone), moses_overview_window_clone_order()));
                if (order == keysym - CLUTTER_KEY_0) {
                    priv->selected_actor = clone;
                    overview_animated_destroy(self, MOSES_OV_REASON_ACTIVATE_WINDOW, TRUE);
                }
            }
        }
    }

    return FALSE;
}
예제 #4
0
파일: courasel.c 프로젝트: UIKit0/toys
static gboolean
on_input (ClutterActor *stage,
	  ClutterEvent *event,
	  gpointer      user_data)
{
  App *app = user_data;

  if (event->type == CLUTTER_KEY_RELEASE)
    {
      if (clutter_timeline_is_playing(app->timeline))
	return FALSE;

      switch (clutter_event_get_key_symbol (event))
	{
	case CLUTTER_Left:
	  rotate_items (app, -1);
	  break;
	case CLUTTER_Right:
	  rotate_items (app, 1);
	  break;
	case CLUTTER_Return:
	  break;
	case CLUTTER_q:
	  clutter_main_quit();
	  break;
	default:
	  break;
	}
    }

  return FALSE;
}
예제 #5
0
파일: main.c 프로젝트: aalex/jasm
gboolean key_press_event(ClutterActor *stage, ClutterEvent *event, gpointer user_data)
{
    UNUSED(user_data);
    guint keyval = clutter_event_get_key_symbol(event);
    ClutterModifierType state = clutter_event_get_state(event);
    gboolean ctrl_pressed = (state & CLUTTER_CONTROL_MASK ? TRUE : FALSE);
    if (keyval == CLUTTER_KEY_Escape)
    {
        if (clutter_stage_get_fullscreen(CLUTTER_STAGE(stage)))
            clutter_stage_set_fullscreen(CLUTTER_STAGE(stage), FALSE);
        else
            clutter_stage_set_fullscreen(CLUTTER_STAGE(stage), TRUE);
    }
    else if (keyval == CLUTTER_KEY_q)
    {
        // Quit application on ctrl-q, this quits the main loop
        // (if there is one)
        if (ctrl_pressed)
        {
            if (option_verbose)
                g_print("ctrl-q pressed. quitting.\n");
            clutter_main_quit();
        }
    }
    return TRUE;
}
/* change the texture size with +/- */
static gboolean
key_press_cb (ClutterActor *actor,
              ClutterEvent *event,
              gpointer      user_data)
{
  ClutterActor *texture;
  gfloat texture_width, texture_height;
  guint key_pressed;

  texture = CLUTTER_ACTOR (user_data);
  clutter_actor_get_size (texture, &texture_width, &texture_height);

  key_pressed = clutter_event_get_key_symbol (event);

  if (key_pressed == CLUTTER_KEY_plus)
    {
      texture_width *= 1.0 + TEXTURE_SIZE_STEP;
      texture_height *= 1.0 + TEXTURE_SIZE_STEP;
    }
  else if (key_pressed == CLUTTER_KEY_minus)
    {
      texture_width *= 1.0 - TEXTURE_SIZE_STEP;
      texture_height *= 1.0 - TEXTURE_SIZE_STEP;
    }

  if (texture_width <= TEXTURE_SIZE_MAX && texture_width >= TEXTURE_SIZE_MIN)
    clutter_actor_animate (texture, CLUTTER_EASE_OUT_CUBIC, 500,
                           "width", texture_width,
                           "height", texture_height,
                           NULL);

  return TRUE;
}
예제 #7
0
static gboolean
on_key_release (ClutterActor *actor,
                ClutterEvent *event,
                gpointer data)
{
  GFreenectDevice *kinect;
  gdouble angle;
  guint key;
  g_return_val_if_fail (event != NULL, FALSE);

  kinect = GFREENECT_DEVICE (data);

  key = clutter_event_get_key_symbol (event);
  switch (key)
    {
    case CLUTTER_KEY_space:
      SHOW_SKELETON = !SHOW_SKELETON;
      break;
    case CLUTTER_KEY_plus:
      set_threshold (100);
      break;
    case CLUTTER_KEY_minus:
      set_threshold (-100);
      break;
    case CLUTTER_KEY_Up:
      set_tilt_angle (kinect, 5);
      break;
    case CLUTTER_KEY_Down:
      set_tilt_angle (kinect, -5);
      break;
    }
  set_info_text ();
  return TRUE;
}
예제 #8
0
static gboolean
key_press_cb (ClutterActor *stage,
              ClutterEvent *event)
{
  switch (clutter_event_get_key_symbol ( (event)))
    {
    case CLUTTER_Escape:
      clutter_actor_destroy (stage);
      break;
    }

  return TRUE;
}
예제 #9
0
static gboolean
key_release_cb (ClutterActor *actor,
                ClutterEvent *event,
                gpointer user_data)
{
  guint keysym = clutter_event_get_key_symbol (event);
  ClutterModifierType mods = clutter_event_get_state (event);

  if (keysym == CLUTTER_KEY_q ||
      ((mods & CLUTTER_SHIFT_MASK) && keysym == CLUTTER_KEY_q))
    clutter_main_quit ();

  return CLUTTER_EVENT_STOP;
}
예제 #10
0
/* input handler */
static gboolean
input_cb (ClutterStage *stage,
	  ClutterEvent *event,
	  gpointer      data)
{
  ClutterEventType event_type = clutter_event_type (event);
  SuperOH *oh = data;

  if (event_type == CLUTTER_BUTTON_PRESS)
    {
      ClutterActor *a;
      gfloat x, y;

      clutter_event_get_coords (event, &x, &y);

      a = clutter_stage_get_actor_at_pos (stage, CLUTTER_PICK_ALL, x, y);
      if (a != NULL && (CLUTTER_IS_TEXTURE (a) || CLUTTER_IS_CLONE (a)))
	clutter_actor_hide (a);
    }
  else if (event->type == CLUTTER_KEY_PRESS)
    {
      g_print ("*** key press event (key:%c) ***\n",
	       clutter_event_get_key_symbol (event));
      
      if (clutter_event_get_key_symbol (event) == CLUTTER_KEY_q)
	gtk_main_quit ();
      else if (clutter_event_get_key_symbol (event) == CLUTTER_KEY_r)
        {
          int i;

          for (i = 0; i < NHANDS; i++)
            clutter_actor_show (oh->hand[i]);
        }
    }

  return TRUE;
}
예제 #11
0
static gboolean
on_key_press_event (ClutterActor *stage,
                    ClutterEvent *event,
                    gpointer      data_)
{
  ValidateData *data = data_;

  if (data->stage == stage &&
      clutter_event_get_key_symbol (event) == CLUTTER_KEY_Escape)
    {
      clutter_actor_hide (stage);

      data->was_painted = TRUE;
    }

  return CLUTTER_EVENT_PROPAGATE;
}
예제 #12
0
static gboolean
stage_key_release_cb (ClutterActor *actor,
		      ClutterEvent *event,
		      gpointer      data)
{
  switch (clutter_event_get_key_symbol (event))
    {
    case CLUTTER_KEY_q:
    case CLUTTER_KEY_Q:
      clutter_main_quit ();
      break;

    case CLUTTER_KEY_m:
      toggle_texture_quality (actor);
      break;
    }
  return FALSE;
}
예제 #13
0
/* Process keyboard/mouse events */
static void input_events_cb(ClutterActor *stage, ClutterEvent *event,
							gpointer user_data)
{
	/* Only handle keyboard events */
	if (event->type != CLUTTER_KEY_PRESS)
		return;

	guint sym;

	sym = clutter_event_get_key_symbol(event);
	switch (sym) {
	case CLUTTER_Escape:
	case CLUTTER_q:
		clutter_main_quit();
		break;
	case CLUTTER_Right:
		mozart_next_track();
		break;
	case CLUTTER_Left:
		mozart_prev_track();
		break;
	case CLUTTER_Down:
		mozart_replay_track();
		break;
	case CLUTTER_space:
		mozart_play_pause();
		break;
	case CLUTTER_r:
		toggle_repeat(stage, "single");
		break;
	case CLUTTER_a:
		toggle_repeat(stage, "all");
		break;
	case CLUTTER_s:
		toggle_shuffle(stage);
		break;
	case CLUTTER_Page_Up:
		mozart_player_seek("seek-fwd");
		break;
	case CLUTTER_Page_Down:
		mozart_player_seek("seek-bwd");
		break;
	}
}
예제 #14
0
static gboolean
key_release_cb (ClutterActor *stage,
                ClutterEvent *event,
                ClutterActor *box)
{
  ClutterGridLayout *layout;
  gboolean toggle;
  guint spacing;

  layout = CLUTTER_GRID_LAYOUT (clutter_actor_get_layout_manager (box));

  switch (clutter_event_get_key_symbol (event))
    {
    case CLUTTER_KEY_c:
      toggle = clutter_grid_layout_get_column_homogeneous (layout);
      clutter_grid_layout_set_column_homogeneous (layout, !toggle);
      break;

    case CLUTTER_KEY_r:
      toggle = clutter_grid_layout_get_row_homogeneous (layout);
      clutter_grid_layout_set_row_homogeneous (layout, !toggle);
      break;

    case CLUTTER_KEY_s:
      spacing = clutter_grid_layout_get_column_spacing (layout);
      if (spacing < 12)
        spacing += 1;
      else
        spacing = 0;
      clutter_grid_layout_set_column_spacing (layout, spacing);
      clutter_grid_layout_set_row_spacing (layout, spacing);
      break;

    case CLUTTER_KEY_q:
      clutter_main_quit ();
      break;

    default:
      return FALSE;
    }

  return TRUE;
}
예제 #15
0
파일: Platform.cpp 프로젝트: shakin/pheobe
gboolean Platform::stageEvent(ClutterStage * stage, ClutterEvent * event, gpointer ui)
{
    g_print("stageEvent\n");
    switch (event->type) {
    case CLUTTER_KEY_PRESS: {
        guint keyval = clutter_event_get_key_symbol (event);
        switch(keyval) {
        case CLUTTER_q:
        case CLUTTER_Escape:
            clutter_main_quit ();
            return TRUE;
        }
        break;
    }

    }

    return FALSE;
}
예제 #16
0
//FIXME: actually key_release is activated even when key press (WTF). does it because I'm hold alt/super?
static gboolean on_key_release(ClutterActor *actor, ClutterEvent *event, MetaSwitcher* self)
{
    MetaSwitcherPrivate* priv = self->priv;
    MetaScreen* screen = meta_plugin_get_screen(priv->plugin);
    MetaDisplay* display = meta_screen_get_display(screen);

    ClutterModifierType state = clutter_event_get_state(event);
    guint keysym = clutter_event_get_key_symbol(event);
    guint action = meta_display_get_keybinding_action(display, clutter_event_get_key_code(event), state);

    int id = priv->selected_id;
    if (action == META_KEYBINDING_ACTION_SWITCH_WINDOWS) {
        id = (id + 1) % priv->apps->len;
    } else if (action == META_KEYBINDING_ACTION_SWITCH_WINDOWS_BACKWARD) {
        id = (priv->apps->len + id - 1) % priv->apps->len;
    } else if (action == META_KEYBINDING_ACTION_SWITCH_APPLICATIONS) {
        id = (id + 1) % priv->apps->len;
    } else if (action == META_KEYBINDING_ACTION_SWITCH_APPLICATIONS_BACKWARD) {
        id = (priv->apps->len + id - 1) % priv->apps->len;
    }
    _set_highlight(self, priv->selected_id, FALSE);
    _set_highlight(self, id, TRUE);
    g_debug("%s, key: 0x%x, action: %d, previd: %d, now: %d", __func__, keysym, action,
            priv->selected_id, id);
    priv->selected_id = id;

    switch(keysym) {
        //FIXME: do not hardcode keysyms, use action instead
        case CLUTTER_KEY_Super_L:
        case CLUTTER_KEY_Super_R:
        case CLUTTER_KEY_Alt_L:
        case CLUTTER_KEY_Alt_R:
        {
            if (priv->selected_id >= 0) {
                meta_window_activate(g_ptr_array_index(priv->apps, priv->selected_id), clutter_get_current_event_time());
            }
            g_object_unref(self);
        }
        default: break;
    }

    return FALSE;
}
예제 #17
0
static gboolean on_key_press(ClutterActor *actor, ClutterEvent *event, MetaSwitcher* self)
{
    MetaSwitcherPrivate* priv = self->priv;

    g_debug("%s", __func__);

    guint keysym = clutter_event_get_key_symbol(event);

    if (keysym == CLUTTER_KEY_Escape) {
        if (!priv->autoclose_id) {
            priv->autoclose_id = g_timeout_add(AUTOCLOSE_TIMEOUT, on_autoclose_timeout, self);
        }
        return TRUE;
    }

    if (priv->autoclose_id) {
        g_source_remove(priv->autoclose_id);
        priv->autoclose_id = 0;
    }
    return FALSE;
}
예제 #18
0
static gboolean
on_key_press (ClutterActor *stage,
              ClutterEvent *event,
              gpointer      unused)
{
  ClutterActor *scroll;
  guint key_symbol;

  scroll = clutter_actor_get_first_child (stage);

  key_symbol = clutter_event_get_key_symbol (event);

  if (key_symbol == CLUTTER_KEY_space)
    {
      clutter_actor_save_easing_state (scroll);
      clutter_actor_set_easing_duration (scroll, 1000);
      clutter_actor_set_child_transform (scroll, NULL);
      clutter_actor_restore_easing_state (scroll);
    }

  return CLUTTER_EVENT_STOP;
}
예제 #19
0
static void
stage_on_key_pressed (ClutterActor *actor,
                      ClutterEvent *event,
                      gpointer      user_data)
{
  Storyboard *self = user_data;
  guint key = clutter_event_get_key_symbol (event);

  switch (key)
    {
    case CLUTTER_KEY_Return:
      person_entered_scene (self);
      break;

    case CLUTTER_KEY_Escape:
      person_left_scene (self);
      break;

    case CLUTTER_KEY_space:
      on_gesture_accomplished (self);
    }
}
예제 #20
0
static gboolean
on_key_press (ClutterActor *stage,
              ClutterEvent *event,
              CallbackData *data)
{
  switch (clutter_event_get_key_symbol (event))
    {
    case CLUTTER_KEY_r:
      free_clips (data);
      clutter_actor_queue_redraw (stage);
      break;

    case CLUTTER_KEY_u:
      if (data->clips)
        {
          g_slice_free (Clip, data->clips->data);
          data->clips = g_slist_delete_link (data->clips, data->clips);
          clutter_actor_queue_redraw (stage);
       }
      break;
    }

  return FALSE;
}
예제 #21
0
static gboolean
on_captured_event (ClutterText *text,
                   ClutterEvent *event,
                   gpointer      dummy G_GNUC_UNUSED)
{
  gboolean is_unicode_mode = FALSE;
  gunichar c;
  guint keyval;

  if (event->type != CLUTTER_KEY_PRESS)
    return FALSE;

  is_unicode_mode = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (text),
                                                        "unicode-mode"));

  c = clutter_event_get_key_unicode (event);
  keyval = clutter_event_get_key_symbol (event);
  if (keyval == CLUTTER_KEY_U)
    {
      if (is_unicode_mode)
        {
          GString *str = g_object_get_data (G_OBJECT (text), "unicode-str");

          clutter_text_set_preedit_string (text, NULL, NULL, 0);

          g_object_set_data (G_OBJECT (text), "unicode-mode",
                             GINT_TO_POINTER (FALSE));
          g_object_set_data (G_OBJECT (text), "unicode-str",
                             NULL);

          g_string_free (str, TRUE);

          return FALSE;
        }

      if (clutter_event_has_control_modifier (event))
        {
          PangoAttrList *attrs;
          PangoAttribute *a;
          GString *str = g_string_sized_new (5);

          g_string_append (str, "u");

          g_object_set_data (G_OBJECT (text),
                             "unicode-mode",
                             GINT_TO_POINTER (TRUE));
          g_object_set_data (G_OBJECT (text),
                             "unicode-str",
                             str);

          attrs = pango_attr_list_new ();

          a = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
          a->start_index = 0;
          a->end_index = str->len;
          pango_attr_list_insert (attrs, a);

          clutter_text_set_preedit_string (text, str->str, attrs, str->len);

          pango_attr_list_unref (attrs);

          return TRUE;
        }

      return FALSE;
    }
  else if (is_unicode_mode && is_hex_digit (c))
    {
      GString *str = g_object_get_data (G_OBJECT (text), "unicode-str");
      PangoAttrList *attrs;
      PangoAttribute *a;
      gchar buf[8];
      gsize len;

      len = g_unichar_to_utf8 (c, buf);
      buf[len] = '\0';

      g_string_append (str, buf);

      g_print ("added '%s' to '%s' (len:%d)\n",
               buf,
               str->str,
               (int) str->len);

      attrs = pango_attr_list_new ();

      a = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
      a->start_index = 0;
      a->end_index = str->len;
      pango_attr_list_insert (attrs, a);

      clutter_text_set_preedit_string (text, str->str, attrs, str->len);

      pango_attr_list_unref (attrs);

      return TRUE;
    }
  else if (is_unicode_mode && (keyval == CLUTTER_KEY_BackSpace))
    {
      GString *str = g_object_get_data (G_OBJECT (text), "unicode-str");
      PangoAttrList *attrs;
      PangoAttribute *a;

      g_string_truncate (str, str->len - 1);

      attrs = pango_attr_list_new ();

      a = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
      a->start_index = 0;
      a->end_index = str->len;
      pango_attr_list_insert (attrs, a);

      clutter_text_set_preedit_string (text, str->str, attrs, str->len);

      pango_attr_list_unref (attrs);

      return TRUE;
    }
  else if (is_unicode_mode &&
           (keyval == CLUTTER_KEY_Return ||
            keyval == CLUTTER_KEY_KP_Enter ||
            keyval == CLUTTER_KEY_ISO_Enter ||
            keyval == CLUTTER_KEY_KP_Space))
    {
      GString *str = g_object_get_data (G_OBJECT (text), "unicode-str");
      const gchar *contents = clutter_text_get_text (text);
      gunichar uchar = 0;
      gchar ch;
      gint i;

      clutter_text_set_preedit_string (text, NULL, NULL, 0);

      g_object_set_data (G_OBJECT (text), "unicode-mode",
                         GINT_TO_POINTER (FALSE));
      g_object_set_data (G_OBJECT (text), "unicode-str",
                         NULL);

      for (i = 0; i < str->len; i++)
        {
          ch = str->str[i];

          if (is_hex_digit (ch))
            uchar += ((gunichar) to_hex_digit (ch) << ((4 - i) * 4));
        }

      g_assert (g_unichar_validate (uchar));

      g_string_overwrite (str, 0, contents);
      g_string_insert_unichar (str,
                               clutter_text_get_cursor_position (text),
                               uchar);

      i = clutter_text_get_cursor_position (text);
      clutter_text_set_text (text, str->str);

      if (i >= 0)
        i += 1;
      else
        i = -1;

      clutter_text_set_cursor_position (text, i);
      clutter_text_set_selection_bound (text, i);

      g_string_free (str, TRUE);

      return TRUE;
    }
  else
    return FALSE;
}
예제 #22
0
파일: IoClutterEvent.c 프로젝트: Akiyah/io
IO_METHOD(IoClutterEvent, getKeySymbol) {
  return IONUMBER(clutter_event_get_key_symbol(IOCEVENT(self)));
}
예제 #23
0
static gboolean
event_cb (ClutterStage * stage, ClutterEvent * event, UserInterface * ui)
{
  gboolean handled = FALSE;

  switch (event->type) {
    case CLUTTER_KEY_PRESS:
    {
      /* Clutter key codes based on */
      /* http://cgit.freedesktop.org/xorg/proto/x11proto/plain/keysymdef.h */

      ClutterVertex center = { 0, };
      ClutterAnimation *animation = NULL;

      center.x - clutter_actor_get_width (ui->texture) / 2;
      guint keyval = clutter_event_get_key_symbol (event);
      switch (keyval) {
        case CLUTTER_q:
        case CLUTTER_Escape:
        {
          clutter_main_quit ();

	  handled = TRUE;
          break;
        }

        case CLUTTER_f:
        {
          // Fullscreen button
          toggle_fullscreen (ui);

          handled = TRUE;
          break;
        }

        case CLUTTER_space:
        {
          // Spacebar
          toggle_playing (ui);

          handled = TRUE;
          break;
        }

        case CLUTTER_l:
        {
          ui->engine->loop = !ui->engine->loop;

	  handled = TRUE;
          break;
        }

        case CLUTTER_8:
        {
          // Mute button
          gdouble volume;
          gboolean muteval;

          g_object_get (G_OBJECT (ui->engine->player), "mute", &muteval, NULL);
          g_object_set (G_OBJECT (ui->engine->player), "mute", !muteval, NULL);
          update_volume (ui, volume);

          handled = TRUE;
          break;
        }

        case CLUTTER_9:
        case CLUTTER_0:
        {
          gdouble volume;
          g_object_get (G_OBJECT (ui->engine->player), "volume", &volume, NULL);
          // Volume Down
          if (keyval == CLUTTER_9 && volume > 0.0) {
            volume -= 0.05;
            if (volume < 0.01)
              volume = 0;
            g_object_set (G_OBJECT (ui->engine->player), "volume",
                volume, NULL);

            // Volume Up
          } else if (keyval == CLUTTER_0 && volume < 1.0) {
            volume += 0.05;
            if (volume > 1)
              volume = 1;
            g_object_set (G_OBJECT (ui->engine->player), "volume",
                volume, NULL);
          }

          update_volume (ui, volume);

          handled = TRUE;
          break;
        }

        case CLUTTER_Up:
        case CLUTTER_Down:
        case CLUTTER_Left:
        case CLUTTER_Right:
        case CLUTTER_Page_Up:
        case CLUTTER_Page_Down:
        {
          gint64 pos, second;
          gfloat progress;

          pos = query_position (ui->engine);
          second = ui->engine->second;

          if (keyval == CLUTTER_Up) {
            // Seek 1 minute foward
            pos += 60 * second;

          } else if (keyval == CLUTTER_Down) {
            // Seek 1 minute back
            pos -= 60 * second;

          } else if (keyval == CLUTTER_Right) {
            // Seek 10 seconds foward
            pos += 10 * second;

          } else if (keyval == CLUTTER_Left) {
            // Seek 10 seconds back
            pos -= 10 * second;

          } else if (keyval == CLUTTER_Page_Up) {
            // Seek 10 minutes foward
            pos += 600 * second;

          } else if (keyval == CLUTTER_Page_Down) {
            // Seek 10 minutes back
            pos -= 600 * second;
          }

          /* clamp the timestamp to be within the media */
          pos = CLAMP (pos, 0, ui->engine->media_duration);

          engine_seek (ui->engine, pos, TRUE);

          progress = (float) pos / ui->engine->media_duration;
          clutter_actor_set_size (ui->control_seekbar,
              progress * ui->seek_width, ui->seek_height);
          progress_update_text (ui);

          handled = TRUE;
          break;
        }

        case CLUTTER_i:
        {
	  // set in point for segment
	  gint64 in_point;

	  in_point = query_position (ui->engine);
	  ui->engine->in_point = in_point;
	  engine_seek (ui->engine, in_point, TRUE);

	  handled = TRUE;
	  break;
        }

        case CLUTTER_o:
        {
	  // set out point for segment
	  gint64 out_point;

	  out_point = query_position (ui->engine);
	  ui->engine->out_point = out_point;
	  engine_seek (ui->engine, out_point, FALSE);

	  handled = TRUE;
	  break;
        }

        case CLUTTER_r:
        {
          // rotate texture 90 degrees.
          rotate_video (ui);

          handled = TRUE;
          break;
        }

        case CLUTTER_c:
        {
          // show or hide controls
          penalty_box (ui);
          ui->keep_showing_controls = !ui->controls_showing;
          show_controls (ui, !ui->controls_showing);

          handled = TRUE;
          break;
        }

        case CLUTTER_period:
        {
          frame_stepping (ui->engine, TRUE);

          handled = TRUE;
          break;
        }

        case CLUTTER_comma:
        {
          frame_stepping (ui->engine, FALSE);

          handled = TRUE;
          break;
        }

        default:
        {
          handled = FALSE;
          break;
        }
      }

      break;
    }

    case CLUTTER_BUTTON_PRESS:
    {
      if (ui->controls_showing) {
        ClutterActor *actor;
        ClutterButtonEvent *bev = (ClutterButtonEvent *) event;

        actor = clutter_stage_get_actor_at_pos (stage, CLUTTER_PICK_ALL,
            bev->x, bev->y);
        if (actor == ui->control_play_toggle) {
          toggle_playing (ui);

        } else if (actor == ui->control_seek1 ||
            actor == ui->control_seek2 || actor == ui->control_seekbar) {
          gfloat x, y, dist;
          gint64 progress;

          clutter_actor_get_transformed_position (ui->control_seekbar, &x, &y);
          dist = bev->x - x;
          dist = CLAMP (dist, 0, ui->seek_width);

          if (ui->engine->media_duration == -1) {
            update_media_duration (ui->engine);
          }

          progress = ui->engine->media_duration * (dist / ui->seek_width);
          engine_seek (ui->engine, progress, TRUE);
          clutter_actor_set_size (ui->control_seekbar, dist, ui->seek_height);
          progress_update_text (ui);

        } else if (actor == ui->vol_int || actor == ui->vol_int_bg) {
          gfloat x, y, dist;
          gdouble volume;

          clutter_actor_get_transformed_position (ui->vol_int_bg, &x, &y);
          dist = bev->x - x;
          dist = CLAMP (dist, 0, ui->volume_width);

          volume = dist / ui->volume_width;
          g_object_set (G_OBJECT (ui->engine->player), "volume", volume, NULL);
          clutter_actor_set_size (ui->vol_int, dist, ui->volume_height);

        } else if (actor == ui->control_bg || actor == ui->control_title
            || actor == ui->control_pos) {
          ui->keep_showing_controls = !ui->keep_showing_controls;

          if (ui->keep_showing_controls) {
            clutter_stage_hide_cursor (CLUTTER_STAGE (ui->stage));
          } else {
            penalty_box (ui);
            show_controls (ui, FALSE);
          }
        } else if (actor == ui->texture || actor == ui->stage) {
          if (!ui->penalty_box_active) {
            penalty_box (ui);
            show_controls (ui, FALSE);
          }
        }
      }

      handled = TRUE;
      break;
    }

    case CLUTTER_MOTION:
    {
      if (!ui->penalty_box_active)
        show_controls (ui, TRUE);

      handled = TRUE;
      break;
    }
  }

  return handled;
}