forked from AuroraMiddleware/gtk
Fill in string, length and is_modifier for key events. Map some more keys
2006-07-17 Richard Hult <richard@imendio.com> * gdk/quartz/gdkevents-quartz.c: (create_key_event): * gdk/quartz/gdkkeys-quartz.c: (_gdk_quartz_key_event_type), (_gdk_quartz_key_is_modifier): * gdk/quartz/gdkprivate-quartz.h: Fill in string, length and is_modifier for key events. Map some more keys into gdk keyvals.
This commit is contained in:
parent
1f9befb77a
commit
d473868ace
@ -1,3 +1,11 @@
|
||||
2006-07-17 Richard Hult <richard@imendio.com>
|
||||
|
||||
* gdk/quartz/gdkevents-quartz.c: (create_key_event):
|
||||
* gdk/quartz/gdkkeys-quartz.c: (_gdk_quartz_key_event_type),
|
||||
(_gdk_quartz_key_is_modifier):
|
||||
* gdk/quartz/gdkprivate-quartz.h: Fill in string, length and
|
||||
is_modifier for key events. Map some more keys into gdk keyvals.
|
||||
|
||||
2006-07-17 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtknotebook.c (gtk_notebook_stop_reorder): Don't undo
|
||||
|
@ -1,3 +1,11 @@
|
||||
2006-07-17 Richard Hult <richard@imendio.com>
|
||||
|
||||
* gdk/quartz/gdkevents-quartz.c: (create_key_event):
|
||||
* gdk/quartz/gdkkeys-quartz.c: (_gdk_quartz_key_event_type),
|
||||
(_gdk_quartz_key_is_modifier):
|
||||
* gdk/quartz/gdkprivate-quartz.h: Fill in string, length and
|
||||
is_modifier for key events. Map some more keys into gdk keyvals.
|
||||
|
||||
2006-07-17 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtknotebook.c (gtk_notebook_stop_reorder): Don't undo
|
||||
|
@ -26,7 +26,11 @@
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
#include "gdkscreen.h"
|
||||
#include "gdkkeysyms.h"
|
||||
|
||||
#include "gdkprivate-quartz.h"
|
||||
|
||||
static GPollFD event_poll_fd;
|
||||
@ -1340,6 +1344,8 @@ static GdkEvent *
|
||||
create_key_event (GdkWindow *window, NSEvent *nsevent, GdkEventType type)
|
||||
{
|
||||
GdkEvent *event;
|
||||
gchar buf[7];
|
||||
gunichar c = 0;
|
||||
|
||||
event = gdk_event_new (type);
|
||||
event->key.window = window;
|
||||
@ -1347,6 +1353,8 @@ create_key_event (GdkWindow *window, NSEvent *nsevent, GdkEventType type)
|
||||
event->key.state = get_keyboard_modifiers_from_nsevent (nsevent);
|
||||
event->key.hardware_keycode = [nsevent keyCode];
|
||||
event->key.group = ([nsevent modifierFlags] & NSAlternateKeyMask) ? 1 : 0;
|
||||
|
||||
event->key.keyval = GDK_VoidSymbol;
|
||||
|
||||
gdk_keymap_translate_keyboard_state (NULL,
|
||||
event->key.hardware_keycode,
|
||||
@ -1355,6 +1363,46 @@ create_key_event (GdkWindow *window, NSEvent *nsevent, GdkEventType type)
|
||||
&event->key.keyval,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
event->key.is_modifier = _gdk_quartz_key_is_modifier (event->key.hardware_keycode);
|
||||
|
||||
event->key.string = NULL;
|
||||
|
||||
/* Fill in ->string since apps depend on it, taken from the x11 backend. */
|
||||
if (event->key.keyval != GDK_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_Escape)
|
||||
{
|
||||
event->key.length = 1;
|
||||
event->key.string = g_strdup ("\033");
|
||||
}
|
||||
else if (event->key.keyval == GDK_Return ||
|
||||
event->key.keyval == GDK_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,
|
||||
g_message ("key %s:\t\twindow: %p key: %12s %d",
|
||||
type == GDK_KEY_PRESS ? "press" : "release",
|
||||
|
@ -160,6 +160,8 @@ const static struct {
|
||||
guint keyval;
|
||||
} special_ucs_table [] = {
|
||||
{ 0x0001, GDK_Home },
|
||||
{ 0x0003, GDK_Return },
|
||||
{ 0x0004, GDK_End },
|
||||
{ 0x0008, GDK_BackSpace },
|
||||
{ 0x0009, GDK_Tab },
|
||||
{ 0x000b, GDK_Page_Up },
|
||||
@ -169,7 +171,8 @@ const static struct {
|
||||
{ 0x001c, GDK_Left },
|
||||
{ 0x001d, GDK_Right },
|
||||
{ 0x001e, GDK_Up },
|
||||
{ 0x001f, GDK_Down }
|
||||
{ 0x001f, GDK_Down },
|
||||
{ 0x007f, GDK_Delete }
|
||||
};
|
||||
|
||||
static void
|
||||
@ -582,7 +585,8 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
|
||||
/* What sort of key event is this? Returns one of
|
||||
* GDK_KEY_PRESS, GDK_KEY_RELEASE, GDK_NOTHING (should be ignored)
|
||||
*/
|
||||
GdkEventType _gdk_quartz_key_event_type (NSEvent *event)
|
||||
GdkEventType
|
||||
_gdk_quartz_key_event_type (NSEvent *event)
|
||||
{
|
||||
unsigned short keycode;
|
||||
unsigned int flags;
|
||||
@ -590,10 +594,14 @@ GdkEventType _gdk_quartz_key_event_type (NSEvent *event)
|
||||
|
||||
switch ([event type])
|
||||
{
|
||||
case NSKeyDown: return GDK_KEY_PRESS;
|
||||
case NSKeyUp: return GDK_KEY_RELEASE;
|
||||
case NSFlagsChanged: break; /* Continue... */
|
||||
default: g_assert_not_reached ();
|
||||
case NSKeyDown:
|
||||
return GDK_KEY_PRESS;
|
||||
case NSKeyUp:
|
||||
return GDK_KEY_RELEASE;
|
||||
case NSFlagsChanged:
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
/* For flags-changed events, we have to find the special key that caused the
|
||||
@ -604,15 +612,32 @@ GdkEventType _gdk_quartz_key_event_type (NSEvent *event)
|
||||
for (i = 0; i < G_N_ELEMENTS (known_keys); i++)
|
||||
{
|
||||
if (known_keys[i].keycode == keycode)
|
||||
{
|
||||
if (flags & known_keys[i].modmask)
|
||||
return GDK_KEY_PRESS;
|
||||
else
|
||||
return GDK_KEY_RELEASE;
|
||||
}
|
||||
{
|
||||
if (flags & known_keys[i].modmask)
|
||||
return GDK_KEY_PRESS;
|
||||
else
|
||||
return GDK_KEY_RELEASE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Some keypresses (eg: Expose' activations) seem to trigger flags-changed
|
||||
* events for no good reason. Ignore them! */
|
||||
return GDK_NOTHING;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gdk_quartz_key_is_modifier (guint keycode)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (known_keys); i++)
|
||||
{
|
||||
if (known_keys[i].modmask == 0)
|
||||
break;
|
||||
|
||||
if (known_keys[i].keycode == keycode)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -96,6 +96,7 @@ GdkGC *_gdk_quartz_gc_new (GdkDrawable *drawable,
|
||||
void _gdk_windowing_window_init (void);
|
||||
void _gdk_events_init (void);
|
||||
void _gdk_visual_init (void);
|
||||
void _gdk_input_init (void);
|
||||
|
||||
void _gdk_quartz_set_context_fill_color_from_pixel (CGContextRef context, GdkColormap *colormap, guint32 pixel);
|
||||
void _gdk_quartz_set_context_stroke_color_from_pixel (CGContextRef context, GdkColormap *colormap, guint32 pixel);
|
||||
@ -122,7 +123,8 @@ GdkImage *_gdk_quartz_copy_to_image (GdkDrawable *drawable,
|
||||
|
||||
void _gdk_quartz_send_map_events (GdkWindow *window);
|
||||
|
||||
GdkEventType _gdk_quartz_flags_changed_is_press (NSEvent *event);
|
||||
GdkEventType _gdk_quartz_key_event_type (NSEvent *event);
|
||||
gboolean _gdk_quartz_key_is_modifier (guint keycode);
|
||||
|
||||
extern GdkWindow *_gdk_quartz_keyboard_grab_window;
|
||||
extern GdkWindow *_gdk_quartz_pointer_grab_window;
|
||||
|
Loading…
Reference in New Issue
Block a user