2 * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <Elementary.h>
19 //#include <Ecore_X.h>
21 #include <runtime_info.h>
22 #include <system_settings.h>
26 #include "indicator.h"
31 /* Using this macro to emphasize that some portion like stacking and
32 rotation handling are implemented for X based platform */
34 #define __UNUSED__ __attribute__((unused))
37 struct Internal_Data {
39 Ecore_Event_Handler *rotation_event_handler;
45 #define PRIVATE_DATA_KEY_DATA "pdk_data"
47 static void _content_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
50 struct Internal_Data *wd = evas_object_data_get(data, PRIVATE_DATA_KEY_DATA);
54 evas_object_size_hint_min_get(obj, NULL, &h);
57 evas_object_size_hint_min_set(obj, wd->w, wd->h);
58 evas_object_size_hint_min_set(data, wd->w, wd->h);
62 static void _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
64 struct Internal_Data *wd = evas_object_data_get(obj, PRIVATE_DATA_KEY_DATA);
65 Evas_Object *sub = event_info;
69 if (sub == wd->content) {
70 evas_object_event_callback_del(wd->content, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _content_changed_size_hints);
75 static void _noti_win_destroy(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
77 Evas_Object *win = NULL;
78 struct Internal_Data *wd = NULL;
84 wd = evas_object_data_del(win, PRIVATE_DATA_KEY_DATA);
87 if (wd->rotation_event_handler) {
88 ecore_event_handler_del(wd->rotation_event_handler);
92 quickpanel_dbus_ticker_visibility_send(0);
96 static void _rotate_cb(void *data, Evas_Object *obj, void *event)
98 struct appdata *ad = data;
99 struct Internal_Data *wd = NULL;
100 Evas_Object *base = NULL;
105 wd = evas_object_data_get(obj, PRIVATE_DATA_KEY_DATA);
108 base = evas_object_data_get(obj, DATA_KEY_BASE_RECT);
111 angle = elm_win_rotation_get(obj);
116 _D("Ticker angle is %d degree", angle);
121 evas_object_resize(base, ad->win.port_w, wd->h);
122 evas_object_size_hint_min_set(base, ad->win.port_w, wd->h);
123 evas_object_resize(obj, ad->win.port_w, wd->h);
124 evas_object_move(obj, 0, 0);
127 evas_object_resize(base, ad->win.land_w, wd->h);
128 evas_object_size_hint_min_set(base, ad->win.land_w, wd->h);
129 evas_object_resize(obj, ad->win.land_w, wd->h);
130 evas_object_move(obj, 0, 0);
133 evas_object_resize(base, ad->win.land_w, wd->h);
134 evas_object_size_hint_min_set(base, ad->win.land_w, wd->h);
135 evas_object_resize(obj, ad->win.land_w, wd->h);
136 evas_object_move(obj, ad->win.port_w - wd->h, 0);
139 _E("cannot reach here");
145 Evas_Object *noti_win_add(Evas_Object *parent, struct appdata *ad)
147 Evas_Object *win = NULL;
148 struct Internal_Data *wd = NULL;
150 _D("A window is created for ticker notifications");
151 win = elm_win_add (NULL, "noti_win", ELM_WIN_NOTIFICATION);
154 elm_win_alpha_set(win, EINA_FALSE);
155 elm_win_title_set(win, "noti_win");
156 elm_win_borderless_set(win, EINA_TRUE);
157 elm_win_autodel_set(win, EINA_TRUE);
158 //efl_util_set_notification_window_level(win, EFL_UTIL_NOTIFICATION_LEVEL_HIGH);
159 elm_win_prop_focus_skip_set(win, EINA_TRUE);
160 /* you can use evas_object_resize() and evas_object_move() by using elm_win_aux_hint_add().
161 elm_win_aux_hint_add() makes it possible to set the size and location of the notification window freely.
162 if you do not use elm_win_aux_hint_add(), notification window is displayed full screen. */
163 // elm_win_aux_hint_add(win, "wm.policy.win.user.geometry", "1");
164 evas_object_resize(win, ad->win.w, ad->win.h);
165 evas_object_move(win, 0, 0);
166 evas_object_show(win);
168 if (elm_win_wm_rotation_supported_get(win)) {
169 int rots[4] = { 0, 90, 180, 270 };
170 elm_win_wm_rotation_available_rotations_set(win, rots, 4);
172 evas_object_smart_callback_add(win, "wm,rotation,changed", _rotate_cb, ad);
174 wd = (struct Internal_Data *) calloc(1, sizeof(struct Internal_Data));
176 if (win) evas_object_del(win);
179 evas_object_data_set(win, PRIVATE_DATA_KEY_DATA, wd);
185 evas_object_smart_callback_add(win, "sub-object-del", _sub_del, NULL);
186 evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _noti_win_destroy, NULL);
191 void noti_win_content_set(Evas_Object *obj, Evas_Object *content)
193 struct Internal_Data *wd;
197 wd = evas_object_data_get(obj, PRIVATE_DATA_KEY_DATA);
200 if (wd->content && content != NULL) {
201 evas_object_del(content);
205 wd->content = content;
207 evas_object_show(wd->content);
208 evas_object_event_callback_add(wd->content, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _content_changed_size_hints, obj);