mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-16 07:04:29 +00:00
gdk: Fix Windows and OS X backend for keyevent.string removal
This commit is contained in:
parent
03a6420c37
commit
7e919aaaa5
@ -1113,8 +1113,6 @@ fill_key_event (GdkSurface *window,
|
|||||||
{
|
{
|
||||||
GdkEventPrivate *priv;
|
GdkEventPrivate *priv;
|
||||||
GdkQuartzDeviceManagerCore *device_manager;
|
GdkQuartzDeviceManagerCore *device_manager;
|
||||||
gchar buf[7];
|
|
||||||
gunichar c = 0;
|
|
||||||
|
|
||||||
priv = (GdkEventPrivate *) event;
|
priv = (GdkEventPrivate *) event;
|
||||||
priv->windowing_data = [nsevent retain];
|
priv->windowing_data = [nsevent retain];
|
||||||
@ -1189,44 +1187,6 @@ fill_key_event (GdkSurface *window,
|
|||||||
gdk_keymap_add_virtual_modifiers (gdk_display_get_keymap (_gdk_display),
|
gdk_keymap_add_virtual_modifiers (gdk_display_get_keymap (_gdk_display),
|
||||||
&event->key.state);
|
&event->key.state);
|
||||||
|
|
||||||
event->key.string = NULL;
|
|
||||||
|
|
||||||
/* Fill in ->string since apps depend on it, taken from the x11 backend. */
|
|
||||||
if (event->key.keyval != GDK_KEY_VoidSymbol)
|
|
||||||
c = gdk_keyval_to_unicode (event->key.keyval);
|
|
||||||
|
|
||||||
if (c)
|
|
||||||
{
|
|
||||||
gsize bytes_written;
|
|
||||||
gint len;
|
|
||||||
|
|
||||||
len = g_unichar_to_utf8 (c, buf);
|
|
||||||
buf[len] = '\0';
|
|
||||||
|
|
||||||
event->key.string = g_locale_from_utf8 (buf, len,
|
|
||||||
NULL, &bytes_written,
|
|
||||||
NULL);
|
|
||||||
if (event->key.string)
|
|
||||||
event->key.length = bytes_written;
|
|
||||||
}
|
|
||||||
else if (event->key.keyval == GDK_KEY_Escape)
|
|
||||||
{
|
|
||||||
event->key.length = 1;
|
|
||||||
event->key.string = g_strdup ("\033");
|
|
||||||
}
|
|
||||||
else if (event->key.keyval == GDK_KEY_Return ||
|
|
||||||
event->key.keyval == GDK_KEY_KP_Enter)
|
|
||||||
{
|
|
||||||
event->key.length = 1;
|
|
||||||
event->key.string = g_strdup ("\r");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!event->key.string)
|
|
||||||
{
|
|
||||||
event->key.length = 0;
|
|
||||||
event->key.string = g_strdup ("");
|
|
||||||
}
|
|
||||||
|
|
||||||
GDK_NOTE(EVENTS,
|
GDK_NOTE(EVENTS,
|
||||||
g_message ("key %s:\t\twindow: %p key: %12s %d",
|
g_message ("key %s:\t\twindow: %p key: %12s %d",
|
||||||
type == GDK_KEY_PRESS ? "press" : "release",
|
type == GDK_KEY_PRESS ? "press" : "release",
|
||||||
|
@ -738,8 +738,6 @@ build_wm_ime_composition_event (GdkEvent *event,
|
|||||||
build_key_event_state (event, key_state);
|
build_key_event_state (event, key_state);
|
||||||
|
|
||||||
event->key.hardware_keycode = 0; /* FIXME: What should it be? */
|
event->key.hardware_keycode = 0; /* FIXME: What should it be? */
|
||||||
event->key.string = NULL;
|
|
||||||
event->key.length = 0;
|
|
||||||
event->key.keyval = gdk_unicode_to_keyval (wc);
|
event->key.keyval = gdk_unicode_to_keyval (wc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -768,7 +766,7 @@ print_event_state (guint state)
|
|||||||
void
|
void
|
||||||
_gdk_win32_print_event (const GdkEvent *event)
|
_gdk_win32_print_event (const GdkEvent *event)
|
||||||
{
|
{
|
||||||
gchar *escaped, *kvname;
|
gchar *kvname;
|
||||||
|
|
||||||
g_print ("%s%*s===> ", (debug_indent > 0 ? "\n" : ""), debug_indent, "");
|
g_print ("%s%*s===> ", (debug_indent > 0 ? "\n" : ""), debug_indent, "");
|
||||||
switch (event->any.type)
|
switch (event->any.type)
|
||||||
@ -819,17 +817,10 @@ _gdk_win32_print_event (const GdkEvent *event)
|
|||||||
break;
|
break;
|
||||||
case GDK_KEY_PRESS:
|
case GDK_KEY_PRESS:
|
||||||
case GDK_KEY_RELEASE:
|
case GDK_KEY_RELEASE:
|
||||||
if (event->key.length == 0)
|
|
||||||
escaped = g_strdup ("");
|
|
||||||
else
|
|
||||||
escaped = g_strescape (event->key.string, NULL);
|
|
||||||
kvname = gdk_keyval_name (event->key.keyval);
|
kvname = gdk_keyval_name (event->key.keyval);
|
||||||
g_print ("%#.02x group:%d %s %d:\"%s\" ",
|
g_print ("%#.02x group:%d %s",
|
||||||
event->key.hardware_keycode, event->key.group,
|
event->key.hardware_keycode, event->key.group,
|
||||||
(kvname ? kvname : "??"),
|
(kvname ? kvname : "??"));
|
||||||
event->key.length,
|
|
||||||
escaped);
|
|
||||||
g_free (escaped);
|
|
||||||
print_event_state (event->key.state);
|
print_event_state (event->key.state);
|
||||||
break;
|
break;
|
||||||
case GDK_ENTER_NOTIFY:
|
case GDK_ENTER_NOTIFY:
|
||||||
@ -940,73 +931,6 @@ _gdk_win32_append_event (GdkEvent *event)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
fill_key_event_string (GdkEvent *event)
|
|
||||||
{
|
|
||||||
gunichar c;
|
|
||||||
gchar buf[256];
|
|
||||||
|
|
||||||
/* Fill in event->string crudely, since various programs
|
|
||||||
* depend on it.
|
|
||||||
*/
|
|
||||||
|
|
||||||
c = 0;
|
|
||||||
if (event->key.keyval != GDK_KEY_VoidSymbol)
|
|
||||||
c = gdk_keyval_to_unicode (event->key.keyval);
|
|
||||||
|
|
||||||
if (c)
|
|
||||||
{
|
|
||||||
gsize bytes_written;
|
|
||||||
gint len;
|
|
||||||
|
|
||||||
/* Apply the control key - Taken from Xlib
|
|
||||||
*/
|
|
||||||
if (event->key.state & GDK_CONTROL_MASK)
|
|
||||||
{
|
|
||||||
if ((c >= '@' && c < '\177') || c == ' ')
|
|
||||||
c &= 0x1F;
|
|
||||||
else if (c == '2')
|
|
||||||
{
|
|
||||||
event->key.string = g_memdup ("\0\0", 2);
|
|
||||||
event->key.length = 1;
|
|
||||||
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->key.string = g_locale_from_utf8 (buf, len,
|
|
||||||
NULL, &bytes_written,
|
|
||||||
NULL);
|
|
||||||
if (event->key.string)
|
|
||||||
event->key.length = bytes_written;
|
|
||||||
}
|
|
||||||
else if (event->key.keyval == GDK_KEY_Escape)
|
|
||||||
{
|
|
||||||
event->key.length = 1;
|
|
||||||
event->key.string = g_strdup ("\033");
|
|
||||||
}
|
|
||||||
else if (event->key.keyval == GDK_KEY_Return ||
|
|
||||||
event->key.keyval == GDK_KEY_KP_Enter)
|
|
||||||
{
|
|
||||||
event->key.length = 1;
|
|
||||||
event->key.string = g_strdup ("\r");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!event->key.string)
|
|
||||||
{
|
|
||||||
event->key.length = 0;
|
|
||||||
event->key.string = g_strdup ("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static GdkWin32MessageFilterReturn
|
static GdkWin32MessageFilterReturn
|
||||||
apply_message_filters (GdkDisplay *display,
|
apply_message_filters (GdkDisplay *display,
|
||||||
MSG *msg,
|
MSG *msg,
|
||||||
@ -2288,8 +2212,6 @@ gdk_event_translate (MSG *msg,
|
|||||||
event->any.surface = window;
|
event->any.surface = window;
|
||||||
event->key.time = _gdk_win32_get_next_tick (msg->time);
|
event->key.time = _gdk_win32_get_next_tick (msg->time);
|
||||||
event->key.keyval = GDK_KEY_VoidSymbol;
|
event->key.keyval = GDK_KEY_VoidSymbol;
|
||||||
event->key.string = NULL;
|
|
||||||
event->key.length = 0;
|
|
||||||
event->key.hardware_keycode = msg->wParam;
|
event->key.hardware_keycode = msg->wParam;
|
||||||
/* save original scancode */
|
/* save original scancode */
|
||||||
gdk_event_set_scancode (event, msg->lParam >> 16);
|
gdk_event_set_scancode (event, msg->lParam >> 16);
|
||||||
@ -2360,8 +2282,6 @@ gdk_event_translate (MSG *msg,
|
|||||||
else
|
else
|
||||||
impl->leading_surrogate_keyup = 0;
|
impl->leading_surrogate_keyup = 0;
|
||||||
|
|
||||||
fill_key_event_string (event);
|
|
||||||
|
|
||||||
/* Only one release key event is fired when both shift keys are pressed together
|
/* Only one release key event is fired when both shift keys are pressed together
|
||||||
and then released. In order to send the missing event, press events for shift
|
and then released. In order to send the missing event, press events for shift
|
||||||
keys are recorded and sent together when the release event occurs.
|
keys are recorded and sent together when the release event occurs.
|
||||||
|
Loading…
Reference in New Issue
Block a user