Ejemplo n.º 1
0
EAPI void
e_focus_event_mouse_out(E_Border* bd)
{
   if (e_config->focus_policy == E_FOCUS_MOUSE)
     {
        /* FIXME: this is such a hack. its a big hack around x's async events
	 * as we dont know always exactly what action causes what event
	 * so by waiting more than 0.2 secs before reverting focus to nothing
	 * since we entered root, we are ignoring mouse in's on the root
	 * container for a bit after the mosue may have entered it
	 */
	if ((ecore_loop_time_get() - e_grabinput_last_focus_time_get()) > 0.2)
	  {
	     if (!bd->lock_focus_in)
               {
                  if (bd->focused)
                    e_border_focus_set(bd, 0, 1);
               }
	  }
     }
   if (bd->raise_timer)
     {
	ecore_timer_del(bd->raise_timer);
	bd->raise_timer = NULL;
     }
}
Ejemplo n.º 2
0
static void
_begin_tick(void)
{
   if (ticking) return;
   ticking = 1;
   switch (src)
     {
      case ECORE_ANIMATOR_SOURCE_TIMER:
        if (!timer)
          {
             double t_loop = ecore_loop_time_get();
             double sync_0 = 0.0;
             double d = -fmod(t_loop - sync_0, animators_frametime);

             timer = _ecore_timer_loop_add(animators_frametime,
                                           _ecore_animator, NULL);
             _ecore_timer_delay(timer, d);
          }
        break;

      case ECORE_ANIMATOR_SOURCE_CUSTOM:
        if (begin_tick_cb) begin_tick_cb((void *)begin_tick_data);
        break;

      default:
        break;
     }
}
Ejemplo n.º 3
0
void GestureHandler::handleSingleTap(const IntPoint& position)
{
    Evas* evas = evas_object_evas_get(m_ewkView->evasObject());
    ASSERT(evas);

    // Send mouse move, down and up event to create fake click event.
    Evas_Event_Mouse_Move mouseMove;
    mouseMove.buttons = 0;
    mouseMove.prev.output.x = mouseMove.prev.canvas.x = position.x();
    mouseMove.prev.output.y = mouseMove.prev.canvas.y = position.y();
    mouseMove.cur.output.x = mouseMove.cur.canvas.x = position.x();
    mouseMove.cur.output.y = mouseMove.cur.canvas.y = position.y();
    mouseMove.data = 0;
    mouseMove.modifiers = const_cast<Evas_Modifier*>(evas_key_modifier_get(evas));
    mouseMove.locks = const_cast<Evas_Lock*>(evas_key_lock_get(evas));
    mouseMove.timestamp = ecore_loop_time_get();
    mouseMove.event_flags = EVAS_EVENT_FLAG_NONE;
    mouseMove.dev = 0;
    WKViewSendMouseMoveEvent(m_ewkView->wkView(), &mouseMove);

    Evas_Event_Mouse_Down mouseDown;
    mouseDown.button = 1;
    mouseDown.output.x = mouseDown.canvas.x = position.x();
    mouseDown.output.y = mouseDown.canvas.y = position.y();
    mouseDown.data = 0;
    mouseDown.modifiers = const_cast<Evas_Modifier*>(evas_key_modifier_get(evas));
    mouseDown.locks = const_cast<Evas_Lock*>(evas_key_lock_get(evas));
    mouseDown.flags = EVAS_BUTTON_NONE;
    mouseDown.timestamp = ecore_loop_time_get();
    mouseDown.event_flags = EVAS_EVENT_FLAG_NONE;
    mouseDown.dev = 0;
    WKViewSendMouseDownEvent(m_ewkView->wkView(), &mouseDown);

    Evas_Event_Mouse_Up mouseUp;
    mouseUp.button = 1;
    mouseUp.output.x = mouseUp.canvas.x = position.x();
    mouseUp.output.y = mouseUp.canvas.y = position.y();
    mouseUp.data = 0;
    mouseUp.modifiers = const_cast<Evas_Modifier*>(evas_key_modifier_get(evas));
    mouseUp.locks = const_cast<Evas_Lock*>(evas_key_lock_get(evas));
    mouseUp.flags = EVAS_BUTTON_NONE;
    mouseUp.timestamp = ecore_loop_time_get();
    mouseUp.event_flags = EVAS_EVENT_FLAG_NONE;
    mouseUp.dev = 0;
    WKViewSendMouseUpEvent(m_ewkView->wkView(), &mouseUp);
}
Ejemplo n.º 4
0
/**********   Main Game Animator Loop   **************************************/
static Eina_Bool
_game_loop(void *data)
{
   static double last_time = 0;
   double elapsed, now;
   int num_enemies;
   int remaining_waves;

   // calc time between each frame
   now = ecore_loop_time_get();
   elapsed = last_time ? now - last_time : 0.0;
   last_time = now;

   if (_game_state >= GAME_STATE_PLAYING)
   {
      // keep track of play time
      _play_time += elapsed;

      // spawn wave/enemy as required
      remaining_waves = ede_wave_step(elapsed);
      // recalc every enemys
      num_enemies = ede_enemy_one_step_all(elapsed);
      // recalc every towers
      ede_tower_one_step_all(elapsed);
      // recalc every bullets
      ede_bullet_one_step_all(elapsed);

      // no more lives ? LOOSER !!
      if (_player_lives < 0)
      {
         ede_gui_menu_show("Looser !!");
         ede_gui_menu_item_add("Retry Level", "", _restart_level_cb, NULL);
         ede_gui_menu_item_add("Main Menu", "", _mainmenu_cb, NULL);
         ede_gui_menu_item_add("Level Selector", "", _scenario_selected_cb, _current_scenario);
         _game_state = GAME_STATE_PAUSE;
      }

      // no more enemies ? WINNER !!
      if (remaining_waves < 1 && num_enemies < 1)
      {
         Ede_Level *next = ede_level_next_get();
         ede_gui_menu_show("Victory !!");
         if (next)
            ede_gui_menu_item_add("Next level", "", _level_selected_cb, next);
         ede_gui_menu_item_add("Retry Level", "", _restart_level_cb, NULL);
         ede_gui_menu_item_add("Main Menu", "", _mainmenu_cb, NULL);
         _game_state = GAME_STATE_PAUSE;
      }
   }

   // update debug panel (if visible)
   ede_game_debug_panel_update(now);

   return ECORE_CALLBACK_RENEW;
}
static void
_timer_loop_constructor(Eo *obj, void *_pd, va_list *list)
{
   double in = va_arg(*list, double);
   Ecore_Task_Cb func = va_arg(*list, Ecore_Task_Cb);
   const void *data = va_arg(*list, const void *);
   double now;

   now = ecore_loop_time_get();

   Ecore_Timer_Private_Data *timer = _pd;
   _ecore_timer_add(obj, timer, now, in, func, data);
}
Ejemplo n.º 6
0
static int
_rotate(void *data)
{
    Smart_Data *sd = data;
    double t = ecore_loop_time_get() - sd->start;
    Evas_Coord x, y, w, h;
    double p, deg = 0.0;
    Evas_Map *map;
    Evas_Object *photocam;
    Elm_Slideshow_Item *item;

    item = elm_slideshow_item_current_get(sd->slideshow);
    if(!item) return 1;
    photocam = elm_slideshow_item_object_get(item);

    if (!sd->animator) return 0;
    t = t / ROTATION_DURATION;
    if (t > 1.0) t = 1.0;

    evas_object_geometry_get(photocam, &x, &y, &w, &h);
    map = evas_map_new(4);
    evas_map_smooth_set(map, 0);

    if (photocam)
        evas_map_util_points_populate_from_object_full(map, photocam, 0);

    x += (w / 2);
    y += (h / 2);

    p = 1.0 - t;
    p = 1.0 - (p * p);

    if (sd->mode)
        deg = 90.0 * p + sd->state * 90;
    else
        deg = - ((3 - sd->state) * 90.0) - (90.0 * p);

    evas_map_util_3d_rotate(map, 0.0, 0.0, deg, x, y, 0);

    evas_object_map_set(photocam, map);
    evas_object_map_enable_set(photocam, 1);
    evas_map_free(map);

    if (t >= 1.0)
    {
        sd->animator = NULL;
        return 0;
    }
    return 1;
}
Ejemplo n.º 7
0
/**
 * Creates a timer to call the given function in the given period of time.
 * @param   in   The interval in seconds from current loop time.
 * @param   func The given function.  If @p func returns 1, the timer is
 *               rescheduled for the next interval @p in.
 * @param   data Data to pass to @p func when it is called.
 * @return  A timer object on success.  @c NULL on failure.
 *
 * This is the same as ecore_timer_add(), but "now" is the time from
 * ecore_loop_time_get() not ecore_time_get() as ecore_timer_add() uses. See
 * ecore_timer_add() for more details.
 */
EAPI Ecore_Timer *
ecore_timer_loop_add(double in, Ecore_Task_Cb func, const void *data)
{
   double now;
   Ecore_Timer *timer;

   if (!func) return NULL;
   if (in < 0.0) in = 0.0;
   timer = calloc(1, sizeof(Ecore_Timer));
   if (!timer) return NULL;
   ECORE_MAGIC_SET(timer, ECORE_MAGIC_TIMER);
   now = ecore_loop_time_get();
   _ecore_timer_set(timer, now + in, in, func, (void *)data);
   return timer;
}
Ejemplo n.º 8
0
static void
_rotate_go(Smart_Data *sd, unsigned char mode)
{
    char inc = 1;

    if (!sd->animator) sd->animator = ecore_animator_add(_rotate, sd);
    sd->start = ecore_loop_time_get();

    if (!mode)
        inc = -1;

    sd->state += inc;
    if (sd->state < 0)
        sd->state = 3;
    else if (sd->state > 3)
        sd->state = 0;
    sd->mode = mode;
}
Ejemplo n.º 9
0
double
_ecore_timer_next_get(void)
{
   double now;
   double in;
   Ecore_Timer *first, *second;

   first = _ecore_timer_first_get();
   if (!first) return -1;

   second = _ecore_timer_after_get(first);
   if (second)
     first = second;

   now = ecore_loop_time_get();
   in = first->at - now;
   if (in < 0) in = 0;
   return in;
}
Ejemplo n.º 10
0
static Eina_Bool
_ecore_animator_run(void *data)
{
   Ecore_Animator *animator = data;
   double pos = 0.0, t;
   Eina_Bool run_ret;

   t = ecore_loop_time_get();
   if (animator->run > 0.0)
     {
        pos = (t - animator->start) / animator->run;
        if (pos > 1.0) pos = 1.0;
        else if (pos < 0.0)
          pos = 0.0;
     }
   run_ret = animator->run_func(animator->run_data, pos);
   if (t >= (animator->start + animator->run)) run_ret = EINA_FALSE;
   return run_ret;
}
Ejemplo n.º 11
0
EAPI Ecore_Animator *
ecore_animator_timeline_add(double            runtime,
                            Ecore_Timeline_Cb func,
                            const void       *data)
{
   Ecore_Animator *animator;

   EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
   _ecore_lock();
   if (runtime <= 0.0) runtime = 0.0;
   animator = _ecore_animator_add(_ecore_animator_run, NULL);
   animator->data = animator;
   animator->run_func = func;
   animator->run_data = (void *)data;
   animator->start = ecore_loop_time_get();
   animator->run = runtime;
   _ecore_unlock();
   return animator;
}
Ejemplo n.º 12
0
static void
_mouse_up_animation(void *data, const Efl_Event *event)
{
   Efl_Ui_Pager_Data *pd = data;
   double p = ecore_loop_time_get() - pd->mouse_up_time;

   if (p >= 1.0) p = 1.0;
   p = ecore_animator_pos_map(p, ECORE_POS_MAP_ACCELERATE, 0.0, 0.0);

   if (pd->curr.pos < 0.0)
     {
        if (pd->curr.pos > -0.5)
          pd->curr.pos = pd->curr.pos * (1 - p);
        else
          pd->curr.pos = (-1) - (-1 - pd->curr.pos) * (1 - p);
     }
   else
     {
        if (pd->curr.pos < 0.5)
          pd->curr.pos = pd->curr.pos * (1 - p);
        else
          pd->curr.pos = 1 - (1 - pd->curr.pos) * (1 - p);
     }

   if (EINA_DBL_EQ(pd->curr.pos, 1.0))
     {
        efl_page_transition_curr_page_change(pd->transition, 1);
        pd->curr.page = (pd->curr.page + 1 + pd->cnt) % pd->cnt;
        pd->curr.pos = 0.0;
     }
   else if (EINA_DBL_EQ(pd->curr.pos, -1.0))
     {
        efl_page_transition_curr_page_change(pd->transition, -1);
        pd->curr.page = (pd->curr.page - 1 + pd->cnt) % pd->cnt;
        pd->curr.pos = 0.0;
     }

   _efl_ui_pager_update(pd);

   if (EINA_DBL_EQ(p, 1.0))
     efl_event_callback_del(event->object, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK,
                            _mouse_up_animation, pd);
}
Ejemplo n.º 13
0
static void
_itask_item_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
   Evas_Event_Mouse_Up *ev;
   Itask_Item *ic;
   E_Desk *current_desk;

   ev = event_info;
   ic = data;

   ic->drag.start = 0;
   
   if ((ev->button == 1) && (!ic->drag.dnd))
     {
	if (ic->time_press + 0.3 < ecore_loop_time_get())
	  return;
	
	current_desk = e_desk_current_get(ic->border->zone);
       
	if ((ic->itask->ci->iconify_focused) &&
	    (ic->border == e_border_focused_get()))
	  {	     
	     e_border_iconify(ic->border);
	  }
	else
   	  {
	     if ((e_desk_current_get(ic->border->zone) != ic->border->desk) &&
		 (!ic->border->sticky))
	       e_desk_show(ic->border->desk);

	     if (ic->border->shaded)
	       e_border_unshade(ic->border, E_DIRECTION_UP);

	     if (ic->border->iconic)
	       e_border_uniconify(ic->border);
	     else
	       e_border_raise(ic->border);

	     e_border_focus_set(ic->border, 1, 1);
   	  }
     }
}
Ejemplo n.º 14
0
static void
_page_set_animation(void *data, const Efl_Event *event)
{
   Efl_Ui_Pager_Data *pd = data;
   double p = ecore_loop_time_get() - pd->change.start_time;
   double d, temp_pos;
   int temp_page;

   if (p >= 1.0) p = 1.0;
   p = ecore_animator_pos_map(p, ECORE_POS_MAP_ACCELERATE, 0.0, 0.0);

   d = pd->change.src + pd->change.delta * p;
   temp_page = d;
   temp_pos = d - temp_page;

   if ((temp_page < pd->curr.page) && (fabs(pd->curr.page - d) < 1.0))
     {
        temp_page += 1;
        temp_pos -= 1.0;
     }

   if (pd->curr.page != temp_page)
     {
        if (pd->change.delta < 0)
          efl_page_transition_curr_page_change(pd->transition, -1);
        else
          efl_page_transition_curr_page_change(pd->transition, 1);
        temp_pos = 0.0;
     }

   pd->curr.page = temp_page;
   pd->curr.pos = temp_pos;

   ERR("page %d pos %lf", pd->curr.page, pd->curr.pos);

   _efl_ui_pager_update(pd);

   if (EINA_DBL_EQ(p, 1.0))
     efl_event_callback_del(event->object, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK,
                            _page_set_animation, pd);
}
Ejemplo n.º 15
0
static void
_mouse_up_cb(void *data,
             const Efl_Event *event)
{
   Efl_Input_Pointer *ev = event->info;
   Eo *obj = data;
   EFL_UI_PAGER_DATA_GET(obj, pd);

   if (efl_input_event_flags_get(ev) & EFL_INPUT_FLAGS_PROCESSED) return;
   if (!pd->down.enabled) return;

   pd->down.enabled = EINA_FALSE;

   ELM_SAFE_FREE(pd->job, ecore_job_del);

   if (EINA_DBL_EQ(pd->curr.pos, 0.0)) return;

   pd->mouse_up_time = ecore_loop_time_get();

   efl_event_callback_add(obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, _mouse_up_animation, pd);
}
Ejemplo n.º 16
0
/**
 * Add a animator to tick off at every animaton tick during main loop execution.
 * @param func The function to call when it ticks off
 * @param data The data to pass to the function
 * @return A handle to the new animator
 * @ingroup Ecore_Animator_Group
 *
 * This function adds a animator and returns its handle on success and NULL on
 * failure. The function @p func will be called every N seconds where N is the
 * frametime interval set by ecore_animator_frametime_set(). The function will
 * be passed the @p data pointer as its parameter.
 *
 * When the animator @p func is called, it must return a value of either 1 or 0.
 * If it returns 1 (or ECORE_CALLBACK_RENEW), it will be called again at the
 * next tick, or if it returns 0 (or ECORE_CALLBACK_CANCEL) it will be deleted
 * automatically making any references/handles for it invalid.
 */
EAPI Ecore_Animator *
ecore_animator_add(Ecore_Task_Cb func, const void *data)
{
   Ecore_Animator *animator;

   if (!func) return NULL;
   animator = calloc(1, sizeof(Ecore_Animator));
   if (!animator) return NULL;
   ECORE_MAGIC_SET(animator, ECORE_MAGIC_ANIMATOR);
   animator->func = func;
   animator->data = (void *)data;
   animators = (Ecore_Animator *)eina_inlist_append(EINA_INLIST_GET(animators), EINA_INLIST_GET(animator));
   if (!timer)
     {
        double t_loop = ecore_loop_time_get();
        double sync_0 = 0.0;
        double d = -fmod(t_loop - sync_0, animators_frametime);

        timer = ecore_timer_loop_add(animators_frametime, _ecore_animator, NULL);
        ecore_timer_delay(timer, d);
     }
   return animator;
}
Ejemplo n.º 17
0
static int
_scoring(void)
{
   int score;
   double end_time;
   char *user;

   /* compute score using time, board size and mines count */
   end_time = ecore_loop_time_get() - t0 - game.clock.delay;
   score = (game.datas.x_theme * game.datas.y_theme * game.datas.mines_total)
            - (10 * end_time);
   /* Don't be rude with bad players */
   if (score < 0) score = 0;

   /* get system username for name */
   user = getenv("USER");

   /* add the score */
   game.trophy.escore = etrophy_score_new(user, score);
   /* Level is Standard if using default board values */
   if (game.datas.mines_total == game.datas.mines_theme)
     {
        game.trophy.game_type = STANDARD;
     }
   else
     {
        game.trophy.game_type = CUSTOM;
     }

   game.trophy.level = etrophy_gamescore_level_get(game.trophy.gamescore,
                                                   game.trophy.game_type);
   etrophy_level_score_add(game.trophy.level, game.trophy.escore);
   etrophy_gamescore_save(game.trophy.gamescore, NULL);

   return score;

}
Ejemplo n.º 18
0
static void
_opinfo_op_registry_listener(void *data, const E_Fm2_Op_Registry_Entry *ere)
{
   Evas_Object *o = data;
   char *total, buf[4096];
   Edje_Message_Float msg;
   int mw, mh;

   if (!o || !ere) return;

   // Don't show if the operation keep less than 1 second
   if (!ere->needs_attention && (ere->start_time + 1.0 > ecore_loop_time_get()))
     return;
   
   // Update icon
   switch (ere->op)
   {
      case E_FM_OP_COPY:
        edje_object_signal_emit(o, "e,action,icon,copy", "e");
        break;

      case E_FM_OP_MOVE:
        edje_object_signal_emit(o, "e,action,icon,move", "e");
        break;

      case E_FM_OP_REMOVE:
        edje_object_signal_emit(o, "e,action,icon,delete", "e");
        break;

      case E_FM_OP_SECURE_REMOVE:
        edje_object_signal_emit(o, "e,action,icon,secure_delete", "e");
        break;

      default:
        edje_object_signal_emit(o, "e,action,icon,unknown", "e");
   }

   // Update information text
   switch (ere->status)
     {
      case E_FM2_OP_STATUS_ABORTED:
        switch (ere->op)
          {
           case E_FM_OP_COPY:
             snprintf(buf, sizeof(buf), _("Copying is aborted"));
             break;

           case E_FM_OP_MOVE:
             snprintf(buf, sizeof(buf), _("Moving is aborted"));
             break;

           case E_FM_OP_REMOVE:
             snprintf(buf, sizeof(buf), _("Deleting is aborted"));
             break;

           case E_FM_OP_SECURE_REMOVE:
             snprintf(buf, sizeof(buf), _("Secure deletion is aborted"));
             break;

           default:
             snprintf(buf, sizeof(buf), _("Unknown operation from slave is aborted"));
          }
        break;

      default:
        total = e_util_size_string_get(ere->total);
        switch (ere->op)
          {
           case E_FM_OP_COPY:
             if (ere->finished)
               snprintf(buf, sizeof(buf), _("Copy of %s done"), total);
             else
               snprintf(buf, sizeof(buf), _("Copying %s (eta: %s)"),
                             total, e_util_time_str_get(ere->eta));
             break;

           case E_FM_OP_MOVE:
             if (ere->finished)
               snprintf(buf, sizeof(buf), _("Move of %s done"), total);
             else
               snprintf(buf, sizeof(buf), _("Moving %s (eta: %s)"),
                             total, e_util_time_str_get(ere->eta));
             break;

           case E_FM_OP_REMOVE:
             if (ere->finished)
               snprintf(buf, sizeof(buf), _("Delete done"));
             else
               snprintf(buf, sizeof(buf), _("Deleting files..."));
             break;

           case E_FM_OP_SECURE_REMOVE:
             if (ere->finished)
               snprintf(buf, sizeof(buf), _("Secure delete done"));
             else
               snprintf(buf, sizeof(buf), _("Securely deleting files..."));
             break;

           default:
             snprintf(buf, sizeof(buf), _("Unknown operation from slave %d"), ere->id);
          }
        E_FREE(total);
     }
   edje_object_part_text_set(o, "e.text.info", buf);

   // Update spinner wheel
   if ((ere->finished) || (ere->status == E_FM2_OP_STATUS_ABORTED))
     {
        if (!evas_object_data_get(o, "stopped"))
          {
             evas_object_data_set(o, "stopped", o);
             edje_object_signal_emit(o, "e,state,busy,stop", "e");
          }
     }
   if (ere->percent > 0)
     {
        if (!evas_object_data_get(o, "started"))
          {
             evas_object_data_set(o, "started", o);
             edje_object_signal_emit(o, "e,state,busy,start", "e");
          }
     }

   // Show/hide the red attention led
   if (ere->needs_attention)
     {
        if (!evas_object_data_get(o, "attention_started"))
          {
             evas_object_data_set(o, "attention_started", o);
             edje_object_signal_emit(o, "e,state,attention,start", "e");
             if (evas_object_data_get(o, "attention_stopped"))
               evas_object_data_del(o, "attention_stopped");
          }
     }
   else
     {
        if (!evas_object_data_get(o, "attention_stopped"))
          {
             evas_object_data_set(o, "attention_stopped", o);
             edje_object_signal_emit(o, "e,state,attention,stop", "e");
             if (evas_object_data_get(o, "attention_started"))
               evas_object_data_del(o, "attention_started");
          }
     }

   // Update gauge
   edje_object_part_drag_size_set(o, "e.gauge.bar",
                                  ((double)(ere->percent)) / 100.0, 1.0);
   msg.val = ((double)(ere->percent)) / 100.0;
   edje_object_message_send(o, EDJE_MESSAGE_FLOAT, 1, &msg);

   // resize element to fit the box
   edje_object_size_min_calc(o, &mw, &mh);
   e_box_pack_options_set(o, 1, 0, 1, 0, 0.0, 0.0, mw, mh, 9999, mh);
   evas_object_show(o);
}
Ejemplo n.º 19
0
/* local subsystem functions */
static Eina_Bool
_cb_key_down(__UNUSED__ void *data, __UNUSED__ int type, void *event)
{
   Ecore_Event_Key *ev;

   ev = event;
   if (ev->event_window != input_window) return ECORE_CALLBACK_PASS_ON;
   if (!strcmp(ev->key, "Escape"))
     e_syscon_hide();
   else if ((!strcmp(ev->key, "Left")) || (!strcmp(ev->key, "Up")))
     {
        if (!o_selected)
          {
             if (e_flowlayout_pack_count_get(o_flow_extra))
               o_selected_flow = o_flow_extra, o_selected = e_flowlayout_pack_object_last(o_flow_extra);
             else if (e_flowlayout_pack_count_get(o_flow_secondary))
               o_selected_flow = o_flow_secondary, o_selected = e_flowlayout_pack_object_last(o_flow_secondary);
             else
               o_selected_flow = o_flow_main, o_selected = e_flowlayout_pack_object_last(o_flow_main);
          }
        else
          {
             edje_object_signal_emit(o_selected, "e,state,focused", "e");
             o_selected = e_flowlayout_pack_object_prev(o_selected_flow, o_selected);
             if (!o_selected)
               {
                  if (o_selected_flow == o_flow_extra)
                    {
                       if (e_flowlayout_pack_count_get(o_flow_secondary))
                         o_selected_flow = o_flow_secondary, o_selected = e_flowlayout_pack_object_last(o_flow_secondary);
                       else
                         o_selected_flow = o_flow_main, o_selected = e_flowlayout_pack_object_last(o_flow_main);
                    }
                  else if (o_selected_flow == o_flow_secondary)
                    o_selected_flow = o_flow_main, o_selected = e_flowlayout_pack_object_last(o_flow_main);
                  else
                    {
                       if (e_flowlayout_pack_count_get(o_flow_extra))
                         o_selected_flow = o_flow_extra, o_selected = e_flowlayout_pack_object_last(o_flow_extra);
                       else if (e_flowlayout_pack_count_get(o_flow_secondary))
                         o_selected_flow = o_flow_secondary, o_selected = e_flowlayout_pack_object_last(o_flow_secondary);
                       else
                         o_selected_flow = o_flow_main, o_selected = e_flowlayout_pack_object_last(o_flow_main);
                    }
               }
          }
        edje_object_signal_emit(o_selected, "e,state,unfocused", "e");
     }
   else if ((!strcmp(ev->key, "Right")) || (!strcmp(ev->key, "Down")) || (!strcmp(ev->key, "Tab")))
     {
        if (!o_selected)
          o_selected_flow = o_flow_main, o_selected = e_flowlayout_pack_object_first(o_flow_main);
        else
          {
             edje_object_signal_emit(o_selected, "e,state,focused", "e");
             o_selected = e_flowlayout_pack_object_next(o_selected_flow, o_selected);
             if (!o_selected)
               {
                  if (o_selected_flow == o_flow_extra)
                    o_selected_flow = o_flow_main, o_selected = e_flowlayout_pack_object_first(o_flow_main);
                  else if (o_selected_flow == o_flow_secondary)
                    {
                       if (e_flowlayout_pack_count_get(o_flow_extra))
                         o_selected_flow = o_flow_extra, o_selected = e_flowlayout_pack_object_first(o_flow_extra);
                       else
                         o_selected_flow = o_flow_main, o_selected = e_flowlayout_pack_object_first(o_flow_main);
                    }
                  else
                    {
                       if (e_flowlayout_pack_count_get(o_flow_secondary))
                         o_selected_flow = o_flow_secondary, o_selected = e_flowlayout_pack_object_first(o_flow_secondary);
                       else if (e_flowlayout_pack_count_get(o_flow_extra))
                         o_selected_flow = o_flow_extra, o_selected = e_flowlayout_pack_object_first(o_flow_extra);
                       else
                         o_selected_flow = o_flow_main, o_selected = e_flowlayout_pack_object_first(o_flow_main);
                    }
               }
          }
        edje_object_signal_emit(o_selected, "e,state,unfocused", "e");
     }
   else if ((!strcmp(ev->keyname, "KP_Enter")) || (!strcmp(ev->keyname, "Return")))
     {
        if (!o_selected) return ECORE_CALLBACK_RENEW;
        edje_object_signal_emit(o_selected, "e,state,focused", "e");
        edje_object_signal_emit(o_selected, "e,action,click", "");
        o_selected = o_selected_flow = NULL;
     }
   else
     {
        E_Action *act;
        double t;

        t = ecore_loop_time_get();
        if (t - show_time > 0.5)
          {
             act = e_bindings_key_down_event_find(E_BINDING_CONTEXT_ANY, ev);
             if ((act) && (act->name))
               {
                  if (!strcmp(act->name, "syscon"))
                    {
                       if (popup)
                         {
                            e_syscon_show(popup->zone, do_defact);
                         }
                    }
                  else
                    {
                       Eina_List *l;

                       for (l = e_config->syscon.actions; l; l = l->next)
                         {
                            E_Config_Syscon_Action *sca;

                            if (!(sca = l->data)) continue;
                            if (!sca->action) continue;
                            if (!strcmp(sca->action, act->name))
                              {
                                 act_count++;
                                 if (act_count > 2)
                                   {
                                      act->func.go(NULL, sca->params);
                                      e_syscon_hide();
                                      break;
                                   }
                              }
                         }
                    }
               }
          }
     }

   return ECORE_CALLBACK_PASS_ON;
}
Ejemplo n.º 20
0
int
e_syscon_show(E_Zone *zone, const char *defact)
{
   Evas_Object *o, *o2;
   Evas_Coord mw, mh;
   int x, y, w, h, zx, zy, zw, zh;
   int iw, ih;
   Eina_List *l;
   double t;

   t = ecore_loop_time_get();
   if (popup)
     {
        if ((t - show_time) > 0.5)
          {
             for (l = e_config->syscon.actions; l; l = l->next)
               {
                  E_Config_Syscon_Action *sca;
                  E_Action *a;

                  if (!(sca = l->data)) continue;
                  if (!sca->action) continue;
                  a = e_action_find(sca->action);
                  if (!a) continue;
                  if (sca->is_main == 2)
                    {
                       a->func.go(NULL, sca->params);
                       e_syscon_hide();
                       break;
                    }
               }
          }
        return 0;
     }

   input_window = ecore_x_window_input_new(zone->container->win, zone->x,
                                           zone->y, zone->w, zone->h);
   ecore_x_window_show(input_window);
   if (!e_grabinput_get(input_window, 1, input_window))
     {
        ecore_x_window_free(input_window);
        input_window = 0;
        return 0;
     }

   popup = e_popup_new(zone, 0, 0, 1, 1);
   if (!popup)
     {
        e_grabinput_release(input_window, input_window);
        ecore_x_window_free(input_window);
        input_window = 0;
        return 0;
     }
   evas_event_freeze(popup->evas);
   e_popup_layer_set(popup, E_LAYER_POPUP);

   handlers = eina_list_append
       (handlers, ecore_event_handler_add
         (ECORE_EVENT_KEY_DOWN, _cb_key_down, NULL));
   handlers = eina_list_append
       (handlers, ecore_event_handler_add
         (ECORE_EVENT_MOUSE_BUTTON_DOWN, _cb_mouse_down, NULL));
   handlers = eina_list_append
       (handlers, ecore_event_handler_add
         (ECORE_EVENT_MOUSE_BUTTON_UP, _cb_mouse_up, NULL));
   handlers = eina_list_append
       (handlers, ecore_event_handler_add
         (ECORE_EVENT_MOUSE_MOVE, _cb_mouse_move, NULL));
   handlers = eina_list_append
       (handlers, ecore_event_handler_add
         (ECORE_EVENT_MOUSE_WHEEL, _cb_mouse_wheel, NULL));

   o = edje_object_add(popup->evas);
   o_bg = o;
   e_theme_edje_object_set(o, "base/theme/syscon",
                           "e/widgets/syscon/main");
   edje_object_part_text_set(o, "e.text.label", _("Cancel"));
   edje_object_signal_callback_add(o, "e,action,close", "",
                                   _cb_signal_close, NULL);
   edje_object_signal_callback_add(o, "e,action,syscon", "*",
                                   _cb_signal_syscon, NULL);

   act_count = 0;
   show_time = t;

   // main (default):
   //  halt | suspend | desk_lock
   // secondary (default):
   //  reboot | hibernate | logout
   // extra (example for illume):
   //  home | close | kill

   o = e_flowlayout_add(popup->evas);
   o_flow_main = o;
   e_flowlayout_orientation_set(o, 1);
   e_flowlayout_flowdirection_set(o, 1, 1);
   e_flowlayout_homogenous_set(o, 1);

   o = e_flowlayout_add(popup->evas);
   o_flow_secondary = o;
   e_flowlayout_orientation_set(o, 1);
   e_flowlayout_flowdirection_set(o, 1, 1);
   e_flowlayout_homogenous_set(o, 1);

   o = e_flowlayout_add(popup->evas);
   o_flow_extra = o;
   e_flowlayout_orientation_set(o, 1);
   e_flowlayout_flowdirection_set(o, 1, 1);
   e_flowlayout_homogenous_set(o, 1);

   for (l = e_config->syscon.actions; l; l = l->next)
     {
        E_Config_Syscon_Action *sca;
        char buf[1024];
        E_Action *a;
        int disabled;

        if (!(sca = l->data)) continue;
        if (!sca->action) continue;
        a = e_action_find(sca->action);
        if (!a) continue;
        disabled = 0;
        if ((!strcmp(sca->action, "logout")) &&
            (!e_sys_action_possible_get(E_SYS_LOGOUT))) disabled = 1;
        else if ((!strcmp(sca->action, "halt")) &&
                 (!e_sys_action_possible_get(E_SYS_HALT)))
          disabled = 1;
        else if ((!strcmp(sca->action, "halt_now")) &&
                 (!e_sys_action_possible_get(E_SYS_HALT_NOW)))
          disabled = 1;
        else if ((!strcmp(sca->action, "reboot")) &&
                 (!e_sys_action_possible_get(E_SYS_REBOOT)))
          disabled = 1;
        else if ((!strcmp(sca->action, "suspend")) &&
                 (!e_sys_action_possible_get(E_SYS_SUSPEND)))
          disabled = 1;
        else if ((!strcmp(sca->action, "hibernate")) &&
                 (!e_sys_action_possible_get(E_SYS_HIBERNATE)))
          disabled = 1;
        o = edje_object_add(popup->evas);
        edje_object_signal_callback_add(o, "e,action,click", "",
                                        _cb_signal_action, sca);
        if (sca->button)
          {
             snprintf(buf, sizeof(buf), "e/widgets/syscon/item/%s",
                      sca->button);
             e_theme_edje_object_set(o, "base/theme/widgets", buf);
          }
        else
          e_theme_edje_object_set(o, "base/theme/widgets",
                                  "e/widgets/syscon/item/button");
        edje_object_part_text_set(o, "e.text.label",
                                  _(e_action_predef_label_get(sca->action, sca->params)));
        if (sca->icon)
          {
             o2 = e_icon_add(popup->evas);
             e_util_icon_theme_set(o2, sca->icon);
             edje_object_part_swallow(o, "e.swallow.icon", o2);
             evas_object_show(o2);
             if (disabled)
               edje_object_signal_emit(o2, "e,state,disabled", "e");
          }
        if (disabled)
          edje_object_signal_emit(o, "e,state,disabled", "e");
        if (sca->is_main)
          {
             e_flowlayout_pack_end(o_flow_main, o);
             iw = ih = e_config->syscon.main.icon_size * e_scale;
          }
        else
          {
             e_flowlayout_pack_end(o_flow_secondary, o);
             iw = ih = e_config->syscon.secondary.icon_size * e_scale;
          }
        edje_object_message_signal_process(o);
        edje_object_size_min_calc(o, &mw, &mh);
        if (mw > iw) iw = mw;
        if (mh > ih) ih = mh;
        e_flowlayout_pack_options_set(o, 1, 1, 0, 0, 0.5, 0.5,
                                      iw, ih, iw, ih);
        evas_object_show(o);
     }

   for (l = (Eina_List *)e_sys_con_extra_action_list_get(); l; l = l->next)
     {
        E_Sys_Con_Action *sca;
        char buf[1024];

        sca = l->data;
        o = edje_object_add(popup->evas);
        edje_object_signal_callback_add(o, "e,action,click", "", _cb_signal_action_extra, sca);
        if (sca->button_name)
          {
             snprintf(buf, sizeof(buf), "e/widgets/syscon/item/%s",
                      sca->button_name);
             e_theme_edje_object_set(o, "base/theme/widgets", buf);
          }
        else
          e_theme_edje_object_set(o, "base/theme/widgets",
                                  "e/widgets/syscon/item/button");
        edje_object_part_text_set(o, "e.text.label", sca->label);
        if (sca->icon_group)
          {
             o2 = edje_object_add(popup->evas);
             e_util_edje_icon_set(o2, sca->icon_group);
             edje_object_part_swallow(o, "e.swallow.icon", o2);
             evas_object_show(o2);
             if (sca->disabled)
               edje_object_signal_emit(o2, "e,state,disabled", "e");
          }
        if (sca->disabled)
          edje_object_signal_emit(o, "e,state,disabled", "e");
        e_flowlayout_pack_end(o_flow_extra, o);
        iw = ih = e_config->syscon.extra.icon_size * e_scale;
        e_flowlayout_pack_options_set(o, 1, 1, 0, 0, 0.5, 0.5,
                                      iw, ih, iw, ih);
        evas_object_show(o);
     }

   e_flowlayout_fill_set(o_flow_main, 1);
   edje_object_part_swallow(o_bg, "e.swallow.main", o_flow_main);
   e_flowlayout_fill_set(o_flow_secondary, 1);
   edje_object_part_swallow(o_bg, "e.swallow.secondary", o_flow_secondary);
   e_flowlayout_fill_set(o_flow_extra, 1);
   edje_object_part_swallow(o_bg, "e.swallow.extra", o_flow_extra);

   e_zone_useful_geometry_get(zone, &zx, &zy, &zw, &zh);
   evas_object_resize(o_bg, zw, zh);
   edje_object_calc_force(o_bg);

   e_flowlayout_size_min_get(o_flow_main, &mw, &mh);
   edje_extern_object_min_size_set(o_flow_main, mw, mh);
   edje_object_part_swallow(o_bg, "e.swallow.main", o_flow_main);
   e_flowlayout_size_min_get(o_flow_secondary, &mw, &mh);
   edje_extern_object_min_size_set(o_flow_secondary, mw, mh);
   edje_object_part_swallow(o_bg, "e.swallow.secondary", o_flow_secondary);
   e_flowlayout_size_min_get(o_flow_extra, &mw, &mh);
   edje_extern_object_min_size_set(o_flow_extra, mw, mh);
   edje_object_part_swallow(o_bg, "e.swallow.extra", o_flow_extra);

   edje_object_size_min_calc(o_bg, &mw, &mh);

   w = mw;
   if (w > zw) w = zw;
   x = zx - zone->x + (zw - w) / 2;
   h = mh;
   if (h > zh) h = zh;
   y = zy - zone->y + (zh - h) / 2;

   e_popup_move_resize(popup, x, y, w, h);
   evas_object_move(o_bg, 0, 0);
   evas_object_resize(o_bg, w, h);
   evas_object_show(o_bg);
   e_popup_edje_bg_object_set(popup, o_bg);

   if (e_config->syscon.do_input)
     {
        deftimer = ecore_timer_add(e_config->syscon.timeout,
                                   _cb_timeout_defaction, NULL);
        if (defact) do_defact = eina_stringshare_add(defact);
     }

   evas_event_thaw(popup->evas);
   inevas = 0;
   e_popup_show(popup);
   return 1;
}
static void
_ecore_fb_li_device_event_key(Ecore_Fb_Input_Device *dev, struct input_event *iev)
{
   if (!dev->listen) return;

   /* check for basic keyboard keys */
   if ((iev->code >= KEY_ESC) && (iev->code <= KEY_COMPOSE))
     {
        int offset = 0;
        const char *keyname = _ecore_fb_li_kbd_syms[iev->code * 7];
        
        /* check the key table */
        if (iev->value)
          {
             /* its a repeated key, dont increment */
             if (iev->value != 2)
               {
                  if (!strcmp(keyname, "Control_L"))
                    dev->keyboard.ctrl++;
                  else if (!strcmp(keyname, "Control_R"))
                    dev->keyboard.ctrl++;
                  else if (!strcmp(keyname, "Alt_L"))
                    dev->keyboard.alt++;
                  else if (!strcmp(keyname, "Alt_R"))
                    dev->keyboard.alt++;
                  else if (!strcmp(keyname, "Shift_L"))
                    dev->keyboard.shift++;
                  else if (!strcmp(keyname, "Shift_R"))
                    dev->keyboard.shift++;
                  else if (!strcmp(keyname, "Caps_Lock"))
                    dev->keyboard.lock = !dev->keyboard.lock;
                  if (dev->keyboard.ctrl > 2) dev->keyboard.ctrl = 2;
                  if (dev->keyboard.alt > 2) dev->keyboard.alt = 2;
                  if (dev->keyboard.shift > 2) dev->keyboard.shift = 2;
                  if (dev->keyboard.lock > 1) dev->keyboard.lock = 1;
               }
          }
        else
          {
             if (!strcmp(keyname, "Control_L"))
                dev->keyboard.ctrl--;
             else if (!strcmp(keyname, "Control_R"))
                dev->keyboard.ctrl--;
             else if (!strcmp(keyname, "Alt_L"))
                dev->keyboard.alt--;
             else if (!strcmp(keyname, "Alt_R"))
                dev->keyboard.alt--;
             else if (!strcmp(keyname, "Shift_L"))
                dev->keyboard.shift--;
             else if (!strcmp(keyname, "Shift_R"))
                dev->keyboard.shift--;
             if (dev->keyboard.ctrl < 0) dev->keyboard.ctrl = 0;
             if (dev->keyboard.alt < 0) dev->keyboard.alt = 0;
             if (dev->keyboard.shift < 0) dev->keyboard.shift = 0;
             if (dev->keyboard.lock < 0) dev->keyboard.lock = 0;
          }

        /* sending ecore_input_evas events */
        Ecore_Event_Key *e;

        if (dev->keyboard.shift) offset = 1;
        else if (dev->keyboard.lock) offset = 2;

        const char *key = _ecore_fb_li_kbd_syms[(iev->code * 7) + offset];
        const char *compose = _ecore_fb_li_kbd_syms[(iev->code * 7) + 3 + offset];
        
        if (dev->keyboard.ctrl)
          {
             const char *ts = _ecore_fb_li_kbd_syms[(iev->code * 7) + 3 + 3];
             
             if (ts) compose = ts;
          }

        e = calloc(1, sizeof(Ecore_Event_Key) + strlen(key) +
                   strlen(keyname) + (compose ? strlen(compose) : 0) + 3);
        e->keyname = (char *)(e + 1);
        e->key = e->keyname + strlen(keyname) + 1;
        e->compose = (compose) ? e->key + strlen(key) + 1 : NULL;
        e->string = e->compose;

        strcpy((char *)e->keyname, keyname);
        strcpy((char *)e->key, key);
        if (compose)
          strcpy((char *)e->compose, compose);

        e->modifiers = 0;
        if (dev->keyboard.shift)
          e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
        if (dev->keyboard.ctrl) e->modifiers |= ECORE_EVENT_MODIFIER_CTRL;
        if (dev->keyboard.alt) e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
        if (dev->keyboard.lock) e->modifiers |= ECORE_EVENT_LOCK_CAPS;

        e->timestamp = ecore_loop_time_get() * 1000.0;
        e->window = (Ecore_Window)dev->window;
        e->event_window = (Ecore_Window)dev->window;
        e->root_window = (Ecore_Window)dev->window;
        e->same_screen = 1;

        if (iev->value)
          ecore_event_add(ECORE_EVENT_KEY_DOWN, e, NULL, NULL);
        else
          ecore_event_add(ECORE_EVENT_KEY_UP, e, NULL, NULL);
     }
   /* check for mouse button events */
   else if ((iev->code >= BTN_MOUSE) && (iev->code < BTN_JOYSTICK))
     {
        int button;
        Ecore_Event_Mouse_Button *e;
        double current = ecore_loop_time_get();

        button = ((iev->code & 0x00F) + 1);
        // swap 2 and 3 to make middle and right butotn work right.
        if (button == 3) button = 2;
        else if (button == 2) button = 3;
        if (iev->value)
          {
             dev->mouse.did_double = EINA_FALSE;
             dev->mouse.did_triple = EINA_FALSE;

             if (((current - dev->mouse.prev) <= dev->mouse.threshold) &&
                 (button == dev->mouse.prev_button))
               {
                  dev->mouse.did_double = EINA_TRUE;
                  if (((current - dev->mouse.last) <= (2 * dev->mouse.threshold)) &&
                      (button == dev->mouse.last_button))
                    {
                       dev->mouse.did_triple = EINA_TRUE;
                       /* reset */
                       dev->mouse.prev = 0;
                       dev->mouse.last = 0;
                       current = 0;
                    }
               }
             dev->mouse.last = dev->mouse.prev;
             dev->mouse.prev = current;
             dev->mouse.last_button = dev->mouse.prev_button;
             dev->mouse.prev_button = button;
          }

        e = calloc(1, sizeof(Ecore_Event_Mouse_Button));
        if (!e)
          return;

        e->timestamp = current * 1000.0;
        e->window = (Ecore_Window)dev->window;
        e->event_window = (Ecore_Window)dev->window;
        e->root_window = (Ecore_Window)dev->window;
        e->same_screen = 1;

        e->modifiers = 0;
        if (dev->keyboard.shift)
          e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
        if (dev->keyboard.ctrl) e->modifiers |= ECORE_EVENT_MODIFIER_CTRL;
        if (dev->keyboard.alt) e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
        if (dev->keyboard.lock) e->modifiers |= ECORE_EVENT_LOCK_CAPS;

        e->x = dev->mouse.x;
        e->y = dev->mouse.y;
        e->root.x = e->x;
        e->root.y = e->y;
        e->buttons = button;

        if (dev->mouse.did_double)
          e->double_click = 1;
        if (dev->mouse.did_triple)
          e->triple_click = 1;

        if (iev->value)
          ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL);
        else
          ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL);
     }
}
static void
_ecore_fb_li_device_event_rel(Ecore_Fb_Input_Device *dev, struct input_event *iev)
{
   if (!dev->listen) return;
   /* dispatch the button events if they are queued */
   switch (iev->code)
     {
     case REL_X:
     case REL_Y:
          {
             Ecore_Event_Mouse_Move *e;
             if (iev->code == REL_X)
               {
                  dev->mouse.x += iev->value;
                  if (dev->mouse.x > dev->mouse.w - 1)
                    dev->mouse.x = dev->mouse.w;
                  else if(dev->mouse.x < 0)
                    dev->mouse.x = 0;
               }
             else
               {
                  dev->mouse.y += iev->value;
                  if (dev->mouse.y > dev->mouse.h - 1)
                    dev->mouse.y = dev->mouse.h;
                  else if(dev->mouse.y < 0)
                    dev->mouse.y = 0;
               }

             e = calloc(1, sizeof(Ecore_Event_Mouse_Move));
             if (!e)
               return;

             e->window = (Ecore_Window)dev->window;
             e->event_window = (Ecore_Window)dev->window;
             e->root_window = (Ecore_Window)dev->window;
             e->same_screen = 1;

             e->modifiers = 0;
             if (dev->keyboard.shift) e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
             if (dev->keyboard.ctrl) e->modifiers |= ECORE_EVENT_MODIFIER_CTRL;
             if (dev->keyboard.alt) e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
             if (dev->keyboard.lock) e->modifiers |= ECORE_EVENT_LOCK_CAPS;

             e->x = dev->mouse.x;
             e->y = dev->mouse.y;
             e->root.x = e->x;
             e->root.y = e->y;

             e->timestamp = ecore_loop_time_get() * 1000.0;

             ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL);

             break;
          }
     case REL_WHEEL:
     case REL_HWHEEL:
          {
             Ecore_Event_Mouse_Wheel *e;

             e = calloc(1, sizeof(Ecore_Event_Mouse_Wheel));
             if (!e)
               return;

             e->x = dev->mouse.x;
             e->y = dev->mouse.y;
             if (iev->code == REL_HWHEEL) e->direction = 1;
             e->z = iev->value;
             e->root.x = dev->mouse.x;
             e->root.y = dev->mouse.y;

             e->window = (Ecore_Window)dev->window;
             e->event_window = (Ecore_Window)dev->window;
             e->root_window = (Ecore_Window)dev->window;
             e->same_screen = 1;

             e->modifiers = 0;
             if (dev->keyboard.shift) e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
             if (dev->keyboard.ctrl) e->modifiers |= ECORE_EVENT_MODIFIER_CTRL;
             if (dev->keyboard.alt) e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
             if (dev->keyboard.lock) e->modifiers |= ECORE_EVENT_LOCK_CAPS;

             e->timestamp = ecore_loop_time_get() * 1000.0;

             ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, e, NULL, NULL);

             break;
          }
     default:
        break;
     }
}
Ejemplo n.º 23
0
{
   if (_apply_delay) ecore_timer_del(_apply_delay);
   if (_fade_animator) ecore_animator_del(_fade_animator);
   _apply_delay = NULL;
   _fade_animator = NULL;
   _applying = EINA_FALSE;
   _fade_obj = NULL;
}

static Eina_Bool
_cb_delay_timer(void *data EINA_UNUSED)
{
   _apply_delay = NULL;
   _target_from = 255;
   _target_to = 0;
   _start_time = ecore_loop_time_get();
   _fade_animator = ecore_animator_add(_cb_fade_animator, NULL);
   return EINA_FALSE;
}

static Eina_Bool
_cb_fade_animator(void *data EINA_UNUSED)
{
   double t = ecore_loop_time_get() - _start_time;
   int v;

   t = t / 0.5;
   if (t < 0.0) t = 0.0;
   v = _target_from + ((_target_to - _target_from) * t);
   if (t >= 1.0) v = _target_to;
   evas_object_color_set(_fade_obj, 0, 0, 0, v);
Ejemplo n.º 24
0
/**
 * @brief Wait from another thread on the read side of a pipe.
 *
 * @param p The pipe to watch on.
 * @param message_count The minimal number of message to wait before exiting.
 * @param wait The amount of time in second to wait before exiting.
 * @return the number of message catched during that wait call.
 * @since 1.1
 *
 * Negative value for @p wait means infite wait.
 */
EAPI int
ecore_pipe_wait(Ecore_Pipe *p,
                int         message_count,
                double      wait)
{
   struct timeval tv, *t;
   fd_set rset;
   double end = 0.0;
   double timeout;
   int ret;
   int total = 0;

   EINA_MAIN_LOOP_CHECK_RETURN_VAL(-1);
   if (p->fd_read == PIPE_FD_INVALID)
     return -1;

   FD_ZERO(&rset);
   FD_SET(p->fd_read, &rset);

   if (wait >= 0.0)
     end = ecore_loop_time_get() + wait;
   timeout = wait;

   while (message_count > 0 && (timeout > 0.0 || wait <= 0.0))
     {
        if (wait >= 0.0)
          {
             /* finite() tests for NaN, too big, too small, and infinity.  */
              if ((!ECORE_FINITE(timeout)) || (timeout == 0.0))
                {
                   tv.tv_sec = 0;
                   tv.tv_usec = 0;
                }
              else if (timeout > 0.0)
                {
                   int sec, usec;
#ifdef FIX_HZ
                   timeout += (0.5 / HZ);
                   sec = (int)timeout;
                   usec = (int)((timeout - (double)sec) * 1000000);
#else
                   sec = (int)timeout;
                   usec = (int)((timeout - (double)sec) * 1000000);
#endif
                   tv.tv_sec = sec;
                   tv.tv_usec = usec;
                }
              t = &tv;
          }
        else
          {
             t = NULL;
          }

        ret = main_loop_select(p->fd_read + 1, &rset, NULL, NULL, t);

        if (ret > 0)
          {
             _ecore_pipe_read(p, NULL);
             message_count -= p->message;
             total += p->message;
             p->message = 0;
          }
        else if (ret == 0)
          {
             break;
          }
        else if (errno != EINTR)
          {
             close(p->fd_read);
             p->fd_read = PIPE_FD_INVALID;
             break;
          }

        if (wait >= 0.0)
          timeout = end - ecore_loop_time_get();
     }

   return total;
}
Ejemplo n.º 25
0
             *pixel++ = v;
        }

        pixel += padding;
   }
}

static void
_cb_post_render(Ecore_Evas *ee EINA_UNUSED)
{
   void *data;

   // Get pixel data and update.
   data = ecore_buffer_data_get(win.buffer);
   paint_pixels(data, 0, WIDTH, HEIGHT, ecore_loop_time_get() * 1000);
   evas_object_image_data_set(win.img, data);
   evas_object_image_data_update_add(win.img, 0, 0, WIDTH, HEIGHT);
}

int
main(void)
{
   Evas_Object *o;
   void *data;

   eina_init();
   ecore_init();
   ecore_evas_init();
   ecore_buffer_init();
Ejemplo n.º 26
0
/* local subsystem functions */
static Eina_Bool
_cb_key_down(__UNUSED__ void *data, __UNUSED__ int type, void *event)
{
   Ecore_Event_Key *ev;

   ev = event;
   if (ev->event_window != input_window) return ECORE_CALLBACK_PASS_ON;
   if (!strcmp(ev->key, "Escape"))
     e_syscon_hide();
   else if (!strcmp(ev->key, "Up"))
     {
        // FIXME: implement focus and key control... eventually
     }
   else if (!strcmp(ev->key, "Down"))
     {
        // FIXME: implement focus and key control... eventually
     }
   else if (!strcmp(ev->key, "Left"))
     {
        // FIXME: implement focus and key control... eventually
     }
   else if (!strcmp(ev->key, "Right"))
     {
        // FIXME: implement focus and key control... eventually
     }
   else if (!strcmp(ev->key, "Tab"))
     {
        // FIXME: implement focus and key control... eventually
     }
   else if (!strcmp(ev->key, "Enter"))
     {
        // FIXME: implement focus and key control... eventually
     }
   else
     {
        E_Action *act;
        double t;
        
        t = ecore_loop_time_get();
        if (t - show_time > 0.5)
          {
             act = e_bindings_key_down_event_find(E_BINDING_CONTEXT_ANY, ev);
             if ((act) && (act->name))
               {
                  if (!strcmp(act->name, "syscon"))
                    {
                       if (popup)
                         {
                            e_syscon_show(popup->zone, do_defact);
                         }
                    }
                  else
                    {
                       Eina_List *l;
                       
                       for (l = e_config->syscon.actions; l; l = l->next)
                         {
                            E_Config_Syscon_Action *sca;
                            
                            if (!(sca = l->data)) continue;
                            if (!sca->action) continue;
                            if (!strcmp(sca->action, act->name))
                              {
                                 act_count++;
                                 if (act_count > 2)
                                   {
                                      act->func.go(NULL, sca->params);
                                      e_syscon_hide();
                                      break;
                                   }
                              }
                         }
                    }
               }
          }
     }

   return ECORE_CALLBACK_PASS_ON;
}
Ejemplo n.º 27
0
EAPI void
efreet_mime_type_cache_flush(void)
{
    efreet_mime_icons_flush(ecore_loop_time_get());
}
Ejemplo n.º 28
0
             _edje_seat_emit(ed, ev->device, buf, rp->part->name);
          }

        ev->event_flags |= rp->mask_flags;
     }
}

void
_edje_timer_cb(void *data, const Efl_Event *event EINA_UNUSED)
{
   double t;
   Eina_List *l;
   Eina_List *newl = NULL;
   Edje *ed = data;

   t = ecore_loop_time_get();
   _edje_ref(ed);

   _edje_block(ed);
   _edje_util_freeze(ed);
   if ((!ed->paused) && (!ed->delete_me))
     {
        Edje_Running_Program *tmp;

        ed->walking_actions = EINA_TRUE;
        EINA_LIST_FOREACH(ed->actions, l, tmp)
          {
             tmp->ref++;
             newl = eina_list_append(newl, tmp);
          }
        while (newl)
Ejemplo n.º 29
0
static void
_itask_item_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
   Evas_Event_Mouse_Down *ev;
   Itask_Item *ic;
   Evas_Coord x, y, w, h;
   E_Menu *mn = NULL;
   int cx, cy, cw, ch, dir;

   ev = event_info;
   ic = data;

   if (ev->button == 1)
     {
	ic->drag.x = ev->output.x;
	ic->drag.y = ev->output.y;
	ic->drag.start = 1;
	ic->drag.dnd = 0;
	ic->time_press = ecore_loop_time_get();
     }
   else if (ev->button == 3)
     {
	if (ic->border)
	  {
	     evas_object_geometry_get(ic->o_holder, &x, &y, &w, &h);
	     e_gadcon_canvas_zone_geometry_get(ic->itask->gcc->gadcon,
					       &cx, &cy, &cw, &ch);
	     x += cx;
	     y += cy;

	     e_int_border_menu_show(ic->border, x, y, 0, ev->timestamp);
	  }
     }
   else if (ev->button == 2)
     {
     }
   if (mn)
     {
	e_menu_post_deactivate_callback_set(mn, _itask_item_cb_menu_post, NULL);

	evas_object_geometry_get(ic->o_holder, &x, &y, &w, &h);
	e_gadcon_canvas_zone_geometry_get(ic->itask->gcc->gadcon,
					  &cx, &cy, &cw, &ch);
	x += cx;
	y += cy;

	dir = E_MENU_POP_DIRECTION_AUTO;
	switch (ic->itask->gcc->gadcon->orient)
	  {
	   case E_GADCON_ORIENT_TOP:
	   case E_GADCON_ORIENT_CORNER_TL:
	   case E_GADCON_ORIENT_CORNER_TR:
	      dir = E_MENU_POP_DIRECTION_DOWN;
	      break;
	   case E_GADCON_ORIENT_BOTTOM:
	   case E_GADCON_ORIENT_CORNER_BL:
	   case E_GADCON_ORIENT_CORNER_BR:
	      dir = E_MENU_POP_DIRECTION_UP;
	      break;
	   case E_GADCON_ORIENT_LEFT:
	   case E_GADCON_ORIENT_CORNER_LT:
	   case E_GADCON_ORIENT_CORNER_LB:
	      dir = E_MENU_POP_DIRECTION_RIGHT;
	      break;
	   case E_GADCON_ORIENT_RIGHT:
	   case E_GADCON_ORIENT_CORNER_RT:
	   case E_GADCON_ORIENT_CORNER_RB:
	      dir = E_MENU_POP_DIRECTION_LEFT;
	      break;
	   case E_GADCON_ORIENT_FLOAT:
	   case E_GADCON_ORIENT_HORIZ:
	   case E_GADCON_ORIENT_VERT:
	   default:
	      dir = E_MENU_POP_DIRECTION_AUTO;
	      break;
	  }
	e_menu_activate_mouse(mn,
			      e_util_zone_current_get(e_manager_current_get()),
			      x, y, w, h, dir, ev->timestamp);
     }
}