typedef struct shell_pointer_grab shell_pointer_grab_t;
typedef struct shell_pointer_grab_interface shell_pointer_grab_interface_t;
+typedef struct shell_keyboard_grab shell_keyboard_grab_t;
+typedef struct shell_keyboard_grab_interface shell_keyboard_grab_interface_t;
+
+typedef struct shell_touch_grab shell_touch_grab_t;
+typedef struct shell_touch_grab_interface shell_touch_grab_interface_t;
+
struct shell_pointer_grab
{
shell_seat_t *shseat;
uint32_t time, enum wl_pointer_axis axis, wl_fixed_t amount, void *data);
};
+struct shell_keyboard_grab
+{
+ shell_seat_t *shseat;
+ pepper_keyboard_t *keyboard;
+ shell_keyboard_grab_interface_t *interface;
+ void *userdata;
+};
+
+struct shell_keyboard_grab_interface
+{
+ void (*key)(shell_keyboard_grab_t *grab,
+ uint32_t time, uint32_t key, uint32_t state, void *data);
+ void (*modifiers)(shell_keyboard_grab_t *grab,
+ uint32_t time, uint32_t key, uint32_t state, void *data);
+};
+
+
+struct shell_touch_grab
+{
+ shell_seat_t *shseat;
+ pepper_touch_t *touch;
+ shell_touch_grab_interface_t *interface;
+ void *userdata;
+};
+
+struct shell_touch_grab_interface
+{
+ void (*down)(shell_touch_grab_t *grab,
+ uint32_t time, uint32_t id, double x, double y, void *data);
+ void (*up)(shell_touch_grab_t *grab,
+ uint32_t time, uint32_t id, void *data);
+ void (*motion)(shell_touch_grab_t *grab,
+ uint32_t time, uint32_t id, double x, double y, void *data);
+ void (*frame)(shell_touch_grab_t *grab, void *data);
+ void (*cancel)(shell_touch_grab_t *grab, void *data);
+};
+
+
struct shell_seat
{
desktop_shell_t *shell;
/* grab */
shell_pointer_grab_t pointer_grab;
shell_pointer_grab_t default_pointer_grab;
- /* TODO: keyboard, touch*/
+
+ shell_keyboard_grab_t keyboard_grab;
+ shell_keyboard_grab_t default_keyboard_grab;
+
+ shell_touch_grab_t touch_grab;
+ shell_touch_grab_t default_touch_grab;
/* Seat's logical device add/remove */
pepper_event_listener_t *pointer_add_listener;
void
shell_seat_pointer_end_grab(shell_seat_t *shseat);
+void
+shell_seat_keyboard_start_grab(shell_seat_t *shseat, shell_keyboard_grab_interface_t *grab, void *userdata);
+
+void
+shell_seat_keyboard_end_grab(shell_seat_t *shseat);
+
+void
+shell_seat_touch_start_grab(shell_seat_t *shseat, shell_touch_grab_interface_t *grab, void *userdata);
+
+void
+shell_seat_touch_end_grab(shell_seat_t *shseat);
+
void
shell_surface_move(shell_surface_t *shsurf, pepper_seat_t *seat, uint32_t serial);
shseat->pointer_grab.interface = shseat->default_pointer_grab.interface;
}
+void
+shell_seat_keyboard_start_grab(shell_seat_t *shseat,
+ shell_keyboard_grab_interface_t *grab, void *userdata)
+{
+ shseat->keyboard_grab.shseat = shseat;
+ shseat->keyboard_grab.interface = grab;
+ shseat->keyboard_grab.userdata = userdata;
+ shseat->keyboard_grab.keyboard = pepper_seat_get_keyboard(shseat->seat);
+}
+
+void
+shell_seat_keyboard_end_grab(shell_seat_t *shseat)
+{
+ shseat->keyboard_grab.interface = shseat->default_keyboard_grab.interface;
+}
+
+void
+shell_seat_touch_start_grab(shell_seat_t *shseat,
+ shell_touch_grab_interface_t *grab, void *userdata)
+{
+ shseat->touch_grab.shseat = shseat;
+ shseat->touch_grab.interface = grab;
+ shseat->touch_grab.userdata = userdata;
+ shseat->touch_grab.touch = pepper_seat_get_touch(shseat->seat);
+}
+
+void
+shell_seat_touch_end_grab(shell_seat_t *shseat)
+{
+ shseat->touch_grab.interface = shseat->default_touch_grab.interface;
+}
+
static void
shell_pointer_move_grab_motion(shell_pointer_grab_t *grab,
uint32_t time,
shell_pointer_default_grab_axis,
};
+static void
+shell_keyboard_default_grab_key(shell_keyboard_grab_t *grab,
+ uint32_t time,
+ uint32_t key,
+ uint32_t state,
+ void *data)
+{
+ /* TODO */
+}
+
+static void
+shell_keyboard_default_grab_modifiers(shell_keyboard_grab_t *grab,
+ uint32_t time,
+ uint32_t key,
+ uint32_t state,
+ void *data)
+{
+ /* TODO */
+}
+
+
+shell_keyboard_grab_interface_t shell_keyboard_default_grab =
+{
+ shell_keyboard_default_grab_key,
+ shell_keyboard_default_grab_modifiers,
+};
+
+static void
+shell_touch_default_grab_down(shell_touch_grab_t *grab,
+ uint32_t time,
+ uint32_t id,
+ double x,
+ double y,
+ void *data)
+{
+ /* TODO */
+}
+
+static void
+shell_touch_default_grab_up(shell_touch_grab_t *grab,
+ uint32_t time,
+ uint32_t id,
+ void *data)
+{
+ /* TODO */
+}
+
+static void
+shell_touch_default_grab_motion(shell_touch_grab_t *grab,
+ uint32_t time,
+ uint32_t id,
+ double x,
+ double y,
+ void *data)
+{
+ /* TODO */
+}
+
+static void
+shell_touch_default_grab_frame(shell_touch_grab_t *grab, void *data)
+{
+ /* TODO */
+}
+
+static void
+shell_touch_default_grab_cancel(shell_touch_grab_t *grab, void *data)
+{
+ /* TODO */
+}
+
+shell_touch_grab_interface_t shell_touch_default_grab =
+{
+ shell_touch_default_grab_down,
+ shell_touch_default_grab_up,
+ shell_touch_default_grab_motion,
+ shell_touch_default_grab_frame,
+ shell_touch_default_grab_cancel,
+};
+
static void
shell_seat_set_default_grab(shell_seat_t *shseat)
{
shell_seat_pointer_start_grab(shseat, &shell_pointer_default_grab, NULL);
- /* TODO: keyboard, touch */
+ shseat->default_keyboard_grab.interface = &shell_keyboard_default_grab;
+ shseat->default_keyboard_grab.shseat = shseat;
+ shseat->default_keyboard_grab.userdata = NULL;
+
+ shell_seat_keyboard_start_grab(shseat, &shell_keyboard_default_grab, NULL);
+
+ shseat->default_touch_grab.interface = &shell_touch_default_grab;
+ shseat->default_touch_grab.shseat = shseat;
+ shseat->default_touch_grab.userdata = NULL;
+
+ shell_seat_touch_start_grab(shseat, &shell_touch_default_grab, NULL);
}
static void
void *info,
void *data)
{
+ shell_seat_t *shseat = data;
+
switch (id)
{
- /* TODO */
+ case PEPPER_EVENT_KEYBOARD_KEY:
+ {
+ pepper_keyboard_key_event_t *event = info;
+
+ if (shseat->keyboard_grab.interface && shseat->keyboard_grab.interface->key)
+ {
+ shseat->keyboard_grab.interface->key(&shseat->keyboard_grab,
+ event->time,
+ event->key,
+ event->state,
+ shseat->keyboard_grab.userdata);
+ }
+ }
+ break;
+ case PEPPER_EVENT_KEYBOARD_MODIFIERS:
+ {
+ pepper_keyboard_key_event_t *event = info;
+
+ if (shseat->keyboard_grab.interface && shseat->keyboard_grab.interface->modifiers)
+ {
+ shseat->keyboard_grab.interface->modifiers(&shseat->keyboard_grab,
+ event->time,
+ event->key,
+ event->state,
+ shseat->keyboard_grab.userdata);
+ }
+ }
break;
default:
PEPPER_ERROR("unknown event %d\n", id);
void *info,
void *data)
{
+ shell_seat_t *shseat = data;
+
switch (id)
{
- /* TODO */
+ case PEPPER_EVENT_TOUCH_DOWN:
+ {
+ pepper_touch_down_event_t *event = info;
+
+ if (shseat->touch_grab.interface && shseat->touch_grab.interface->down)
+ {
+ shseat->touch_grab.interface->down(&shseat->touch_grab,
+ event->time,
+ event->id,
+ event->x,
+ event->y,
+ shseat->touch_grab.userdata);
+ }
+ }
+ break;
+ case PEPPER_EVENT_TOUCH_UP:
+ {
+ pepper_touch_up_event_t *event = info;
+
+ if (shseat->touch_grab.interface && shseat->touch_grab.interface->up)
+ {
+ shseat->touch_grab.interface->up(&shseat->touch_grab,
+ event->time,
+ event->id,
+ shseat->touch_grab.userdata);
+ }
+ }
+ break;
+ case PEPPER_EVENT_TOUCH_MOTION:
+ {
+ pepper_touch_motion_event_t *event = info;
+
+ if (shseat->touch_grab.interface && shseat->touch_grab.interface->motion)
+ {
+ shseat->touch_grab.interface->motion(&shseat->touch_grab,
+ event->time,
+ event->id,
+ event->x,
+ event->y,
+ shseat->touch_grab.userdata);
+ }
+ }
+ break;
+ case PEPPER_EVENT_TOUCH_FRAME:
+ {
+ if (shseat->touch_grab.interface && shseat->touch_grab.interface->frame)
+ {
+ shseat->touch_grab.interface->frame(&shseat->touch_grab,
+ shseat->touch_grab.userdata);
+ }
+ }
+ break;
+ case PEPPER_EVENT_TOUCH_CANCEL:
+ {
+ if (shseat->touch_grab.interface && shseat->touch_grab.interface->cancel)
+ {
+ shseat->touch_grab.interface->cancel(&shseat->touch_grab,
+ shseat->touch_grab.userdata);
+ }
+ }
break;
default:
PEPPER_ERROR("unknown event %d\n", id);
shseat->keyboard_modifiers_listener =
pepper_object_add_event_listener(keyboard, PEPPER_EVENT_KEYBOARD_MODIFIERS,
0, keyboard_event_handler, shseat);
+
+ shseat->keyboard_grab.keyboard = (pepper_keyboard_t *)keyboard;
}
break;
case PEPPER_EVENT_SEAT_TOUCH_ADD:
shseat->touch_cancel_listener =
pepper_object_add_event_listener(touch, PEPPER_EVENT_TOUCH_CANCEL,
0, touch_event_handler, shseat);
+
+ shseat->touch_grab.touch = (pepper_touch_t *)touch;
}
break;
default :