2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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.
20 #include <Elementary.h>
22 #include "livebox/livebox_panel.h"
24 #include "livebox_all_pages.h"
25 #include "folder_panel.h"
29 Ecore_Event_Handler *mouse_down;
30 Ecore_Event_Handler *mouse_up;
31 Ecore_Event_Handler *mouse_move;
49 .is_initialized = false,
59 static Eina_Bool __mouse_down_cb(void *data, int type, void *event);
60 static Eina_Bool __mouse_up_cb(void *data, int type, void *event);
61 static Eina_Bool __mouse_move_cb(void *data, int type, void *event);
64 HAPI void mouse_register(void)
66 mouse_info.mouse_down = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, __mouse_down_cb, NULL);
67 if (!mouse_info.mouse_down)
68 LOGD("Failed to register the mouse down event callback");
70 mouse_info.mouse_move = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, __mouse_move_cb, NULL);
71 if (!mouse_info.mouse_move) {
72 LOGD("Failed to register the mouse move event callback");
73 ecore_event_handler_del(mouse_info.mouse_down);
74 mouse_info.mouse_down = NULL;
77 mouse_info.mouse_up = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, __mouse_up_cb, NULL);
78 if (!mouse_info.mouse_up) {
79 LOGD("Failed to register the mouse up event callback");
80 ecore_event_handler_del(mouse_info.mouse_down);
81 ecore_event_handler_del(mouse_info.mouse_move);
83 mouse_info.mouse_down = NULL;
84 mouse_info.mouse_move = NULL;
89 HAPI void mouse_unregister(void)
91 if (mouse_info.mouse_down) {
92 ecore_event_handler_del(mouse_info.mouse_down);
93 mouse_info.mouse_down = NULL;
96 if (mouse_info.mouse_up) {
97 ecore_event_handler_del(mouse_info.mouse_up);
98 mouse_info.mouse_up = NULL;
101 if (mouse_info.mouse_move) {
102 ecore_event_handler_del(mouse_info.mouse_move);
103 mouse_info.mouse_move = NULL;
108 static Eina_Bool __mouse_down_cb(void *data, int type, void *event)
110 Ecore_Event_Mouse_Button *move = event;
112 if (mouse_info.pressed)
113 return ECORE_CALLBACK_RENEW;
115 mouse_info.pressed = true;
116 mouse_info.is_initialized = false;
118 mouse_info.down_x = move->root.x;
119 mouse_info.down_y = move->root.y;
121 return ECORE_CALLBACK_RENEW;
125 static Eina_Bool __mouse_up_cb(void *data, int type, void *event)
127 Ecore_Event_Mouse_Button *move = event;
129 if (!mouse_info.pressed)
130 return ECORE_CALLBACK_RENEW;
132 mouse_info.pressed = false;
133 mouse_info.pre_x = 0;
134 mouse_info.pre_y = 0;
136 mouse_info.up_x = move->root.x;
137 mouse_info.up_y = move->root.y;
139 livebox_all_pages_up_item();
141 return ECORE_CALLBACK_RENEW;
144 static Eina_Bool __mouse_move_cb(void *data, int type, void *event)
146 Ecore_Event_Mouse_Move *move = event;
148 mouse_info.move_x = move->root.x;
149 mouse_info.move_y = move->root.y;
151 if (mouse_info.pressed == false)
152 return ECORE_CALLBACK_RENEW;
154 livebox_all_pages_move_item(move->root.x, move->root.y);
155 livebox_panel_move_mouse_cb(move->root.x, move->root.y);
157 return ECORE_CALLBACK_RENEW;