summaryrefslogtreecommitdiff
path: root/src/lib/ecore_wayland
diff options
context:
space:
mode:
authorRafael Antognolli <rafael.antognolli@intel.com>2013-11-29 16:04:18 -0200
committerRafael Antognolli <rafael.antognolli@intel.com>2013-11-29 18:05:19 -0200
commita14ee372e0285602a010856b090dcf7f7b3373e3 (patch)
tree938f6e2bdeebb52b7fc3d9a7fc29e533e1bec970 /src/lib/ecore_wayland
parent2c95c5ee1d470650480781fe72518ef67263010d (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. Should fix T468.
Diffstat (limited to 'src/lib/ecore_wayland')
-rw-r--r--src/lib/ecore_wayland/ecore_wl_input.c66
-rw-r--r--src/lib/ecore_wayland/ecore_wl_private.h4
-rw-r--r--src/lib/ecore_wayland/ecore_wl_window.c5
3 files changed, 38 insertions, 37 deletions
diff --git a/src/lib/ecore_wayland/ecore_wl_input.c b/src/lib/ecore_wayland/ecore_wl_input.c
index 4661891500..aa0ed7074a 100644
--- a/src/lib/ecore_wayland/ecore_wl_input.c
+++ b/src/lib/ecore_wayland/ecore_wl_input.c
@@ -165,6 +165,28 @@ ecore_wl_input_ungrab(Ecore_Wl_Input *input)
165 input->grab_button = 0; 165 input->grab_button = 0;
166} 166}
167 167
168/* NB: This function should be called just before shell move and shell resize
169 * functions. Those requests will trigger a mouse/touch implicit grab on the
170 * compositor that will prevent the respective mouse/touch up events being
171 * released after the end of the operation. This function checks if such grab
172 * is in place for those windows and, if so, emit the respective mouse up
173 * event. It's a workaround to the fact that wayland doesn't inform the
174 * application about this move or resize grab being finished.
175 */
176void
177_ecore_wl_input_grab_release(Ecore_Wl_Input *input, Ecore_Wl_Window *win)
178{
179 LOGFN(__FILE__, __LINE__, __FUNCTION__);
180
181 if (!input) return;
182 if (input->grab != win) return;
183
184 _ecore_wl_input_mouse_up_send(input, input->pointer_focus,
185 0, input->grab_button, input->grab_timestamp);
186
187 ecore_wl_input_ungrab(input);
188}
189
168static void 190static void
169_pointer_update_stop(Ecore_Wl_Input *input) 191_pointer_update_stop(Ecore_Wl_Input *input)
170{ 192{
@@ -497,7 +519,10 @@ _ecore_wl_input_cb_pointer_button(void *data, struct wl_pointer *pointer EINA_UN
497 if (state) 519 if (state)
498 { 520 {
499 if ((input->pointer_focus) && (!input->grab) && (state)) 521 if ((input->pointer_focus) && (!input->grab) && (state))
500 ecore_wl_input_grab(input, input->pointer_focus, button); 522 {
523 ecore_wl_input_grab(input, input->pointer_focus, button);
524 input->grab_timestamp = timestamp;
525 }
501 526
502 if (input->pointer_focus) 527 if (input->pointer_focus)
503 _ecore_wl_input_mouse_down_send(input, input->pointer_focus, 528 _ecore_wl_input_mouse_down_send(input, input->pointer_focus,
@@ -861,37 +886,6 @@ _ecore_wl_input_cb_pointer_enter(void *data, struct wl_pointer *pointer EINA_UNU
861 886
862 _ecore_wl_input_mouse_in_send(input, win, input->timestamp); 887 _ecore_wl_input_mouse_in_send(input, win, input->timestamp);
863 } 888 }
864
865 /* NB: This whole 'if' below is a major HACK due to wayland's stupidness
866 * of not sending a mouse_up (or any notification at all for that matter)
867 * when a move or resize grab is finished */
868 if (input->grab)
869 {
870 /* NB: This COULD mean a move has finished, or it could mean that
871 * a 'drag' is being done to a different surface */
872
873 if ((input->grab == win) && (win->moving))
874 {
875 /* NB: 'Fake' a mouse_up for move finished */
876 win->moving = EINA_FALSE;
877 _ecore_wl_input_mouse_up_send(input, win, 0,
878 BTN_LEFT, input->timestamp);
879
880 if ((input->grab) && (input->grab_button == BTN_LEFT))
881 ecore_wl_input_ungrab(input);
882 }
883 else if ((input->grab == win) && (win->resizing))
884 {
885 /* NB: 'Fake' a mouse_up for resize finished */
886 win->resizing = EINA_FALSE;
887 _ecore_wl_input_mouse_up_send(input, win, 0,
888 BTN_LEFT, input->timestamp);
889
890 if ((input->grab) && (input->grab_button == BTN_LEFT))
891 ecore_wl_input_ungrab(input);
892 }
893 /* FIXME: Test d-n-d and potentially add needed case here */
894 }
895} 889}
896 890
897static void 891static void
@@ -1011,6 +1005,12 @@ _ecore_wl_input_cb_touch_down(void *data, struct wl_touch *touch EINA_UNUSED, un
1011 1005
1012 _ecore_wl_input_mouse_move_send(input, input->pointer_focus, timestamp, id); 1006 _ecore_wl_input_mouse_move_send(input, input->pointer_focus, timestamp, id);
1013 _ecore_wl_input_cb_pointer_enter(data, NULL, serial, surface, x, y); 1007 _ecore_wl_input_cb_pointer_enter(data, NULL, serial, surface, x, y);
1008 if ((input->touch_focus) && (!input->grab))
1009 {
1010 ecore_wl_input_grab(input, input->pointer_focus, BTN_LEFT);
1011 input->grab_timestamp = timestamp;
1012 }
1013
1014 _ecore_wl_input_mouse_down_send(input, input->touch_focus, 1014 _ecore_wl_input_mouse_down_send(input, input->touch_focus,
1015 id, 0, timestamp); 1015 id, 0, timestamp);
1016} 1016}
@@ -1029,6 +1029,8 @@ _ecore_wl_input_cb_touch_up(void *data, struct wl_touch *touch EINA_UNUSED, unsi
1029 input->display->serial = serial; 1029 input->display->serial = serial;
1030 1030
1031 _ecore_wl_input_mouse_up_send(input, input->touch_focus, id, 0, timestamp); 1031 _ecore_wl_input_mouse_up_send(input, input->touch_focus, id, 0, timestamp);
1032 if ((input->grab) && (input->grab_button == BTN_LEFT))
1033 ecore_wl_input_ungrab(input);
1032} 1034}
1033 1035
1034static void 1036static void
diff --git a/src/lib/ecore_wayland/ecore_wl_private.h b/src/lib/ecore_wayland/ecore_wl_private.h
index 80b454c0c2..ecb54f0467 100644
--- a/src/lib/ecore_wayland/ecore_wl_private.h
+++ b/src/lib/ecore_wayland/ecore_wl_private.h
@@ -129,8 +129,6 @@ struct _Ecore_Wl_Window
129 /* Eina_Bool resize_scheduled : 1; */ 129 /* Eina_Bool resize_scheduled : 1; */
130 Eina_Bool alpha : 1; 130 Eina_Bool alpha : 1;
131 Eina_Bool transparent : 1; 131 Eina_Bool transparent : 1;
132 Eina_Bool moving : 1;
133 Eina_Bool resizing : 1;
134 Eina_Bool has_buffer : 1; 132 Eina_Bool has_buffer : 1;
135 133
136 Ecore_Wl_Window_Type type; 134 Ecore_Wl_Window_Type type;
@@ -183,6 +181,7 @@ struct _Ecore_Wl_Input
183 181
184 Ecore_Wl_Window *grab; 182 Ecore_Wl_Window *grab;
185 unsigned int grab_button; 183 unsigned int grab_button;
184 unsigned int grab_timestamp;
186 185
187 Ecore_Wl_Dnd_Source *drag_source; 186 Ecore_Wl_Dnd_Source *drag_source;
188 Ecore_Wl_Dnd_Source *selection_source; 187 Ecore_Wl_Dnd_Source *selection_source;
@@ -258,6 +257,7 @@ void _ecore_wl_output_del(Ecore_Wl_Output *output);
258void _ecore_wl_input_add(Ecore_Wl_Display *ewd, unsigned int id); 257void _ecore_wl_input_add(Ecore_Wl_Display *ewd, unsigned int id);
259void _ecore_wl_input_del(Ecore_Wl_Input *input); 258void _ecore_wl_input_del(Ecore_Wl_Input *input);
260void _ecore_wl_input_pointer_xy_get(int *x, int *y); 259void _ecore_wl_input_pointer_xy_get(int *x, int *y);
260void _ecore_wl_input_grab_release(Ecore_Wl_Input *input, Ecore_Wl_Window *win);
261 261
262void _ecore_wl_dnd_add(Ecore_Wl_Input *input, struct wl_data_device *data_device, struct wl_data_offer *offer); 262void _ecore_wl_dnd_add(Ecore_Wl_Input *input, struct wl_data_device *data_device, struct wl_data_offer *offer);
263void _ecore_wl_dnd_enter(void *data, struct wl_data_device *data_device, unsigned int timestamp, struct wl_surface *surface, int x, int y, struct wl_data_offer *offer); 263void _ecore_wl_dnd_enter(void *data, struct wl_data_device *data_device, unsigned int timestamp, 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 e9ecd795e4..127563575d 100644
--- a/src/lib/ecore_wayland/ecore_wl_window.c
+++ b/src/lib/ecore_wayland/ecore_wl_window.c
@@ -136,8 +136,6 @@ ecore_wl_window_move(Ecore_Wl_Window *win, int x, int y)
136 136
137 if (!win) return; 137 if (!win) return;
138 138
139 win->moving = EINA_TRUE;
140
141 ecore_wl_window_update_location(win, x, y); 139 ecore_wl_window_update_location(win, x, y);
142 140
143 if (win->shell_surface) 141 if (win->shell_surface)
@@ -155,6 +153,7 @@ ecore_wl_window_move(Ecore_Wl_Window *win, int x, int y)
155 153
156 if ((!input) || (!input->seat)) return; 154 if ((!input) || (!input->seat)) return;
157 155
156 _ecore_wl_input_grab_release(input, win);
158 wl_shell_surface_move(win->shell_surface, input->seat, 157 wl_shell_surface_move(win->shell_surface, input->seat,
159 input->display->serial); 158 input->display->serial);
160 } 159 }
@@ -167,7 +166,6 @@ ecore_wl_window_resize(Ecore_Wl_Window *win, int w, int h, int location)
167 166
168 if (!win) return; 167 if (!win) return;
169 168
170 win->resizing = EINA_TRUE;
171 ecore_wl_window_update_size(win, w, h); 169 ecore_wl_window_update_size(win, w, h);
172 170
173 if (win->shell_surface) 171 if (win->shell_surface)
@@ -185,6 +183,7 @@ ecore_wl_window_resize(Ecore_Wl_Window *win, int w, int h, int location)
185 183
186 if ((!input) || (!input->seat)) return; 184 if ((!input) || (!input->seat)) return;
187 185
186 _ecore_wl_input_grab_release(input, win);
188 wl_shell_surface_resize(win->shell_surface, input->seat, 187 wl_shell_surface_resize(win->shell_surface, input->seat,
189 input->display->serial, location); 188 input->display->serial, location);
190 } 189 }