]> Pileus Git - ~andy/gtk/blobdiff - gdk/win32/gdkmain-win32.c
Minor documentation improvements
[~andy/gtk] / gdk / win32 / gdkmain-win32.c
index df42789e23f042cfd3d86b070af87012161dc185..a876631df6f83b1694a153424064c70a964285be 100644 (file)
@@ -25,7 +25,7 @@
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <glib/gprintf.h>
 #include <stdlib.h>
 #include <io.h>
 
 #include "gdk.h"
-#include "gdkregion-generic.h"
 #include "gdkkeysyms.h"
 #include "gdkinternals.h"
+#include "gdkintl.h"
 #include "gdkprivate-win32.h"
-#include "gdkinput-win32.h"
+#include "gdkwin32.h"
 
 #include <objbase.h>
 
-#if defined (__GNUC__) && defined (HAVE_DIMM_H)
-/* The w32api imm.h clashes a bit with the IE5.5 dimm.h */
-# define IMEMENUITEMINFOA hidden_IMEMENUITEMINFOA
-# define IMEMENUITEMINFOW hidden_IMEMENUITEMINFOW
-#endif
-
+#include <windows.h>
+#include <wintab.h>
 #include <imm.h>
 
 static gboolean gdk_synchronize = FALSE;
 
-GdkArgDesc _gdk_windowing_args[] = {
-  { "sync",          GDK_ARG_BOOL, &gdk_synchronize, (GdkArgFunc) NULL},
-  { "no-wintab",     GDK_ARG_BOOL, &_gdk_input_ignore_wintab,
-                                                    (GdkArgFunc) NULL},
-  { "ignore-wintab", GDK_ARG_BOOL, &_gdk_input_ignore_wintab,
-                                                    (GdkArgFunc) NULL},
-  { "use-wintab",    GDK_ARG_NOBOOL, &_gdk_input_ignore_wintab,
-                                                    (GdkArgFunc) NULL},
-  { "max-colors",    GDK_ARG_INT,  &_gdk_max_colors,  (GdkArgFunc) NULL},
+static gboolean dummy;
+
+const GOptionEntry _gdk_windowing_args[] = {
+  { "sync", 0, 0, G_OPTION_ARG_NONE, &gdk_synchronize, 
+    /* Description of --sync in --help output */              N_("Don't batch GDI requests"), NULL },
+  { "no-wintab", 0, 0, G_OPTION_ARG_NONE, &_gdk_input_ignore_wintab, 
+    /* Description of --no-wintab in --help output */         N_("Don't use the Wintab API for tablet support"), NULL },
+  { "ignore-wintab", 0, 0, G_OPTION_ARG_NONE, &_gdk_input_ignore_wintab, 
+    /* Description of --ignore-wintab in --help output */     N_("Same as --no-wintab"), NULL },
+  { "use-wintab", 0, 0, G_OPTION_ARG_NONE, &dummy,
+    /* Description of --use-wintab in --help output */     N_("Do use the Wintab API [default]"), NULL },
+  { "max-colors", 0, 0, G_OPTION_ARG_INT, &_gdk_max_colors, 
+    /* Description of --max-colors=COLORS in --help output */ N_("Size of the palette in 8 bit mode"), 
+    /* Placeholder in --max-colors=COLORS in --help output */ N_("COLORS") },
   { NULL }
 };
 
-int __stdcall
+BOOL WINAPI
 DllMain (HINSTANCE hinstDLL,
         DWORD     dwReason,
         LPVOID    reserved)
@@ -75,31 +76,20 @@ DllMain (HINSTANCE hinstDLL,
 }
 
 void
-_gdk_windowing_init (gint    *argc,
-                     gchar ***argv)
+_gdk_win32_windowing_init (void)
 {
   gchar buf[10];
 
-#ifdef HAVE_WINTAB
   if (getenv ("GDK_IGNORE_WINTAB") != NULL)
     _gdk_input_ignore_wintab = TRUE;
   else if (getenv ("GDK_USE_WINTAB") != NULL)
     _gdk_input_ignore_wintab = FALSE;
-#endif
 
   if (gdk_synchronize)
     GdiSetBatchLimit (1);
 
   _gdk_app_hmodule = GetModuleHandle (NULL);
   _gdk_display_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
-  _gdk_root_window = GetDesktopWindow ();
-  _windows_version = GetVersion ();
-
-  if (getenv ("PRETEND_WIN9X"))
-    _windows_version = 0x80000004;
-
-  GDK_NOTE (MISC, g_print ("Windows version: %08x\n", (guint) _windows_version));
-
   _gdk_input_locale = GetKeyboardLayout (0);
   _gdk_input_locale_is_ime = ImmIsIME (_gdk_input_locale);
   GetLocaleInfo (MAKELCID (LOWORD (_gdk_input_locale), SORT_DEFAULT),
@@ -111,135 +101,57 @@ _gdk_windowing_init (gint    *argc,
 
   CoInitialize (NULL);
 
-  _cf_rtf = RegisterClipboardFormat ("Rich Text Format");
-  _cf_utf8_string = RegisterClipboardFormat ("UTF8_STRING");
-
-  _utf8_string = gdk_atom_intern ("UTF8_STRING", FALSE);
-  _compound_text = gdk_atom_intern ("COMPOUND_TEXT", FALSE);
-  _text_uri_list = gdk_atom_intern ("text/uri-list", FALSE);
-
-  _local_dnd = gdk_atom_intern ("LocalDndSelection", FALSE);
-  _gdk_win32_dropfiles = gdk_atom_intern ("DROPFILES_DND", FALSE);
-  _gdk_ole2_dnd = gdk_atom_intern ("OLE2_DND", FALSE);
-
-  _gdk_selection_property = gdk_atom_intern ("GDK_SELECTION", FALSE);
+  _gdk_selection = gdk_atom_intern_static_string ("GDK_SELECTION");
+  _wm_transient_for = gdk_atom_intern_static_string ("WM_TRANSIENT_FOR");
+  _targets = gdk_atom_intern_static_string ("TARGETS");
+  _delete = gdk_atom_intern_static_string ("DELETE");
+  _save_targets = gdk_atom_intern_static_string ("SAVE_TARGETS");
+  _utf8_string = gdk_atom_intern_static_string ("UTF8_STRING");
+  _text = gdk_atom_intern_static_string ("TEXT");
+  _compound_text = gdk_atom_intern_static_string ("COMPOUND_TEXT");
+  _text_uri_list = gdk_atom_intern_static_string ("text/uri-list");
+  _text_html = gdk_atom_intern_static_string ("text/html");
+  _image_png = gdk_atom_intern_static_string ("image/png");
+  _image_jpeg = gdk_atom_intern_static_string ("image/jpeg");
+  _image_bmp = gdk_atom_intern_static_string ("image/bmp");
+  _image_gif = gdk_atom_intern_static_string ("image/gif");
+
+  _local_dnd = gdk_atom_intern_static_string ("LocalDndSelection");
+  _gdk_win32_dropfiles = gdk_atom_intern_static_string ("DROPFILES_DND");
+  _gdk_ole2_dnd = gdk_atom_intern_static_string ("OLE2_DND");
+
+  /* MS Office 2007, at least, offers images in common file formats
+   * using clipboard format names like "PNG" and "JFIF". So we follow
+   * the lead and map the GDK target name "image/png" to the clipboard
+   * format name "PNG" etc.
+   */
+  _cf_png = RegisterClipboardFormat ("PNG");
+  _cf_jfif = RegisterClipboardFormat ("JFIF");
+  _cf_gif = RegisterClipboardFormat ("GIF");
 
-  _wm_transient_for = gdk_atom_intern ("WM_TRANSIENT_FOR", FALSE);
+  _cf_url = RegisterClipboardFormat ("UniformResourceLocatorW");
+  _cf_html_format = RegisterClipboardFormat ("HTML Format");
+  _cf_text_html = RegisterClipboardFormat ("text/html");
 
   _gdk_win32_selection_init ();
 }
 
 void
 _gdk_win32_api_failed (const gchar *where,
-                     gint         line,
                      const gchar *api)
 {
   gchar *msg = g_win32_error_message (GetLastError ());
-  g_warning ("%s:%d: %s failed: %s", where, line, api, msg);
+  g_warning ("%s: %s failed: %s", where, api, msg);
   g_free (msg);
 }
 
 void
 _gdk_other_api_failed (const gchar *where,
-                     gint         line,
-                     const gchar *api)
-{
-  g_warning ("%s:%d: %s failed", where, line, api);
-}
-
-void
-_gdk_win32_gdi_failed (const gchar *where,
-                     gint         line,
                      const gchar *api)
 {
-  /* On Win9x GDI calls are implemented in 16-bit code and thus
-   * don't set the 32-bit error code, sigh.
-   */
-  if (IS_WIN_NT ())
-    _gdk_win32_api_failed (where, line, api);
-  else
-    _gdk_other_api_failed (where, line, api);
-}
-
-void
-gdk_set_use_xshm (gboolean use_xshm)
-{
-  /* Always on */
+  g_warning ("%s: %s failed", where, api);
 }
 
-gboolean
-gdk_get_use_xshm (void)
-{
-  return TRUE;
-}
-
-gint
-gdk_screen_get_width (GdkScreen *screen)
-{
-  return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_parent_root)->impl)->width;
-}
-
-gint
-gdk_screen_get_height (GdkScreen *screen)
-{
-  return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_parent_root)->impl)->height;
-}
-gint
-gdk_screen_get_width_mm (GdkScreen *screen)
-{
-  return (double) GetDeviceCaps (_gdk_display_hdc, HORZRES) / GetDeviceCaps (_gdk_display_hdc, LOGPIXELSX) * 25.4;
-}
-
-gint
-gdk_screen_get_height_mm (GdkScreen *screen)
-{
-  return (double) GetDeviceCaps (_gdk_display_hdc, VERTRES) / GetDeviceCaps (_gdk_display_hdc, LOGPIXELSY) * 25.4;
-}
-
-void
-_gdk_windowing_display_set_sm_client_id (GdkDisplay  *display,
-                                        const gchar *sm_client_id)
-{
-  g_warning("gdk_set_sm_client_id %s", sm_client_id ? sm_client_id : "NULL");
-}
-
-void
-gdk_display_beep (GdkDisplay *display)
-{
-  g_return_if_fail (display == gdk_display_get_default());
-  Beep(1000, 50);
-}
-
-void
-_gdk_windowing_exit (void)
-{
-  _gdk_win32_dnd_exit ();
-  CoUninitialize ();
-  DeleteDC (_gdk_display_hdc);
-  _gdk_display_hdc = NULL;
-}
-
-gchar *
-gdk_get_display (void)
-{
-  return g_strdup (gdk_display_get_name (gdk_display_get_default ()));
-}
-
-void
-gdk_error_trap_push (void)
-{
-}
-
-gint
-gdk_error_trap_pop (void)
-{
-  return 0;
-}
-
-void
-gdk_notify_startup_complete (void)
-{
-}
 
 #ifdef G_ENABLE_DEBUG
 
@@ -253,7 +165,7 @@ gdk_notify_startup_complete (void)
  */
 static gchar *
 static_printf (const gchar *format,
-                        ...)
+              ...)
 {
   static gchar buf[10000];
   gchar *msg;
@@ -380,7 +292,7 @@ _gdk_win32_print_dc (HDC hdc)
           _gdk_win32_psstyle_to_string (extlogpen.elpPenStyle),
           _gdk_win32_psendcap_to_string (extlogpen.elpPenStyle),
           _gdk_win32_psjoin_to_string (extlogpen.elpPenStyle),
-          extlogpen.elpWidth,
+          (int) extlogpen.elpWidth,
           _gdk_win32_lbstyle_to_string (extlogpen.elpBrushStyle));
   g_print ("rop2: %s textcolor=%06lx\n",
           _gdk_win32_rop2_to_string (GetROP2 (hdc)),
@@ -400,137 +312,173 @@ _gdk_win32_print_dc (HDC hdc)
 }
 
 gchar *
-_gdk_win32_cap_style_to_string (GdkCapStyle cap_style)
+_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol)
 {
-  switch (cap_style)
+  switch (protocol)
     {
-#define CASE(x) case GDK_CAP_##x: return #x
-    CASE (NOT_LAST);
-    CASE (BUTT);
-    CASE (ROUND);
-    CASE (PROJECTING);
+#define CASE(x) case GDK_DRAG_PROTO_##x: return #x
+      CASE (MOTIF);
+      CASE (XDND);
+      CASE (ROOTWIN);
+      CASE (NONE);
+      CASE (WIN32_DROPFILES);
+      CASE (OLE2);
+      CASE (LOCAL);
 #undef CASE
-    default: return static_printf ("illegal_%d", cap_style);
+    default: return static_printf ("illegal_%d", protocol);
     }
   /* NOTREACHED */
-  return NULL;
+  return NULL; 
 }
 
 gchar *
-_gdk_win32_fill_style_to_string (GdkFill fill)
+_gdk_win32_window_state_to_string (GdkWindowState state)
 {
-  switch (fill)
-    {
-#define CASE(x) case GDK_##x: return #x
-    CASE (SOLID);
-    CASE (TILED);
-    CASE (STIPPLED);
-    CASE (OPAQUE_STIPPLED);
-#undef CASE
-    default: return static_printf ("illegal_%d", fill);
-    }
-  /* NOTREACHED */
-  return NULL;
-}
+  gchar buf[100];
+  gchar *bufp = buf;
+  gchar *s = "";
 
-gchar *
-_gdk_win32_function_to_string (GdkFunction function)
-{
-  switch (function)
-    {
-#define CASE(x) case GDK_##x: return #x
-    CASE (COPY);
-    CASE (INVERT);
-    CASE (XOR);
-    CASE (CLEAR);
-    CASE (AND);
-    CASE (AND_REVERSE);
-    CASE (AND_INVERT);
-    CASE (NOOP);
-    CASE (OR);
-    CASE (EQUIV);
-    CASE (OR_REVERSE);
-    CASE (COPY_INVERT);
-    CASE (OR_INVERT);
-    CASE (NAND);
-    CASE (SET);
-#undef CASE
-    default: return static_printf ("illegal_%d", function);
-    }
-  /* NOTREACHED */
-  return NULL; 
+  buf[0] = '\0';
+
+#define BIT(x)                                         \
+  if (state & GDK_WINDOW_STATE_ ## x)                  \
+    (bufp += sprintf (bufp, "%s" #x, s), s = "|")
+
+  /* For clarity, also show the complement of WITHDRAWN, i.e. "MAPPED" */
+  if (!(state & GDK_WINDOW_STATE_WITHDRAWN))
+    (bufp += sprintf (bufp, "MAPPED"), s = "|");
+
+  BIT (WITHDRAWN);
+  BIT (ICONIFIED);
+  BIT (MAXIMIZED);
+  BIT (STICKY);
+#undef BIT
+
+  return static_printf ("%s", buf);  
 }
 
 gchar *
-_gdk_win32_join_style_to_string (GdkJoinStyle join_style)
+_gdk_win32_window_style_to_string (LONG style)
 {
-  switch (join_style)
-    {
-#define CASE(x) case GDK_JOIN_##x: return #x
-    CASE (MITER);
-    CASE (ROUND);
-    CASE (BEVEL);
-#undef CASE
-    default: return static_printf ("illegal_%d", join_style);
-    }
-  /* NOTREACHED */
-  return NULL; 
+  gchar buf[1000];
+  gchar *bufp = buf;
+  gchar *s = "";
+
+  buf[0] = '\0';
+
+#define BIT(x)                                         \
+  if (style & WS_ ## x)                                        \
+    (bufp += sprintf (bufp, "%s" #x, s), s = "|")
+
+  /* Note that many of the WS_* macros are in face several bits.
+   * Handle just the individual bits here. Sort as in w32api's
+   * winuser.h.
+   */
+  BIT (BORDER);
+  BIT (CHILD);
+  BIT (CLIPCHILDREN);
+  BIT (CLIPSIBLINGS);
+  BIT (DISABLED);
+  BIT (DLGFRAME);
+  BIT (GROUP);
+  BIT (HSCROLL);
+  BIT (ICONIC);
+  BIT (MAXIMIZE);
+  BIT (MAXIMIZEBOX);
+  BIT (MINIMIZE);
+  BIT (MINIMIZEBOX);
+  BIT (POPUP);
+  BIT (SIZEBOX);
+  BIT (SYSMENU);
+  BIT (TABSTOP);
+  BIT (THICKFRAME);
+  BIT (VISIBLE);
+  BIT (VSCROLL);
+#undef BIT
+
+  return static_printf ("%s", buf);  
 }
 
 gchar *
-_gdk_win32_line_style_to_string (GdkLineStyle line_style)
+_gdk_win32_window_exstyle_to_string (LONG style)
 {
-  switch (line_style)
-    {
-#define CASE(x) case GDK_LINE_##x: return #x
-    CASE(SOLID);
-    CASE(ON_OFF_DASH);  
-    CASE(DOUBLE_DASH);  
-#undef CASE
-    default: return static_printf ("illegal_%d", line_style);
-    }
-  /* NOTREACHED */
-  return NULL; 
+  gchar buf[1000];
+  gchar *bufp = buf;
+  gchar *s = "";
+
+  buf[0] = '\0';
+
+#define BIT(x)                                         \
+  if (style & WS_EX_ ## x)                             \
+    (bufp += sprintf (bufp, "%s" #x, s), s = "|")
+
+  /* Note that many of the WS_EX_* macros are in face several bits.
+   * Handle just the individual bits here. Sort as in w32api's
+   * winuser.h.
+   */
+  BIT (ACCEPTFILES);
+  BIT (APPWINDOW);
+  BIT (CLIENTEDGE);
+#ifndef WS_EX_COMPOSITED
+#  define WS_EX_COMPOSITED 0x02000000L
+#endif
+  BIT (COMPOSITED);
+  BIT (CONTEXTHELP);
+  BIT (CONTROLPARENT);
+  BIT (DLGMODALFRAME);
+  BIT (LAYERED);
+  BIT (LAYOUTRTL);
+  BIT (LEFTSCROLLBAR);
+  BIT (MDICHILD);
+  BIT (NOACTIVATE);
+  BIT (NOINHERITLAYOUT);
+  BIT (NOPARENTNOTIFY);
+  BIT (RIGHT);
+  BIT (RTLREADING);
+  BIT (STATICEDGE);
+  BIT (TOOLWINDOW);
+  BIT (TOPMOST);
+  BIT (TRANSPARENT);
+  BIT (WINDOWEDGE);
+#undef BIT
+
+  return static_printf ("%s", buf);  
 }
 
 gchar *
-_gdk_win32_gcvalues_mask_to_string (GdkGCValuesMask mask)
+_gdk_win32_window_pos_bits_to_string (UINT flags)
 {
-  gchar buf[400];
+  gchar buf[1000];
   gchar *bufp = buf;
   gchar *s = "";
 
   buf[0] = '\0';
 
-#define BIT(x)                                                 \
-  if (mask & GDK_GC_##x)                               \
-    (bufp += g_sprintf (bufp, "%s" #x, s), s = "|")
-
-  BIT (FOREGROUND);
-  BIT (BACKGROUND);
-  BIT (FONT);
-  BIT (FUNCTION);
-  BIT (FILL);
-  BIT (TILE);
-  BIT (STIPPLE);
-  BIT (CLIP_MASK);
-  BIT (SUBWINDOW);
-  BIT (TS_X_ORIGIN);
-  BIT (TS_Y_ORIGIN);
-  BIT (CLIP_X_ORIGIN);
-  BIT (CLIP_Y_ORIGIN);
-  BIT (EXPOSURES);
-  BIT (LINE_WIDTH);
-  BIT (LINE_STYLE);
-  BIT (CAP_STYLE);
-  BIT (JOIN_STYLE);
+#define BIT(x)                                         \
+  if (flags & SWP_ ## x)                               \
+    (bufp += sprintf (bufp, "%s" #x, s), s = "|")
+
+  BIT (DRAWFRAME);
+  BIT (FRAMECHANGED);
+  BIT (HIDEWINDOW);
+  BIT (NOACTIVATE);
+  BIT (NOCOPYBITS);
+  BIT (NOMOVE);
+  BIT (NOSIZE);
+  BIT (NOREDRAW);
+  BIT (NOZORDER);
+  BIT (SHOWWINDOW);
+  BIT (NOOWNERZORDER);
+  BIT (NOSENDCHANGING);
+  BIT (DEFERERASE);
+  BIT (ASYNCWINDOWPOS);
 #undef BIT
 
   return static_printf ("%s", buf);  
 }
 
 gchar *
-_gdk_win32_window_state_to_string (GdkWindowState state)
+_gdk_win32_drag_action_to_string (GdkDragAction actions)
 {
   gchar buf[100];
   gchar *bufp = buf;
@@ -539,17 +487,15 @@ _gdk_win32_window_state_to_string (GdkWindowState state)
   buf[0] = '\0';
 
 #define BIT(x)                                         \
-  if (state & GDK_WINDOW_STATE_ ## x)                  \
+  if (actions & GDK_ACTION_ ## x)                              \
     (bufp += sprintf (bufp, "%s" #x, s), s = "|")
 
-  /* For clarity, also show the complement of WITHDRAWN, i.e. "MAPPED" */
-  if (!(state & GDK_WINDOW_STATE_WITHDRAWN))
-    (bufp += sprintf (bufp, "MAPPED"), s = "|");
-
-  BIT (WITHDRAWN);
-  BIT (ICONIFIED);
-  BIT (MAXIMIZED);
-  BIT (STICKY);
+  BIT (DEFAULT);
+  BIT (COPY);
+  BIT (MOVE);
+  BIT (LINK);
+  BIT (PRIVATE);
+  BIT (ASK);
 #undef BIT
 
   return static_printf ("%s", buf);  
@@ -622,14 +568,15 @@ _gdk_win32_psstyle_to_string (DWORD pen_style)
   switch (pen_style & PS_STYLE_MASK)
     {
 #define CASE(x) case PS_##x: return #x
+      CASE (ALTERNATE);
+      CASE (SOLID);
       CASE (DASH);
+      CASE (DOT);
       CASE (DASHDOT);
       CASE (DASHDOTDOT);
-      CASE (DOT);
-      CASE (INSIDEFRAME);
       CASE (NULL);
-      CASE (SOLID);
       CASE (USERSTYLE);
+      CASE (INSIDEFRAME);
 #undef CASE
     default: return static_printf ("illegal_%d", pen_style & PS_STYLE_MASK);
     }
@@ -643,9 +590,9 @@ _gdk_win32_psendcap_to_string (DWORD pen_style)
   switch (pen_style & PS_ENDCAP_MASK)
     {
 #define CASE(x) case PS_ENDCAP_##x: return #x
-      CASE (FLAT);
       CASE (ROUND);
       CASE (SQUARE);
+      CASE (FLAT);
 #undef CASE
     default: return static_printf ("illegal_%d", pen_style & PS_ENDCAP_MASK);
     }
@@ -659,9 +606,9 @@ _gdk_win32_psjoin_to_string (DWORD pen_style)
   switch (pen_style & PS_JOIN_MASK)
     {
 #define CASE(x) case PS_JOIN_##x: return #x
+      CASE (ROUND);
       CASE (BEVEL);
       CASE (MITER);
-      CASE (ROUND);
 #undef CASE
     default: return static_printf ("illegal_%d", pen_style & PS_JOIN_MASK);
     }
@@ -882,11 +829,9 @@ _gdk_win32_message_to_string (UINT msg)
       CASE (WM_PENWINFIRST);
       CASE (WM_PENWINLAST);
       CASE (WM_APP);
-#ifdef HAVE_WINTAB
       CASE (WT_PACKET);
       CASE (WT_CSRCHANGE);
       CASE (WT_PROXIMITY);
-#endif
 #undef CASE
     default:
       if (msg >= WM_HANDHELDFIRST && msg <= WM_HANDHELDLAST)
@@ -906,10 +851,93 @@ _gdk_win32_message_to_string (UINT msg)
   return NULL;
 }
 
+gchar *
+_gdk_win32_key_to_string (LONG lParam)
+{
+  char buf[100];
+  gchar *keyname_utf8;
+
+  if (GetKeyNameText (lParam, buf, sizeof (buf)) &&
+      (keyname_utf8 = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL)) != NULL)
+    {
+      gchar *retval = static_printf ("%s", keyname_utf8);
+
+      g_free (keyname_utf8);
+
+      return retval;
+    }
+
+  return static_printf ("unk-%#lx", lParam);
+}
+      
+gchar *
+_gdk_win32_cf_to_string (UINT format)
+{
+  char buf[100];
+
+  switch (format)
+    {
+#define CASE(x) case CF_##x: return "CF_" #x
+      CASE (BITMAP);
+      CASE (DIB);
+      CASE (DIBV5);
+      CASE (DIF);
+      CASE (DSPBITMAP);
+      CASE (DSPENHMETAFILE);
+      CASE (DSPMETAFILEPICT);
+      CASE (DSPTEXT);
+      CASE (ENHMETAFILE);
+      CASE (HDROP);
+      CASE (LOCALE);
+      CASE (METAFILEPICT);
+      CASE (OEMTEXT);
+      CASE (OWNERDISPLAY);
+      CASE (PALETTE);
+      CASE (PENDATA);
+      CASE (RIFF);
+      CASE (SYLK);
+      CASE (TEXT);
+      CASE (WAVE);
+      CASE (TIFF);
+      CASE (UNICODETEXT);
+    default:
+      if (format >= CF_GDIOBJFIRST &&
+         format <= CF_GDIOBJLAST)
+       return static_printf ("CF_GDIOBJ%d", format - CF_GDIOBJFIRST);
+      if (format >= CF_PRIVATEFIRST &&
+         format <= CF_PRIVATELAST)
+       return static_printf ("CF_PRIVATE%d", format - CF_PRIVATEFIRST);
+      if (GetClipboardFormatName (format, buf, sizeof (buf)))
+       return static_printf ("'%s'", buf);
+      else
+       return static_printf ("unk-%#lx", format);
+    }
+}
+      
+gchar *
+_gdk_win32_data_to_string (const guchar *data,
+                          int           nbytes)
+{
+  GString *s = g_string_new ("");
+  int i;
+  gchar *retval;
+
+  for (i = 0; i < nbytes; i++)
+    if (data[i] >=' ' && data[i] <= '~')
+      g_string_append_printf (s, "%c  ", data[i]);
+    else
+      g_string_append_printf (s, "%02X ", data[i]);
+
+  retval = static_printf ("%s", s->str);
+  g_string_free (s, TRUE);
+
+  return retval;
+}
+
 gchar *
 _gdk_win32_rect_to_string (const RECT *rect)
 {
-  return static_printf ("%ldx%ld@+%ld+%ld",
+  return static_printf ("%ldx%ld@%+ld%+ld",
                        (rect->right - rect->left), (rect->bottom - rect->top),
                        rect->left, rect->top);
 }
@@ -917,33 +945,32 @@ _gdk_win32_rect_to_string (const RECT *rect)
 gchar *
 _gdk_win32_gdkrectangle_to_string (const GdkRectangle *rect)
 {
-  return static_printf ("%dx%d@+%d+%d",
+  return static_printf ("%dx%d@%+d%+d",
                        rect->width, rect->height,
                        rect->x, rect->y);
 }
 
 gchar *
-_gdk_win32_gdkregion_to_string (const GdkRegion *rgn)
+_gdk_win32_cairo_region_to_string (const cairo_region_t *rgn)
 {
-  return static_printf ("%dx%d@+%d+%d",
-                       (rgn->extents.x2 - rgn->extents.x1),
-                       (rgn->extents.y2 - rgn->extents.y1),
-                       rgn->extents.x1, rgn->extents.y1);
+  cairo_rectangle_int_t extents;
+  cairo_region_get_extents (rgn, &extents);
+  return static_printf ("%dx%d@%+d%+d",
+                       extents.width, extents.height,
+                       extents.x, extents.y);
 }
 
 gchar *
-_gdk_win32_drawable_description (GdkDrawable *d)
+_gdk_win32_window_description (GdkWindow *d)
 {
-  gint width, height, depth;
-
-  gdk_drawable_get_size (d, &width, &height);
-  depth = gdk_drawable_get_depth (d);
+  g_return_val_if_fail (GDK_IS_WINDOW (d), NULL);
 
-  return static_printf
-    ("%s:%p:%dx%dx%d",
-     G_OBJECT_TYPE_NAME (d),
-     GDK_DRAWABLE_HANDLE (d),
-     width, height, depth);
+  return static_printf ("%s:%p:%dx%dx%d",
+                       G_OBJECT_TYPE_NAME (d),
+                       GDK_WINDOW_HWND (d),
+                       gdk_window_get_width (GDK_WINDOW (d)),
+                        gdk_window_get_height (GDK_WINDOW (d)),
+                        gdk_visual_get_depth (gdk_window_get_visual (GDK_WINDOW (d))));
 }
 
 #endif /* G_ENABLE_DEBUG */