* clutter/clutter-main.c: (pre_parse_hook):

Call setlocale on init
        
        * clutter/x11/clutter-event-x11.c: (translate_key_event):
        Fix typo and use the same buffer size as xev
This commit is contained in:
Chris Lord 2008-06-10 14:01:43 +00:00
parent 8fcfd8ff21
commit 878b353568
4 changed files with 24 additions and 11 deletions

View File

@ -1,3 +1,11 @@
2008-06-10 Chris Lord <chris@openedhand.com>
* clutter/clutter-main.c: (pre_parse_hook):
Call setlocale on init
* clutter/x11/clutter-event-x11.c: (translate_key_event):
Fix typo and use the same buffer size as xev
2008-06-10 Øyvind Kolås <pippin@o-hand.com> 2008-06-10 Øyvind Kolås <pippin@o-hand.com>
* clutter/clutter-texture.c: improved documentation for * clutter/clutter-texture.c: improved documentation for

View File

@ -35,6 +35,8 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#define GETTEXT_PACKAGE "clutter"
#include <glib/gi18n-lib.h>
#include "clutter-event.h" #include "clutter-event.h"
#include "clutter-backend.h" #include "clutter-backend.h"
@ -990,6 +992,10 @@ pre_parse_hook (GOptionContext *context,
if (clutter_is_initialized) if (clutter_is_initialized)
return TRUE; return TRUE;
if (setlocale (LC_ALL, "") == NULL)
g_warning ("Locale not supported by C library.\n"
"Using the fallback 'C' locale.");
clutter_context = clutter_context_get_default (); clutter_context = clutter_context_get_default ();
clutter_context->id_pool = clutter_id_pool_new (256); clutter_context->id_pool = clutter_id_pool_new (256);

View File

@ -220,7 +220,7 @@ translate_key_event (ClutterBackend *backend,
ClutterEvent *event, ClutterEvent *event,
XEvent *xevent) XEvent *xevent)
{ {
char buffer[6]; char buffer[256+1];
int n; int n;
CLUTTER_NOTE (EVENT, "Translating key %s event", CLUTTER_NOTE (EVENT, "Translating key %s event",
@ -239,18 +239,17 @@ translate_key_event (ClutterBackend *backend,
0); 0);
/* unicode_value is the printable representation */ /* unicode_value is the printable representation */
n = XLookupString (&xevent->xkey, buffer, sizeof (buffer), NULL, NULL); n = XLookupString (&xevent->xkey, buffer, sizeof (buffer) - 1, NULL, NULL);
if (n == NoSymbol)
{ if (n != NoSymbol)
event->key.unicode_value = (gunichar)'\0';
}
else
{ {
event->key.unicode_value = g_utf8_get_char_validated (buffer, n); event->key.unicode_value = g_utf8_get_char_validated (buffer, n);
if ((event->key.unicode_value == -1) || if ((event->key.unicode_value != -1) &&
(event->key.unicode_value == -1)) (event->key.unicode_value != -2))
event->key.unicode_value = (gunichar)'\0'; return;
} }
event->key.unicode_value = (gunichar)'\0';
} }
static gboolean static gboolean