]> Pileus Git - ~andy/gtk/commitdiff
Only query the colormap for GRAYSCALE and PSEUDOCOLOR visuals, and don't
authorOwen Taylor <owt1@cornell.edu>
Tue, 3 Feb 1998 20:57:40 +0000 (20:57 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Tue, 3 Feb 1998 20:57:40 +0000 (20:57 +0000)
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.

15 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/gdkcc.c
gdk/gdkcolor.c
gdk/gdkinputcommon.h
gdk/gdkwindow.c
gdk/x11/gdkcc-x11.c
gdk/x11/gdkcolor-x11.c
gdk/x11/gdkinput-x11.c
gdk/x11/gdkwindow-x11.c

index 107c23f1498e587fc1270529073a3845c80813a7..e08398b60f9aa8da3b9340440876dc49342121d5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+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.
+
 Tue Feb  3 15:09:55 1998  Tim Janik  <timj@gimp.org>
 
        * gtk/testgtk.c: don't add the same menu to different menuitems/
index 107c23f1498e587fc1270529073a3845c80813a7..e08398b60f9aa8da3b9340440876dc49342121d5 100644 (file)
@@ -1,3 +1,25 @@
+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.
+
 Tue Feb  3 15:09:55 1998  Tim Janik  <timj@gimp.org>
 
        * gtk/testgtk.c: don't add the same menu to different menuitems/
index 107c23f1498e587fc1270529073a3845c80813a7..e08398b60f9aa8da3b9340440876dc49342121d5 100644 (file)
@@ -1,3 +1,25 @@
+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.
+
 Tue Feb  3 15:09:55 1998  Tim Janik  <timj@gimp.org>
 
        * gtk/testgtk.c: don't add the same menu to different menuitems/
index 107c23f1498e587fc1270529073a3845c80813a7..e08398b60f9aa8da3b9340440876dc49342121d5 100644 (file)
@@ -1,3 +1,25 @@
+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.
+
 Tue Feb  3 15:09:55 1998  Tim Janik  <timj@gimp.org>
 
        * gtk/testgtk.c: don't add the same menu to different menuitems/
index 107c23f1498e587fc1270529073a3845c80813a7..e08398b60f9aa8da3b9340440876dc49342121d5 100644 (file)
@@ -1,3 +1,25 @@
+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.
+
 Tue Feb  3 15:09:55 1998  Tim Janik  <timj@gimp.org>
 
        * gtk/testgtk.c: don't add the same menu to different menuitems/
index 107c23f1498e587fc1270529073a3845c80813a7..e08398b60f9aa8da3b9340440876dc49342121d5 100644 (file)
@@ -1,3 +1,25 @@
+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.
+
 Tue Feb  3 15:09:55 1998  Tim Janik  <timj@gimp.org>
 
        * gtk/testgtk.c: don't add the same menu to different menuitems/
index 107c23f1498e587fc1270529073a3845c80813a7..e08398b60f9aa8da3b9340440876dc49342121d5 100644 (file)
@@ -1,3 +1,25 @@
+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.
+
 Tue Feb  3 15:09:55 1998  Tim Janik  <timj@gimp.org>
 
        * gtk/testgtk.c: don't add the same menu to different menuitems/
index d105db5f5f9aafd5ff2e2eb4dfe33c12aaefc048..cd0c314f4ac589223f82998be359d29e7002f936 100644 (file)
@@ -507,9 +507,9 @@ gdk_color_context_new (GdkVisual   *visual,
 
   g_assert (visual != NULL);
   g_assert (colormap != NULL);
-       
-  cc = g_new (GdkColorContext, 1);
-  ccp = (GdkColorContextPrivate *) cc;
+
+  ccp = g_new (GdkColorContextPrivate, 1);
+  cc = (GdkColorContext *) ccp;
   ccp->xdisplay = gdk_display;
   cc->visual = visual;
   cc->colormap = colormap;
index 5da61f063c5456fd19380010f2b1d448dfca1f0b..7bc436957799fd57cabff96d9bc0166c66c58158 100644 (file)
@@ -174,23 +174,27 @@ gdk_colormap_get_system (void)
       private->next_color = 0;
       private->ref_count = 1;
 
-      for (i = 0; i < 256; i++)
+      if ((private->visual->type == GDK_VISUAL_GRAYSCALE) ||
+         (private->visual->type == GDK_VISUAL_PSEUDO_COLOR))
        {
-         xpalette[i].pixel = i;
-         xpalette[i].red = 0;
-         xpalette[i].green = 0;
-         xpalette[i].blue = 0;
-       }
-
-      XQueryColors (gdk_display, private->xcolormap, xpalette, 
-                    private->visual->colormap_size);
-
-      for (i = 0; i < 256; i++)
-       {
-         colormap->colors[i].pixel = xpalette[i].pixel;
-         colormap->colors[i].red = xpalette[i].red;
-         colormap->colors[i].green = xpalette[i].green;
-         colormap->colors[i].blue = xpalette[i].blue;
+         for (i = 0; i < 256; i++)
+           {
+             xpalette[i].pixel = i;
+             xpalette[i].red = 0;
+             xpalette[i].green = 0;
+             xpalette[i].blue = 0;
+           }
+         
+         XQueryColors (gdk_display, private->xcolormap, xpalette, 
+                       MIN (private->visual->colormap_size, 256));
+         
+         for (i = 0; i < 256; i++)
+           {
+             colormap->colors[i].pixel = xpalette[i].pixel;
+             colormap->colors[i].red = xpalette[i].red;
+             colormap->colors[i].green = xpalette[i].green;
+             colormap->colors[i].blue = xpalette[i].blue;
+           }
        }
 
       gdk_colormap_add (colormap);
index 9b7d2c6834aecb64c14c6c664a7c4c36eb378c68..b0f7a058d74e5a8bb5b70404945339ffb94bc27b 100644 (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,
index 35e09cfc5a11c6dfd7662b99831a5be2e9f4c5e6..9d6706b6189b1264c62717b234698afa12318127 100644 (file)
@@ -382,6 +382,9 @@ gdk_window_internal_destroy (GdkWindow *window, int xdestroy)
 
          g_list_free (children);
 
+         if (private->extension_events != 0)
+           gdk_input_window_destroy (window);
+
          if(private->dnd_drag_data_numtypesavail > 0) 
            {
              g_free (private->dnd_drag_data_typesavail);
@@ -430,9 +433,6 @@ gdk_window_destroy_notify (GdkWindow *window)
 
   private = (GdkWindowPrivate*) window;
 
-  if (private->extension_events != 0)
-    gdk_input_window_destroy (window);
-
   gdk_xid_table_remove (private->xwindow);
   gdk_window_unref (window);
 }
index d105db5f5f9aafd5ff2e2eb4dfe33c12aaefc048..cd0c314f4ac589223f82998be359d29e7002f936 100644 (file)
@@ -507,9 +507,9 @@ gdk_color_context_new (GdkVisual   *visual,
 
   g_assert (visual != NULL);
   g_assert (colormap != NULL);
-       
-  cc = g_new (GdkColorContext, 1);
-  ccp = (GdkColorContextPrivate *) cc;
+
+  ccp = g_new (GdkColorContextPrivate, 1);
+  cc = (GdkColorContext *) ccp;
   ccp->xdisplay = gdk_display;
   cc->visual = visual;
   cc->colormap = colormap;
index 5da61f063c5456fd19380010f2b1d448dfca1f0b..7bc436957799fd57cabff96d9bc0166c66c58158 100644 (file)
@@ -174,23 +174,27 @@ gdk_colormap_get_system (void)
       private->next_color = 0;
       private->ref_count = 1;
 
-      for (i = 0; i < 256; i++)
+      if ((private->visual->type == GDK_VISUAL_GRAYSCALE) ||
+         (private->visual->type == GDK_VISUAL_PSEUDO_COLOR))
        {
-         xpalette[i].pixel = i;
-         xpalette[i].red = 0;
-         xpalette[i].green = 0;
-         xpalette[i].blue = 0;
-       }
-
-      XQueryColors (gdk_display, private->xcolormap, xpalette, 
-                    private->visual->colormap_size);
-
-      for (i = 0; i < 256; i++)
-       {
-         colormap->colors[i].pixel = xpalette[i].pixel;
-         colormap->colors[i].red = xpalette[i].red;
-         colormap->colors[i].green = xpalette[i].green;
-         colormap->colors[i].blue = xpalette[i].blue;
+         for (i = 0; i < 256; i++)
+           {
+             xpalette[i].pixel = i;
+             xpalette[i].red = 0;
+             xpalette[i].green = 0;
+             xpalette[i].blue = 0;
+           }
+         
+         XQueryColors (gdk_display, private->xcolormap, xpalette, 
+                       MIN (private->visual->colormap_size, 256));
+         
+         for (i = 0; i < 256; i++)
+           {
+             colormap->colors[i].pixel = xpalette[i].pixel;
+             colormap->colors[i].red = xpalette[i].red;
+             colormap->colors[i].green = xpalette[i].green;
+             colormap->colors[i].blue = xpalette[i].blue;
+           }
        }
 
       gdk_colormap_add (colormap);
index 9b7d2c6834aecb64c14c6c664a7c4c36eb378c68..b0f7a058d74e5a8bb5b70404945339ffb94bc27b 100644 (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,
index 35e09cfc5a11c6dfd7662b99831a5be2e9f4c5e6..9d6706b6189b1264c62717b234698afa12318127 100644 (file)
@@ -382,6 +382,9 @@ gdk_window_internal_destroy (GdkWindow *window, int xdestroy)
 
          g_list_free (children);
 
+         if (private->extension_events != 0)
+           gdk_input_window_destroy (window);
+
          if(private->dnd_drag_data_numtypesavail > 0) 
            {
              g_free (private->dnd_drag_data_typesavail);
@@ -430,9 +433,6 @@ gdk_window_destroy_notify (GdkWindow *window)
 
   private = (GdkWindowPrivate*) window;
 
-  if (private->extension_events != 0)
-    gdk_input_window_destroy (window);
-
   gdk_xid_table_remove (private->xwindow);
   gdk_window_unref (window);
 }