#include <tbm_surface.h>
#include <tbm_surface_internal.h>
#include "xdg-shell-client-protocol.h"
+#include <tizen-extension-client-protocol.h>
static uint64_t buffer_info_key;
#define BUFFER_INFO_KEY (unsigned long)(&buffer_info_key)
struct wl_seat *seat;
struct wayland_tbm_client *wl_tbm;
bool has_xrgb;
+
+ struct tizen_input_device_manager *devicemgr;
+ int notified;
+ bool blocked;
};
struct window {
{
fprintf(stderr, "touch_handle_down id:%d, x:%d, y:%d\n",
id, wl_fixed_to_int(x), wl_fixed_to_int(y));
+
+ struct display *d = data;
+
+ tizen_input_device_manager_block_events(d->devicemgr, 0, TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD, 50000);
+
+ while (d->notified == -1)
+ wl_display_roundtrip(d->display);
+
+ if (d->notified == TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE) {
+ printf("Success to block keyboard events\n");
+ } else {
+ printf("Failed to block keyboard events: %d\n", d->notified);
+ }
+ d->notified = -1;
+ d->blocked = true;
}
static void touch_handle_up(void *data, struct wl_touch *wl_touch,
uint32_t serial, uint32_t time, int32_t id)
{
fprintf(stderr, "touch_handle_up id:%d\n", id);
+
+ struct display *d = data;
+
+ if (!d->blocked) return;
+ tizen_input_device_manager_unblock_events(d->devicemgr, 0);
+
+ while (d->notified == -1)
+ wl_display_roundtrip(d->display);
+
+ if (d->notified == TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE) {
+ printf("Success to unblock keyboard events\n");
+ } else {
+ printf("Failed to unblock keyboard events: %d\n", d->notified);
+ }
+ d->notified = -1;
+ d->blocked = false;
}
static void touch_handle_motion(void *data, struct wl_touch *wl_touch,
uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
{
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
- fprintf(stderr, "keyboard_handle_key: PRESSED\n");
+ fprintf(stderr, "keyboard_handle_key: key:%d, PRESSED\n", key);
} else {
- fprintf(stderr, "keyboard_handle_key: RELEASED\n");
+ fprintf(stderr, "keyboard_handle_key: key:%d, RELEASED\n", key);
}
}
static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
enum wl_seat_capability caps)
{
+ struct display *d = data;
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD)) {
struct wl_keyboard *keyboard = wl_seat_get_keyboard(wl_seat);
wl_keyboard_add_listener(keyboard, &keyboard_listener, NULL);
}
if ((caps & WL_SEAT_CAPABILITY_TOUCH)) {
struct wl_touch *touch = wl_seat_get_touch(wl_seat);
- wl_touch_add_listener(touch, &touch_listener, NULL);
+ wl_touch_add_listener(touch, &touch_listener, d);
fprintf(stderr, "seat_handle_capabilities: touch\n");
}
}
};
static void
+input_device_manager_handle_error(void *data,
+ struct tizen_input_device_manager *tizen_input_device_manager,
+ uint32_t errorcode)
+{
+ struct display *d = data;
+ fprintf(stderr, "errorcode: %d\n", errorcode);
+ d->notified = errorcode;
+}
+
+static void
+input_device_manager_handle_block_expired(void *data,
+ struct tizen_input_device_manager *tizen_input_device_manager)
+{
+ fprintf(stderr, "block expired\n");
+}
+
+static const struct tizen_input_device_manager_listener _input_device_manager_listener =
+{
+ .device_add = NULL,
+ .device_remove = NULL,
+ .error = input_device_manager_handle_error,
+ .block_expired = input_device_manager_handle_block_expired,
+};
+
+static void
registry_handle_global(void *data, struct wl_registry *registry,
uint32_t id, const char *interface, uint32_t version)
{
id, &wl_seat_interface, 7);
wl_seat_add_listener(d->seat, &seat_listener, d);
fprintf(stderr, "wl_seat bound!\n");
- }
+ } else if (strcmp(interface, "tizen_input_device_manager") == 0) {
+ d->devicemgr = wl_registry_bind(registry,
+ id, &tizen_input_device_manager_interface, version);
+ tizen_input_device_manager_add_listener(d->devicemgr,
+ &_input_device_manager_listener, d);
+ fprintf(stderr, "tizen input device manager bound!\n");
+ }
}
static void
exit(1);
}
+ display->notified = -1;
+
return display;
}
static void
destroy_display(struct display *display)
{
+ if (display->seat)
+ wl_seat_destroy(display->seat);
+
+ if (display->devicemgr)
+ tizen_input_device_manager_destroy(display->devicemgr);
+
if (display->shm)
wl_shm_destroy(display->shm);