]> Pileus Git - ~andy/gtk/blobdiff - gdk/win32/gdkmain-win32.c
Minor documentation improvements
[~andy/gtk] / gdk / win32 / gdkmain-win32.c
index 8999008d16baac220e473cc543a4e16323a39226..a876631df6f83b1694a153424064c70a964285be 100644 (file)
 #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>
 
+#include <windows.h>
+#include <wintab.h>
 #include <imm.h>
 
 static gboolean gdk_synchronize = FALSE;
@@ -64,7 +65,7 @@ const GOptionEntry _gdk_windowing_args[] = {
   { NULL }
 };
 
-int __stdcall
+BOOL WINAPI
 DllMain (HINSTANCE hinstDLL,
         DWORD     dwReason,
         LPVOID    reserved)
@@ -75,7 +76,7 @@ DllMain (HINSTANCE hinstDLL,
 }
 
 void
-_gdk_windowing_init (void)
+_gdk_win32_windowing_init (void)
 {
   gchar buf[10];
 
@@ -100,134 +101,57 @@ _gdk_windowing_init (void)
 
   CoInitialize (NULL);
 
-  _cf_utf8_string = RegisterClipboardFormat ("UTF8_STRING");
-  _cf_image_bmp = RegisterClipboardFormat ("image/bmp");
-
-  _gdk_selection_property = gdk_atom_intern ("GDK_SELECTION", FALSE);
-  _wm_transient_for = gdk_atom_intern ("WM_TRANSIENT_FOR", FALSE);
-  _targets = gdk_atom_intern ("TARGETS", FALSE);
-  _save_targets = gdk_atom_intern ("SAVE_TARGETS", FALSE);
-  _utf8_string = gdk_atom_intern ("UTF8_STRING", FALSE);
-  _text = gdk_atom_intern ("TEXT", FALSE);
-  _compound_text = gdk_atom_intern ("COMPOUND_TEXT", FALSE);
-  _text_uri_list = gdk_atom_intern ("text/uri-list", FALSE);
-  _image_bmp = gdk_atom_intern ("image/bmp", 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");
 
-  _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);
+  _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_set_use_xshm (gboolean use_xshm)
-{
-  /* Always on */
-}
-
-gboolean
-gdk_get_use_xshm (void)
-{
-  return TRUE;
-}
-
-gint
-gdk_screen_get_width (GdkScreen *screen)
-{
-  return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_root)->impl)->width;
-}
-
-gint
-gdk_screen_get_height (GdkScreen *screen)
-{
-  return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_root)->impl)->height;
-}
-gint
-gdk_screen_get_width_mm (GdkScreen *screen)
-{
-  return (double) gdk_screen_get_width (screen) / GetDeviceCaps (_gdk_display_hdc, LOGPIXELSX) * 25.4;
-}
-
-gint
-gdk_screen_get_height_mm (GdkScreen *screen)
-{
-  return (double) gdk_screen_get_height (screen) / 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)
-{
-}
-
-void
-gdk_notify_startup_complete_with_id (const gchar* startup_id)
-{
+  g_warning ("%s: %s failed", where, api);
 }
 
-void          
-gdk_window_set_startup_id (GdkWindow   *window,
-                          const gchar *startup_id)
-{
-}
 
 #ifdef G_ENABLE_DEBUG
 
@@ -368,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)),
@@ -388,135 +312,25 @@ _gdk_win32_print_dc (HDC hdc)
 }
 
 gchar *
-_gdk_win32_cap_style_to_string (GdkCapStyle cap_style)
-{
-  switch (cap_style)
-    {
-#define CASE(x) case GDK_CAP_##x: return #x
-    CASE (NOT_LAST);
-    CASE (BUTT);
-    CASE (ROUND);
-    CASE (PROJECTING);
-#undef CASE
-    default: return static_printf ("illegal_%d", cap_style);
-    }
-  /* NOTREACHED */
-  return NULL;
-}
-
-gchar *
-_gdk_win32_fill_style_to_string (GdkFill fill)
-{
-  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 *
-_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; 
-}
-
-gchar *
-_gdk_win32_join_style_to_string (GdkJoinStyle join_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 *
-_gdk_win32_line_style_to_string (GdkLineStyle line_style)
+_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol)
 {
-  switch (line_style)
+  switch (protocol)
     {
-#define CASE(x) case GDK_LINE_##x: return #x
-    CASE(SOLID);
-    CASE(ON_OFF_DASH);  
-    CASE(DOUBLE_DASH);  
+#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", line_style);
+    default: return static_printf ("illegal_%d", protocol);
     }
   /* NOTREACHED */
   return NULL; 
 }
 
-gchar *
-_gdk_win32_gcvalues_mask_to_string (GdkGCValuesMask mask)
-{
-  gchar buf[400];
-  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);
-#undef BIT
-
-  return static_printf ("%s", buf);  
-}
-
 gchar *
 _gdk_win32_window_state_to_string (GdkWindowState state)
 {
@@ -553,7 +367,7 @@ _gdk_win32_window_style_to_string (LONG style)
   buf[0] = '\0';
 
 #define BIT(x)                                         \
-  if (style & WS_ ## x)                        \
+  if (style & WS_ ## x)                                        \
     (bufp += sprintf (bufp, "%s" #x, s), s = "|")
 
   /* Note that many of the WS_* macros are in face several bits.
@@ -585,6 +399,108 @@ _gdk_win32_window_style_to_string (LONG style)
   return static_printf ("%s", buf);  
 }
 
+gchar *
+_gdk_win32_window_exstyle_to_string (LONG style)
+{
+  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_window_pos_bits_to_string (UINT flags)
+{
+  gchar buf[1000];
+  gchar *bufp = buf;
+  gchar *s = "";
+
+  buf[0] = '\0';
+
+#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_drag_action_to_string (GdkDragAction actions)
+{
+  gchar buf[100];
+  gchar *bufp = buf;
+  gchar *s = "";
+
+  buf[0] = '\0';
+
+#define BIT(x)                                         \
+  if (actions & GDK_ACTION_ ## x)                              \
+    (bufp += sprintf (bufp, "%s" #x, s), s = "|")
+
+  BIT (DEFAULT);
+  BIT (COPY);
+  BIT (MOVE);
+  BIT (LINK);
+  BIT (PRIVATE);
+  BIT (ASK);
+#undef BIT
+
+  return static_printf ("%s", buf);  
+}
+
 gchar *
 _gdk_win32_rop2_to_string (int rop2)
 {
@@ -964,9 +880,7 @@ _gdk_win32_cf_to_string (UINT format)
 #define CASE(x) case CF_##x: return "CF_" #x
       CASE (BITMAP);
       CASE (DIB);
-#ifdef CF_DIBV5
       CASE (DIBV5);
-#endif
       CASE (DIF);
       CASE (DSPBITMAP);
       CASE (DSPENHMETAFILE);
@@ -1037,26 +951,26 @@ _gdk_win32_gdkrectangle_to_string (const GdkRectangle *rect)
 }
 
 gchar *
-_gdk_win32_gdkregion_to_string (const GdkRegion *rgn)
+_gdk_win32_cairo_region_to_string (const cairo_region_t *rgn)
 {
+  cairo_rectangle_int_t extents;
+  cairo_region_get_extents (rgn, &extents);
   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);
+                       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);
+                       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 */