2 * e17-extra-config-modules
3 * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an AS IS BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #include "e_mod_main.h"
20 #include "Elementary.h"
22 #define RESOLUTION_BASE 1
24 #define BASE_LAYOUT_INCH 4.65
25 #define BASE_LAYOUT_WIDTH_PX 720
26 #define BASE_LAYOUT_HEIGHT_PX 1280
27 #define ROUND_DOUBLE(x) (round(((double)x)*100)/100)
28 #define ELM_FINGER_SIZE 60
30 static int _e_elm_config_scale_update(void);
32 /* this is needed to advertise a label for the module IN the code (not just
33 * the .desktop file) but more specifically the api version it was compiled
34 * for so E can skip modules that are compiled for an incorrect API version
37 EAPI E_Module_Api e_modapi =
39 E_MODULE_API_VERSION, "Elementary Profile Module of Window Manager"
43 e_modapi_init(E_Module* m)
45 _e_elm_config_scale_update();
50 e_modapi_shutdown(E_Module* m)
56 e_modapi_save(E_Module* m)
62 #ifndef RESOLUTION_BASE
64 _e_elm_config_dpi_get(double d_inch, int w_px, int h_px)
68 dpi = (sqrt((w_px * w_px) + (h_px * h_px))) / d_inch;
75 _e_mod_config_elm_profile_save(double scale)
78 elm_config_scale_set(scale);
79 elm_config_finger_size_set(scale * ELM_FINGER_SIZE);
87 _e_elm_config_scale_update (void)
89 int target_width, target_height, target_width_mm, target_height_mm;
97 ecore_x_randr_screen_current_size_get(ecore_x_window_root_first_get(), &target_width, &target_height, &target_width_mm, &target_height_mm);
101 scale = ROUND_DOUBLE(target_width / BASE_LAYOUT_WIDTH_PX);
104 double target_inch, target_dpi, base_dpi;
106 target_inch = ROUND_DOUBLE(sqrt(target_width_mm * target_width_mm + target_height_mm * target_height_mm) / 25.4);
109 base_dpi = ROUND_DOUBLE(_e_elm_config_dpi_get(BASE_LAYOUT_INCH, BASE_LAYOUT_WIDTH_PX, BASE_LAYOUT_HEIGHT_PX));
110 target_dpi = ROUND_DOUBLE(_e_elm_config_dpi_get(target_inch, target_width, target_height));
112 // Calculate Scale factor
113 scale = ROUND_DOUBLE(target_dpi / base_dpi);
116 e_config->scale.factor = scale;
118 // calculate elementray scale factor
119 _e_mod_config_elm_profile_save(scale);