Update minictrl and assistive_light
[apps/core/preloaded/quickpanel.git] / daemon / page / pager_common_x11.c
1 /*
2  * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include "pager.h"
19 #include "datetime.h"
20
21 #define EVAS_DATA_PAGE_HANDLER "page_handler"
22
23 static inline void _scroll_hold(Evas_Object *viewer)
24 {
25         int hold_count = 0;
26         retif(viewer == NULL, , "Invalid parameter!");
27
28         hold_count = elm_object_scroll_hold_get(viewer);
29
30         if (hold_count <= 0) {
31                 elm_object_scroll_hold_push(viewer);
32         }
33 }
34
35 static inline void _scroll_unhold(Evas_Object *viewer)
36 {
37         int i = 0, hold_count = 0;
38         retif(viewer == NULL, , "Invalid parameter!");
39
40         hold_count = elm_object_scroll_hold_get(viewer);
41
42         for (i = 0 ; i < hold_count; i++) {
43                 elm_object_scroll_hold_pop(viewer);
44         }
45 }
46
47 static inline void _scroll_freeze(Evas_Object *viewer)
48 {
49         int freezed_count = 0;
50         retif(viewer == NULL, , "Invalid parameter!");
51
52         freezed_count = elm_object_scroll_freeze_get(viewer);
53
54         if (freezed_count <= 0) {
55                 elm_object_scroll_freeze_push(viewer);
56         }
57 }
58
59 static inline void _scroll_unfreeze(Evas_Object *viewer)
60 {
61         int i = 0, freezed_count = 0;
62         retif(viewer == NULL, , "Invalid parameter!");
63
64         freezed_count = elm_object_scroll_freeze_get(viewer);
65
66         for (i = 0 ; i < freezed_count; i++) {
67                 elm_object_scroll_freeze_pop(viewer);
68         }
69 }
70
71 HAPI void quickpanel_page_handler_set(Evas_Object *page, QP_Page_Handler *handler)
72 {
73         retif(page == NULL, , "invalid parameter");
74
75         evas_object_data_set(page, EVAS_DATA_PAGE_HANDLER, handler);
76 }
77
78 HAPI QP_Page_Handler *quickpanel_page_handler_get(Evas_Object *page)
79 {
80         retif(page == NULL, NULL, "invalid parameter");
81
82         return evas_object_data_get(page, EVAS_DATA_PAGE_HANDLER);
83 }
84
85 HAPI void quickpanel_page_scroll_freeze_set(Eina_Bool is_freeze)
86 {
87         Evas_Object *pager_scroller = quickpanel_pager_view_get("SCROLLER");
88         retif(pager_scroller == NULL, , "pager null");
89
90         if (is_freeze) {
91                 _scroll_freeze(pager_scroller);
92         } else {
93                 _scroll_unfreeze(pager_scroller);
94         }
95 }
96
97 HAPI void quickpanel_page_scroll_hold_set(Eina_Bool is_freeze)
98 {
99         Evas_Object *pager_scroller = quickpanel_pager_view_get("SCROLLER");
100         retif(pager_scroller == NULL, , "pager null");
101
102         if (is_freeze) {
103                 _scroll_hold(pager_scroller);
104         } else {
105                 _scroll_unhold(pager_scroller);
106         }
107 }
108
109 HAPI void quickpanel_page_get_recoordinated_pos(int local_x, int local_y, int *x, int *y)
110 {
111         int rot_x = 0;
112         int rot_y = 0;
113         int width = 0;
114         int height = 0;
115         retif(x == NULL && y == NULL, , "invalid parameter");
116
117         struct appdata *ad = quickpanel_get_app_data();
118         retif(ad == NULL, , "invalid parameter");
119
120         //ecore_x_window_size_get(ecore_x_window_root_first_get(), &width, &height);
121         elm_win_screen_size_get(ad->win, NULL, NULL, &width, &height);
122         
123         switch (ad->angle) {
124         case 0:
125                 rot_x = local_x;
126                 rot_y = local_y;
127                 break;
128         case 90:
129                 rot_x = height - local_y;
130                 rot_y = local_x;
131                 break;
132         case 180:
133                 rot_x = width - local_x;
134                 rot_y = height - local_y;
135                 break;
136         case 270:
137                 rot_x = local_y;
138                 rot_y = width - local_x;
139                 break;
140         default:
141                 break;
142         }
143
144         if (x != NULL) {
145                 *x = rot_x;
146         }
147
148         if (y != NULL) {
149                 *y = rot_y;
150         }
151 }
152
153 HAPI void quickpanel_page_get_touched_pos(int *x, int *y)
154 {
155         int rot_x = 0;
156         int rot_y = 0;
157         int local_x = 0;
158         int local_y = 0;
159         retif(x == NULL && y == NULL, , "invalid parameter");
160
161         struct appdata *ad = quickpanel_get_app_data();
162         retif(ad == NULL, , "invalid parameter");
163
164         ecore_x_pointer_last_xy_get(&local_x, &local_y);
165         quickpanel_page_get_recoordinated_pos(local_x, local_y, &rot_x, &rot_y);
166
167         if (x != NULL) {
168                 *x = rot_x;
169         }
170
171         if (y != NULL) {
172                 *y = rot_y;
173         }
174 }
175
176 HAPI void quickpanel_page_editing_icon_visible_status_update(void)
177 {
178         int is_visible = 0;
179         struct appdata *ad = quickpanel_get_app_data();
180         retif(ad == NULL, , "invalid parameter");
181
182         if (quickpanel_pager_current_page_get() == PAGE_IDX_EDITING) {
183                 is_visible = 1;
184         } else {
185                 is_visible = 0;
186         }
187
188         quickpanel_datetime_editing_icon_visibility_set(is_visible);
189 }