Only query the colormap for GRAYSCALE and PSEUDOCOLOR visuals, and don't

Tue Feb  3 15:34:27 1998  Owen Taylor  <owt1@cornell.edu>

	* gdk/gdkcolor.c (gdk_colormap_get_system): Only query
	  the colormap for GRAYSCALE and PSEUDOCOLOR visuals,
	  and don't ask for more than 256 colors in any case.

	* gdk/gdkwindow.c (gdk_window_internal_destroy): Remove
	  the input window information when we destroy the window,
	  not when we are notified of it.

	* gdk/gdkinputcommon.h (gdk_input_device_new): Work around
	  bug in XFree86 3.3.1's handling of Wacom macro buttons.
	  by assumming no device will report exactly 25 buttons.

	* gdk/gdkinputcommon.h (gdk_input_common_other_event): Fill
	  in string translation for generated key press events,
	  do sanity checking on received key codes.

	* gdk/gdkcc.c (gdk_color_context_new): Allocate enough
	  room for a GdkColorContextPrivate, not just for a
	  GdkColorContext.
This commit is contained in:
Owen Taylor
1998-02-03 20:57:40 +00:00
committed by Owen Taylor
parent 5842311062
commit 3b0de24a7b
15 changed files with 278 additions and 50 deletions

View File

@ -177,8 +177,19 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
case KeyClass:
{
XKeyInfo *xki = (XKeyInfo *)class;
gdkdev->info.num_keys = xki->max_keycode - xki->min_keycode + 1;
gdkdev->min_keycode = xki->min_keycode;
/* Hack to catch XFree86 3.3.1 bug. Other devices better
* not have exactly 25 keys...
*/
if ((xki->min_keycode == 8) && (xki->max_keycode == 32))
{
gdkdev->info.num_keys = 32;
gdkdev->min_keycode = 0;
}
else
{
gdkdev->info.num_keys = xki->max_keycode - xki->min_keycode + 1;
gdkdev->min_keycode = xki->min_keycode;
}
gdkdev->info.keys = g_new (GdkDeviceKey, gdkdev->info.num_keys);
for (j=0; j<gdkdev->info.num_keys; j++)
@ -585,7 +596,6 @@ gdk_input_common_other_event (GdkEvent *event,
(xevent->type == gdkdev->keyrelease_type))
{
XDeviceKeyEvent *xdke = (XDeviceKeyEvent *)(xevent);
event->key.keyval = gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].keyval;
if (gdk_show_events)
g_print ("device key %s:\twindow: %ld device: %ld keycode: %d\n",
@ -594,6 +604,15 @@ gdk_input_common_other_event (GdkEvent *event,
xdke->deviceid,
xdke->keycode);
if (xdke->keycode < gdkdev->min_keycode ||
xdke->keycode >= gdkdev->min_keycode + gdkdev->info.num_keys)
{
g_warning ("Invalid device key code received");
return FALSE;
}
event->key.keyval = gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].keyval;
if (event->key.keyval == 0)
{
if (gdk_show_events)
@ -611,6 +630,20 @@ gdk_input_common_other_event (GdkEvent *event,
event->key.state = gdk_input_translate_state(xdke->state, xdke->device_state)
| gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].modifiers;
/* Add a string translation for the key event */
if ((event->key.keyval >= 0x20) && (event->key.keyval <= 0xFF))
{
event->key.length = 1;
event->key.string = g_new (gchar, 2);
event->key.string[0] = (gchar)event->key.keyval;
event->key.string[1] = 0;
}
else
{
event->key.length = 0;
event->key.string = g_new0 (gchar, 1);
}
if (gdk_show_events)
g_print ("\t\ttranslation - keyval: %d modifiers: %#x\n",
event->key.keyval,