Kaydet (Commit) 8cef6c7e authored tarafından Caolán McNamara's avatar Caolán McNamara

Related: fdo#41169 fix GTK non-Latin keyboard layout with Latin shortcuts

See also rhbz#958300

Change-Id: I5c3cf9652adb7b1c9ec53a32ed39f231a09ae1d7
üst 48c29ef3
...@@ -335,6 +335,14 @@ static sal_uInt16 GetKeyCode( guint keyval ) ...@@ -335,6 +335,14 @@ static sal_uInt16 GetKeyCode( guint keyval )
return nCode; return nCode;
} }
static guint GetKeyValFor(GdkKeymap* pKeyMap, guint16 hardware_keycode, guint8 group)
{
guint updated_keyval = 0;
gdk_keymap_translate_keyboard_state(pKeyMap, hardware_keycode,
(GdkModifierType)0, group, &updated_keyval, NULL, NULL, NULL);
return updated_keyval;
}
// F10 means either KEY_F10 or KEY_MENU, which has to be decided // F10 means either KEY_F10 or KEY_MENU, which has to be decided
// in the independent part. // in the independent part.
struct KeyAlternate struct KeyAlternate
...@@ -385,7 +393,7 @@ struct DamageTracker : public basebmp::IBitmapDeviceDamageTracker ...@@ -385,7 +393,7 @@ struct DamageTracker : public basebmp::IBitmapDeviceDamageTracker
void GtkSalFrame::doKeyCallback( guint state, void GtkSalFrame::doKeyCallback( guint state,
guint keyval, guint keyval,
guint16 hardware_keycode, guint16 hardware_keycode,
guint8 /*group*/, guint8 group,
guint32 time, guint32 time,
sal_Unicode aOrigCode, sal_Unicode aOrigCode,
bool bDown, bool bDown,
...@@ -417,33 +425,48 @@ void GtkSalFrame::doKeyCallback( guint state, ...@@ -417,33 +425,48 @@ void GtkSalFrame::doKeyCallback( guint state,
} }
#endif #endif
/* #i42122# translate all keys with Ctrl and/or Alt to group 0 /*
* else shortcuts (e.g. Ctrl-o) will not work but be inserted by * #i42122# translate all keys with Ctrl and/or Alt to group 0 else
* the application * shortcuts (e.g. Ctrl-o) will not work but be inserted by the
*/ * application
/* #i52338# do this for all keys that the independent part has no key code for *
*/ * #i52338# do this for all keys that the independent part has no key code
* for
*
* fdo#41169 rather than use group 0, detect if there is a group which can
* be used to input Latin text and use that if possible
*/
aEvent.mnCode = GetKeyCode( keyval ); aEvent.mnCode = GetKeyCode( keyval );
if( aEvent.mnCode == 0 ) if( aEvent.mnCode == 0 )
{ {
// check other mapping gint best_group = SAL_MAX_INT32;
gint eff_group, level;
GdkModifierType consumed; // Try and find Latin layout
guint updated_keyval = 0; GdkKeymap* keymap = gdk_keymap_get_default();
// use gdk_keymap_get_default instead of NULL; GdkKeymapKey *keys;
// workaround a crahs fixed in gtk 2.4 gint n_keys;
if( gdk_keymap_translate_keyboard_state( gdk_keymap_get_default(), if (gdk_keymap_get_entries_for_keyval(keymap, GDK_A, &keys, &n_keys))
hardware_keycode,
(GdkModifierType)0,
0,
&updated_keyval,
&eff_group,
&level,
&consumed ) )
{ {
aEvent.mnCode = GetKeyCode( updated_keyval ); // Find the lowest group that supports Latin layout
for (gint i = 0; i < n_keys; ++i)
{
if (keys[i].level != 0 && keys[i].level != 1)
continue;
best_group = std::min(best_group, keys[i].group);
if (best_group == 0)
break;
}
g_free(keys);
} }
//Unavailable, go with original group then I suppose
if (best_group == SAL_MAX_INT32)
best_group = group;
guint updated_keyval = GetKeyValFor(keymap, hardware_keycode, best_group);
aEvent.mnCode = GetKeyCode(updated_keyval);
} }
aEvent.mnCode |= GetKeyModCode( state ); aEvent.mnCode |= GetKeyModCode( state );
if( bDown ) if( bDown )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment