forked from AuroraMiddleware/gtk
gdk: Tweaks to keyname handling
Rename the private header to follow our naming conventions, and drop the extra gdkkeys.c file.
This commit is contained in:
parent
e499a09759
commit
9ff549799d
@ -1,103 +0,0 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkkeysyms.h"
|
||||
|
||||
/* Key handling not part of the keymap */
|
||||
|
||||
#include "keyname-table.h"
|
||||
|
||||
#include <glib/gprintf.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define GDK_NUM_KEYS G_N_ELEMENTS (gdk_keys_by_keyval)
|
||||
|
||||
static int
|
||||
gdk_keys_keyval_compare (const void *pkey, const void *pbase)
|
||||
{
|
||||
return (*(int *) pkey) - ((gdk_key *) pbase)->keyval;
|
||||
}
|
||||
|
||||
static char *
|
||||
_gdk_keyval_name (guint keyval)
|
||||
{
|
||||
static char buf[100];
|
||||
gdk_key *found;
|
||||
|
||||
/* Check for directly encoded 24-bit UCS characters: */
|
||||
if ((keyval & 0xff000000) == 0x01000000)
|
||||
{
|
||||
g_sprintf (buf, "U+%.04X", (keyval & 0x00ffffff));
|
||||
return buf;
|
||||
}
|
||||
|
||||
found = bsearch (&keyval, gdk_keys_by_keyval,
|
||||
GDK_NUM_KEYS, sizeof (gdk_key),
|
||||
gdk_keys_keyval_compare);
|
||||
|
||||
if (found != NULL)
|
||||
{
|
||||
while ((found > gdk_keys_by_keyval) &&
|
||||
((found - 1)->keyval == keyval))
|
||||
found--;
|
||||
|
||||
return (char *) (keynames + found->offset);
|
||||
}
|
||||
else if (keyval != 0)
|
||||
{
|
||||
g_sprintf (buf, "%#x", keyval);
|
||||
return buf;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
gdk_keys_name_compare (const void *pkey, const void *pbase)
|
||||
{
|
||||
return strcmp ((const char *) pkey,
|
||||
(const char *) (keynames + ((const gdk_key *) pbase)->offset));
|
||||
}
|
||||
|
||||
static guint
|
||||
_gdk_keyval_from_name (const char *keyval_name)
|
||||
{
|
||||
gdk_key *found;
|
||||
|
||||
g_return_val_if_fail (keyval_name != NULL, 0);
|
||||
|
||||
if (strncmp (keyval_name,"XF86", 4) == 0)
|
||||
keyval_name += 4;
|
||||
|
||||
found = bsearch (keyval_name, gdk_keys_by_name,
|
||||
GDK_NUM_KEYS, sizeof (gdk_key),
|
||||
gdk_keys_name_compare);
|
||||
if (found != NULL)
|
||||
return found->keyval;
|
||||
else
|
||||
return GDK_KEY_VoidSymbol;
|
||||
}
|
@ -29,6 +29,11 @@
|
||||
#include "gdkdisplay.h"
|
||||
#include "gdkdisplaymanagerprivate.h"
|
||||
|
||||
#include "keynamesprivate.h"
|
||||
#include <glib/gprintf.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_DISPLAY,
|
||||
@ -614,7 +619,73 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
|
||||
consumed_modifiers);
|
||||
}
|
||||
|
||||
#include "gdkkeynames.c"
|
||||
static int
|
||||
gdk_keys_keyval_compare (const void *pkey, const void *pbase)
|
||||
{
|
||||
return (*(int *) pkey) - ((gdk_key *) pbase)->keyval;
|
||||
}
|
||||
|
||||
static char *
|
||||
_gdk_keyval_name (guint keyval)
|
||||
{
|
||||
static char buf[100];
|
||||
gdk_key *found;
|
||||
|
||||
/* Check for directly encoded 24-bit UCS characters: */
|
||||
if ((keyval & 0xff000000) == 0x01000000)
|
||||
{
|
||||
g_sprintf (buf, "U+%.04X", (keyval & 0x00ffffff));
|
||||
return buf;
|
||||
}
|
||||
|
||||
found = bsearch (&keyval,
|
||||
gdk_keys_by_keyval, G_N_ELEMENTS (gdk_keys_by_keyval),
|
||||
sizeof (gdk_key),
|
||||
gdk_keys_keyval_compare);
|
||||
|
||||
if (found != NULL)
|
||||
{
|
||||
while ((found > gdk_keys_by_keyval) &&
|
||||
((found - 1)->keyval == keyval))
|
||||
found--;
|
||||
|
||||
return (char *) (keynames + found->offset);
|
||||
}
|
||||
else if (keyval != 0)
|
||||
{
|
||||
g_sprintf (buf, "%#x", keyval);
|
||||
return buf;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
gdk_keys_name_compare (const void *pkey, const void *pbase)
|
||||
{
|
||||
return strcmp ((const char *) pkey,
|
||||
(const char *) (keynames + ((const gdk_key *) pbase)->offset));
|
||||
}
|
||||
|
||||
static guint
|
||||
_gdk_keyval_from_name (const char *keyval_name)
|
||||
{
|
||||
gdk_key *found;
|
||||
|
||||
g_return_val_if_fail (keyval_name != NULL, 0);
|
||||
|
||||
if (strncmp (keyval_name,"XF86", 4) == 0)
|
||||
keyval_name += 4;
|
||||
|
||||
found = bsearch (keyval_name,
|
||||
gdk_keys_by_name, G_N_ELEMENTS (gdk_keys_by_name),
|
||||
sizeof (gdk_key),
|
||||
gdk_keys_name_compare);
|
||||
if (found != NULL)
|
||||
return found->keyval;
|
||||
else
|
||||
return GDK_KEY_VoidSymbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_keyval_name:
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
if (@ARGV != 2) {
|
||||
die "Usage: gen-keyname-table.pl keynames.txt keynames-translate.txt > keyname-table.h\n";
|
||||
die "Usage: gen-keyname-table.pl keynames.txt keynames-translate.txt > keynamesprivate.h\n";
|
||||
}
|
||||
|
||||
open IN, $ARGV[0] || die "Cannot open $ARGV[0]: $!\n";
|
||||
@ -38,7 +38,7 @@ $offset = 0;
|
||||
$date = gmtime;
|
||||
|
||||
print <<EOT;
|
||||
/* keyname-table.h: Generated by gen-keyname-table.pl from keynames.txt
|
||||
/* keynamesprivate.h: Generated by gen-keyname-table.pl from keynames.txt
|
||||
*
|
||||
* Date: $date
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* keyname-table.h: Generated by gen-keyname-table.pl from keynames.txt
|
||||
/* keynametableprivate.h: Generated by gen-keyname-table.pl from keynames.txt
|
||||
*
|
||||
* Date: Sat Oct 7 23:00:42 2017
|
||||
*
|
Loading…
Reference in New Issue
Block a user