4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
24 #include "syspopup_core.h"
26 #include "syspopup_api.h"
27 #include "simple_util.h"
30 #include <Ecore_Input.h>
33 static void __elm_popupwin_del_cb(void *data, Evas * e, Evas_Object * obj,
39 _D("callback del called, destroy internal data - id = %d\n", id);
44 static Eina_Bool __x_keydown_cb(void *data, int type, void *event)
47 Ecore_Event_Key *ev = event;
52 X_syspopup_process_keydown(id, ev->keyname);
54 return ECORE_CALLBACK_DONE;
57 static Eina_Bool __x_rotate_cb(void *data, int type, void *event)
60 Ecore_X_Event_Client_Message *ev = event;
63 return ECORE_CALLBACK_RENEW;
65 if (ev->message_type == ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE)
66 X_syspopup_process_rotate(id);
68 return ECORE_CALLBACK_RENEW;
71 static int __efl_rotate(Display *dpy, Window win, syspopup *sp)
75 rotation = X_syspopup_rotation_get(dpy, win);
82 elm_win_rotation_with_resize_set(sp->win, rotation);
87 API int syspopup_create(bundle *b, syspopup_handler *handler,
88 Evas_Object *parent, void *user_data)
92 const char *popup_name;
95 XWindowAttributes attr;
96 int is_unviewable = 0;
98 popup_name = _syspopup_get_name_from_bundle(b);
99 if (popup_name == NULL || handler == NULL) {
100 _E("popup_name or handler is NULL");
104 if (parent == NULL) {
105 _E("parent window is NULL");
109 sp = _syspopup_find(popup_name);
111 _E("already exist - syspopup %s", popup_name);
114 xwin = elm_win_xwindow_get(parent);
115 dpy = ecore_x_display_get();
117 id = X_make_syspopup(b, dpy, xwin, parent, __efl_rotate,
120 _E("fail to make X syspopup");
124 ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, __x_keydown_cb,
127 evas_object_event_callback_add(parent, EVAS_CALLBACK_DEL,
128 __elm_popupwin_del_cb, (void *)id);
130 /* X_syspopup_core should process 2 events */
131 /* First, rotate event */
132 /* Second, keydown event */
133 ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
134 __x_rotate_cb, (void *)id);
141 API int syspopup_reset(bundle *b)
143 return X_syspopup_reset(b);