mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-11 11:20:12 +00:00
wayland: Remove unused, commented out code
https://bugzilla.gnome.org/show_bug.cgi?id=692823
This commit is contained in:
parent
3493814ead
commit
ac3a50bfe6
@ -385,411 +385,6 @@ _gdk_wayland_device_get_keymap (GdkDevice *device)
|
||||
return GDK_DEVICE_CORE (device)->device->keymap;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
input_handle_motion(void *data, struct wl_input_device *input_device,
|
||||
uint32_t time,
|
||||
int32_t x, int32_t y, int32_t sx, int32_t sy)
|
||||
{
|
||||
GdkWaylandDevice *device = data;
|
||||
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (device->display);
|
||||
GdkEvent *event;
|
||||
|
||||
event = gdk_event_new (GDK_NOTHING);
|
||||
|
||||
device->time = time;
|
||||
device->x = x;
|
||||
device->y = y;
|
||||
device->surface_x = sx;
|
||||
device->surface_y = sy;
|
||||
|
||||
event->motion.type = GDK_MOTION_NOTIFY;
|
||||
event->motion.window = g_object_ref (device->pointer_focus);
|
||||
gdk_event_set_device (event, device->pointer);
|
||||
event->motion.time = time;
|
||||
event->motion.x = (gdouble) sx;
|
||||
event->motion.y = (gdouble) sy;
|
||||
event->motion.x_root = (gdouble) x;
|
||||
event->motion.y_root = (gdouble) y;
|
||||
event->motion.axes = NULL;
|
||||
event->motion.state = device->modifiers;
|
||||
event->motion.is_hint = 0;
|
||||
gdk_event_set_screen (event, display->screen);
|
||||
|
||||
GDK_NOTE (EVENTS,
|
||||
g_message ("motion %d %d, state %d",
|
||||
sx, sy, event->button.state));
|
||||
|
||||
_gdk_wayland_display_deliver_event (device->display, event);
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_button(void *data, struct wl_input_device *input_device,
|
||||
uint32_t time, uint32_t button, uint32_t state)
|
||||
{
|
||||
GdkWaylandDevice *device = data;
|
||||
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (device->display);
|
||||
GdkEvent *event;
|
||||
uint32_t modifier;
|
||||
int gdk_button;
|
||||
|
||||
switch (button) {
|
||||
case 273:
|
||||
gdk_button = 3;
|
||||
break;
|
||||
case 274:
|
||||
gdk_button = 2;
|
||||
break;
|
||||
default:
|
||||
gdk_button = button - 271;
|
||||
break;
|
||||
}
|
||||
|
||||
device->time = time;
|
||||
event = gdk_event_new (state ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE);
|
||||
event->button.window = g_object_ref (device->pointer_focus);
|
||||
gdk_event_set_device (event, device->pointer);
|
||||
event->button.time = time;
|
||||
event->button.x = (gdouble) device->surface_x;
|
||||
event->button.y = (gdouble) device->surface_y;
|
||||
event->button.x_root = (gdouble) device->x;
|
||||
event->button.y_root = (gdouble) device->y;
|
||||
event->button.axes = NULL;
|
||||
event->button.state = device->modifiers;
|
||||
event->button.button = gdk_button;
|
||||
gdk_event_set_screen (event, display->screen);
|
||||
|
||||
modifier = 1 << (8 + gdk_button - 1);
|
||||
if (state)
|
||||
device->modifiers |= modifier;
|
||||
else
|
||||
device->modifiers &= ~modifier;
|
||||
|
||||
GDK_NOTE (EVENTS,
|
||||
g_message ("button %d %s, state %d",
|
||||
event->button.button,
|
||||
state ? "press" : "release", event->button.state));
|
||||
|
||||
_gdk_wayland_display_deliver_event (device->display, event);
|
||||
}
|
||||
|
||||
static void
|
||||
translate_keyboard_string (GdkEventKey *event)
|
||||
{
|
||||
gunichar c = 0;
|
||||
gchar buf[7];
|
||||
|
||||
/* Fill in event->string crudely, since various programs
|
||||
* depend on it.
|
||||
*/
|
||||
event->string = NULL;
|
||||
|
||||
if (event->keyval != GDK_KEY_VoidSymbol)
|
||||
c = gdk_keyval_to_unicode (event->keyval);
|
||||
|
||||
if (c)
|
||||
{
|
||||
gsize bytes_written;
|
||||
gint len;
|
||||
|
||||
/* Apply the control key - Taken from Xlib
|
||||
*/
|
||||
if (event->state & GDK_CONTROL_MASK)
|
||||
{
|
||||
if ((c >= '@' && c < '\177') || c == ' ') c &= 0x1F;
|
||||
else if (c == '2')
|
||||
{
|
||||
event->string = g_memdup ("\0\0", 2);
|
||||
event->length = 1;
|
||||
buf[0] = '\0';
|
||||
return;
|
||||
}
|
||||
else if (c >= '3' && c <= '7') c -= ('3' - '\033');
|
||||
else if (c == '8') c = '\177';
|
||||
else if (c == '/') c = '_' & 0x1F;
|
||||
}
|
||||
|
||||
len = g_unichar_to_utf8 (c, buf);
|
||||
buf[len] = '\0';
|
||||
|
||||
event->string = g_locale_from_utf8 (buf, len,
|
||||
NULL, &bytes_written,
|
||||
NULL);
|
||||
if (event->string)
|
||||
event->length = bytes_written;
|
||||
}
|
||||
else if (event->keyval == GDK_KEY_Escape)
|
||||
{
|
||||
event->length = 1;
|
||||
event->string = g_strdup ("\033");
|
||||
}
|
||||
else if (event->keyval == GDK_KEY_Return ||
|
||||
event->keyval == GDK_KEY_KP_Enter)
|
||||
{
|
||||
event->length = 1;
|
||||
event->string = g_strdup ("\r");
|
||||
}
|
||||
|
||||
if (!event->string)
|
||||
{
|
||||
event->length = 0;
|
||||
event->string = g_strdup ("");
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
keyboard_repeat (gpointer data);
|
||||
|
||||
static gboolean
|
||||
deliver_key_event(GdkWaylandDevice *device,
|
||||
uint32_t time, uint32_t key, uint32_t state)
|
||||
{
|
||||
GdkEvent *event;
|
||||
uint32_t code, modifier, level;
|
||||
struct xkb_desc *xkb;
|
||||
GdkKeymap *keymap;
|
||||
|
||||
keymap = gdk_keymap_get_for_display (device->display);
|
||||
xkb = _gdk_wayland_keymap_get_xkb_desc (keymap);
|
||||
|
||||
device->time = time;
|
||||
event = gdk_event_new (state ? GDK_KEY_PRESS : GDK_KEY_RELEASE);
|
||||
event->key.window = g_object_ref (device->keyboard_focus);
|
||||
gdk_event_set_device (event, device->keyboard);
|
||||
event->button.time = time;
|
||||
event->key.state = device->modifiers;
|
||||
event->key.group = 0;
|
||||
code = key + xkb->min_key_code;
|
||||
event->key.hardware_keycode = code;
|
||||
|
||||
level = 0;
|
||||
if (device->modifiers & XKB_COMMON_SHIFT_MASK &&
|
||||
XkbKeyGroupWidth(xkb, code, 0) > 1)
|
||||
level = 1;
|
||||
|
||||
event->key.keyval = XkbKeySymEntry(xkb, code, level, 0);
|
||||
|
||||
modifier = xkb->map->modmap[code];
|
||||
if (state)
|
||||
device->modifiers |= modifier;
|
||||
else
|
||||
device->modifiers &= ~modifier;
|
||||
|
||||
event->key.is_modifier = modifier > 0;
|
||||
|
||||
translate_keyboard_string (&event->key);
|
||||
|
||||
_gdk_wayland_display_deliver_event (device->display, event);
|
||||
|
||||
GDK_NOTE (EVENTS,
|
||||
g_message ("keyboard event, code %d, sym %d, "
|
||||
"string %s, mods 0x%x",
|
||||
code, event->key.keyval,
|
||||
event->key.string, event->key.state));
|
||||
|
||||
device->repeat_count++;
|
||||
device->repeat_key = key;
|
||||
|
||||
if (state == 0)
|
||||
{
|
||||
if (device->repeat_timer)
|
||||
{
|
||||
g_source_remove (device->repeat_timer);
|
||||
device->repeat_timer = 0;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
else if (modifier)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else switch (device->repeat_count)
|
||||
{
|
||||
case 1:
|
||||
if (device->repeat_timer)
|
||||
{
|
||||
g_source_remove (device->repeat_timer);
|
||||
device->repeat_timer = 0;
|
||||
}
|
||||
|
||||
device->repeat_timer =
|
||||
gdk_threads_add_timeout (400, keyboard_repeat, device);
|
||||
return TRUE;
|
||||
case 2:
|
||||
device->repeat_timer =
|
||||
gdk_threads_add_timeout (80, keyboard_repeat, device);
|
||||
return FALSE;
|
||||
default:
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
keyboard_repeat (gpointer data)
|
||||
{
|
||||
GdkWaylandDevice *device = data;
|
||||
|
||||
return deliver_key_event (device, device->time, device->repeat_key, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_key(void *data, struct wl_input_device *input_device,
|
||||
uint32_t time, uint32_t key, uint32_t state)
|
||||
{
|
||||
GdkWaylandDevice *device = data;
|
||||
|
||||
device->repeat_count = 0;
|
||||
deliver_key_event (data, time, key, state);
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_pointer_focus(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t time, struct wl_surface *surface,
|
||||
int32_t x, int32_t y, int32_t sx, int32_t sy)
|
||||
{
|
||||
GdkWaylandDevice *device = data;
|
||||
GdkEvent *event;
|
||||
|
||||
device->time = time;
|
||||
if (device->pointer_focus)
|
||||
{
|
||||
event = gdk_event_new (GDK_LEAVE_NOTIFY);
|
||||
event->crossing.window = g_object_ref (device->pointer_focus);
|
||||
gdk_event_set_device (event, device->pointer);
|
||||
event->crossing.subwindow = NULL;
|
||||
event->crossing.time = time;
|
||||
event->crossing.x = (gdouble) device->surface_x;
|
||||
event->crossing.y = (gdouble) device->surface_y;
|
||||
event->crossing.x_root = (gdouble) device->x;
|
||||
event->crossing.y_root = (gdouble) device->y;
|
||||
|
||||
event->crossing.mode = GDK_CROSSING_NORMAL;
|
||||
event->crossing.detail = GDK_NOTIFY_ANCESTOR;
|
||||
event->crossing.focus = TRUE;
|
||||
event->crossing.state = 0;
|
||||
|
||||
_gdk_wayland_display_deliver_event (device->display, event);
|
||||
|
||||
GDK_NOTE (EVENTS,
|
||||
g_message ("leave, device %p surface %p",
|
||||
device, device->pointer_focus));
|
||||
|
||||
g_object_unref(device->pointer_focus);
|
||||
device->pointer_focus = NULL;
|
||||
}
|
||||
|
||||
if (surface)
|
||||
{
|
||||
device->pointer_focus = wl_surface_get_user_data(surface);
|
||||
g_object_ref(device->pointer_focus);
|
||||
|
||||
event = gdk_event_new (GDK_ENTER_NOTIFY);
|
||||
event->crossing.window = g_object_ref (device->pointer_focus);
|
||||
gdk_event_set_device (event, device->pointer);
|
||||
event->crossing.subwindow = NULL;
|
||||
event->crossing.time = time;
|
||||
event->crossing.x = (gdouble) sx;
|
||||
event->crossing.y = (gdouble) sy;
|
||||
event->crossing.x_root = (gdouble) x;
|
||||
event->crossing.y_root = (gdouble) y;
|
||||
|
||||
event->crossing.mode = GDK_CROSSING_NORMAL;
|
||||
event->crossing.detail = GDK_NOTIFY_ANCESTOR;
|
||||
event->crossing.focus = TRUE;
|
||||
event->crossing.state = 0;
|
||||
|
||||
device->surface_x = sx;
|
||||
device->surface_y = sy;
|
||||
device->x = x;
|
||||
device->y = y;
|
||||
|
||||
_gdk_wayland_display_deliver_event (device->display, event);
|
||||
|
||||
GDK_NOTE (EVENTS,
|
||||
g_message ("enter, device %p surface %p",
|
||||
device, device->pointer_focus));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_modifiers(GdkWaylandDevice *device, struct wl_array *keys)
|
||||
{
|
||||
uint32_t *k, *end;
|
||||
GdkKeymap *keymap;
|
||||
struct xkb_desc *xkb;
|
||||
|
||||
keymap = gdk_keymap_get_for_display (device->display);
|
||||
xkb = _gdk_wayland_keymap_get_xkb_desc (keymap);
|
||||
|
||||
end = keys->data + keys->size;
|
||||
device->modifiers = 0;
|
||||
for (k = keys->data; k < end; k++)
|
||||
device->modifiers |= xkb->map->modmap[*k];
|
||||
}
|
||||
|
||||
static void
|
||||
input_handle_keyboard_focus(void *data,
|
||||
struct wl_input_device *input_device,
|
||||
uint32_t time,
|
||||
struct wl_surface *surface,
|
||||
struct wl_array *keys)
|
||||
{
|
||||
GdkWaylandDevice *device = data;
|
||||
GdkEvent *event;
|
||||
|
||||
device->time = time;
|
||||
if (device->keyboard_focus)
|
||||
{
|
||||
_gdk_wayland_window_remove_focus (device->keyboard_focus);
|
||||
event = gdk_event_new (GDK_FOCUS_CHANGE);
|
||||
event->focus_change.window = g_object_ref (device->keyboard_focus);
|
||||
event->focus_change.send_event = FALSE;
|
||||
event->focus_change.in = FALSE;
|
||||
gdk_event_set_device (event, device->keyboard);
|
||||
|
||||
g_object_unref(device->keyboard_focus);
|
||||
device->keyboard_focus = NULL;
|
||||
|
||||
GDK_NOTE (EVENTS,
|
||||
g_message ("focus out, device %p surface %p",
|
||||
device, device->keyboard_focus));
|
||||
|
||||
_gdk_wayland_display_deliver_event (device->display, event);
|
||||
}
|
||||
|
||||
if (surface)
|
||||
{
|
||||
device->keyboard_focus = wl_surface_get_user_data(surface);
|
||||
g_object_ref(device->keyboard_focus);
|
||||
|
||||
event = gdk_event_new (GDK_FOCUS_CHANGE);
|
||||
event->focus_change.window = g_object_ref (device->keyboard_focus);
|
||||
event->focus_change.send_event = FALSE;
|
||||
event->focus_change.in = TRUE;
|
||||
gdk_event_set_device (event, device->keyboard);
|
||||
|
||||
update_modifiers (device, keys);
|
||||
|
||||
GDK_NOTE (EVENTS,
|
||||
g_message ("focus int, device %p surface %p",
|
||||
device, device->keyboard_focus));
|
||||
|
||||
_gdk_wayland_display_deliver_event (device->display, event);
|
||||
|
||||
_gdk_wayland_window_add_focus (device->keyboard_focus);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct wl_input_device_listener input_device_listener = {
|
||||
input_handle_motion,
|
||||
input_handle_button,
|
||||
input_handle_key,
|
||||
input_handle_pointer_focus,
|
||||
input_handle_keyboard_focus,
|
||||
};
|
||||
#endif
|
||||
|
||||
struct _DataOffer {
|
||||
struct wl_data_offer *offer;
|
||||
gint ref_count;
|
||||
|
Loading…
Reference in New Issue
Block a user