[gtk+] Add vfuncs for keyval and window property functions



commit 519f09f7f4b60305df1308d9cda2736c166ff5e9
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Dec 16 19:00:01 2010 -0500

    Add vfuncs for keyval and window property functions
    
    The keyval functions should really be generic, and the window
    property api should be completely revisited, but for now this
    will allow us to proceed.

 gdk/gdkdisplaymanagerprivate.h  |   10 +++
 gdk/gdkkeys.c                   |  163 ++++++++------------------------------
 gdk/gdkwindow.c                 |  119 ++++++++++++++++++++++++++++
 gdk/gdkwindowimpl.h             |   21 +++++
 gdk/x11/gdkdisplaymanager-x11.c |    3 +
 gdk/x11/gdkkeys-x11.c           |  154 ++++++++++++++++++++++++++++++++-----
 gdk/x11/gdkprivate-x11.h        |   27 +++++++
 gdk/x11/gdkproperty-x11.c       |  118 +++++-----------------------
 gdk/x11/gdkwindow-x11.c         |    3 +
 9 files changed, 372 insertions(+), 246 deletions(-)
---
diff --git a/gdk/gdkdisplaymanagerprivate.h b/gdk/gdkdisplaymanagerprivate.h
index 70afd7d..a1d19ec 100644
--- a/gdk/gdkdisplaymanagerprivate.h
+++ b/gdk/gdkdisplaymanagerprivate.h
@@ -39,11 +39,21 @@ struct _GdkDisplayManagerClass
                                        GdkDisplay        *display);
   GdkDisplay * (*open_display)        (GdkDisplayManager *manager,
                                        const gchar       *name);
+
+  /* FIXME the following should really be frontend-only, not vfuncs */
   GdkAtom      (*atom_intern)         (GdkDisplayManager *manager,
                                        const gchar       *atom_name,
                                        gboolean           copy_name);
   gchar *      (*get_atom_name)       (GdkDisplayManager *manager,
                                        GdkAtom            atom);
+  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,
diff --git a/gdk/gdkkeys.c b/gdk/gdkkeys.c
index 75ef078..5b7ea78 100644
--- a/gdk/gdkkeys.c
+++ b/gdk/gdkkeys.c
@@ -28,6 +28,7 @@
 
 #include "gdkkeysprivate.h"
 #include "gdkdisplay.h"
+#include "gdkdisplaymanagerprivate.h"
 
 
 /**
@@ -182,12 +183,6 @@ gdk_keymap_init (GdkKeymap *keymap)
 /* Other key-handling stuff
  */
 
-#ifndef HAVE_XCONVERTCASE
-#include "gdkkeysyms.h"
-
-/* compatibility function from X11R6.3, since XConvertCase is not
- * supplied by X11R5.
- */
 /**
  * gdk_keyval_convert_case:
  * @symbol: a keyval
@@ -196,133 +191,16 @@ gdk_keymap_init (GdkKeymap *keymap)
  *
  * Obtains the upper- and lower-case versions of the keyval @symbol.
  * Examples of keyvals are #GDK_KEY_a, #GDK_KEY_Enter, #GDK_KEY_F1, etc.
- *
- **/
+ */
 void
 gdk_keyval_convert_case (guint symbol,
-			 guint *lower,
-			 guint *upper)
+                         guint *lower,
+                         guint *upper)
 {
-  guint xlower = symbol;
-  guint xupper = symbol;
-
-  /* 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;
-    }
-
-  switch (symbol >> 8)
-    {
-    case 0: /* Latin 1 */
-      if ((symbol >= GDK_KEY_A) && (symbol <= GDK_KEY_Z))
-	xlower += (GDK_KEY_a - GDK_KEY_A);
-      else if ((symbol >= GDK_KEY_a) && (symbol <= GDK_KEY_z))
-	xupper -= (GDK_KEY_a - GDK_KEY_A);
-      else if ((symbol >= GDK_KEY_Agrave) && (symbol <= GDK_KEY_Odiaeresis))
-	xlower += (GDK_KEY_agrave - GDK_KEY_Agrave);
-      else if ((symbol >= GDK_KEY_agrave) && (symbol <= GDK_KEY_odiaeresis))
-	xupper -= (GDK_KEY_agrave - GDK_KEY_Agrave);
-      else if ((symbol >= GDK_KEY_Ooblique) && (symbol <= GDK_KEY_Thorn))
-	xlower += (GDK_KEY_oslash - GDK_KEY_Ooblique);
-      else if ((symbol >= GDK_KEY_oslash) && (symbol <= GDK_KEY_thorn))
-	xupper -= (GDK_KEY_oslash - GDK_KEY_Ooblique);
-      break;
-      
-    case 1: /* Latin 2 */
-      /* Assume the KeySym is a legal value (ignore discontinuities) */
-      if (symbol == GDK_KEY_Aogonek)
-	xlower = GDK_KEY_aogonek;
-      else if (symbol >= GDK_KEY_Lstroke && symbol <= GDK_KEY_Sacute)
-	xlower += (GDK_KEY_lstroke - GDK_KEY_Lstroke);
-      else if (symbol >= GDK_KEY_Scaron && symbol <= GDK_KEY_Zacute)
-	xlower += (GDK_KEY_scaron - GDK_KEY_Scaron);
-      else if (symbol >= GDK_KEY_Zcaron && symbol <= GDK_KEY_Zabovedot)
-	xlower += (GDK_KEY_zcaron - GDK_KEY_Zcaron);
-      else if (symbol == GDK_KEY_aogonek)
-	xupper = GDK_KEY_Aogonek;
-      else if (symbol >= GDK_KEY_lstroke && symbol <= GDK_KEY_sacute)
-	xupper -= (GDK_KEY_lstroke - GDK_KEY_Lstroke);
-      else if (symbol >= GDK_KEY_scaron && symbol <= GDK_KEY_zacute)
-	xupper -= (GDK_KEY_scaron - GDK_KEY_Scaron);
-      else if (symbol >= GDK_KEY_zcaron && symbol <= GDK_KEY_zabovedot)
-	xupper -= (GDK_KEY_zcaron - GDK_KEY_Zcaron);
-      else if (symbol >= GDK_KEY_Racute && symbol <= GDK_KEY_Tcedilla)
-	xlower += (GDK_KEY_racute - GDK_KEY_Racute);
-      else if (symbol >= GDK_KEY_racute && symbol <= GDK_KEY_tcedilla)
-	xupper -= (GDK_KEY_racute - GDK_KEY_Racute);
-      break;
-      
-    case 2: /* Latin 3 */
-      /* Assume the KeySym is a legal value (ignore discontinuities) */
-      if (symbol >= GDK_KEY_Hstroke && symbol <= GDK_KEY_Hcircumflex)
-	xlower += (GDK_KEY_hstroke - GDK_KEY_Hstroke);
-      else if (symbol >= GDK_KEY_Gbreve && symbol <= GDK_KEY_Jcircumflex)
-	xlower += (GDK_KEY_gbreve - GDK_KEY_Gbreve);
-      else if (symbol >= GDK_KEY_hstroke && symbol <= GDK_KEY_hcircumflex)
-	xupper -= (GDK_KEY_hstroke - GDK_KEY_Hstroke);
-      else if (symbol >= GDK_KEY_gbreve && symbol <= GDK_KEY_jcircumflex)
-	xupper -= (GDK_KEY_gbreve - GDK_KEY_Gbreve);
-      else if (symbol >= GDK_KEY_Cabovedot && symbol <= GDK_KEY_Scircumflex)
-	xlower += (GDK_KEY_cabovedot - GDK_KEY_Cabovedot);
-      else if (symbol >= GDK_KEY_cabovedot && symbol <= GDK_KEY_scircumflex)
-	xupper -= (GDK_KEY_cabovedot - GDK_KEY_Cabovedot);
-      break;
-      
-    case 3: /* Latin 4 */
-      /* Assume the KeySym is a legal value (ignore discontinuities) */
-      if (symbol >= GDK_KEY_Rcedilla && symbol <= GDK_KEY_Tslash)
-	xlower += (GDK_KEY_rcedilla - GDK_KEY_Rcedilla);
-      else if (symbol >= GDK_KEY_rcedilla && symbol <= GDK_KEY_tslash)
-	xupper -= (GDK_KEY_rcedilla - GDK_KEY_Rcedilla);
-      else if (symbol == GDK_KEY_ENG)
-	xlower = GDK_KEY_eng;
-      else if (symbol == GDK_KEY_eng)
-	xupper = GDK_KEY_ENG;
-      else if (symbol >= GDK_KEY_Amacron && symbol <= GDK_KEY_Umacron)
-	xlower += (GDK_KEY_amacron - GDK_KEY_Amacron);
-      else if (symbol >= GDK_KEY_amacron && symbol <= GDK_KEY_umacron)
-	xupper -= (GDK_KEY_amacron - GDK_KEY_Amacron);
-      break;
-      
-    case 6: /* Cyrillic */
-      /* Assume the KeySym is a legal value (ignore discontinuities) */
-      if (symbol >= GDK_KEY_Serbian_DJE && symbol <= GDK_KEY_Serbian_DZE)
-	xlower -= (GDK_KEY_Serbian_DJE - GDK_KEY_Serbian_dje);
-      else if (symbol >= GDK_KEY_Serbian_dje && symbol <= GDK_KEY_Serbian_dze)
-	xupper += (GDK_KEY_Serbian_DJE - GDK_KEY_Serbian_dje);
-      else if (symbol >= GDK_KEY_Cyrillic_YU && symbol <= GDK_KEY_Cyrillic_HARDSIGN)
-	xlower -= (GDK_KEY_Cyrillic_YU - GDK_KEY_Cyrillic_yu);
-      else if (symbol >= GDK_KEY_Cyrillic_yu && symbol <= GDK_KEY_Cyrillic_hardsign)
-	xupper += (GDK_KEY_Cyrillic_YU - GDK_KEY_Cyrillic_yu);
-      break;
-      
-    case 7: /* Greek */
-      /* Assume the KeySym is a legal value (ignore discontinuities) */
-      if (symbol >= GDK_KEY_Greek_ALPHAaccent && symbol <= GDK_KEY_Greek_OMEGAaccent)
-	xlower += (GDK_KEY_Greek_alphaaccent - GDK_KEY_Greek_ALPHAaccent);
-      else if (symbol >= GDK_KEY_Greek_alphaaccent && symbol <= GDK_KEY_Greek_omegaaccent &&
-	       symbol != GDK_KEY_Greek_iotaaccentdieresis &&
-	       symbol != GDK_KEY_Greek_upsilonaccentdieresis)
-	xupper -= (GDK_KEY_Greek_alphaaccent - GDK_KEY_Greek_ALPHAaccent);
-      else if (symbol >= GDK_KEY_Greek_ALPHA && symbol <= GDK_KEY_Greek_OMEGA)
-	xlower += (GDK_KEY_Greek_alpha - GDK_KEY_Greek_ALPHA);
-      else if (symbol >= GDK_KEY_Greek_alpha && symbol <= GDK_KEY_Greek_omega &&
-	       symbol != GDK_KEY_Greek_finalsmallsigma)
-	xupper -= (GDK_KEY_Greek_alpha - GDK_KEY_Greek_ALPHA);
-      break;
-    }
+  GdkDisplayManager *manager = gdk_display_manager_get ();
 
-  if (lower)
-    *lower = xlower;
-  if (upper)
-    *upper = xupper;
+  GDK_DISPLAY_MANAGER_GET_CLASS (manager)->keyval_convert_case (manager, symbol, lower, upper);
 }
-#endif
 
 /**
  * gdk_keyval_to_upper:
@@ -699,3 +577,32 @@ gdk_keymap_map_virtual_modifiers (GdkKeymap       *keymap,
 {
   return GDK_KEYMAP_GET_CLASS(keymap)->map_virtual_modifiers (keymap, state);
 }
+
+/**
+ * gdk_keyval_name:
+ * @keyval: a key value.
+ *
+ * Converts a key value into a symbolic name.
+ * The names are the same as those in the
+ * <filename>&lt;gdk/gdkkeysyms.h&gt;</filename> header file
+ * but without the leading "GDK_KEY_".
+ *
+ * Return value: (transfer none): a string containing the name of the key,
+ *     or %NULL if @keyval is not a valid key. The string should not be
+ *     modified.
+ */
+gchar*
+gdk_keyval_name (guint keyval)
+{
+  GdkDisplayManager *manager = gdk_display_manager_get ();
+
+  return GDK_DISPLAY_MANAGER_GET_CLASS (manager)->get_keyval_name (manager, keyval);
+}
+
+guint
+gdk_keyval_from_name (const gchar *keyval_name)
+{
+  GdkDisplayManager *manager = gdk_display_manager_get ();
+
+  return GDK_DISPLAY_MANAGER_GET_CLASS (manager)->lookup_keyval (manager, keyval_name);
+}
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index d949e8b..4a1049b 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -10813,3 +10813,122 @@ gdk_test_simulate_button (GdkWindow      *window,
   return GDK_WINDOW_IMPL_GET_CLASS (window->impl)
     ->simulate_button (window, x, y, button, modifiers, button_pressrelease);
 }
+
+/**
+ * gdk_property_get:
+ * @window: a #GdkWindow.
+ * @property: the property to retrieve.
+ * @type: the desired property type, or %GDK_NONE, if any type of data
+ *   is acceptable. If this does not match the actual
+ *   type, then @actual_format and @actual_length will
+ *   be filled in, a warning will be printed to stderr
+ *   and no data will be returned.
+ * @offset: the offset into the property at which to begin
+ *   retrieving data, in 4 byte units.
+ * @length: the length of the data to retrieve in bytes.  Data is
+ *   considered to be retrieved in 4 byte chunks, so @length
+ *   will be rounded up to the next highest 4 byte boundary
+ *   (so be careful not to pass a value that might overflow
+ *   when rounded up).
+ * @pdelete: if %TRUE, delete the property after retrieving the
+ *   data.
+ * @actual_property_type: location to store the actual type of
+*   the property.
+ * @actual_format: location to store the actual return format of the
+ *   data; either 8, 16 or 32 bits.
+ * @actual_length: location to store the length of the retrieved data, in
+ *   bytes.  Data returned in the 32 bit format is stored
+ *   in a long variable, so the actual number of 32 bit
+ *   elements should be be calculated via
+ *   @actual_length / sizeof(glong) to ensure portability to
+ *   64 bit systems.
+ * @data: location to store a pointer to the data. The retrieved
+ *   data should be freed with g_free() when you are finished
+ *   using it.
+ *
+ * Retrieves a portion of the contents of a property. If the
+ * property does not exist, then the function returns %FALSE,
+ * and %GDK_NONE will be stored in @actual_property_type.
+ *
+ * <note>
+ * <para>
+ * The XGetWindowProperty() function that gdk_property_get()
+ * uses has a very confusing and complicated set of semantics.
+ * uses has a very confusing and complicated set of semantics.
+ * Unfortunately, gdk_property_get() makes the situation
+ * worse instead of better (the semantics should be considered
+ * undefined), and also prints warnings to stderr in cases where it
+ * should return a useful error to the program. You are advised to use
+ * XGetWindowProperty() directly until a replacement function for
+ * gdk_property_get()
+ * is provided.
+ * </para>
+ * </note>
+ *
+ * Returns: %TRUE if data was successfully received and stored
+ *   in @data, otherwise %FALSE.
+ */
+gboolean
+gdk_property_get (GdkWindow  *window,
+                  GdkAtom     property,
+                  GdkAtom     type,
+                  gulong      offset,
+                  gulong      length,
+                  gint        pdelete,
+                  GdkAtom    *actual_property_type,
+                  gint       *actual_format_type,
+                  gint       *actual_length,
+                  guchar    **data)
+{
+  return GDK_WINDOW_IMPL_GET_CLASS (window->impl)
+    ->get_property (window, property, type, offset, length, pdelete,
+                    actual_property_type, actual_format_type,
+                    actual_length, data);
+}
+
+/**
+ * gdk_property_change:
+ * @window: a #GdkWindow.
+ * @property: the property to change.
+ * @type: the new type for the property. If @mode is
+ *   %GDK_PROP_MODE_PREPEND or %GDK_PROP_MODE_APPEND, then this
+ *   must match the existing type or an error will occur.
+ * @format: the new format for the property. If @mode is
+ *   %GDK_PROP_MODE_PREPEND or %GDK_PROP_MODE_APPEND, then this
+ *   must match the existing format or an error will occur.
+ * @mode: a value describing how the new data is to be combined
+ *   with the current data.
+ * @data: the data (a <literal>guchar *</literal>
+ *   <literal>gushort *</literal>, or <literal>gulong *</literal>,
+ *   depending on @format), cast to a <literal>guchar *</literal>.
+ * @nelements: the number of elements of size determined by the format,
+ *   contained in @data.
+ *
+ * Changes the contents of a property on a window.
+ */
+void
+gdk_property_change (GdkWindow    *window,
+                     GdkAtom       property,
+                     GdkAtom       type,
+                     gint          format,
+                     GdkPropMode   mode,
+                     const guchar *data,
+                     gint          nelements)
+{
+  GDK_WINDOW_IMPL_GET_CLASS (window->impl)
+    ->change_property (window, property, type, format, mode, data, nelements);
+}
+
+/**
+ * gdk_property_delete:
+ * @window: a #GdkWindow.
+ * @property: the property to delete.
+ *
+ * Deletes a property from a window.
+ */
+void
+gdk_property_delete (GdkWindow *window,
+                     GdkAtom    property)
+{
+  GDK_WINDOW_IMPL_GET_CLASS (window->impl)->delete_property (window, property);
+}
diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h
index 0b7695e..fd9add2 100644
--- a/gdk/gdkwindowimpl.h
+++ b/gdk/gdkwindowimpl.h
@@ -28,6 +28,7 @@
 #define __GDK_WINDOW_IMPL_H__
 
 #include <gdk/gdkwindow.h>
+#include <gdk/gdkproperty.h>
 
 G_BEGIN_DECLS
 
@@ -268,6 +269,26 @@ struct _GdkWindowImplClass
                                            guint           button,
                                            GdkModifierType modifiers,
                                            GdkEventType    event_type);
+
+  gboolean     (*get_property)            (GdkWindow      *window,
+                                           GdkAtom         property,
+                                           GdkAtom         type,
+                                           gulong          offset,
+                                           gulong          length,
+                                           gint            pdelete,
+                                           GdkAtom        *actual_type,
+                                           gint           *actual_format,
+                                           gint           *actual_length,
+                                           guchar        **data);
+  void         (*change_property)         (GdkWindow      *window,
+                                           GdkAtom         property,
+                                           GdkAtom         type,
+                                           gint            format,
+                                           GdkPropMode     mode,
+                                           const guchar   *data,
+                                           gint            n_elements);
+  void         (*delete_property)         (GdkWindow      *window,
+                                           GdkAtom         property);
 };
 
 /* Interface Functions */
diff --git a/gdk/x11/gdkdisplaymanager-x11.c b/gdk/x11/gdkdisplaymanager-x11.c
index aef1a6d..d073c3c 100644
--- a/gdk/x11/gdkdisplaymanager-x11.c
+++ b/gdk/x11/gdkdisplaymanager-x11.c
@@ -104,6 +104,9 @@ gdk_display_manager_x11_class_init (GdkDisplayManagerX11Class *class)
   manager_class->get_default_display = gdk_display_manager_x11_get_default_display;
   manager_class->atom_intern = _gdk_x11_display_manager_atom_intern;
   manager_class->get_atom_name = _gdk_x11_display_manager_get_atom_name;
+  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;
 }
 
 void
diff --git a/gdk/x11/gdkkeys-x11.c b/gdk/x11/gdkkeys-x11.c
index c18aac1..1b1e942 100644
--- a/gdk/x11/gdkkeys-x11.c
+++ b/gdk/x11/gdkkeys-x11.c
@@ -1406,22 +1406,10 @@ gdk_x11_keymap_translate_keyboard_state (GdkKeymap       *keymap,
   return tmp_keyval != NoSymbol;
 }
 
-
 /* Key handling not part of the keymap */
-/**
- * gdk_keyval_name:
- * @keyval: a key value.
- *
- * Converts a key value into a symbolic name.
- * The names are the same as those in the
- * <filename>&lt;gdk/gdkkeysyms.h&gt;</filename> header file
- * but without the leading "GDK_KEY_".
- *
- * Return value: (transfer none): a string containing the name of the key, or
- * %NULL if @keyval is not a valid key. The string should not be modified.
- **/
 gchar*
-gdk_keyval_name (guint        keyval)
+_gdk_x11_display_manager_get_keyval_name (GdkDisplayManager *manager,
+                                          guint              keyval)
 {
   switch (keyval)
     {
@@ -1439,7 +1427,8 @@ gdk_keyval_name (guint        keyval)
 }
 
 guint
-gdk_keyval_from_name (const gchar *keyval_name)
+_gdk_x11_display_manager_lookup_keyval (GdkDisplayManager *manager,
+                                        const gchar       *keyval_name)
 {
   g_return_val_if_fail (keyval_name != NULL, 0);
 
@@ -1448,9 +1437,10 @@ gdk_keyval_from_name (const gchar *keyval_name)
 
 #ifdef HAVE_XCONVERTCASE
 void
-gdk_keyval_convert_case (guint symbol,
-                         guint *lower,
-                         guint *upper)
+_gdk_x11_display_manager_keyval_convert_case (GdkDisplayManager *manager,
+                                              guint              symbol,
+                                              guint             *lower,
+                                              guint             *upper)
 {
   KeySym xlower = 0;
   KeySym xupper = 0;
@@ -1473,7 +1463,133 @@ gdk_keyval_convert_case (guint symbol,
   if (upper)
     *upper = xupper;
 }
-#endif /* HAVE_XCONVERTCASE */
+#else /* !HAVE_XCONVERTCASE */
+void
+_gdk_x11_display_manager_keyval_convert_case (GdkDisplayManager *manager,
+                                              guint              symbol,
+                                              guint             *lower,
+                                              guint             *upper)
+{
+  guint xlower = symbol;
+  guint xupper = symbol;
+
+  /* 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;
+    }
+
+  switch (symbol >> 8)
+    {
+    case 0: /* Latin 1 */
+      if ((symbol >= GDK_KEY_A) && (symbol <= GDK_KEY_Z))
+        xlower += (GDK_KEY_a - GDK_KEY_A);
+      else if ((symbol >= GDK_KEY_a) && (symbol <= GDK_KEY_z))
+        xupper -= (GDK_KEY_a - GDK_KEY_A);
+      else if ((symbol >= GDK_KEY_Agrave) && (symbol <= GDK_KEY_Odiaeresis))
+        xlower += (GDK_KEY_agrave - GDK_KEY_Agrave);
+      else if ((symbol >= GDK_KEY_agrave) && (symbol <= GDK_KEY_odiaeresis))
+        xupper -= (GDK_KEY_agrave - GDK_KEY_Agrave);
+      else if ((symbol >= GDK_KEY_Ooblique) && (symbol <= GDK_KEY_Thorn))
+        xlower += (GDK_KEY_oslash - GDK_KEY_Ooblique);
+      else if ((symbol >= GDK_KEY_oslash) && (symbol <= GDK_KEY_thorn))
+        xupper -= (GDK_KEY_oslash - GDK_KEY_Ooblique);
+      break;
+
+    case 1: /* Latin 2 */
+      /* Assume the KeySym is a legal value (ignore discontinuities) */
+      if (symbol == GDK_KEY_Aogonek)
+        xlower = GDK_KEY_aogonek;
+      else if (symbol >= GDK_KEY_Lstroke && symbol <= GDK_KEY_Sacute)
+        xlower += (GDK_KEY_lstroke - GDK_KEY_Lstroke);
+      else if (symbol >= GDK_KEY_Scaron && symbol <= GDK_KEY_Zacute)
+        xlower += (GDK_KEY_scaron - GDK_KEY_Scaron);
+      else if (symbol >= GDK_KEY_Zcaron && symbol <= GDK_KEY_Zabovedot)
+        xlower += (GDK_KEY_zcaron - GDK_KEY_Zcaron);
+      else if (symbol == GDK_KEY_aogonek)
+        xupper = GDK_KEY_Aogonek;
+      else if (symbol >= GDK_KEY_lstroke && symbol <= GDK_KEY_sacute)
+        xupper -= (GDK_KEY_lstroke - GDK_KEY_Lstroke);
+      else if (symbol >= GDK_KEY_scaron && symbol <= GDK_KEY_zacute)
+        xupper -= (GDK_KEY_scaron - GDK_KEY_Scaron);
+      else if (symbol >= GDK_KEY_zcaron && symbol <= GDK_KEY_zabovedot)
+        xupper -= (GDK_KEY_zcaron - GDK_KEY_Zcaron);
+      else if (symbol >= GDK_KEY_Racute && symbol <= GDK_KEY_Tcedilla)
+        xlower += (GDK_KEY_racute - GDK_KEY_Racute);
+      else if (symbol >= GDK_KEY_racute && symbol <= GDK_KEY_tcedilla)
+        xupper -= (GDK_KEY_racute - GDK_KEY_Racute);
+      break;
+
+    case 2: /* Latin 3 */
+      /* Assume the KeySym is a legal value (ignore discontinuities) */
+      if (symbol >= GDK_KEY_Hstroke && symbol <= GDK_KEY_Hcircumflex)
+        xlower += (GDK_KEY_hstroke - GDK_KEY_Hstroke);
+      else if (symbol >= GDK_KEY_Gbreve && symbol <= GDK_KEY_Jcircumflex)
+        xlower += (GDK_KEY_gbreve - GDK_KEY_Gbreve);
+      else if (symbol >= GDK_KEY_hstroke && symbol <= GDK_KEY_hcircumflex)
+        xupper -= (GDK_KEY_hstroke - GDK_KEY_Hstroke);
+      else if (symbol >= GDK_KEY_gbreve && symbol <= GDK_KEY_jcircumflex)
+        xupper -= (GDK_KEY_gbreve - GDK_KEY_Gbreve);
+      else if (symbol >= GDK_KEY_Cabovedot && symbol <= GDK_KEY_Scircumflex)
+        xlower += (GDK_KEY_cabovedot - GDK_KEY_Cabovedot);
+      else if (symbol >= GDK_KEY_cabovedot && symbol <= GDK_KEY_scircumflex)
+        xupper -= (GDK_KEY_cabovedot - GDK_KEY_Cabovedot);
+      break;
+
+    case 3: /* Latin 4 */
+      /* Assume the KeySym is a legal value (ignore discontinuities) */
+      if (symbol >= GDK_KEY_Rcedilla && symbol <= GDK_KEY_Tslash)
+        xlower += (GDK_KEY_rcedilla - GDK_KEY_Rcedilla);
+      else if (symbol >= GDK_KEY_rcedilla && symbol <= GDK_KEY_tslash)
+        xupper -= (GDK_KEY_rcedilla - GDK_KEY_Rcedilla);
+      else if (symbol == GDK_KEY_ENG)
+        xlower = GDK_KEY_eng;
+      else if (symbol == GDK_KEY_eng)
+        xupper = GDK_KEY_ENG;
+      else if (symbol >= GDK_KEY_Amacron && symbol <= GDK_KEY_Umacron)
+        xlower += (GDK_KEY_amacron - GDK_KEY_Amacron);
+      else if (symbol >= GDK_KEY_amacron && symbol <= GDK_KEY_umacron)
+        xupper -= (GDK_KEY_amacron - GDK_KEY_Amacron);
+      break;
+
+    case 6: /* Cyrillic */
+      /* Assume the KeySym is a legal value (ignore discontinuities) */
+      if (symbol >= GDK_KEY_Serbian_DJE && symbol <= GDK_KEY_Serbian_DZE)
+        xlower -= (GDK_KEY_Serbian_DJE - GDK_KEY_Serbian_dje);
+      else if (symbol >= GDK_KEY_Serbian_dje && symbol <= GDK_KEY_Serbian_dze)
+        xupper += (GDK_KEY_Serbian_DJE - GDK_KEY_Serbian_dje);
+      else if (symbol >= GDK_KEY_Cyrillic_YU && symbol <= GDK_KEY_Cyrillic_HARDSIGN)
+        xlower -= (GDK_KEY_Cyrillic_YU - GDK_KEY_Cyrillic_yu);
+      else if (symbol >= GDK_KEY_Cyrillic_yu && symbol <= GDK_KEY_Cyrillic_hardsign)
+        xupper += (GDK_KEY_Cyrillic_YU - GDK_KEY_Cyrillic_yu);
+      break;
+
+    case 7: /* Greek */
+      /* Assume the KeySym is a legal value (ignore discontinuities) */
+      if (symbol >= GDK_KEY_Greek_ALPHAaccent && symbol <= GDK_KEY_Greek_OMEGAaccent)
+        xlower += (GDK_KEY_Greek_alphaaccent - GDK_KEY_Greek_ALPHAaccent);
+      else if (symbol >= GDK_KEY_Greek_alphaaccent && symbol <= GDK_KEY_Greek_omegaaccent &&
+               symbol != GDK_KEY_Greek_iotaaccentdieresis &&
+               symbol != GDK_KEY_Greek_upsilonaccentdieresis)
+        xupper -= (GDK_KEY_Greek_alphaaccent - GDK_KEY_Greek_ALPHAaccent);
+      else if (symbol >= GDK_KEY_Greek_ALPHA && symbol <= GDK_KEY_Greek_OMEGA)
+        xlower += (GDK_KEY_Greek_alpha - GDK_KEY_Greek_ALPHA);
+      else if (symbol >= GDK_KEY_Greek_alpha && symbol <= GDK_KEY_Greek_omega &&
+               symbol != GDK_KEY_Greek_finalsmallsigma)
+        xupper -= (GDK_KEY_Greek_alpha - GDK_KEY_Greek_ALPHA);
+      break;
+    }
+
+  if (lower)
+    *lower = xlower;
+  if (upper)
+    *upper = xupper;
+}
+#endif
 
 gint
 _gdk_x11_get_group_for_state (GdkDisplay      *display,
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index 4dc341c..70cffc7 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -112,6 +112,25 @@ gboolean _gdk_x11_window_simulate_button   (GdkWindow       *window,
                                             guint            button,
                                             GdkModifierType  modifiers,
                                             GdkEventType     button_pressrelease);
+gboolean _gdk_x11_window_get_property      (GdkWindow    *window,
+                                            GdkAtom       property,
+                                            GdkAtom       type,
+                                            gulong        offset,
+                                            gulong        length,
+                                            gint          pdelete,
+                                            GdkAtom      *actual_property_type,
+                                            gint         *actual_format_type,
+                                            gint         *actual_length,
+                                            guchar      **data);
+void     _gdk_x11_window_change_property   (GdkWindow    *window,
+                                            GdkAtom       property,
+                                            GdkAtom       type,
+                                            gint          format,
+                                            GdkPropMode   mode,
+                                            const guchar *data,
+                                            gint          nelements);
+void     _gdk_x11_window_delete_property   (GdkWindow    *window,
+                                            GdkAtom       property);
 
 gboolean _gdk_x11_window_queue_antiexpose  (GdkWindow *window,
                                             cairo_region_t *area);
@@ -182,6 +201,14 @@ 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);
diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c
index d0ec2d7..1b57860 100644
--- a/gdk/x11/gdkproperty-x11.c
+++ b/gdk/x11/gdkproperty-x11.c
@@ -531,70 +531,17 @@ gdk_x11_get_xatom_name (Atom xatom)
   return get_atom_name (gdk_x11_xatom_to_atom (xatom));
 }
 
-/**
- * gdk_property_get:
- * @window: a #GdkWindow.
- * @property: the property to retrieve.
- * @type: the desired property type, or %GDK_NONE, if any type of data
- *   is acceptable. If this does not match the actual
- *   type, then @actual_format and @actual_length will
- *   be filled in, a warning will be printed to stderr
- *   and no data will be returned.
- * @offset: the offset into the property at which to begin
- *   retrieving data, in 4 byte units.
- * @length: the length of the data to retrieve in bytes.  Data is
- *   considered to be retrieved in 4 byte chunks, so @length
- *   will be rounded up to the next highest 4 byte boundary
- *   (so be careful not to pass a value that might overflow
- *   when rounded up).
- * @pdelete: if %TRUE, delete the property after retrieving the
- *   data.
- * @actual_property_type: location to store the actual type of
- *   the property.
- * @actual_format: location to store the actual return format of the
- *   data; either 8, 16 or 32 bits.
- * @actual_length: location to store the length of the retrieved data, in
- *   bytes.  Data returned in the 32 bit format is stored
- *   in a long variable, so the actual number of 32 bit
- *   elements should be be calculated via
- *   @actual_length / sizeof(glong) to ensure portability to
- *   64 bit systems.
- * @data: location to store a pointer to the data. The retrieved
- *   data should be freed with g_free() when you are finished
- *   using it.
- *
- * Retrieves a portion of the contents of a property. If the
- * property does not exist, then the function returns %FALSE,
- * and %GDK_NONE will be stored in @actual_property_type.
- *
- * <note>
- * <para>
- * The XGetWindowProperty() function that gdk_property_get()
- * uses has a very confusing and complicated set of semantics.
- * Unfortunately, gdk_property_get() makes the situation
- * worse instead of better (the semantics should be considered
- * undefined), and also prints warnings to stderr in cases where it
- * should return a useful error to the program. You are advised to use
- * XGetWindowProperty() directly until a replacement function for
- * gdk_property_get()
- * is provided.
- * </para>
- * </note>
- *
- * Returns: %TRUE if data was successfully received and stored
- *   in @data, otherwise %FALSE.
- */
 gboolean
-gdk_property_get (GdkWindow   *window,
-		  GdkAtom      property,
-		  GdkAtom      type,
-		  gulong       offset,
-		  gulong       length,
-		  gint         pdelete,
-		  GdkAtom     *actual_property_type,
-		  gint        *actual_format_type,
-		  gint        *actual_length,
-		  guchar     **data)
+_gdk_x11_window_get_property (GdkWindow   *window,
+                              GdkAtom      property,
+                              GdkAtom      type,
+                              gulong       offset,
+                              gulong       length,
+                              gint         pdelete,
+                              GdkAtom     *actual_property_type,
+                              gint        *actual_format_type,
+                              gint        *actual_length,
+                              guchar     **data)
 {
   GdkDisplay *display;
   Atom ret_prop_type;
@@ -730,34 +677,14 @@ gdk_property_get (GdkWindow   *window,
   return TRUE;
 }
 
-/**
- * gdk_property_change:
- * @window: a #GdkWindow.
- * @property: the property to change.
- * @type: the new type for the property. If @mode is
- *   %GDK_PROP_MODE_PREPEND or %GDK_PROP_MODE_APPEND, then this
- *   must match the existing type or an error will occur.
- * @format: the new format for the property. If @mode is
- *   %GDK_PROP_MODE_PREPEND or %GDK_PROP_MODE_APPEND, then this
- *   must match the existing format or an error will occur.
- * @mode: a value describing how the new data is to be combined
- *   with the current data.
- * @data: the data (a <literal>guchar *</literal>
- *   <literal>gushort *</literal>, or <literal>gulong *</literal>,
- *   depending on @format), cast to a <literal>guchar *</literal>.
- * @nelements: the number of elements of size determined by the format,
- *   contained in @data.
- *
- * Changes the contents of a property on a window.
- */
 void
-gdk_property_change (GdkWindow    *window,
-		     GdkAtom       property,
-		     GdkAtom       type,
-		     gint          format,
-		     GdkPropMode   mode,
-		     const guchar *data,
-		     gint          nelements)
+_gdk_x11_window_change_property (GdkWindow    *window,
+                                 GdkAtom       property,
+                                 GdkAtom       type,
+                                 gint          format,
+                                 GdkPropMode   mode,
+                                 const guchar *data,
+                                 gint          nelements)
 {
   GdkDisplay *display;
   Window xwindow;
@@ -813,16 +740,9 @@ gdk_property_change (GdkWindow    *window,
 		     xtype, format, mode, (guchar *)data, nelements);
 }
 
-/**
- * gdk_property_delete:
- * @window: a #GdkWindow.
- * @property: the property to delete.
- *
- * Deletes a property from a window.
- */
 void
-gdk_property_delete (GdkWindow *window,
-		     GdkAtom    property)
+_gdk_x11_window_delete_property (GdkWindow *window,
+                                 GdkAtom    property)
 {
   g_return_if_fail (!window || GDK_WINDOW_IS_X11 (window));
 
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 07746d0..2fd5fa5 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -4762,4 +4762,7 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
   impl_class->sync_rendering = _gdk_x11_window_sync_rendering;
   impl_class->simulate_key = _gdk_x11_window_simulate_key;
   impl_class->simulate_button = _gdk_x11_window_simulate_button;
+  impl_class->get_property = _gdk_x11_window_get_property;
+  impl_class->change_property = _gdk_x11_window_change_property;
+  impl_class->delete_property = _gdk_x11_window_delete_property;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]