From 46587958172cf895cca524a2cc91344463f358aa Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Sun, 23 Jul 2000 21:43:23 +0000 Subject: [PATCH] More work on the Win32 backend. More files compile now. --- gdk/win32/gdkcursor-win32.c | 6 +- gdk/win32/gdkdnd-win32.c | 4 +- gdk/win32/gdkdrawable-win32.c | 654 +++++++++++++---------- gdk/win32/gdkevents-win32.c | 980 +++++++++++++++++----------------- gdk/win32/gdkfont-win32.c | 60 +-- gdk/win32/gdkgc-win32.c | 634 ++++++++++++---------- gdk/win32/gdkglobals-win32.c | 7 +- gdk/win32/gdkimage-win32.c | 123 +---- gdk/win32/gdkmain-win32.c | 18 +- gdk/win32/gdkprivate-win32.h | 4 +- gdk/win32/gdkvisual-win32.c | 28 +- gdk/win32/gdkwin32.h | 24 +- gdk/win32/gdkwindow-win32.c | 22 +- 13 files changed, 1291 insertions(+), 1273 deletions(-) diff --git a/gdk/win32/gdkcursor-win32.c b/gdk/win32/gdkcursor-win32.c index ac10ff0d42..2247f0148b 100644 --- a/gdk/win32/gdkcursor-win32.c +++ b/gdk/win32/gdkcursor-win32.c @@ -235,14 +235,14 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source, q[-1] |= residue; /* Set left-over bits */ } - hcursor = CreateCursor (gdk_app_hinstance, x, y, cursor_width, cursor_height, + hcursor = CreateCursor (gdk_app_hmodule, x, y, cursor_width, cursor_height, and_mask, xor_mask); GDK_NOTE (MISC, g_print ("gdk_cursor_new_from_pixmap: " "%#x (%dx%d) %#x (%dx%d) = %#x (%dx%d)\n", - GDK_PIXMAP_HBM (source), + GDK_PIXMAP_HBITMAP (source), source_impl->width, source_impl->height, - GDK_PIXMAP_HBM (mask), + GDK_PIXMAP_HBITMAP (mask), mask_impl->width, mask_impl->height, hcursor, cursor_width, cursor_height)); diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c index 880e5662b9..285fc0e2d2 100644 --- a/gdk/win32/gdkdnd-win32.c +++ b/gdk/win32/gdkdnd-win32.c @@ -37,6 +37,7 @@ #include "gdkproperty.h" #include "gdkinternals.h" #include "gdkprivate-win32.h" +#include "gdkdrawable-win32.h" #ifdef OLE2_DND #include @@ -1108,7 +1109,6 @@ gdk_drag_find_window (GdkDragContext *context, GdkDragProtocol *protocol) { GdkDragContextPrivate *private = (GdkDragContextPrivate *)context; - GdkDrawablePrivate *drag_window_private = (GdkDrawablePrivate*) drag_window; HWND recipient; POINT pt; @@ -1233,7 +1233,7 @@ gdk_window_register_dnd (GdkWindow *window) * (in gtk, data of type text/uri-list) or not. */ gdk_window_add_filter (window, gdk_dropfiles_filter, NULL); - DragAcceptFiles (GDK_DRAWABLE_XID (window), TRUE); + DragAcceptFiles (GDK_WINDOW_HWND (window), TRUE); #ifdef OLE2_DND /* Register for OLE2 d&d */ diff --git a/gdk/win32/gdkdrawable-win32.c b/gdk/win32/gdkdrawable-win32.c index 37abf2db75..8a7466d419 100644 --- a/gdk/win32/gdkdrawable-win32.c +++ b/gdk/win32/gdkdrawable-win32.c @@ -24,19 +24,15 @@ * GTK+ at ftp://ftp.gtk.org/pub/gtk/. */ -#include "config.h" - #include #include -#ifndef G_PI -#define G_PI 3.14159265358979323846 -#endif +#include #include "gdkinternals.h" #include "gdkprivate-win32.h" - -static void gdk_win32_drawable_destroy (GdkDrawable *drawable); +#include "gdkdrawable-win32.h" +#include "gdkpixmap-win32.h" static void gdk_win32_draw_rectangle (GdkDrawable *drawable, GdkGC *gc, @@ -94,86 +90,121 @@ static void gdk_win32_draw_lines (GdkDrawable *drawable, GdkGC *gc, GdkPoint *points, gint npoints); +static void gdk_win32_draw_glyphs (GdkDrawable *drawable, + GdkGC *gc, + PangoFont *font, + gint x, + gint y, + PangoGlyphString *glyphs); +static void gdk_win32_draw_image (GdkDrawable *drawable, + GdkGC *gc, + GdkImage *image, + gint xsrc, + gint ysrc, + gint xdest, + gint ydest, + gint width, + gint height); -GdkDrawableClass _gdk_win32_drawable_class = { - gdk_win32_drawable_destroy, - _gdk_win32_gc_new, - gdk_win32_draw_rectangle, - gdk_win32_draw_arc, - gdk_win32_draw_polygon, - gdk_win32_draw_text, - gdk_win32_draw_text_wc, - gdk_win32_draw_drawable, - gdk_win32_draw_points, - gdk_win32_draw_segments, - gdk_win32_draw_lines -}; +static void gdk_win32_set_colormap (GdkDrawable *drawable, + GdkColormap *colormap); + +static GdkColormap* gdk_win32_get_colormap (GdkDrawable *drawable); + +static gint gdk_win32_get_depth (GdkDrawable *drawable); + +static void gdk_drawable_impl_win32_class_init (GdkDrawableImplWin32Class *klass); + +static gpointer parent_class = NULL; + +GType +gdk_drawable_impl_win32_get_type (void) +{ + static GType object_type = 0; + + if (!object_type) + { + static const GTypeInfo object_info = + { + sizeof (GdkDrawableImplWin32Class), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gdk_drawable_impl_win32_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GdkDrawableImplWin32), + 0, /* n_preallocs */ + (GInstanceInitFunc) NULL, + }; + + object_type = g_type_register_static (GDK_TYPE_DRAWABLE, + "GdkDrawableImplWin32", + &object_info); + } + + return object_type; +} + +static void +gdk_drawable_impl_win32_class_init (GdkDrawableImplWin32Class *klass) +{ + GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + drawable_class->create_gc = _gdk_win32_gc_new; + drawable_class->draw_rectangle = gdk_win32_draw_rectangle; + drawable_class->draw_arc = gdk_win32_draw_arc; + drawable_class->draw_polygon = gdk_win32_draw_polygon; + drawable_class->draw_text = gdk_win32_draw_text; + drawable_class->draw_text_wc = gdk_win32_draw_text_wc; + drawable_class->draw_drawable = gdk_win32_draw_drawable; + drawable_class->draw_points = gdk_win32_draw_points; + drawable_class->draw_segments = gdk_win32_draw_segments; + drawable_class->draw_lines = gdk_win32_draw_lines; + drawable_class->draw_glyphs = gdk_win32_draw_glyphs; + drawable_class->draw_image = gdk_win32_draw_image; + + drawable_class->set_colormap = gdk_win32_set_colormap; + drawable_class->get_colormap = gdk_win32_get_colormap; + + drawable_class->get_depth = gdk_win32_get_depth; +} /***************************************************** * Win32 specific implementations of generic functions * *****************************************************/ -GdkColormap* -gdk_drawable_get_colormap (GdkDrawable *drawable) +static GdkColormap* +gdk_win32_get_colormap (GdkDrawable *drawable) { - GdkDrawablePrivate *drawable_private; + GdkDrawableImplWin32 *impl; - g_return_val_if_fail (drawable != NULL, NULL); - drawable_private = (GdkDrawablePrivate*) drawable; - - if (!GDK_DRAWABLE_DESTROYED (drawable)) - { - if (drawable_private->colormap == NULL) - return gdk_colormap_get_system (); /* XXX ??? */ - else - return drawable_private->colormap; - } - - return NULL; + return impl->colormap; } -void -gdk_drawable_set_colormap (GdkDrawable *drawable, - GdkColormap *colormap) +static void +gdk_win32_set_colormap (GdkDrawable *drawable, + GdkColormap *colormap) { - GdkDrawablePrivate *drawable_private; - GdkColormapPrivateWin32 *colormap_private; + GdkDrawableImplWin32 *impl; + + g_return_if_fail (colormap != NULL); + + impl = GDK_DRAWABLE_IMPL_WIN32 (drawable); + + if (impl->colormap == colormap) + return; - g_return_if_fail (drawable != NULL); - g_return_if_fail (colormap != NULL); - - drawable_private = (GdkDrawablePrivate *) drawable; - colormap_private = (GdkColormapPrivateWin32 *) colormap; - - if (!GDK_DRAWABLE_DESTROYED (drawable)) - { - if (GDK_IS_WINDOW (drawable)) - { - g_return_if_fail (colormap_private->base.visual != - ((GdkColormapPrivate *) (drawable_private->colormap))->visual); - /* XXX ??? */ - GDK_NOTE (MISC, g_print ("gdk_drawable_set_colormap: %#x %#x\n", - GDK_DRAWABLE_XID (drawable), - colormap_private->xcolormap)); - } - if (drawable_private->colormap) - gdk_colormap_unref (drawable_private->colormap); - drawable_private->colormap = colormap; - gdk_colormap_ref (drawable_private->colormap); - - if (GDK_IS_WINDOW (drawable) - && drawable_private->window_type != GDK_WINDOW_TOPLEVEL) - gdk_window_add_colormap_windows (drawable); - } + if (impl->colormap) + gdk_colormap_unref (impl->colormap); + impl->colormap = colormap; + if (impl->colormap) + gdk_colormap_ref (impl->colormap); } /* Drawing */ -static void -gdk_win32_drawable_destroy (GdkDrawable *drawable) -{ - -} static void gdk_win32_draw_rectangle (GdkDrawable *drawable, @@ -184,8 +215,8 @@ gdk_win32_draw_rectangle (GdkDrawable *drawable, gint width, gint height) { - GdkGCPrivate *gc_private = (GdkGCPrivate*) gc; - GdkGCWin32Data *gc_data = GDK_GC_WIN32DATA (gc_private); + GdkGCWin32 *gc_private = GDK_GC_WIN32 (gc); + const GdkGCValuesMask mask = GDK_GC_FOREGROUND|GDK_GC_BACKGROUND; HDC hdc; HGDIOBJ oldpen, oldbrush; HBRUSH hbr = NULL; @@ -193,13 +224,12 @@ gdk_win32_draw_rectangle (GdkDrawable *drawable, gboolean ok = TRUE; GDK_NOTE (MISC, g_print ("gdk_win32_draw_rectangle: %#x (%d) %s%dx%d@+%d+%d\n", - GDK_DRAWABLE_XID (drawable), + GDK_DRAWABLE_HANDLE (drawable), gc_private, (filled ? "fill " : ""), width, height, x, y)); - hdc = gdk_gc_predraw (drawable, gc_private, - GDK_GC_FOREGROUND|GDK_GC_BACKGROUND); + hdc = gdk_gc_predraw (drawable, gc_private, mask); #if 0 { @@ -220,7 +250,7 @@ gdk_win32_draw_rectangle (GdkDrawable *drawable, } #endif - if (gc_data->fill_style == GDK_OPAQUE_STIPPLED) + if (gc_private->fill_style == GDK_OPAQUE_STIPPLED) { if (!BeginPath (hdc)) WIN32_GDI_FAILED ("BeginPath"), ok = FALSE; @@ -277,7 +307,7 @@ gdk_win32_draw_rectangle (GdkDrawable *drawable, SelectObject (hdc, oldbrush); } - gdk_gc_postdraw (drawable, gc_private, GDK_GC_FOREGROUND|GDK_GC_BACKGROUND); + gdk_gc_postdraw (drawable, gc_private, mask); } static void @@ -291,69 +321,66 @@ gdk_win32_draw_arc (GdkDrawable *drawable, gint angle1, gint angle2) { - GdkGCPrivate *gc_private; + GdkGCWin32 *gc_private = GDK_GC_WIN32 (gc); + const GdkGCValuesMask mask = GDK_GC_FOREGROUND|GDK_GC_BACKGROUND; HDC hdc; int nXStartArc, nYStartArc, nXEndArc, nYEndArc; - gc_private = (GdkGCPrivate*) gc; - GDK_NOTE (MISC, g_print ("gdk_draw_arc: %#x %d,%d,%d,%d %d %d\n", - GDK_DRAWABLE_XID (drawable), + GDK_DRAWABLE_HANDLE (drawable), x, y, width, height, angle1, angle2)); /* Seems that drawing arcs with width or height <= 2 fails, at least * with my TNT card. */ - if (width > 2 && height > 2 && angle2 != 0) + if (width <= 2 || height <= 2 || angle2 == 0) + return; + + hdc = gdk_gc_predraw (drawable, gc_private, mask); + + if (angle2 >= 360*64) { - hdc = gdk_gc_predraw (drawable, gc_private, - GDK_GC_FOREGROUND|GDK_GC_BACKGROUND); - - if (angle2 >= 360*64) - { - nXStartArc = nYStartArc = nXEndArc = nYEndArc = 0; - } - else if (angle2 > 0) - { - /* The 100. is just an arbitrary value */ - nXStartArc = x + width/2 + 100. * cos(angle1/64.*2.*G_PI/360.); - nYStartArc = y + height/2 + -100. * sin(angle1/64.*2.*G_PI/360.); - nXEndArc = x + width/2 + 100. * cos((angle1+angle2)/64.*2.*G_PI/360.); - nYEndArc = y + height/2 + -100. * sin((angle1+angle2)/64.*2.*G_PI/360.); - } - else - { - nXEndArc = x + width/2 + 100. * cos(angle1/64.*2.*G_PI/360.); - nYEndArc = y + height/2 + -100. * sin(angle1/64.*2.*G_PI/360.); - nXStartArc = x + width/2 + 100. * cos((angle1+angle2)/64.*2.*G_PI/360.); - nYStartArc = y + height/2 + -100. * sin((angle1+angle2)/64.*2.*G_PI/360.); - } - - /* GDK_OPAQUE_STIPPLED arcs not implemented. */ - - if (filled) - { - GDK_NOTE (MISC, g_print ("...Pie(hdc,%d,%d,%d,%d,%d,%d,%d,%d)\n", - x, y, x+width, y+height, - nXStartArc, nYStartArc, - nXEndArc, nYEndArc)); - if (!Pie (hdc, x, y, x+width, y+height, - nXStartArc, nYStartArc, nXEndArc, nYEndArc)) - WIN32_GDI_FAILED ("Pie"); - } - else - { - GDK_NOTE (MISC, g_print ("...Arc(hdc,%d,%d,%d,%d,%d,%d,%d,%d)\n", - x, y, x+width, y+height, - nXStartArc, nYStartArc, - nXEndArc, nYEndArc)); - if (!Arc (hdc, x, y, x+width, y+height, - nXStartArc, nYStartArc, nXEndArc, nYEndArc)) - WIN32_GDI_FAILED ("Arc"); - } - gdk_gc_postdraw (drawable, gc_private, - GDK_GC_FOREGROUND|GDK_GC_BACKGROUND); + nXStartArc = nYStartArc = nXEndArc = nYEndArc = 0; } + else if (angle2 > 0) + { + /* The 100. is just an arbitrary value */ + nXStartArc = x + width/2 + 100. * cos(angle1/64.*2.*G_PI/360.); + nYStartArc = y + height/2 + -100. * sin(angle1/64.*2.*G_PI/360.); + nXEndArc = x + width/2 + 100. * cos((angle1+angle2)/64.*2.*G_PI/360.); + nYEndArc = y + height/2 + -100. * sin((angle1+angle2)/64.*2.*G_PI/360.); + } + else + { + nXEndArc = x + width/2 + 100. * cos(angle1/64.*2.*G_PI/360.); + nYEndArc = y + height/2 + -100. * sin(angle1/64.*2.*G_PI/360.); + nXStartArc = x + width/2 + 100. * cos((angle1+angle2)/64.*2.*G_PI/360.); + nYStartArc = y + height/2 + -100. * sin((angle1+angle2)/64.*2.*G_PI/360.); + } + + /* GDK_OPAQUE_STIPPLED arcs not implemented. */ + + if (filled) + { + GDK_NOTE (MISC, g_print ("...Pie(hdc,%d,%d,%d,%d,%d,%d,%d,%d)\n", + x, y, x+width, y+height, + nXStartArc, nYStartArc, + nXEndArc, nYEndArc)); + if (!Pie (hdc, x, y, x+width, y+height, + nXStartArc, nYStartArc, nXEndArc, nYEndArc)) + WIN32_GDI_FAILED ("Pie"); + } + else + { + GDK_NOTE (MISC, g_print ("...Arc(hdc,%d,%d,%d,%d,%d,%d,%d,%d)\n", + x, y, x+width, y+height, + nXStartArc, nYStartArc, + nXEndArc, nYEndArc)); + if (!Arc (hdc, x, y, x+width, y+height, + nXStartArc, nYStartArc, nXEndArc, nYEndArc)) + WIN32_GDI_FAILED ("Arc"); + } + gdk_gc_postdraw (drawable, gc_private, mask); } static void @@ -363,8 +390,8 @@ gdk_win32_draw_polygon (GdkDrawable *drawable, GdkPoint *points, gint npoints) { - GdkGCPrivate *gc_private = (GdkGCPrivate*) gc; - GdkGCWin32Data *gc_data = GDK_GC_WIN32DATA (gc_private); + GdkGCWin32 *gc_private = GDK_GC_WIN32 (gc); + const GdkGCValuesMask mask = GDK_GC_FOREGROUND|GDK_GC_BACKGROUND; HDC hdc; HBRUSH hbr = NULL; POINT *pts; @@ -372,14 +399,13 @@ gdk_win32_draw_polygon (GdkDrawable *drawable, int i; GDK_NOTE (MISC, g_print ("gdk_win32_draw_polygon: %#x (%d) %d\n", - GDK_DRAWABLE_XID (drawable), gc_private, + GDK_DRAWABLE_HANDLE (drawable), gc_private, npoints)); if (npoints < 2) return; - hdc = gdk_gc_predraw (drawable, gc_private, - GDK_GC_FOREGROUND|GDK_GC_BACKGROUND); + hdc = gdk_gc_predraw (drawable, gc_private, mask); pts = g_new (POINT, npoints+1); for (i = 0; i < npoints; i++) @@ -388,12 +414,13 @@ gdk_win32_draw_polygon (GdkDrawable *drawable, pts[i].y = points[i].y; } - if (gc_data->fill_style == GDK_OPAQUE_STIPPLED) + if (gc_private->fill_style == GDK_OPAQUE_STIPPLED) { if (!BeginPath (hdc)) WIN32_GDI_FAILED ("BeginPath"), ok = FALSE; - MoveToEx (hdc, points[0].x, points[0].y, NULL); + if (ok) + MoveToEx (hdc, points[0].x, points[0].y, NULL); if (pts[0].x == pts[npoints-1].x && pts[0].y == pts[npoints-1].y) npoints--; @@ -440,7 +467,7 @@ gdk_win32_draw_polygon (GdkDrawable *drawable, } } g_free (pts); - gdk_gc_postdraw (drawable, gc_private, GDK_GC_FOREGROUND|GDK_GC_BACKGROUND); + gdk_gc_postdraw (drawable, gc_private, mask); } typedef struct @@ -462,7 +489,7 @@ gdk_draw_text_handler (GdkWin32SingleFont *singlefont, if (!singlefont) return; - if ((oldfont = SelectObject (argp->hdc, singlefont->xfont)) == NULL) + if ((oldfont = SelectObject (argp->hdc, singlefont->hfont)) == NULL) { WIN32_GDI_FAILED ("SelectObject"); return; @@ -485,51 +512,45 @@ gdk_win32_draw_text (GdkDrawable *drawable, const gchar *text, gint text_length) { - GdkGCPrivate *gc_private; - wchar_t *wcstr; + GdkGCWin32 *gc_private = GDK_GC_WIN32 (gc); + const GdkGCValuesMask mask = GDK_GC_FOREGROUND|GDK_GC_FONT; + wchar_t *wcstr, wc; gint wlen; gdk_draw_text_arg arg; - - if (GDK_DRAWABLE_DESTROYED (drawable)) - return; - if (text_length == 0) return; g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET); - gc_private = (GdkGCPrivate*) gc; - arg.x = x; arg.y = y; - arg.hdc = gdk_gc_predraw (drawable, gc_private, - GDK_GC_FOREGROUND|GDK_GC_FONT); + arg.hdc = gdk_gc_predraw (drawable, gc_private, mask); GDK_NOTE (MISC, g_print ("gdk_draw_text: %#x (%d,%d) \"%.*s\" (len %d)\n", - GDK_DRAWABLE_XID (drawable), + GDK_DRAWABLE_HANDLE (drawable), x, y, (text_length > 10 ? 10 : text_length), text, text_length)); - wcstr = g_new (wchar_t, text_length); if (text_length == 1) { /* For single characters, don't try to interpret as UTF-8. */ - wcstr[0] = (guchar) text[0]; - gdk_wchar_text_handle (font, wcstr, 1, gdk_draw_text_handler, &arg); + wc = (guchar) text[0]; + gdk_wchar_text_handle (font, &wc, 1, gdk_draw_text_handler, &arg); } else { + wcstr = g_new (wchar_t, text_length); if ((wlen = gdk_nmbstowchar_ts (wcstr, text, text_length, text_length)) == -1) g_warning ("gdk_win32_draw_text: gdk_nmbstowchar_ts failed"); else gdk_wchar_text_handle (font, wcstr, wlen, gdk_draw_text_handler, &arg); + g_free (wcstr); } - g_free (wcstr); - gdk_gc_postdraw (drawable, gc_private, GDK_GC_FOREGROUND|GDK_GC_FONT); + gdk_gc_postdraw (drawable, gc_private, mask); } static void @@ -541,29 +562,23 @@ gdk_win32_draw_text_wc (GdkDrawable *drawable, const GdkWChar *text, gint text_length) { - GdkGCPrivate *gc_private; + GdkGCWin32 *gc_private = GDK_GC_WIN32 (gc); + const GdkGCValuesMask mask = GDK_GC_FOREGROUND|GDK_GC_FONT; gint i, wlen; wchar_t *wcstr; gdk_draw_text_arg arg; - - if (GDK_DRAWABLE_DESTROYED (drawable)) - return; - if (text_length == 0) return; g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET); - gc_private = (GdkGCPrivate*) gc; - arg.x = x; arg.y = y; - arg.hdc = gdk_gc_predraw (drawable, gc_private, - GDK_GC_FOREGROUND|GDK_GC_FONT); + arg.hdc = gdk_gc_predraw (drawable, gc_private, mask); GDK_NOTE (MISC, g_print ("gdk_draw_text_wc: %#x (%d,%d) len: %d\n", - GDK_DRAWABLE_XID (drawable), + GDK_DRAWABLE_HANDLE (drawable), x, y, text_length)); if (sizeof (wchar_t) != sizeof (GdkWChar)) @@ -581,7 +596,7 @@ gdk_win32_draw_text_wc (GdkDrawable *drawable, if (sizeof (wchar_t) != sizeof (GdkWChar)) g_free (wcstr); - gdk_gc_postdraw (drawable, gc_private, GDK_GC_FOREGROUND|GDK_GC_FONT); + gdk_gc_postdraw (drawable, gc_private, mask); } static void @@ -595,38 +610,36 @@ gdk_win32_draw_drawable (GdkDrawable *drawable, gint width, gint height) { - GdkDrawablePrivate *src_private; - GdkGCPrivate *gc_private; + GdkGCWin32 *gc_private = GDK_GC_WIN32 (gc); + GdkDrawableImplWin32 *src_impl = GDK_DRAWABLE_IMPL_WIN32 (src); HDC hdc; HDC srcdc; HGDIOBJ hgdiobj; HRGN src_rgn, draw_rgn, outside_rgn; RECT r; + gint src_width, src_height; + gboolean ok = TRUE; - src_private = (GdkDrawablePrivate*) src; - gc_private = (GdkGCPrivate*) gc; - - GDK_NOTE (MISC, g_print ("gdk_draw_pixmap: dest: %#x " - "src: %#x %dx%d@+%d+%d" - " dest: %#x @+%d+%d\n", - GDK_DRAWABLE_XID (drawable), - GDK_DRAWABLE_XID (src), - width, height, xsrc, ysrc, - GDK_DRAWABLE_XID (drawable), xdest, ydest)); + GDK_NOTE (MISC, g_print ("gdk_draw_pixmap: dest: %#x @+%d+%d" + "src: %#x %dx%d@+%d+%d\n", + GDK_DRAWABLE_HANDLE (drawable), xdest, ydest, + GDK_PIXMAP_HBITMAP (src), + width, height, xsrc, ysrc)); hdc = gdk_gc_predraw (drawable, gc_private, 0); - src_rgn = CreateRectRgn (0, 0, src_private->width + 1, src_private->height + 1); + gdk_drawable_get_size (src, &src_width, &src_height); + src_rgn = CreateRectRgn (0, 0, src_width + 1, src_height + 1); draw_rgn = CreateRectRgn (xsrc, ysrc, xsrc + width + 1, ysrc + height + 1); - SetRectEmpty (&r); - outside_rgn = CreateRectRgnIndirect (&r); - if (GDK_DRAWABLE_TYPE (drawable) != GDK_DRAWABLE_PIXMAP) + if (!GDK_IS_PIXMAP (drawable)) { /* If we are drawing on a window, calculate the region that is * outside the source pixmap, and invalidate that, causing it to * be cleared. XXX */ + SetRectEmpty (&r); + outside_rgn = CreateRectRgnIndirect (&r); if (CombineRgn (outside_rgn, draw_rgn, src_rgn, RGN_DIFF) != NULLREGION) { OffsetRgn (outside_rgn, xdest, ydest); @@ -635,8 +648,9 @@ gdk_win32_draw_drawable (GdkDrawable *drawable, "bbox: %dx%d@+%d+%d\n", r.right - r.left - 1, r.bottom - r.top - 1, r.left, r.top))); - InvalidateRgn (GDK_DRAWABLE_XID (drawable), outside_rgn, TRUE); + InvalidateRgn (GDK_DRAWABLE_HANDLE (drawable), outside_rgn, TRUE); } + DeleteObject (outside_rgn); } #if 1 /* Don't know if this is necessary */ @@ -665,68 +679,64 @@ gdk_win32_draw_drawable (GdkDrawable *drawable, DeleteObject (src_rgn); DeleteObject (draw_rgn); - DeleteObject (outside_rgn); - /* Strangely enough, this function is called also to bitblt - * from a window. + /* This function is called also to bitblt from a window. */ - if (src_private->window_type == GDK_DRAWABLE_PIXMAP) + if (GDK_IS_PIXMAP (src)) { if ((srcdc = CreateCompatibleDC (hdc)) == NULL) - WIN32_GDI_FAILED ("CreateCompatibleDC"); + WIN32_GDI_FAILED ("CreateCompatibleDC"), ok = FALSE; - if ((hgdiobj = SelectObject (srcdc, GDK_DRAWABLE_XID (src))) == NULL) - WIN32_GDI_FAILED ("SelectObject"); + if (ok && (hgdiobj = SelectObject (srcdc, GDK_PIXMAP_HBITMAP (src))) == NULL) + WIN32_GDI_FAILED ("SelectObject"), ok = FALSE; - if (!BitBlt (hdc, xdest, ydest, width, height, - srcdc, xsrc, ysrc, SRCCOPY)) + if (ok && !BitBlt (hdc, xdest, ydest, width, height, + srcdc, xsrc, ysrc, SRCCOPY)) WIN32_GDI_FAILED ("BitBlt"); - if ((SelectObject (srcdc, hgdiobj) == NULL)) + if (ok && (SelectObject (srcdc, hgdiobj) == NULL)) WIN32_GDI_FAILED ("SelectObject"); - if (!DeleteDC (srcdc)) + if (srcdc != NULL && !DeleteDC (srcdc)) WIN32_GDI_FAILED ("DeleteDC"); } + else if (GDK_DRAWABLE_HANDLE (drawable) == GDK_DRAWABLE_HANDLE (src)) + { + /* Blitting inside a window, use ScrollDC */ + RECT scrollRect, clipRect, emptyRect; + HRGN updateRgn; + + scrollRect.left = MIN (xsrc, xdest); + scrollRect.top = MIN (ysrc, ydest); + scrollRect.right = MAX (xsrc + width + 1, xdest + width + 1); + scrollRect.bottom = MAX (ysrc + height + 1, ydest + height + 1); + + clipRect.left = xdest; + clipRect.top = ydest; + clipRect.right = xdest + width + 1; + clipRect.bottom = ydest + height + 1; + + SetRectEmpty (&emptyRect); + updateRgn = CreateRectRgnIndirect (&emptyRect); + if (!ScrollDC (hdc, xdest - xsrc, ydest - ysrc, + &scrollRect, &clipRect, + updateRgn, NULL)) + WIN32_GDI_FAILED ("ScrollDC"), ok = FALSE; + if (ok && !InvalidateRgn (GDK_WINDOW_HWND (drawable), updateRgn, FALSE)) + WIN32_GDI_FAILED ("InvalidateRgn"), ok = FALSE; + if (ok && !UpdateWindow (GDK_WINDOW_HWND (drawable))) + WIN32_GDI_FAILED ("UpdateWindow"); + DeleteObject (updateRgn); + } else { - if (GDK_DRAWABLE_XID(drawable) == GDK_DRAWABLE_XID (src)) - { - /* Blitting inside a window, use ScrollDC */ - RECT scrollRect, clipRect, emptyRect; - HRGN updateRgn; - - scrollRect.left = MIN (xsrc, xdest); - scrollRect.top = MIN (ysrc, ydest); - scrollRect.right = MAX (xsrc + width + 1, xdest + width + 1); - scrollRect.bottom = MAX (ysrc + height + 1, ydest + height + 1); - - clipRect.left = xdest; - clipRect.top = ydest; - clipRect.right = xdest + width + 1; - clipRect.bottom = ydest + height + 1; - - SetRectEmpty (&emptyRect); - updateRgn = CreateRectRgnIndirect (&emptyRect); - if (!ScrollDC (hdc, xdest - xsrc, ydest - ysrc, - &scrollRect, &clipRect, - updateRgn, NULL)) - WIN32_GDI_FAILED ("ScrollDC"); - if (!InvalidateRgn (GDK_DRAWABLE_XID (drawable), updateRgn, FALSE)) - WIN32_GDI_FAILED ("InvalidateRgn"); - if (!UpdateWindow (GDK_DRAWABLE_XID (drawable))) - WIN32_GDI_FAILED ("UpdateWindow"); - } - else - { - if ((srcdc = GetDC (GDK_DRAWABLE_XID (src))) == NULL) - WIN32_GDI_FAILED ("GetDC"); - - if (!BitBlt (hdc, xdest, ydest, width, height, - srcdc, xsrc, ysrc, SRCCOPY)) - WIN32_GDI_FAILED ("BitBlt"); - ReleaseDC (GDK_DRAWABLE_XID (src), srcdc); - } + if ((srcdc = GetDC (GDK_WINDOW_HWND (src))) == NULL) + WIN32_GDI_FAILED ("GetDC"), ok = FALSE; + + if (ok && !BitBlt (hdc, xdest, ydest, width, height, + srcdc, xsrc, ysrc, SRCCOPY)) + WIN32_GDI_FAILED ("BitBlt"); + ReleaseDC (GDK_WINDOW_HWND (src), srcdc); } gdk_gc_postdraw (drawable, gc_private, 0); } @@ -739,16 +749,15 @@ gdk_win32_draw_points (GdkDrawable *drawable, { HDC hdc; COLORREF fg; - GdkGCPrivate *gc_private = (GdkGCPrivate*) gc; - GdkGCWin32Data *gc_data = GDK_GC_WIN32DATA (gc_private); - GdkDrawablePrivate *drawable_private = (GdkDrawablePrivate *) drawable; + GdkGCWin32 *gc_private = GDK_GC_WIN32 (gc); + GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable); GdkColormapPrivateWin32 *colormap_private = - (GdkColormapPrivateWin32 *) drawable_private->colormap; + (GdkColormapPrivateWin32 *) impl->colormap; int i; hdc = gdk_gc_predraw (drawable, gc_private, 0); - fg = gdk_colormap_color (colormap_private, gc_data->foreground); + fg = gdk_colormap_color (colormap_private, gc_private->foreground); GDK_NOTE (MISC, g_print ("gdk_draw_points: %#x %dx%.06x\n", GDK_DRAWABLE_XID (drawable), npoints, fg)); @@ -765,25 +774,24 @@ gdk_win32_draw_segments (GdkDrawable *drawable, GdkSegment *segs, gint nsegs) { - GdkGCPrivate *gc_private = (GdkGCPrivate*) gc; - GdkGCWin32Data *gc_data = GDK_GC_WIN32DATA (gc_private); + GdkGCWin32 *gc_private = GDK_GC_WIN32 (gc); + const GdkGCValuesMask mask = GDK_GC_FOREGROUND|GDK_GC_BACKGROUND; HDC hdc; HBRUSH hbr = NULL; gboolean ok = TRUE; int i; GDK_NOTE (MISC, g_print ("gdk_win32_draw_segments: %#x nsegs: %d\n", - GDK_DRAWABLE_XID (drawable), nsegs)); + GDK_DRAWABLE_HANDLE (drawable), nsegs)); - hdc = gdk_gc_predraw (drawable, gc_private, - GDK_GC_FOREGROUND|GDK_GC_BACKGROUND); + hdc = gdk_gc_predraw (drawable, gc_private, mask); - if (gc_data->fill_style == GDK_OPAQUE_STIPPLED) + if (gc_private->fill_style == GDK_OPAQUE_STIPPLED) { if (!BeginPath (hdc)) WIN32_GDI_FAILED ("BeginPath"), ok = FALSE; - for (i = 0; i < nsegs; i++) + for (i = 0; ok && i < nsegs; i++) { if (ok && !MoveToEx (hdc, segs[i].x1, segs[i].y1, NULL)) WIN32_GDI_FAILED ("MoveToEx"), ok = FALSE; @@ -791,7 +799,7 @@ gdk_win32_draw_segments (GdkDrawable *drawable, WIN32_GDI_FAILED ("LineTo"), ok = FALSE; /* Draw end pixel */ - if (ok && gc_data->pen_width <= 1) + if (ok && gc_private->pen_width <= 1) if (!LineTo (hdc, segs[i].x2 + 1, segs[i].y2)) WIN32_GDI_FAILED ("LineTo"), ok = FALSE; } @@ -811,20 +819,20 @@ gdk_win32_draw_segments (GdkDrawable *drawable, } else { - for (i = 0; i < nsegs; i++) + for (i = 0; ok && i < nsegs; i++) { if (!MoveToEx (hdc, segs[i].x1, segs[i].y1, NULL)) - WIN32_GDI_FAILED ("MoveToEx"); - if (!LineTo (hdc, segs[i].x2, segs[i].y2)) - WIN32_GDI_FAILED ("LineTo"); + WIN32_GDI_FAILED ("MoveToEx"), ok = FALSE; + if (ok && !LineTo (hdc, segs[i].x2, segs[i].y2)) + WIN32_GDI_FAILED ("LineTo"), ok = FALSE; /* Draw end pixel */ - if (gc_data->pen_width <= 1) + if (ok && gc_private->pen_width <= 1) if (!LineTo (hdc, segs[i].x2 + 1, segs[i].y2)) - WIN32_GDI_FAILED ("LineTo"); + WIN32_GDI_FAILED ("LineTo"), ok = FALSE; } } - gdk_gc_postdraw (drawable, gc_private, GDK_GC_FOREGROUND|GDK_GC_BACKGROUND); + gdk_gc_postdraw (drawable, gc_private, mask); } static void @@ -833,18 +841,18 @@ gdk_win32_draw_lines (GdkDrawable *drawable, GdkPoint *points, gint npoints) { - GdkGCPrivate *gc_private = (GdkGCPrivate*) gc; - GdkGCWin32Data *gc_data = GDK_GC_WIN32DATA (gc_private); + GdkGCWin32 *gc_private = GDK_GC_WIN32 (gc); + const GdkGCValuesMask mask = GDK_GC_FOREGROUND|GDK_GC_BACKGROUND; HDC hdc; POINT *pts; int i; + gboolean ok = TRUE; if (npoints < 2) return; - hdc = gdk_gc_predraw (drawable, gc_private, - GDK_GC_FOREGROUND|GDK_GC_BACKGROUND); -#if 1 + hdc = gdk_gc_predraw (drawable, gc_private, mask); + pts = g_new (POINT, npoints); for (i = 0; i < npoints; i++) @@ -854,31 +862,129 @@ gdk_win32_draw_lines (GdkDrawable *drawable, } if (!Polyline (hdc, pts, npoints)) - WIN32_GDI_FAILED ("Polyline"); + WIN32_GDI_FAILED ("Polyline"), ok = FALSE; g_free (pts); /* Draw end pixel */ - if (gc_data->pen_width <= 1) + if (ok && gc_private->pen_width <= 1) { MoveToEx (hdc, points[npoints-1].x, points[npoints-1].y, NULL); if (!LineTo (hdc, points[npoints-1].x + 1, points[npoints-1].y)) WIN32_GDI_FAILED ("LineTo"); } -#else - MoveToEx (hdc, points[0].x, points[0].y, NULL); - for (i = 1; i < npoints; i++) - if (!LineTo (hdc, points[i].x, points[i].y)) - WIN32_GDI_FAILED ("LineTo"); - - /* Draw end pixel */ - /* LineTo doesn't draw the last point, so if we have a pen width of 1, - * we draw the end pixel separately... With wider pens we don't care. - * //HB: But the NT developers don't read their API documentation ... - */ - if (gc_data->pen_width <= 1 && windows_version > 0x80000000) - if (!LineTo (hdc, points[npoints-1].x + 1, points[npoints-1].y)) - WIN32_GDI_FAILED ("LineTo"); -#endif - gdk_gc_postdraw (drawable, gc_private, GDK_GC_FOREGROUND|GDK_GC_BACKGROUND); + gdk_gc_postdraw (drawable, gc_private, mask); +} + +static void +gdk_win32_draw_glyphs (GdkDrawable *drawable, + GdkGC *gc, + PangoFont *font, + gint x, + gint y, + PangoGlyphString *glyphs) +{ + GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable); + GdkGCWin32 *gc_private = GDK_GC_WIN32 (gc); + const GdkGCValuesMask mask = GDK_GC_FOREGROUND; + HDC hdc; + + hdc = gdk_gc_predraw (drawable, gc_private, mask); + + pango_win32_render (hdc, font, glyphs, x, y); + + gdk_gc_postdraw (drawable, gc_private, mask); +} + +static void +gdk_win32_draw_image (GdkDrawable *drawable, + GdkGC *gc, + GdkImage *image, + gint xsrc, + gint ysrc, + gint xdest, + gint ydest, + gint width, + gint height) +{ + GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable); + GdkGCWin32 *gc_private = GDK_GC_WIN32 (gc); + GdkImagePrivateWin32 *image_private = (GdkImagePrivateWin32 *) image; + GdkColormapPrivateWin32 *colormap_private = (GdkColormapPrivateWin32 *) impl->colormap; + HDC hdc, memdc; + HGDIOBJ oldbitmap; + DIBSECTION ds; + static struct { + BITMAPINFOHEADER bmiHeader; + WORD bmiIndices[256]; + } bmi; + static gboolean bmi_inited = FALSE; + gboolean ok = TRUE; + int i; + + hdc = gdk_gc_predraw (drawable, gc_private, 0); + + if (colormap_private && colormap_private->xcolormap->rc_palette) + { + if (!bmi_inited) + { + for (i = 0; i < 256; i++) + bmi.bmiIndices[i] = i; + bmi_inited = TRUE; + } + + if (GetObject (image_private->hbitmap, sizeof (DIBSECTION), + &ds) != sizeof (DIBSECTION)) + WIN32_GDI_FAILED ("GetObject"), ok = FALSE; +#if 0 + g_print("xdest = %d, ydest = %d, xsrc = %d, ysrc = %d, width = %d, height = %d\n", + xdest, ydest, xsrc, ysrc, width, height); + g_print("bmWidth = %d, bmHeight = %d, bmBitsPixel = %d, bmBits = %p\n", + ds.dsBm.bmWidth, ds.dsBm.bmHeight, ds.dsBm.bmBitsPixel, ds.dsBm.bmBits); + g_print("biWidth = %d, biHeight = %d, biBitCount = %d, biClrUsed = %d\n", + ds.dsBmih.biWidth, ds.dsBmih.biHeight, ds.dsBmih.biBitCount, ds.dsBmih.biClrUsed); +#endif + bmi.bmiHeader = ds.dsBmih; + /* I have spent hours on getting the parameters to + * SetDIBitsToDevice right. I wonder what drugs the guys in + * Redmond were on when they designed this API. + */ + if (ok && SetDIBitsToDevice (hdc, + xdest, ydest, + width, height, + xsrc, (-ds.dsBmih.biHeight)-height-ysrc, + 0, -ds.dsBmih.biHeight, + ds.dsBm.bmBits, + (CONST BITMAPINFO *) &bmi, + DIB_PAL_COLORS) == 0) + WIN32_GDI_FAILED ("SetDIBitsToDevice"); + } + else + { + + if ((memdc = CreateCompatibleDC (hdc)) == NULL) + WIN32_GDI_FAILED ("CreateCompatibleDC"), ok = FALSE; + + if (ok && (oldbitmap = SelectObject (memdc, image_private->hbitmap)) == NULL) + WIN32_GDI_FAILED ("SelectObject"), ok = FALSE; + + if (ok && !BitBlt (hdc, xdest, ydest, width, height, + memdc, xsrc, ysrc, SRCCOPY)) + WIN32_GDI_FAILED ("BitBlt"); + + if (oldbitmap != NULL && SelectObject (memdc, oldbitmap) == NULL) + WIN32_GDI_FAILED ("SelectObject"); + + if (memdc != NULL && !DeleteDC (memdc)) + WIN32_GDI_FAILED ("DeleteDC"); + } + gdk_gc_postdraw (drawable, gc_private, 0); +} + +static gint +gdk_win32_get_depth (GdkDrawable *drawable) +{ + /* This is a bit bogus but I'm not sure the other way is better */ + + return gdk_drawable_get_depth (GDK_DRAWABLE_IMPL_WIN32 (drawable)->wrapper); } diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index 193f0cbb1d..7a8a6e4491 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -41,6 +41,9 @@ #include "gdk.h" #include "gdkinternals.h" #include "gdkprivate-win32.h" +#include "gdkdrawable-win32.h" +#include "gdkwindow-win32.h" +#include "gdkpixmap-win32.h" #include "gdkkeysyms.h" @@ -61,8 +64,6 @@ #define PING() printf("%s: %d\n",__FILE__,__LINE__),fflush(stdout) -#define WINDOW_PRIVATE(wp) GDK_WINDOW_WIN32DATA (wp) - typedef struct _GdkIOClosure GdkIOClosure; typedef struct _GdkEventPrivate GdkEventPrivate; @@ -93,11 +94,11 @@ struct _GdkEventPrivate */ static GdkFilterReturn - gdk_event_apply_filters(MSG *xevent, + gdk_event_apply_filters(MSG *msg, GdkEvent *event, GList *filters); static gboolean gdk_event_translate (GdkEvent *event, - MSG *xevent, + MSG *msg, gboolean *ret_val_flagp, gint *ret_valp); static gboolean gdk_event_prepare (gpointer source_data, @@ -111,9 +112,6 @@ static gboolean gdk_event_dispatch (gpointer source_data, GTimeVal *current_time, gpointer user_data); -static void gdk_synthesize_click (GdkEvent *event, - gint nclicks); - /* Private variable declarations */ @@ -132,8 +130,6 @@ static GdkEventMask p_grab_mask; static gboolean p_grab_owner_events, k_grab_owner_events; static HCURSOR p_grab_cursor; -static GList *client_filters; /* Filters for client messages */ - static GSourceFuncs event_funcs = { gdk_event_prepare, gdk_event_check, @@ -143,27 +139,27 @@ static GSourceFuncs event_funcs = { GPollFD event_poll_fd; -static GdkWindow *curWnd = NULL; +static GdkWindow *current_window = NULL; static HWND active = NULL; -static gint curX, curY; -static gdouble curXroot, curYroot; +static gint current_x, current_y; +static gdouble current_x_root, current_y_root; static UINT gdk_ping_msg; -static gboolean ignore_WM_CHAR = FALSE; -static gboolean is_AltGr_key = FALSE; +static gboolean ignore_wm_char = FALSE; +static gboolean is_altgr_key = FALSE; -static IActiveIMMApp *paimmapp = NULL; -static IActiveIMMMessagePumpOwner *paimmmpo = NULL; +static IActiveIMMApp *active_imm_app = NULL; +static IActiveIMMMessagePumpOwner *active_imm_msgpump_owner = NULL; typedef BOOL (WINAPI *PFN_TrackMouseEvent) (LPTRACKMOUSEEVENT); -static PFN_TrackMouseEvent p_TrackMouseEvent = NULL; +static PFN_TrackMouseEvent track_mouse_event = NULL; -static gboolean use_IME_COMPOSITION = FALSE; +static gboolean use_ime_composition = FALSE; LRESULT CALLBACK -gdk_WindowProc (HWND hWnd, - UINT message, - WPARAM wParam, - LPARAM lParam) +gdk_window_procedure (HWND hwnd, + UINT message, + WPARAM wparam, + LPARAM lparam) { GdkEventPrivate event; GdkEvent *eventp; @@ -173,13 +169,13 @@ gdk_WindowProc (HWND hWnd, gint ret_val; gboolean ret_val_flag; - GDK_NOTE (EVENTS, g_print ("gdk_WindowProc: %#x %s\n", - hWnd, gdk_win32_message_name (message))); + GDK_NOTE (EVENTS, g_print ("gdk_window_procedure: %#x %s\n", + hwnd, gdk_win32_message_name (message))); - msg.hwnd = hWnd; + msg.hwnd = hwnd; msg.message = message; - msg.wParam = wParam; - msg.lParam = lParam; + msg.wParam = wparam; + msg.lParam = lparam; msg.time = GetTickCount (); pos = GetMessagePos (); msg.pt.x = LOWORD (pos); @@ -274,9 +270,9 @@ gdk_WindowProc (HWND hWnd, return ret_val; else { - if (paimmapp == NULL - || (*paimmapp->lpVtbl->OnDefWindowProc) (paimmapp, hWnd, message, wParam, lParam, &lres) == S_FALSE) - return DefWindowProc (hWnd, message, wParam, lParam); + if (active_imm_app == NULL + || (*active_imm_app->lpVtbl->OnDefWindowProc) (active_imm_app, hwnd, message, wparam, lparam, &lres) == S_FALSE) + return DefWindowProc (hwnd, message, wparam, lparam); else return lres; } @@ -309,29 +305,29 @@ gdk_events_init (void) NULL, CLSCTX_ALL, &IID_IActiveIMMApp, - (LPVOID *) &paimmapp); + (LPVOID *) &active_imm_app); if (hres == S_OK) { GDK_NOTE (EVENTS, g_print ("IActiveIMMApp created %#x\n", - paimmapp)); - (*paimmapp->lpVtbl->Activate) (paimmapp, TRUE); + active_imm_app)); + (*active_imm_app->lpVtbl->Activate) (active_imm_app, TRUE); - hres = (*paimmapp->lpVtbl->QueryInterface) (paimmapp, &IID_IActiveIMMMessagePumpOwner, &paimmmpo); + hres = (*active_imm_app->lpVtbl->QueryInterface) (active_imm_app, &IID_IActiveIMMMessagePumpOwner, &active_imm_msgpump_owner); GDK_NOTE (EVENTS, g_print ("IActiveIMMMessagePumpOwner created %#x\n", - paimmmpo)); - (paimmmpo->lpVtbl->Start) (paimmmpo); + active_imm_msgpump_owner)); + (active_imm_msgpump_owner->lpVtbl->Start) (active_imm_msgpump_owner); } #ifdef USE_TRACKMOUSEEVENT user32 = GetModuleHandle ("user32.dll"); - if ((p_TrackMouseEvent = GetProcAddress (user32, "TrackMouseEvent")) == NULL) + if ((track_mouse_event = GetProcAddress (user32, "TrackMouseEvent")) == NULL) { if ((commctrl32 = LoadLibrary ("commctrl32.dll")) != NULL) - p_TrackMouseEvent = (PFN_TrackMouseEvent) + track_mouse_event = (PFN_TrackMouseEvent) GetProcAddress (commctrl32, "_TrackMouseEvent"); } - if (p_TrackMouseEvent != NULL) + if (track_mouse_event != NULL) GDK_NOTE (EVENTS, g_print ("Using TrackMouseEvent to detect leave events\n")); #endif if (IS_WIN_NT (windows_version) && (windows_version & 0xFF) == 5) @@ -341,7 +337,7 @@ gdk_events_init (void) * WM_IME_COMPOSITION with GCS_RESULTSTR instead, fetch the * Unicode char from the IME with ImmGetCompositionStringW(). */ - use_IME_COMPOSITION = TRUE; + use_ime_composition = TRUE; } } @@ -366,7 +362,8 @@ gdk_events_pending (void) { MSG msg; - return (gdk_event_queue_find_first() || PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)); + return (gdk_event_queue_find_first() || + PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)); } /* @@ -388,7 +385,7 @@ gdk_events_pending (void) GdkEvent* gdk_event_get_graphics_expose (GdkWindow *window) { - MSG xevent; + MSG msg; GdkEvent *event; g_return_val_if_fail (window != NULL, NULL); @@ -399,11 +396,11 @@ gdk_event_get_graphics_expose (GdkWindow *window) /* Some nasty bugs here, just return NULL for now. */ return NULL; #else - if (PeekMessage (&xevent, GDK_DRAWABLE_XID (window), WM_PAINT, WM_PAINT, PM_REMOVE)) + if (PeekMessage (&msg, GDK_WINDOW_HWND (window), WM_PAINT, WM_PAINT, PM_REMOVE)) { event = gdk_event_new (); - if (gdk_event_translate (event, &xevent, NULL, NULL)) + if (gdk_event_translate (event, &msg, NULL, NULL)) return event; else gdk_event_free (event); @@ -473,16 +470,15 @@ event_mask_string (GdkEventMask mask) */ GdkGrabStatus -gdk_pointer_grab (GdkWindow * window, - gboolean owner_events, - GdkEventMask event_mask, - GdkWindow * confine_to, - GdkCursor * cursor, - guint32 time) +gdk_pointer_grab (GdkWindow *window, + gboolean owner_events, + GdkEventMask event_mask, + GdkWindow *confine_to, + GdkCursor *cursor, + guint32 time) { - HWND xwindow; - HWND xconfine_to; - HCURSOR xcursor; + HWND hwnd_confined_to; + HCURSOR hcursor; GdkCursorPrivate *cursor_private; gint return_val; @@ -492,17 +488,15 @@ gdk_pointer_grab (GdkWindow * window, cursor_private = (GdkCursorPrivate*) cursor; - xwindow = GDK_DRAWABLE_XID (window); - if (!confine_to || GDK_DRAWABLE_DESTROYED (confine_to)) - xconfine_to = NULL; + hwnd_confined_to = NULL; else - xconfine_to = GDK_DRAWABLE_XID (confine_to); + hwnd_confined_to = GDK_WINDOW_HWND (confine_to); if (!cursor) - xcursor = NULL; + hcursor = NULL; else - xcursor = cursor_private->xcursor; + hcursor = cursor_private->hcursor; if (gdk_input_vtable.grab_pointer) return_val = gdk_input_vtable.grab_pointer (window, @@ -518,9 +512,9 @@ gdk_pointer_grab (GdkWindow * window, if (!GDK_DRAWABLE_DESTROYED (window)) { GDK_NOTE (EVENTS, g_print ("gdk_pointer_grab: %#x %s %#x %s\n", - xwindow, + GDK_WINDOW_HWND (window), (owner_events ? "TRUE" : "FALSE"), - xcursor, + hcursor, event_mask_string (event_mask))); p_grab_mask = event_mask; p_grab_owner_events = (owner_events != 0); @@ -529,7 +523,7 @@ gdk_pointer_grab (GdkWindow * window, #if 1 /* Menus don't work if we use mouse capture. Pity, because many other * things work better with mouse capture. */ - SetCapture (xwindow); + SetCapture (GDK_WINDOW_HWND (window)); #endif return_val = GDK_GRAB_SUCCESS; } @@ -540,7 +534,7 @@ gdk_pointer_grab (GdkWindow * window, if (return_val == GDK_GRAB_SUCCESS) { p_grab_window = window; - p_grab_cursor = xcursor; + p_grab_cursor = hcursor; } return return_val; @@ -617,9 +611,9 @@ gdk_pointer_is_grabbed (void) */ GdkGrabStatus -gdk_keyboard_grab (GdkWindow * window, - gboolean owner_events, - guint32 time) +gdk_keyboard_grab (GdkWindow *window, + gboolean owner_events, + guint32 time) { gint return_val; @@ -627,7 +621,7 @@ gdk_keyboard_grab (GdkWindow * window, g_return_val_if_fail (GDK_IS_WINDOW (window), 0); GDK_NOTE (EVENTS, g_print ("gdk_keyboard_grab %#x\n", - GDK_DRAWABLE_XID (window))); + GDK_WINDOW_HWND (window))); if (!GDK_DRAWABLE_DESTROYED (window)) { @@ -699,7 +693,7 @@ gdk_io_invoke (GIOChannel *source, } static GdkFilterReturn -gdk_event_apply_filters (MSG *xevent, +gdk_event_apply_filters (MSG *msg, GdkEvent *event, GList *filters) { @@ -713,7 +707,7 @@ gdk_event_apply_filters (MSG *xevent, { filter = (GdkEventFilter *) tmp_list->data; - result = (*filter->function) (xevent, event, filter->data); + result = (*filter->function) (msg, event, filter->data); if (result != GDK_FILTER_CONTINUE) return result; @@ -748,7 +742,7 @@ build_key_event_state (GdkEvent *event) event->key.state |= GDK_SHIFT_MASK; if (GetKeyState (VK_CAPITAL) & 0x1) event->key.state |= GDK_LOCK_MASK; - if (!is_AltGr_key) + if (!is_altgr_key) { if (GetKeyState (VK_CONTROL) < 0) { @@ -771,20 +765,20 @@ build_key_event_state (GdkEvent *event) } static gint -build_pointer_event_state (MSG *xevent) +build_pointer_event_state (MSG *msg) { gint state; state = 0; - if (xevent->wParam & MK_CONTROL) + if (msg->wParam & MK_CONTROL) state |= GDK_CONTROL_MASK; - if (xevent->wParam & MK_LBUTTON) + if (msg->wParam & MK_LBUTTON) state |= GDK_BUTTON1_MASK; - if (xevent->wParam & MK_MBUTTON) + if (msg->wParam & MK_MBUTTON) state |= GDK_BUTTON2_MASK; - if (xevent->wParam & MK_RBUTTON) + if (msg->wParam & MK_RBUTTON) state |= GDK_BUTTON3_MASK; - if (xevent->wParam & MK_SHIFT) + if (msg->wParam & MK_SHIFT) state |= GDK_SHIFT_MASK; if (GetKeyState (VK_MENU) < 0) state |= GDK_MOD1_MASK; @@ -795,50 +789,50 @@ build_pointer_event_state (MSG *xevent) } static void -build_keypress_event (GdkWindowWin32Data *windata, +build_keypress_event (GdkWindowImplWin32 *impl, GdkEvent *event, - MSG *xevent) + MSG *msg) { - HIMC hIMC; + HIMC himc; gint i, bytecount, ucount, ucleft, len; guchar buf[100], *bp; wchar_t wbuf[100], *wcp; event->key.type = GDK_KEY_PRESS; - event->key.time = xevent->time; + event->key.time = msg->time; event->key.state = 0; - if (xevent->message == WM_IME_COMPOSITION) + if (msg->message == WM_IME_COMPOSITION) { - hIMC = ImmGetContext (xevent->hwnd); + himc = ImmGetContext (msg->hwnd); - bytecount = ImmGetCompositionStringW (hIMC, GCS_RESULTSTR, + bytecount = ImmGetCompositionStringW (himc, GCS_RESULTSTR, wbuf, sizeof (wbuf)); ucount = bytecount / 2; } else { - if (xevent->message == WM_CHAR || xevent->message == WM_SYSCHAR) + if (msg->message == WM_CHAR || msg->message == WM_SYSCHAR) { - bytecount = MIN ((xevent->lParam & 0xFFFF), sizeof (buf)); + bytecount = MIN ((msg->lParam & 0xFFFF), sizeof (buf)); for (i = 0; i < bytecount; i++) - buf[i] = xevent->wParam; + buf[i] = msg->wParam; } else /* WM_IME_CHAR */ { event->key.keyval = GDK_VoidSymbol; - if (xevent->wParam & 0xFF00) + if (msg->wParam & 0xFF00) { /* Contrary to some versions of the documentation, * the lead byte is the most significant byte. */ - buf[0] = ((xevent->wParam >> 8) & 0xFF); - buf[1] = (xevent->wParam & 0xFF); + buf[0] = ((msg->wParam >> 8) & 0xFF); + buf[1] = (msg->wParam & 0xFF); bytecount = 2; } else { - buf[0] = (xevent->wParam & 0xFF); + buf[0] = (msg->wParam & 0xFF); bytecount = 1; } } @@ -847,17 +841,17 @@ build_keypress_event (GdkWindowWin32Data *windata, * to Unicode. Then convert to UTF-8. * We don't handle the surrogate stuff. Should we? */ - ucount = MultiByteToWideChar (windata->charset_info.ciACP, + ucount = MultiByteToWideChar (impl->charset_info.ciACP, 0, buf, bytecount, wbuf, sizeof (wbuf) / sizeof (wbuf[0])); } if (ucount == 0) event->key.keyval = GDK_VoidSymbol; - else if (xevent->message == WM_CHAR || xevent->message == WM_SYSCHAR) - if (xevent->wParam < ' ') + else if (msg->message == WM_CHAR || msg->message == WM_SYSCHAR) + if (msg->wParam < ' ') { - event->key.keyval = xevent->wParam + '@'; + event->key.keyval = msg->wParam + '@'; /* This is needed in case of Alt+nnn or Alt+0nnn (on the numpad) * where nnn<32 */ @@ -935,24 +929,24 @@ build_keypress_event (GdkWindowWin32Data *windata, } static void -build_keyrelease_event (GdkWindowWin32Data *windata, +build_keyrelease_event (GdkWindowImplWin32 *impl, GdkEvent *event, - MSG *xevent) + MSG *msg) { guchar buf; wchar_t wbuf; event->key.type = GDK_KEY_RELEASE; - event->key.time = xevent->time; + event->key.time = msg->time; event->key.state = 0; - if (xevent->message == WM_CHAR || xevent->message == WM_SYSCHAR) - if (xevent->wParam < ' ') - event->key.keyval = xevent->wParam + '@'; + if (msg->message == WM_CHAR || msg->message == WM_SYSCHAR) + if (msg->wParam < ' ') + event->key.keyval = msg->wParam + '@'; else { - buf = xevent->wParam; - MultiByteToWideChar (windata->charset_info.ciACP, + buf = msg->wParam; + MultiByteToWideChar (impl->charset_info.ciACP, 0, &buf, 1, &wbuf, 1); event->key.keyval = gdk_unicode_to_keyval (wbuf); @@ -1024,7 +1018,7 @@ print_event (GdkEvent *event) case GDK_NO_EXPOSE: g_print ("GDK_NO_EXPOSE "); break; case GDK_SCROLL: g_print ("GDK_SCROLL "); break; } - g_print ("%#x ", GDK_DRAWABLE_XID (event->any.window)); + g_print ("%#x ", GDK_WINDOW_HWND (event->any.window)); switch (event->any.type) { @@ -1088,33 +1082,33 @@ print_event (GdkEvent *event) static void synthesize_crossing_events (GdkWindow *window, - MSG *xevent) + MSG *msg) { GdkEvent *event; /* If we are not using TrackMouseEvent, generate a leave notify * event if necessary */ - if (p_TrackMouseEvent == NULL - && curWnd - && (GDK_WINDOW_WIN32DATA (curWnd)->event_mask & GDK_LEAVE_NOTIFY_MASK)) + if (track_mouse_event == NULL + && current_window + && (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (current_window)->impl)->event_mask & GDK_LEAVE_NOTIFY_MASK)) { GDK_NOTE (EVENTS, g_print ("synthesizing LEAVE_NOTIFY event\n")); event = gdk_event_new (); event->crossing.type = GDK_LEAVE_NOTIFY; - event->crossing.window = curWnd; + event->crossing.window = current_window; gdk_drawable_ref (event->crossing.window); event->crossing.subwindow = NULL; - event->crossing.time = xevent->time; - event->crossing.x = curX; - event->crossing.y = curY; - event->crossing.x_root = curXroot; - event->crossing.y_root = curYroot; + event->crossing.time = msg->time; + event->crossing.x = current_x; + event->crossing.y = current_y; + event->crossing.x_root = current_x_root; + event->crossing.y_root = current_y_root; event->crossing.mode = GDK_CROSSING_NORMAL; - if (IsChild (GDK_DRAWABLE_XID (curWnd), GDK_DRAWABLE_XID (window))) + if (IsChild (GDK_WINDOW_HWND (current_window), GDK_WINDOW_HWND (window))) event->crossing.detail = GDK_NOTIFY_INFERIOR; - else if (IsChild (GDK_DRAWABLE_XID (window), GDK_DRAWABLE_XID (curWnd))) + else if (IsChild (GDK_WINDOW_HWND (window), GDK_WINDOW_HWND (current_window))) event->crossing.detail = GDK_NOTIFY_ANCESTOR; else event->crossing.detail = GDK_NOTIFY_NONLINEAR; @@ -1126,7 +1120,7 @@ synthesize_crossing_events (GdkWindow *window, GDK_NOTE (EVENTS, print_event (event)); } - if (GDK_WINDOW_WIN32DATA (window)->event_mask & GDK_ENTER_NOTIFY_MASK) + if (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_ENTER_NOTIFY_MASK) { GDK_NOTE (EVENTS, g_print ("synthesizing ENTER_NOTIFY event\n")); @@ -1135,17 +1129,17 @@ synthesize_crossing_events (GdkWindow *window, event->crossing.window = window; gdk_drawable_ref (event->crossing.window); event->crossing.subwindow = NULL; - event->crossing.time = xevent->time; - event->crossing.x = LOWORD (xevent->lParam); - event->crossing.y = HIWORD (xevent->lParam); - event->crossing.x_root = (gfloat) xevent->pt.x; - event->crossing.y_root = (gfloat) xevent->pt.y; + event->crossing.time = msg->time; + event->crossing.x = LOWORD (msg->lParam); + event->crossing.y = HIWORD (msg->lParam); + event->crossing.x_root = (gfloat) msg->pt.x; + event->crossing.y_root = (gfloat) msg->pt.y; event->crossing.mode = GDK_CROSSING_NORMAL; - if (curWnd - && IsChild (GDK_DRAWABLE_XID (curWnd), GDK_DRAWABLE_XID (window))) + if (current_window + && IsChild (GDK_WINDOW_HWND (current_window), GDK_WINDOW_HWND (window))) event->crossing.detail = GDK_NOTIFY_ANCESTOR; - else if (curWnd - && IsChild (GDK_DRAWABLE_XID (window), GDK_DRAWABLE_XID (curWnd))) + else if (current_window + && IsChild (GDK_WINDOW_HWND (window), GDK_WINDOW_HWND (current_window))) event->crossing.detail = GDK_NOTIFY_INFERIOR; else event->crossing.detail = GDK_NOTIFY_NONLINEAR; @@ -1157,27 +1151,27 @@ synthesize_crossing_events (GdkWindow *window, GDK_NOTE (EVENTS, print_event (event)); - if (((GdkWindowPrivate *) window)->extension_events != 0 + if (GDK_WINDOW_OBJECT (window)->extension_events != 0 && gdk_input_vtable.enter_event) gdk_input_vtable.enter_event (&event->crossing, window); } - if (curWnd) - gdk_drawable_unref (curWnd); - curWnd = window; - gdk_drawable_ref (curWnd); + if (current_window) + gdk_drawable_unref (current_window); + current_window = window; + gdk_drawable_ref (current_window); #ifdef USE_TRACKMOUSEEVENT - if (p_TrackMouseEvent != NULL) + if (track_mouse_event != NULL) { TRACKMOUSEEVENT tme; tme.cbSize = sizeof (TRACKMOUSEEVENT); tme.dwFlags = TME_LEAVE; - tme.hwndTrack = GDK_DRAWABLE_XID (curWnd); + tme.hwndTrack = GDK_WINDOW_HWND (current_window); tme.dwHoverTime = HOVER_DEFAULT; - (*p_TrackMouseEvent) (&tme); + (*track_mouse_event) (&tme); } #endif } @@ -1185,32 +1179,32 @@ synthesize_crossing_events (GdkWindow *window, static void translate_mouse_coords (GdkWindow *window1, GdkWindow *window2, - MSG *xevent) + MSG *msg) { POINT pt; - pt.x = LOWORD (xevent->lParam); - pt.y = HIWORD (xevent->lParam); - ClientToScreen (GDK_DRAWABLE_XID (window1), &pt); - ScreenToClient (GDK_DRAWABLE_XID (window2), &pt); - xevent->lParam = MAKELPARAM (pt.x, pt.y); + pt.x = LOWORD (msg->lParam); + pt.y = HIWORD (msg->lParam); + ClientToScreen (GDK_WINDOW_HWND (window1), &pt); + ScreenToClient (GDK_WINDOW_HWND (window2), &pt); + msg->lParam = MAKELPARAM (pt.x, pt.y); GDK_NOTE (EVENTS, g_print ("...new coords are (%d,%d)\n", pt.x, pt.y)); } static gboolean propagate (GdkWindow **window, - MSG *xevent, + MSG *msg, GdkWindow *grab_window, gboolean grab_owner_events, gint grab_mask, gboolean (*doesnt_want_it) (gint mask, - MSG *xevent)) + MSG *msg)) { if (grab_window != NULL && !grab_owner_events) { /* Event source is grabbed with owner_events FALSE */ GDK_NOTE (EVENTS, g_print ("...grabbed, owner_events FALSE, ")); - if ((*doesnt_want_it) (grab_mask, xevent)) + if ((*doesnt_want_it) (grab_mask, msg)) { GDK_NOTE (EVENTS, g_print ("...grabber doesn't want it\n")); return FALSE; @@ -1218,7 +1212,7 @@ propagate (GdkWindow **window, else { GDK_NOTE (EVENTS, g_print ("...sending to grabber %#x\n", - GDK_DRAWABLE_XID (grab_window))); + GDK_WINDOW_HWND (grab_window))); gdk_drawable_unref (*window); *window = grab_window; gdk_drawable_ref (*window); @@ -1227,17 +1221,17 @@ propagate (GdkWindow **window, } while (TRUE) { - if ((*doesnt_want_it) (GDK_WINDOW_WIN32DATA (*window)->event_mask, xevent)) + if ((*doesnt_want_it) (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (*window)->impl)->event_mask, msg)) { /* Owner doesn't want it, propagate to parent. */ - if (((GdkWindowPrivate *) *window)->parent == gdk_parent_root) + if (GDK_WINDOW (GDK_WINDOW_OBJECT (window)->parent) == gdk_parent_root) { /* No parent; check if grabbed */ if (grab_window != NULL) { /* Event source is grabbed with owner_events TRUE */ GDK_NOTE (EVENTS, g_print ("...undelivered, but grabbed\n")); - if ((*doesnt_want_it) (grab_mask, xevent)) + if ((*doesnt_want_it) (grab_mask, msg)) { /* Grabber doesn't want it either */ GDK_NOTE (EVENTS, g_print ("...grabber doesn't want it\n")); @@ -1247,7 +1241,7 @@ propagate (GdkWindow **window, { /* Grabbed! */ GDK_NOTE (EVENTS, g_print ("...sending to grabber %#x\n", - GDK_DRAWABLE_XID (grab_window))); + GDK_WINDOW_HWND (grab_window))); gdk_drawable_unref (*window); *window = grab_window; gdk_drawable_ref (*window); @@ -1263,10 +1257,10 @@ propagate (GdkWindow **window, else { gdk_drawable_unref (*window); - *window = ((GdkWindowPrivate *) *window)->parent; + *window = GDK_WINDOW (GDK_WINDOW_OBJECT (*window)->parent); gdk_drawable_ref (*window); GDK_NOTE (EVENTS, g_print ("...propagating to %#x\n", - GDK_DRAWABLE_XID (*window))); + GDK_WINDOW_HWND (*window))); /* The only branch where we actually continue the loop */ } } @@ -1277,54 +1271,54 @@ propagate (GdkWindow **window, static gboolean doesnt_want_key (gint mask, - MSG *xevent) + MSG *msg) { - return (((xevent->message == WM_KEYUP || xevent->message == WM_SYSKEYUP) + return (((msg->message == WM_KEYUP || msg->message == WM_SYSKEYUP) && !(mask & GDK_KEY_RELEASE_MASK)) || - ((xevent->message == WM_KEYDOWN || xevent->message == WM_SYSKEYDOWN) + ((msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN) && !(mask & GDK_KEY_PRESS_MASK))); } static gboolean doesnt_want_char (gint mask, - MSG *xevent) + MSG *msg) { return !(mask & (GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK)); } static gboolean doesnt_want_button_press (gint mask, - MSG *xevent) + MSG *msg) { return !(mask & GDK_BUTTON_PRESS_MASK); } static gboolean doesnt_want_button_release (gint mask, - MSG *xevent) + MSG *msg) { return !(mask & GDK_BUTTON_RELEASE_MASK); } static gboolean doesnt_want_button_motion (gint mask, - MSG *xevent) + MSG *msg) { return !((mask & GDK_POINTER_MOTION_MASK) - || ((xevent->wParam & (MK_LBUTTON|MK_MBUTTON|MK_RBUTTON)) + || ((msg->wParam & (MK_LBUTTON|MK_MBUTTON|MK_RBUTTON)) && (mask & GDK_BUTTON_MOTION_MASK)) - || ((xevent->wParam & MK_LBUTTON) + || ((msg->wParam & MK_LBUTTON) && (mask & GDK_BUTTON1_MOTION_MASK)) - || ((xevent->wParam & MK_MBUTTON) + || ((msg->wParam & MK_MBUTTON) && (mask & GDK_BUTTON2_MOTION_MASK)) - || ((xevent->wParam & MK_RBUTTON) + || ((msg->wParam & MK_RBUTTON) && (mask & GDK_BUTTON3_MOTION_MASK))); } static gboolean doesnt_want_scroll (gint mask, - MSG *xevent) + MSG *msg) { #if 0 return !(mask & GDK_SCROLL_MASK); @@ -1354,7 +1348,7 @@ decode_key_lparam (LPARAM lParam) static gboolean gdk_event_translate (GdkEvent *event, - MSG *xevent, + MSG *msg, gboolean *ret_val_flagp, gint *ret_valp) { @@ -1369,14 +1363,14 @@ gdk_event_translate (GdkEvent *event, COLORREF bg; RECT rect; POINT pt; - MINMAXINFO *lpmmi; + MINMAXINFO *mmi; HWND hwnd; - HCURSOR xcursor; + HCURSOR hcursor; GdkWindow *window, *orig_window, *newwindow; GdkColormapPrivateWin32 *colormap_private; GdkEventMask mask; GdkPixmap *pixmap; - GdkDrawablePrivate *pixmap_private; + GdkPixmapImplWin32 *pixmap_impl; int button; int i, j, n, k; gchar buf[256]; @@ -1389,7 +1383,7 @@ gdk_event_translate (GdkEvent *event, if (ret_val_flagp) *ret_val_flagp = FALSE; - window = gdk_window_lookup (xevent->hwnd); + window = gdk_window_lookup (msg->hwnd); orig_window = window; event->any.window = window; @@ -1400,13 +1394,13 @@ gdk_event_translate (GdkEvent *event, else { /* Handle WM_QUIT here ? */ - if (xevent->message == WM_QUIT) + if (msg->message == WM_QUIT) { - GDK_NOTE (EVENTS, g_print ("WM_QUIT: %d\n", xevent->wParam)); - exit (xevent->wParam); + GDK_NOTE (EVENTS, g_print ("WM_QUIT: %d\n", msg->wParam)); + exit (msg->wParam); } - else if (xevent->message == WM_MOVE - || xevent->message == WM_SIZE) + else if (msg->message == WM_MOVE + || msg->message == WM_SIZE) { /* It's quite normal to get these messages before we have * had time to register the window in our lookup table, or @@ -1415,12 +1409,12 @@ gdk_event_translate (GdkEvent *event, * we will get it later when we are prepared. */ GDK_NOTE(MISC, g_print("gdk_event_translate: %#x %s posted.\n", - xevent->hwnd, - xevent->message == WM_MOVE ? + msg->hwnd, + msg->message == WM_MOVE ? "WM_MOVE" : "WM_SIZE")); - PostMessage (xevent->hwnd, xevent->message, - xevent->wParam, xevent->lParam); + PostMessage (msg->hwnd, msg->message, + msg->wParam, msg->lParam); } return FALSE; } @@ -1431,7 +1425,7 @@ gdk_event_translate (GdkEvent *event, GdkFilterReturn result; result = gdk_event_apply_filters - (xevent, event, ((GdkWindowPrivate *) window)->filters); + (msg, event, GDK_WINDOW_OBJECT (window)->filters); if (result != GDK_FILTER_CONTINUE) { @@ -1440,48 +1434,48 @@ gdk_event_translate (GdkEvent *event, } } - if (xevent->message == gdk_selection_notify_msg) + if (msg->message == gdk_selection_notify_msg) { GDK_NOTE (EVENTS, g_print ("gdk_selection_notify_msg: %#x\n", - xevent->hwnd)); + msg->hwnd)); event->selection.type = GDK_SELECTION_NOTIFY; event->selection.window = window; - event->selection.selection = xevent->wParam; - event->selection.target = xevent->lParam; + event->selection.selection = msg->wParam; + event->selection.target = msg->lParam; event->selection.property = gdk_selection_property; - event->selection.time = xevent->time; + event->selection.time = msg->time; return_val = !GDK_DRAWABLE_DESTROYED (window); /* Will pass through switch below without match */ } - else if (xevent->message == gdk_selection_request_msg) + else if (msg->message == gdk_selection_request_msg) { GDK_NOTE (EVENTS, g_print ("gdk_selection_request_msg: %#x\n", - xevent->hwnd)); + msg->hwnd)); event->selection.type = GDK_SELECTION_REQUEST; event->selection.window = window; event->selection.selection = gdk_clipboard_atom; event->selection.target = GDK_TARGET_STRING; event->selection.property = gdk_selection_property; - event->selection.requestor = (guint32) xevent->hwnd; - event->selection.time = xevent->time; + event->selection.requestor = (guint32) msg->hwnd; + event->selection.time = msg->time; return_val = !GDK_DRAWABLE_DESTROYED (window); /* Again, will pass through switch below without match */ } - else if (xevent->message == gdk_selection_clear_msg) + else if (msg->message == gdk_selection_clear_msg) { GDK_NOTE (EVENTS, g_print ("gdk_selection_clear_msg: %#x\n", - xevent->hwnd)); + msg->hwnd)); event->selection.type = GDK_SELECTION_CLEAR; event->selection.window = window; - event->selection.selection = xevent->wParam; - event->selection.time = xevent->time; + event->selection.selection = msg->wParam; + event->selection.time = msg->time; return_val = !GDK_DRAWABLE_DESTROYED (window); @@ -1496,11 +1490,11 @@ gdk_event_translate (GdkEvent *event, while (tmp_list) { GdkClientFilter *filter = tmp_list->data; - if (filter->type == xevent->message) + if (filter->type == msg->message) { GDK_NOTE (EVENTS, g_print ("client filter matched\n")); event->any.window = window; - result = (*filter->function) (xevent, event, filter->data); + result = (*filter->function) (msg, event, filter->data); switch (result) { case GDK_FILTER_REMOVE: @@ -1515,10 +1509,10 @@ gdk_event_translate (GdkEvent *event, return_val = TRUE; event->client.type = GDK_CLIENT_EVENT; event->client.window = window; - event->client.message_type = xevent->message; + event->client.message_type = msg->message; event->client.data_format = 0; - event->client.data.l[0] = xevent->wParam; - event->client.data.l[1] = xevent->lParam; + event->client.data.l[0] = msg->wParam; + event->client.data.l[1] = msg->lParam; break; } goto done; @@ -1527,15 +1521,15 @@ gdk_event_translate (GdkEvent *event, } } - switch (xevent->message) + switch (msg->message) { case WM_INPUTLANGCHANGE: GDK_NOTE (EVENTS, g_print ("WM_INPUTLANGCHANGE: %#x charset %d locale %x\n", - xevent->hwnd, xevent->wParam, xevent->lParam)); - GDK_WINDOW_WIN32DATA (window)->input_locale = (HKL) xevent->lParam; - TranslateCharsetInfo ((DWORD FAR *) xevent->wParam, - &GDK_WINDOW_WIN32DATA (window)->charset_info, + msg->hwnd, msg->wParam, msg->lParam)); + GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->input_locale = (HKL) msg->lParam; + TranslateCharsetInfo ((DWORD FAR *) msg->wParam, + &GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->charset_info, TCI_SRCCHARSET); break; @@ -1543,25 +1537,25 @@ gdk_event_translate (GdkEvent *event, case WM_SYSKEYDOWN: GDK_NOTE (EVENTS, g_print ("WM_SYSKEY%s: %#x %s %#x %s\n", - (xevent->message == WM_SYSKEYUP ? "UP" : "DOWN"), - xevent->hwnd, - (GetKeyNameText (xevent->lParam, buf, + (msg->message == WM_SYSKEYUP ? "UP" : "DOWN"), + msg->hwnd, + (GetKeyNameText (msg->lParam, buf, sizeof (buf)) > 0 ? buf : ""), - xevent->wParam, - decode_key_lparam (xevent->lParam))); + msg->wParam, + decode_key_lparam (msg->lParam))); /* Let the system handle Alt-Tab and Alt-Enter */ - if (xevent->wParam == VK_TAB - || xevent->wParam == VK_RETURN - || xevent->wParam == VK_F4) + if (msg->wParam == VK_TAB + || msg->wParam == VK_RETURN + || msg->wParam == VK_F4) break; /* If posted without us having keyboard focus, ignore */ - if (!(xevent->lParam & 0x20000000)) + if (!(msg->lParam & 0x20000000)) break; #if 0 /* don't generate events for just the Alt key */ - if (xevent->wParam == VK_MENU) + if (msg->wParam == VK_MENU) break; #endif /* Jump to code in common with WM_KEYUP and WM_KEYDOWN */ @@ -1571,20 +1565,20 @@ gdk_event_translate (GdkEvent *event, case WM_KEYDOWN: GDK_NOTE (EVENTS, g_print ("WM_KEY%s: %#x %s %#x %s\n", - (xevent->message == WM_KEYUP ? "UP" : "DOWN"), - xevent->hwnd, - (GetKeyNameText (xevent->lParam, buf, + (msg->message == WM_KEYUP ? "UP" : "DOWN"), + msg->hwnd, + (GetKeyNameText (msg->lParam, buf, sizeof (buf)) > 0 ? buf : ""), - xevent->wParam, - decode_key_lparam (xevent->lParam))); + msg->wParam, + decode_key_lparam (msg->lParam))); - ignore_WM_CHAR = TRUE; + ignore_wm_char = TRUE; keyup_or_down: event->key.window = window; - switch (xevent->wParam) + switch (msg->wParam) { case VK_LBUTTON: event->key.keyval = GDK_Pointer_Button1; break; @@ -1606,34 +1600,34 @@ gdk_event_translate (GdkEvent *event, event->key.keyval = GDK_Return; break; case VK_SHIFT: /* Don't let Shift auto-repeat */ - if (xevent->message == WM_KEYDOWN - && (HIWORD (xevent->lParam) & KF_REPEAT)) - ignore_WM_CHAR = FALSE; + if (msg->message == WM_KEYDOWN + && (HIWORD (msg->lParam) & KF_REPEAT)) + ignore_wm_char = FALSE; else event->key.keyval = GDK_Shift_L; break; case VK_CONTROL: /* And not Control either */ - if (xevent->message == WM_KEYDOWN - && (HIWORD (xevent->lParam) & KF_REPEAT)) - ignore_WM_CHAR = FALSE; - else if (HIWORD (xevent->lParam) & KF_EXTENDED) + if (msg->message == WM_KEYDOWN + && (HIWORD (msg->lParam) & KF_REPEAT)) + ignore_wm_char = FALSE; + else if (HIWORD (msg->lParam) & KF_EXTENDED) event->key.keyval = GDK_Control_R; else event->key.keyval = GDK_Control_L; break; case VK_MENU: /* And not Alt */ - if (xevent->message == WM_KEYDOWN - && (HIWORD (xevent->lParam) & KF_REPEAT)) - ignore_WM_CHAR = FALSE; - else if (HIWORD (xevent->lParam) & KF_EXTENDED) + if (msg->message == WM_KEYDOWN + && (HIWORD (msg->lParam) & KF_REPEAT)) + ignore_wm_char = FALSE; + else if (HIWORD (msg->lParam) & KF_EXTENDED) { /* AltGr key comes in as Control+Right Alt */ if (GetKeyState (VK_CONTROL) < 0) { - ignore_WM_CHAR = FALSE; - is_AltGr_key = TRUE; + ignore_wm_char = FALSE; + is_altgr_key = TRUE; } event->key.keyval = GDK_Alt_R; } @@ -1641,7 +1635,7 @@ gdk_event_translate (GdkEvent *event, { event->key.keyval = GDK_Alt_L; /* This needed in case she types Alt+nnn (on the numpad) */ - ignore_WM_CHAR = FALSE; + ignore_wm_char = FALSE; } break; case VK_PAUSE: @@ -1691,26 +1685,26 @@ gdk_event_translate (GdkEvent *event, /* Apparently applications work better if we just pass numpad digits * on as real digits? So wait for the WM_CHAR instead. */ - ignore_WM_CHAR = FALSE; + ignore_wm_char = FALSE; break; case VK_MULTIPLY: event->key.keyval = GDK_KP_Multiply; break; case VK_ADD: /* Pass it on as an ASCII plus in WM_CHAR. */ - ignore_WM_CHAR = FALSE; + ignore_wm_char = FALSE; break; case VK_SEPARATOR: event->key.keyval = GDK_KP_Separator; break; case VK_SUBTRACT: /* Pass it on as an ASCII minus in WM_CHAR. */ - ignore_WM_CHAR = FALSE; + ignore_wm_char = FALSE; break; case VK_DECIMAL: /* The keypad decimal key should also be passed on as the decimal * sign ('.' or ',' depending on the Windows locale settings, * apparently). So wait for the WM_CHAR here, also. */ - ignore_WM_CHAR = FALSE; + ignore_wm_char = FALSE; break; case VK_DIVIDE: event->key.keyval = GDK_KP_Divide; break; @@ -1756,20 +1750,20 @@ gdk_event_translate (GdkEvent *event, case '7': case '8': case '9': - if (!is_AltGr_key && (GetKeyState (VK_CONTROL) < 0 + if (!is_altgr_key && (GetKeyState (VK_CONTROL) < 0 || GetKeyState (VK_MENU) < 0)) /* Control- or Alt-digits won't come in as a WM_CHAR, * but beware of AltGr-digits, which are used for instance * on Finnish keyboards. */ - event->key.keyval = GDK_0 + (xevent->wParam - '0'); + event->key.keyval = GDK_0 + (msg->wParam - '0'); else - ignore_WM_CHAR = FALSE; + ignore_wm_char = FALSE; break; case VK_OEM_PLUS: /* On my Win98, the '+' key comes in * as VK_OEM_PLUS */ - if (!is_AltGr_key && (GetKeyState (VK_CONTROL) < 0 + if (!is_altgr_key && (GetKeyState (VK_CONTROL) < 0 || GetKeyState (VK_MENU) < 0)) /* Control- or Alt-plus won't come in as WM_CHAR, * but beware of AltGr-plus which is backslash on @@ -1777,29 +1771,29 @@ gdk_event_translate (GdkEvent *event, */ event->key.keyval = '+'; else - ignore_WM_CHAR = FALSE; + ignore_wm_char = FALSE; break; default: - if (xevent->message == WM_SYSKEYDOWN || xevent->message == WM_SYSKEYUP) - event->key.keyval = xevent->wParam; + if (msg->message == WM_SYSKEYDOWN || msg->message == WM_SYSKEYUP) + event->key.keyval = msg->wParam; else - ignore_WM_CHAR = FALSE; + ignore_wm_char = FALSE; break; } - if (!ignore_WM_CHAR) + if (!ignore_wm_char) break; - if (!propagate (&window, xevent, + if (!propagate (&window, msg, k_grab_window, k_grab_owner_events, GDK_ALL_EVENTS_MASK, doesnt_want_key)) break; - is_AltGr_key = FALSE; - event->key.type = ((xevent->message == WM_KEYDOWN - || xevent->message == WM_SYSKEYDOWN) ? + is_altgr_key = FALSE; + event->key.type = ((msg->message == WM_KEYDOWN + || msg->message == WM_SYSKEYDOWN) ? GDK_KEY_PRESS : GDK_KEY_RELEASE); - event->key.time = xevent->time; + event->key.time = msg->time; event->key.state = 0; if (GetKeyState (VK_SHIFT) < 0) event->key.state |= GDK_SHIFT_MASK; @@ -1807,7 +1801,7 @@ gdk_event_translate (GdkEvent *event, event->key.state |= GDK_LOCK_MASK; if (GetKeyState (VK_CONTROL) < 0) event->key.state |= GDK_CONTROL_MASK; - if (xevent->wParam != VK_MENU && GetKeyState (VK_MENU) < 0) + if (msg->wParam != VK_MENU && GetKeyState (VK_MENU) < 0) event->key.state |= GDK_MOD1_MASK; event->key.string = NULL; event->key.length = 0; @@ -1815,67 +1809,68 @@ gdk_event_translate (GdkEvent *event, break; case WM_IME_COMPOSITION: - if (!use_IME_COMPOSITION) + if (!use_ime_composition) break; + GDK_NOTE (EVENTS, g_print ("WM_IME_COMPOSITION: %#x %#x\n", - xevent->hwnd, xevent->lParam)); - if (xevent->lParam & GCS_RESULTSTR) + msg->hwnd, msg->lParam)); + if (msg->lParam & GCS_RESULTSTR) goto wm_char; break; case WM_IME_CHAR: GDK_NOTE (EVENTS, g_print ("WM_IME_CHAR: %#x bytes: %#.04x\n", - xevent->hwnd, xevent->wParam)); + msg->hwnd, msg->wParam)); goto wm_char; case WM_CHAR: case WM_SYSCHAR: GDK_NOTE (EVENTS, g_print ("WM_%sCHAR: %#x %#x %#s %s\n", - (xevent->message == WM_CHAR ? "" : "SYS"), - xevent->hwnd, xevent->wParam, - decode_key_lparam (xevent->lParam), - (ignore_WM_CHAR ? "ignored" : ""))); + (msg->message == WM_CHAR ? "" : "SYS"), + msg->hwnd, msg->wParam, + decode_key_lparam (msg->lParam), + (ignore_wm_char ? "ignored" : ""))); - if (ignore_WM_CHAR) + if (ignore_wm_char) { - ignore_WM_CHAR = FALSE; + ignore_wm_char = FALSE; break; } wm_char: - if (!propagate (&window, xevent, + if (!propagate (&window, msg, k_grab_window, k_grab_owner_events, GDK_ALL_EVENTS_MASK, doesnt_want_char)) break; event->key.window = window; return_val = !GDK_DRAWABLE_DESTROYED (window); if (return_val && (event->key.window == k_grab_window - || (GDK_WINDOW_WIN32DATA (window)->event_mask & GDK_KEY_RELEASE_MASK))) + || (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_KEY_RELEASE_MASK))) { if (window == k_grab_window - || (GDK_WINDOW_WIN32DATA (window)->event_mask & GDK_KEY_PRESS_MASK)) + || (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_KEY_PRESS_MASK)) { /* Append a GDK_KEY_PRESS event to the pushback list * (from which it will be fetched before the release * event). */ GdkEvent *event2 = gdk_event_new (); - build_keypress_event (GDK_WINDOW_WIN32DATA (window), event2, xevent); + build_keypress_event (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl), event2, msg); event2->key.window = window; gdk_drawable_ref (window); gdk_event_queue_append (event2); GDK_NOTE (EVENTS, print_event (event2)); } /* Return the key release event. */ - build_keyrelease_event (GDK_WINDOW_WIN32DATA (window), event, xevent); + build_keyrelease_event (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl), event, msg); } else if (return_val - && (GDK_WINDOW_WIN32DATA (window)->event_mask & GDK_KEY_PRESS_MASK)) + && (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_KEY_PRESS_MASK)) { /* Return just the key press event. */ - build_keypress_event (GDK_WINDOW_WIN32DATA (window), event, xevent); + build_keypress_event (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl), event, msg); } else return_val = FALSE; @@ -1901,21 +1896,21 @@ gdk_event_translate (GdkEvent *event, GDK_NOTE (EVENTS, g_print ("WM_%cBUTTONDOWN: %#x (%d,%d)\n", " LMR"[button], - xevent->hwnd, - LOWORD (xevent->lParam), HIWORD (xevent->lParam))); + msg->hwnd, + LOWORD (msg->lParam), HIWORD (msg->lParam))); - if (((GdkWindowPrivate *) window)->extension_events != 0 + if (GDK_WINDOW_OBJECT (window)->extension_events != 0 && gdk_input_ignore_core) { GDK_NOTE (EVENTS, g_print ("...ignored\n")); break; } - if (window != curWnd) - synthesize_crossing_events (window, xevent); + if (window != current_window) + synthesize_crossing_events (window, msg); event->button.type = GDK_BUTTON_PRESS; - if (!propagate (&window, xevent, + if (!propagate (&window, msg, p_grab_window, p_grab_owner_events, p_grab_mask, doesnt_want_button_press)) break; @@ -1925,31 +1920,28 @@ gdk_event_translate (GdkEvent *event, { /* No explicit active grab, let's start one automatically */ gint owner_events = - GDK_WINDOW_WIN32DATA (window)->event_mask + GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & (GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK); GDK_NOTE (EVENTS, g_print ("...automatic grab started\n")); gdk_pointer_grab (window, owner_events, - GDK_WINDOW_WIN32DATA (window)->event_mask, + GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask, NULL, NULL, 0); p_grab_automatic = TRUE; } - event->button.time = xevent->time; + event->button.time = msg->time; if (window != orig_window) - translate_mouse_coords (orig_window, window, xevent); - event->button.x = curX = (gint16) LOWORD (xevent->lParam); - event->button.y = curY = (gint16) HIWORD (xevent->lParam); - event->button.x_root = xevent->pt.x; - event->button.y_root = xevent->pt.y; - event->button.pressure = 0.5; - event->button.xtilt = 0; - event->button.ytilt = 0; - event->button.state = build_pointer_event_state (xevent); + translate_mouse_coords (orig_window, window, msg); + event->button.x = current_x = (gint16) LOWORD (msg->lParam); + event->button.y = current_y = (gint16) HIWORD (msg->lParam); + event->button.x_root = msg->pt.x; + event->button.y_root = msg->pt.y; + event->button.axes = NULL; + event->button.state = build_pointer_event_state (msg); event->button.button = button; - event->button.source = GDK_SOURCE_MOUSE; - event->button.deviceid = GDK_CORE_POINTER; + event->button.device = gdk_core_pointer; gdk_event_button_generate (event); @@ -1969,39 +1961,36 @@ gdk_event_translate (GdkEvent *event, GDK_NOTE (EVENTS, g_print ("WM_%cBUTTONUP: %#x (%d,%d)\n", " LMR"[button], - xevent->hwnd, - LOWORD (xevent->lParam), HIWORD (xevent->lParam))); + msg->hwnd, + LOWORD (msg->lParam), HIWORD (msg->lParam))); - if (((GdkWindowPrivate *) window)->extension_events != 0 + if (GDK_WINDOW_OBJECT (window)->extension_events != 0 && gdk_input_ignore_core) { GDK_NOTE (EVENTS, g_print ("...ignored\n")); break; } - if (window != curWnd) - synthesize_crossing_events (window, xevent); + if (window != current_window) + synthesize_crossing_events (window, msg); event->button.type = GDK_BUTTON_RELEASE; - if (!propagate (&window, xevent, + if (!propagate (&window, msg, p_grab_window, p_grab_owner_events, p_grab_mask, doesnt_want_button_release)) goto maybe_ungrab; event->button.window = window; - event->button.time = xevent->time; + event->button.time = msg->time; if (window != orig_window) - translate_mouse_coords (orig_window, window, xevent); - event->button.x = (gint16) LOWORD (xevent->lParam); - event->button.y = (gint16) HIWORD (xevent->lParam); - event->button.x_root = xevent->pt.x; - event->button.y_root = xevent->pt.y; - event->button.pressure = 0.5; - event->button.xtilt = 0; - event->button.ytilt = 0; - event->button.state = build_pointer_event_state (xevent); + translate_mouse_coords (orig_window, window, msg); + event->button.x = (gint16) LOWORD (msg->lParam); + event->button.y = (gint16) HIWORD (msg->lParam); + event->button.x_root = msg->pt.x; + event->button.y_root = msg->pt.y; + event->button.axes = NULL; + event->button.state = build_pointer_event_state (msg); event->button.button = button; - event->button.source = GDK_SOURCE_MOUSE; - event->button.deviceid = GDK_CORE_POINTER; + event->button.device = gdk_core_pointer; return_val = !GDK_DRAWABLE_DESTROYED (window); @@ -2015,28 +2004,28 @@ gdk_event_translate (GdkEvent *event, case WM_MOUSEMOVE: GDK_NOTE (EVENTS, g_print ("WM_MOUSEMOVE: %#x %#x (%d,%d)\n", - xevent->hwnd, xevent->wParam, - LOWORD (xevent->lParam), HIWORD (xevent->lParam))); + msg->hwnd, msg->wParam, + LOWORD (msg->lParam), HIWORD (msg->lParam))); /* If we haven't moved, don't create any event. * Windows sends WM_MOUSEMOVE messages after button presses * even if the mouse doesn't move. This disturbs gtk. */ - if (window == curWnd - && LOWORD (xevent->lParam) == curX - && HIWORD (xevent->lParam) == curY) + if (window == current_window + && LOWORD (msg->lParam) == current_x + && HIWORD (msg->lParam) == current_y) break; /* HB: only process mouse move messages if we own the active window. */ GetWindowThreadProcessId(GetActiveWindow(), &pidActWin); - GetWindowThreadProcessId(xevent->hwnd, &pidThis); + GetWindowThreadProcessId(msg->hwnd, &pidThis); if (pidActWin != pidThis) break; - if (window != curWnd) - synthesize_crossing_events (window, xevent); + if (window != current_window) + synthesize_crossing_events (window, msg); - if (((GdkWindowPrivate *) window)->extension_events != 0 + if (GDK_WINDOW_OBJECT (window)->extension_events != 0 && gdk_input_ignore_core) { GDK_NOTE (EVENTS, g_print ("...ignored\n")); @@ -2044,27 +2033,22 @@ gdk_event_translate (GdkEvent *event, } event->motion.type = GDK_MOTION_NOTIFY; - if (!propagate (&window, xevent, + if (!propagate (&window, msg, p_grab_window, p_grab_owner_events, p_grab_mask, doesnt_want_button_motion)) break; event->motion.window = window; - event->motion.time = xevent->time; + event->motion.time = msg->time; if (window != orig_window) - translate_mouse_coords (orig_window, window, xevent); - event->motion.x = curX = (gint16) LOWORD (xevent->lParam); - event->motion.y = curY = (gint16) HIWORD (xevent->lParam); - event->motion.x_root = xevent->pt.x; - event->motion.y_root = xevent->pt.y; - curXroot = event->motion.x_root; - curYroot = event->motion.y_root; - event->motion.pressure = 0.5; - event->motion.xtilt = 0; - event->motion.ytilt = 0; - event->motion.state = build_pointer_event_state (xevent); + translate_mouse_coords (orig_window, window, msg); + event->motion.x = current_x = (gint16) LOWORD (msg->lParam); + event->motion.y = current_y = (gint16) HIWORD (msg->lParam); + event->motion.x_root = current_x_root = msg->pt.x; + event->motion.y_root = current_y_root = msg->pt.y; + event->motion.axes = NULL; + event->motion.state = build_pointer_event_state (msg); event->motion.is_hint = FALSE; - event->motion.source = GDK_SOURCE_MOUSE; - event->motion.deviceid = GDK_CORE_POINTER; + event->motion.device = gdk_core_pointer; return_val = !GDK_DRAWABLE_DESTROYED (window); break; @@ -2072,22 +2056,22 @@ gdk_event_translate (GdkEvent *event, case WM_NCMOUSEMOVE: GDK_NOTE (EVENTS, g_print ("WM_NCMOUSEMOVE: %#x x,y: %d %d\n", - xevent->hwnd, - LOWORD (xevent->lParam), HIWORD (xevent->lParam))); - if (p_TrackMouseEvent == NULL - && curWnd != NULL - && (GDK_WINDOW_WIN32DATA (curWnd)->event_mask & GDK_LEAVE_NOTIFY_MASK)) + msg->hwnd, + LOWORD (msg->lParam), HIWORD (msg->lParam))); + if (track_mouse_event == NULL + && current_window != NULL + && (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (current_window)->impl)->event_mask & GDK_LEAVE_NOTIFY_MASK)) { GDK_NOTE (EVENTS, g_print ("...synthesizing LEAVE_NOTIFY event\n")); event->crossing.type = GDK_LEAVE_NOTIFY; - event->crossing.window = curWnd; + event->crossing.window = current_window; event->crossing.subwindow = NULL; - event->crossing.time = xevent->time; - event->crossing.x = curX; - event->crossing.y = curY; - event->crossing.x_root = curXroot; - event->crossing.y_root = curYroot; + event->crossing.time = msg->time; + event->crossing.x = current_x; + event->crossing.y = current_y; + event->crossing.x_root = current_x_root; + event->crossing.y_root = current_y_root; event->crossing.mode = GDK_CROSSING_NORMAL; event->crossing.detail = GDK_NOTIFY_NONLINEAR; @@ -2096,18 +2080,18 @@ gdk_event_translate (GdkEvent *event, return_val = TRUE; } - if (curWnd) + if (current_window) { - gdk_drawable_unref (curWnd); - curWnd = NULL; + gdk_drawable_unref (current_window); + current_window = NULL; } break; case WM_MOUSEWHEEL: - GDK_NOTE (EVENTS, g_print ("WM_MOUSEWHEEL: %#x\n", xevent->hwnd)); + GDK_NOTE (EVENTS, g_print ("WM_MOUSEWHEEL: %#x\n", msg->hwnd)); - if (((GdkWindowPrivate *) window)->extension_events != 0 + if (GDK_WINDOW_OBJECT (window)->extension_events != 0 && gdk_input_ignore_core) { GDK_NOTE (EVENTS, g_print ("...ignored\n")); @@ -2121,12 +2105,12 @@ gdk_event_translate (GdkEvent *event, * is in screen coordinates, not client coordinates as with the * button messages. I love the consistency of Windows. */ - pt.x = LOWORD (xevent->lParam); - pt.y = HIWORD (xevent->lParam); + pt.x = LOWORD (msg->lParam); + pt.y = HIWORD (msg->lParam); if ((hwnd = WindowFromPoint (pt)) == NULL) break; - xevent->hwnd = hwnd; - if ((newwindow = gdk_window_lookup (xevent->hwnd)) == NULL) + msg->hwnd = hwnd; + if ((newwindow = gdk_window_lookup (msg->hwnd)) == NULL) break; if (newwindow != window) { @@ -2134,51 +2118,47 @@ gdk_event_translate (GdkEvent *event, window = newwindow; gdk_drawable_ref (window); } - ScreenToClient (xevent->hwnd, &pt); - if (!propagate (&window, xevent, + ScreenToClient (msg->hwnd, &pt); + if (!propagate (&window, msg, p_grab_window, p_grab_owner_events, p_grab_mask, doesnt_want_scroll)) break; event->button.window = window; - event->scroll.direction = (((short) HIWORD (xevent->wParam)) > 0) ? + event->scroll.direction = (((short) HIWORD (msg->wParam)) > 0) ? GDK_SCROLL_UP : GDK_SCROLL_DOWN; event->scroll.window = window; - event->scroll.time = xevent->time; + event->scroll.time = msg->time; event->scroll.x = (gint16) pt.x; event->scroll.y = (gint16) pt.y; - event->scroll.x_root = (gint16) LOWORD (xevent->lParam); - event->scroll.y_root = (gint16) LOWORD (xevent->lParam); - event->scroll.pressure = 0.5; - event->scroll.xtilt = 0; - event->scroll.ytilt = 0; - event->scroll.state = build_pointer_event_state (xevent); - event->scroll.source = GDK_SOURCE_MOUSE; - event->scroll.deviceid = GDK_CORE_POINTER; + event->scroll.x_root = (gint16) LOWORD (msg->lParam); + event->scroll.y_root = (gint16) LOWORD (msg->lParam); + event->scroll.state = build_pointer_event_state (msg); + event->scroll.device = gdk_core_pointer; return_val = !GDK_DRAWABLE_DESTROYED (window); break; #ifdef USE_TRACKMOUSEEVENT case WM_MOUSELEAVE: - GDK_NOTE (EVENTS, g_print ("WM_MOUSELEAVE: %#x\n", xevent->hwnd)); + GDK_NOTE (EVENTS, g_print ("WM_MOUSELEAVE: %#x\n", msg->hwnd)); - if (!(GDK_WINDOW_WIN32DATA (window)->event_mask & GDK_LEAVE_NOTIFY_MASK)) + if (!(GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_LEAVE_NOTIFY_MASK)) break; event->crossing.type = GDK_LEAVE_NOTIFY; event->crossing.window = window; event->crossing.subwindow = NULL; - event->crossing.time = xevent->time; - event->crossing.x = curX; - event->crossing.y = curY; - event->crossing.x_root = curXroot; + event->crossing.time = msg->time; + event->crossing.x = current_x; + event->crossing.y = current_y; + event->crossing.x_root = current_xroot; event->crossing.y_root = curYroot; event->crossing.mode = GDK_CROSSING_NORMAL; - if (curWnd - && IsChild (GDK_DRAWABLE_XID (curWnd), GDK_DRAWABLE_XID (window))) + if (current_window + && IsChild (GDK_WINDOW_HWND (current_window), GDK_WINDOW_HWND (window))) event->crossing.detail = GDK_NOTIFY_INFERIOR; - else if (curWnd - && IsChild (GDK_DRAWABLE_XID (window), GDK_DRAWABLE_XID (curWnd))) + else if (current_window + && IsChild (GDK_WINDOW_HWND (window), GDK_WINDOW_HWND (current_window))) event->crossing.detail = GDK_NOTIFY_ANCESTOR; else event->crossing.detail = GDK_NOTIFY_NONLINEAR; @@ -2186,10 +2166,10 @@ gdk_event_translate (GdkEvent *event, event->crossing.focus = TRUE; /* ??? */ event->crossing.state = 0; /* ??? */ - if (curWnd) + if (current_window) { - gdk_drawable_unref (curWnd); - curWnd = NULL; + gdk_drawable_unref (current_window); + current_window = NULL; } return_val = !GDK_DRAWABLE_DESTROYED (window); @@ -2199,30 +2179,29 @@ gdk_event_translate (GdkEvent *event, case WM_SETFOCUS: case WM_KILLFOCUS: GDK_NOTE (EVENTS, g_print ("WM_%sFOCUS: %#x\n", - (xevent->message == WM_SETFOCUS ? + (msg->message == WM_SETFOCUS ? "SET" : "KILL"), - xevent->hwnd)); + msg->hwnd)); - if (!(GDK_WINDOW_WIN32DATA (window)->event_mask & GDK_FOCUS_CHANGE_MASK)) + if (!(GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_FOCUS_CHANGE_MASK)) break; event->focus_change.type = GDK_FOCUS_CHANGE; event->focus_change.window = window; - event->focus_change.in = (xevent->message == WM_SETFOCUS); + event->focus_change.in = (msg->message == WM_SETFOCUS); return_val = !GDK_DRAWABLE_DESTROYED (window); break; case WM_ERASEBKGND: GDK_NOTE (EVENTS, g_print ("WM_ERASEBKGND: %#x dc %#x\n", - xevent->hwnd, xevent->wParam)); + msg->hwnd, msg->wParam)); if (GDK_DRAWABLE_DESTROYED (window)) break; - colormap_private = (GdkColormapPrivateWin32 *) ((GdkWindowPrivate *) window)->drawable.colormap; - hdc = (HDC) xevent->wParam; - if (colormap_private - && colormap_private->xcolormap->rc_palette) + colormap_private = (GdkColormapPrivateWin32 *) GDK_DRAWABLE_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->colormap; + hdc = (HDC) msg->wParam; + if (colormap_private && colormap_private->xcolormap->rc_palette) { int k; @@ -2239,28 +2218,27 @@ gdk_event_translate (GdkEvent *event, *ret_val_flagp = TRUE; *ret_valp = 1; - if (GDK_WINDOW_WIN32DATA (window)->bg_type == GDK_WIN32_BG_TRANSPARENT) + if (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->bg_type == GDK_WIN32_BG_TRANSPARENT) break; - if (GDK_WINDOW_WIN32DATA (window)->bg_type == GDK_WIN32_BG_PARENT_RELATIVE) + if (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->bg_type == GDK_WIN32_BG_PARENT_RELATIVE) { /* If this window should have the same background as the * parent, fetch the parent. (And if the same goes for * the parent, fetch the grandparent, etc.) */ - while (window - && GDK_WINDOW_WIN32DATA (window)->bg_type == GDK_WIN32_BG_PARENT_RELATIVE) + while (window && GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->bg_type == GDK_WIN32_BG_PARENT_RELATIVE) { gdk_drawable_unref (window); - window = ((GdkWindowPrivate *) window)->parent; + window = GDK_WINDOW (GDK_WINDOW_OBJECT (window)->parent); gdk_drawable_ref (window); } } - if (GDK_WINDOW_WIN32DATA (window)->bg_type == GDK_WIN32_BG_PIXEL) + if (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->bg_type == GDK_WIN32_BG_PIXEL) { bg = gdk_colormap_color (colormap_private, - GDK_WINDOW_WIN32DATA (window)->bg_pixel); + GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->bg_pixel); GetClipBox (hdc, &rect); GDK_NOTE (EVENTS, @@ -2277,17 +2255,16 @@ gdk_event_translate (GdkEvent *event, WIN32_GDI_FAILED ("FillRect"); DeleteObject (hbr); } - else if (GDK_WINDOW_WIN32DATA (window)->bg_type == GDK_WIN32_BG_PIXMAP) + else if (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->bg_type == GDK_WIN32_BG_PIXMAP) { - pixmap = GDK_WINDOW_WIN32DATA (window)->bg_pixmap; - pixmap_private = (GdkDrawablePrivate*) pixmap; + pixmap = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->bg_pixmap; + pixmap_impl = GDK_PIXMAP_IMPL_WIN32 (pixmap); GetClipBox (hdc, &rect); - if (pixmap_private->width <= 8 - && pixmap_private->height <= 8) + if (pixmap_impl->width <= 8 && pixmap_impl->height <= 8) { GDK_NOTE (EVENTS, g_print ("...small pixmap, using brush\n")); - hbr = CreatePatternBrush (GDK_DRAWABLE_XID (pixmap)); + hbr = CreatePatternBrush (GDK_PIXMAP_HBITMAP (pixmap)); if (!FillRect (hdc, &rect, hbr)) WIN32_GDI_FAILED ("FillRect"); DeleteObject (hbr); @@ -2298,8 +2275,8 @@ gdk_event_translate (GdkEvent *event, g_print ("...blitting pixmap %#x (%dx%d) " "all over the place,\n" "...clip box = %dx%d@+%d+%d\n", - GDK_DRAWABLE_XID (pixmap), - pixmap_private->width, pixmap_private->height, + GDK_PIXMAP_HBITMAP (pixmap), + pixmap_impl->width, pixmap_impl->height, rect.right - rect.left, rect.bottom - rect.top, rect.left, rect.top)); @@ -2308,7 +2285,7 @@ gdk_event_translate (GdkEvent *event, WIN32_GDI_FAILED ("CreateCompatibleDC"); break; } - if (!(oldbitmap = SelectObject (bgdc, GDK_DRAWABLE_XID (pixmap)))) + if (!(oldbitmap = SelectObject (bgdc, GDK_PIXMAP_HBITMAP (pixmap)))) { WIN32_GDI_FAILED ("SelectObject"); DeleteDC (bgdc); @@ -2320,20 +2297,20 @@ gdk_event_translate (GdkEvent *event, j = 0; while (j < rect.bottom) { - if (i + pixmap_private->width >= rect.left - && j + pixmap_private->height >= rect.top) + if (i + pixmap_impl->width >= rect.left + && j + pixmap_impl->height >= rect.top) { if (!BitBlt (hdc, i, j, - pixmap_private->width, pixmap_private->height, + pixmap_impl->width, pixmap_impl->height, bgdc, 0, 0, SRCCOPY)) { WIN32_GDI_FAILED ("BitBlt"); goto loopexit; } } - j += pixmap_private->height; + j += pixmap_impl->height; } - i += pixmap_private->width; + i += pixmap_impl->width; } loopexit: SelectObject (bgdc, oldbitmap); @@ -2351,27 +2328,27 @@ gdk_event_translate (GdkEvent *event, break; case WM_PAINT: - if (!GetUpdateRect(xevent->hwnd, NULL, FALSE)) + if (!GetUpdateRect(msg->hwnd, NULL, FALSE)) { GDK_NOTE (EVENTS, g_print ("WM_PAINT: %#x no update rect\n", - xevent->hwnd)); + msg->hwnd)); break; } - hdc = BeginPaint (xevent->hwnd, &paintstruct); + hdc = BeginPaint (msg->hwnd, &paintstruct); GDK_NOTE (EVENTS, g_print ("WM_PAINT: %#x %dx%d@+%d+%d %s dc %#x\n", - xevent->hwnd, + msg->hwnd, paintstruct.rcPaint.right - paintstruct.rcPaint.left, paintstruct.rcPaint.bottom - paintstruct.rcPaint.top, paintstruct.rcPaint.left, paintstruct.rcPaint.top, (paintstruct.fErase ? "erase" : ""), hdc)); - EndPaint (xevent->hwnd, &paintstruct); + EndPaint (msg->hwnd, &paintstruct); - if (!(GDK_WINDOW_WIN32DATA (window)->event_mask & GDK_EXPOSURE_MASK)) + if (!(GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_EXPOSURE_MASK)) break; if ((paintstruct.rcPaint.right == paintstruct.rcPaint.left) @@ -2404,23 +2381,23 @@ gdk_event_translate (GdkEvent *event, case WM_SETCURSOR: GDK_NOTE (EVENTS, g_print ("WM_SETCURSOR: %#x %#x %#x\n", - xevent->hwnd, - LOWORD (xevent->lParam), HIWORD (xevent->lParam))); + msg->hwnd, + LOWORD (msg->lParam), HIWORD (msg->lParam))); - if (LOWORD (xevent->lParam) != HTCLIENT) + if (LOWORD (msg->lParam) != HTCLIENT) break; if (p_grab_window != NULL && p_grab_cursor != NULL) - xcursor = p_grab_cursor; + hcursor = p_grab_cursor; else if (!GDK_DRAWABLE_DESTROYED (window)) - xcursor = GDK_WINDOW_WIN32DATA (window)->xcursor; + hcursor = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hcursor; else - xcursor = NULL; + hcursor = NULL; - if (xcursor != NULL) + if (hcursor != NULL) { - GDK_NOTE (EVENTS, g_print ("...SetCursor(%#x)\n", xcursor)); - SetCursor (xcursor); + GDK_NOTE (EVENTS, g_print ("...SetCursor(%#x)\n", hcursor)); + SetCursor (hcursor); *ret_val_flagp = TRUE; *ret_valp = TRUE; } @@ -2428,22 +2405,22 @@ gdk_event_translate (GdkEvent *event, case WM_SHOWWINDOW: GDK_NOTE (EVENTS, g_print ("WM_SHOWWINDOW: %#x %d\n", - xevent->hwnd, - xevent->wParam)); + msg->hwnd, + msg->wParam)); - if (!(GDK_WINDOW_WIN32DATA (window)->event_mask & GDK_STRUCTURE_MASK)) + if (!(GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_STRUCTURE_MASK)) break; - event->any.type = (xevent->wParam ? GDK_MAP : GDK_UNMAP); + event->any.type = (msg->wParam ? GDK_MAP : GDK_UNMAP); event->any.window = window; if (event->any.type == GDK_UNMAP && p_grab_window == window) - gdk_pointer_ungrab (xevent->time); + gdk_pointer_ungrab (msg->time); if (event->any.type == GDK_UNMAP && k_grab_window == window) - gdk_keyboard_ungrab (xevent->time); + gdk_keyboard_ungrab (msg->time); return_val = !GDK_DRAWABLE_DESTROYED (window); break; @@ -2451,113 +2428,114 @@ gdk_event_translate (GdkEvent *event, case WM_SIZE: GDK_NOTE (EVENTS, g_print ("WM_SIZE: %#x %s %dx%d\n", - xevent->hwnd, - (xevent->wParam == SIZE_MAXHIDE ? "MAXHIDE" : - (xevent->wParam == SIZE_MAXIMIZED ? "MAXIMIZED" : - (xevent->wParam == SIZE_MAXSHOW ? "MAXSHOW" : - (xevent->wParam == SIZE_MINIMIZED ? "MINIMIZED" : - (xevent->wParam == SIZE_RESTORED ? "RESTORED" : "?"))))), - LOWORD (xevent->lParam), HIWORD (xevent->lParam))); + msg->hwnd, + (msg->wParam == SIZE_MAXHIDE ? "MAXHIDE" : + (msg->wParam == SIZE_MAXIMIZED ? "MAXIMIZED" : + (msg->wParam == SIZE_MAXSHOW ? "MAXSHOW" : + (msg->wParam == SIZE_MINIMIZED ? "MINIMIZED" : + (msg->wParam == SIZE_RESTORED ? "RESTORED" : "?"))))), + LOWORD (msg->lParam), HIWORD (msg->lParam))); - if (!(GDK_WINDOW_WIN32DATA (window)->event_mask & GDK_STRUCTURE_MASK)) + if (!(GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_STRUCTURE_MASK)) break; - if (xevent->wParam == SIZE_MINIMIZED) + if (msg->wParam == SIZE_MINIMIZED) { event->any.type = GDK_UNMAP; event->any.window = window; if (p_grab_window == window) - gdk_pointer_ungrab (xevent->time); + gdk_pointer_ungrab (msg->time); if (k_grab_window == window) - gdk_keyboard_ungrab (xevent->time); + gdk_keyboard_ungrab (msg->time); return_val = !GDK_DRAWABLE_DESTROYED (window); } - else if ((xevent->wParam == SIZE_RESTORED - || xevent->wParam == SIZE_MAXIMIZED) + else if ((msg->wParam == SIZE_RESTORED + || msg->wParam == SIZE_MAXIMIZED) #if 1 && GDK_DRAWABLE_TYPE (window) != GDK_WINDOW_CHILD #endif ) { - if (LOWORD (xevent->lParam) == 0) + if (LOWORD (msg->lParam) == 0) break; event->configure.type = GDK_CONFIGURE; event->configure.window = window; pt.x = 0; pt.y = 0; - ClientToScreen (xevent->hwnd, &pt); + ClientToScreen (msg->hwnd, &pt); event->configure.x = pt.x; event->configure.y = pt.y; - event->configure.width = LOWORD (xevent->lParam); - event->configure.height = HIWORD (xevent->lParam); - ((GdkWindowPrivate *) window)->x = event->configure.x; - ((GdkWindowPrivate *) window)->y = event->configure.y; - ((GdkWindowPrivate *) window)->drawable.width = event->configure.width; - ((GdkWindowPrivate *) window)->drawable.height = event->configure.height; - if (((GdkWindowPrivate *) window)->resize_count > 1) - ((GdkWindowPrivate *) window)->resize_count -= 1; + event->configure.width = LOWORD (msg->lParam); + event->configure.height = HIWORD (msg->lParam); + GDK_WINDOW_OBJECT (window)->x = event->configure.x; + GDK_WINDOW_OBJECT (window)->y = event->configure.y; + GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->width = event->configure.width; + GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->height = event->configure.height; + + if (GDK_WINDOW_OBJECT (window)->resize_count > 1) + GDK_WINDOW_OBJECT (window)->resize_count -= 1; return_val = !GDK_DRAWABLE_DESTROYED (window); if (return_val - && ((GdkWindowPrivate *) window)->extension_events != 0 + && GDK_WINDOW_OBJECT (window)->extension_events != 0 && gdk_input_vtable.configure_event) gdk_input_vtable.configure_event (&event->configure, window); } break; case WM_GETMINMAXINFO: - GDK_NOTE (EVENTS, g_print ("WM_GETMINMAXINFO: %#x\n", xevent->hwnd)); + GDK_NOTE (EVENTS, g_print ("WM_GETMINMAXINFO: %#x\n", msg->hwnd)); - lpmmi = (MINMAXINFO*) xevent->lParam; - if (GDK_WINDOW_WIN32DATA (window)->hint_flags & GDK_HINT_MIN_SIZE) + mmi = (MINMAXINFO*) msg->lParam; + if (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hint_flags & GDK_HINT_MIN_SIZE) { - lpmmi->ptMinTrackSize.x = GDK_WINDOW_WIN32DATA (window)->hint_min_width; - lpmmi->ptMinTrackSize.y = GDK_WINDOW_WIN32DATA (window)->hint_min_height; + mmi->ptMinTrackSize.x = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hint_min_width; + mmi->ptMinTrackSize.y = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hint_min_height; } - if (GDK_WINDOW_WIN32DATA (window)->hint_flags & GDK_HINT_MAX_SIZE) + if (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hint_flags & GDK_HINT_MAX_SIZE) { - lpmmi->ptMaxTrackSize.x = GDK_WINDOW_WIN32DATA (window)->hint_max_width; - lpmmi->ptMaxTrackSize.y = GDK_WINDOW_WIN32DATA (window)->hint_max_height; + mmi->ptMaxTrackSize.x = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hint_max_width; + mmi->ptMaxTrackSize.y = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hint_max_height; - lpmmi->ptMaxSize.x = GDK_WINDOW_WIN32DATA (window)->hint_max_width; - lpmmi->ptMaxSize.y = GDK_WINDOW_WIN32DATA (window)->hint_max_height; + mmi->ptMaxSize.x = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hint_max_width; + mmi->ptMaxSize.y = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->hint_max_height; } break; case WM_MOVE: GDK_NOTE (EVENTS, g_print ("WM_MOVE: %#x (%d,%d)\n", - xevent->hwnd, - LOWORD (xevent->lParam), HIWORD (xevent->lParam))); + msg->hwnd, + LOWORD (msg->lParam), HIWORD (msg->lParam))); - if (!(GDK_WINDOW_WIN32DATA (window)->event_mask & GDK_STRUCTURE_MASK)) + if (!(GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->event_mask & GDK_STRUCTURE_MASK)) break; if (GDK_DRAWABLE_TYPE (window) != GDK_WINDOW_CHILD - && !IsIconic(xevent->hwnd) - && IsWindowVisible(xevent->hwnd)) + && !IsIconic(msg->hwnd) + && IsWindowVisible(msg->hwnd)) { event->configure.type = GDK_CONFIGURE; event->configure.window = window; - event->configure.x = LOWORD (xevent->lParam); - event->configure.y = HIWORD (xevent->lParam); - GetClientRect (xevent->hwnd, &rect); + event->configure.x = LOWORD (msg->lParam); + event->configure.y = HIWORD (msg->lParam); + GetClientRect (msg->hwnd, &rect); event->configure.width = rect.right; event->configure.height = rect.bottom; - ((GdkWindowPrivate *) window)->x = event->configure.x; - ((GdkWindowPrivate *) window)->y = event->configure.y; - ((GdkWindowPrivate *) window)->drawable.width = event->configure.width; - ((GdkWindowPrivate *) window)->drawable.height = event->configure.height; + GDK_WINDOW_OBJECT (window)->x = event->configure.x; + GDK_WINDOW_OBJECT (window)->y = event->configure.y; + GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->width = event->configure.width; + GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->height = event->configure.height; return_val = !GDK_DRAWABLE_DESTROYED (window); } break; case WM_CLOSE: - GDK_NOTE (EVENTS, g_print ("WM_CLOSE: %#x\n", xevent->hwnd)); + GDK_NOTE (EVENTS, g_print ("WM_CLOSE: %#x\n", msg->hwnd)); event->any.type = GDK_DELETE; event->any.window = window; @@ -2581,29 +2559,29 @@ gdk_event_translate (GdkEvent *event, GDK_NOTE (EVENTS, flag = TRUE); if (flag) g_print ("WM_%s: %#x %#x (%s)\n", - (xevent->message == WM_RENDERFORMAT ? "RENDERFORMAT" : + (msg->message == WM_RENDERFORMAT ? "RENDERFORMAT" : "RENDERALLFORMATS"), - xevent->hwnd, - xevent->wParam, - (xevent->wParam == CF_TEXT ? "CF_TEXT" : - (xevent->wParam == CF_DIB ? "CF_DIB" : - (xevent->wParam == CF_UNICODETEXT ? "CF_UNICODETEXT" : - (GetClipboardFormatName (xevent->wParam, buf, sizeof (buf)), buf))))); + msg->hwnd, + msg->wParam, + (msg->wParam == CF_TEXT ? "CF_TEXT" : + (msg->wParam == CF_DIB ? "CF_DIB" : + (msg->wParam == CF_UNICODETEXT ? "CF_UNICODETEXT" : + (GetClipboardFormatName (msg->wParam, buf, sizeof (buf)), buf))))); #if 0 event->selection.type = GDK_SELECTION_REQUEST; event->selection.window = window; event->selection.selection = gdk_clipboard_atom; - if (xevent->wParam == CF_TEXT) + if (msg->wParam == CF_TEXT) event->selection.target = GDK_TARGET_STRING; else { - GetClipboardFormatName (xevent->wParam, buf, sizeof (buf)); + GetClipboardFormatName (msg->wParam, buf, sizeof (buf)); event->selection.target = gdk_atom_intern (buf, FALSE); } event->selection.property = gdk_selection_property; - event->selection.requestor = (guint32) xevent->hwnd; - event->selection.time = xevent->time; + event->selection.requestor = (guint32) msg->hwnd; + event->selection.time = msg->time; return_val = !GDK_DRAWABLE_DESTROYED (window); #else /* Test code, to see if SetClipboardData works when called from @@ -2625,21 +2603,21 @@ gdk_event_translate (GdkEvent *event, #endif /* No delayed rendering */ case WM_DESTROY: - GDK_NOTE (EVENTS, g_print ("WM_DESTROY: %#x\n", xevent->hwnd)); + GDK_NOTE (EVENTS, g_print ("WM_DESTROY: %#x\n", msg->hwnd)); event->any.type = GDK_DESTROY; event->any.window = window; - if (window != NULL && window == curWnd) + if (window != NULL && window == current_window) { - gdk_drawable_unref (curWnd); - curWnd = NULL; + gdk_drawable_unref (current_window); + current_window = NULL; } if (p_grab_window == window) - gdk_pointer_ungrab (xevent->time); + gdk_pointer_ungrab (msg->time); if (k_grab_window == window) - gdk_keyboard_ungrab (xevent->time); + gdk_keyboard_ungrab (msg->time); return_val = window != NULL && !GDK_DRAWABLE_DESTROYED (window); @@ -2655,33 +2633,33 @@ gdk_event_translate (GdkEvent *event, */ case WT_PACKET: GDK_NOTE (EVENTS, g_print ("WT_PACKET: %#x %d %#x\n", - xevent->hwnd, - xevent->wParam, xevent->lParam)); + msg->hwnd, + msg->wParam, msg->lParam)); goto wintab; case WT_CSRCHANGE: GDK_NOTE (EVENTS, g_print ("WT_CSRCHANGE: %#x %d %#x\n", - xevent->hwnd, - xevent->wParam, xevent->lParam)); + msg->hwnd, + msg->wParam, msg->lParam)); goto wintab; case WT_PROXIMITY: GDK_NOTE (EVENTS, g_print ("WT_PROXIMITY: %#x %#x %d %d\n", - xevent->hwnd, xevent->wParam, - LOWORD (xevent->lParam), - HIWORD (xevent->lParam))); + msg->hwnd, msg->wParam, + LOWORD (msg->lParam), + HIWORD (msg->lParam))); /* Fall through */ wintab: event->any.window = window; - return_val = gdk_input_vtable.other_event(event, xevent); + return_val = gdk_input_vtable.other_event(event, msg); break; #endif default: GDK_NOTE (EVENTS, g_print ("%s: %#x %#x %#x\n", - gdk_win32_message_name (xevent->message), - xevent->hwnd, - xevent->wParam, xevent->lParam)); + gdk_win32_message_name (msg->message), + msg->hwnd, + msg->wParam, msg->lParam)); } done: @@ -2724,8 +2702,8 @@ gdk_events_queue (void) GDK_NOTE (EVENTS, g_print ("PeekMessage: %#x %s\n", msg.hwnd, gdk_win32_message_name (msg.message))); - if (paimmmpo == NULL - || (paimmmpo->lpVtbl->OnTranslateMessage) (paimmmpo, &msg) != S_OK) + if (active_imm_msgpump_owner == NULL + || (active_imm_msgpump_owner->lpVtbl->OnTranslateMessage) (active_imm_msgpump_owner, &msg) != S_OK) TranslateMessage (&msg); if (msg.message == g_pipe_readable_msg) diff --git a/gdk/win32/gdkfont-win32.c b/gdk/win32/gdkfont-win32.c index db8c2067a8..9fa7c1b63e 100644 --- a/gdk/win32/gdkfont-win32.c +++ b/gdk/win32/gdkfont-win32.c @@ -142,7 +142,7 @@ logfont_to_xlfd (const LOGFONT *lfp, if (logpixelsy == 0) { - logpixelsy = GetDeviceCaps (gdk_DC, LOGPIXELSY); + logpixelsy = GetDeviceCaps (gdk_display_hdc, LOGPIXELSY); } if (lfp->lfWeight >= FW_HEAVY) @@ -281,7 +281,7 @@ gdk_font_full_name_get (GdkFont *font) { singlefont = (GdkWin32SingleFont *) list->data; - if (GetObject (singlefont->xfont, sizeof (LOGFONT), &logfont) == 0) + if (GetObject (singlefont->hfont, sizeof (LOGFONT), &logfont) == 0) { WIN32_GDI_FAILED ("GetObject"); return NULL; @@ -409,7 +409,7 @@ EnumFontFamExProc (const LOGFONT *lfp, lf = *lfp; - EnumFontFamiliesEx (gdk_DC, &lf, InnerEnumFontFamExProc, lParam, 0); + EnumFontFamiliesEx (gdk_display_hdc, &lf, InnerEnumFontFamExProc, lParam, 0); } else InnerEnumFontFamExProc (lfp, metrics, fontType, lParam); @@ -429,7 +429,7 @@ gdk_font_list_new (const gchar *font_pattern, xfontnames = g_new (gchar *, font_names_size); memset (&logfont, 0, sizeof (logfont)); logfont.lfCharSet = DEFAULT_CHARSET; - EnumFontFamiliesEx (gdk_DC, &logfont, EnumFontFamExProc, + EnumFontFamiliesEx (gdk_display_hdc, &logfont, EnumFontFamExProc, (LPARAM) font_pattern, 0); result = g_new (gchar *, num_fonts + 1); @@ -1234,7 +1234,7 @@ gdk_font_load_internal (const gchar *font_name) return NULL; } - logpixelsy = GetDeviceCaps (gdk_DC, LOGPIXELSY); + logpixelsy = GetDeviceCaps (gdk_display_hdc, LOGPIXELSY); if (strcmp (pixel_size, "*") == 0) if (strcmp (point_size, "*") == 0) @@ -1447,13 +1447,13 @@ gdk_font_load_internal (const gchar *font_name) return NULL; singlefont = g_new (GdkWin32SingleFont, 1); - singlefont->xfont = hfont; - GetObject (singlefont->xfont, sizeof (logfont), &logfont); - oldfont = SelectObject (gdk_DC, singlefont->xfont); + singlefont->hfont = hfont; + GetObject (singlefont->hfont, sizeof (logfont), &logfont); + oldfont = SelectObject (gdk_display_hdc, singlefont->hfont); memset (&singlefont->fs, 0, sizeof (singlefont->fs)); - singlefont->charset = GetTextCharsetInfo (gdk_DC, &singlefont->fs, 0); - GetTextFace (gdk_DC, sizeof (face), face); - SelectObject (gdk_DC, oldfont); + singlefont->charset = GetTextCharsetInfo (gdk_display_hdc, &singlefont->fs, 0); + GetTextFace (gdk_display_hdc, sizeof (face), face); + SelectObject (gdk_display_hdc, oldfont); if (TranslateCharsetInfo ((DWORD *) singlefont->charset, &csi, TCI_SRCCHARSET) && singlefont->charset != MAC_CHARSET) @@ -1462,7 +1462,7 @@ gdk_font_load_internal (const gchar *font_name) singlefont->codepage = 0; GDK_NOTE (MISC, (g_print ("... = %#x %s cs %s cp%d\n", - singlefont->xfont, face, + singlefont->hfont, face, charset_name (singlefont->charset), singlefont->codepage), g_print ("... Unicode subranges:"), @@ -1504,9 +1504,9 @@ gdk_font_load (const gchar *font_name) * chars to work. (Yes, even Latin-1, as we use Unicode internally.) */ font->type = GDK_FONT_FONTSET; - oldfont = SelectObject (gdk_DC, singlefont->xfont); - GetTextMetrics (gdk_DC, &textmetric); - SelectObject (gdk_DC, oldfont); + oldfont = SelectObject (gdk_display_hdc, singlefont->hfont); + GetTextMetrics (gdk_display_hdc, &textmetric); + SelectObject (gdk_display_hdc, oldfont); font->ascent = textmetric.tmAscent; font->descent = textmetric.tmDescent; @@ -1568,9 +1568,9 @@ gdk_fontset_load (const gchar *fontset_name) if (singlefont) { private->fonts = g_slist_append (private->fonts, singlefont); - oldfont = SelectObject (gdk_DC, singlefont->xfont); - GetTextMetrics (gdk_DC, &textmetric); - SelectObject (gdk_DC, oldfont); + oldfont = SelectObject (gdk_display_hdc, singlefont->hfont); + GetTextMetrics (gdk_display_hdc, &textmetric); + SelectObject (gdk_display_hdc, oldfont); font->ascent = MAX (font->ascent, textmetric.tmAscent); font->descent = MAX (font->descent, textmetric.tmDescent); } @@ -1602,14 +1602,14 @@ _gdk_font_destroy (GdkFont *font) singlefont = (GdkWin32SingleFont *) private->fonts->data; GDK_NOTE (MISC, g_print ("_gdk_font_destroy %#x\n", - singlefont->xfont)); + singlefont->hfont)); gdk_font_hash_remove (font->type, font); switch (font->type) { case GDK_FONT_FONT: - DeleteObject (singlefont->xfont); + DeleteObject (singlefont->hfont); break; case GDK_FONT_FONTSET: @@ -1617,7 +1617,7 @@ _gdk_font_destroy (GdkFont *font) while (list) { singlefont = (GdkWin32SingleFont *) list->data; - DeleteObject (singlefont->xfont); + DeleteObject (singlefont->hfont); list = list->next; } @@ -1647,7 +1647,7 @@ gdk_font_id (const GdkFont *font) private = (const GdkFontPrivateWin32 *) font; if (font->type == GDK_FONT_FONT) - return (gint) ((GdkWin32SingleFont *) private->fonts->data)->xfont; + return (gint) ((GdkWin32SingleFont *) private->fonts->data)->hfont; else return 0; } @@ -1666,8 +1666,8 @@ gdk_font_equal (const GdkFont *fonta, privateb = (const GdkFontPrivateWin32 *) fontb; if (fonta->type == GDK_FONT_FONT && fontb->type == GDK_FONT_FONT) - return (((GdkWin32SingleFont *) privatea->fonts->data)->xfont - == ((GdkWin32SingleFont *) privateb->fonts->data)->xfont); + return (((GdkWin32SingleFont *) privatea->fonts->data)->hfont + == ((GdkWin32SingleFont *) privateb->fonts->data)->hfont); else if (fonta->type == GDK_FONT_FONTSET && fontb->type == GDK_FONT_FONTSET) { GSList *lista = privatea->fonts; @@ -1675,8 +1675,8 @@ gdk_font_equal (const GdkFont *fonta, while (lista && listb) { - if (((GdkWin32SingleFont *) lista->data)->xfont - != ((GdkWin32SingleFont *) listb->data)->xfont) + if (((GdkWin32SingleFont *) lista->data)->hfont + != ((GdkWin32SingleFont *) listb->data)->hfont) return 0; lista = lista->next; listb = listb->next; @@ -1762,7 +1762,7 @@ gdk_wchar_text_handle (GdkFont *font, GDK_NOTE (MISC, g_print ("%d:%d:%d:%#x ", start-wcstr, wcp-wcstr, block, - (singlefont ? singlefont->xfont : 0))); + (singlefont ? singlefont->hfont : 0))); /* Call the callback function */ (*handler) (singlefont, start, wcp+1 - start, arg); @@ -1789,13 +1789,13 @@ gdk_text_size_handler (GdkWin32SingleFont *singlefont, if (!singlefont) return; - if ((oldfont = SelectObject (gdk_DC, singlefont->xfont)) == NULL) + if ((oldfont = SelectObject (gdk_display_hdc, singlefont->hfont)) == NULL) { WIN32_GDI_FAILED ("SelectObject"); return; } - GetTextExtentPoint32W (gdk_DC, wcstr, wclen, &this_size); - SelectObject (gdk_DC, oldfont); + GetTextExtentPoint32W (gdk_display_hdc, wcstr, wclen, &this_size); + SelectObject (gdk_display_hdc, oldfont); arg->total.cx += this_size.cx; arg->total.cy = MAX (arg->total.cy, this_size.cy); diff --git a/gdk/win32/gdkgc-win32.c b/gdk/win32/gdkgc-win32.c index 8894c0277b..065d4ebb6f 100644 --- a/gdk/win32/gdkgc-win32.c +++ b/gdk/win32/gdkgc-win32.c @@ -43,22 +43,82 @@ static void gdk_win32_gc_set_values (GdkGC *gc, GdkGCValuesMask values_mask); static void gdk_win32_gc_set_dashes (GdkGC *gc, gint dash_offset, - gchar dash_list[], + gint8 dash_list[], gint n); -static GdkGCClass gdk_win32_gc_class = { - gdk_win32_gc_destroy, - gdk_win32_gc_get_values, - gdk_win32_gc_set_values, - gdk_win32_gc_set_dashes -}; +static void gdk_gc_win32_class_init (GdkGCWin32Class *klass); +static void gdk_gc_win32_finalize (GObject *object); + +static gpointer parent_class = NULL; + +GType +gdk_gc_win32_get_type (void) +{ + static GType object_type = 0; + + if (!object_type) + { + static const GTypeInfo object_info = + { + sizeof (GdkGCWin32Class), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gdk_gc_win32_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GdkGCWin32), + 0, /* n_preallocs */ + (GInstanceInitFunc) NULL, + }; + + object_type = g_type_register_static (GDK_TYPE_GC, + "GdkGCWin32", + &object_info); + } + + return object_type; +} + +static void +gdk_gc_win32_class_init (GdkGCWin32Class *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GdkGCClass *gc_class = GDK_GC_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->finalize = gdk_gc_win32_finalize; + + gc_class->get_values = gdk_win32_gc_get_values; + gc_class->set_values = gdk_win32_gc_set_values; + gc_class->set_dashes = gdk_win32_gc_set_dashes; +} + +static void +gdk_gc_win32_finalize (GObject *object) +{ + GdkGCWin32 *win32_gc = GDK_GC_WIN32 (object); + + if (win32_gc->clip_region) + gdk_region_destroy (win32_gc->clip_region); + + if (win32_gc->values_mask & GDK_GC_FONT) + gdk_font_unref (win32_gc->font); + + if (win32_gc->values_mask & GDK_GC_TILE) + gdk_drawable_unref (win32_gc->tile); + + if (win32_gc->values_mask & GDK_GC_STIPPLE) + gdk_drawable_unref (win32_gc->stipple); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} static void gdk_win32_gc_values_to_win32values (GdkGCValues *values, GdkGCValuesMask mask, - GdkGC *gc) + GdkGCWin32 *win32_gc) { - GdkGCWin32Data *data = GDK_GC_WIN32DATA (gc); char *s = ""; gint sw, sh; @@ -66,40 +126,40 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values, if (mask & GDK_GC_FOREGROUND) { - data->foreground = values->foreground.pixel; - data->values_mask |= GDK_GC_FOREGROUND; - GDK_NOTE (MISC, (g_print ("fg=%.06x", data->foreground), + win32_gc->foreground = values->foreground.pixel; + win32_gc->values_mask |= GDK_GC_FOREGROUND; + GDK_NOTE (MISC, (g_print ("fg=%.06x", win32_gc->foreground), s = ",")); } if (mask & GDK_GC_BACKGROUND) { - data->background = values->background.pixel; - data->values_mask |= GDK_GC_BACKGROUND; - GDK_NOTE (MISC, (g_print ("%sbg=%.06x", s, data->background), + win32_gc->background = values->background.pixel; + win32_gc->values_mask |= GDK_GC_BACKGROUND; + GDK_NOTE (MISC, (g_print ("%sbg=%.06x", s, win32_gc->background), s = ",")); } if ((mask & GDK_GC_FONT) && (values->font->type == GDK_FONT_FONT || values->font->type == GDK_FONT_FONTSET)) { - if (data->font != NULL) - gdk_font_unref (data->font); - data->font = values->font; - if (data->font != NULL) + if (win32_gc->font != NULL) + gdk_font_unref (win32_gc->font); + win32_gc->font = values->font; + if (win32_gc->font != NULL) { gchar *xlfd; - gdk_font_ref (data->font); - data->values_mask |= GDK_GC_FONT; - GDK_NOTE (MISC, (xlfd = gdk_font_full_name_get (data->font), + gdk_font_ref (win32_gc->font); + win32_gc->values_mask |= GDK_GC_FONT; + GDK_NOTE (MISC, (xlfd = gdk_font_full_name_get (win32_gc->font), g_print ("%sfont=%s", s, xlfd), s = ",", gdk_font_full_name_free (xlfd))); } else { - data->values_mask &= ~GDK_GC_FONT; + win32_gc->values_mask &= ~GDK_GC_FONT; GDK_NOTE (MISC, (g_print ("%sfont=NULL"), s = ",")); } @@ -112,97 +172,97 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values, switch (values->function) { case GDK_COPY: - data->rop2 = R2_COPYPEN; + win32_gc->rop2 = R2_COPYPEN; GDK_NOTE (MISC, g_print ("COPYPEN")); break; case GDK_INVERT: - data->rop2 = R2_NOT; + win32_gc->rop2 = R2_NOT; GDK_NOTE (MISC, g_print ("NOT")); break; case GDK_XOR: - data->rop2 = R2_XORPEN; + win32_gc->rop2 = R2_XORPEN; GDK_NOTE (MISC, g_print ("XORPEN")); break; case GDK_CLEAR: - data->rop2 = R2_BLACK; + win32_gc->rop2 = R2_BLACK; GDK_NOTE (MISC, g_print ("BLACK")); break; case GDK_AND: - data->rop2 = R2_MASKPEN; + win32_gc->rop2 = R2_MASKPEN; GDK_NOTE (MISC, g_print ("MASKPEN")); break; case GDK_AND_REVERSE: - data->rop2 = R2_MASKPENNOT; + win32_gc->rop2 = R2_MASKPENNOT; GDK_NOTE (MISC, g_print ("MASKPENNOT")); break; case GDK_AND_INVERT: - data->rop2 = R2_MASKNOTPEN; + win32_gc->rop2 = R2_MASKNOTPEN; GDK_NOTE (MISC, g_print ("MASKNOTPEN")); break; case GDK_NOOP: - data->rop2 = R2_NOP; + win32_gc->rop2 = R2_NOP; GDK_NOTE (MISC, g_print ("NOP")); break; case GDK_OR: - data->rop2 = R2_MERGEPEN; + win32_gc->rop2 = R2_MERGEPEN; GDK_NOTE (MISC, g_print ("MERGEPEN")); break; case GDK_EQUIV: - data->rop2 = R2_NOTXORPEN; + win32_gc->rop2 = R2_NOTXORPEN; GDK_NOTE (MISC, g_print ("NOTXORPEN")); break; case GDK_OR_REVERSE: - data->rop2 = R2_MERGEPENNOT; + win32_gc->rop2 = R2_MERGEPENNOT; GDK_NOTE (MISC, g_print ("MERGEPENNOT")); break; case GDK_COPY_INVERT: - data->rop2 = R2_NOTCOPYPEN; + win32_gc->rop2 = R2_NOTCOPYPEN; GDK_NOTE (MISC, g_print ("NOTCOPYPEN")); break; case GDK_OR_INVERT: - data->rop2 = R2_MERGENOTPEN; + win32_gc->rop2 = R2_MERGENOTPEN; GDK_NOTE (MISC, g_print ("MERGENOTPEN")); break; case GDK_NAND: - data->rop2 = R2_NOTMASKPEN; + win32_gc->rop2 = R2_NOTMASKPEN; GDK_NOTE (MISC, g_print ("NOTMASKPEN")); break; case GDK_NOR: - data->rop2 = R2_NOTMERGEPEN; + win32_gc->rop2 = R2_NOTMERGEPEN; GDK_NOTE (MISC, g_print ("NOTMERGEPEN")); break; case GDK_SET: - data->rop2 = R2_WHITE; + win32_gc->rop2 = R2_WHITE; GDK_NOTE (MISC, g_print ("WHITE")); break; } - data->values_mask |= GDK_GC_FUNCTION; + win32_gc->values_mask |= GDK_GC_FUNCTION; } if (mask & GDK_GC_FILL) { - data->fill_style = values->fill; - data->values_mask |= GDK_GC_FILL; - GDK_NOTE (MISC, (g_print ("%sfill=%d", s, data->fill_style), + win32_gc->fill_style = values->fill; + win32_gc->values_mask |= GDK_GC_FILL; + GDK_NOTE (MISC, (g_print ("%sfill=%d", s, win32_gc->fill_style), s = ",")); } if (mask & GDK_GC_TILE) { - if (data->tile != NULL) - gdk_drawable_unref (data->tile); - data->tile = values->tile; - if (data->tile != NULL) + if (win32_gc->tile != NULL) + gdk_drawable_unref (win32_gc->tile); + win32_gc->tile = values->tile; + if (win32_gc->tile != NULL) { - gdk_drawable_ref (data->tile); - data->values_mask |= GDK_GC_TILE; + gdk_drawable_ref (win32_gc->tile); + win32_gc->values_mask |= GDK_GC_TILE; GDK_NOTE (MISC, (g_print ("%stile=%#x", s, - GDK_DRAWABLE_XID (data->tile)), + GDK_DRAWABLE_XID (win32_gc->tile)), s = ",")); } else { - data->values_mask &= ~GDK_GC_TILE; + win32_gc->values_mask &= ~GDK_GC_TILE; GDK_NOTE (MISC, (g_print ("%stile=NULL", s), s = ",")); } @@ -210,12 +270,12 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values, if (mask & GDK_GC_STIPPLE) { - if (data->stipple != NULL) - gdk_drawable_unref (data->stipple); - data->stipple = values->stipple; - if (data->stipple != NULL) + if (win32_gc->stipple != NULL) + gdk_drawable_unref (win32_gc->stipple); + win32_gc->stipple = values->stipple; + if (win32_gc->stipple != NULL) { - gdk_drawable_get_size (data->stipple, &sw, &sh); + gdk_drawable_get_size (win32_gc->stipple, &sw, &sh); if (sw != 8 || sh != 8) { @@ -235,24 +295,24 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values, j = 0; while (j < 8) { - gdk_draw_drawable (bm, gc, data->stipple, 0, 0, i, j, sw, sh); + gdk_draw_drawable (bm, gc, win32_gc->stipple, 0, 0, i, j, sw, sh); j += sh; } i += sw; } - data->stipple = bm; + win32_gc->stipple = bm; gdk_gc_unref (gc); } else - gdk_drawable_ref (data->stipple); - data->values_mask |= GDK_GC_STIPPLE; + gdk_drawable_ref (win32_gc->stipple); + win32_gc->values_mask |= GDK_GC_STIPPLE; GDK_NOTE (MISC, (g_print ("%sstipple=%#x", s, - GDK_DRAWABLE_XID (data->stipple)), + GDK_DRAWABLE_XID (win32_gc->stipple)), s = ",")); } else { - data->values_mask &= ~GDK_GC_STIPPLE; + win32_gc->values_mask &= ~GDK_GC_STIPPLE; GDK_NOTE (MISC, (g_print ("%sstipple=NULL", s), s = ",")); } @@ -260,107 +320,107 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values, if (mask & GDK_GC_CLIP_MASK) { - if (data->clip_region != NULL) + if (win32_gc->clip_region != NULL) { - gdk_region_destroy (data->clip_region); - data->clip_region = NULL; + gdk_region_destroy (win32_gc->clip_region); + win32_gc->clip_region = NULL; } - if (data->hcliprgn != NULL) - DeleteObject (data->hcliprgn); + if (win32_gc->hcliprgn != NULL) + DeleteObject (win32_gc->hcliprgn); if (values->clip_mask != NULL) { - data->hcliprgn = + win32_gc->hcliprgn = BitmapToRegion ((HBITMAP) GDK_DRAWABLE_XID (values->clip_mask)); - data->values_mask |= GDK_GC_CLIP_MASK; - OffsetRgn (data->hcliprgn, - ((GdkGCPrivate *) gc)->clip_x_origin, - ((GdkGCPrivate *) gc)->clip_y_origin); + win32_gc->values_mask |= GDK_GC_CLIP_MASK; + OffsetRgn (win32_gc->hcliprgn, + win32_gc->parent_instance.clip_x_origin, + win32_gc->parent_instance.clip_y_origin); } else { - data->hcliprgn = NULL; - data->values_mask &= ~GDK_GC_CLIP_MASK; + win32_gc->hcliprgn = NULL; + win32_gc->values_mask &= ~GDK_GC_CLIP_MASK; } - GDK_NOTE (MISC, (g_print ("%sclip=%#x", s, data->hcliprgn), + GDK_NOTE (MISC, (g_print ("%sclip=%#x", s, win32_gc->hcliprgn), s = ",")); } if (mask & GDK_GC_SUBWINDOW) { - data->subwindow_mode = values->subwindow_mode; - data->values_mask |= GDK_GC_SUBWINDOW; - GDK_NOTE (MISC, (g_print ("%ssubw=%d", s, data->subwindow_mode), + win32_gc->subwindow_mode = values->subwindow_mode; + win32_gc->values_mask |= GDK_GC_SUBWINDOW; + GDK_NOTE (MISC, (g_print ("%ssubw=%d", s, win32_gc->subwindow_mode), s = ",")); } if (mask & GDK_GC_TS_X_ORIGIN) { - data->values_mask |= GDK_GC_TS_X_ORIGIN; + win32_gc->values_mask |= GDK_GC_TS_X_ORIGIN; GDK_NOTE (MISC, (g_print ("%sts_x=%d", s, values->ts_x_origin), s = ",")); } if (mask & GDK_GC_TS_Y_ORIGIN) { - data->values_mask |= GDK_GC_TS_Y_ORIGIN; + win32_gc->values_mask |= GDK_GC_TS_Y_ORIGIN; GDK_NOTE (MISC, (g_print ("%sts_y=%d", s, values->ts_y_origin), s = ",")); } if (mask & GDK_GC_CLIP_X_ORIGIN) { - data->values_mask |= GDK_GC_CLIP_X_ORIGIN; + win32_gc->values_mask |= GDK_GC_CLIP_X_ORIGIN; GDK_NOTE (MISC, (g_print ("%sclip_x=%d", s, values->clip_x_origin), s = ",")); } if (mask & GDK_GC_CLIP_Y_ORIGIN) { - data->values_mask |= GDK_GC_CLIP_Y_ORIGIN; + win32_gc->values_mask |= GDK_GC_CLIP_Y_ORIGIN; GDK_NOTE (MISC, (g_print ("%sclip_y=%d", s, values->clip_y_origin), s = ",")); } if (mask & GDK_GC_EXPOSURES) { - data->graphics_exposures = values->graphics_exposures; - data->values_mask |= GDK_GC_EXPOSURES; - GDK_NOTE (MISC, (g_print ("%sexp=%d", s, data->graphics_exposures), + win32_gc->graphics_exposures = values->graphics_exposures; + win32_gc->values_mask |= GDK_GC_EXPOSURES; + GDK_NOTE (MISC, (g_print ("%sexp=%d", s, win32_gc->graphics_exposures), s = ",")); } if (mask & GDK_GC_LINE_WIDTH) { - data->pen_width = values->line_width; - data->values_mask |= GDK_GC_LINE_WIDTH; - GDK_NOTE (MISC, (g_print ("%spw=%d", s, data->pen_width), + win32_gc->pen_width = values->line_width; + win32_gc->values_mask |= GDK_GC_LINE_WIDTH; + GDK_NOTE (MISC, (g_print ("%spw=%d", s, win32_gc->pen_width), s = ",")); } if (mask & GDK_GC_LINE_STYLE) { - data->pen_style &= ~(PS_STYLE_MASK); + win32_gc->pen_style &= ~(PS_STYLE_MASK); GDK_NOTE (MISC, (g_print ("%sps|=", s), s = ",")); switch (values->line_style) { case GDK_LINE_SOLID: GDK_NOTE (MISC, g_print ("LINE_SOLID")); - data->pen_style |= PS_SOLID; + win32_gc->pen_style |= PS_SOLID; break; case GDK_LINE_ON_OFF_DASH: case GDK_LINE_DOUBLE_DASH: /* ??? */ GDK_NOTE (MISC, g_print ("DASH")); - data->pen_style |= PS_DASH; + win32_gc->pen_style |= PS_DASH; break; } - data->values_mask |= GDK_GC_LINE_STYLE; + win32_gc->values_mask |= GDK_GC_LINE_STYLE; } if (mask & GDK_GC_CAP_STYLE) { - data->pen_style &= ~(PS_ENDCAP_MASK); + win32_gc->pen_style &= ~(PS_ENDCAP_MASK); GDK_NOTE (MISC, (g_print ("%sps|=", s), s = ",")); switch (values->cap_style) @@ -368,41 +428,41 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values, case GDK_CAP_NOT_LAST: /* ??? */ case GDK_CAP_BUTT: GDK_NOTE (MISC, g_print ("ENDCAP_FLAT")); - data->pen_style |= PS_ENDCAP_FLAT; + win32_gc->pen_style |= PS_ENDCAP_FLAT; break; case GDK_CAP_ROUND: GDK_NOTE (MISC, g_print ("ENDCAP_ROUND")); - data->pen_style |= PS_ENDCAP_ROUND; + win32_gc->pen_style |= PS_ENDCAP_ROUND; break; case GDK_CAP_PROJECTING: GDK_NOTE (MISC, g_print ("ENDCAP_SQUARE")); - data->pen_style |= PS_ENDCAP_SQUARE; + win32_gc->pen_style |= PS_ENDCAP_SQUARE; break; } - data->values_mask |= GDK_GC_CAP_STYLE; + win32_gc->values_mask |= GDK_GC_CAP_STYLE; } if (mask & GDK_GC_JOIN_STYLE) { - data->pen_style &= ~(PS_JOIN_MASK); + win32_gc->pen_style &= ~(PS_JOIN_MASK); GDK_NOTE (MISC, (g_print ("%sps|=", s), s = ",")); switch (values->join_style) { case GDK_JOIN_MITER: GDK_NOTE (MISC, g_print ("JOIN_MITER")); - data->pen_style |= PS_JOIN_MITER; + win32_gc->pen_style |= PS_JOIN_MITER; break; case GDK_JOIN_ROUND: GDK_NOTE (MISC, g_print ("JOIN_ROUND")); - data->pen_style |= PS_JOIN_ROUND; + win32_gc->pen_style |= PS_JOIN_ROUND; break; case GDK_JOIN_BEVEL: GDK_NOTE (MISC, g_print ("JOIN_BEVEL")); - data->pen_style |= PS_JOIN_BEVEL; + win32_gc->pen_style |= PS_JOIN_BEVEL; break; } - data->values_mask |= GDK_GC_JOIN_STYLE; + win32_gc->values_mask |= GDK_GC_JOIN_STYLE; } GDK_NOTE (MISC, g_print ("}\n")); } @@ -413,76 +473,56 @@ _gdk_win32_gc_new (GdkDrawable *drawable, GdkGCValuesMask mask) { GdkGC *gc; - GdkGCPrivate *private; - GdkGCWin32Data *data; + GdkGCWin32 *win32_gc; - gc = gdk_gc_alloc (); - private = (GdkGCPrivate *)gc; + /* NOTICE that the drawable here has to be the impl drawable, + * not the publically-visible drawables. + */ + g_return_val_if_fail (GDK_IS_DRAWABLE_IMPL_WIN32 (drawable), NULL); - private->klass = &gdk_win32_gc_class; - private->klass_data = data = g_new (GdkGCWin32Data, 1); - - data->clip_region = NULL; + gc = g_object_new (gdk_gc_win32_get_type (), NULL); + win32_gc = GDK_GC_WIN32 (gc); + + win32_gc->hdc = NULL; + win32_gc->clip_region = NULL; + win32_gc->hcliprgn = NULL; /* Use the same default values as X11 does, even if they don't make * sense per se. But apps always set fg and bg anyway. */ - data->foreground = 0; - data->background = 1; - data->font = NULL; - data->rop2 = R2_COPYPEN; - data->fill_style = GDK_SOLID; - data->tile = NULL; - data->stipple = NULL; - data->pen_style = PS_GEOMETRIC|PS_ENDCAP_FLAT|PS_JOIN_MITER; - data->pen_width = 0; + win32_gc->foreground = 0; + win32_gc->background = 1; + win32_gc->font = NULL; + win32_gc->rop2 = R2_COPYPEN; + win32_gc->fill_style = GDK_SOLID; + win32_gc->tile = NULL; + win32_gc->stipple = NULL; + win32_gc->pen_style = PS_GEOMETRIC|PS_ENDCAP_FLAT|PS_JOIN_MITER; + win32_gc->pen_width = 0; - data->values_mask = GDK_GC_FUNCTION | GDK_GC_FILL; + win32_gc->values_mask = GDK_GC_FUNCTION | GDK_GC_FILL; GDK_NOTE (MISC, g_print ("_gdk_win32_gc_new: ")); - gdk_win32_gc_values_to_win32values (values, mask, gc); + gdk_win32_gc_values_to_win32values (values, mask, win32_gc); - data->hwnd = NULL; - data->xgc = NULL; - data->hcliprgn = NULL; + win32_gc->hwnd = NULL; GDK_NOTE (MISC, g_print (" = %p\n", gc)); return gc; } -static void -gdk_win32_gc_destroy (GdkGC *gc) -{ - GdkGCWin32Data *data = GDK_GC_WIN32DATA (gc); - - if (data->clip_region) - gdk_region_destroy (data->clip_region); - - if (data->values_mask & GDK_GC_FONT) - gdk_font_unref (data->font); - - if (data->values_mask & GDK_GC_TILE) - gdk_drawable_unref (data->tile); - - if (data->values_mask & GDK_GC_STIPPLE) - gdk_drawable_unref (data->stipple); - - g_free (GDK_GC_WIN32DATA (gc)); -} - static void gdk_win32_gc_get_values (GdkGC *gc, GdkGCValues *values) { - GdkGCPrivate *private = (GdkGCPrivate *) gc; - GdkGCWin32Data *data = GDK_GC_WIN32DATA (gc); + GdkGCWin32 *win32_gc = GDK_GC_WIN32 (gc); - values->foreground.pixel = data->foreground; - values->background.pixel = data->background; - values->font = data->font; + values->foreground.pixel = win32_gc->foreground; + values->background.pixel = win32_gc->background; + values->font = win32_gc->font; - switch (data->rop2) + switch (win32_gc->rop2) { case R2_COPYPEN: values->function = GDK_COPY; break; @@ -518,41 +558,41 @@ gdk_win32_gc_get_values (GdkGC *gc, values->function = GDK_SET; break; } - values->fill = data->fill_style; + values->fill = win32_gc->fill_style; - values->tile = data->tile; - values->stipple = data->stipple; + values->tile = win32_gc->tile; + values->stipple = win32_gc->stipple; /* Also the X11 backend always returns a NULL clip_mask */ values->clip_mask = NULL; - values->subwindow_mode = data->subwindow_mode; - values->ts_x_origin = private->ts_x_origin; - values->ts_y_origin = private->ts_y_origin; - values->clip_x_origin = private->clip_x_origin; - values->clip_y_origin = private->clip_y_origin; - values->graphics_exposures = data->graphics_exposures; - values->line_width = data->pen_width; + values->subwindow_mode = win32_gc->subwindow_mode; + values->ts_x_origin = win32_gc->parent_instance.ts_x_origin; + values->ts_y_origin = win32_gc->parent_instance.ts_y_origin; + values->clip_x_origin = win32_gc->parent_instance.clip_x_origin; + values->clip_y_origin = win32_gc->parent_instance.clip_y_origin; + values->graphics_exposures = win32_gc->graphics_exposures; + values->line_width = win32_gc->pen_width; - if (data->pen_style & PS_SOLID) + if (win32_gc->pen_style & PS_SOLID) values->line_style = GDK_LINE_SOLID; - else if (data->pen_style & PS_DASH) + else if (win32_gc->pen_style & PS_DASH) values->line_style = GDK_LINE_ON_OFF_DASH; else values->line_style = GDK_LINE_SOLID; /* PS_ENDCAP_ROUND is zero */ - if (data->pen_style & PS_ENDCAP_FLAT) + if (win32_gc->pen_style & PS_ENDCAP_FLAT) values->cap_style = GDK_CAP_BUTT; - else if (data->pen_style & PS_ENDCAP_SQUARE) + else if (win32_gc->pen_style & PS_ENDCAP_SQUARE) values->cap_style = GDK_CAP_PROJECTING; else values->cap_style = GDK_CAP_ROUND; /* PS_JOIN_ROUND is zero */ - if (data->pen_style & PS_JOIN_MITER) + if (win32_gc->pen_style & PS_JOIN_MITER) values->join_style = GDK_JOIN_MITER; - else if (data->pen_style & PS_JOIN_BEVEL) + else if (win32_gc->pen_style & PS_JOIN_BEVEL) values->join_style = GDK_JOIN_BEVEL; else values->join_style = GDK_JOIN_ROUND; @@ -563,20 +603,28 @@ gdk_win32_gc_set_values (GdkGC *gc, GdkGCValues *values, GdkGCValuesMask mask) { + g_return_if_fail (GDK_IS_GC (gc)); + GDK_NOTE (MISC, g_print ("gdk_win32_gc_set_values: ")); - gdk_win32_gc_values_to_win32values (values, mask, gc); + + gdk_win32_gc_values_to_win32values (values, mask, GDK_GC_WIN32 (gc)); } static void gdk_win32_gc_set_dashes (GdkGC *gc, - gint dash_offset, - gchar dash_list[], + gint dash_offset, + gint8 dash_list[], gint n) { - GdkGCWin32Data *data = GDK_GC_WIN32DATA (gc); + GdkGCWin32 *win32_gc; - data->pen_style &= ~(PS_STYLE_MASK); - data->pen_style |= PS_DASH; + g_return_if_fail (GDK_IS_GC (gc)); + g_return_if_fail (dash_list != NULL); + + win32_gc = GDK_GC_WIN32 (gc); + + win32_gc->pen_style &= ~(PS_STYLE_MASK); + win32_gc->pen_style |= PS_DASH; /* * Set the extended line style. This could be done by @@ -588,39 +636,39 @@ gdk_win32_gc_set_dashes (GdkGC *gc, * More workarounds for Win9x descibed at: * http://www.codeguru.com/gdi/dashed.shtml */ - if (!IS_WIN_NT (windows_version) && data->pen_width > 1) + if (!IS_WIN_NT (windows_version) && win32_gc->pen_width > 1) { GDK_NOTE (MISC, g_print ("gdk_win32_gc_set_dashes: not fully supported\n")); - data->pen_style |= PS_SOLID; + win32_gc->pen_style |= PS_SOLID; return; } - /* data->pen_style = PS_COSMETIC; ??? */ + /* win32_gc->pen_style = PS_COSMETIC; ??? */ if (2 == n) { if ((dash_list[0] == dash_list[1]) && (dash_list[0] > 2)) { - data->pen_style |= PS_DASH; + win32_gc->pen_style |= PS_DASH; GDK_NOTE (MISC, g_print("gdk_win32_gc_set_dashes: PS_DASH (%d,%d)\n", dash_list[0], dash_list[1])); } else { - data->pen_style |= PS_DOT; + win32_gc->pen_style |= PS_DOT; GDK_NOTE (MISC, g_print("gdk_win32_gc_set_dashes: PS_DOT (%d,%d)\n", dash_list[0], dash_list[1])); } } else if (4 == n) { - data->pen_style |= PS_DASHDOT; + win32_gc->pen_style |= PS_DASHDOT; GDK_NOTE (MISC, g_print("gdk_win32_gc_set_dashes: PS_DASHDOT (%d,%d,%d,%d)\n", dash_list[0], dash_list[1], dash_list[2], dash_list[3])); } else if (6 == n) { - data->pen_style |= PS_DASHDOTDOT; + win32_gc->pen_style |= PS_DASHDOTDOT; GDK_NOTE (MISC, g_print("gdk_win32_gc_set_dashes: PS_DASHDOTDOT (%d,%d,%d,%d,%d,%d)\n", dash_list[0], dash_list[1], dash_list[2], dash_list[3], @@ -628,7 +676,7 @@ gdk_win32_gc_set_dashes (GdkGC *gc, } else { - data->pen_style |= PS_DASH; + win32_gc->pen_style |= PS_DASH; GDK_NOTE (MISC, g_print("gdk_win32_gc_set_dashes: no guess for %d dashes\n", n)); } } @@ -637,100 +685,106 @@ void gdk_gc_set_clip_rectangle (GdkGC *gc, GdkRectangle *rectangle) { - GdkGCWin32Data *data; - - g_return_if_fail (gc != NULL); + GdkGCWin32 *win32_gc; - data = GDK_GC_WIN32DATA (gc); + g_return_if_fail (GDK_IS_GC (gc)); - if (data->clip_region) - gdk_region_destroy (data->clip_region); + win32_gc = GDK_GC_WIN32 (gc); + + if (win32_gc->clip_region) + gdk_region_destroy (win32_gc->clip_region); if (rectangle) { GDK_NOTE (MISC, g_print ("gdk_gc_set_clip_rectangle: (%d) %dx%d@+%d+%d\n", - data, + win32_gc, rectangle->width, rectangle->height, rectangle->x, rectangle->y)); - data->clip_region = gdk_region_rectangle (rectangle); - data->values_mask |= GDK_GC_CLIP_MASK; + win32_gc->clip_region = gdk_region_rectangle (rectangle); + win32_gc->values_mask |= GDK_GC_CLIP_MASK; } else { GDK_NOTE (MISC, g_print ("gdk_gc_set_clip_rectangle: (%d) NULL\n", - data)); - data->clip_region = NULL; - data->values_mask &= ~GDK_GC_CLIP_MASK; + win32_gc)); + win32_gc->clip_region = NULL; + win32_gc->values_mask &= ~GDK_GC_CLIP_MASK; } - data->values_mask &= ~(GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN); + win32_gc->values_mask &= ~(GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN); } void gdk_gc_set_clip_region (GdkGC *gc, GdkRegion *region) { - GdkGCPrivate *private = (GdkGCPrivate *) gc; - GdkGCWin32Data *data; + GdkGCWin32 *win32_gc; - g_return_if_fail (gc != NULL); + g_return_if_fail (GDK_IS_GC (gc)); - data = GDK_GC_WIN32DATA (gc); + win32_gc = GDK_GC_WIN32 (gc); - if (data->clip_region) - gdk_region_destroy (data->clip_region); + if (win32_gc->clip_region) + gdk_region_destroy (win32_gc->clip_region); if (region) { GDK_NOTE (MISC, g_print ("gdk_gc_set_clip_region: %d %dx%d+%d+%d\n", - data, + win32_gc, region->extents.x2 - region->extents.x1, region->extents.y2 - region->extents.y1, region->extents.x1, region->extents.y1)); - data->clip_region = gdk_region_copy (region); - data->values_mask |= GDK_GC_CLIP_MASK; + win32_gc->clip_region = gdk_region_copy (region); + win32_gc->values_mask |= GDK_GC_CLIP_MASK; } else { GDK_NOTE (MISC, g_print ("gdk_gc_set_clip_region: %d NULL\n", - data)); - data->clip_region = NULL; - data->values_mask &= ~GDK_GC_CLIP_MASK; + win32_gc)); + win32_gc->clip_region = NULL; + win32_gc->values_mask &= ~GDK_GC_CLIP_MASK; } - private->clip_x_origin = 0; - private->clip_y_origin = 0; + gc->clip_x_origin = 0; + gc->clip_y_origin = 0; - data->values_mask &= ~(GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN); + win32_gc->values_mask &= ~(GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN); } void -gdk_gc_copy (GdkGC *dst_gc, GdkGC *src_gc) +gdk_gc_copy (GdkGC *dst_gc, + GdkGC *src_gc) { - GdkGCWin32Data *dst_data = GDK_GC_WIN32DATA (dst_gc); - GdkGCWin32Data *src_data = GDK_GC_WIN32DATA (src_gc); + GdkGCWin32 *dst_data; + GdkGCWin32 *src_data; DWORD nbytes; LPRGNDATA rgn; - if (dst_data->font != NULL) - gdk_font_unref (dst_data->font); - if (dst_data->tile != NULL) - gdk_drawable_unref (dst_data->tile); - if (dst_data->stipple != NULL) - gdk_drawable_unref (dst_data->stipple); - if (dst_data->clip_region != NULL) - gdk_region_destroy (dst_data->clip_region); + g_return_if_fail (GDK_IS_GC_WIN32 (dst_gc)); + g_return_if_fail (GDK_IS_GC_WIN32 (src_gc)); - *dst_data = *src_data; + dst_win32_gc = GDK_GC_WIN32 (dst_gc); + src_win32_gc = GDK_GC_WIN32 (src_gc); - if (dst_data->clip_region != NULL) - dst_data->clip_region = gdk_region_copy (dst_data->clip_region); - if (dst_data->font != NULL) - gdk_font_ref (dst_data->font); - if (dst_data->tile != NULL) - gdk_drawable_ref (dst_data->tile); - if (dst_data->stipple != NULL) - gdk_drawable_ref (dst_data->stipple); + if (dst_win32_gc->font != NULL) + gdk_font_unref (dst_win32_gc->font); + if (dst_win32_gc->tile != NULL) + gdk_drawable_unref (dst_win32_gc->tile); + if (dst_win32_gc->stipple != NULL) + gdk_drawable_unref (dst_win32_gc->stipple); + if (dst_win32_gc->clip_region != NULL) + gdk_region_destroy (dst_win32_gc->clip_region); + + *dst_win32_gc = *src_win32_gc; + + if (dst_win32_gc->clip_region != NULL) + dst_win32_gc->clip_region = gdk_region_copy (dst_win32_gc->clip_region); + if (dst_win32_gc->font != NULL) + gdk_font_ref (dst_win32_gc->font); + if (dst_win32_gc->tile != NULL) + gdk_drawable_ref (dst_win32_gc->tile); + if (dst_win32_gc->stipple != NULL) + gdk_drawable_ref (dst_win32_gc->stipple); } static guint bitmask[9] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 }; @@ -759,7 +813,7 @@ gdk_colormap_color (GdkColormapPrivateWin32 *colormap_private, } static void -predraw_set_foreground (GdkGCPrivate *gc_private, +predraw_set_foreground (GdkGCWin32 *gc_win32, GdkColormapPrivateWin32 *colormap_private, gboolean *ok) { @@ -767,7 +821,6 @@ predraw_set_foreground (GdkGCPrivate *gc_private, LOGBRUSH logbrush; HPEN hpen; HBRUSH hbr; - GdkGCWin32Data *data = GDK_GC_WIN32DATA (gc_private); if (colormap_private == NULL) { @@ -796,31 +849,31 @@ predraw_set_foreground (GdkGCPrivate *gc_private, if ((hpal = CreatePalette ((LOGPALETTE *) &logpal)) == NULL) WIN32_GDI_FAILED ("CreatePalette"), *ok = FALSE; } - SelectPalette (data->xgc, hpal, FALSE); - RealizePalette (data->xgc); - fg = PALETTEINDEX (data->foreground); + SelectPalette (win32_gc->hdc, hpal, FALSE); + RealizePalette (win32_gc->hdc); + fg = PALETTEINDEX (win32_gc->foreground); } else if (colormap_private->xcolormap->rc_palette) { int k; - if (SelectPalette (data->xgc, colormap_private->xcolormap->palette, + if (SelectPalette (win32_gc->hdc, colormap_private->xcolormap->palette, FALSE) == NULL) WIN32_GDI_FAILED ("SelectPalette"), *ok = FALSE; if (TRUE || colormap_private->xcolormap->stale) { - if ((k = RealizePalette (data->xgc)) == GDI_ERROR) + if ((k = RealizePalette (win32_gc->hdc)) == GDI_ERROR) WIN32_GDI_FAILED ("RealizePalette"), *ok = FALSE; colormap_private->xcolormap->stale = FALSE; } #if 0 g_print ("Selected palette %#x for gc %#x, realized %d colors\n", - colormap_private->xcolormap->palette, data->xgc, k); + colormap_private->xcolormap->palette, win32_gc->hdc, k); #endif } - fg = gdk_colormap_color (colormap_private, data->foreground); + fg = gdk_colormap_color (colormap_private, win32_gc->foreground); - if (SetTextColor (data->xgc, fg) == CLR_INVALID) + if (SetTextColor (win32_gc->hdc, fg) == CLR_INVALID) WIN32_GDI_FAILED ("SetTextColor"), *ok = FALSE; /* Create and select pen and brush. */ @@ -828,21 +881,21 @@ predraw_set_foreground (GdkGCPrivate *gc_private, logbrush.lbStyle = BS_SOLID; logbrush.lbColor = fg; - if (*ok && (hpen = ExtCreatePen (data->pen_style, - (data->pen_width > 0 ? data->pen_width : 1), + if (*ok && (hpen = ExtCreatePen (win32_gc->pen_style, + (win32_gc->pen_width > 0 ? win32_gc->pen_width : 1), &logbrush, 0, NULL)) == NULL) WIN32_GDI_FAILED ("ExtCreatePen"); - if (SelectObject (data->xgc, hpen) == NULL) + if (SelectObject (win32_gc->hdc, hpen) == NULL) WIN32_GDI_FAILED ("SelectObject"), *ok = FALSE; - switch (data->fill_style) + switch (win32_gc->fill_style) { case GDK_OPAQUE_STIPPLED: - if (*ok && (hbr = CreatePatternBrush (GDK_DRAWABLE_XID (data->stipple))) == NULL) + if (*ok && (hbr = CreatePatternBrush (GDK_DRAWABLE_XID (win32_gc->stipple))) == NULL) WIN32_GDI_FAILED ("CreatePatternBrush"), *ok = FALSE; - if (*ok && !SetBrushOrgEx(data->xgc, gc_private->ts_x_origin, + if (*ok && !SetBrushOrgEx(win32_gc->hdc, gc_private->ts_x_origin, gc_private->ts_y_origin, NULL)) WIN32_GDI_FAILED ("SetBrushOrgEx"), *ok = FALSE; break; @@ -853,54 +906,52 @@ predraw_set_foreground (GdkGCPrivate *gc_private, WIN32_GDI_FAILED ("CreateSolidBrush"), *ok = FALSE; break; } - if (*ok && SelectObject (data->xgc, hbr) == NULL) + if (*ok && SelectObject (win32_gc->hdc, hbr) == NULL) WIN32_GDI_FAILED ("SelectObject"), *ok = FALSE; } void -predraw_set_background (GdkGCWin32Data *data, +predraw_set_background (GdkGCWin32 *win32_gc, GdkColormapPrivateWin32 *colormap_private, gboolean *ok) { - COLORREF bg = gdk_colormap_color (colormap_private, data->background); + COLORREF bg = gdk_colormap_color (colormap_private, win32_gc->background); - if (SetBkColor (data->xgc, bg) == CLR_INVALID) + if (SetBkColor (win32_gc->hdc, bg) == CLR_INVALID) WIN32_GDI_FAILED ("SetBkColor"), *ok = FALSE; } HDC gdk_gc_predraw (GdkDrawable *drawable, - GdkGCPrivate *gc_private, + GdkGCWin32 *win32_gc, GdkGCValuesMask usage) { - GdkDrawablePrivate *drawable_private = (GdkDrawablePrivate *) drawable; GdkColormapPrivateWin32 *colormap_private = - (GdkColormapPrivateWin32 *) drawable_private->colormap; - GdkGCWin32Data *data = GDK_GC_WIN32DATA (gc_private); + (GdkColormapPrivateWin32 *) GDK_DRAWABLE_IMPL_WIN32 (drawable)->colormap; gboolean ok = TRUE; int flag; - g_assert (data->xgc == NULL); + g_assert (win32_gc->hdc == NULL); - data->hwnd = GDK_DRAWABLE_XID (drawable); + win32_gc->hwnd = GDK_DRAWABLE_XID (drawable); if (GDK_DRAWABLE_TYPE (drawable) == GDK_DRAWABLE_PIXMAP) { - if ((data->xgc = CreateCompatibleDC (NULL)) == NULL) + if ((win32_gc->hdc = CreateCompatibleDC (NULL)) == NULL) WIN32_GDI_FAILED ("CreateCompatibleDC"), ok = FALSE; - if (ok && (data->saved_dc = SaveDC (data->xgc)) == 0) + if (ok && (win32_gc->saved_dc = SaveDC (win32_gc->hdc)) == 0) WIN32_GDI_FAILED ("SaveDC"), ok = FALSE; - if (ok && SelectObject (data->xgc, data->hwnd) == NULL) + if (ok && SelectObject (win32_gc->hdc, win32_gc->hwnd) == NULL) WIN32_GDI_FAILED ("SelectObject"), ok = FALSE; } else { - if ((data->xgc = GetDC (data->hwnd)) == NULL) + if ((win32_gc->hdc = GetDC (win32_gc->hwnd)) == NULL) WIN32_GDI_FAILED ("GetDC"); - if (ok && (data->saved_dc = SaveDC (data->xgc)) == 0) + if (ok && (win32_gc->saved_dc = SaveDC (win32_gc->hdc)) == 0) WIN32_GDI_FAILED ("SaveDC"); } @@ -909,35 +960,35 @@ gdk_gc_predraw (GdkDrawable *drawable, if (ok && (usage & GDK_GC_BACKGROUND) - && (data->values_mask & GDK_GC_BACKGROUND)) - predraw_set_background (data, colormap_private, &ok); + && (win32_gc->values_mask & GDK_GC_BACKGROUND)) + predraw_set_background (win32_gc, colormap_private, &ok); if (ok && (usage & GDK_GC_FONT)) { - if (SetBkMode (data->xgc, TRANSPARENT) == 0) + if (SetBkMode (win32_gc->hdc, TRANSPARENT) == 0) WIN32_GDI_FAILED ("SetBkMode"), ok = FALSE; - if (ok && SetTextAlign (data->xgc, TA_BASELINE) == GDI_ERROR) + if (ok && SetTextAlign (win32_gc->hdc, TA_BASELINE) == GDI_ERROR) WIN32_GDI_FAILED ("SetTextAlign"), ok = FALSE; } - if (ok && (data->values_mask & GDK_GC_FUNCTION)) - if (SetROP2 (data->xgc, data->rop2) == 0) + if (ok && (win32_gc->values_mask & GDK_GC_FUNCTION)) + if (SetROP2 (win32_gc->hdc, win32_gc->rop2) == 0) WIN32_GDI_FAILED ("SetROP2"), ok = FALSE; - if (data->values_mask & GDK_GC_CLIP_MASK) - g_assert ((data->clip_region != NULL) != (data->hcliprgn != NULL)); + if (win32_gc->values_mask & GDK_GC_CLIP_MASK) + g_assert ((win32_gc->clip_region != NULL) != (win32_gc->hcliprgn != NULL)); if (ok - && (data->values_mask & GDK_GC_CLIP_MASK) - && data->clip_region != NULL) + && (win32_gc->values_mask & GDK_GC_CLIP_MASK) + && win32_gc->clip_region != NULL) { HRGN hrgn; RGNDATA *rgndata; RECT *rect; - GdkRegionBox *boxes = data->clip_region->rects; + GdkRegionBox *boxes = win32_gc->clip_region->rects; guint nbytes = - sizeof (RGNDATAHEADER) + (sizeof (RECT) * data->clip_region->numRects); + sizeof (RGNDATAHEADER) + (sizeof (RECT) * win32_gc->clip_region->numRects); int i; rgndata = g_malloc (nbytes); @@ -947,7 +998,7 @@ gdk_gc_predraw (GdkDrawable *drawable, SetRect (&rgndata->rdh.rcBound, G_MAXSHORT, G_MAXSHORT, G_MINSHORT, G_MINSHORT); - for (i = 0; i < data->clip_region->numRects; i++) + for (i = 0; i < win32_gc->clip_region->numRects; i++) { rect = ((RECT *) rgndata->Buffer) + rgndata->rdh.nCount++; @@ -978,17 +1029,17 @@ gdk_gc_predraw (GdkDrawable *drawable, if ((hrgn = ExtCreateRegion (NULL, nbytes, rgndata)) == NULL) WIN32_API_FAILED ("ExtCreateRegion"), ok = FALSE; - if (ok && SelectClipRgn (data->xgc, hrgn) == ERROR) + if (ok && SelectClipRgn (win32_gc->hdc, hrgn) == ERROR) WIN32_API_FAILED ("SelectClipRgn"), ok = FALSE; if (hrgn != NULL) DeleteObject (hrgn); } else if (ok - && (data->values_mask & GDK_GC_CLIP_MASK) - && data->hcliprgn != NULL) + && (win32_gc->values_mask & GDK_GC_CLIP_MASK) + && win32_gc->hcliprgn != NULL) { - if (SelectClipRgn (data->xgc, data->hcliprgn) == ERROR) + if (SelectClipRgn (win32_gc->hdc, win32_gc->hcliprgn) == ERROR) WIN32_API_FAILED ("SelectClipRgn"), ok = FALSE; } @@ -1000,8 +1051,8 @@ gdk_gc_predraw (GdkDrawable *drawable, HRGN hrgn; RECT rect; - g_print ("gdk_gc_predraw: %d: %#x\n", data, data->xgc); - obj = GetCurrentObject (data->xgc, OBJ_BRUSH); + g_print ("gdk_gc_predraw: %d: %#x\n", win32_gc, win32_gc->hdc); + obj = GetCurrentObject (win32_gc->hdc, OBJ_BRUSH); GetObject (obj, sizeof (LOGBRUSH), &logbrush); g_print ("brush: style: %s color: %.06x hatch: %#x\n", (logbrush.lbStyle == BS_HOLLOW ? "HOLLOW" : @@ -1010,7 +1061,7 @@ gdk_gc_predraw (GdkDrawable *drawable, "???"))), logbrush.lbColor, logbrush.lbHatch); - obj = GetCurrentObject (data->xgc, OBJ_PEN); + obj = GetCurrentObject (win32_gc->hdc, OBJ_PEN); GetObject (obj, sizeof (EXTLOGPEN), &extlogpen); g_print ("pen: type: %s style: %s endcap: %s join: %s width: %d brush: %s\n", ((extlogpen.elpPenStyle & PS_TYPE_MASK) == @@ -1041,7 +1092,7 @@ gdk_gc_predraw (GdkDrawable *drawable, (extlogpen.elpBrushStyle == BS_PATTERN ? "PATTERN" : (extlogpen.elpBrushStyle == BS_SOLID ? "SOLID" : "???"))))))); hrgn = CreateRectRgn (0, 0, 0, 0); - if ((flag = GetClipRgn (data->xgc, hrgn)) == -1) + if ((flag = GetClipRgn (win32_gc->hdc, hrgn)) == -1) WIN32_API_FAILED ("GetClipRgn"); else if (flag == 0) g_print ("no clip region\n"); @@ -1055,50 +1106,49 @@ gdk_gc_predraw (GdkDrawable *drawable, } } - return data->xgc; + return win32_gc->hdc; } void gdk_gc_postdraw (GdkDrawable *drawable, - GdkGCPrivate *gc_private, + GdkGCWin32 *win32_gc, GdkGCValuesMask usage) { GdkDrawablePrivate *drawable_private = (GdkDrawablePrivate *) drawable; GdkColormapPrivateWin32 *colormap_private = (GdkColormapPrivateWin32 *) drawable_private->colormap; - GdkGCWin32Data *data = GDK_GC_WIN32DATA (gc_private); HGDIOBJ hpen = NULL; HGDIOBJ hbr = NULL; if (usage & GDK_GC_FOREGROUND) { - if ((hpen = GetCurrentObject (data->xgc, OBJ_PEN)) == NULL) + if ((hpen = GetCurrentObject (win32_gc->hdc, OBJ_PEN)) == NULL) WIN32_GDI_FAILED ("GetCurrentObject"); - if ((hbr = GetCurrentObject (data->xgc, OBJ_BRUSH)) == NULL) + if ((hbr = GetCurrentObject (win32_gc->hdc, OBJ_BRUSH)) == NULL) WIN32_GDI_FAILED ("GetCurrentObject"); } - if (!RestoreDC (data->xgc, data->saved_dc)) + if (!RestoreDC (win32_gc->hdc, win32_gc->saved_dc)) WIN32_GDI_FAILED ("RestoreDC"); #if 0 if (colormap_private != NULL && colormap_private->xcolormap->rc_palette && colormap_private->xcolormap->stale) { - SelectPalette (data->xgc, GetStockObject (DEFAULT_PALETTE), FALSE); + SelectPalette (win32_gc->hdc, GetStockObject (DEFAULT_PALETTE), FALSE); if (!UnrealizeObject (colormap_private->xcolormap->palette)) WIN32_GDI_FAILED ("UnrealizeObject"); } #endif if (GDK_DRAWABLE_TYPE (drawable) == GDK_DRAWABLE_PIXMAP) { - if (!DeleteDC (data->xgc)) + if (!DeleteDC (win32_gc->hdc)) WIN32_GDI_FAILED ("DeleteDC"); } else { - ReleaseDC (data->hwnd, data->xgc); + ReleaseDC (win32_gc->hwnd, win32_gc->hdc); } if (hpen != NULL) @@ -1109,7 +1159,7 @@ gdk_gc_postdraw (GdkDrawable *drawable, if (!DeleteObject (hbr)) WIN32_GDI_FAILED ("DeleteObject"); - data->xgc = NULL; + win32_gc->hdc = NULL; } HDC @@ -1117,7 +1167,7 @@ gdk_win32_hdc_get (GdkDrawable *drawable, GdkGC *gc, GdkGCValuesMask usage) { - return gdk_gc_predraw (drawable, (GdkGCPrivate *) gc, usage); + return gdk_gc_predraw (drawable, GDK_GC_WIN32 (gc), usage); } void @@ -1125,7 +1175,7 @@ gdk_win32_hdc_release (GdkDrawable *drawable, GdkGC *gc, GdkGCValuesMask usage) { - gdk_gc_postdraw (drawable, (GdkGCPrivate *) gc, usage); + gdk_gc_postdraw (drawable, GDK_GC_WIN32 (gc), usage); } /* This function originally from Jean-Edouard Lachand-Robert, and diff --git a/gdk/win32/gdkglobals-win32.c b/gdk/win32/gdkglobals-win32.c index 9f0dc1e1d3..b7734dc9d2 100644 --- a/gdk/win32/gdkglobals-win32.c +++ b/gdk/win32/gdkglobals-win32.c @@ -29,9 +29,9 @@ HWND gdk_root_window = NULL; gint gdk_event_func_from_window_proc = FALSE; -HDC gdk_DC; -HINSTANCE gdk_DLLInstance; -HINSTANCE gdk_ProgInstance; +HDC gdk_display_hdc; +HINSTANCE gdk_dll_hinstance; +HINSTANCE gdk_app_hmodule; /* Works as a HMODULE, too? */ UINT gdk_selection_notify_msg; UINT gdk_selection_request_msg; UINT gdk_selection_clear_msg; @@ -40,5 +40,4 @@ GdkAtom gdk_win32_dropfiles_atom; GdkAtom gdk_ole2_dnd_atom; ATOM gdk_selection_property; gint gdk_null_window_warnings = TRUE; - DWORD windows_version = 0; diff --git a/gdk/win32/gdkimage-win32.c b/gdk/win32/gdkimage-win32.c index 0cdae6a242..1c8c3b5492 100644 --- a/gdk/win32/gdkimage-win32.c +++ b/gdk/win32/gdkimage-win32.c @@ -107,7 +107,10 @@ gdk_image_exit (void) } GdkImage * -gdk_image_new_bitmap (GdkVisual *visual, gpointer data, gint w, gint h) +gdk_image_new_bitmap (GdkVisual *visual, + gpointer data, + gint w, + gint h) /* * Desc: create a new bitmap image */ @@ -162,7 +165,7 @@ gdk_image_new_bitmap (GdkVisual *visual, gpointer data, gint w, gint h) bmi.u.bmiColors[1].rgbRed = 0xFF; bmi.u.bmiColors[1].rgbReserved = 0x00; - private->ximage = CreateDIBSection (gdk_DC, (BITMAPINFO *) &bmi, + private->ximage = CreateDIBSection (gdk_display_hdc, (BITMAPINFO *) &bmi, DIB_RGB_COLORS, &bits, NULL, 0); if (bpl != bpl32) { @@ -284,7 +287,7 @@ gdk_image_new_with_depth (GdkImageType type, } private->ximage = - CreateDIBSection (gdk_DC, (BITMAPINFO *) &bmi, iUsage, + CreateDIBSection (gdk_display_hdc, (BITMAPINFO *) &bmi, iUsage, &image->mem, NULL, 0); if (private->ximage == NULL) @@ -587,8 +590,8 @@ gdk_image_get (GdkWindow *window, guint32 gdk_image_get_pixel (GdkImage *image, - gint x, - gint y) + gint x, + gint y) { guint32 pixel; @@ -629,9 +632,9 @@ gdk_image_get_pixel (GdkImage *image, void gdk_image_put_pixel (GdkImage *image, - gint x, - gint y, - guint32 pixel) + gint x, + gint y, + guint32 pixel) { g_return_if_fail (image != NULL); @@ -701,107 +704,3 @@ gdk_win32_image_destroy (GdkImage *image) g_free (private); } -static void -gdk_image_put (GdkImage *image, - GdkDrawable *drawable, - GdkGC *gc, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height) -{ - GdkDrawablePrivate *drawable_private; - GdkImagePrivateWin32 *image_private; - GdkGCPrivate *gc_private; - HDC hdc; - GdkColormapPrivateWin32 *colormap_private; - - g_return_if_fail (drawable != NULL); - g_return_if_fail (image != NULL); - g_return_if_fail (gc != NULL); - - if (GDK_DRAWABLE_DESTROYED (drawable)) - return; - image_private = (GdkImagePrivateWin32 *) image; - drawable_private = (GdkDrawablePrivate *) drawable; - gc_private = (GdkGCPrivate *) gc; - - hdc = gdk_gc_predraw (drawable, gc_private, 0); - colormap_private = (GdkColormapPrivateWin32 *) drawable_private->colormap; - if (colormap_private && colormap_private->xcolormap->rc_palette) - { - DIBSECTION ds; - static struct { - BITMAPINFOHEADER bmiHeader; - WORD bmiIndices[256]; - } bmi; - static gboolean bmi_inited = FALSE; - int i; - - if (!bmi_inited) - { - for (i = 0; i < 256; i++) - bmi.bmiIndices[i] = i; - bmi_inited = TRUE; - } - - if (GetObject (image_private->ximage, sizeof (DIBSECTION), - &ds) != sizeof (DIBSECTION)) - { - WIN32_GDI_FAILED ("GetObject"); - } -#if 0 - g_print("xdest = %d, ydest = %d, xsrc = %d, ysrc = %d, width = %d, height = %d\n", - xdest, ydest, xsrc, ysrc, width, height); - g_print("bmWidth = %d, bmHeight = %d, bmBitsPixel = %d, bmBits = %p\n", - ds.dsBm.bmWidth, ds.dsBm.bmHeight, ds.dsBm.bmBitsPixel, ds.dsBm.bmBits); - g_print("biWidth = %d, biHeight = %d, biBitCount = %d, biClrUsed = %d\n", - ds.dsBmih.biWidth, ds.dsBmih.biHeight, ds.dsBmih.biBitCount, ds.dsBmih.biClrUsed); -#endif - bmi.bmiHeader = ds.dsBmih; - /* I have spent hours on getting the parameters to - * SetDIBitsToDevice right. I wonder what drugs the guys in - * Redmond were on when they designed this API. - */ - if (SetDIBitsToDevice (hdc, - xdest, ydest, - width, height, - xsrc, (-ds.dsBmih.biHeight)-height-ysrc, - 0, -ds.dsBmih.biHeight, - ds.dsBm.bmBits, - (CONST BITMAPINFO *) &bmi, - DIB_PAL_COLORS) == 0) - WIN32_GDI_FAILED ("SetDIBitsToDevice"); - } - else - { - HDC memdc; - HGDIOBJ oldbitmap; - - if ((memdc = CreateCompatibleDC (hdc)) == NULL) - { - WIN32_GDI_FAILED ("CreateCompatibleDC"); - gdk_gc_postdraw (drawable, gc_private, 0); - return; - } - - if ((oldbitmap = SelectObject (memdc, image_private->ximage)) == NULL) - { - WIN32_GDI_FAILED ("SelectObject"); - gdk_gc_postdraw (drawable, gc_private, 0); - return; - } - if (!BitBlt (hdc, xdest, ydest, width, height, - memdc, xsrc, ysrc, SRCCOPY)) - WIN32_GDI_FAILED ("BitBlt"); - - if (SelectObject (memdc, oldbitmap) == NULL) - WIN32_GDI_FAILED ("SelectObject"); - - if (!DeleteDC (memdc)) - WIN32_GDI_FAILED ("DeleteDC"); - } - gdk_gc_postdraw (drawable, gc_private, 0); -} diff --git a/gdk/win32/gdkmain-win32.c b/gdk/win32/gdkmain-win32.c index 8b9e9695ae..ff2b872311 100644 --- a/gdk/win32/gdkmain-win32.c +++ b/gdk/win32/gdkmain-win32.c @@ -57,10 +57,10 @@ GdkArgDesc _gdk_windowing_args[] = { int __stdcall DllMain(HINSTANCE hinstDLL, - DWORD dwReason, - LPVOID reserved) + DWORD dwReason, + LPVOID reserved) { - gdk_DLLInstance = hinstDLL; + gdk_dll_hinstance = hinstDLL; return TRUE; } @@ -80,8 +80,8 @@ _gdk_windowing_init_check (int argc, if (gdk_synchronize) GdiSetBatchLimit (1); - gdk_ProgInstance = GetModuleHandle (NULL); - gdk_DC = CreateDC ("DISPLAY", NULL, NULL, NULL); + gdk_app_hmodule = GetModuleHandle (NULL); + gdk_display_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL); gdk_root_window = GetDesktopWindow (); windows_version = GetVersion (); @@ -205,7 +205,7 @@ gdk_screen_height (void) gint gdk_screen_width_mm (void) { - return GetDeviceCaps (gdk_DC, HORZSIZE); + return GetDeviceCaps (gdk_display_hdc, HORZSIZE); } /* @@ -226,7 +226,7 @@ gdk_screen_width_mm (void) gint gdk_screen_height_mm (void) { - return GetDeviceCaps (gdk_DC, VERTSIZE); + return GetDeviceCaps (gdk_display_hdc, VERTSIZE); } void @@ -258,8 +258,8 @@ gdk_windowing_exit (void) { gdk_win32_dnd_exit (); CoUninitialize (); - DeleteDC (gdk_DC); - gdk_DC = NULL; + DeleteDC (gdk_display_hdc); + gdk_display_hdc = NULL; } gchar * diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h index c0f872e98c..759b6775ce 100644 --- a/gdk/win32/gdkprivate-win32.h +++ b/gdk/win32/gdkprivate-win32.h @@ -93,7 +93,7 @@ void gdk_win32_api_failed (const gchar *where, #define OTHER_API_FAILED(api) gdk_other_api_failed (__FILE__, __LINE__, api) #endif -extern LRESULT CALLBACK gdk_WindowProc (HWND, UINT, WPARAM, LPARAM); +extern LRESULT CALLBACK gdk_window_procedure (HWND, UINT, WPARAM, LPARAM); extern GdkDrawableClass _gdk_win32_drawable_class; extern HWND gdk_root_window; @@ -101,7 +101,7 @@ extern gboolean gdk_event_func_from_window_proc; extern HDC gdk_display_hdc; extern HINSTANCE gdk_dll_hinstance; -extern HINSTANCE gdk_app_hinstance; +extern HINSTANCE gdk_app_hmodule; extern UINT gdk_selection_notify_msg; extern UINT gdk_selection_request_msg; diff --git a/gdk/win32/gdkvisual-win32.c b/gdk/win32/gdkvisual-win32.c index acc47b79b1..21fd6af163 100644 --- a/gdk/win32/gdkvisual-win32.c +++ b/gdk/win32/gdkvisual-win32.c @@ -39,20 +39,6 @@ static gint available_depths[1]; static GdkVisualType available_types[1]; -#ifdef G_ENABLE_DEBUG - -static const gchar* visual_names[] = -{ - "static gray", - "grayscale", - "static color", - "pseudo color", - "true color", - "direct color", -}; - -#endif /* G_ENABLE_DEBUG */ - void gdk_visual_init (void) { @@ -71,8 +57,8 @@ gdk_visual_init (void) system_visual = g_new (GdkVisualPrivate, 1); - bitspixel = GetDeviceCaps (gdk_DC, BITSPIXEL); - rastercaps = GetDeviceCaps (gdk_DC, RASTERCAPS); + bitspixel = GetDeviceCaps (gdk_display_hdc, BITSPIXEL); + rastercaps = GetDeviceCaps (gdk_display_hdc, RASTERCAPS); system_visual->xvisual = g_new (Visual, 1); system_visual->xvisual->visualid = 0; system_visual->xvisual->bitspixel = bitspixel; @@ -80,8 +66,8 @@ gdk_visual_init (void) if (rastercaps & RC_PALETTE) { system_visual->visual.type = GDK_VISUAL_PSEUDO_COLOR; - numcolors = GetDeviceCaps (gdk_DC, NUMCOLORS); - sizepalette = GetDeviceCaps (gdk_DC, SIZEPALETTE); + numcolors = GetDeviceCaps (gdk_display_hdc, NUMCOLORS); + sizepalette = GetDeviceCaps (gdk_display_hdc, SIZEPALETTE); system_visual->xvisual->map_entries = sizepalette; } else if (bitspixel == 1) @@ -109,10 +95,10 @@ gdk_visual_init (void) memset (&bmi, 0, sizeof (bmi)); bmi.bi.biSize = sizeof (bmi.bi); - hbm = CreateCompatibleBitmap (gdk_DC, 1, 1); - GetDIBits (gdk_DC, hbm, 0, 1, NULL, + hbm = CreateCompatibleBitmap (gdk_display_hdc, 1, 1); + GetDIBits (gdk_display_hdc, hbm, 0, 1, NULL, (BITMAPINFO *) &bmi, DIB_RGB_COLORS); - GetDIBits (gdk_DC, hbm, 0, 1, NULL, + GetDIBits (gdk_display_hdc, hbm, 0, 1, NULL, (BITMAPINFO *) &bmi, DIB_RGB_COLORS); DeleteObject (hbm); diff --git a/gdk/win32/gdkwin32.h b/gdk/win32/gdkwin32.h index fa2ad74dd7..cb06d284b2 100644 --- a/gdk/win32/gdkwin32.h +++ b/gdk/win32/gdkwin32.h @@ -235,7 +235,7 @@ struct _GdkColormapPrivateWin32 struct _GdkImagePrivateWin32 { - HBITMAP ximage; + HBITMAP hbitmap; }; typedef struct _GdkGCWin32 GdkGCWin32; @@ -260,7 +260,7 @@ struct _GdkGCWin32 * window or pixmap. We thus keep all the necessary values in the * GdkGCWin32 object. */ - HDC xgc; + HDC hdc; GdkRegion *clip_region; HRGN hcliprgn; @@ -295,9 +295,9 @@ GType gdk_gc_win32_get_type (void); #define GDK_ROOT_WINDOW() ((guint32) HWND_DESKTOP) #define GDK_ROOT_PARENT() ((GdkWindow *) gdk_parent_root) #define GDK_DISPLAY() NULL -#define GDK_WINDOW_HWND(win) (GDK_DRAWABLE_IMPL_WIN32(((GdkWindowObject *)win)->impl)->handle) -#define GDK_PIXMAP_HBM(win) (GDK_DRAWABLE_IMPL_WIN32(((GdkPixmapObject *)win)->impl)->handle) -#define GDK_DRAWABLE_HANDLE(win) (GDK_IS_WINDOW (win) ? GDK_WINDOW_HWND (win) : GDK_PIXMAP_HBM (win)) +#define GDK_WINDOW_HWND(win) (HWND) (GDK_DRAWABLE_IMPL_WIN32(((GdkWindowObject *)win)->impl)->handle) +#define GDK_PIXMAP_HBITMAP(win) (HBITMAP) (GDK_DRAWABLE_IMPL_WIN32(((GdkPixmapObject *)win)->impl)->handle) +#define GDK_DRAWABLE_HANDLE(win) (GDK_IS_WINDOW (win) ? ((HGDIOBJ) GDK_WINDOW_HWND (win)) : ((HGDIOBJ) GDK_PIXMAP_HBITMAP (win))) #define GDK_IMAGE_HBM(image) (((GdkImagePrivateWin32 *) GDK_IMAGE (image)->windowing_data)->hbm) #define GDK_COLORMAP_WIN32COLORMAP(cmap) (((GdkColormapPrivateWin32 *)GDK_COLORMAP (cmap)->windowing_data)->xcolormap) #define GDK_VISUAL_XVISUAL(vis) (((GdkVisualPrivate *) vis)->xvisual) @@ -310,23 +310,23 @@ GdkPixmap *gdk_pixmap_foreign_new (guint32 anid); GdkWindow *gdk_window_foreign_new (guint32 anid); /* Return the Gdk* for a particular HANDLE */ -gpointer gdk_xid_table_lookup (HANDLE handle); +gpointer gdk_xid_table_lookup (HANDLE handle); /* Return a device context to draw in a drawable, given a GDK GC, * and a mask indicating which GC values might be used (for efficiency, * no need to muck around with text-related stuff if we aren't going * to output text, for instance). */ -HDC gdk_win32_hdc_get (GdkDrawable *drawable, - GdkGC *gc, - GdkGCValuesMask usage); +HDC gdk_win32_hdc_get (GdkDrawable *drawable, + GdkGC *gc, + GdkGCValuesMask usage); /* Each HDC returned from gdk_win32_hdc_get must be released with * this function */ -void gdk_win32_hdc_release (GdkDrawable *drawable, - GdkGC *gc, - GdkGCValuesMask usage); +void gdk_win32_hdc_release (GdkDrawable *drawable, + GdkGC *gc, + GdkGCValuesMask usage); #ifdef __cplusplus } diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index c60140480f..919bde2e69 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -178,24 +178,24 @@ RegisterGdkClass (GdkDrawableType wtype) wcl.style = 0; /* DON'T set CS_REDRAW. It causes total redraw * on WM_SIZE and WM_MOVE. Flicker, Performance! */ - wcl.lpfnWndProc = gdk_WindowProc; + wcl.lpfnWndProc = gdk_window_procedure; wcl.cbClsExtra = 0; wcl.cbWndExtra = 0; - wcl.hInstance = gdk_ProgInstance; + wcl.hInstance = gdk_app_hmodule; wcl.hIcon = 0; /* initialize once! */ if (0 == hAppIcon) { gchar sLoc [_MAX_PATH+1]; - if (0 != GetModuleFileName(gdk_ProgInstance, sLoc, _MAX_PATH)) + if (0 != GetModuleFileName (gdk_app_hmodule, sLoc, _MAX_PATH)) { - hAppIcon = ExtractIcon(gdk_ProgInstance, sLoc, 0); + hAppIcon = ExtractIcon (gdk_app_hmodule, sLoc, 0); if (0 == hAppIcon) { char *gdklibname = g_strdup_printf ("gdk-%s.dll", GDK_VERSION); - hAppIcon = ExtractIcon(gdk_ProgInstance, gdklibname, 0); + hAppIcon = ExtractIcon (gdk_app_hmodule, gdklibname, 0); g_free (gdklibname); } @@ -211,7 +211,7 @@ RegisterGdkClass (GdkDrawableType wtype) #define ONCE_PER_CLASS() \ wcl.hIcon = CopyIcon (hAppIcon); \ wcl.hIconSm = CopyIcon (hAppIcon); \ - wcl.hbrBackground = CreateSolidBrush( RGB(0,0,0)); \ + wcl.hbrBackground = CreateSolidBrush (RGB (0,0,0)); \ wcl.hCursor = LoadCursor (NULL, IDC_ARROW); switch (wtype) @@ -222,7 +222,7 @@ RegisterGdkClass (GdkDrawableType wtype) wcl.lpszClassName = "gdkWindowToplevel"; ONCE_PER_CLASS(); - klassTOPLEVEL = RegisterClassEx(&wcl); + klassTOPLEVEL = RegisterClassEx (&wcl); } klass = klassTOPLEVEL; break; @@ -233,7 +233,7 @@ RegisterGdkClass (GdkDrawableType wtype) wcl.style |= CS_PARENTDC; /* MSDN: ... enhances system performance. */ ONCE_PER_CLASS(); - klassCHILD = RegisterClassEx(&wcl); + klassCHILD = RegisterClassEx (&wcl); } klass = klassCHILD; break; @@ -243,7 +243,7 @@ RegisterGdkClass (GdkDrawableType wtype) wcl.lpszClassName = "gdkWindowDialog"; wcl.style |= CS_SAVEBITS; ONCE_PER_CLASS(); - klassDIALOG = RegisterClassEx(&wcl); + klassDIALOG = RegisterClassEx (&wcl); } klass = klassDIALOG; break; @@ -253,7 +253,7 @@ RegisterGdkClass (GdkDrawableType wtype) wcl.lpszClassName = "gdkWindowTemp"; wcl.style |= CS_SAVEBITS; ONCE_PER_CLASS(); - klassTEMP = RegisterClassEx(&wcl); + klassTEMP = RegisterClassEx (&wcl); } klass = klassTEMP; break; @@ -449,7 +449,7 @@ gdk_window_new (GdkWindow *parent, width, height, xparent, NULL, - gdk_ProgInstance, + gdk_app_hmodule, NULL); GDK_NOTE (MISC,