mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 03:22:04 +00:00
Bug #914 - ClutterEntry is confused about characters vs. bytes
* clutter/clutter-entry.c: (clutter_entry_ensure_layout), (clutter_entry_handle_key_event_internal), (clutter_entry_set_text): Fix mix-up of character and byte counts, handle unicode correctly. Use clutter_key_event_unicode() instead of clutter_keysym_to_unicode(). * clutter/clutter-event.c: (clutter_key_event_unicode): Don't ignore ClutterKeyEvent.unicode_value * clutter/clutter-keysyms-table.h: Rename header define so as not to conflict with clutter-keysyms.h Patch originally by Emmanuele Bassi, with input from Tommi Komulainen.
This commit is contained in:
parent
374022bc3d
commit
db232dd5e7
19
ChangeLog
19
ChangeLog
@ -1,3 +1,22 @@
|
||||
2008-06-09 Chris Lord <chris@openedhand.com>
|
||||
|
||||
Bug #914 - ClutterEntry is confused about characters vs. bytes
|
||||
|
||||
* clutter/clutter-entry.c: (clutter_entry_ensure_layout),
|
||||
(clutter_entry_handle_key_event_internal),
|
||||
(clutter_entry_set_text):
|
||||
Fix mix-up of character and byte counts, handle unicode correctly.
|
||||
Use clutter_key_event_unicode() instead of
|
||||
clutter_keysym_to_unicode().
|
||||
|
||||
* clutter/clutter-event.c: (clutter_key_event_unicode):
|
||||
Don't ignore ClutterKeyEvent.unicode_value
|
||||
|
||||
* clutter/clutter-keysyms-table.h:
|
||||
Rename header define so as not to conflict with clutter-keysyms.h
|
||||
|
||||
Patch originally by Emmanuele Bassi, with input from Tommi Komulainen.
|
||||
|
||||
2008-06-07 Øyvind Kolås <pippin@o-hand.com>
|
||||
|
||||
* clutter/clutter-texture.c: made the filter-quality proeprty also
|
||||
|
@ -104,7 +104,8 @@ struct _ClutterEntryPrivate
|
||||
gint extents_height;
|
||||
|
||||
gint width;
|
||||
gint n_chars;
|
||||
gint n_chars; /* number of chars */
|
||||
gint n_bytes; /* number of bytes */
|
||||
|
||||
guint alignment : 2;
|
||||
guint wrap : 1;
|
||||
@ -270,15 +271,23 @@ clutter_entry_ensure_layout (ClutterEntry *entry, gint width)
|
||||
pango_layout_set_font_description (priv->layout, priv->desc);
|
||||
|
||||
if (priv->text_visible)
|
||||
pango_layout_set_text (priv->layout, priv->text, priv->n_chars);
|
||||
pango_layout_set_text (priv->layout, priv->text, priv->n_bytes);
|
||||
else
|
||||
{
|
||||
gint len = g_utf8_strlen (priv->text, -1);
|
||||
gchar *invisible = g_strnfill (len, priv->priv_char);
|
||||
GString *str = g_string_sized_new (priv->n_bytes);
|
||||
gunichar invisible_char;
|
||||
gint i;
|
||||
|
||||
pango_layout_set_text (priv->layout, invisible, len);
|
||||
if (priv->priv_char != 0)
|
||||
invisible_char = priv->priv_char;
|
||||
else
|
||||
invisible_char = '*';
|
||||
|
||||
g_free (invisible);
|
||||
for (i = 0; i < priv->n_chars; i++)
|
||||
g_string_append_unichar (str, invisible_char);
|
||||
|
||||
pango_layout_set_text (priv->layout, str->str, str->len);
|
||||
g_string_free (str, TRUE);
|
||||
}
|
||||
|
||||
if (priv->wrap)
|
||||
@ -499,6 +508,7 @@ static inline void
|
||||
clutter_entry_handle_key_event_internal (ClutterEntry *entry,
|
||||
ClutterKeyEvent *event)
|
||||
{
|
||||
gunichar key_unichar;
|
||||
ClutterEntryPrivate *priv = entry->priv;
|
||||
gint pos = priv->position;
|
||||
gint len = 0;
|
||||
@ -567,8 +577,9 @@ clutter_entry_handle_key_event_internal (ClutterEntry *entry,
|
||||
break;
|
||||
|
||||
default:
|
||||
clutter_entry_insert_unichar (entry,
|
||||
clutter_keysym_to_unicode (keyval));
|
||||
key_unichar = clutter_key_event_unicode (event);
|
||||
if (g_unichar_validate (key_unichar))
|
||||
clutter_entry_insert_unichar (entry, key_unichar);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1027,7 +1038,10 @@ clutter_entry_set_text (ClutterEntry *entry,
|
||||
if (len < priv->max_length)
|
||||
{
|
||||
g_free (priv->text);
|
||||
|
||||
priv->text = g_strdup (text);
|
||||
priv->n_bytes = strlen (text);
|
||||
priv->n_chars = len;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1037,6 +1051,8 @@ clutter_entry_set_text (ClutterEntry *entry,
|
||||
g_free (priv->text);
|
||||
|
||||
priv->text = n;
|
||||
priv->n_bytes = strlen (n);
|
||||
priv->n_chars = priv->max_length;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1044,6 +1060,7 @@ clutter_entry_set_text (ClutterEntry *entry,
|
||||
g_free (priv->text);
|
||||
|
||||
priv->text = g_strdup (text);
|
||||
priv->n_bytes = strlen (text);
|
||||
priv->n_chars = g_utf8_strlen (priv->text, -1);
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "clutter-keysyms.h"
|
||||
#include "clutter-keysyms-table.h"
|
||||
#include "clutter-event.h"
|
||||
#include "clutter-private.h"
|
||||
@ -264,6 +265,9 @@ clutter_key_event_unicode (ClutterKeyEvent *keyev)
|
||||
{
|
||||
g_return_val_if_fail (keyev != NULL, 0);
|
||||
|
||||
if (keyev->unicode_value)
|
||||
return keyev->unicode_value;
|
||||
else
|
||||
return clutter_keysym_to_unicode (keyev->keyval);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef __CLUTTER_KEYSYMS_H__
|
||||
#define __CLUTTER_KEYSYMS_H__
|
||||
#ifndef __CLUTTER_KEYSYMS_TABLE_H__
|
||||
#define __CLUTTER_KEYSYMS_TABLE_H__
|
||||
|
||||
/* Code below from GDK, which contains following comment;
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user