summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Antognolli <rafael.antognolli@intel.com>2013-12-11 19:01:28 -0200
committerEduardo Lima (Etrunko) <eduardo.lima@intel.com>2013-12-19 17:47:50 -0200
commit86083432270b91c36c71c33621f00dcd368c3b88 (patch)
tree5f7bd059b8fde540f4359e2c693ed68e1bfe88f4
parent55c4af5dbba4eda51c7da6b024453d6c95a7a360 (diff)
ecore/wayland: Send a mouse up event when the implicit grab starts.
The previous workaround used to send a mouse up event to the application, using the pointer enter callback to determine when an implicit grab has finished. This was "simulating" a mouse up event when the surface move or resize finished. However, this doesn't work for touch-based move. The pointer enter isn't emitted, because the wl_touch interface doesn't have the concept of a pointer. Changing this code to make it more similar to what Weston's toytoolkit does, the mouse up event is sent as soon as the move or resize grab starts. After that, the compositor takes care of the move/resize almost entirely. Change-Id: Ib8daac999137be2fd1e66f82aa3b07b474666a88 Signed-off-by: Rafael Antognolli <rafael.antognolli@intel.com>
-rw-r--r--src/lib/ecore_evas/ecore_evas_wayland_egl.c2
-rw-r--r--src/lib/ecore_evas/ecore_evas_wayland_shm.c2
-rw-r--r--src/lib/ecore_wayland/Ecore_Wayland.h3
-rw-r--r--src/lib/ecore_wayland/ecore_wl_input.c65
-rw-r--r--src/lib/ecore_wayland/ecore_wl_private.h1
-rw-r--r--src/lib/ecore_wayland/ecore_wl_window.c2
6 files changed, 37 insertions, 38 deletions
diff --git a/src/lib/ecore_evas/ecore_evas_wayland_egl.c b/src/lib/ecore_evas/ecore_evas_wayland_egl.c
index 1dab3777..5aae40ad 100644
--- a/src/lib/ecore_evas/ecore_evas_wayland_egl.c
+++ b/src/lib/ecore_evas/ecore_evas_wayland_egl.c
@@ -972,7 +972,6 @@ _ecore_evas_wayland_egl_resize(Ecore_Evas *ee, int location)
972 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); 972 ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
973 } 973 }
974 974
975 ee->engine.wl.win->resizing = EINA_TRUE;
976 ecore_wl_window_resize(ee->engine.wl.win, ee->w, ee->h, location); 975 ecore_wl_window_resize(ee->engine.wl.win, ee->w, ee->h, location);
977 } 976 }
978} 977}
@@ -985,7 +984,6 @@ _ecore_evas_wayland_egl_move(Ecore_Evas *ee, int x, int y)
985 if (!ee) return; 984 if (!ee) return;
986 if (ee->engine.wl.win) 985 if (ee->engine.wl.win)
987 { 986 {
988 ee->engine.wl.win->moving = EINA_TRUE;
989 ecore_wl_window_move(ee->engine.wl.win, x, y); 987 ecore_wl_window_move(ee->engine.wl.win, x, y);
990 } 988 }
991} 989}
diff --git a/src/lib/ecore_evas/ecore_evas_wayland_shm.c b/src/lib/ecore_evas/ecore_evas_wayland_shm.c
index 75ac0ea2..9e05aa8f 100644
--- a/src/lib/ecore_evas/ecore_evas_wayland_shm.c
+++ b/src/lib/ecore_evas/ecore_evas_wayland_shm.c
@@ -1158,7 +1158,6 @@ _ecore_evas_wayland_shm_resize(Ecore_Evas *ee, int location)
1158 if (!ee) return; 1158 if (!ee) return;
1159 if (ee->engine.wl.win) 1159 if (ee->engine.wl.win)
1160 { 1160 {
1161 ee->engine.wl.win->resizing = EINA_TRUE;
1162 ecore_wl_window_resize(ee->engine.wl.win, ee->w, ee->h, location); 1161 ecore_wl_window_resize(ee->engine.wl.win, ee->w, ee->h, location);
1163 } 1162 }
1164} 1163}
@@ -1171,7 +1170,6 @@ _ecore_evas_wayland_shm_move(Ecore_Evas *ee, int x, int y)
1171 if (!ee) return; 1170 if (!ee) return;
1172 if (ee->engine.wl.win) 1171 if (ee->engine.wl.win)
1173 { 1172 {
1174 ee->engine.wl.win->moving = EINA_TRUE;
1175 ecore_wl_window_move(ee->engine.wl.win, x, y); 1173 ecore_wl_window_move(ee->engine.wl.win, x, y);
1176 } 1174 }
1177} 1175}
diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h b/src/lib/ecore_wayland/Ecore_Wayland.h
index a62d55fc..63cd3191 100644
--- a/src/lib/ecore_wayland/Ecore_Wayland.h
+++ b/src/lib/ecore_wayland/Ecore_Wayland.h
@@ -163,6 +163,7 @@ struct _Ecore_Wl_Input
163 163
164 Ecore_Wl_Window *grab; 164 Ecore_Wl_Window *grab;
165 unsigned int grab_button; 165 unsigned int grab_button;
166 unsigned int grab_timestamp;
166 167
167 Ecore_Wl_Dnd_Source *drag_source; 168 Ecore_Wl_Dnd_Source *drag_source;
168 Ecore_Wl_Dnd_Source *selection_source; 169 Ecore_Wl_Dnd_Source *selection_source;
@@ -209,8 +210,6 @@ struct _Ecore_Wl_Window
209 /* Eina_Bool resize_scheduled : 1; */ 210 /* Eina_Bool resize_scheduled : 1; */
210 Eina_Bool alpha : 1; 211 Eina_Bool alpha : 1;
211 Eina_Bool transparent : 1; 212 Eina_Bool transparent : 1;
212 Eina_Bool moving : 1;
213 Eina_Bool resizing : 1;
214 213
215 Ecore_Wl_Window_Type type; 214 Ecore_Wl_Window_Type type;
216 Ecore_Wl_Window_Buffer_Type buffer_type; 215 Ecore_Wl_Window_Buffer_Type buffer_type;
diff --git a/src/lib/ecore_wayland/ecore_wl_input.c b/src/lib/ecore_wayland/ecore_wl_input.c
index 07b9a269..3c380c54 100644
--- a/src/lib/ecore_wayland/ecore_wl_input.c
+++ b/src/lib/ecore_wayland/ecore_wl_input.c
@@ -150,6 +150,27 @@ ecore_wl_input_ungrab(Ecore_Wl_Input *input)
150 input->grab_button = 0; 150 input->grab_button = 0;
151} 151}
152 152
153/* NB: This function should be called just before shell move and shell resize
154 * functions. Those requests will trigger a mouse/touch implicit grab on the
155 * compositor that will prevent the respective mouse/touch up events being
156 * released after the end of the operation. This function checks if such grab
157 * is in place for those windows and, if so, emit the respective mouse up
158 * event. It's a workaround to the fact that wayland doesn't inform the
159 * application about this move or resize grab being finished.
160 */
161void
162_ecore_wl_input_grab_release(Ecore_Wl_Input *input, Ecore_Wl_Window *win)
163{
164 LOGFN(__FILE__, __LINE__, __FUNCTION__);
165
166 if (!input) return;
167 if (input->grab != win) return;
168
169 _ecore_wl_input_mouse_up_send(input, input->grab,
170 input->grab_button, input->grab_timestamp);
171 ecore_wl_input_ungrab(input);
172}
173
153EAPI void 174EAPI void
154ecore_wl_input_pointer_set(Ecore_Wl_Input *input, struct wl_surface *surface, int hot_x, int hot_y) 175ecore_wl_input_pointer_set(Ecore_Wl_Input *input, struct wl_surface *surface, int hot_x, int hot_y)
155{ 176{
@@ -404,7 +425,10 @@ _ecore_wl_input_cb_pointer_button(void *data, struct wl_pointer *pointer __UNUSE
404 if (state) 425 if (state)
405 { 426 {
406 if ((input->pointer_focus) && (!input->grab) && (state)) 427 if ((input->pointer_focus) && (!input->grab) && (state))
407 ecore_wl_input_grab(input, input->pointer_focus, button); 428 {
429 ecore_wl_input_grab(input, input->pointer_focus, button);
430 input->grab_timestamp = timestamp;
431 }
408 432
409 _ecore_wl_input_mouse_down_send(input, input->pointer_focus, 433 _ecore_wl_input_mouse_down_send(input, input->pointer_focus,
410 button, timestamp); 434 button, timestamp);
@@ -704,37 +728,6 @@ _ecore_wl_input_cb_pointer_enter(void *data, struct wl_pointer *pointer __UNUSED
704 728
705 _ecore_wl_input_mouse_in_send(input, win, input->timestamp); 729 _ecore_wl_input_mouse_in_send(input, win, input->timestamp);
706 } 730 }
707
708 /* NB: This whole 'if' below is a major HACK due to wayland's stupidness
709 * of not sending a mouse_up (or any notification at all for that matter)
710 * when a move or resize grab is finished */
711 if (input->grab)
712 {
713 /* NB: This COULD mean a move has finished, or it could mean that
714 * a 'drag' is being done to a different surface */
715
716 if ((input->grab == win) && (win->moving))
717 {
718 /* NB: 'Fake' a mouse_up for move finished */
719 win->moving = EINA_FALSE;
720 _ecore_wl_input_mouse_up_send(input, win, BTN_LEFT,
721 input->timestamp);
722
723 if ((input->grab) && (input->grab_button == BTN_LEFT))
724 ecore_wl_input_ungrab(input);
725 }
726 else if ((input->grab == win) && (win->resizing))
727 {
728 /* NB: 'Fake' a mouse_up for resize finished */
729 win->resizing = EINA_FALSE;
730 _ecore_wl_input_mouse_up_send(input, win, BTN_LEFT,
731 input->timestamp);
732
733 if ((input->grab) && (input->grab_button == BTN_LEFT))
734 ecore_wl_input_ungrab(input);
735 }
736 /* FIXME: Test d-n-d and potentially add needed case here */
737 }
738} 731}
739 732
740static void 733static void
@@ -855,6 +848,12 @@ _ecore_wl_input_cb_touch_down(void *data, struct wl_touch *touch __UNUSED__, uns
855 input->sx = wl_fixed_to_int(x); 848 input->sx = wl_fixed_to_int(x);
856 input->sy = wl_fixed_to_int(y); 849 input->sy = wl_fixed_to_int(y);
857 _ecore_wl_input_cb_pointer_enter(data, NULL, serial, surface, x, y); 850 _ecore_wl_input_cb_pointer_enter(data, NULL, serial, surface, x, y);
851 if ((input->pointer_focus) && (!input->grab))
852 {
853 ecore_wl_input_grab(input, input->pointer_focus, BTN_LEFT);
854 input->grab_timestamp = timestamp;
855 }
856
858 _ecore_wl_input_mouse_down_send(input, input->pointer_focus, BTN_LEFT, timestamp); 857 _ecore_wl_input_mouse_down_send(input, input->pointer_focus, BTN_LEFT, timestamp);
859} 858}
860 859
@@ -872,6 +871,8 @@ _ecore_wl_input_cb_touch_up(void *data, struct wl_touch *touch __UNUSED__, unsig
872 /* input->timestamp = timestamp; */ 871 /* input->timestamp = timestamp; */
873 input->display->serial = serial; 872 input->display->serial = serial;
874 _ecore_wl_input_mouse_up_send(input, input->pointer_focus, BTN_LEFT, timestamp); 873 _ecore_wl_input_mouse_up_send(input, input->pointer_focus, BTN_LEFT, timestamp);
874 if ((input->grab) && (input->grab_button == BTN_LEFT))
875 ecore_wl_input_ungrab(input);
875} 876}
876 877
877static void 878static void
diff --git a/src/lib/ecore_wayland/ecore_wl_private.h b/src/lib/ecore_wayland/ecore_wl_private.h
index 7f59ae9b..e87772b4 100644
--- a/src/lib/ecore_wayland/ecore_wl_private.h
+++ b/src/lib/ecore_wayland/ecore_wl_private.h
@@ -90,6 +90,7 @@ void _ecore_wl_input_add(Ecore_Wl_Display *ewd, unsigned int id);
90void _ecore_wl_input_del(Ecore_Wl_Input *input); 90void _ecore_wl_input_del(Ecore_Wl_Input *input);
91void _ecore_wl_input_pointer_xy_get(int *x, int *y); 91void _ecore_wl_input_pointer_xy_get(int *x, int *y);
92void _ecore_wl_input_set_selection(Ecore_Wl_Input *input, struct wl_data_source *source); 92void _ecore_wl_input_set_selection(Ecore_Wl_Input *input, struct wl_data_source *source);
93void _ecore_wl_input_grab_release(Ecore_Wl_Input *input, Ecore_Wl_Window *win);
93 94
94void _ecore_wl_dnd_add(Ecore_Wl_Input *input, struct wl_data_device *data_device, struct wl_data_offer *offer); 95void _ecore_wl_dnd_add(Ecore_Wl_Input *input, struct wl_data_device *data_device, struct wl_data_offer *offer);
95void _ecore_wl_dnd_enter(void *data, struct wl_data_device *data_device __UNUSED__, unsigned int timestamp __UNUSED__, struct wl_surface *surface, int x, int y, struct wl_data_offer *offer); 96void _ecore_wl_dnd_enter(void *data, struct wl_data_device *data_device __UNUSED__, unsigned int timestamp __UNUSED__, struct wl_surface *surface, int x, int y, struct wl_data_offer *offer);
diff --git a/src/lib/ecore_wayland/ecore_wl_window.c b/src/lib/ecore_wayland/ecore_wl_window.c
index 4187f0f5..f473995d 100644
--- a/src/lib/ecore_wayland/ecore_wl_window.c
+++ b/src/lib/ecore_wayland/ecore_wl_window.c
@@ -204,6 +204,7 @@ ecore_wl_window_move(Ecore_Wl_Window *win, int x, int y)
204 204
205 if ((!input) || (!input->seat)) return; 205 if ((!input) || (!input->seat)) return;
206 206
207 _ecore_wl_input_grab_release(input, win);
207 wl_shell_surface_move(win->shell_surface, input->seat, 208 wl_shell_surface_move(win->shell_surface, input->seat,
208 input->display->serial); 209 input->display->serial);
209 } 210 }
@@ -264,6 +265,7 @@ ecore_wl_window_resize(Ecore_Wl_Window *win, int w, int h, int location)
264 265
265 if ((!input) || (!input->seat)) return; 266 if ((!input) || (!input->seat)) return;
266 267
268 _ecore_wl_input_grab_release(input, win);
267 wl_shell_surface_resize(win->shell_surface, input->seat, 269 wl_shell_surface_resize(win->shell_surface, input->seat,
268 input->display->serial, location); 270 input->display->serial, location);
269 } 271 }