Remove trivial unnecessary build dependency
[apps/core/preloaded/lockscreen.git] / src / window.c
1 /*
2  * Copyright (c) 2009-2014 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 #include <Elementary.h>
18 #ifdef USE_TIZEN_SHELL
19 #include <tzsh_lockscreen_service.h>
20 #endif
21
22 #include "window.h"
23 #include "log.h"
24
25
26 static struct {
27         Evas_Object *win;
28         Evas_Object *conformant;
29 } view;
30
31 static void _lockscreen_window_event_rect_mouse_down_cb(void *data, Evas *e, Evas_Object *src, void *event_info)
32 {
33         evas_object_smart_callback_call(data, SIGNAL_TOUCH_STARTED, NULL);
34 }
35
36 static void _lockscreen_window_event_rect_mouse_up_cb(void *data, Evas *e, Evas_Object *src, void *event_info)
37 {
38         evas_object_smart_callback_call(data, SIGNAL_TOUCH_ENDED, NULL);
39 }
40
41 static void _lockscreen_window_event_rect_geometry_changed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
42 {
43         int x, y, w, h;
44         evas_object_geometry_get(obj, &x, &y, &w, &h);
45         evas_object_geometry_set(data, x, y, w, h);
46 }
47
48 Evas_Object *lockscreen_window_create(void)
49 {
50 #ifdef USE_TIZEN_SHELL
51         tzsh_h tzsh = NULL;
52         tzsh_lockscreen_service_h lockscreen_service = NULL;
53 #endif
54         Evas_Object *win = elm_win_add(NULL, "LOCKSCREEN", ELM_WIN_NOTIFICATION);
55         if (!win) return NULL;
56
57         elm_win_alpha_set(win, EINA_TRUE);
58         elm_win_title_set(win, "LOCKSCREEN");
59         elm_win_borderless_set(win, EINA_TRUE);
60         elm_win_autodel_set(win, EINA_TRUE);
61         elm_win_role_set(win, "notification-normal");
62         elm_win_fullscreen_set(win, EINA_TRUE);
63         elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW);
64
65 #ifdef USE_TIZEN_SHELL
66         tzsh = tzsh_create(TZSH_TOOLKIT_TYPE_EFL);
67         if (!tzsh) {
68                 ERR("tzsh_create failed");
69                 evas_object_del(win);
70                 return NULL;
71         }
72
73         lockscreen_service = tzsh_lockscreen_service_create(tzsh, elm_win_window_id_get(win));
74         if (!lockscreen_service) {
75                 ERR("tzsh_lockscreen_service_create failed");
76                 tzsh_destroy(tzsh);
77                 evas_object_del(win);
78                 return NULL;
79         }
80 #endif
81
82         Evas_Object *conformant = elm_conformant_add(win);
83         evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
84         evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, EVAS_HINT_FILL);
85         elm_win_resize_object_add(win, conformant);
86
87         elm_object_signal_emit(conformant, "elm,state,indicator,overlap", "elm");
88
89         Evas_Object *event_rect = evas_object_rectangle_add(evas_object_evas_get(win));
90         evas_object_color_set(event_rect, 0, 0, 0, 0);
91         evas_object_layer_set(event_rect, EVAS_LAYER_MAX);
92         evas_object_repeat_events_set(event_rect, EINA_TRUE);
93         evas_object_event_callback_add(event_rect, EVAS_CALLBACK_MOUSE_DOWN, _lockscreen_window_event_rect_mouse_down_cb, win);
94         evas_object_event_callback_add(event_rect, EVAS_CALLBACK_MOUSE_UP, _lockscreen_window_event_rect_mouse_up_cb, win);
95         evas_object_show(event_rect);
96
97         evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _lockscreen_window_event_rect_geometry_changed_cb, event_rect);
98         evas_object_event_callback_add(win, EVAS_CALLBACK_MOVE, _lockscreen_window_event_rect_geometry_changed_cb, event_rect);
99         evas_object_show(win);
100         evas_object_show(conformant);
101
102         view.win = win;
103         view.conformant = conformant;
104
105         return win;
106 }
107
108 void lockscreen_window_content_set(Evas_Object *content)
109 {
110         elm_object_part_content_set(view.conformant, NULL, content);
111 }