Exemple #1
0
EAPI void
e_scale_update(void)
{
   int dpi;
   char buf[128];

   if (e_config->scale.use_dpi)
     {
	dpi = ecore_x_dpi_get();
	e_scale = (double)dpi / (double)e_config->scale.base_dpi;
	if (e_scale > e_config->scale.max) e_scale = e_config->scale.max;
	else if (e_scale < e_config->scale.min) e_scale = e_config->scale.min;
     }
   else if (e_config->scale.use_custom)
     {
	e_scale = e_config->scale.factor;
	if (e_scale > e_config->scale.max) e_scale = e_config->scale.max;
	else if (e_scale < e_config->scale.min) e_scale = e_config->scale.min;
     }

   edje_scale_set(e_scale);
   snprintf(buf, sizeof(buf), "%1.3f", e_scale);
   e_util_env_set("E_SCALE", buf);
   e_hints_scale_update();
}
Exemple #2
0
E_API void
e_scale_update(void)
{
   char buf[128];

   if (e_config->scale.use_dpi)
     {
#ifndef HAVE_WAYLAND_ONLY
        if (e_comp->comp_type == E_PIXMAP_TYPE_X)
          e_scale = (double)ecore_x_dpi_get() / (double)e_config->scale.base_dpi;
#endif
#ifdef HAVE_WAYLAND
        /* FIXME: This needs to get the DPI from a given output */
        if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
          {
             e_scale = (double)ecore_wl2_output_dpi_get(NULL) /
               (double)e_config->scale.base_dpi;
          }
#endif
        if (e_scale > e_config->scale.max) e_scale = e_config->scale.max;
        else if (e_scale < e_config->scale.min)
          e_scale = e_config->scale.min;
     }
   else if (e_config->scale.use_custom)
     {
        e_scale = e_config->scale.factor;
        if (e_scale > e_config->scale.max) e_scale = e_config->scale.max;
        else if (e_scale < e_config->scale.min)
          e_scale = e_config->scale.min;
     }
   elm_config_scale_set(e_scale);
   elm_config_all_flush();
   edje_scale_set(e_scale);
   snprintf(buf, sizeof(buf), "%1.3f", e_scale);
   e_util_env_set("E_SCALE", buf);
   e_hints_scale_update();
}
ApplicationMain::ApplicationMain(int argc, char **argv)
{
    cInfo() <<  "Calaos Home, starting...";

    if (system("killall -9 eskiss 2> /dev/null") == -1)
        cCritical() <<  "Error forking !";

    //init random generator
    srand(time(NULL));

    //Init SSL and CURL
    SSL_load_error_strings();
    SSL_library_init();
    curl_global_init(CURL_GLOBAL_ALL);

    char *themefile = argvOptionParam(argv, argv + argc, "--theme");
    if (themefile)
    {
        ApplicationMain::theme = themefile;
        cInfo() <<  "Using specified theme file: " << ApplicationMain::getTheme();
    }
    else
    {
        ApplicationMain::theme = Prefix::Instance().dataDirectoryGet() + "/default.edj";
        if (ecore_file_exists(ApplicationMain::theme.c_str()))
            cInfo() << "Using theme file " << theme;
        else
            cError() << theme << " Not found!";
    }

    //Init efl core
    if (!eina_init())
        throw (runtime_error("Unable to init Eina"));
    if (!ecore_init())
        throw (runtime_error("Unable to init Ecore"));
    if (!ecore_con_init())
        throw (runtime_error("Unable to init Ecore-Con"));
    if (!ecore_con_url_init())
        throw (runtime_error("Unable to init Ecore-Con-Url"));
    if (!evas_init())
        throw (runtime_error("Unable to init Evas"));
    if (!ecore_evas_init())
        throw (runtime_error("Unable to init Ecore-Evas"));
    if (!edje_init())
        throw (runtime_error("Unable to init Edje"));

    edje_frametime_set(1.0 / 60.0);
    edje_scale_set(1.0);

    if (!elm_init(argc, argv))
        throw (runtime_error("Unable to init Elementary"));

    //Load Calaos specific ELM extensions
    elm_theme_extension_add(NULL, ApplicationMain::getTheme());

    //Create the main window
    window = elm_win_add(NULL, "calaos-home", ELM_WIN_BASIC);
    elm_win_title_set(window, "Calaos Home");
    elm_win_borderless_set(window, true);

    bool bFullscreen = argvOptionCheck(argv, argv + argc, "--fullscreen");
    elm_win_fullscreen_set(window, bFullscreen);

    //Automatically quit main loop when the window is closed
    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
    elm_win_autodel_set(window, true);

    if (argvOptionCheck(argv, argv + argc, "--set-elm-config"))
    {
        //force setting the correct elementary options for touchscreen
        elm_config_finger_size_set(10);
        elm_config_scroll_bounce_enabled_set(true);
        elm_config_scroll_thumbscroll_enabled_set(true);
        elm_config_scroll_thumbscroll_threshold_set(24);
        elm_config_scroll_thumbscroll_momentum_threshold_set(100.0);
        elm_config_scroll_bounce_friction_set(0.5);
        elm_config_scroll_page_scroll_friction_set(0.5);
        elm_config_scroll_bring_in_scroll_friction_set(0.5);
        elm_config_scroll_zoom_friction_set(0.5);
        elm_config_scroll_thumbscroll_friction_set(1.0);
        elm_config_scroll_thumbscroll_border_friction_set(0.5);
        elm_config_scroll_thumbscroll_sensitivity_friction_set(0.25);
    }

    evas_object_event_callback_add(window, EVAS_CALLBACK_RESIZE, _window_resize_cb, this);
    evas = evas_object_evas_get(window);

    Evas_Object *bg = elm_bg_add(window);
    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_win_resize_object_add(window, bg);
    evas_object_show(bg);
    evas_object_size_hint_min_set(bg, 200, 200);
    elm_bg_color_set(bg, 0, 0, 0);

    layout = elm_layout_add(window);
    if (!elm_layout_file_set(layout, ApplicationMain::getTheme(), EDJE_GROUP_MAIN_LAYOUT))
    {
        string e = "Unable to find group \"";
        e += EDJE_GROUP_MAIN_LAYOUT;
        e += "\" in theme \"";
        e += ApplicationMain::getTheme();
        e += "\"";
        throw (runtime_error(e));
    }

    //create the screen suspend object and put it on the canvas
    ScreenSuspendView *screen_suspend = new ScreenSuspendView(evas, window);
    screen_suspend->Show();
    screen_suspend->setAutoDelete(true);

    evas_object_size_hint_weight_set(layout, 1.0, 1.0);
    evas_object_show(layout);

    evas_object_resize(window, 1024, 768);
    evas_object_show(window);
    ecore_evas_focus_set(ecore_evas_ecore_evas_get(evas_object_evas_get(window)), true);

    Resize();

    try
    {
        controller = new ApplicationController(evas, layout);
    }
    catch(exception const& e)
    {
        cCritical() <<  "Can't create ApplicationController";
        throw;
    }
}