#include "config.h"
-#include <stdio.h>
+#include <glib/gprintf.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "gdkregion-generic.h"
#include "gdkkeysyms.h"
#include "gdkinternals.h"
+#include "gdkintl.h"
#include "gdkprivate-win32.h"
#include "gdkinput-win32.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 <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},
- { "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 }
};
}
void
-_gdk_windowing_init (gint *argc,
- gchar ***argv)
+_gdk_windowing_init (void)
{
gchar buf[10];
-#ifdef HAVE_WINTAB
if (getenv ("GDK_IGNORE_WINTAB") != NULL)
_gdk_input_ignore_wintab = TRUE;
-#endif
+ else if (getenv ("GDK_USE_WINTAB") != NULL)
+ _gdk_input_ignore_wintab = FALSE;
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),
LOCALE_IDEFAULTANSICODEPAGE,
buf, sizeof (buf));
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 = 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");
- _gdk_selection_property = gdk_atom_intern ("GDK_SELECTION", 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);
+ g_warning ("%s: %s failed", where, api);
}
void
gint
gdk_screen_get_width (GdkScreen *screen)
{
- return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_parent_root)->impl)->width;
+ return GDK_WINDOW_OBJECT (_gdk_root)->width;
}
gint
gdk_screen_get_height (GdkScreen *screen)
{
- return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_parent_root)->impl)->height;
+ return GDK_WINDOW_OBJECT (_gdk_root)->height;
}
gint
gdk_screen_get_width_mm (GdkScreen *screen)
{
- return (double) GetDeviceCaps (_gdk_display_hdc, HORZRES) / GetDeviceCaps (_gdk_display_hdc, LOGPIXELSX) * 25.4;
+ return (double) gdk_screen_get_width (screen) / 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;
+ return (double) gdk_screen_get_height (screen) / GetDeviceCaps (_gdk_display_hdc, LOGPIXELSY) * 25.4;
}
void
{
}
+void
+gdk_notify_startup_complete_with_id (const gchar* startup_id)
+{
+}
+
+void
+gdk_window_set_startup_id (GdkWindow *window,
+ const gchar *startup_id)
+{
+}
+
#ifdef G_ENABLE_DEBUG
/*
*/
static gchar *
static_printf (const gchar *format,
- ...)
+ ...)
{
static gchar buf[10000];
gchar *msg;
(pep[i].peFlags == PC_EXPLICIT ? " PC_EXPLICIT" :
(pep[i].peFlags == PC_NOCOLLAPSE ? " PC_NOCOLLAPSE" :
(pep[i].peFlags == PC_RESERVED ? " PC_RESERVED" :
- (sprintf (buf, " %d", pep[i].peFlags), buf))))));
+ (g_sprintf (buf, " %d", pep[i].peFlags), buf))))));
}
void
_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)),
return NULL;
}
+gchar *
+_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol)
+{
+ switch (protocol)
+ {
+#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", protocol);
+ }
+ /* NOTREACHED */
+ return NULL;
+}
+
gchar *
_gdk_win32_gcvalues_mask_to_string (GdkGCValuesMask mask)
{
#define BIT(x) \
if (mask & GDK_GC_##x) \
- (bufp += sprintf (bufp, "%s" #x, s), s = "|")
+ (bufp += g_sprintf (bufp, "%s" #x, s), s = "|")
BIT (FOREGROUND);
BIT (BACKGROUND);
return static_printf ("%s", buf);
}
+gchar *
+_gdk_win32_window_style_to_string (LONG style)
+{
+ 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_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)
{
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);
}
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);
}
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);
}
CASE (WM_PENWINFIRST);
CASE (WM_PENWINLAST);
CASE (WM_APP);
+ CASE (WT_PACKET);
+ CASE (WT_CSRCHANGE);
+ CASE (WT_PROXIMITY);
#undef CASE
default:
if (msg >= WM_HANDHELDFIRST && msg <= WM_HANDHELDLAST)
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);
}
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)
{
- return static_printf ("%dx%d@+%d+%d",
+ 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);
gchar *
_gdk_win32_drawable_description (GdkDrawable *d)
{
- GdkVisual *v;
- gint width, height;
+ gint width, height, depth;
+
+ g_return_val_if_fail (GDK_IS_DRAWABLE (d), NULL);
gdk_drawable_get_size (d, &width, &height);
+ depth = gdk_drawable_get_depth (d);
- return static_printf
- ("%s:%p:%dx%dx%d",
- G_OBJECT_TYPE_NAME (d),
- GDK_DRAWABLE_HANDLE (d),
- width, height,
- (GDK_IS_PIXMAP (d) ? GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (d)->impl)->image->depth
- : ((v = gdk_drawable_get_visual (d)) ? v->depth : gdk_visual_get_system ()->depth)));
+ return static_printf ("%s:%p:%dx%dx%d",
+ G_OBJECT_TYPE_NAME (d),
+ GDK_DRAWABLE_HANDLE (d),
+ width, height, depth);
}
#endif /* G_ENABLE_DEBUG */