gdk: Unvfuncify generic key functions

This makes Wayland and X11 no longer call into XKB and libX11 for these
functions but use GDK's own copy of these functions, just like the
win32, quartz and broadway backends.
This commit is contained in:
Benjamin Otte 2013-04-16 15:27:15 +02:00
parent 065a8da87a
commit 0990c11a83
7 changed files with 2 additions and 161 deletions

View File

@ -397,15 +397,6 @@ gdk_display_manager_peek (void)
return manager;
}
/* Used for cases where we don't actually want to instantiate a
* display manager if none exists. Internal only.
*/
GdkDisplayManager *
_gdk_display_manager_get_nocreate (void)
{
return manager;
}
/**
* gdk_display_manager_get_default_display:
* @manager: a #GdkDisplayManager

View File

@ -44,24 +44,11 @@ struct _GdkDisplayManagerClass
GdkDisplay * (*open_display) (GdkDisplayManager *manager,
const gchar *name);
/* FIXME the following should really be frontend-only, not vfuncs */
guint (*lookup_keyval) (GdkDisplayManager *manager,
const gchar *name);
gchar * (*get_keyval_name) (GdkDisplayManager *manager,
guint keyval);
void (*keyval_convert_case) (GdkDisplayManager *manager,
guint keyval,
guint *lower,
guint *upper);
/* signals */
void (*display_opened) (GdkDisplayManager *manager,
GdkDisplay *display);
};
GdkDisplayManager *
_gdk_display_manager_get_nocreate (void);
void _gdk_display_manager_add_display (GdkDisplayManager *manager,
GdkDisplay *display);
void _gdk_display_manager_remove_display (GdkDisplayManager *manager,

View File

@ -693,16 +693,7 @@ gdk_keymap_get_modifier_mask (GdkKeymap *keymap,
gchar *
gdk_keyval_name (guint keyval)
{
GdkDisplayManagerClass *manager_class;
GdkDisplayManager *manager;
manager = gdk_display_manager_get ();
manager_class = GDK_DISPLAY_MANAGER_GET_CLASS (manager);
if (manager_class->get_keyval_name)
return manager_class->get_keyval_name (manager, keyval);
else
return _gdk_keyval_name (keyval);
return _gdk_keyval_name (keyval);
}
/**
@ -721,16 +712,7 @@ gdk_keyval_name (guint keyval)
guint
gdk_keyval_from_name (const gchar *keyval_name)
{
GdkDisplayManagerClass *manager_class;
GdkDisplayManager *manager;
manager = gdk_display_manager_get ();
manager_class = GDK_DISPLAY_MANAGER_GET_CLASS (manager);
if (manager_class->lookup_keyval)
return manager_class->lookup_keyval (manager, keyval_name);
else
return _gdk_keyval_from_name (keyval_name);
return _gdk_keyval_from_name (keyval_name);
}
/**
@ -747,21 +729,8 @@ gdk_keyval_convert_case (guint symbol,
guint *lower,
guint *upper)
{
GdkDisplayManager *manager;
guint xlower, xupper;
manager = _gdk_display_manager_get_nocreate ();
if (manager)
{
GdkDisplayManagerClass *manager_class = GDK_DISPLAY_MANAGER_GET_CLASS (manager);
if (manager_class->keyval_convert_case)
{
manager_class->keyval_convert_case (manager, symbol, lower, upper);
return;
}
}
xlower = symbol;
xupper = symbol;

View File

@ -27,8 +27,6 @@
#include "gdkwayland.h"
#include "gdkinternals.h"
#include <xkbcommon/xkbcommon.h>
struct _GdkWaylandDisplayManager
{
GdkDisplayManager parent;
@ -97,40 +95,6 @@ gdk_wayland_display_manager_open_display (GdkDisplayManager *manager,
return _gdk_wayland_display_open (name);
}
static guint
gdk_wayland_display_manager_lookup_keyval (GdkDisplayManager *manager,
const gchar *keyval_name)
{
g_return_val_if_fail (keyval_name != NULL, 0);
return xkb_keysym_from_name (keyval_name, 0);
}
static gchar *
gdk_wayland_display_manager_get_keyval_name (GdkDisplayManager *manager,
guint keyval)
{
static char buf[128];
switch (keyval)
{
case 0:
return NULL;
case GDK_KEY_Page_Up:
return "Page_Up";
case GDK_KEY_Page_Down:
return "Page_Down";
case GDK_KEY_KP_Page_Up:
return "KP_Page_Up";
case GDK_KEY_KP_Page_Down:
return "KP_Page_Down";
}
xkb_keysym_get_name(keyval, buf, sizeof (buf));
return buf;
}
static void
gdk_wayland_display_manager_class_init (GdkWaylandDisplayManagerClass *class)
{
@ -140,8 +104,6 @@ gdk_wayland_display_manager_class_init (GdkWaylandDisplayManagerClass *class)
object_class->finalize = gdk_wayland_display_manager_finalize;
manager_class->open_display = gdk_wayland_display_manager_open_display;
manager_class->lookup_keyval = gdk_wayland_display_manager_lookup_keyval;
manager_class->get_keyval_name = gdk_wayland_display_manager_get_keyval_name;
}
static void

View File

@ -113,7 +113,4 @@ gdk_x11_display_manager_class_init (GdkX11DisplayManagerClass *class)
object_class->finalize = gdk_x11_display_manager_finalize;
manager_class->open_display = gdk_x11_display_manager_open_display;
manager_class->lookup_keyval = _gdk_x11_display_manager_lookup_keyval;
manager_class->get_keyval_name = _gdk_x11_display_manager_get_keyval_name;
manager_class->keyval_convert_case = _gdk_x11_display_manager_keyval_convert_case;
}

View File

@ -1382,63 +1382,6 @@ gdk_x11_keymap_translate_keyboard_state (GdkKeymap *keymap,
return tmp_keyval != NoSymbol;
}
/* Key handling not part of the keymap */
gchar*
_gdk_x11_display_manager_get_keyval_name (GdkDisplayManager *manager,
guint keyval)
{
switch (keyval)
{
case GDK_KEY_Page_Up:
return "Page_Up";
case GDK_KEY_Page_Down:
return "Page_Down";
case GDK_KEY_KP_Page_Up:
return "KP_Page_Up";
case GDK_KEY_KP_Page_Down:
return "KP_Page_Down";
}
return XKeysymToString (keyval);
}
guint
_gdk_x11_display_manager_lookup_keyval (GdkDisplayManager *manager,
const gchar *keyval_name)
{
g_return_val_if_fail (keyval_name != NULL, 0);
return XStringToKeysym (keyval_name);
}
void
_gdk_x11_display_manager_keyval_convert_case (GdkDisplayManager *manager,
guint symbol,
guint *lower,
guint *upper)
{
KeySym xlower = 0;
KeySym xupper = 0;
/* Check for directly encoded 24-bit UCS characters: */
if ((symbol & 0xff000000) == 0x01000000)
{
if (lower)
*lower = gdk_unicode_to_keyval (g_unichar_tolower (symbol & 0x00ffffff));
if (upper)
*upper = gdk_unicode_to_keyval (g_unichar_toupper (symbol & 0x00ffffff));
return;
}
if (symbol)
XConvertCase (symbol, &xlower, &xupper);
if (lower)
*lower = xlower;
if (upper)
*upper = xupper;
}
/**
* gdk_x11_keymap_get_group_for_state:
* @keymap: a #GdkX11Keymap

View File

@ -252,14 +252,6 @@ GdkAtom _gdk_x11_display_manager_atom_intern (GdkDisplayManager *manager,
gboolean copy_name);
gchar * _gdk_x11_display_manager_get_atom_name (GdkDisplayManager *manager,
GdkAtom atom);
guint _gdk_x11_display_manager_lookup_keyval (GdkDisplayManager *manager,
const gchar *name);
gchar * _gdk_x11_display_manager_get_keyval_name (GdkDisplayManager *manager,
guint keyval);
void _gdk_x11_display_manager_keyval_convert_case (GdkDisplayManager *manager,
guint symbol,
guint *lower,
guint *upper);
GdkCursor *_gdk_x11_display_get_cursor_for_type (GdkDisplay *display,
GdkCursorType type);