Ejemplo n.º 1
0
int
main(void)
{
   double done;
   eina_init();
   ecore_init();
   ecore_con_init();

   eina_log_domain_level_set("ecore_con", EINA_LOG_LEVEL_ERR);
   eina_log_domain_level_set("eina", EINA_LOG_LEVEL_ERR);
   counter = eina_counter_new("client");
   eina_counter_start(counter);
   done = ecore_time_get();

   ecore_job_add(_spawn, NULL);

/* set event handler for server connect */
   ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb)_add, NULL);
   ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb)_del, NULL);

/* start client */
   ecore_main_loop_begin();
   eina_counter_stop(counter, 1);
   printf("\nTime elapsed for %i connections: %f seconds\n%s", NUM_CLIENTS, ecore_time_get() - done, eina_counter_dump(counter));
   return 0;
}
Ejemplo n.º 2
0
static Eina_Bool
_ecore_con_url_idler_handler(void *data)
{
   double start;
   int done = 1, still_running;

   start = ecore_time_get();
   while (curl_multi_perform(curlm, &still_running) == CURLM_CALL_MULTI_PERFORM)
     /* make this not more than a frametime to keep interactivity high */
     if ((ecore_time_get() - start) > ecore_animator_frametime_get())
       {
	  done = 0;
	  break;
       }

   _ecore_con_url_process_completed_jobs(NULL);

   if (done)
     {
	_ecore_con_url_restart_fd_handler();
	_fd_idler_handler = NULL;

	if (!_url_con_list)
	  ecore_timer_freeze(_curl_timeout);
	return data == (void*) 0xACE ? ECORE_CALLBACK_RENEW : ECORE_CALLBACK_CANCEL;
     }

   return ECORE_CALLBACK_RENEW;
}
Ejemplo n.º 3
0
int
_battery_openbsd_start(void)
{
   int mib[] = {CTL_HW, HW_SENSORS, 0, 0, 0};
   int devn;
   struct sensordev snsrdev;
   size_t sdlen = sizeof(struct sensordev);

   for (devn = 0;; devn++) {
        mib[2] = devn;
        if (sysctl(mib, 3, &snsrdev, &sdlen, NULL, 0) == -1)
          {
             if (errno == ENXIO)
               continue;
             if (errno == ENOENT)
               break;
          }

        if (!strcmp("acpibat0", snsrdev.xname))
          {
             if (!(bat = E_NEW(Battery, 1)))
               return 0;
             bat->udi = eina_stringshare_add("acpibat0"),
             bat->mib = malloc(sizeof(int) * 5);
             if (!bat->mib) return 0;
             bat->mib[0] = mib[0];
             bat->mib[1] = mib[1];
             bat->mib[2] = mib[2];
             bat->technology = eina_stringshare_add("Unknow");
             bat->model = eina_stringshare_add("Unknow");
             bat->vendor = eina_stringshare_add("Unknow");
             bat->last_update = ecore_time_get();
             bat->poll = ecore_poller_add(ECORE_POLLER_CORE,
                                          battery_config->poll_interval,
                                          _battery_openbsd_battery_update_poll, NULL);
             device_batteries = eina_list_append(device_batteries, bat);
          }
        else if (!strcmp("acpiac0", snsrdev.xname))
          {
             if (!(ac = E_NEW(Ac_Adapter, 1)))
               return 0;
             ac->udi = eina_stringshare_add("acpiac0");
             ac->mib = malloc(sizeof(int) * 5);
             if (!ac->mib) return 0;
             ac->mib[0] = mib[0];
             ac->mib[1] = mib[1];
             ac->mib[2] = mib[2];
             device_ac_adapters = eina_list_append(device_ac_adapters, ac);
          }
     }

   _battery_openbsd_battery_update();

   init_time = ecore_time_get();
   return 1;
}
Ejemplo n.º 4
0
int
main(void)
{
   double start;
   Eina_Hash *headers;

   eina_init();
   ecore_init();
   ecore_file_init();

   if (ecore_file_exists(DST))
     ecore_file_unlink(DST);

   start = ecore_time_get();

   if (ecore_file_download(URL, DST, completion_cb, progress_cb, NULL, NULL))
     {
        printf("Download started successfully:\n  URL: %s\n  DEST: %s\n", URL, DST);
        ecore_main_loop_begin();
        printf("\nTime elapsed: %f seconds\n", ecore_time_get() - start);
        printf("Downloaded %lld bytes\n", ecore_file_size(DST));
     }
   else
     {
        printf("Error, can't start download\n");
        goto done;
     }

   headers = eina_hash_string_small_new(NULL);
   eina_hash_add(headers, "Content-type", "application/x-gzip");

   if (ecore_file_download_full(URL, DST_MIME, completion_cb, progress_cb, NULL, NULL, headers))
     {
        printf("Download started successfully:\n  URL: %s\n  DEST: %s\n", URL, DST_MIME);
        ecore_main_loop_begin();
        printf("\nTime elapsed: %f seconds\n", ecore_time_get() - start);
        printf("Downloaded %lld bytes\n", ecore_file_size(DST));
     }
   else
     {
        printf("Error, can't start download\n");
        goto done;
     }

done:
   if (headers) eina_hash_free(headers);
   ecore_file_shutdown();
   ecore_shutdown();
   eina_shutdown();
   return 0;
}
Ejemplo n.º 5
0
void XmasWidget::_Animator()
{
        double d;

        for (uint i = 0;i < flakes.size();i++)
        {
                Flake *flake = flakes[i];
                Evas_Coord _y;

                d = ecore_time_get() - flake->getStart();
                _y = 30 * d * flake->getSpeed();
                if (_y > cliph)
                        flake->setStart(ecore_time_get() + (double)(random() % 100) / (double)100);
                flake->Move(flake->getX(), _y + clipy);
        }
}
Ejemplo n.º 6
0
/**
 * Resumes a frozen (paused) timer.
 *
 * @param timer The timer to be resumed.
 *
 * The timer will be resumed from its previous relative position in time. That
 * means, if it had X seconds remaining until expire when it was paused, it will
 * be started now with those same X seconds remaining to expire again. But
 * notice that the interval time won't be touched by this call or by
 * ecore_timer_freeze().
 *
 * @see ecore_timer_freeze()
 */
EAPI void
ecore_timer_thaw(Ecore_Timer *timer)
{
   double now;

   _ecore_lock();

   if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER))
     {
        ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
                         "ecore_timer_thaw");
        goto unlock;
     }

   /* Timer not frozen */
   if (!timer->frozen)
     goto unlock;

   suspended = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));
   now = ecore_time_get();

   _ecore_timer_set(timer, timer->pending + now, timer->in, timer->func, timer->data);
unlock:
   _ecore_unlock();
}
Ejemplo n.º 7
0
/**
 * Get the pending time regarding a timer.
 *
 * @param        timer The timer to learn from.
 * @ingroup        Ecore_Time_Group
 */
EAPI double
ecore_timer_pending_get(Ecore_Timer *timer)
{
   double now;
   double ret = 0.0;

   _ecore_lock();

   if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER))
     {
        ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
                         "ecore_timer_pending_get");
        goto unlock;
     }

   now = ecore_time_get();

   if (timer->frozen)
     ret = timer->pending;
   else
     ret = timer->at - now;
unlock:
   _ecore_unlock();
   return ret;
}
Ejemplo n.º 8
0
/**
 * Creates a timer to call the given function in the given period of time.
 * @param   in   The interval in seconds.
 * @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 function adds a timer and returns its handle on success and NULL on
 * failure. The function @p func will be called every @p in seconds. The
 * function will be passed the @p data pointer as its parameter.
 *
 * When the timer @p func is called, it must return a value of either 1
 * (or ECORE_CALLBACK_RENEW) or 0 (or ECORE_CALLBACK_CANCEL).
 * If it returns 1, it will be called again at the next tick, or if it returns
 * 0 it will be deleted automatically making any references/handles for it
 * invalid.
 */
EAPI Ecore_Timer *
ecore_timer_add(double        in,
                Ecore_Task_Cb func,
                const void   *data)
{
   double now;
   Ecore_Timer *timer = NULL;

   _ecore_lock();
   if (!func) goto unlock;
   if (in < 0.0) in = 0.0;
   timer = ecore_timer_calloc(1);
   if (!timer) goto unlock;
   ECORE_MAGIC_SET(timer, ECORE_MAGIC_TIMER);
   now = ecore_time_get();

#ifdef WANT_ECORE_TIMER_DUMP
   timer->timer_bt_num = backtrace((void **)(timer->timer_bt),
                                   ECORE_TIMER_DEBUG_BT_NUM);
#endif

   _ecore_timer_set(timer, now + in, in, func, (void *)data);
unlock:
   _ecore_unlock();
   return timer;
}
Ejemplo n.º 9
0
EAPI void
ecore_timer_freeze(Ecore_Timer *timer)
{
   double now;

   if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER))
     {
        ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
                         "ecore_timer_freeze");
        return ;
     }

   /* Timer already frozen */
   if (timer->frozen)
     return ;

   timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
   suspended = (Ecore_Timer *) eina_inlist_prepend(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer));

   now = ecore_time_get();

   timer->pending = timer->at - now;
   timer->at = 0.0;
   timer->frozen = 1;
}
Ejemplo n.º 10
0
/*** internal plugin functions ***/
static int
_container_scroll_timer(void *data)
{
  Container *cont = data;
  double dt, dx, size, pad, max_scroll;
 
  dt = ecore_time_get() - cont->scroll.start_time;
  dx = 10 * (1 - exp(-dt)); 

  cont->scroll.offset += dx * cont->scroll.velocity;
  
  size = cont->direction ? cont->h : cont->w;
  pad = cont->direction ? cont->padding.t + cont->padding.b :
                              cont->padding.l + cont->padding.r;
  max_scroll = size - cont->length - pad;

  if (cont->scroll.offset < max_scroll)
  {
    cont->scroll.offset = max_scroll;
    _default_scroll_stop(cont);
  } 
  else if (cont->scroll.offset > 0)
  {
    cont->scroll.offset = 0;
    _default_scroll_stop(cont);
  }
    
  _default_layout(cont);
  return 1;
}
Ejemplo n.º 11
0
/* TODO: Documentation says "All  implementations  support  the  system-wide
 * real-time clock, which is identified by CLOCK_REALTIME. Check if the fallback
 * to unix time (without specifying the resolution) might be removed
 */
void
_ecore_time_init(void)
{
#ifdef HAVE_CLOCK_GETTIME
   struct timespec t;

   if (_ecore_time_clock_id != -1) return;

   if (!clock_gettime(CLOCK_MONOTONIC, &t))
     {
        _ecore_time_clock_id = CLOCK_MONOTONIC;
        DBG("using CLOCK_MONOTONIC.");
     }
   else if (!clock_gettime(CLOCK_REALTIME, &t))
     {
        /* may go backwards */
        _ecore_time_clock_id = CLOCK_REALTIME;
        WRN("CLOCK_MONOTONIC not available. Fallback to CLOCK_REALTIME.");
     }
   else
     {
        _ecore_time_clock_id = -2;
        CRIT("Cannot get a valid clock_gettime() clock id! "
             "Fallback to unix time.");
     }
#else
# ifndef HAVE_EVIL
#  warning "Your platform isn't supported yet"
   CRIT("Platform does not support clock_gettime. "
        "Fallback to unix time.");
# endif
#endif

   _ecore_time_loop_time = ecore_time_get();
}
Ejemplo n.º 12
0
/**
 * @internal
 * @param w: The widget to work with
 * @ev_data: The Ewl_Event_Mouse_Down data
 * @param data: The scrollport
 * @return Returns no value
 * @brief The mouse down function for kinetic scrolling
 */
static void
ewl_scrollport_kinetic_cb_mouse_down_embedded(Ewl_Widget *w, void *ev,
                void *data)
{
        Ewl_Scrollport *s;
        Ewl_Event_Mouse *md;
        Ewl_Scrollport_Kinetic_Info_Embedded *info;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR(ev);
        DCHECK_PARAM_PTR(data);
        DCHECK_TYPE(w, EWL_WIDGET_TYPE);

        s = EWL_SCROLLPORT(data);
        md = EWL_EVENT_MOUSE(ev);
        info = s->kinfo->extra;
        s->kinfo->clicked = !!TRUE;
        s->kinfo->active = !!FALSE;

        memset(&(info->back[0]), 0, sizeof(info->back[0]) * HIST_NUM);
        info->back[0].x = md->x;
        info->back[0].y = md->y;
        info->back[0].time = ecore_time_get();
        info->xs = md->x;
        info->ys = md->y;

        DLEAVE_FUNCTION(DLEVEL_STABLE);
}
Ejemplo n.º 13
0
int
main(int argc, char **argv)
{
   double interval = 0.3; // tick each 0.3 seconds
   Ecore_Poller *poller1, *poller2;
   char *str1 = "poller1";
   char *str2 = "poller2";

   if (!ecore_init())
     {
        printf("ERROR: Cannot init Ecore!\n");
        return -1;
     }

   _initial_time = ecore_time_get();

   ecore_poller_poll_interval_set(ECORE_POLLER_CORE, interval);

   poller1 = ecore_poller_add(ECORE_POLLER_CORE, 4, _poller_print_cb, str1);
   poller2 = ecore_poller_add(ECORE_POLLER_CORE, 8, _poller_print_cb, str2);

   ecore_main_loop_begin();

   printf("changing poller2 interval to 16\n");

   ecore_poller_poller_interval_set(poller2, 16);
   ecore_main_loop_begin();

   ecore_poller_del(poller1);
   ecore_poller_del(poller2);

   ecore_shutdown();
}
Ejemplo n.º 14
0
Eina_List *
eio_pack_send(Ecore_Thread *thread, Eina_List *pack, double *start)
{
   double current;

   current = ecore_time_get();
   if (current - *start > EIO_PACKED_TIME)
     {
        *start = current;
        ecore_thread_feedback(thread, pack);
        return NULL;
     }

   if (memory_pool_limit > 0 &&
       memory_pool_usage > memory_pool_limit)
     {
        eina_lock_take(&(memory_pool_mutex));
        memory_pool_suspended = EINA_TRUE;
        eina_condition_wait(&(memory_pool_cond));
        memory_pool_suspended = EINA_FALSE;
        eina_lock_release(&(memory_pool_mutex));
     }

   return pack;
}
Ejemplo n.º 15
0
static void
_eio_file_heavy(void *data, Ecore_Thread *thread)
{
   Eio_File_Char_Ls *async = data;
   Eina_Iterator *ls;
   const char *file;
   Eina_List *pack = NULL;
   double start;

   ls = eina_file_ls(async->ls.directory);
   if (!ls)
     {
	eio_file_thread_error(&async->ls.common, thread);
	return;
     }

   eio_file_container_set(&async->ls.common, eina_iterator_container_get(ls));

   start = ecore_time_get();

   EINA_ITERATOR_FOREACH(ls, file)
     {
	Eina_Bool filter = EINA_TRUE;

	if (async->filter_cb)
	  {
	     filter = async->filter_cb((void*) async->ls.common.data, &async->ls.common, file);
	  }

	if (filter)
          {
             Eio_File_Char *send_fc;

             send_fc = eio_char_malloc();
             if (!send_fc) goto on_error;

             send_fc->filename = file;
	     send_fc->associated = async->ls.common.worker.associated;
	     async->ls.common.worker.associated = NULL;

	     pack = eina_list_append(pack, send_fc);
          }
	else
          {
          on_error:
             eina_stringshare_del(file);

             if (async->ls.common.worker.associated)
               {
                  eina_hash_free(async->ls.common.worker.associated);
                  async->ls.common.worker.associated = NULL;
               }
          }

        pack = eio_pack_send(thread, pack, &start);

	if (ecore_thread_check(thread))
	  break;
     }
Ejemplo n.º 16
0
int
ef_mime_cb_get(void)
{
   const char *mime = NULL, *icon;
   int misses = 0, i = 0;
   struct
     {
        char *file;
        char *mime;
     } files[] = {
        {"test_type.desktop", "application/x-desktop"},
        {"entry.png", "image/png"},
        {"entry", "image/png"},
        {"sub", "inode/directory"},
        { }
     };
   double start;

   if (!efreet_mime_init())
     {
        printf("Could not init efreet\n");
        return 1;
     }

   for (i = 0; files[i].file; ++i)
     {
        mime = efreet_mime_type_get(ef_test_path_get(files[i].file));
        if (!mime)
          {
             printf("Got %s as null instead of %s\n", files[i].file, files[i].mime);
             misses ++;
          }
        else if (strcmp(mime, files[i].mime))
          {
             printf("Got %s as %s instead of %s\n", files[i].file, mime, files[i].mime);
             misses ++;
          }
        start = ecore_time_get();
        icon = efreet_mime_type_icon_get(files[i].mime, THEME, SIZE);
        printf("mime icon: %s %s %f\n", files[i].mime, icon, ecore_time_get() - start);
     }

   efreet_mime_shutdown();

   return !misses;
}
Ejemplo n.º 17
0
static void
_ecore_poller_next_tick_eval(void)
{
   int i;
   double interval;

   min_interval = -1;
   for (i = 0; i < 15; i++)
     {
        if (pollers[i])
          {
             min_interval = i;
             break;
          }
     }
   if (min_interval < 0)
     {
        /* no pollers */
         if (timer)
           {
              ecore_timer_del(timer);
              timer = NULL;
           }
         return;
     }
   interval_incr = (1 << min_interval);
   interval = interval_incr * poll_interval;
   /* we are at the tick callback - so no need to do inter-tick adjustments
    * so we can fasttrack this as t -= last_tick in theory is 0.0 (though
    * in practice it will be a very very very small value. also the tick
    * callback will adjust the timer interval at the end anyway */
   if (at_tick)
     {
        if (!timer)
          timer = ecore_timer_add(interval, _ecore_poller_cb_timer, NULL);
     }
   else
     {
        double t;

        if (!timer)
          timer = ecore_timer_add(interval, _ecore_poller_cb_timer, NULL);
        else
          {
             t = ecore_time_get();
             if (interval != poll_cur_interval)
               {
                  t -= last_tick; /* time since we last ticked */
     /* delete the timer and reset it to tick off in the new
      * time interval. at the tick this will be adjusted */
                  ecore_timer_del(timer);
                  timer = ecore_timer_add(interval - t,
                                          _ecore_poller_cb_timer, NULL);
               }
          }
     }
   poll_cur_interval = interval;
}
Ejemplo n.º 18
0
static int 
ecore_idle(void *data)
{
    static double       last = 0;
    static int          cnt = 0;


    cnt += fpsflag;
    if (cnt == 100)
      {
          cnt = 0;
          printf("%f\n", 1 / ((ecore_time_get() - last) / 100));
          last = ecore_time_get();
      }
    gui_apply();
    gra_apply();
    return 1;
}
Ejemplo n.º 19
0
static Eina_Bool
_poller_print_cb(void *data)
{
   char *str = data;
   printf("Ecore Poller '%s' callback called after %0.3f seconds.\n",
          str, ecore_time_get() - _initial_time);

   return ECORE_CALLBACK_RENEW;
}
Ejemplo n.º 20
0
static void
_load_done_cb(void          *data,
              Enlil_Load    *load,
              int            nb_albums __UNUSED__,
              int            nb_photos __UNUSED__)
{
   Enlil_Library *library = (Enlil_Library *)data;

   enlil_load_free(&load);

   t = ecore_time_get();
   double _time = t - t0;
   LOG_ERR("Load Time: %f sec)", _time);

   t0_sync = ecore_time_get();
   Enlil_Sync *_sync = enlil_library_sync_get(library);
   enlil_sync_job_all_add(_sync);
}
Ejemplo n.º 21
0
void EventSenderProxy::mouseUp(unsigned button, WKEventModifiers wkModifiers)
{
    sendOrQueueEvent(WTREvent(WTREventTypeMouseUp, 0, wkModifiers, evasMouseButton(button)));

    if (m_mouseButton == button)
        m_mouseButton = kWKEventMouseButtonNoButton;

    m_clickPosition = m_position;
    m_clickTime = ecore_time_get();
}
Ejemplo n.º 22
0
static double 
_elitaire_card_job_frametime_get(Elitaire_Card_Job * job)
{
    double ft;

    if (job->t == 0.0) {
        Elitaire_Card * ecard;

        ecard = (Elitaire_Card *) evas_object_smart_data_get(job->card);
        ft = 1.0 / ecard->eli->frame_rate;
        job->t = ecore_time_get();
    }
    else {
        double nt;

        nt = ecore_time_get();
        ft = nt - job->t;
        job->t = nt;
    }

    return ft;
}
Ejemplo n.º 23
0
int
_battery_fso_start(void)
{
   conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
   if (!conn) return 0;

   /* Initiate the battery gadget */
   Battery *bat;
   const char *udi = "FSO";
   bat = _battery_battery_find( udi );
   if (!bat)
     {
        bat = E_NEW(Battery, 1);
        if (!bat) return 0;
        bat->udi = eina_stringshare_add(udi);
        device_batteries = eina_list_append(device_batteries, bat);
     }
   battery = bat;

   /* Get initial status */
   _battery_fso_get_capacity( bat );
   _battery_fso_get_powerstatus( bat );

/* Add signal listeners for PowerSupply.Capacity and PowerSupply.PowerStatus */
if( conn ) {
   nameowner_handler = e_dbus_signal_handler_add(conn,
         "org.freedesktop.DBus",
         "/org/freedesktop/DBus",
         "org.freedesktop.DBus",
         "NameOwnerChanged",
         _battery_fso_on_nameowner_change, bat);

   capacity_handler = e_dbus_signal_handler_add( conn,
         "org.freesmartphone.odeviced",
         "/org/freesmartphone/Device/PowerSupply",
         "org.freesmartphone.Device.PowerSupply",
         "Capacity",
         _battery_fso_on_capacity_change, bat );

   powerstatus_handler = e_dbus_signal_handler_add( conn,
         "org.freesmartphone.odeviced",
         "/org/freesmartphone/Device/PowerSupply",
         "org.freesmartphone.Device.PowerSupply",
         "PowerStatus",
         _battery_fso_on_powerstatus_change, bat );
   }

   init_time = ecore_time_get();
   return 1;
}
Ejemplo n.º 24
0
int 
_ex_file_download_progress_cb(void *data, const char *file, long int dltotal, long int dlnow, long int ultotal, long int ulnow)
{
   double fraction;
   char text[42];
   static long int last;
   static double t_last;
   long int diff;
   double t_diff;
   double kbytes;
   static double total_kbytes;

   if (dlnow == 0 || dltotal == 0)
     return 0;

   if (!total_kbytes)
     total_kbytes = (double) ((((double)dltotal) / 1024));

   if (last)
     {
	diff = dlnow - last;
	t_diff = ecore_time_get() - t_last;
	kbytes = (double) ((((double) diff) / 1024));
	fraction = (double) ((double) dlnow) / ((double) dltotal);
	etk_progress_bar_fraction_set(ETK_PROGRESS_BAR(progressbar), fraction);
	snprintf(text, sizeof(text), "%d%% done at %.0f kb/s (%.0f of %.0f kb)", 
	      (int) (fraction * 100.0),
	      kbytes / t_diff,
	      kbytes, total_kbytes);
	etk_progress_bar_text_set(ETK_PROGRESS_BAR(progressbar), text);
     }

   t_last = ecore_time_get();
   last = dlnow;
   
   return 0;
}
Ejemplo n.º 25
0
bool XmasWidget::LoadWidget(std::string, double _x, double _y, std::string _id)
{
        std::string witem = "calaos/widget/xmas";
        if (!LoadEdje(witem))
        {
                return false;
        }

        setLayer(500);
        EdjeObject::Show();

        clip = evas_object_rectangle_add(evas);
        evas_object_show(clip);
        edje_object_part_swallow(edje, "widget.swallow", clip);

        Resize(1024, 768);

        //create some flakes
        for (int i = 0;i < MAX_FLAKE;i++)
        {
                std::string type;
                if (i < MAX_FLAKE / 3) type = "flake_small";
                else if (i >= MAX_FLAKE / 3 && i < (MAX_FLAKE / 3) * 2) type = "flake_medium";
                else type = "flake_large";

                EdjeObject *o = new EdjeObject(theme, evas);
                if (!o->LoadEdje("calaos/widget/xmas/" + type))
                    cError() << "Error loading edje group calaos/widget/xmas/" + type;
                o->setLayer(500);
                evas_object_clip_set(o->getEvasObject(), clip);

                Flake *flake = new Flake(o);

                int tx = random() % clipw;
                int ty = random() % cliph;

                flake->Move(tx + clipx, ty + clipy);
                flake->Show();
                flake->setStart(ecore_time_get() + (double)(random() % (flake->getHeight() * 10)) / (double)flake->getHeight());

                if (type == "flake_small") flake->setSpeed(1);
                if (type == "flake_medium") flake->setSpeed(2);
                if (type == "flake_large") flake->setSpeed(3);

                flakes.push_back(flake);
        }

        return true;
}
static void
_timer_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;

   _ecore_lock();
   now = ecore_time_get();

   Ecore_Timer_Private_Data *timer = _pd;
   _ecore_timer_add(obj, timer, now, in, func, data);
   _ecore_unlock();
}
Ejemplo n.º 27
0
void GestureHandler::handlePan(const IntPoint& point)
{
    m_currentPoint = point;
    m_isCurrentPointUpdated = true;

    // Save current point to use to calculate offset of flick.
    HistoryItem item = { m_currentPoint, ecore_time_get() };
    if (m_history.size() < m_history.capacity())
        m_history.uncheckedAppend(item);
    else {
        m_history[m_oldestHistoryItemIndex++] = item;
        if (m_oldestHistoryItemIndex == m_history.capacity())
            m_oldestHistoryItemIndex = 0;
    }
}
Ejemplo n.º 28
0
/**
 * Creates a timer to call the given function in the given period of time.
 * @param   in   The interval in seconds.
 * @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 function adds a timer and returns its handle on success and NULL on
 * failure. The function @p func will be called every @p in seconds. The
 * function will be passed the @p data pointer as its parameter.
 *
 * When the timer @p func is called, it must return a value of either 1
 * (or ECORE_CALLBACK_RENEW) or 0 (or ECORE_CALLBACK_CANCEL).
 * If it returns 1, it will be called again at the next tick, or if it returns
 * 0 it will be deleted automatically making any references/handles for it
 * invalid.
 */
EAPI Ecore_Timer *
ecore_timer_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_time_get();
   _ecore_timer_set(timer, now + in, in, func, (void *)data);
   return timer;
}
Ejemplo n.º 29
0
/* TODO: Documentation says "All  implementations  support  the  system-wide
 * real-time clock, which is identified by CLOCK_REALTIME. Check if the fallback
 * to unix time (without specifying the resolution) might be removed
 */
void
_ecore_time_init(void)
{
#if defined (HAVE_CLOCK_GETTIME) || defined (EXOTIC_PROVIDE_CLOCK_GETTIME)
   struct timespec t;

   if (_ecore_time_clock_id != -1) return;

   if (!clock_gettime(CLOCK_MONOTONIC, &t))
     {
        _ecore_time_clock_id = CLOCK_MONOTONIC;
        DBG("using CLOCK_MONOTONIC.");
     }
   else if (!clock_gettime(CLOCK_REALTIME, &t))
     {
        /* may go backwards */
         _ecore_time_clock_id = CLOCK_REALTIME;
         WRN("CLOCK_MONOTONIC not available. Fallback to CLOCK_REALTIME.");
     }
   else
     {
        _ecore_time_clock_id = -2;
        CRI("Cannot get a valid clock_gettime() clock id! "
             "Fallback to unix time.");
     }
#else
# ifndef HAVE_EVIL
#  if defined(__APPLE__) && defined(__MACH__)
   mach_timebase_info_data_t info;
   kern_return_t err = mach_timebase_info(&info);
   if (err == 0)
     {
        _ecore_time_clock_conversion = 1e-9 * (double)info.numer / (double)info.denom;
     }
   else
     {
        WRN("Unable to get timebase info. Fallback to nanoseconds.");
     }
#  else
#  warning "Your platform isn't supported yet"
   CRI("Platform does not support clock_gettime. "
       "Fallback to unix time.");
#  endif
# endif
#endif

   _ecore_time_loop_time = ecore_time_get();
}
int
main(int argc, char **argv)
{
   double interval = 0.3; // tick each 0.3 seconds
   Ecore_Poller *poller1, *poller2, *poller3;
   char *str1 = "poller1";
   char *str2 = "poller2";
   char *str3 = "poller3";

   if (!ecore_init())
     {
        printf("ERROR: Cannot init Ecore!\n");
        return -1;
     }

   _initial_time = ecore_time_get();

   ecore_poller_poll_interval_set(ECORE_POLLER_CORE, interval);

//   poller1 = ecore_poller_add(ECORE_POLLER_CORE, 4, _poller_print_cb, str1);
//   poller2 = ecore_poller_add(ECORE_POLLER_CORE, 8, _poller_print_cb, str2);
  // poller3 = ecore_poller_add(ECORE_POLLER_CORE, 30, _poller_quit_cb, str3);

   poller1 = eo_add_custom(ECORE_POLLER_CLASS, NULL,
         ecore_poller_constructor(ECORE_POLLER_CORE, 4, _poller_print_cb, str1));
   poller2 = eo_add_custom(ECORE_POLLER_CLASS, NULL,
         ecore_poller_constructor(ECORE_POLLER_CORE, 8, _poller_print_cb, str2));
   poller3 = eo_add_custom(ECORE_POLLER_CLASS, NULL,
         ecore_poller_constructor(ECORE_POLLER_CORE, 20, _poller_quit_cb, str3));


   ecore_main_loop_begin();

   printf("changing poller2 interval to 16\n");

//   ecore_poller_poller_interval_set(poller2, 16);
   eo_do(poller2, ecore_poller_interval_set(16, NULL));
   ecore_main_loop_begin();

   eo_unref(poller1);
   eo_unref(poller2);
   eo_unref(poller3);
//   ecore_poller_del(poller1);
//   ecore_poller_del(poller2);
//   ecore_poller_del(poller3);

   ecore_shutdown();
}