From eec6970fe2c427075cfc00e2835a8f3152868e07 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 17 Nov 1999 00:45:37 +0000 Subject: [PATCH] Intermediate commit. I go to bed now. --- gdk/win32/gdkcolor-win32.c | 151 ++++--- gdk/win32/gdkcursor-win32.c | 7 +- gdk/win32/gdkdnd-win32.c | 18 +- gdk/win32/gdkdrawable-win32.c | 576 +++++++++---------------- gdk/win32/gdkevents-win32.c | 773 ++++++---------------------------- gdk/win32/gdkgc-win32.c | 18 +- gdk/win32/gdkinput-win32.c | 5 +- gdk/win32/gdkprivate-win32.h | 355 +++++----------- gdk/win32/gdkwin32.h | 7 +- gdk/win32/gdkwindow-win32.c | 1 + 10 files changed, 546 insertions(+), 1365 deletions(-) diff --git a/gdk/win32/gdkcolor-win32.c b/gdk/win32/gdkcolor-win32.c index 438cd820db..4709fac225 100644 --- a/gdk/win32/gdkcolor-win32.c +++ b/gdk/win32/gdkcolor-win32.c @@ -293,10 +293,10 @@ alloc_color(Colormap colormap, */ static void -XFreeColors(Colormap colormap, - gulong *pixels, - gint npixels, - gulong planes) +free_colors (Colormap colormap, + gulong *pixels, + gint npixels, + gulong planes) { gint i; PALETTEENTRY entries[256]; @@ -329,11 +329,11 @@ XFreeColors(Colormap colormap, if (SetPaletteEntries (colormap->palette, lowestpixel, highestpixel - lowestpixel + 1, entries + lowestpixel) == 0) - g_warning ("XFreeColors: SetPaletteEntries failed"); + g_warning ("free_colors: SetPaletteEntries failed"); #endif colormap->stale = TRUE; #if 0 - g_print("XFreeColors %#x lowestpixel = %d, highestpixel = %d\n", + g_print("free_colors %#x lowestpixel = %d, highestpixel = %d\n", colormap->palette, lowestpixel, highestpixel); #endif } @@ -358,7 +358,7 @@ XFreeColors(Colormap colormap, static Colormap create_colormap (HWND w, Visual *visual, - int alloc) + gboolean alloc) { char logPalBuf[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)]; LOGPALETTE *logPalettePtr; @@ -420,7 +420,7 @@ create_colormap (HWND w, */ static void -XFreeColormap(Colormap colormap) +free_colormap(Colormap colormap) { if (!DeleteObject (colormap->palette)) @@ -1304,7 +1304,7 @@ parse_color(Colormap map, /* End of code from Tk8.0 */ static Colormap -DefaultColormap () +default_colormap () { static Colormap colormap; gint i; @@ -1312,7 +1312,7 @@ DefaultColormap () if (colormap) return colormap; - colormap = create_colormap ( NULL, NULL, AllocNone); + colormap = create_colormap ( NULL, NULL, FALSE); return colormap; } @@ -1321,18 +1321,18 @@ gdk_colormap_new (GdkVisual *visual, gint private_cmap) { GdkColormap *colormap; - GdkColormapPrivate *private; + GdkColormapPrivateWin32 *private; Visual *xvisual; int size; - unsigned int i; + int i; g_return_val_if_fail (visual != NULL, NULL); - private = g_new (GdkColormapPrivate, 1); + private = g_new (GdkColormapPrivateWin32, 1); colormap = (GdkColormap*) private; - private->visual = visual; - private->ref_count = 1; + private->base.visual = visual; + private->base.ref_count = 1; private->hash = NULL; private->last_sync_time = 0; @@ -1354,7 +1354,7 @@ gdk_colormap_new (GdkVisual *visual, private->private_val = private_cmap; private->xcolormap = create_colormap (gdk_root_window, xvisual, - (private_cmap) ? (AllocAll) : (AllocNone)); + private_cmap); if (private_cmap) { @@ -1387,7 +1387,7 @@ gdk_colormap_new (GdkVisual *visual, case GDK_VISUAL_TRUE_COLOR: private->private_val = FALSE; private->xcolormap = create_colormap (gdk_root_window, - xvisual, AllocNone); + xvisual, FALSE); break; } @@ -1399,13 +1399,13 @@ gdk_colormap_new (GdkVisual *visual, void _gdk_colormap_real_destroy (GdkColormap *colormap) { - GdkColormapPrivate *private = (GdkColormapPrivate*) colormap; + GdkColormapPrivateWin32 *private = (GdkColormapPrivateWin32 *) colormap; g_return_if_fail (colormap != NULL); - g_return_if_fail (private->ref_count == 0); + g_return_if_fail (private->base.ref_count == 0); gdk_colormap_remove (colormap); - XFreeColormap (private->xcolormap); + free_colormap (private->xcolormap); if (private->hash) g_hash_table_destroy (private->hash); @@ -1422,7 +1422,7 @@ gdk_colormap_sync (GdkColormap *colormap, gboolean force) { time_t current_time; - GdkColormapPrivate *private = (GdkColormapPrivate *)colormap; + GdkColormapPrivateWin32 *private = (GdkColormapPrivateWin32 *) colormap; XColor *xpalette; gint nlookup; gint i; @@ -1460,33 +1460,32 @@ gdk_colormap_sync (GdkColormap *colormap, g_free (xpalette); } - GdkColormap* gdk_colormap_get_system (void) { static GdkColormap *colormap = NULL; - GdkColormapPrivate *private; + GdkColormapPrivateWin32 *private; gint i; if (!colormap) { - private = g_new (GdkColormapPrivate, 1); + private = g_new (GdkColormapPrivateWin32, 1); colormap = (GdkColormap*) private; - private->xcolormap = DefaultColormap (); - private->visual = gdk_visual_get_system (); + private->xcolormap = default_colormap (); + private->base.visual = gdk_visual_get_system (); private->private_val = FALSE; - private->ref_count = 1; + private->base.ref_count = 1; private->hash = NULL; private->last_sync_time = 0; private->info = NULL; colormap->colors = NULL; - colormap->size = private->visual->colormap_size; + colormap->size = private->base.visual->colormap_size; - if ((private->visual->type == GDK_VISUAL_GRAYSCALE) || - (private->visual->type == GDK_VISUAL_PSEUDO_COLOR)) + if ((private->base.visual->type == GDK_VISUAL_GRAYSCALE) || + (private->base.visual->type == GDK_VISUAL_PSEUDO_COLOR)) { private->info = g_new0 (GdkColorInfo, colormap->size); colormap->colors = g_new (GdkColor, colormap->size); @@ -1527,7 +1526,7 @@ void gdk_colormap_change (GdkColormap *colormap, gint ncolors) { - GdkColormapPrivate *private; + GdkColormapPrivateWin32 *private; GdkVisual *visual; XColor *palette; gint shift; @@ -1539,8 +1538,8 @@ gdk_colormap_change (GdkColormap *colormap, palette = g_new (XColor, ncolors); - private = (GdkColormapPrivate*) colormap; - switch (private->visual->type) + private = (GdkColormapPrivateWin32 *) colormap; + switch (private->base.visual->type) { case GDK_VISUAL_GRAYSCALE: case GDK_VISUAL_PSEUDO_COLOR: @@ -1573,13 +1572,13 @@ gdk_colors_alloc (GdkColormap *colormap, gulong *pixels, gint npixels) { - GdkColormapPrivate *private; + GdkColormapPrivateWin32 *private; gint return_val; gint i; g_return_val_if_fail (colormap != NULL, 0); - private = (GdkColormapPrivate*) colormap; + private = (GdkColormapPrivateWin32 *) colormap; return_val = alloc_color_cells (private->xcolormap, contiguous, planes, nplanes, pixels, npixels); @@ -1593,7 +1592,7 @@ gdk_colors_alloc (GdkColormap *colormap, } } - return return_val; + return return_val != 0; } gboolean @@ -1602,19 +1601,13 @@ gdk_color_parse (const gchar *spec, { Colormap xcolormap; XColor xcolor; - gboolean return_val; g_return_val_if_fail (spec != NULL, FALSE); g_return_val_if_fail (color != NULL, FALSE); - xcolormap = DefaultColormap (); + xcolormap = default_colormap (); - if (parse_color (xcolormap, spec, color)) - return_val = TRUE; - else - return_val = FALSE; - - return return_val; + return parse_color (xcolormap, spec, color); } /* This is almost identical to gdk_colormap_free_colors. @@ -1626,7 +1619,7 @@ gdk_colors_free (GdkColormap *colormap, gint in_npixels, gulong planes) { - GdkColormapPrivate *private; + GdkColormapPrivateWin32 *private; gulong *pixels; gint npixels = 0; gint i; @@ -1634,10 +1627,10 @@ gdk_colors_free (GdkColormap *colormap, g_return_if_fail (colormap != NULL); g_return_if_fail (in_pixels != NULL); - private = (GdkColormapPrivate*) colormap; + private = (GdkColormapPrivateWin32 *) colormap; - if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) && - (private->visual->type != GDK_VISUAL_GRAYSCALE)) + if ((private->base.visual->type != GDK_VISUAL_PSEUDO_COLOR) && + (private->base.visual->type != GDK_VISUAL_GRAYSCALE)) return; pixels = g_new (gulong, in_npixels); @@ -1654,15 +1647,14 @@ gdk_colors_free (GdkColormap *colormap, { pixels[npixels++] = pixel; if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE)) - g_hash_table_remove (private->hash, &colormap->colors[in_pixels[i]]); + g_hash_table_remove (private->hash, &colormap->colors[pixel]); private->info[pixel].flags = 0; } } } - if (npixels) - XFreeColors (private->xcolormap, pixels, npixels, planes); + free_colors (private->xcolormap, pixels, npixels, planes); g_free (pixels); } @@ -1675,7 +1667,7 @@ gdk_colormap_free_colors (GdkColormap *colormap, GdkColor *colors, gint ncolors) { - GdkColormapPrivate *private; + GdkColormapPrivateWin32 *private; gulong *pixels; gint npixels = 0; gint i; @@ -1683,10 +1675,10 @@ gdk_colormap_free_colors (GdkColormap *colormap, g_return_if_fail (colormap != NULL); g_return_if_fail (colors != NULL); - private = (GdkColormapPrivate*) colormap; + private = (GdkColormapPrivateWin32 *) colormap; - if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) && - (private->visual->type != GDK_VISUAL_GRAYSCALE)) + if ((private->base.visual->type != GDK_VISUAL_PSEUDO_COLOR) && + (private->base.visual->type != GDK_VISUAL_GRAYSCALE)) return; pixels = g_new (gulong, ncolors); @@ -1703,13 +1695,13 @@ gdk_colormap_free_colors (GdkColormap *colormap, { pixels[npixels++] = pixel; if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE)) - g_hash_table_remove (private->hash, &colors[i]); + g_hash_table_remove (private->hash, &colormap->colors[pixel]); private->info[pixel].flags = 0; } } } if (npixels) - XFreeColors (private->xcolormap, pixels, npixels, 0); + free_colors (private->xcolormap, pixels, npixels, 0); g_free (pixels); } @@ -1725,10 +1717,10 @@ gdk_colormap_alloc1 (GdkColormap *colormap, GdkColor *color, GdkColor *ret) { - GdkColormapPrivate *private; + GdkColormapPrivateWin32 *private; XColor xcolor; - private = (GdkColormapPrivate*) colormap; + private = (GdkColormapPrivateWin32 *) colormap; xcolor.peRed = color->red >> 8; xcolor.peGreen = color->green >> 8; @@ -1772,12 +1764,12 @@ gdk_colormap_alloc_colors_writeable (GdkColormap *colormap, gboolean best_match, gboolean *success) { - GdkColormapPrivate *private; + GdkColormapPrivateWin32 *private; gulong *pixels; Status status; gint i, index; - private = (GdkColormapPrivate*) colormap; + private = (GdkColormapPrivateWin32 *) colormap; if (private->private_val) { @@ -1802,8 +1794,8 @@ gdk_colormap_alloc_colors_writeable (GdkColormap *colormap, else { pixels = g_new (gulong, ncolors); - /* Allocation of a writeable color cells */ + status = alloc_color_cells (private->xcolormap, FALSE, NULL, 0, pixels, ncolors); if (status) @@ -1830,13 +1822,13 @@ gdk_colormap_alloc_colors_private (GdkColormap *colormap, gboolean best_match, gboolean *success) { - GdkColormapPrivate *private; + GdkColormapPrivateWin32 *private; gint i, index; XColor *store = g_new (XColor, ncolors); gint nstore = 0; gint nremaining = 0; - private = (GdkColormapPrivate*) colormap; + private = (GdkColormapPrivateWin32 *) colormap; index = -1; /* First, store the colors we have room for */ @@ -1892,6 +1884,7 @@ gdk_colormap_alloc_colors_private (GdkColormap *colormap, { colors[i] = colormap->colors[index]; private->info[index].ref_count++; + success[i] = TRUE; nremaining--; } @@ -1911,12 +1904,12 @@ gdk_colormap_alloc_colors_shared (GdkColormap *colormap, gboolean best_match, gboolean *success) { - GdkColormapPrivate *private; + GdkColormapPrivateWin32 *private; gint i, index; gint nremaining = 0; gint nfailed = 0; - private = (GdkColormapPrivate*) colormap; + private = (GdkColormapPrivateWin32 *) colormap; index = -1; for (i=0; ivisual->type) + switch (private->base.visual->type) { case GDK_VISUAL_PSEUDO_COLOR: case GDK_VISUAL_GRAYSCALE: @@ -2079,7 +2072,7 @@ gdk_colormap_alloc_colors (GdkColormap *colormap, break; case GDK_VISUAL_TRUE_COLOR: - visual = private->visual; + visual = private->base.visual; for (i=0; ired >> 8; xcolor.peGreen = color->green >> 8; @@ -2184,13 +2177,13 @@ gdk_colormap_lookup (Colormap xcolormap) static void gdk_colormap_add (GdkColormap *cmap) { - GdkColormapPrivate *private; + GdkColormapPrivateWin32 *private; if (!colormap_hash) colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash, (GCompareFunc) gdk_colormap_cmp); - private = (GdkColormapPrivate*) cmap; + private = (GdkColormapPrivateWin32 *) cmap; g_hash_table_insert (colormap_hash, &private->xcolormap, cmap); } @@ -2198,13 +2191,13 @@ gdk_colormap_add (GdkColormap *cmap) static void gdk_colormap_remove (GdkColormap *cmap) { - GdkColormapPrivate *private; + GdkColormapPrivateWin32 *private; if (!colormap_hash) colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash, (GCompareFunc) gdk_colormap_cmp); - private = (GdkColormapPrivate*) cmap; + private = (GdkColormapPrivateWin32 *) cmap; g_hash_table_remove (colormap_hash, &private->xcolormap); } @@ -2223,7 +2216,7 @@ gdk_colormap_cmp (Colormap *a, } char * -gdk_color_to_string (GdkColor *color) +gdk_color_to_string (const GdkColor *color) { static char buf[100]; diff --git a/gdk/win32/gdkcursor-win32.c b/gdk/win32/gdkcursor-win32.c index 78623a25f2..8f9c07c126 100644 --- a/gdk/win32/gdkcursor-win32.c +++ b/gdk/win32/gdkcursor-win32.c @@ -20,7 +20,7 @@ #include "config.h" #include "gdkcursor.h" -#include "gdkprivate.h" +#include "gdkwin32.h" static const struct { const char *name; int type; } cursors[] = { { "x_cursor", 0 }, @@ -109,7 +109,6 @@ gdk_cursor_new (GdkCursorType cursor_type) GdkCursorPrivate *private; GdkCursor *cursor; HCURSOR xcursor; - int i; for (i = 0; cursors[i].name != NULL && cursors[i].type != cursor_type; i++) @@ -235,9 +234,9 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source, GDK_NOTE (MISC, g_print ("gdk_cursor_new_from_pixmap: " "%#x (%dx%d) %#x (%dx%d) = %#x (%dx%d)\n", - source_private->xwindow, + GDK_DRAWABLE_XID (source), source_private->width, source_private->height, - mask_private->xwindow, + GDK_DRAWABLE_XID (mask), mask_private->width, mask_private->height, xcursor, cursor_width, cursor_height)); diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c index da6da4bb5e..7c486767cd 100644 --- a/gdk/win32/gdkdnd-win32.c +++ b/gdk/win32/gdkdnd-win32.c @@ -36,7 +36,7 @@ #include "gdkdnd.h" #include "gdkproperty.h" #include "gdkprivate.h" -#include "gdkx.h" +#include "gdkwin32.h" #ifdef OLE2_DND #include @@ -671,7 +671,7 @@ gdk_dropfiles_filter (GdkXEvent *xev, private = (GdkDragContextPrivate *) context; context->protocol = GDK_DRAG_PROTO_WIN32_DROPFILES; context->is_source = FALSE; - context->source_window = (GdkWindow *) gdk_root_parent; + context->source_window = gdk_parent_root; context->dest_window = event->any.window; gdk_window_ref (context->dest_window); /* WM_DROPFILES drops are always file names */ @@ -713,8 +713,8 @@ gdk_dropfiles_filter (GdkXEvent *xev, } g_string_append (result, "\015\012"); } - gdk_sel_prop_store ((GdkWindow *) gdk_root_parent, - text_uri_list_atom, 8, result->str, result->len + 1); + gdk_sel_prop_store (gdk_parent_root, text_uri_list_atom, 8, + result->str, result->len + 1); DragFinish (hdrop); @@ -816,7 +816,7 @@ gdk_drag_find_window (GdkDragContext *context, POINT pt; GDK_NOTE (DND, g_print ("gdk_drag_find_window: %#x +%d+%d\n", - (drag_window ? drag_window_private->xwindow : 0), + (drag_window ? GDK_DRAWABLE_XID (drag_window) : 0), x_root, y_root)); pt.x = x_root; @@ -911,7 +911,6 @@ gdk_destroy_filter (GdkXEvent *xev, void gdk_window_register_dnd (GdkWindow *window) { - GdkDrawablePrivate *private = (GdkDrawablePrivate *) window; #ifdef OLE2_DND target_drag_context *context; HRESULT hres; @@ -919,7 +918,8 @@ gdk_window_register_dnd (GdkWindow *window) g_return_if_fail (window != NULL); - GDK_NOTE (DND, g_print ("gdk_window_register_dnd: %#x\n", private->xwindow)); + GDK_NOTE (DND, g_print ("gdk_window_register_dnd: %#x\n", + GDK_DRAWABLE_XID (window))); /* We always claim to accept dropped files, but in fact we might not, * of course. This function is called in such a way that it cannot know @@ -927,7 +927,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 (private->xwindow, TRUE); + DragAcceptFiles (GDK_DRAWABLE_XID (window), TRUE); #ifdef OLE2_DND /* Register for OLE2 d&d */ @@ -937,7 +937,7 @@ gdk_window_register_dnd (GdkWindow *window) g_warning ("gdk_window_register_dnd: CoLockObjectExternal failed"); else { - hres = RegisterDragDrop (private->xwindow, &context->idt); + hres = RegisterDragDrop (GDK_DRAWABLE_XID (window), &context->idt); if (hres == DRAGDROP_E_ALREADYREGISTERED) { g_print ("DRAGDROP_E_ALREADYREGISTERED\n"); diff --git a/gdk/win32/gdkdrawable-win32.c b/gdk/win32/gdkdrawable-win32.c index 73f5e513d9..aaf4ab7067 100644 --- a/gdk/win32/gdkdrawable-win32.c +++ b/gdk/win32/gdkdrawable-win32.c @@ -27,57 +27,111 @@ #include "config.h" #include - -#include "gdkdrawable.h" -#include "gdkprivate.h" -#include "gdkwindow.h" -#include "gdkx.h" +#include #ifndef G_PI #define G_PI 3.14159265358979323846 #endif -/* Manipulation of drawables - */ -void -gdk_drawable_set_data (GdkDrawable *drawable, - const gchar *key, - gpointer data, - GDestroyNotify destroy_func) -{ - g_dataset_set_data_full (drawable, key, data, destroy_func); -} +#include "gdkdrawable.h" +#include "gdkprivate.h" +#include "gdkwindow.h" +#include "gdkwin32.h" -void -gdk_drawable_get_data (GdkDrawable *drawable, - const gchar *key) -{ - g_dataset_get_data (drawable, key); -} +static void gdk_win32_drawable_destroy (GdkDrawable *drawable); -GdkDrawableType -gdk_drawable_get_type (GdkDrawable *drawable) -{ - g_return_val_if_fail (drawable != NULL, (GdkDrawableType) -1); - - return GDK_DRAWABLE_TYPE (drawable); -} +static void gdk_win32_draw_rectangle (GdkDrawable *drawable, + GdkGC *gc, + gint filled, + gint x, + gint y, + gint width, + gint height); +static void gdk_win32_draw_arc (GdkDrawable *drawable, + GdkGC *gc, + gint filled, + gint x, + gint y, + gint width, + gint height, + gint angle1, + gint angle2); +static void gdk_win32_draw_polygon (GdkDrawable *drawable, + GdkGC *gc, + gint filled, + GdkPoint *points, + gint npoints); +static void gdk_win32_draw_text (GdkDrawable *drawable, + GdkFont *font, + GdkGC *gc, + gint x, + gint y, + const gchar *text, + gint text_length); +static void gdk_win32_draw_text_wc (GdkDrawable *drawable, + GdkFont *font, + GdkGC *gc, + gint x, + gint y, + const GdkWChar *text, + gint text_length); +static void gdk_win32_draw_drawable (GdkDrawable *drawable, + GdkGC *gc, + GdkPixmap *src, + gint xsrc, + gint ysrc, + gint xdest, + gint ydest, + gint width, + gint height); +static void gdk_win32_draw_points (GdkDrawable *drawable, + GdkGC *gc, + GdkPoint *points, + gint npoints); +static void gdk_win32_draw_segments (GdkDrawable *drawable, + GdkGC *gc, + GdkSegment *segs, + gint nsegs); +static void gdk_win32_draw_lines (GdkDrawable *drawable, + GdkGC *gc, + GdkPoint *points, + gint npoints); -void -gdk_drawable_get_size (GdkDrawable *drawable, - 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 +}; + +/***************************************************** + * Win32 specific implementations of generic functions * + *****************************************************/ + +GdkColormap* +gdk_drawable_get_colormap (GdkDrawable *drawable) { GdkDrawablePrivate *drawable_private; - g_return_if_fail (drawable != NULL); - + 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; + } - if (width) - *width = drawable_private->width; - if (height) - *height = drawable_private->height; + return NULL; } void @@ -85,13 +139,13 @@ gdk_drawable_set_colormap (GdkDrawable *drawable, GdkColormap *colormap) { GdkDrawablePrivate *drawable_private; - GdkColormapPrivate *colormap_private; + GdkColormapPrivateWin32 *colormap_private; g_return_if_fail (drawable != NULL); g_return_if_fail (colormap != NULL); - drawable_private = (GdkDrawablePrivate*) drawable; - colormap_private = (GdkColormapPrivate*) colormap; + drawable_private = (GdkDrawablePrivate *) drawable; + colormap_private = (GdkColormapPrivateWin32 *) colormap; if (!GDK_DRAWABLE_DESTROYED (drawable)) { @@ -115,137 +169,33 @@ gdk_drawable_set_colormap (GdkDrawable *drawable, } } -GdkColormap* -gdk_drawable_get_colormap (GdkDrawable *drawable) +/* Drawing + */ +static void +gdk_win32_drawable_destroy (GdkDrawable *drawable) { - GdkDrawablePrivate *drawable_private; - 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; } -GdkVisual* -gdk_drawable_get_visual (GdkDrawable *drawable) +static void +gdk_win32_draw_rectangle (GdkDrawable *drawable, + GdkGC *gc, + gint filled, + gint x, + gint y, + gint width, + gint height) { - GdkColormap *colormap; - - g_return_val_if_fail (drawable != NULL, NULL); - - colormap = gdk_drawable_get_colormap (drawable); - return colormap ? gdk_colormap_get_visual (colormap) : NULL; -} - -void -gdk_draw_point (GdkDrawable *drawable, - GdkGC *gc, - gint x, - gint y) -{ - GdkDrawablePrivate *drawable_private; - GdkGCPrivate *gc_private; - HDC hdc; - - g_return_if_fail (drawable != NULL); - g_return_if_fail (gc != NULL); - - if (GDK_DRAWABLE_DESTROYED (drawable)) - return; - drawable_private = (GdkDrawablePrivate*) drawable; - gc_private = (GdkGCPrivate*) gc; - - hdc = gdk_gc_predraw (drawable_private, gc_private); - - /* We use LineTo because SetPixel wants the COLORREF directly, - * and doesn't use the current pen, which is what we want. - */ - if (!MoveToEx (hdc, x, y, NULL)) - g_warning ("gdk_draw_point: MoveToEx failed"); - if (!LineTo (hdc, x + 1, y)) - g_warning ("gdk_draw_point: LineTo failed"); - - gdk_gc_postdraw (drawable_private, gc_private); -} - -void -gdk_draw_line (GdkDrawable *drawable, - GdkGC *gc, - gint x1, - gint y1, - gint x2, - gint y2) -{ - GdkDrawablePrivate *drawable_private; - GdkGCPrivate *gc_private; - HDC hdc; - - g_return_if_fail (drawable != NULL); - g_return_if_fail (gc != NULL); - - if (GDK_DRAWABLE_DESTROYED (drawable)) - return; - drawable_private = (GdkDrawablePrivate*) drawable; - gc_private = (GdkGCPrivate*) gc; - - hdc = gdk_gc_predraw (drawable_private, gc_private); - - GDK_NOTE (MISC, g_print ("gdk_draw_line: %#x (%d) +%d+%d..+%d+%d\n", - drawable_private->xwindow, gc_private, - x1, y1, x2, y2)); - - MoveToEx (hdc, x1, y1, NULL); - if (!LineTo (hdc, x2, y2)) - g_warning ("gdk_draw_line: LineTo #1 failed"); - /* 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_private->pen_width == 1 && windows_version > 0x80000000) - if (!LineTo (hdc, x2 + 1, y2)) - g_warning ("gdk_draw_line: LineTo #2 failed"); - gdk_gc_postdraw (drawable_private, gc_private); -} - -void -gdk_draw_rectangle (GdkDrawable *drawable, - GdkGC *gc, - gint filled, - gint x, - gint y, - gint width, - gint height) -{ - GdkDrawablePrivate *drawable_private; GdkGCPrivate *gc_private; HDC hdc; HGDIOBJ oldpen, oldbrush; - g_return_if_fail (drawable != NULL); - g_return_if_fail (gc != NULL); - - if (GDK_DRAWABLE_DESTROYED (drawable)) - return; - drawable_private = (GdkDrawablePrivate*) drawable; gc_private = (GdkGCPrivate*) gc; - if (width == -1) - width = drawable_private->width; - if (height == -1) - height = drawable_private->height; - - hdc = gdk_gc_predraw (drawable_private, gc_private); + hdc = gdk_gc_predraw (drawable, gc_private); GDK_NOTE (MISC, g_print ("gdk_draw_rectangle: %#x (%d) %s%dx%d@+%d+%d\n", - drawable_private->xwindow, + GDK_DRAWABLE_XID (drawable), gc_private, (filled ? "fill " : ""), width, height, x, y)); @@ -282,45 +232,33 @@ gdk_draw_rectangle (GdkDrawable *drawable, else SelectObject (hdc, oldbrush); - gdk_gc_postdraw (drawable_private, gc_private); + gdk_gc_postdraw (drawable, gc_private); } -void -gdk_draw_arc (GdkDrawable *drawable, - GdkGC *gc, - gint filled, - gint x, - gint y, - gint width, - gint height, - gint angle1, - gint angle2) +static void +gdk_win32_draw_arc (GdkDrawable *drawable, + GdkGC *gc, + gint filled, + gint x, + gint y, + gint width, + gint height, + gint angle1, + gint angle2) { - GdkDrawablePrivate *drawable_private; GdkGCPrivate *gc_private; HDC hdc; int nXStartArc, nYStartArc, nXEndArc, nYEndArc; - g_return_if_fail (drawable != NULL); - g_return_if_fail (gc != NULL); - - if (GDK_DRAWABLE_DESTROYED (drawable)) - return; - drawable_private = (GdkDrawablePrivate*) drawable; gc_private = (GdkGCPrivate*) gc; - if (width == -1) - width = drawable_private->width; - if (height == -1) - height = drawable_private->height; - GDK_NOTE (MISC, g_print ("gdk_draw_arc: %#x %d,%d,%d,%d %d %d\n", - drawable_private->xwindow, + GDK_DRAWABLE_XID (drawable), x, y, width, height, angle1, angle2)); if (width != 0 && height != 0 && angle2 != 0) { - hdc = gdk_gc_predraw (drawable_private, gc_private); + hdc = gdk_gc_predraw (drawable, gc_private); if (angle2 >= 360*64) { @@ -360,39 +298,32 @@ gdk_draw_arc (GdkDrawable *drawable, Arc (hdc, x, y, x+width, y+height, nXStartArc, nYStartArc, nXEndArc, nYEndArc); } - gdk_gc_postdraw (drawable_private, gc_private); + gdk_gc_postdraw (drawable, gc_private); } } -void -gdk_draw_polygon (GdkDrawable *drawable, - GdkGC *gc, - gint filled, - GdkPoint *points, - gint npoints) +static void +gdk_win32_draw_polygon (GdkDrawable *drawable, + GdkGC *gc, + gint filled, + GdkPoint *points, + gint npoints) { - GdkDrawablePrivate *drawable_private; GdkGCPrivate *gc_private; HDC hdc; POINT *pts; int i; - g_return_if_fail (drawable != NULL); - g_return_if_fail (gc != NULL); - - if (GDK_DRAWABLE_DESTROYED (drawable)) - return; - drawable_private = (GdkDrawablePrivate*) drawable; gc_private = (GdkGCPrivate*) gc; GDK_NOTE (MISC, g_print ("gdk_draw_polygon: %#x (%d) %d\n", - drawable_private->xwindow, gc_private, + GDK_DRAWABLE_XID (drawable), gc_private, npoints)); if (npoints < 2) return; - hdc = gdk_gc_predraw (drawable_private, gc_private); + hdc = gdk_gc_predraw (drawable, gc_private); pts = g_malloc ((npoints+1) * sizeof (POINT)); for (i = 0; i < npoints; i++) @@ -419,7 +350,7 @@ gdk_draw_polygon (GdkDrawable *drawable, g_warning ("gdk_draw_polygon: Polyline failed"); } g_free (pts); - gdk_gc_postdraw (drawable_private, gc_private); + gdk_gc_postdraw (drawable, gc_private); } typedef struct @@ -428,19 +359,6 @@ typedef struct HDC hdc; } gdk_draw_text_arg; -/* gdk_draw_string - */ -void -gdk_draw_string (GdkDrawable *drawable, - GdkFont *font, - GdkGC *gc, - gint x, - gint y, - const gchar *string) -{ - gdk_draw_text (drawable, font, gc, x, y, string, strlen (string)); -} - static void gdk_draw_text_handler (GdkWin32SingleFont *singlefont, const wchar_t *wcstr, @@ -468,28 +386,20 @@ gdk_draw_text_handler (GdkWin32SingleFont *singlefont, SelectObject (argp->hdc, oldfont); } -/* gdk_draw_text - * - */ -void -gdk_draw_text (GdkDrawable *drawable, - GdkFont *font, - GdkGC *gc, - gint x, - gint y, - const gchar *text, - gint text_length) +static void +gdk_win32_draw_text (GdkDrawable *drawable, + GdkFont *font, + GdkGC *gc, + gint x, + gint y, + const gchar *text, + gint text_length) { - GdkDrawablePrivate *drawable_private; GdkGCPrivate *gc_private; wchar_t *wcstr; gint wlen; gdk_draw_text_arg arg; - g_return_if_fail (drawable != NULL); - g_return_if_fail (font != NULL); - g_return_if_fail (gc != NULL); - g_return_if_fail (text != NULL); if (GDK_DRAWABLE_DESTROYED (drawable)) return; @@ -499,15 +409,14 @@ gdk_draw_text (GdkDrawable *drawable, g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET); - drawable_private = (GdkDrawablePrivate*) drawable; gc_private = (GdkGCPrivate*) gc; arg.x = x; arg.y = y; - arg.hdc = gdk_gc_predraw (drawable_private, gc_private); + arg.hdc = gdk_gc_predraw (drawable, gc_private); GDK_NOTE (MISC, g_print ("gdk_draw_text: %#x (%d,%d) \"%.*s\" (len %d)\n", - drawable_private->xwindow, + GDK_DRAWABLE_XID (drawable), x, y, (text_length > 10 ? 10 : text_length), text, text_length)); @@ -521,28 +430,23 @@ gdk_draw_text (GdkDrawable *drawable, g_free (wcstr); - gdk_gc_postdraw (drawable_private, gc_private); + gdk_gc_postdraw (drawable, gc_private); } -void -gdk_draw_text_wc (GdkDrawable *drawable, - GdkFont *font, - GdkGC *gc, - gint x, - gint y, - const GdkWChar *text, - gint text_length) +static void +gdk_win32_draw_text_wc (GdkDrawable *drawable, + GdkFont *font, + GdkGC *gc, + gint x, + gint y, + const GdkWChar *text, + gint text_length) { - GdkDrawablePrivate *drawable_private; GdkGCPrivate *gc_private; gint i, wlen; wchar_t *wcstr; gdk_draw_text_arg arg; - g_return_if_fail (drawable != NULL); - g_return_if_fail (font != NULL); - g_return_if_fail (gc != NULL); - g_return_if_fail (text != NULL); if (GDK_DRAWABLE_DESTROYED (drawable)) return; @@ -552,15 +456,14 @@ gdk_draw_text_wc (GdkDrawable *drawable, g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET); - drawable_private = (GdkDrawablePrivate*) drawable; gc_private = (GdkGCPrivate*) gc; arg.x = x; arg.y = y; - arg.hdc = gdk_gc_predraw (drawable_private, gc_private); + arg.hdc = gdk_gc_predraw (drawable, gc_private); GDK_NOTE (MISC, g_print ("gdk_draw_text_wc: %#x (%d,%d) len: %d\n", - drawable_private->xwindow, + GDK_DRAWABLE_XID (drawable), x, y, text_length)); if (sizeof (wchar_t) != sizeof (GdkWChar)) @@ -578,21 +481,20 @@ gdk_draw_text_wc (GdkDrawable *drawable, if (sizeof (wchar_t) != sizeof (GdkWChar)) g_free (wcstr); - gdk_gc_postdraw (drawable_private, gc_private); + gdk_gc_postdraw (drawable, gc_private); } -void -gdk_draw_pixmap (GdkDrawable *drawable, - GdkGC *gc, - GdkPixmap *src, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height) +static void +gdk_win32_draw_drawable (GdkDrawable *drawable, + GdkGC *gc, + GdkPixmap *src, + gint xsrc, + gint ysrc, + gint xdest, + gint ydest, + gint width, + gint height) { - GdkDrawablePrivate *drawable_private; GdkDrawablePrivate *src_private; GdkGCPrivate *gc_private; HDC hdc; @@ -601,37 +503,25 @@ gdk_draw_pixmap (GdkDrawable *drawable, HRGN src_rgn, draw_rgn, outside_rgn; RECT r; - g_return_if_fail (drawable != NULL); - g_return_if_fail (src != NULL); - g_return_if_fail (gc != NULL); - - if (GDK_DRAWABLE_DESTROYED (drawable) || GDK_DRAWABLE_DESTROYED (src)) - return; - drawable_private = (GdkDrawablePrivate*) drawable; src_private = (GdkDrawablePrivate*) src; gc_private = (GdkGCPrivate*) gc; - if (width == -1) - width = src_private->width; /* Or should we subtract xsrc? */ - if (height == -1) - height = src_private->height; /* Ditto? */ - GDK_NOTE (MISC, g_print ("gdk_draw_pixmap: dest: %#x " "src: %#x %dx%d@+%d+%d" " dest: %#x @+%d+%d\n", - drawable_private->xwindow, - src_private->xwindow, + GDK_DRAWABLE_XID (drawable), + GDK_DRAWABLE_XID (src), width, height, xsrc, ysrc, - drawable_private->xwindow, xdest, ydest)); + GDK_DRAWABLE_XID (drawable), xdest, ydest)); - hdc = gdk_gc_predraw (drawable_private, gc_private); + hdc = gdk_gc_predraw (drawable, gc_private); src_rgn = CreateRectRgn (0, 0, src_private->width + 1, src_private->height + 1); draw_rgn = CreateRectRgn (xsrc, ysrc, xsrc + width + 1, ysrc + height + 1); SetRectEmpty (&r); outside_rgn = CreateRectRgnIndirect (&r); - if (drawable_private->window_type != GDK_DRAWABLE_PIXMAP) + if (GDK_DRAWABLE_TYPE (drawable) != GDK_DRAWABLE_PIXMAP) { /* If we are drawing on a window, calculate the region that is * outside the source pixmap, and invalidate that, causing it to @@ -645,7 +535,7 @@ gdk_draw_pixmap (GdkDrawable *drawable, "bbox: %dx%d@+%d+%d\n", r.right - r.left - 1, r.bottom - r.top - 1, r.left, r.top))); - InvalidateRgn (drawable_private->xwindow, outside_rgn, TRUE); + InvalidateRgn (GDK_DRAWABLE_XID (drawable), outside_rgn, TRUE); } } @@ -685,7 +575,7 @@ gdk_draw_pixmap (GdkDrawable *drawable, if ((srcdc = CreateCompatibleDC (hdc)) == NULL) g_warning ("gdk_draw_pixmap: CreateCompatibleDC failed"); - if ((hgdiobj = SelectObject (srcdc, src_private->xwindow)) == NULL) + if ((hgdiobj = SelectObject (srcdc, GDK_DRAWABLE_XID (src))) == NULL) g_warning ("gdk_draw_pixmap: SelectObject #1 failed"); if (!BitBlt (hdc, xdest, ydest, width, height, @@ -700,7 +590,7 @@ gdk_draw_pixmap (GdkDrawable *drawable, } else { - if (drawable_private->xwindow == src_private->xwindow) + if (GDK_DRAWABLE_XID(drawable) == GDK_DRAWABLE_XID (src)) { /* Blitting inside a window, use ScrollDC */ RECT scrollRect, clipRect, emptyRect; @@ -722,80 +612,43 @@ gdk_draw_pixmap (GdkDrawable *drawable, &scrollRect, &clipRect, updateRgn, NULL)) g_warning ("gdk_draw_pixmap: ScrollDC failed"); - if (!InvalidateRgn (drawable_private->xwindow, updateRgn, FALSE)) + if (!InvalidateRgn (GDK_DRAWABLE_XID (drawable), updateRgn, FALSE)) g_warning ("gdk_draw_pixmap: InvalidateRgn failed"); - if (!UpdateWindow (drawable_private->xwindow)) + if (!UpdateWindow (GDK_DRAWABLE_XID (drawable))) g_warning ("gdk_draw_pixmap: UpdateWindow failed"); } else { - if ((srcdc = GetDC (src_private->xwindow)) == NULL) + if ((srcdc = GetDC (GDK_DRAWABLE_XID (src))) == NULL) g_warning ("gdk_draw_pixmap: GetDC failed"); if (!BitBlt (hdc, xdest, ydest, width, height, srcdc, xsrc, ysrc, SRCCOPY)) g_warning ("gdk_draw_pixmap: BitBlt failed"); - ReleaseDC (src_private->xwindow, srcdc); + ReleaseDC (GDK_DRAWABLE_XID (src), srcdc); } } - gdk_gc_postdraw (drawable_private, gc_private); + gdk_gc_postdraw (drawable, gc_private); } -void -gdk_draw_image (GdkDrawable *drawable, - GdkGC *gc, - GdkImage *image, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height) +static void +gdk_win32_draw_points (GdkDrawable *drawable, + GdkGC *gc, + GdkPoint *points, + gint npoints) { - GdkImagePrivate *image_private; - - g_return_if_fail (drawable != NULL); - g_return_if_fail (image != NULL); - g_return_if_fail (gc != NULL); - - image_private = (GdkImagePrivate*) image; - - g_return_if_fail (image_private->image_put != NULL); - - if (width == -1) - width = image->width; - if (height == -1) - height = image->height; - - (* image_private->image_put) (drawable, gc, image, xsrc, ysrc, - xdest, ydest, width, height); -} - -void -gdk_draw_points (GdkDrawable *drawable, - GdkGC *gc, - GdkPoint *points, - gint npoints) -{ - GdkDrawablePrivate *drawable_private; GdkGCPrivate *gc_private; HDC hdc; int i; - g_return_if_fail (drawable != NULL); - g_return_if_fail ((points != NULL) && (npoints > 0)); - g_return_if_fail (gc != NULL); - - if (GDK_DRAWABLE_DESTROYED (drawable)) - return; - drawable_private = (GdkDrawablePrivate*) drawable; gc_private = (GdkGCPrivate*) gc; - hdc = gdk_gc_predraw (drawable_private, gc_private); + hdc = gdk_gc_predraw (drawable, gc_private); GDK_NOTE (MISC, g_print ("gdk_draw_points: %#x destdc: (%d) %#x " "npoints: %d\n", - drawable_private->xwindow, gc_private, hdc, + GDK_DRAWABLE_XID (drawable), + gc_private, hdc, npoints)); for (i = 0; i < npoints; i++) @@ -805,33 +658,22 @@ gdk_draw_points (GdkDrawable *drawable, if (!LineTo (hdc, points[i].x + 1, points[i].y)) g_warning ("gdk_draw_points: LineTo failed"); } - gdk_gc_postdraw (drawable_private, gc_private); + gdk_gc_postdraw (drawable, gc_private); } -void -gdk_draw_segments (GdkDrawable *drawable, - GdkGC *gc, - GdkSegment *segs, - gint nsegs) +static void +gdk_win32_draw_segments (GdkDrawable *drawable, + GdkGC *gc, + GdkSegment *segs, + gint nsegs) { - GdkDrawablePrivate *drawable_private; GdkGCPrivate *gc_private; HDC hdc; int i; - if (nsegs <= 0) - return; - - g_return_if_fail (drawable != NULL); - g_return_if_fail (segs != NULL); - g_return_if_fail (gc != NULL); - - if (GDK_DRAWABLE_DESTROYED (drawable)) - return; - drawable_private = (GdkDrawablePrivate*) drawable; gc_private = (GdkGCPrivate*) gc; - hdc = gdk_gc_predraw (drawable_private, gc_private); + hdc = gdk_gc_predraw (drawable, gc_private); for (i = 0; i < nsegs; i++) { @@ -841,20 +683,19 @@ gdk_draw_segments (GdkDrawable *drawable, g_warning ("gdk_draw_segments: LineTo #1 failed"); /* Draw end pixel */ - if (gc_private->pen_width == 1) + if (GDK_GC_WIN32DATA (gc)->pen_width == 1) if (!LineTo (hdc, segs[i].x2 + 1, segs[i].y2)) g_warning ("gdk_draw_segments: LineTo #2 failed"); } - gdk_gc_postdraw (drawable_private, gc_private); + gdk_gc_postdraw (drawable, gc_private); } -void -gdk_draw_lines (GdkDrawable *drawable, - GdkGC *gc, - GdkPoint *points, - gint npoints) +static void +gdk_win32_draw_lines (GdkDrawable *drawable, + GdkGC *gc, + GdkPoint *points, + gint npoints) { - GdkDrawablePrivate *drawable_private; GdkGCPrivate *gc_private; HDC hdc; POINT *pts; @@ -863,16 +704,9 @@ gdk_draw_lines (GdkDrawable *drawable, if (npoints < 2) return; - g_return_if_fail (drawable != NULL); - g_return_if_fail (points != NULL); - g_return_if_fail (gc != NULL); - - if (GDK_DRAWABLE_DESTROYED (drawable)) - return; - drawable_private = (GdkDrawablePrivate*) drawable; gc_private = (GdkGCPrivate*) gc; - hdc = gdk_gc_predraw (drawable_private, gc_private); + hdc = gdk_gc_predraw (drawable, gc_private); #if 1 pts = g_malloc (npoints * sizeof (POINT)); @@ -888,7 +722,7 @@ gdk_draw_lines (GdkDrawable *drawable, g_free (pts); /* Draw end pixel */ - if (gc_private->pen_width == 1) + if (GDK_GC_WIN32DATA (gc)->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)) @@ -901,9 +735,13 @@ gdk_draw_lines (GdkDrawable *drawable, g_warning ("gdk_draw_lines: LineTo #1 failed"); /* Draw end pixel */ - if (gc_private->pen_width == 1) + /* 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 (GDK_GC_WIN32DATA (gc)->pen_width == 1 && windows_version > 0x80000000) if (!LineTo (hdc, points[npoints-1].x + 1, points[npoints-1].y)) g_warning ("gdk_draw_lines: LineTo #2 failed"); #endif - gdk_gc_postdraw (drawable_private, gc_private); + gdk_gc_postdraw (drawable, gc_private); } diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index 9ef45fe8d8..fb87e27a83 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -42,7 +42,12 @@ #include -#include +#include "gdk.h" +#include "gdkwin32.h" + +#include "gdkkeysyms.h" + +#include "gdkinputprivate.h" #include #include @@ -57,25 +62,13 @@ #include #endif -#include "gdk.h" -#include "gdkx.h" - -#include "gdkkeysyms.h" - -#include "gdkinputprivate.h" - #define PING() printf("%s: %d\n",__FILE__,__LINE__),fflush(stdout) -#define WINDOW_PRIVATE(wp) ((GdkWindowPrivate *) (wp)) +#define WINDOW_PRIVATE(wp) GDK_WINDOW_WIN32DATA (wp) typedef struct _GdkIOClosure GdkIOClosure; typedef struct _GdkEventPrivate GdkEventPrivate; -#define DOUBLE_CLICK_TIME 250 -#define TRIPLE_CLICK_TIME 500 -#define DOUBLE_CLICK_DIST 5 -#define TRIPLE_CLICK_DIST 5 - gint gdk_event_func_from_window_proc = FALSE; typedef enum @@ -104,7 +97,6 @@ struct _GdkEventPrivate * Private function declarations */ -static GdkEvent *gdk_event_new (void); static GdkFilterReturn gdk_event_apply_filters(MSG *xevent, GdkEvent *event, @@ -113,8 +105,6 @@ static gboolean gdk_event_translate (GdkEvent *event, MSG *xevent, gboolean *ret_val_flagp, gint *ret_valp); -static void gdk_events_queue (void); -static GdkEvent *gdk_event_unqueue (void); static gboolean gdk_event_prepare (gpointer source_data, GTimeVal *current_time, gint *timeout); @@ -130,16 +120,6 @@ static void gdk_synthesize_click (GdkEvent *event, /* Private variable declarations */ -static guint32 button_click_time[2]; /* The last 2 button click times. Used - * to determine if the latest button click - * is part of a double or triple click. - */ -static GdkWindow *button_window[2]; /* The last 2 windows to receive button presses. - * Also used to determine if the latest button - * click is part of a double or triple click. - */ -static guint button_number[2]; /* The last 2 buttons to be pressed. - */ static GdkWindow *p_grab_window = NULL; /* Window that currently * holds the pointer grab */ @@ -155,10 +135,6 @@ static GdkEventMask p_grab_mask; static gboolean p_grab_owner_events, k_grab_owner_events; static HCURSOR p_grab_cursor; -static GdkEventFunc event_func = NULL; /* Callback for events */ -static gpointer event_data = NULL; -static GDestroyNotify event_notify = NULL; - static GList *client_filters; /* Filters for client messages */ /* FIFO's for event queue, and for events put back using @@ -273,11 +249,11 @@ gdk_WindowProc (HWND hWnd, * GDK_EVENT_FUNC_FROM_WINDOW_PROC env var to get this * behaviour. */ - if (gdk_event_func_from_window_proc && event_func) + if (gdk_event_func_from_window_proc && gdk_event_func) { GDK_THREADS_ENTER (); - (*event_func) (eventp, event_data); + (*gdk_event_func) (eventp, gdk_event_data); gdk_event_free (eventp); GDK_THREADS_LEAVE (); @@ -309,79 +285,6 @@ gdk_WindowProc (HWND hWnd, } } -/********************************************* - * Functions for maintaining the event queue * - *********************************************/ - -/************************************************************* - * gdk_event_queue_find_first: - * Find the first event on the queue that is not still - * being filled in. - * arguments: - * - * results: - * Pointer to the list node for that event, or NULL - *************************************************************/ - -static GList* -gdk_event_queue_find_first (void) -{ - GList *tmp_list = queued_events; - - while (tmp_list) - { - GdkEventPrivate *event = tmp_list->data; - if (!(event->flags & GDK_EVENT_PENDING)) - return tmp_list; - - tmp_list = g_list_next (tmp_list); - } - - return NULL; -} - -/************************************************************* - * gdk_event_queue_remove_link: - * Remove a specified list node from the event queue. - * arguments: - * node: Node to remove. - * results: - *************************************************************/ - -static void -gdk_event_queue_remove_link (GList *node) -{ - if (node->prev) - node->prev->next = node->next; - else - queued_events = node->next; - - if (node->next) - node->next->prev = node->prev; - else - queued_tail = node->prev; - -} - -/************************************************************* - * gdk_event_queue_append: - * Append an event onto the tail of the event queue. - * arguments: - * event: Event to append. - * results: - *************************************************************/ - -void -gdk_event_queue_append (GdkEvent *event) -{ - queued_tail = g_list_append (queued_tail, event); - - if (!queued_events) - queued_events = queued_tail; - else - queued_tail = queued_tail->next; -} - void gdk_events_init (void) { @@ -405,13 +308,6 @@ gdk_events_init (void) g_main_add_poll (&event_poll_fd, GDK_PRIORITY_EVENTS); - button_click_time[0] = 0; - button_click_time[1] = 0; - button_window[0] = NULL; - button_window[1] = NULL; - button_number[0] = -1; - button_number[1] = -1; - hres = CoCreateInstance (&CLSID_CActiveIMM, NULL, CLSCTX_ALL, @@ -521,331 +417,6 @@ gdk_event_get_graphics_expose (GdkWindow *window) #endif } -/************************************************************* - * gdk_event_handler_set: - * - * arguments: - * func: Callback function to be called for each event. - * data: Data supplied to the function - * notify: function called when function is no longer needed - * - * results: - *************************************************************/ - -void -gdk_event_handler_set (GdkEventFunc func, - gpointer data, - GDestroyNotify notify) -{ - if (event_notify) - (*event_notify) (event_data); - - event_func = func; - event_data = data; - event_notify = notify; -} - -/* - *-------------------------------------------------------------- - * gdk_event_get - * - * Gets the next event. - * - * Arguments: - * - * Results: - * If an event is waiting that we care about, returns - * a pointer to that event, to be freed with gdk_event_free. - * Otherwise, returns NULL. - * - * Side effects: - * - *-------------------------------------------------------------- - */ - -GdkEvent* -gdk_event_get (void) -{ - gdk_events_queue(); - - return gdk_event_unqueue(); -} - -/* - *-------------------------------------------------------------- - * gdk_event_peek - * - * Gets the next event. - * - * Arguments: - * - * Results: - * If an event is waiting that we care about, returns - * a copy of that event, but does not remove it from - * the queue. The pointer is to be freed with gdk_event_free. - * Otherwise, returns NULL. - * - * Side effects: - * - *-------------------------------------------------------------- - */ - -GdkEvent* -gdk_event_peek (void) -{ - GList *tmp_list; - - tmp_list = gdk_event_queue_find_first (); - - if (tmp_list) - return gdk_event_copy (tmp_list->data); - else - return NULL; -} - -void -gdk_event_put (GdkEvent *event) -{ - GdkEvent *new_event; - GList *tmp_list; - - g_return_if_fail (event != NULL); - - new_event = gdk_event_copy (event); - - gdk_event_queue_append (new_event); -} - -/* - *-------------------------------------------------------------- - * gdk_event_copy - * - * Copy a event structure into new storage. - * - * Arguments: - * "event" is the event struct to copy. - * - * Results: - * A new event structure. Free it with gdk_event_free. - * - * Side effects: - * The reference count of the window in the event is increased. - * - *-------------------------------------------------------------- - */ - -static GMemChunk *event_chunk = NULL; - -static GdkEvent* -gdk_event_new (void) -{ - GdkEventPrivate *new_event; - - if (event_chunk == NULL) - event_chunk = g_mem_chunk_new ("events", - sizeof (GdkEventPrivate), - 4096, - G_ALLOC_AND_FREE); - - new_event = g_chunk_new (GdkEventPrivate, event_chunk); - new_event->flags = 0; - - return (GdkEvent *) new_event; -} - -GdkEvent* -gdk_event_copy (GdkEvent *event) -{ - GdkEvent *new_event; - gchar *s; - - g_return_val_if_fail (event != NULL, NULL); - - new_event = gdk_event_new (); - - *new_event = *event; - gdk_window_ref (new_event->any.window); - - switch (event->any.type) - { - case GDK_KEY_PRESS: - case GDK_KEY_RELEASE: - if (event->key.length > 0) - { - s = event->key.string; - new_event->key.string = g_malloc (event->key.length + 1); - memcpy (new_event->key.string, s, event->key.length + 1); - } - break; - - case GDK_ENTER_NOTIFY: - case GDK_LEAVE_NOTIFY: - if (event->crossing.subwindow != NULL) - gdk_window_ref (event->crossing.subwindow); - break; - - case GDK_DRAG_ENTER: - case GDK_DRAG_LEAVE: - case GDK_DRAG_MOTION: - case GDK_DRAG_STATUS: - case GDK_DROP_START: - case GDK_DROP_FINISHED: - gdk_drag_context_ref (event->dnd.context); - break; - - default: - break; - } - - return new_event; -} - -/* - *-------------------------------------------------------------- - * gdk_event_free - * - * Free a event structure obtained from gdk_event_copy. Do not use - * with other event structures. - * - * Arguments: - * "event" is the event struct to free. - * - * Results: - * - * Side effects: - * The reference count of the window in the event is decreased and - * might be freed, too. - * - *-------------------------------------------------------------- */ - -void -gdk_event_free (GdkEvent *event) -{ - g_return_if_fail (event != NULL); - - g_assert (event_chunk != NULL); /* paranoid */ - - if (event->any.window) - gdk_window_unref (event->any.window); - - switch (event->any.type) - { - case GDK_KEY_PRESS: - case GDK_KEY_RELEASE: - g_free (event->key.string); - break; - - case GDK_ENTER_NOTIFY: - case GDK_LEAVE_NOTIFY: - if (event->crossing.subwindow != NULL) - gdk_window_unref (event->crossing.subwindow); - break; - - case GDK_DRAG_ENTER: - case GDK_DRAG_LEAVE: - case GDK_DRAG_MOTION: - case GDK_DRAG_STATUS: - case GDK_DROP_START: - case GDK_DROP_FINISHED: - gdk_drag_context_unref (event->dnd.context); - break; - - default: - break; - } - - g_mem_chunk_free (event_chunk, event); -} - -/* - *-------------------------------------------------------------- - * gdk_event_get_time: - * Get the timestamp from an event. - * arguments: - * event: - * results: - * The event's time stamp, if it has one, otherwise - * GDK_CURRENT_TIME. - *-------------------------------------------------------------- - */ - -guint32 -gdk_event_get_time (GdkEvent *event) -{ - if (event) - switch (event->type) - { - case GDK_MOTION_NOTIFY: - return event->motion.time; - case GDK_BUTTON_PRESS: - case GDK_2BUTTON_PRESS: - case GDK_3BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - return event->button.time; - case GDK_KEY_PRESS: - case GDK_KEY_RELEASE: - return event->key.time; - case GDK_ENTER_NOTIFY: - case GDK_LEAVE_NOTIFY: - return event->crossing.time; - case GDK_PROPERTY_NOTIFY: - return event->property.time; - case GDK_SELECTION_CLEAR: - case GDK_SELECTION_REQUEST: - case GDK_SELECTION_NOTIFY: - return event->selection.time; - case GDK_PROXIMITY_IN: - case GDK_PROXIMITY_OUT: - return event->proximity.time; - case GDK_DRAG_ENTER: - case GDK_DRAG_LEAVE: - case GDK_DRAG_MOTION: - case GDK_DRAG_STATUS: - case GDK_DROP_START: - case GDK_DROP_FINISHED: - return event->dnd.time; - default: /* use current time */ - break; - } - - return GDK_CURRENT_TIME; -} - -/* - *-------------------------------------------------------------- - * gdk_set_show_events - * - * Turns on/off the showing of events. - * - * Arguments: - * "show_events" is a boolean describing whether or - * not to show the events gdk receives. - * - * Results: - * - * Side effects: - * When "show_events" is TRUE, calls to "gdk_event_get" - * will output debugging informatin regarding the event - * received to stdout. - * - *-------------------------------------------------------------- - */ - -void -gdk_set_show_events (gint show_events) -{ - if (show_events) - gdk_debug_flags |= GDK_DEBUG_EVENTS; - else - gdk_debug_flags &= ~GDK_DEBUG_EVENTS; -} - -gint -gdk_get_show_events (void) -{ - return gdk_debug_flags & GDK_DEBUG_EVENTS; -} - /* *-------------------------------------------------------------- * gdk_pointer_grab @@ -2856,9 +2427,9 @@ build_pointer_event_state (MSG *xevent) static void -build_keypress_event (GdkWindowPrivate *window_private, - GdkEvent *event, - MSG *xevent) +build_keypress_event (GdkWindowWin32Data *windata, + GdkEvent *event, + MSG *xevent) { HIMC hIMC; gint i, bytesleft, bytecount, ucount, ucleft, len; @@ -2907,7 +2478,7 @@ build_keypress_event (GdkWindowPrivate *window_private, * to Unicode. Then convert to UTF-8. * We don't handle the surrogate stuff. Should we? */ - ucount = MultiByteToWideChar (window_private->charset_info.ciACP, + ucount = MultiByteToWideChar (windata->charset_info.ciACP, 0, buf, bytecount, wbuf, sizeof (wbuf) / sizeof (wbuf[0])); @@ -2990,9 +2561,9 @@ build_keypress_event (GdkWindowPrivate *window_private, } static void -build_keyrelease_event (GdkWindowPrivate *window_private, - GdkEvent *event, - MSG *xevent) +build_keyrelease_event (GdkWindowWin32Data *windata, + GdkEvent *event, + MSG *xevent) { guchar buf; wchar_t wbuf; @@ -3006,7 +2577,7 @@ build_keyrelease_event (GdkWindowPrivate *window_private, else { buf = xevent->wParam; - MultiByteToWideChar (window_private->charset_info.ciACP, + MultiByteToWideChar (windata->charset_info.ciACP, 0, &buf, 1, &wbuf, 1); event->key.keyval = unicode_to_keyval (wbuf); @@ -3141,7 +2712,7 @@ synthesize_crossing_events (GdkWindow *window, */ if (p_TrackMouseEvent == NULL && curWnd - && (WINDOW_PRIVATE(curWnd)->event_mask & GDK_LEAVE_NOTIFY_MASK)) + && (GDK_WINDOW_WIN32DATA(curWnd)->event_mask & GDK_LEAVE_NOTIFY_MASK)) { GDK_NOTE (EVENTS, g_print ("synthesizing LEAVE_NOTIFY event\n")); @@ -3170,7 +2741,7 @@ synthesize_crossing_events (GdkWindow *window, GDK_NOTE (EVENTS, print_event (event)); } - if (WINDOW_PRIVATE(window)->event_mask & GDK_ENTER_NOTIFY_MASK) + if (GDK_WINDOW_WIN32DATA(window)->event_mask & GDK_ENTER_NOTIFY_MASK) { GDK_NOTE (EVENTS, g_print ("synthesizing ENTER_NOTIFY event\n")); @@ -3201,7 +2772,7 @@ synthesize_crossing_events (GdkWindow *window, GDK_NOTE (EVENTS, print_event (event)); - if (WINDOW_PRIVATE(window)->extension_events != 0 + if (((GdkWindowPrivate *) window)->extension_events != 0 && gdk_input_vtable.enter_event) gdk_input_vtable.enter_event (&event->crossing, window); @@ -3233,7 +2804,7 @@ key_propagate (GdkWindow *window, MSG *xevent) { gdk_window_unref (window); - window = WINDOW_PRIVATE(window)->parent; + window = ((GdkWindowPrivate *) window)->parent; gdk_window_ref (window); return window; @@ -3249,7 +2820,7 @@ pointer_propagate (GdkWindow *window, pt.y = HIWORD (xevent->lParam); ClientToScreen (GDK_DRAWABLE_XID (window), &pt); gdk_window_unref (window); - window = WINDOW_PRIVATE(window)->parent; + window = ((GdkWindowPrivate *) window)->parent; gdk_window_ref (window); ScreenToClient (GDK_DRAWABLE_XID (window), &pt); xevent->lParam = MAKELPARAM (pt.x, pt.y); @@ -3306,10 +2877,10 @@ propagate (GdkWindow **window, } while (TRUE) { - if ((*doesnt_want_it) (WINDOW_PRIVATE(*window)->event_mask, xevent)) + if ((*doesnt_want_it) (GDK_WINDOW_WIN32DATA(*window)->event_mask, xevent)) { /* Owner doesn't want it, propagate to parent. */ - if (WINDOW_PRIVATE(*window)->parent == (GdkWindow *) gdk_root_parent) + if (((GdkWindowPrivate *) *window)->parent == gdk_parent_root) { /* No parent; check if grabbed */ if (grab_window != NULL) @@ -3342,7 +2913,7 @@ propagate (GdkWindow **window, else { gdk_window_unref (*window); - *window = WINDOW_PRIVATE(*window)->parent; + *window = ((GdkWindowPrivate *) *window)->parent; gdk_window_ref (*window); GDK_NOTE (EVENTS, g_print ("...propagating to %#x\n", GDK_DRAWABLE_XID (*window))); @@ -3412,7 +2983,7 @@ gdk_event_translate (GdkEvent *event, gint *ret_valp) { GdkWindow *window, *orig_window; - GdkColormapPrivate *colormap_private; + GdkColormapPrivateWin32 *colormap_private; HWND owner; DWORD pidActWin; DWORD pidThis; @@ -3424,6 +2995,7 @@ gdk_event_translate (GdkEvent *event, POINT pt; MINMAXINFO *lpmmi; GdkEventMask mask; + GdkPixmap *pixmap; GdkDrawablePrivate *pixmap_private; HDC bgdc; HGDIOBJ oldbitmap; @@ -3490,7 +3062,7 @@ gdk_event_translate (GdkEvent *event, /* Check for filters for this window */ GdkFilterReturn result; result = gdk_event_apply_filters - (xevent, event, WINDOW_PRIVATE(window)->filters); + (xevent, event, ((GdkWindowPrivate *) window)->filters); if (result != GDK_FILTER_CONTINUE) { @@ -3500,8 +3072,8 @@ gdk_event_translate (GdkEvent *event, if (xevent->message == gdk_selection_notify_msg) { - GDK_NOTE (SELECTION, g_print ("gdk_selection_notify_msg: %#x\n", - xevent->hwnd)); + GDK_NOTE (EVENTS, g_print ("gdk_selection_notify_msg: %#x\n", + xevent->hwnd)); event->selection.type = GDK_SELECTION_NOTIFY; event->selection.window = window; @@ -3516,8 +3088,8 @@ gdk_event_translate (GdkEvent *event, } else if (xevent->message == gdk_selection_request_msg) { - GDK_NOTE (SELECTION, g_print ("gdk_selection_request_msg: %#x\n", - xevent->hwnd)); + GDK_NOTE (EVENTS, g_print ("gdk_selection_request_msg: %#x\n", + xevent->hwnd)); event->selection.type = GDK_SELECTION_REQUEST; event->selection.window = window; @@ -3533,8 +3105,8 @@ gdk_event_translate (GdkEvent *event, } else if (xevent->message == gdk_selection_clear_msg) { - GDK_NOTE (SELECTION, g_print ("gdk_selection_clear_msg: %#x\n", - xevent->hwnd)); + GDK_NOTE (EVENTS, g_print ("gdk_selection_clear_msg: %#x\n", + xevent->hwnd)); event->selection.type = GDK_SELECTION_CLEAR; event->selection.window = window; @@ -3590,9 +3162,9 @@ gdk_event_translate (GdkEvent *event, GDK_NOTE (EVENTS, g_print ("WM_INPUTLANGCHANGE: %#x charset %d locale %x\n", xevent->hwnd, xevent->wParam, xevent->lParam)); - WINDOW_PRIVATE(window)->input_locale = (HKL) xevent->lParam; + GDK_WINDOW_WIN32DATA(window)->input_locale = (HKL) xevent->lParam; TranslateCharsetInfo ((DWORD FAR *) xevent->wParam, - &WINDOW_PRIVATE(window)->charset_info, + &GDK_WINDOW_WIN32DATA(window)->charset_info, TCI_SRCCHARSET); break; @@ -3657,13 +3229,13 @@ gdk_event_translate (GdkEvent *event, } else if (((xevent->message == WM_KEYUP || xevent->message == WM_SYSKEYUP) - && !(WINDOW_PRIVATE(window)->event_mask & GDK_KEY_RELEASE_MASK)) + && !(GDK_WINDOW_WIN32DATA(window)->event_mask & GDK_KEY_RELEASE_MASK)) || ((xevent->message == WM_KEYDOWN || xevent->message == WM_SYSKEYDOWN) - && !(WINDOW_PRIVATE(window)->event_mask & GDK_KEY_PRESS_MASK))) + && !(GDK_WINDOW_WIN32DATA(window)->event_mask & GDK_KEY_PRESS_MASK))) { /* Owner doesn't want it, propagate to parent. */ - if (WINDOW_PRIVATE(window)->parent == (GdkWindow *) gdk_root_parent) + if (((GdkWindowPrivate *) window)->parent == (GdkWindow *) gdk_root_parent) { /* No parent; check if grabbed */ if (k_grab_window != NULL) @@ -3943,10 +3515,10 @@ gdk_event_translate (GdkEvent *event, GDK_DRAWABLE_XID (k_grab_window))); event->key.window = k_grab_window; } - else if (!(WINDOW_PRIVATE(window)->event_mask & (GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK))) + else if (!(GDK_WINDOW_WIN32DATA(window)->event_mask & (GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK))) { /* Owner doesn't want it, propagate to parent. */ - if (WINDOW_PRIVATE(window)->parent == (GdkWindow *) gdk_root_parent) + if (((GdkWindowPrivate *) window)->parent == (GdkWindow *) gdk_root_parent) { /* No parent; check if grabbed */ if (k_grab_window != NULL) @@ -3971,30 +3543,30 @@ gdk_event_translate (GdkEvent *event, #endif return_val = !GDK_DRAWABLE_DESTROYED (window); if (return_val && (event->key.window == k_grab_window - || (WINDOW_PRIVATE(window)->event_mask & GDK_KEY_RELEASE_MASK))) + || (GDK_WINDOW_WIN32DATA(window)->event_mask & GDK_KEY_RELEASE_MASK))) { if (window == k_grab_window - || (WINDOW_PRIVATE(window)->event_mask & GDK_KEY_PRESS_MASK)) + || (GDK_WINDOW_WIN32DATA(window)->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 (WINDOW_PRIVATE(window), event2, xevent); + build_keypress_event (GDK_WINDOW_WIN32DATA(window), event2, xevent); event2->key.window = window; gdk_window_ref (window); gdk_event_queue_append (event2); GDK_NOTE (EVENTS, print_event (event2)); } /* Return the key release event. */ - build_keyrelease_event (WINDOW_PRIVATE(window), event, xevent); + build_keyrelease_event (GDK_WINDOW_WIN32DATA(window), event, xevent); } else if (return_val - && (WINDOW_PRIVATE(window)->event_mask & GDK_KEY_PRESS_MASK)) + && (GDK_WINDOW_WIN32DATA(window)->event_mask & GDK_KEY_PRESS_MASK)) { /* Return just the key press event. */ - build_keypress_event (WINDOW_PRIVATE(window), event, xevent); + build_keypress_event (GDK_WINDOW_WIN32DATA(window), event, xevent); } else return_val = FALSE; @@ -4023,7 +3595,7 @@ gdk_event_translate (GdkEvent *event, xevent->hwnd, LOWORD (xevent->lParam), HIWORD (xevent->lParam))); - if (WINDOW_PRIVATE(window)->extension_events != 0 + if (GDK_WINDOW_WIN32DATA(window)->extension_events != 0 && gdk_input_ignore_core) { GDK_NOTE (EVENTS, g_print ("...ignored\n")); @@ -4042,7 +3614,7 @@ gdk_event_translate (GdkEvent *event, event->button.window = window; #else buttondown: - mask = WINDOW_PRIVATE(window)->event_mask; + mask = ((GdkWindowPrivate *) window)->event_mask; if (p_grab_window != NULL && !p_grab_owner_events) { @@ -4061,7 +3633,7 @@ gdk_event_translate (GdkEvent *event, else if (!(mask & GDK_BUTTON_PRESS_MASK)) { /* Owner doesn't want it, propagate to parent. */ - if (WINDOW_PRIVATE(window)->parent == (GdkWindow *) gdk_root_parent) + if (((GdkWindowPrivate *) window)->parent == gdk_parent_root) { /* No parent; check if grabbed */ if (p_grab_window != NULL) @@ -4100,13 +3672,13 @@ gdk_event_translate (GdkEvent *event, { /* No explicit active grab, let's start one automatically */ gint owner_events = - WINDOW_PRIVATE(window)->event_mask + GDK_WINDOW_WIN32DATA(window)->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, - WINDOW_PRIVATE(window)->event_mask, + GDK_WINDOW_WIN32DATA(window)->event_mask, NULL, NULL, 0); p_grab_automatic = TRUE; } @@ -4114,8 +3686,8 @@ gdk_event_translate (GdkEvent *event, event->button.time = xevent->time; if (window != orig_window) translate_mouse_coords (orig_window, window, xevent); - event->button.x = curX = LOWORD (xevent->lParam); - event->button.y = curY = HIWORD (xevent->lParam); + 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; @@ -4126,41 +3698,8 @@ gdk_event_translate (GdkEvent *event, event->button.source = GDK_SOURCE_MOUSE; event->button.deviceid = GDK_CORE_POINTER; - if ((event->button.time < (button_click_time[1] + TRIPLE_CLICK_TIME)) && - (event->button.window == button_window[1]) && - (event->button.button == button_number[1])) - { - gdk_synthesize_click (event, 3); - - button_click_time[1] = 0; - button_click_time[0] = 0; - button_window[1] = NULL; - button_window[0] = 0; - button_number[1] = -1; - button_number[0] = -1; - } - else if ((event->button.time < (button_click_time[0] + DOUBLE_CLICK_TIME)) && - (event->button.window == button_window[0]) && - (event->button.button == button_number[0])) - { - gdk_synthesize_click (event, 2); - - button_click_time[1] = button_click_time[0]; - button_click_time[0] = event->button.time; - button_window[1] = button_window[0]; - button_window[0] = event->button.window; - button_number[1] = button_number[0]; - button_number[0] = event->button.button; - } - else - { - button_click_time[1] = 0; - button_click_time[0] = event->button.time; - button_window[1] = NULL; - button_window[0] = event->button.window; - button_number[1] = -1; - button_number[0] = event->button.button; - } + gdk_event_button_generate (event); + return_val = !GDK_DRAWABLE_DESTROYED (window); break; @@ -4180,7 +3719,7 @@ gdk_event_translate (GdkEvent *event, xevent->hwnd, LOWORD (xevent->lParam), HIWORD (xevent->lParam))); - if (WINDOW_PRIVATE(window)->extension_events != 0 + if (((GdkWindowPrivate *) window)->extension_events != 0 && gdk_input_ignore_core) { GDK_NOTE (EVENTS, g_print ("...ignored\n")); @@ -4199,7 +3738,7 @@ gdk_event_translate (GdkEvent *event, event->button.window = window; #else buttonup: - mask = WINDOW_PRIVATE(window)->event_mask; + mask = GDK_WINDOW_WIN32DATA(window)->event_mask; if (p_grab_window != NULL && !p_grab_owner_events) { @@ -4218,7 +3757,7 @@ gdk_event_translate (GdkEvent *event, else if (!(mask & GDK_BUTTON_RELEASE_MASK)) { /* Owner doesn't want it, propagate to parent. */ - if (WINDOW_PRIVATE(window)->parent == (GdkWindow *) gdk_root_parent) + if (((GdkWindowPrivate *) window)->parent == gdk_parent_root) { /* No parent; check if grabbed */ if (p_grab_window != NULL) @@ -4256,8 +3795,8 @@ gdk_event_translate (GdkEvent *event, event->button.time = xevent->time; if (window != orig_window) translate_mouse_coords (orig_window, window, xevent); - event->button.x = LOWORD (xevent->lParam); - event->button.y = HIWORD (xevent->lParam); + 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; @@ -4301,7 +3840,7 @@ gdk_event_translate (GdkEvent *event, if (window != curWnd) synthesize_crossing_events (window, xevent); - if (WINDOW_PRIVATE(window)->extension_events != 0 + if (((GdkWindowPrivate *) window)->extension_events != 0 && gdk_input_ignore_core) { GDK_NOTE (EVENTS, g_print ("...ignored\n")); @@ -4317,7 +3856,7 @@ gdk_event_translate (GdkEvent *event, event->motion.window = window; #else mousemotion: - mask = WINDOW_PRIVATE(window)->event_mask; + mask = GDK_WINDOW_WIN32DATA(window)->event_mask; if (p_grab_window != NULL && !p_grab_owner_events) { @@ -4352,7 +3891,7 @@ gdk_event_translate (GdkEvent *event, && (mask & GDK_BUTTON3_MOTION_MASK)))) { /* Owner doesn't want it, propagate to parent. */ - if (WINDOW_PRIVATE(window)->parent == (GdkWindow *) gdk_root_parent) + if (((GdkWindowPrivate *) window)->parent == gdk_parent_root) { /* No parent; check if grabbed */ if (p_grab_window != NULL) @@ -4396,8 +3935,8 @@ gdk_event_translate (GdkEvent *event, event->motion.time = xevent->time; if (window != orig_window) translate_mouse_coords (orig_window, window, xevent); - event->motion.x = curX = LOWORD (xevent->lParam); - event->motion.y = curY = HIWORD (xevent->lParam); + 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; @@ -4420,7 +3959,7 @@ gdk_event_translate (GdkEvent *event, LOWORD (xevent->lParam), HIWORD (xevent->lParam))); if (p_TrackMouseEvent == NULL && curWnd != NULL - && (WINDOW_PRIVATE(curWnd)->event_mask & GDK_LEAVE_NOTIFY_MASK)) + && (GDK_WINDOW_WIN32DATA(curWnd)->event_mask & GDK_LEAVE_NOTIFY_MASK)) { GDK_NOTE (EVENTS, g_print ("...synthesizing LEAVE_NOTIFY event\n")); @@ -4452,7 +3991,7 @@ gdk_event_translate (GdkEvent *event, case WM_MOUSELEAVE: GDK_NOTE (EVENTS, g_print ("WM_MOUSELEAVE: %#x\n", xevent->hwnd)); - if (!(WINDOW_PRIVATE(window)->event_mask & GDK_LEAVE_NOTIFY_MASK)) + if (!(GDK_WINDOW_WIN32DATA(window)->event_mask & GDK_LEAVE_NOTIFY_MASK)) break; event->crossing.type = GDK_LEAVE_NOTIFY; @@ -4493,7 +4032,7 @@ gdk_event_translate (GdkEvent *event, "SET" : "KILL"), xevent->hwnd)); - if (!(WINDOW_PRIVATE(window)->event_mask & GDK_FOCUS_CHANGE_MASK)) + if (!(GDK_WINDOW_WIN32DATA(window)->event_mask & GDK_FOCUS_CHANGE_MASK)) break; event->focus_change.type = GDK_FOCUS_CHANGE; @@ -4509,7 +4048,7 @@ gdk_event_translate (GdkEvent *event, if (GDK_DRAWABLE_DESTROYED (window)) break; - colormap_private = (GdkColormapPrivate *) WINDOW_PRIVATE(window)->drawable.colormap; + colormap_private = (GdkColormapPrivateWin32 *) ((GdkWindowPrivate *) window)->drawable.colormap; hdc = (HDC) xevent->wParam; if (colormap_private && colormap_private->xcolormap->rc_palette) @@ -4529,25 +4068,25 @@ gdk_event_translate (GdkEvent *event, *ret_val_flagp = TRUE; *ret_valp = 1; - if (WINDOW_PRIVATE(window)->bg_type == GDK_WIN32_BG_TRANSPARENT) + if (GDK_WINDOW_WIN32DATA(window)->bg_type == GDK_WIN32_BG_TRANSPARENT) break; - if (WINDOW_PRIVATE(window)->bg_type == GDK_WIN32_BG_PARENT_RELATIVE) + if (GDK_WINDOW_WIN32DATA(window)->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 - && WINDOW_PRIVATE(window)->bg_type == GDK_WIN32_BG_PARENT_RELATIVE) + && GDK_WINDOW_WIN32DATA(window)->bg_type == GDK_WIN32_BG_PARENT_RELATIVE) { gdk_window_unref (window); - window = WINDOW_PRIVATE(window)->parent; + window = ((GdkWindowPrivate *) window)->parent; gdk_window_ref (window); } } - if (WINDOW_PRIVATE(window)->bg_type == GDK_WIN32_BG_PIXEL) + if (GDK_WINDOW_WIN32DATA(window)->bg_type == GDK_WIN32_BG_PIXEL) { COLORREF bg; GetClipBox (hdc, &rect); @@ -4556,11 +4095,11 @@ gdk_event_translate (GdkEvent *event, rect.right - rect.left, rect.bottom - rect.top, rect.left, rect.top, - gdk_color_to_string (&WINDOW_PRIVATE(window)->bg_pixel))); + gdk_color_to_string (&GDK_WINDOW_WIN32DATA(window)->bg_pixel))); bg = GetNearestColor - (hdc, RGB (WINDOW_PRIVATE(window)->bg_pixel.red >> 8, - WINDOW_PRIVATE(window)->bg_pixel.green >> 8, - WINDOW_PRIVATE(window)->bg_pixel.blue >> 8)); + (hdc, RGB (GDK_WINDOW_WIN32DATA(window)->bg_pixel.red >> 8, + GDK_WINDOW_WIN32DATA(window)->bg_pixel.green >> 8, + GDK_WINDOW_WIN32DATA(window)->bg_pixel.blue >> 8)); hbr = CreateSolidBrush (bg); #if 0 g_print ("...CreateSolidBrush (%.08x) = %.08x\n", bg, hbr); @@ -4569,17 +4108,17 @@ gdk_event_translate (GdkEvent *event, g_warning ("WM_ERASEBKGND: FillRect failed"); DeleteObject (hbr); } - else if (WINDOW_PRIVATE(window)->bg_type == GDK_WIN32_BG_PIXMAP) + else if (GDK_WINDOW_WIN32DATA(window)->bg_type == GDK_WIN32_BG_PIXMAP) { - pixmap_private = - (GdkDrawablePrivate*) WINDOW_PRIVATE(window)->bg_pixmap; + pixmap = GDK_WINDOW_WIN32DATA(window)->bg_pixmap; + pixmap_private = (GdkDrawablePrivate*) pixmap; GetClipBox (hdc, &rect); if (pixmap_private->width <= 8 && pixmap_private->height <= 8) { GDK_NOTE (EVENTS, g_print ("...small pixmap, using brush\n")); - hbr = CreatePatternBrush (pixmap_private->xwindow); + hbr = CreatePatternBrush (GDK_DRAWABLE_XID (pixmap)); if (!FillRect (hdc, &rect, hbr)) g_warning ("WM_ERASEBKGND: FillRect failed"); DeleteObject (hbr); @@ -4590,7 +4129,7 @@ gdk_event_translate (GdkEvent *event, g_print ("...blitting pixmap %#x (%dx%d) " "all over the place,\n" "...clip box = %dx%d@+%d+%d\n", - pixmap_private->xwindow, + GDK_DRAWABLE_XID (pixmap), pixmap_private->width, pixmap_private->height, rect.right - rect.left, rect.bottom - rect.top, rect.left, rect.top)); @@ -4600,7 +4139,7 @@ gdk_event_translate (GdkEvent *event, g_warning ("WM_ERASEBKGND: CreateCompatibleDC failed"); break; } - if (!(oldbitmap = SelectObject (bgdc, pixmap_private->xwindow))) + if (!(oldbitmap = SelectObject (bgdc, GDK_DRAWABLE_XID (pixmap)))) { g_warning ("WM_ERASEBKGND: SelectObject failed"); DeleteDC (bgdc); @@ -4656,7 +4195,7 @@ gdk_event_translate (GdkEvent *event, EndPaint (xevent->hwnd, &paintstruct); - if (!(WINDOW_PRIVATE(window)->event_mask & GDK_EXPOSURE_MASK)) + if (!(GDK_WINDOW_WIN32DATA(window)->event_mask & GDK_EXPOSURE_MASK)) break; event->expose.type = GDK_EXPOSE; @@ -4696,11 +4235,11 @@ gdk_event_translate (GdkEvent *event, SetCursor (p_grab_cursor); } else if (!GDK_DRAWABLE_DESTROYED (window) - && WINDOW_PRIVATE(window)->xcursor) + && GDK_WINDOW_WIN32DATA(window)->xcursor) { GDK_NOTE (EVENTS, g_print ("...SetCursor(%#x)\n", - WINDOW_PRIVATE(window)->xcursor)); - SetCursor (WINDOW_PRIVATE(window)->xcursor); + GDK_WINDOW_WIN32DATA(window)->xcursor)); + SetCursor (GDK_WINDOW_WIN32DATA(window)->xcursor); } if (window != curWnd) @@ -4715,7 +4254,7 @@ gdk_event_translate (GdkEvent *event, xevent->hwnd, xevent->wParam)); - if (!(WINDOW_PRIVATE(window)->event_mask & GDK_STRUCTURE_MASK)) + if (!(GDK_WINDOW_WIN32DATA(window)->event_mask & GDK_STRUCTURE_MASK)) break; event->any.type = (xevent->wParam ? GDK_MAP : GDK_UNMAP); @@ -4743,7 +4282,7 @@ gdk_event_translate (GdkEvent *event, (xevent->wParam == SIZE_RESTORED ? "RESTORED" : "?"))))), LOWORD (xevent->lParam), HIWORD (xevent->lParam))); - if (!(WINDOW_PRIVATE(window)->event_mask & GDK_STRUCTURE_MASK)) + if (!(GDK_WINDOW_WIN32DATA(window)->event_mask & GDK_STRUCTURE_MASK)) break; if (xevent->wParam == SIZE_MINIMIZED) @@ -4778,16 +4317,16 @@ gdk_event_translate (GdkEvent *event, event->configure.y = pt.y; event->configure.width = LOWORD (xevent->lParam); event->configure.height = HIWORD (xevent->lParam); - WINDOW_PRIVATE(window)->x = event->configure.x; - WINDOW_PRIVATE(window)->y = event->configure.y; - WINDOW_PRIVATE(window)->drawable.width = event->configure.width; - WINDOW_PRIVATE(window)->drawable.height = event->configure.height; - if (WINDOW_PRIVATE(window)->resize_count > 1) - WINDOW_PRIVATE(window)->resize_count -= 1; + ((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; return_val = !GDK_DRAWABLE_DESTROYED (window); if (return_val - && WINDOW_PRIVATE(window)->extension_events != 0 + && ((GdkWindowPrivate *) window)->extension_events != 0 && gdk_input_vtable.configure_event) gdk_input_vtable.configure_event (&event->configure, window); } @@ -4797,18 +4336,18 @@ gdk_event_translate (GdkEvent *event, GDK_NOTE (EVENTS, g_print ("WM_GETMINMAXINFO: %#x\n", xevent->hwnd)); lpmmi = (MINMAXINFO*) xevent->lParam; - if (WINDOW_PRIVATE(window)->hint_flags & GDK_HINT_MIN_SIZE) + if (GDK_WINDOW_WIN32DATA(window)->hint_flags & GDK_HINT_MIN_SIZE) { - lpmmi->ptMinTrackSize.x = WINDOW_PRIVATE(window)->hint_min_width; - lpmmi->ptMinTrackSize.y = WINDOW_PRIVATE(window)->hint_min_height; + lpmmi->ptMinTrackSize.x = GDK_WINDOW_WIN32DATA(window)->hint_min_width; + lpmmi->ptMinTrackSize.y = GDK_WINDOW_WIN32DATA(window)->hint_min_height; } - if (WINDOW_PRIVATE(window)->hint_flags & GDK_HINT_MAX_SIZE) + if (GDK_WINDOW_WIN32DATA(window)->hint_flags & GDK_HINT_MAX_SIZE) { - lpmmi->ptMaxTrackSize.x = WINDOW_PRIVATE(window)->hint_max_width; - lpmmi->ptMaxTrackSize.y = WINDOW_PRIVATE(window)->hint_max_height; + lpmmi->ptMaxTrackSize.x = GDK_WINDOW_WIN32DATA(window)->hint_max_width; + lpmmi->ptMaxTrackSize.y = GDK_WINDOW_WIN32DATA(window)->hint_max_height; - lpmmi->ptMaxSize.x = WINDOW_PRIVATE(window)->hint_max_width; - lpmmi->ptMaxSize.y = WINDOW_PRIVATE(window)->hint_max_height; + lpmmi->ptMaxSize.x = GDK_WINDOW_WIN32DATA(window)->hint_max_width; + lpmmi->ptMaxSize.y = GDK_WINDOW_WIN32DATA(window)->hint_max_height; } break; @@ -4817,7 +4356,7 @@ gdk_event_translate (GdkEvent *event, xevent->hwnd, LOWORD (xevent->lParam), HIWORD (xevent->lParam))); - if (!(WINDOW_PRIVATE(window)->event_mask & GDK_STRUCTURE_MASK)) + if (!(GDK_WINDOW_WIN32DATA(window)->event_mask & GDK_STRUCTURE_MASK)) break; if (GDK_DRAWABLE_TYPE (window) != GDK_WINDOW_CHILD) @@ -4829,10 +4368,10 @@ gdk_event_translate (GdkEvent *event, GetClientRect (xevent->hwnd, &rect); event->configure.width = rect.right; event->configure.height = rect.bottom; - WINDOW_PRIVATE(window)->x = event->configure.x; - WINDOW_PRIVATE(window)->y = event->configure.y; - WINDOW_PRIVATE(window)->drawable.width = event->configure.width; - WINDOW_PRIVATE(window)->drawable.height = event->configure.height; + ((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; return_val = !GDK_DRAWABLE_DESTROYED (window); } @@ -4861,7 +4400,6 @@ gdk_event_translate (GdkEvent *event, case WM_RENDERALLFORMATS: flag = FALSE; GDK_NOTE (EVENTS, flag = TRUE); - GDK_NOTE (SELECTION, flag = TRUE); if (flag) g_print ("WM_%s: %#x %#x (%s)\n", (xevent->message == WM_RENDERFORMAT ? "RENDERFORMAT" : @@ -4933,22 +4471,25 @@ gdk_event_translate (GdkEvent *event, * constants as case labels. */ case WT_PACKET: - GDK_NOTE (EVENTS, g_print ("WT_PACKET: %d %#x\n", + GDK_NOTE (EVENTS, g_print ("WT_PACKET: %#x %d %#x\n", + xevent->hwnd, xevent->wParam, xevent->lParam)); goto wintab; case WT_CSRCHANGE: - GDK_NOTE (EVENTS, g_print ("WT_CSRCHANGE: %d %#x\n", + GDK_NOTE (EVENTS, g_print ("WT_CSRCHANGE: %#x %d %#x\n", + xevent->hwnd, xevent->wParam, xevent->lParam)); goto wintab; case WT_PROXIMITY: GDK_NOTE (EVENTS, - g_print ("WT_PROXIMITY: %#x %d %d\n", - xevent->wParam, + g_print ("WT_PROXIMITY: %#x %#x %d %d\n", + xevent->hwnd, xevent->wParam, LOWORD (xevent->lParam), HIWORD (xevent->lParam))); /* Fall through */ wintab: + event->any.window = window; return_val = gdk_input_vtable.other_event(event, xevent); break; #endif @@ -4980,7 +4521,7 @@ bypass_switch: return return_val; } -static void +void gdk_events_queue (void) { GList *node; @@ -5080,24 +4621,6 @@ gdk_event_check (gpointer source_data, return retval; } -static GdkEvent* -gdk_event_unqueue (void) -{ - GdkEvent *event = NULL; - GList *tmp_list; - - tmp_list = gdk_event_queue_find_first (); - - if (tmp_list) - { - event = tmp_list->data; - gdk_event_queue_remove_link (tmp_list); - g_list_free_1 (tmp_list); - } - - return event; -} - static gboolean gdk_event_dispatch (gpointer source_data, GTimeVal *current_time, @@ -5112,8 +4635,8 @@ gdk_event_dispatch (gpointer source_data, if (event) { - if (event_func) - (*event_func) (event, event_data); + if (gdk_event_func) + (*gdk_event_func) (event, gdk_event_data); gdk_event_free (event); } @@ -5123,60 +4646,6 @@ gdk_event_dispatch (gpointer source_data, return TRUE; } -static void -gdk_synthesize_click (GdkEvent *event, - gint nclicks) -{ - GdkEvent temp_event; - - g_return_if_fail (event != NULL); - - temp_event = *event; - temp_event.type = (nclicks == 2) ? GDK_2BUTTON_PRESS : GDK_3BUTTON_PRESS; - - gdk_event_put (&temp_event); -} - -void -gdk_event_button_generate (GdkEvent *event) -{ - if ((event->button.time < (button_click_time[1] + TRIPLE_CLICK_TIME)) && - (event->button.window == button_window[1]) && - (event->button.button == button_number[1])) - { - gdk_synthesize_click (event, 3); - - button_click_time[1] = 0; - button_click_time[0] = 0; - button_window[1] = NULL; - button_window[0] = 0; - button_number[1] = -1; - button_number[0] = -1; - } - else if ((event->button.time < (button_click_time[0] + DOUBLE_CLICK_TIME)) && - (event->button.window == button_window[0]) && - (event->button.button == button_number[0])) - { - gdk_synthesize_click (event, 2); - - button_click_time[1] = button_click_time[0]; - button_click_time[0] = event->button.time; - button_window[1] = button_window[0]; - button_window[0] = event->button.window; - button_number[1] = button_number[0]; - button_number[0] = event->button.button; - } - else - { - button_click_time[1] = 0; - button_click_time[0] = event->button.time; - button_window[1] = NULL; - button_window[0] = event->button.window; - button_number[1] = -1; - button_number[0] = event->button.button; - } -} - /* Sends a ClientMessage to all toplevel client windows */ gboolean gdk_event_send_client_message (GdkEvent *event, guint32 xid) diff --git a/gdk/win32/gdkgc-win32.c b/gdk/win32/gdkgc-win32.c index 407335a7a2..9066dcd900 100644 --- a/gdk/win32/gdkgc-win32.c +++ b/gdk/win32/gdkgc-win32.c @@ -899,9 +899,10 @@ gdk_gc_copy (GdkGC *dst_gc, GdkGC *src_gc) } HDC -gdk_gc_predraw (GdkDrawablePrivate *drawable_private, - GdkGCPrivate *gc_private) +gdk_gc_predraw (GdkDrawable *drawable, + GdkGCPrivate *gc_private) { + GdkDrawablePrivate *drawable_private = (GdkDrawablePrivate *) drawable; GdkColormapPrivate *colormap_private = (GdkColormapPrivate *) drawable_private->colormap; COLORREF bg; @@ -912,7 +913,7 @@ gdk_gc_predraw (GdkDrawablePrivate *drawable_private, g_assert (gc_private->xgc == NULL); - if (drawable_private->window_type == GDK_DRAWABLE_PIXMAP) + if (GDK_DRAWABLE_TYPE (drawable) == GDK_DRAWABLE_PIXMAP) { if ((gc_private->xgc = CreateCompatibleDC (NULL)) == NULL) g_warning ("gdk_gc_predraw: CreateCompatibleDC failed"); @@ -1082,13 +1083,14 @@ gdk_gc_predraw (GdkDrawablePrivate *drawable_private, } void -gdk_gc_postdraw (GdkDrawablePrivate *drawable_private, - GdkGCPrivate *gc_private) +gdk_gc_postdraw (GdkDrawable *drawable_private, + GdkGCPrivate *gc_private) { - HGDIOBJ hpen; - HGDIOBJ hbr; + GdkDrawablePrivate *drawable_private = (GdkDrawablePrivate *) drawable; GdkColormapPrivate *colormap_private = (GdkColormapPrivate *) drawable_private->colormap; + HGDIOBJ hpen; + HGDIOBJ hbr; if ((hpen = GetCurrentObject (gc_private->xgc, OBJ_PEN)) == NULL) g_warning ("gdk_gc_postdraw: GetCurrentObject #1 failed"); @@ -1108,7 +1110,7 @@ gdk_gc_postdraw (GdkDrawablePrivate *drawable_private, g_warning ("gdk_gc_postraw: UnrealizeObject failed"); } #endif - if (drawable_private->window_type == GDK_DRAWABLE_PIXMAP) + if (GDK_DRAWABLE_TYPE (drawable) == GDK_DRAWABLE_PIXMAP) { if (!DeleteDC (gc_private->xgc)) g_warning ("gdk_gc_postdraw: DeleteDC failed"); diff --git a/gdk/win32/gdkinput-win32.c b/gdk/win32/gdkinput-win32.c index 2335e989c5..bd73d8b032 100644 --- a/gdk/win32/gdkinput-win32.c +++ b/gdk/win32/gdkinput-win32.c @@ -1001,7 +1001,10 @@ gdk_input_win32_other_event (GdkEvent *event, gint x, y; if (event->any.window != wintab_window) - g_warning ("gdk_input_win32_other_event: not wintab_window?"); + { + g_warning ("gdk_input_win32_other_event: not wintab_window?"); + return FALSE; + } #if USE_SYSCONTEXT window = gdk_window_at_pointer (&x, &y); diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h index 30b276d42b..90e2f22675 100644 --- a/gdk/win32/gdkprivate-win32.h +++ b/gdk/win32/gdkprivate-win32.h @@ -24,8 +24,8 @@ * GTK+ at ftp://ftp.gtk.org/pub/gtk/. */ -#ifndef __GDK_PRIVATE_H__ -#define __GDK_PRIVATE_H__ +#ifndef __GDK_PRIVATE_WIN32_H__ +#define __GDK_PRIVATE_WIN32_H__ #define STRICT /* We want strict type checks */ #include @@ -58,6 +58,7 @@ #include #include +#include #include #include @@ -65,19 +66,9 @@ #include #include #include -#include #include #include -#define GDK_DRAWABLE_TYPE(d) (((GdkDrawablePrivate *)d)->window_type) -#define GDK_IS_WINDOW(d) (GDK_DRAWABLE_TYPE(d) <= GDK_WINDOW_TEMP || \ - GDK_DRAWABLE_TYPE(d) == GDK_WINDOW_FOREIGN) -#define GDK_IS_PIXMAP(d) (GDK_DRAWABLE_TYPE(d) == GDK_DRAWABLE_PIXMAP) -#define GDK_DRAWABLE_DESTROYED(d) (((GdkDrawablePrivate *)d)->destroyed) - -#define gdk_window_lookup(xid) ((GdkWindow*) gdk_xid_table_lookup (xid)) -#define gdk_pixmap_lookup(xid) ((GdkPixmap*) gdk_xid_table_lookup (xid)) - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -85,13 +76,8 @@ extern "C" { /* Define corresponding Windows types for some X11 types, just for laziness. */ -typedef HANDLE XID; typedef PALETTEENTRY XColor; -typedef HDC GC; -typedef ATOM Atom; -typedef HCURSOR Cursor; typedef guint VisualID; -typedef DWORD KeySym; typedef int Status; /* Define some of the X11 constants also here, again just for laziness */ @@ -106,10 +92,6 @@ typedef int Status; #define GrabSuccess 0 #define AlreadyGrabbed 2 -/* For CreateColormap */ -#define AllocNone 0 -#define AllocAll 1 - /* Some structs are somewhat useful to emulate internally, just to keep the code less #ifdefed. */ typedef struct { @@ -139,46 +121,62 @@ typedef struct { unsigned long base_pixel; } XStandardColormap; -typedef struct _GdkDrawablePrivate GdkDrawablePrivate; -/* typedef struct _GdkDrawablePrivate GdkPixmapPrivate; */ -typedef struct _GdkWindowPrivate GdkWindowPrivate; -typedef struct _GdkImagePrivate GdkImagePrivate; -typedef struct _GdkGCPrivate GdkGCPrivate; -typedef struct _GdkColormapPrivate GdkColormapPrivate; -typedef struct _GdkColorInfo GdkColorInfo; -typedef struct _GdkVisualPrivate GdkVisualPrivate; -typedef struct _GdkFontPrivate GdkFontPrivate; -typedef struct _GdkCursorPrivate GdkCursorPrivate; -typedef struct _GdkEventFilter GdkEventFilter; -typedef struct _GdkClientFilter GdkClientFilter; -typedef struct _GdkRegionPrivate GdkRegionPrivate; +typedef struct _GdkGCWin32Data GdkGCWin32Data; +typedef struct _GdkDrawableWin32Data GdkDrawableWin32Data; +typedef struct _GdkWindowWin32Data GdkWindowWin32Data; +typedef struct _GdkColormapPrivateWin32 GdkColormapPrivateWin32; +typedef struct _GdkCursorPrivate GdkCursorPrivate; +typedef struct _GdkFontPrivateWin32 GdkFontPrivateWin32; +typedef struct _GdkImagePrivateWin32 GdkImagePrivateWin32; +typedef struct _GdkVisualPrivate GdkVisualPrivate; +typedef struct _GdkRegionPrivate GdkRegionPrivate; +typedef struct _GdkICPrivate GdkICPrivate; -struct _GdkDrawablePrivate +#define GDK_DRAWABLE_WIN32DATA(win) ((GdkDrawableWin32Data *)(((GdkDrawablePrivate*)(win))->klass_data)) +#define GDK_WINDOW_WIN32DATA(win) ((GdkWindowWin32Data *)(((GdkDrawablePrivate*)(win))->klass_data)) +#define GDK_GC_WIN32DATA(gc) ((GdkGCWin32Data *)(((GdkGCPrivate*)(gc))->klass_data)) + +struct _GdkGCWin32Data { - GdkDrawable drawable; - - guint8 window_type; - guint ref_count; - - guint16 width; - guint16 height; - - HANDLE xwindow; - GdkColormap *colormap; - - guint destroyed : 2; + /* A Windows Device Context (DC) is not equivalent to an X11 + * GC. We can use a DC only in the window for which it was + * allocated, or (in the case of a memory DC) with the bitmap that + * has been selected into it. Thus, we have to release and + * reallocate a DC each time the GdkGC is used to paint into a new + * window or pixmap. We thus keep all the necessary values in the + * GdkGCPrivate struct. + */ + HDC xgc; + GdkGCValuesMask values_mask; + GdkColor foreground; + GdkColor background; + GdkFont *font; + gint rop2; + GdkFill fill_style; + GdkPixmap *tile; + GdkPixmap *stipple; + HRGN clip_region; + GdkSubwindowMode subwindow_mode; + gint ts_x_origin; + gint ts_y_origin; + gint clip_x_origin; + gint clip_y_origin; + gint graphics_exposures; + gint pen_width; + DWORD pen_style; + HANDLE hwnd; /* If a DC is allocated, for which window + or what bitmap is selected into it */ + int saved_dc; }; -struct _GdkWindowPrivate +struct _GdkDrawableWin32Data { - GdkDrawablePrivate drawable; + HANDLE xid; +}; - GdkWindow *parent; - gint16 x; - gint16 y; - guint8 resize_count; - guint mapped : 1; - guint guffaw_gravity : 1; +struct _GdkWindowWin32Data +{ + GdkDrawableWin32Data drawable; /* We must keep the event mask here to filter them ourselves */ gint event_mask; @@ -206,93 +204,14 @@ struct _GdkWindowPrivate gint extension_events; gboolean extension_events_selected; - GList *filters; - GList *children; - HKL input_locale; CHARSETINFO charset_info; }; -struct _GdkImagePrivate +struct _GdkCursorPrivate { - GdkImage image; - HBITMAP ximage; - gpointer x_shm_info; - - void (*image_put) (GdkDrawable *window, - GdkGC *gc, - GdkImage *image, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height); -}; - -struct _GdkGCPrivate -{ - GdkGC gc; - GC xgc; - /* A Windows Device Context (DC) is not equivalent to an X11 - * GC. We can use a DC only in the window for which it was - * allocated, or (in the case of a memory DC) with the bitmap that - * has been selected into it. Thus, we have to release and - * reallocate a DC each time the GdkGC is used to paint into a new - * window or pixmap. We thus keep all the necessary values in the - * GdkGCPrivate struct. - */ - GdkGCValuesMask values_mask; - GdkColor foreground; - GdkColor background; - GdkFont *font; - gint rop2; - GdkFill fill_style; - GdkPixmap *tile; - GdkPixmap *stipple; - HRGN clip_region; - GdkSubwindowMode subwindow_mode; - gint ts_x_origin; - gint ts_y_origin; - gint clip_x_origin; - gint clip_y_origin; - gint graphics_exposures; - gint pen_width; - DWORD pen_style; - HANDLE hwnd; /* If a DC is allocated, for which window - or what bitmap is selected into it */ - int saved_dc; - guint ref_count; -}; - -typedef enum { - GDK_COLOR_WRITEABLE = 1 << 0 -} GdkColorInfoFlags; - -struct _GdkColorInfo -{ - GdkColorInfoFlags flags; - guint ref_count; -}; - -struct _GdkColormapPrivate -{ - GdkColormap colormap; - Colormap xcolormap; - GdkVisual *visual; - gint private_val; - - GHashTable *hash; - GdkColorInfo *info; - time_t last_sync_time; - - guint ref_count; -}; - -struct _GdkVisualPrivate -{ - GdkVisual visual; - Visual *xvisual; + GdkCursor cursor; + HCURSOR xcursor; }; typedef struct @@ -304,30 +223,35 @@ typedef struct FONTSIGNATURE fs; } GdkWin32SingleFont; -struct _GdkFontPrivate +struct _GdkFontPrivateWin32 { - GdkFont font; - guint ref_count; - - GSList *fonts; + GdkFontPrivate base; + GSList *fonts; /* Points to a list of GdkWin32SingleFonts */ GSList *names; }; -struct _GdkCursorPrivate +struct _GdkVisualPrivate { - GdkCursor cursor; - Cursor xcursor; + GdkVisual visual; + Visual *xvisual; }; -struct _GdkEventFilter { - GdkFilterFunc function; - gpointer data; +struct _GdkColormapPrivateWin32 +{ + GdkColormapPrivate base; + Colormap xcolormap; + GdkVisual *visual; + gint private_val; + + GHashTable *hash; + GdkColorInfo *info; + time_t last_sync_time; }; -struct _GdkClientFilter { - GdkAtom type; - GdkFilterFunc function; - gpointer data; +struct _GdkImagePrivateWin32 +{ + GdkImagePrivate base; + HBITMAP ximage; }; struct _GdkRegionPrivate @@ -336,85 +260,58 @@ struct _GdkRegionPrivate HRGN xregion; }; -typedef enum { - GDK_DEBUG_MISC = 1 << 0, - GDK_DEBUG_EVENTS = 1 << 1, - GDK_DEBUG_DND = 1 << 2, - GDK_DEBUG_COLOR_CONTEXT = 1 << 3, - GDK_DEBUG_XIM = 1 << 4, - GDK_DEBUG_SELECTION = 1 << 5 -} GdkDebugFlag; - -void gdk_events_init (void); -void gdk_window_init (void); -void gdk_visual_init (void); void gdk_selection_init (void); -void gdk_dnd_init (void); -void gdk_dnd_exit (void); -void gdk_image_init (void); -void gdk_image_exit (void); +void gdk_dnd_exit (void); GdkColormap* gdk_colormap_lookup (Colormap xcolormap); GdkVisual* gdk_visual_lookup (Visual *xvisual); -void gdk_window_add_colormap_windows (GdkWindow *window); -void gdk_window_destroy_notify (GdkWindow *window); +void gdk_xid_table_insert (HANDLE *hnd, + gpointer data); +void gdk_xid_table_remove (HANDLE xid); +gpointer gdk_xid_table_lookup (HANDLE xid); -void gdk_xid_table_insert (XID *xid, - gpointer data); -void gdk_xid_table_remove (XID xid); -gpointer gdk_xid_table_lookup (XID xid); +GdkGC * _gdk_win32_gc_new (GdkDrawable *drawable, + GdkGCValues *values, + GdkGCValuesMask values_mask); +HDC gdk_gc_predraw (GdkDrawable *drawable, + GdkGCPrivate *gc_private); +void gdk_gc_postdraw (GdkDrawable *drawable, + GdkGCPrivate *gc_private); +HRGN BitmapToRegion (HBITMAP hBmp); -/* Internal functions */ +void gdk_sel_prop_store (GdkWindow *owner, + GdkAtom type, + gint format, + guchar *data, + gint length); -HDC gdk_gc_predraw (GdkDrawablePrivate *drawable_private, - GdkGCPrivate *gc_private); -void gdk_gc_postdraw (GdkDrawablePrivate *drawable_private, - GdkGCPrivate *gc_private); -HRGN BitmapToRegion (HBITMAP hBmp); +gint gdk_nmbstowcs (GdkWChar *dest, + const gchar *src, + gint src_len, + gint dest_max); +gint gdk_nmbstowchar_ts (wchar_t *dest, + const gchar *src, + gint src_len, + gint dest_max); -void gdk_sel_prop_store (GdkWindow *owner, - GdkAtom type, - gint format, - guchar *data, - gint length); +void gdk_wchar_text_handle (GdkFont *font, + const wchar_t *wcstr, + int wclen, + void (*handler)(GdkWin32SingleFont *, + const wchar_t *, + int, + void *), + void *arg); -void gdk_event_queue_append (GdkEvent *event); +char *gdk_color_to_string (const GdkColor *); -gint gdk_nmbstowcs (GdkWChar *dest, - const gchar *src, - gint src_len, - gint dest_max); -gint gdk_nmbstowchar_ts (wchar_t *dest, - const gchar *src, - gint src_len, - gint dest_max); +extern LRESULT CALLBACK gdk_WindowProc (HWND, UINT, WPARAM, LPARAM); -void gdk_wchar_text_handle (GdkFont *font, - const wchar_t *wcstr, - int wclen, - void (*handler)(GdkWin32SingleFont *, - const wchar_t *, - int, - void *), - void *arg); - -/* Please see gdkwindow.c for comments on how to use */ -HWND gdk_window_xid_at(HWND base, gint bx, gint by, gint x, gint y, GList *excludes, gboolean excl_child); -HWND gdk_window_xid_at_coords(gint x, gint y, GList *excludes, gboolean excl_child); - -extern gint gdk_debug_level; -extern gint gdk_show_events; -extern gint gdk_stack_trace; extern HWND gdk_root_window; -extern HWND gdk_leader_window; -GDKVAR GdkWindowPrivate *gdk_root_parent; -GDKVAR Atom gdk_selection_property; +GDKVAR ATOM gdk_selection_property; GDKVAR gchar *gdk_progclass; -GDKVAR gint gdk_error_code; -GDKVAR gint gdk_error_warnings; -GDKVAR gint gdk_null_window_warnings; -extern gint gdk_event_func_from_window_proc; +extern gboolean gdk_event_func_from_window_proc; extern HDC gdk_DC; extern HINSTANCE gdk_DLLInstance; @@ -427,33 +324,11 @@ extern GdkAtom gdk_clipboard_atom; extern GdkAtom gdk_win32_dropfiles_atom; extern GdkAtom gdk_ole2_dnd_atom; -extern LRESULT CALLBACK gdk_WindowProc (HWND, UINT, WPARAM, LPARAM); - extern DWORD windows_version; -/* Debugging support */ - -#ifdef G_ENABLE_DEBUG - -#define GDK_NOTE(type,action) G_STMT_START { \ - if (gdk_debug_flags & GDK_DEBUG_##type) \ - { action; }; } G_STMT_END - -#else /* !G_ENABLE_DEBUG */ - -#define GDK_NOTE(type,action) - -#endif /* G_ENABLE_DEBUG */ - -GDKVAR guint gdk_debug_flags; - -/* Internal functions for debug output etc. */ - -char *gdk_color_to_string (GdkColor *); - #ifdef __cplusplus } #endif /* __cplusplus */ -#endif /* __GDK_PRIVATE_H__ */ +#endif /* __GDK_PRIVATE_WIN32_H__ */ diff --git a/gdk/win32/gdkwin32.h b/gdk/win32/gdkwin32.h index 3eeacccd2c..6cc05a7413 100644 --- a/gdk/win32/gdkwin32.h +++ b/gdk/win32/gdkwin32.h @@ -36,9 +36,7 @@ #define GDK_ROOT_PARENT() ((GdkWindow *) gdk_root_parent) #define GDK_DISPLAY() NULL #define GDK_DRAWABLE_XDISPLAY(win) NULL -#define GDK_DRAWABLE_XID(win) (((GdkDrawablePrivate*) win)->xwindow) -#define GDK_WINDOW_XDISPLAY GDK_DRAWABLE_XDISPLAY -#define GDK_WINDOW_XWINDOW GDK_DRAWABLE_XID +#define GDK_DRAWABLE_XID(win) (GDK_DRAWABLE_WIN32DATA(win)->xid) #define GDK_IMAGE_XDISPLAY(image) NULL #define GDK_IMAGE_XIMAGE(image) (((GdkImagePrivate*) image)->ximage) #define GDK_GC_XDISPLAY(gc) NULL @@ -47,6 +45,9 @@ #define GDK_COLORMAP_XCOLORMAP(cmap) (((GdkColormapPrivate*) cmap)->xcolormap) #define GDK_VISUAL_XVISUAL(vis) (((GdkVisualPrivate*) vis)->xvisual) +#define GDK_WINDOW_XDISPLAY GDK_DRAWABLE_XDISPLAY +#define GDK_WINDOW_XWINDOW GDK_DRAWABLE_XID + GdkVisual* gdkx_visual_get (VisualID xvisualid); /* Functions to create GDK pixmaps and windows from their native equivalents */ diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index d8b5177acf..40c64f169d 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -121,6 +121,7 @@ gdk_window_init (void) gdk_root_parent->drawable.height = height; gdk_root_parent->drawable.ref_count = 1; gdk_root_parent->drawable.colormap = NULL; + gdk_root_parent->parent = NULL; gdk_root_parent->children = NULL; gdk_xid_table_insert (&gdk_root_window, gdk_root_parent);