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);
31 /* this is needed to advertise a label for the module IN the code (not just
32 * the .desktop file) but more specifically the api version it was compiled
33 * for so E can skip modules that are compiled for an incorrect API version
36 EAPI E_Module_Api e_modapi =
38 E_MODULE_API_VERSION, "Elementary Profile Module of Window Manager"
42 e_modapi_init(E_Module* m)
44 _e_elm_config_scale_update();
49 e_modapi_shutdown(E_Module* m)
55 e_modapi_save(E_Module* m)
61 #ifndef RESOLUTION_BASE
63 _e_elm_config_dpi_get(double d_inch, int w_px, int h_px)
67 dpi = (sqrt((w_px * w_px) + (h_px * h_px))) / d_inch;
74 _e_mod_config_elm_profile_save(double scale)
77 elm_config_scale_set(scale);
78 elm_config_finger_size_set(scale * ELM_FINGER_SIZE);
86 _e_elm_config_scale_update (void)
88 int target_width, target_height, target_width_mm, target_height_mm;
96 ecore_x_randr_screen_current_size_get(ecore_x_window_root_first_get(), &target_width, &target_height, &target_width_mm, &target_height_mm);
100 if (target_width < target_height)
101 scale = ROUND_DOUBLE(target_width / BASE_LAYOUT_WIDTH_PX);
103 scale = ROUND_DOUBLE(target_height / BASE_LAYOUT_WIDTH_PX);
106 double target_inch, target_dpi, base_dpi;
108 target_inch = ROUND_DOUBLE(sqrt(target_width_mm * target_width_mm + target_height_mm * target_height_mm) / 25.4);
111 base_dpi = ROUND_DOUBLE(_e_elm_config_dpi_get(BASE_LAYOUT_INCH, BASE_LAYOUT_WIDTH_PX, BASE_LAYOUT_HEIGHT_PX));
112 target_dpi = ROUND_DOUBLE(_e_elm_config_dpi_get(target_inch, target_width, target_height));
114 // Calculate Scale factor
115 scale = ROUND_DOUBLE(target_dpi / base_dpi);
118 e_config->scale.factor = scale;
120 // calculate elementray scale factor
121 _e_mod_config_elm_profile_save(scale);