[PATCH weston v3 4/5] exposay: support systems without a pointer device
Stanislav Vorobiov
s.vorobiov at samsung.com
Tue May 13 23:43:04 PDT 2014
if the system doesn't have a pointer device
exposay_transition_active will crash
in weston_pointer_start_grab(seat->pointer, ...).
here we fix that and also implement exposay support
on systems with a touchscreen
---
desktop-shell/exposay.c | 95 ++++++++++++++++++++++++++++++++++++++++++++---
desktop-shell/shell.h | 1 +
2 files changed, 90 insertions(+), 6 deletions(-)
diff --git a/desktop-shell/exposay.c b/desktop-shell/exposay.c
index 1d8b40e..91932ce 100644
--- a/desktop-shell/exposay.c
+++ b/desktop-shell/exposay.c
@@ -391,6 +391,77 @@ static const struct weston_pointer_grab_interface exposay_ptr_grab = {
exposay_pointer_grab_cancel,
};
+static void
+exposay_touch_down(struct weston_touch_grab *grab, uint32_t time,
+ int touch_id, wl_fixed_t sx, wl_fixed_t sy)
+{
+ struct desktop_shell *shell =
+ container_of(grab, struct desktop_shell, exposay.grab_touch);
+
+ wl_signal_emit(&grab->touch->motion_signal, grab->touch);
+
+ exposay_pick(shell,
+ wl_fixed_to_int(grab->touch->grab_x),
+ wl_fixed_to_int(grab->touch->grab_y));
+
+ /* Store the surface we clicked on, and don't do anything if we end up
+ * releasing on a different surface. */
+ if (grab->touch->num_tp == 1) {
+ shell->exposay.clicked = shell->exposay.focus_current;
+ }
+}
+
+static void
+exposay_touch_up(struct weston_touch_grab *grab, uint32_t time, int touch_id)
+{
+ struct desktop_shell *shell =
+ container_of(grab, struct desktop_shell, exposay.grab_touch);
+ struct weston_seat *seat = grab->touch->seat;
+
+ if (grab->touch->num_tp == 0) {
+ if (shell->exposay.focus_current == shell->exposay.clicked)
+ exposay_set_state(shell, EXPOSAY_TARGET_SWITCH, seat);
+ else
+ shell->exposay.clicked = NULL;
+ }
+}
+
+static void
+exposay_touch_motion(struct weston_touch_grab *grab, uint32_t time,
+ int touch_id, wl_fixed_t sx, wl_fixed_t sy)
+{
+ struct desktop_shell *shell =
+ container_of(grab, struct desktop_shell, exposay.grab_touch);
+
+ wl_signal_emit(&grab->touch->motion_signal, grab->touch);
+
+ exposay_pick(shell,
+ wl_fixed_to_int(grab->touch->grab_x),
+ wl_fixed_to_int(grab->touch->grab_y));
+}
+
+static void
+exposay_touch_frame(struct weston_touch_grab *grab)
+{
+}
+
+static void
+exposay_touch_grab_cancel(struct weston_touch_grab *grab)
+{
+ struct desktop_shell *shell =
+ container_of(grab, struct desktop_shell, exposay.grab_touch);
+
+ exposay_set_state(shell, EXPOSAY_TARGET_CANCEL, shell->exposay.seat);
+}
+
+static const struct weston_touch_grab_interface exposay_touch_grab = {
+ exposay_touch_down,
+ exposay_touch_up,
+ exposay_touch_motion,
+ exposay_touch_frame,
+ exposay_touch_grab_cancel,
+};
+
static int
exposay_maybe_move(struct desktop_shell *shell, int row, int column)
{
@@ -517,7 +588,10 @@ exposay_set_inactive(struct desktop_shell *shell)
struct weston_seat *seat = shell->exposay.seat;
weston_keyboard_end_grab(seat->keyboard);
- weston_pointer_end_grab(seat->pointer);
+ if (seat->pointer)
+ weston_pointer_end_grab(seat->pointer);
+ if (seat->touch)
+ weston_touch_end_grab(seat->touch);
if (seat->keyboard->input_method_resource)
seat->keyboard->grab = &seat->keyboard->input_method_grab;
@@ -567,11 +641,20 @@ exposay_transition_active(struct desktop_shell *shell)
&shell->exposay.grab_kbd);
weston_keyboard_set_focus(seat->keyboard, NULL);
- shell->exposay.grab_ptr.interface = &exposay_ptr_grab;
- weston_pointer_start_grab(seat->pointer,
- &shell->exposay.grab_ptr);
- weston_pointer_set_focus(seat->pointer, NULL,
- seat->pointer->x, seat->pointer->y);
+ if (seat->pointer) {
+ shell->exposay.grab_ptr.interface = &exposay_ptr_grab;
+ weston_pointer_start_grab(seat->pointer,
+ &shell->exposay.grab_ptr);
+ weston_pointer_set_focus(seat->pointer, NULL,
+ seat->pointer->x, seat->pointer->y);
+ }
+
+ if (seat->touch) {
+ shell->exposay.grab_touch.interface = &exposay_touch_grab;
+ weston_touch_start_grab(seat->touch,
+ &shell->exposay.grab_touch);
+ weston_touch_set_focus(seat, NULL);
+ }
wl_list_for_each(shell_output, &shell->output_list, link) {
enum exposay_layout_state state;
diff --git a/desktop-shell/shell.h b/desktop-shell/shell.h
index 6e63785..ba7951a 100644
--- a/desktop-shell/shell.h
+++ b/desktop-shell/shell.h
@@ -74,6 +74,7 @@ struct exposay {
struct weston_keyboard_grab grab_kbd;
struct weston_pointer_grab grab_ptr;
+ struct weston_touch_grab grab_touch;
enum exposay_target_state state_target;
enum exposay_layout_state state_cur;
--
1.7.9.5
More information about the wayland-devel
mailing list