summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
Diffstat (limited to 'gdk')
-rw-r--r--gdk/gdk.def2
-rw-r--r--gdk/gdkconfig.h.win3222
-rw-r--r--gdk/win32/gdkcolor-win32.c1167
-rw-r--r--gdk/win32/gdkcursor-win32.c74
-rw-r--r--gdk/win32/gdkdnd-win32.c23
-rw-r--r--gdk/win32/gdkdrawable-win32.c673
-rw-r--r--gdk/win32/gdkdrawable-win32.h3
-rw-r--r--gdk/win32/gdkevents-win32.c695
-rw-r--r--gdk/win32/gdkfont-win32.c1
-rw-r--r--gdk/win32/gdkgc-win32.c616
-rw-r--r--gdk/win32/gdkglobals-win32.c4
-rw-r--r--gdk/win32/gdkim-win32.c1
-rw-r--r--gdk/win32/gdkimage-win32.c715
-rw-r--r--gdk/win32/gdkinput-win32.c74
-rw-r--r--gdk/win32/gdkkeys-win32.c2
-rw-r--r--gdk/win32/gdkmain-win32.c3
-rw-r--r--gdk/win32/gdkpixmap-win32.c260
-rw-r--r--gdk/win32/gdkpixmap-win32.h4
-rw-r--r--gdk/win32/gdkprivate-win32.h164
-rw-r--r--gdk/win32/gdkvisual-win32.c204
-rw-r--r--gdk/win32/gdkwin32.h12
-rw-r--r--gdk/win32/gdkwindow-win32.c285
-rw-r--r--gdk/win32/gdkwindow-win32.h3
23 files changed, 2410 insertions, 2597 deletions
diff --git a/gdk/gdk.def b/gdk/gdk.def
index 24482ce8f3..2634560746 100644
--- a/gdk/gdk.def
+++ b/gdk/gdk.def
@@ -29,7 +29,6 @@ EXPORTS
gdk_colormap_get_system_size
gdk_colormap_get_type
gdk_colormap_get_visual
- gdk_colormap_lookup
gdk_colormap_new
gdk_colormap_query_color
gdk_colormap_ref
@@ -351,7 +350,6 @@ EXPORTS
gdk_visual_get_best_with_type
gdk_visual_get_system
gdk_visual_get_type
- gdk_visual_lookup
gdk_visual_type_get_type
gdk_wcstombs
gdk_win32_drawable_get_handle
diff --git a/gdk/gdkconfig.h.win32 b/gdk/gdkconfig.h.win32
index 6dd3dc732e..1258a460dd 100644
--- a/gdk/gdkconfig.h.win32
+++ b/gdk/gdkconfig.h.win32
@@ -1,9 +1,23 @@
-/* Handcrafted for Win32 */
+/* gdkconfig.h
+ *
+ * This is a pre-generated file.
+ */
+
+#ifndef GDKCONFIG_H
+#define GDKCONFIG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
#define GDK_WINDOWING_WIN32
+
#define GDK_HAVE_WCHAR_H 1
-#ifdef _MSC_VER
#define GDK_HAVE_WCTYPE_H 1
-#endif
-#define GDK_USE_UTF8_MBS 1
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* GDKCONFIG_H */
diff --git a/gdk/win32/gdkcolor-win32.c b/gdk/win32/gdkcolor-win32.c
index 92ae87c398..528ac67a12 100644
--- a/gdk/win32/gdkcolor-win32.c
+++ b/gdk/win32/gdkcolor-win32.c
@@ -1,5 +1,6 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * Copyright (C) 1998-2002 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -27,31 +28,20 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <time.h>
#include "gdkcolor.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
-static void free_colormap (Colormap colormap);
-
static gint gdk_colormap_match_color (GdkColormap *cmap,
GdkColor *color,
const gchar *available);
-static void gdk_colormap_add (GdkColormap *cmap);
-static void gdk_colormap_remove (GdkColormap *cmap);
-static guint gdk_colormap_hash (Colormap *cmap);
-static gboolean gdk_colormap_equal (Colormap *a,
- Colormap *b);
-
static void gdk_colormap_init (GdkColormap *colormap);
static void gdk_colormap_class_init (GdkColormapClass *klass);
static void gdk_colormap_finalize (GObject *object);
static gpointer parent_class = NULL;
-static GHashTable *colormap_hash = NULL;
-
GType
gdk_colormap_get_type (void)
{
@@ -89,8 +79,10 @@ gdk_colormap_init (GdkColormap *colormap)
colormap->windowing_data = private;
+ private->hpal = NULL;
+ private->current_size = 0;
+ private->use = NULL;
private->hash = NULL;
- private->last_sync_time = 0;
private->info = NULL;
colormap->size = 0;
@@ -111,11 +103,10 @@ static void
gdk_colormap_finalize (GObject *object)
{
GdkColormap *colormap = GDK_COLORMAP (object);
- GdkColormapPrivateWin32 *private = GDK_COLORMAP_PRIVATE_DATA (colormap);
+ GdkColormapPrivateWin32 *private = GDK_WIN32_COLORMAP_DATA (colormap);
- gdk_colormap_remove (colormap);
-
- free_colormap (private->xcolormap);
+ if (!DeleteObject (private->hpal))
+ WIN32_GDI_FAILED ("DeleteObject");
if (private->hash)
g_hash_table_destroy (private->hash);
@@ -126,71 +117,156 @@ gdk_colormap_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-static gboolean
-alloc_color_cells(Colormap colormap,
- gboolean contig,
- unsigned long plane_masks_return[],
- unsigned int nplanes,
- unsigned long pixels_return[],
- unsigned int npixels)
+static gint
+palette_size (HPALETTE hpal)
+{
+ WORD npal = 0;
+
+ if (!GetObject (hpal, sizeof (npal), &npal))
+ WIN32_GDI_FAILED ("GetObject (HPALETTE)");
+
+ return npal;
+}
+
+#ifdef G_ENABLE_DEBUG
+
+gchar *
+gdk_win32_color_to_string (const GdkColor *color)
{
- unsigned int i, nfree, iret;
+ static char buf[100];
+
+ sprintf (buf, "(%.04x,%.04x,%.04x):%.06x",
+ color->red, color->green, color->blue, color->pixel);
- nfree = 0;
- for (i = 0; i < colormap->size && nfree < npixels; i++)
- if (!colormap->in_use[i])
- nfree++;
+ return buf;
+}
- if (colormap->size + npixels - nfree > colormap->sizepalette)
+void
+gdk_win32_print_paletteentries (const PALETTEENTRY *pep,
+ const int nentries)
+{
+ char buf[20];
+ int i;
+
+ for (i = 0; i < nentries; i++)
+ g_print (" %3d %02x: %02x %02x %02x%s\n",
+ i, i,
+ pep[i].peRed, pep[i].peGreen, pep[i].peBlue,
+ (pep[i].peFlags == 0 ? "" :
+ (pep[i].peFlags == PC_EXPLICIT ? " PC_EXPLICIT" :
+ (pep[i].peFlags == PC_NOCOLLAPSE ? " PC_NOCOLLAPSE" :
+ (pep[i].peFlags == PC_RESERVED ? " PC_RESERVED" :
+ (sprintf (buf, " %d", pep[i].peFlags), buf))))));
+}
+
+void
+gdk_win32_print_system_palette (void)
+{
+ PALETTEENTRY *pe;
+ int k;
+
+ k = GetSystemPaletteEntries (gdk_display_hdc, 0, 0, NULL);
+ pe = g_new (PALETTEENTRY, k);
+ k = GetSystemPaletteEntries (gdk_display_hdc, 0, k, pe);
+
+ if (!k)
+ g_print ("GetSystemPaletteEntries failed: %s\n",
+ g_win32_error_message (GetLastError ()));
+ else
{
- g_warning ("alloc_color_cells: too large palette: %d",
- colormap->size + npixels);
- return FALSE;
+ g_print ("System palette: %d entries\n", k);
+ gdk_win32_print_paletteentries (pe, k);
}
+ g_free (pe);
+}
- iret = 0;
- for (i = 0; i < colormap->size && iret < npixels; i++)
- if (!colormap->in_use[i])
- {
- colormap->in_use[i] = TRUE;
- pixels_return[iret] = i;
- iret++;
- }
+void
+gdk_win32_print_hpalette (HPALETTE hpal)
+{
+ PALETTEENTRY *pe;
+ gint n, npal;
+
+ npal = palette_size (hpal);
+ pe = g_new (PALETTEENTRY, npal);
+ n = GetPaletteEntries (hpal, 0, npal, pe);
- if (nfree < npixels)
+ if (!n)
+ g_print ("HPALETTE %p: GetPaletteEntries failed: %s\n",
+ hpal, g_win32_error_message (GetLastError ()));
+ else
{
- int nmore = npixels - nfree;
-
- /* I don't understand why, if the code below in #if 0 is
- enabled, gdkrgb fails miserably. The palette doesn't get
- realized correctly. There doesn't seem to be any harm done by
- keeping this code out, either. */
-#ifdef SOME_STRANGE_BUG
- if (!ResizePalette (colormap->palette, colormap->size + nmore))
- {
- WIN32_GDI_FAILED ("ResizePalette")
- return FALSE;
- }
- g_print("alloc_color_cells: %#x to %d\n",
- colormap->palette, colormap->size + nmore);
+ g_print ("HPALETTE %p: %d (%d) entries\n", hpal, n, npal);
+ gdk_win32_print_paletteentries (pe, n);
+ }
+ g_free (pe);
+}
+
#endif
- for (i = colormap->size; i < colormap->size + nmore; i++)
+
+/* Mimics XAllocColorCells. Allocate read/write color cells. */
+
+static gboolean
+alloc_color_cells (GdkColormap *cmap,
+ gboolean contig,
+ unsigned long plane_masks_return[],
+ unsigned int nplanes,
+ unsigned long pixels_return[],
+ unsigned int npixels)
+{
+ GdkColormapPrivateWin32 *cmapp = GDK_WIN32_COLORMAP_DATA (cmap);
+ gint i, nfree, iret, start = 0;
+
+ GDK_NOTE (COLORMAP, g_print ("alloc_color_cells: cmap=%p contig=%s npl=%d npix=%d",
+ cmapp, contig ? "TRUE" : "FALSE",
+ nplanes, npixels));
+
+ switch (cmap->visual->type)
+ {
+ case GDK_VISUAL_GRAYSCALE:
+ case GDK_VISUAL_PSEUDO_COLOR:
+ nfree = 0;
+ for (i = 0; i < cmap->size && nfree < npixels; i++)
+ if (cmapp->use[i] == GDK_WIN32_PE_AVAILABLE &&
+ (!contig ||
+ (nfree == 0 || cmapp->use[i-1] == GDK_WIN32_PE_AVAILABLE)))
+ {
+ if (nfree == 0)
+ start = i;
+ nfree++;
+ }
+ else if (contig)
+ nfree = 0;
+
+ if (npixels > nfree)
{
- pixels_return[iret] = i;
- iret++;
- colormap->in_use[i] = TRUE;
+ GDK_NOTE (COLORMAP, g_print ("...nope (%d > %d)\n", npixels, nfree));
+ return FALSE;
}
-#ifdef SOME_STRANGE_BUG
- colormap->size += nmore;
-#endif
+ else
+ GDK_NOTE (COLORMAP, g_print ("...ok\n"));
+
+ iret = 0;
+ for (i = start; i < cmap->size && iret < npixels; i++)
+ if (cmapp->use[i] == GDK_WIN32_PE_AVAILABLE)
+ {
+ cmapp->use[i] = GDK_WIN32_PE_INUSE;
+ pixels_return[iret] = i;
+ iret++;
+ }
+ g_assert (iret == npixels);
+ break;
+
+ default:
+ g_assert_not_reached ();
}
+
return TRUE;
}
-/* The following functions are from Tk8.0, but heavily modified.
- Here are tk's licensing terms. I hope these terms don't conflict
- with the GNU Lesser General Public License? They shouldn't, as
- they are looser that the GLPL, yes? */
+/* The following functions are originally from Tk8.0, but heavily
+ modified. Here are tk's licensing terms. I hope these terms don't
+ conflict with the GNU Lesser General Public License? They
+ shouldn't, as they are looser that the GLPL, yes? */
/*
This software is copyrighted by the Regents of the University of
@@ -233,97 +309,94 @@ authors grant the U.S. Government and others acting in its behalf
permission to use and distribute the software in accordance with the
terms specified in this license.
*/
-/*
- *----------------------------------------------------------------------
- *
- * XAllocColor --
- *
- * Find the closest available color to the specified XColor.
- *
- * Results:
- * Updates the color argument and returns 1 on success. Otherwise
- * returns 0.
- *
- * Side effects:
- * Allocates a new color in the palette.
- *
- *----------------------------------------------------------------------
- */
+
+/* Mimics XAllocColor. Allocate a read-only colormap entry. */
static int
-alloc_color(Colormap colormap,
- XColor *color,
- guint *pixelp)
+alloc_color (GdkColormap *cmap,
+ PALETTEENTRY *color,
+ guint *pixelp)
{
- PALETTEENTRY entry, closeEntry;
- unsigned int i;
+ PALETTEENTRY entry, close_entry;
+ COLORREF new_pixel;
+ UINT index;
+ GdkColormapPrivateWin32 *cmapp = GDK_WIN32_COLORMAP_DATA (cmap);
+ gint i;
entry = *color;
entry.peFlags = 0;
- if (colormap->rc_palette)
+ new_pixel = RGB (entry.peRed, entry.peGreen, entry.peBlue);
+
+ switch (cmap->visual->type)
{
- COLORREF newPixel, closePixel;
- UINT index;
-
- /*
- * Find the nearest existing palette entry.
- */
-
- newPixel = RGB (entry.peRed, entry.peGreen, entry.peBlue);
- index = GetNearestPaletteIndex (colormap->palette, newPixel);
- GetPaletteEntries (colormap->palette, index, 1, &closeEntry);
- closePixel = RGB (closeEntry.peRed, closeEntry.peGreen,
- closeEntry.peBlue);
-
- if (newPixel != closePixel)
+ case GDK_VISUAL_PSEUDO_COLOR:
+ /* Find the nearest existing palette entry. */
+ index = GetNearestPaletteIndex (cmapp->hpal, new_pixel);
+ GetPaletteEntries (cmapp->hpal, index, 1, &close_entry);
+
+ GDK_NOTE (COLORMAP,
+ g_print ("alloc_color: new_pixel=%06lx index=%d=%02x close=%06lx\n",
+ new_pixel, index, index,
+ RGB (close_entry.peRed, close_entry.peGreen, close_entry.peBlue)));
+
+ if (new_pixel != RGB (close_entry.peRed, close_entry.peGreen,
+ close_entry.peBlue))
{
/* Not a perfect match. */
- if (!colormap->in_use[index])
+ if (cmapp->use[index] == GDK_WIN32_PE_AVAILABLE)
{
- /* It was a free'd entry anyway, so we can use it, and
- set it to the correct color. */
- if (SetPaletteEntries (colormap->palette, index, 1, &entry) == 0)
+ /* It was a nonused entry anyway, so we can use it, and
+ * set it to the correct color.
+ */
+ GDK_NOTE (COLORMAP, g_print ("...was free\n"));
+ if (!SetPaletteEntries (cmapp->hpal, index, 1, &entry))
WIN32_GDI_FAILED ("SetPaletteEntries");
}
else
{
/* The close entry found is in use, so search for a
- unused slot. */
-
- for (i = 0; i < colormap->size; i++)
- if (!colormap->in_use[i])
+ * available slot.
+ */
+ gboolean done = FALSE;
+ for (i = 0; i < cmap->size; i++)
+ if (cmapp->use[i] == GDK_WIN32_PE_AVAILABLE)
{
- /* A free slot, use it. */
- if (SetPaletteEntries (colormap->palette,
- index, 1, &entry) == 0)
- WIN32_GDI_FAILED ("SetPaletteEntries");
- index = i;
+ /* An available slot, use it. */
+ GDK_NOTE (COLORMAP,
+ g_print ("...use free slot %d%s\n",
+ i, (i >= cmapp->current_size) ?
+ ", will resize palette" : ""));
+ if (i >= cmapp->current_size)
+ {
+ if (!ResizePalette (cmapp->hpal, i + 1))
+ {
+ WIN32_GDI_FAILED ("ResizePalette");
+ break;
+ }
+ cmapp->current_size = i + 1;
+ }
+ if (!SetPaletteEntries (cmapp->hpal, i, 1, &entry))
+ {
+ WIN32_GDI_FAILED ("SetPaletteEntries");
+ i = cmap->size;
+ }
+ else
+ {
+ done = TRUE;
+ index = i;
+ }
break;
}
- if (i == colormap->size)
+ if (!done)
{
- /* No free slots found. If the palette isn't maximal
- yet, grow it. */
- if (colormap->size == colormap->sizepalette)
- {
- /* The palette is maximal, and no free slots available,
- so use the close entry, then, dammit. */
- *color = closeEntry;
- }
- else
- {
- /* There is room to grow the palette. */
- index = colormap->size;
- colormap->size++;
- if (!ResizePalette (colormap->palette, colormap->size))
- WIN32_GDI_FAILED ("ResizePalette");
- if (SetPaletteEntries (colormap->palette, index, 1, &entry) == 0)
- WIN32_GDI_FAILED ("SetPaletteEntries");
- }
+ /* No free slots available, or failed to resize
+ * palette or set palette entry.
+ */
+ GDK_NOTE (COLORMAP, g_print ("... failure\n"));
+ return FALSE;
}
}
- colormap->stale = TRUE;
}
else
{
@@ -331,193 +404,217 @@ alloc_color(Colormap colormap,
}
*pixelp = index;
- colormap->in_use[index] = TRUE;
-#if 0
- g_print("alloc_color from %#x: index %d for %02x %02x %02x\n",
- colormap->palette, index,
- entry.peRed, entry.peGreen, entry.peBlue);
-#endif
- }
- else
- {
- /*
- * Determine what color will actually be used on non-colormap systems.
- */
- *pixelp = GetNearestColor (gdk_display_hdc, RGB(entry.peRed, entry.peGreen, entry.peBlue));
-
+ cmapp->use[index] = GDK_WIN32_PE_INUSE;
+ GDK_NOTE (COLORMAP, g_print ("alloc_color: %p: "
+ "index=%3d=%02x for %02x %02x %02x: "
+ "%02x %02x %02x\n",
+ cmapp->hpal, index, index,
+ entry.peRed, entry.peGreen, entry.peBlue,
+ color->peRed, color->peGreen, color->peBlue));
+ return TRUE;
+
+ case GDK_VISUAL_STATIC_COLOR:
+ /* Find the nearest existing palette entry. */
+ index = GetNearestPaletteIndex (cmapp->hpal, new_pixel);
+ GetPaletteEntries (cmapp->hpal, index, 1, &close_entry);
+ *color = close_entry;
+ *pixelp = index;
+ GDK_NOTE (COLORMAP, g_print ("alloc_color %p: "
+ "index=%3d=%02x for %02x %02x %02x: "
+ "%02x %02x %02x\n",
+ cmapp->hpal, index, index,
+ entry.peRed, entry.peGreen, entry.peBlue,
+ color->peRed, color->peGreen, color->peBlue));
+ return TRUE;
+
+ case GDK_VISUAL_TRUE_COLOR:
+ /* Determine what color will actually be used on non-colormap systems. */
+
+ *pixelp = GetNearestColor (gdk_display_hdc, new_pixel);
color->peRed = GetRValue (*pixelp);
color->peGreen = GetGValue (*pixelp);
color->peBlue = GetBValue (*pixelp);
+ return TRUE;
+
+ default:
+ g_assert_not_reached ();
+ return FALSE;
}
-
- return 1;
}
-/*
- *----------------------------------------------------------------------
- *
- * XFreeColors --
- *
- * Deallocate a block of colors.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Removes entries for the current palette and compacts the
- * remaining set.
- *
- *----------------------------------------------------------------------
- */
+/* Mimics XFreeColors. */
static void
-free_colors (Colormap colormap,
- gulong *pixels,
- gint npixels,
- gulong planes)
+free_colors (GdkColormap *cmap,
+ gulong *pixels,
+ gint npixels,
+ gulong planes)
{
+ PALETTEENTRY pe;
+ GdkColormapPrivateWin32 *cmapp = GDK_WIN32_COLORMAP_DATA (cmap);
gint i;
- PALETTEENTRY entries[256];
+#ifdef G_ENABLE_DEBUG
+ gint set_explicit = 0;
+#endif
- /*
- * We don't have to do anything for non-palette devices.
- */
+ /* We don't have to do anything for non-palette devices. */
- if (colormap->rc_palette)
+ switch (cmap->visual->type)
{
- int npal;
- int lowestpixel = 256;
- int highestpixel = -1;
-
- npal = GetPaletteEntries (colormap->palette, 0, 256, entries);
+ case GDK_VISUAL_GRAYSCALE:
+ case GDK_VISUAL_PSEUDO_COLOR:
for (i = 0; i < npixels; i++)
{
- int pixel = pixels[i];
-
- if (pixel < lowestpixel)
- lowestpixel = pixel;
- if (pixel > highestpixel)
- highestpixel = pixel;
-
- colormap->in_use[pixel] = FALSE;
-
- entries[pixel] = entries[0];
+ if (pixels[i] >= cmap->size)
+ ; /* Nothing */
+ else if (cmapp->use[pixels[i]] == GDK_WIN32_PE_STATIC)
+ ; /* Nothing either*/
+ else
+ cmapp->use[pixels[i]] = GDK_WIN32_PE_AVAILABLE;
+ }
+ for (i = cmapp->current_size - 1; i >= 0; i--)
+ if (cmapp->use[i] != GDK_WIN32_PE_AVAILABLE)
+ break;
+ if (i < cmapp->current_size - 1)
+ {
+ GDK_NOTE (COLORMAP, g_print ("free_colors: hpal=%p resize=%d\n",
+ cmapp->hpal, i + 1));
+ if (!ResizePalette (cmapp->hpal, i + 1))
+ WIN32_GDI_FAILED ("ResizePalette");
+ else
+ cmapp->current_size = i + 1;
+ }
+ for (i = 0; i < cmapp->current_size; i++)
+ {
+ if (cmapp->use[i] == GDK_WIN32_PE_AVAILABLE)
+ {
+ *(WORD*)&pe = i;
+ pe.peFlags = PC_EXPLICIT;
+ if (!SetPaletteEntries (cmapp->hpal, i, 1, &pe))
+ WIN32_GDI_FAILED ("SetPaletteEntries");
+ GDK_NOTE (COLORMAP, set_explicit++);
+ }
}
#if 0
- if (SetPaletteEntries (colormap->palette, lowestpixel,
- highestpixel - lowestpixel + 1,
- entries + lowestpixel) == 0)
- WIN32_GDI_FAILED ("SetPaletteEntries");
-#endif
- colormap->stale = TRUE;
-#if 0
- g_print("free_colors %#x lowestpixel = %d, highestpixel = %d\n",
- colormap->palette, lowestpixel, highestpixel);
+ GDK_NOTE (COLORMAP, gdk_win32_print_hpalette (cmapp->hpal));
+#else
+ GDK_NOTE (COLORMAP, (set_explicit > 0 ?
+ g_print ("free_colors: %d (%d) PC_EXPLICIT\n",
+ set_explicit, cmapp->current_size)
+ : (void) 0));
#endif
+ break;
+
+ default:
+ g_assert_not_reached ();
}
}
-/*
- *----------------------------------------------------------------------
- *
- * XCreateColormap --
- *
- * Allocate a new colormap.
- *
- * Results:
- * Returns a newly allocated colormap.
- *
- * Side effects:
- * Allocates an empty palette and color list.
- *
- *----------------------------------------------------------------------
- */
+/* Mimics XCreateColormap. */
-static Colormap
-create_colormap (HWND w,
- Visual *visual,
- gboolean alloc)
+static void
+create_colormap (GdkColormap *cmap,
+ gboolean writeable)
{
- char logPalBuf[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)];
- LOGPALETTE *logPalettePtr;
- Colormap colormap;
- guint i;
- HPALETTE sysPal;
- HDC hdc;
+ struct {
+ LOGPALETTE pal;
+ PALETTEENTRY pe[256-1];
+ } lp;
+ HPALETTE hpal;
+ GdkColormapPrivateWin32 *cmapp = GDK_WIN32_COLORMAP_DATA (cmap);
+ gint i;
- /* Should the alloc parameter do something? */
+ /* Allocate a starting palette with all the static colors. */
+ hpal = GetStockObject (DEFAULT_PALETTE);
+ lp.pal.palVersion = 0x300;
+ lp.pal.palNumEntries = GetPaletteEntries (hpal, 0, 256, lp.pal.palPalEntry);
+ if (cmap->visual->type == GDK_VISUAL_STATIC_COLOR &&
+ cmap->visual->depth == 4)
+ {
+ /* Use only 16 colors */
+ for (i = 8; i < 16; i++)
+ lp.pal.palPalEntry[i] = lp.pal.palPalEntry[i+4];
+ lp.pal.palNumEntries = 16;
+ }
- /* Allocate a starting palette with all of the reserved colors. */
-
- logPalettePtr = (LOGPALETTE *) logPalBuf;
- logPalettePtr->palVersion = 0x300;
- sysPal = (HPALETTE) GetStockObject (DEFAULT_PALETTE);
- logPalettePtr->palNumEntries =
- GetPaletteEntries (sysPal, 0, 256, logPalettePtr->palPalEntry);
+ for (i = 0; i < lp.pal.palNumEntries; i++)
+ lp.pal.palPalEntry[i].peFlags = 0;
+ GDK_NOTE (COLORMAP, (g_print ("Default palette %p: %d entries\n",
+ hpal, lp.pal.palNumEntries),
+ gdk_win32_print_paletteentries (lp.pal.palPalEntry,
+ lp.pal.palNumEntries)));
+ DeleteObject (hpal);
- colormap = (Colormap) g_new (ColormapStruct, 1);
- colormap->size = logPalettePtr->palNumEntries;
- colormap->stale = TRUE;
- colormap->palette = CreatePalette (logPalettePtr);
- hdc = GetDC (NULL);
- colormap->rc_palette = ((GetDeviceCaps (hdc, RASTERCAPS) & RC_PALETTE) != 0);
- if (colormap->rc_palette)
+ /* For writeable colormaps, allow all 256 entries to be set. They won't
+ * set all 256 system palette entries anyhow, of course, but we shouldn't
+ * let the app see that, I think.
+ */
+ if (writeable)
+ cmapp->current_size = 0;
+ else
+ cmapp->current_size = lp.pal.palNumEntries;
+
+ cmapp->private_val = writeable;
+
+ if (!(cmapp->hpal = CreatePalette (&lp.pal)))
+ WIN32_GDI_FAILED ("CreatePalette");
+ else
+ GDK_NOTE (COLORMAP, g_print ("Created palette %p\n", cmapp->hpal));
+
+ switch (cmap->visual->type)
{
- colormap->sizepalette = GetDeviceCaps (hdc, SIZEPALETTE);
- colormap->in_use = g_new (gboolean, colormap->sizepalette);
+ case GDK_VISUAL_PSEUDO_COLOR:
+ cmapp->use = g_new (GdkWin32PalEntryState, cmap->size);
+
/* Mark static colors in use. */
- for (i = 0; i < logPalettePtr->palNumEntries; i++)
- colormap->in_use[i] = TRUE;
+ for (i = 0; i < cmapp->current_size; i++)
+ {
+ cmapp->use[i] = GDK_WIN32_PE_STATIC;
+ cmapp->info[i].ref_count = G_MAXUINT/2;
+ }
/* Mark rest not in use */
- for (i = logPalettePtr->palNumEntries; i < colormap->sizepalette; i++)
- colormap->in_use[i] = FALSE;
- }
- if (!ReleaseDC (NULL, hdc))
- WIN32_GDI_FAILED ("ReleaseDC");
+ for (; i < cmap->size; i++)
+ cmapp->use[i] = GDK_WIN32_PE_AVAILABLE;
+ break;
- return colormap;
+ default:
+ break;
+ }
}
-/*
- *----------------------------------------------------------------------
- *
- * XFreeColormap --
- *
- * Frees the resources associated with the given colormap.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Deletes the palette associated with the colormap. Note that
- * the palette must not be selected into a device context when
- * this occurs.
- *
- *----------------------------------------------------------------------
- */
-
static void
-free_colormap(Colormap colormap)
-
+sync_colors (GdkColormap *colormap)
{
- if (!DeleteObject (colormap->palette))
+ PALETTEENTRY *pe;
+ GdkColormapPrivateWin32 *private = GDK_WIN32_COLORMAP_DATA (colormap);
+ gint nlookup;
+ gint i;
+
+ pe = g_new (PALETTEENTRY, colormap->size);
+ nlookup = GetPaletteEntries (private->hpal, 0, colormap->size, pe);
+
+ GDK_NOTE (COLORMAP, (g_print ("sync_colors: %p hpal=%p: %d entries\n",
+ private, private->hpal, nlookup),
+ gdk_win32_print_paletteentries (pe, nlookup)));
+
+ for (i = 0; i < nlookup; i++)
{
- g_error ("Unable to free colormap, palette is still selected.");
+ colormap->colors[i].pixel = i;
+ colormap->colors[i].red = (pe[i].peRed * 65535) / 255;
+ colormap->colors[i].green = (pe[i].peGreen * 65535) / 255;
+ colormap->colors[i].blue = (pe[i].peBlue * 65535) / 255;
}
- g_free (colormap);
-}
-
-static Colormap
-default_colormap ()
-{
- static Colormap colormap;
-
- if (colormap)
- return colormap;
-
- colormap = create_colormap ( NULL, NULL, FALSE);
- return colormap;
+
+ for ( ; i < colormap->size; i++)
+ {
+ colormap->colors[i].pixel = i;
+ colormap->colors[i].red = 0;
+ colormap->colors[i].green = 0;
+ colormap->colors[i].blue = 0;
+ }
+
+ g_free (pe);
}
GdkColormap*
@@ -526,18 +623,14 @@ gdk_colormap_new (GdkVisual *visual,
{
GdkColormap *colormap;
GdkColormapPrivateWin32 *private;
- Visual *xvisual;
- int i;
g_return_val_if_fail (visual != NULL, NULL);
colormap = g_object_new (gdk_colormap_get_type (), NULL);
- private = GDK_COLORMAP_PRIVATE_DATA (colormap);
+ private = GDK_WIN32_COLORMAP_DATA (colormap);
colormap->visual = visual;
- xvisual = ((GdkVisualPrivate*) visual)->xvisual;
-
colormap->size = visual->colormap_size;
switch (visual->type)
@@ -550,97 +643,34 @@ gdk_colormap_new (GdkVisual *visual,
private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
(GEqualFunc) gdk_color_equal);
- private->private_val = private_cmap;
- private->xcolormap = create_colormap (gdk_root_window, xvisual, private_cmap);
+ create_colormap (colormap, private_cmap);
if (private_cmap)
{
- PALETTEENTRY pal[256];
- guint npal;
-
- npal = GetPaletteEntries (private->xcolormap->palette, 0, colormap->size, pal);
- for (i = 0; i < colormap->size; i++)
- {
- colormap->colors[i].pixel = i;
- if (i >= npal)
- {
- colormap->colors[i].red =
- colormap->colors[i].green =
- colormap->colors[i].blue = 0;
- }
- else
- {
- colormap->colors[i].red = (pal[i].peRed * 65535) / 255;
- colormap->colors[i].green = (pal[i].peGreen * 65525) / 255;
- colormap->colors[i].blue = (pal[i].peBlue * 65535) / 255;
- }
- }
+ sync_colors (colormap);
+#if 0 /* XXX is this needed or not? Seems redundant */
gdk_colormap_change (colormap, colormap->size);
+#endif
}
break;
case GDK_VISUAL_STATIC_GRAY:
case GDK_VISUAL_STATIC_COLOR:
+ create_colormap (colormap, FALSE);
+ colormap->colors = g_new (GdkColor, colormap->size);
+ sync_colors (colormap);
+ break;
+
case GDK_VISUAL_TRUE_COLOR:
- private->private_val = FALSE;
- private->xcolormap = create_colormap (gdk_root_window,
- xvisual, FALSE);
break;
- case GDK_VISUAL_DIRECT_COLOR:
+ default:
g_assert_not_reached ();
}
- gdk_colormap_add (colormap);
-
return colormap;
}
-#define MIN_SYNC_TIME 2
-
-static void
-gdk_colormap_sync (GdkColormap *colormap,
- gboolean force)
-{
- time_t current_time;
- GdkColormapPrivateWin32 *private = GDK_COLORMAP_PRIVATE_DATA (colormap);
- XColor *xpalette;
- gint nlookup;
- gint i;
-
- g_return_if_fail (colormap != NULL);
-
- current_time = time (NULL);
- if (!force && ((current_time - private->last_sync_time) < MIN_SYNC_TIME))
- return;
-
- private->last_sync_time = current_time;
-
- nlookup = 0;
- xpalette = g_new (XColor, colormap->size);
-
- nlookup = GetPaletteEntries (private->xcolormap->palette,
- 0, colormap->size, xpalette);
-
- for (i = 0; i < nlookup; i++)
- {
- colormap->colors[i].pixel = i;
- colormap->colors[i].red = (xpalette[i].peRed * 65535) / 255;
- colormap->colors[i].green = (xpalette[i].peGreen * 65535) / 255;
- colormap->colors[i].blue = (xpalette[i].peBlue * 65535) / 255;
- }
-
- for ( ; i < colormap->size; i++)
- {
- colormap->colors[i].pixel = i;
- colormap->colors[i].red = 0;
- colormap->colors[i].green = 0;
- colormap->colors[i].blue = 0;
- }
-
- g_free (xpalette);
-}
-
GdkColormap*
gdk_colormap_get_system (void)
{
@@ -650,31 +680,37 @@ gdk_colormap_get_system (void)
if (!colormap)
{
colormap = g_object_new (gdk_colormap_get_type (), NULL);
- private = GDK_COLORMAP_PRIVATE_DATA (colormap);
+ private = GDK_WIN32_COLORMAP_DATA (colormap);
- private->xcolormap = default_colormap ();
colormap->visual = gdk_visual_get_system ();
- private->private_val = FALSE;
-
- private->hash = NULL;
- private->last_sync_time = 0;
- private->info = NULL;
- colormap->colors = NULL;
colormap->size = colormap->visual->colormap_size;
- if ((colormap->visual->type == GDK_VISUAL_GRAYSCALE) ||
- (colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR))
+ private->private_val = FALSE;
+
+ switch (colormap->visual->type)
{
+ case GDK_VISUAL_GRAYSCALE:
+ case GDK_VISUAL_PSEUDO_COLOR:
private->info = g_new0 (GdkColorInfo, colormap->size);
- colormap->colors = g_new (GdkColor, colormap->size);
-
private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
(GEqualFunc) gdk_color_equal);
+ /* Fallthrough */
- gdk_colormap_sync (colormap, TRUE);
+ case GDK_VISUAL_STATIC_GRAY:
+ case GDK_VISUAL_STATIC_COLOR:
+ create_colormap (colormap, FALSE);
+
+ colormap->colors = g_new (GdkColor, colormap->size);
+ sync_colors (colormap);
+ break;
+
+ case GDK_VISUAL_TRUE_COLOR:
+ break;
+
+ default:
+ g_assert_not_reached ();
}
- gdk_colormap_add (colormap);
}
return colormap;
@@ -683,60 +719,46 @@ gdk_colormap_get_system (void)
gint
gdk_colormap_get_system_size (void)
{
- gint bitspixel;
-
- bitspixel = GetDeviceCaps (gdk_display_hdc, BITSPIXEL);
-
- if (bitspixel == 1)
- return 2;
- else if (bitspixel == 4)
- return 16;
- else if (bitspixel == 8)
- return 256;
- else if (bitspixel == 12)
- return 32;
- else if (bitspixel == 16)
- return 64;
- else /* if (bitspixel >= 24) */
- return 256;
+ return gdk_colormap_get_system ()->size;
}
void
gdk_colormap_change (GdkColormap *colormap,
gint ncolors)
{
- GdkColormapPrivateWin32 *private;
- XColor *palette;
+ GdkColormapPrivateWin32 *cmapp;
+ PALETTEENTRY *pe;
int i;
- g_return_if_fail (GDK_IS_COLORMAP (colormap));
+ g_return_if_fail (colormap != NULL);
+
+ cmapp = GDK_WIN32_COLORMAP_DATA (colormap);
- palette = g_new (XColor, ncolors);
+ GDK_NOTE (COLORMAP, g_print ("gdk_colormap_change: hpal=%p ncolors=%d\n",
+ cmapp->hpal, ncolors));
- private = GDK_COLORMAP_PRIVATE_DATA (colormap);
switch (colormap->visual->type)
{
case GDK_VISUAL_GRAYSCALE:
case GDK_VISUAL_PSEUDO_COLOR:
+ pe = g_new (PALETTEENTRY, ncolors);
+
for (i = 0; i < ncolors; i++)
{
- palette[i].peRed = (colormap->colors[i].red >> 8);
- palette[i].peGreen = (colormap->colors[i].green >> 8);
- palette[i].peBlue = (colormap->colors[i].blue >> 8);
- palette[i].peFlags = 0;
+ pe[i].peRed = (colormap->colors[i].red >> 8);
+ pe[i].peGreen = (colormap->colors[i].green >> 8);
+ pe[i].peBlue = (colormap->colors[i].blue >> 8);
+ pe[i].peFlags = 0;
}
- if (SetPaletteEntries (private->xcolormap->palette,
- 0, ncolors, palette) == 0)
+ if (!SetPaletteEntries (cmapp->hpal, 0, ncolors, pe))
WIN32_GDI_FAILED ("SetPaletteEntries");
- private->xcolormap->stale = TRUE;
+ g_free (pe);
break;
default:
break;
}
-
- g_free (palette);
}
gboolean
@@ -753,14 +775,14 @@ gdk_colors_alloc (GdkColormap *colormap,
g_return_val_if_fail (GDK_IS_COLORMAP (colormap), 0);
- private = GDK_COLORMAP_PRIVATE_DATA (colormap);
+ private = GDK_WIN32_COLORMAP_DATA (colormap);
- return_val = alloc_color_cells (private->xcolormap, contiguous,
+ return_val = alloc_color_cells (colormap, contiguous,
planes, nplanes, pixels, npixels);
if (return_val)
{
- for (i=0; i<npixels; i++)
+ for (i = 0; i < npixels; i++)
{
private->info[pixels[i]].ref_count++;
private->info[pixels[i]].flags |= GDK_COLOR_WRITEABLE;
@@ -770,9 +792,6 @@ gdk_colors_alloc (GdkColormap *colormap,
return return_val != 0;
}
-/* This is almost identical to gdk_colormap_free_colors.
- * Keep them in sync!
- */
void
gdk_colors_free (GdkColormap *colormap,
gulong *in_pixels,
@@ -787,7 +806,7 @@ gdk_colors_free (GdkColormap *colormap,
g_return_if_fail (GDK_IS_COLORMAP (colormap));
g_return_if_fail (in_pixels != NULL);
- private = GDK_COLORMAP_PRIVATE_DATA (colormap);
+ private = GDK_WIN32_COLORMAP_DATA (colormap);
if ((colormap->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
(colormap->visual->type != GDK_VISUAL_GRAYSCALE))
@@ -795,10 +814,13 @@ gdk_colors_free (GdkColormap *colormap,
pixels = g_new (gulong, in_npixels);
- for (i=0; i<in_npixels; i++)
+ for (i = 0; i < in_npixels; i++)
{
gulong pixel = in_pixels[i];
+ if (private->use[pixel] == GDK_WIN32_PE_STATIC)
+ continue;
+
if (private->info[pixel].ref_count)
{
private->info[pixel].ref_count--;
@@ -814,54 +836,33 @@ gdk_colors_free (GdkColormap *colormap,
}
if (npixels)
- free_colors (private->xcolormap, pixels, npixels, planes);
+ free_colors (colormap, pixels, npixels, planes);
g_free (pixels);
}
-/* This is almost identical to gdk_colors_free.
- * Keep them in sync!
- */
void
gdk_colormap_free_colors (GdkColormap *colormap,
GdkColor *colors,
gint ncolors)
{
- GdkColormapPrivateWin32 *private;
gulong *pixels;
- gint npixels = 0;
gint i;
g_return_if_fail (GDK_IS_COLORMAP (colormap));
g_return_if_fail (colors != NULL);
- private = GDK_COLORMAP_PRIVATE_DATA (colormap);
-
if ((colormap->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
(colormap->visual->type != GDK_VISUAL_GRAYSCALE))
return;
pixels = g_new (gulong, ncolors);
- for (i=0; i<ncolors; i++)
- {
- gulong pixel = colors[i].pixel;
-
- if (private->info[pixel].ref_count)
- {
- private->info[pixel].ref_count--;
+ for (i = 0; i < ncolors; i++)
+ pixels[i] = colors[i].pixel;
+
+ gdk_colors_free (colormap, pixels, ncolors, 0);
- if (private->info[pixel].ref_count == 0)
- {
- pixels[npixels++] = pixel;
- if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
- g_hash_table_remove (private->hash, &colormap->colors[pixel]);
- private->info[pixel].flags = 0;
- }
- }
- }
- if (npixels)
- free_colors (private->xcolormap, pixels, npixels, 0);
g_free (pixels);
}
@@ -878,29 +879,29 @@ gdk_colormap_alloc1 (GdkColormap *colormap,
GdkColor *ret)
{
GdkColormapPrivateWin32 *private;
- XColor xcolor;
+ PALETTEENTRY pe;
- private = GDK_COLORMAP_PRIVATE_DATA (colormap);
+ private = GDK_WIN32_COLORMAP_DATA (colormap);
- xcolor.peRed = color->red >> 8;
- xcolor.peGreen = color->green >> 8;
- xcolor.peBlue = color->blue >> 8;
+ pe.peRed = color->red >> 8;
+ pe.peGreen = color->green >> 8;
+ pe.peBlue = color->blue >> 8;
- if (alloc_color (private->xcolormap, &xcolor, &ret->pixel))
+ if (alloc_color (colormap, &pe, &ret->pixel))
{
- ret->red = (xcolor.peRed * 65535) / 255;
- ret->green = (xcolor.peGreen * 65535) / 255;
- ret->blue = (xcolor.peBlue * 65535) / 255;
+ ret->red = (pe.peRed * 65535) / 255;
+ ret->green = (pe.peGreen * 65535) / 255;
+ ret->blue = (pe.peBlue * 65535) / 255;
if ((guint) ret->pixel < colormap->size)
{
if (private->info[ret->pixel].ref_count) /* got a duplicate */
{
- /* XXX */
}
else
{
colormap->colors[ret->pixel] = *color;
+ colormap->colors[ret->pixel].pixel = ret->pixel;
private->info[ret->pixel].ref_count = 1;
g_hash_table_insert (private->hash,
@@ -910,10 +911,7 @@ gdk_colormap_alloc1 (GdkColormap *colormap,
}
return TRUE;
}
- else
- {
- return FALSE;
- }
+ return FALSE;
}
static gint
@@ -929,14 +927,15 @@ gdk_colormap_alloc_colors_writeable (GdkColormap *colormap,
gboolean status;
gint i, index;
- private = GDK_COLORMAP_PRIVATE_DATA (colormap);
+ private = GDK_WIN32_COLORMAP_DATA (colormap);
if (private->private_val)
{
index = 0;
for (i=0; i<ncolors; i++)
{
- while ((index < colormap->size) && (private->info[index].ref_count != 0))
+ while ((index < colormap->size) &&
+ (private->info[index].ref_count != 0))
index++;
if (index < colormap->size)
@@ -954,13 +953,12 @@ 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);
+ status = alloc_color_cells (colormap, FALSE, NULL, 0, pixels, ncolors);
if (status)
{
- for (i=0; i<ncolors; i++)
+ for (i = 0; i < ncolors; i++)
{
colors[i].pixel = pixels[i];
private->info[pixels[i]].ref_count++;
@@ -982,49 +980,64 @@ gdk_colormap_alloc_colors_private (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
- GdkColormapPrivateWin32 *private;
+ GdkColormapPrivateWin32 *cmapp;
gint i, index;
- XColor *store = g_new (XColor, ncolors);
- gint nstore = 0;
+ PALETTEENTRY pe;
gint nremaining = 0;
- private = GDK_COLORMAP_PRIVATE_DATA (colormap);
+ cmapp = GDK_WIN32_COLORMAP_DATA (colormap);
index = -1;
/* First, store the colors we have room for */
index = 0;
- for (i=0; i<ncolors; i++)
+ for (i = 0; i < ncolors; i++)
{
if (!success[i])
{
- while ((index < colormap->size) && (private->info[index].ref_count != 0))
+ while ((index < colormap->size) &&
+ (cmapp->info[index].ref_count != 0))
index++;
if (index < colormap->size)
{
- store[nstore].peRed = colors[i].red >> 8;
- store[nstore].peBlue = colors[i].blue >> 8;
- store[nstore].peGreen = colors[i].green >> 8;
- nstore++;
-
- success[i] = TRUE;
+ if (index >= cmapp->current_size)
+ {
+ if (!ResizePalette (cmapp->hpal, index + 1))
+ {
+ WIN32_GDI_FAILED ("ResizePalette");
+ nremaining++;
+ }
+ else
+ cmapp->current_size = index + 1;
+ }
+ if (index < cmapp->current_size)
+ {
+ pe.peRed = colors[i].red >> 8;
+ pe.peBlue = colors[i].blue >> 8;
+ pe.peGreen = colors[i].green >> 8;
+ pe.peFlags = 0;
+
+ if (!SetPaletteEntries (cmapp->hpal, index, 1, &pe))
+ {
+ WIN32_GDI_FAILED ("SetPaletteEntries");
+ nremaining++;
+ }
+ else
+ {
+ success[i] = TRUE;
- colors[i].pixel = index;
- private->info[index].ref_count++;
+ colors[i].pixel = index;
+ colormap->colors[index] = colors[i];
+ cmapp->info[index].ref_count++;
+ }
+ }
}
else
nremaining++;
}
}
- if (SetPaletteEntries (private->xcolormap->palette,
- 0, nstore, store) == 0)
- WIN32_GDI_FAILED ("SetPaletteEntries");
- private->xcolormap->stale = TRUE;
-
- g_free (store);
-
if (nremaining > 0 && best_match)
{
/* Get best matches for remaining colors */
@@ -1043,7 +1056,7 @@ gdk_colormap_alloc_colors_private (GdkColormap *colormap,
if (index != -1)
{
colors[i] = colormap->colors[index];
- private->info[index].ref_count++;
+ cmapp->info[index].ref_count++;
success[i] = TRUE;
nremaining--;
@@ -1069,10 +1082,10 @@ gdk_colormap_alloc_colors_shared (GdkColormap *colormap,
gint nremaining = 0;
gint nfailed = 0;
- private = GDK_COLORMAP_PRIVATE_DATA (colormap);
+ private = GDK_WIN32_COLORMAP_DATA (colormap);
index = -1;
- for (i=0; i<ncolors; i++)
+ for (i = 0; i < ncolors; i++)
{
if (!success[i])
{
@@ -1090,11 +1103,9 @@ gdk_colormap_alloc_colors_shared (GdkColormap *colormap,
for (i = 0; i < colormap->size; i++)
available[i] = ((private->info[i].ref_count == 0) ||
!(private->info[i].flags & GDK_COLOR_WRITEABLE));
- gdk_colormap_sync (colormap, FALSE);
-
while (nremaining > 0)
{
- for (i=0; i<ncolors; i++)
+ for (i = 0; i < ncolors; i++)
{
if (!success[i])
{
@@ -1139,7 +1150,7 @@ gdk_colormap_alloc_colors_shared (GdkColormap *colormap,
/* Change back the values we flagged as permanent failures */
if (nfailed > 0)
{
- for (i=0; i<ncolors; i++)
+ for (i = 0; i < ncolors; i++)
if (success[i] == 2)
success[i] = FALSE;
nremaining = nfailed;
@@ -1161,11 +1172,11 @@ gdk_colormap_alloc_colors_pseudocolor (GdkColormap *colormap,
gint i;
gint nremaining = 0;
- private = GDK_COLORMAP_PRIVATE_DATA (colormap);
+ private = GDK_WIN32_COLORMAP_DATA (colormap);
/* Check for an exact match among previously allocated colors */
- for (i=0; i<ncolors; i++)
+ for (i = 0; i < ncolors; i++)
{
if (!success[i])
{
@@ -1207,17 +1218,15 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
GdkVisual *visual;
gint i;
gint nremaining = 0;
- XColor xcolor;
+ PALETTEENTRY pe;
g_return_val_if_fail (GDK_IS_COLORMAP (colormap), FALSE);
g_return_val_if_fail (colors != NULL, FALSE);
- private = GDK_COLORMAP_PRIVATE_DATA (colormap);
+ private = GDK_WIN32_COLORMAP_DATA (colormap);
- for (i=0; i<ncolors; i++)
- {
- success[i] = FALSE;
- }
+ for (i = 0; i < ncolors; i++)
+ success[i] = FALSE;
switch (colormap->visual->type)
{
@@ -1234,23 +1243,24 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
case GDK_VISUAL_TRUE_COLOR:
visual = colormap->visual;
- for (i=0; i<ncolors; i++)
+ for (i = 0; i < ncolors; i++)
{
- colors[i].pixel = (((colors[i].red >> (16 - visual->red_prec)) << visual->red_shift) +
- ((colors[i].green >> (16 - visual->green_prec)) << visual->green_shift) +
- ((colors[i].blue >> (16 - visual->blue_prec)) << visual->blue_shift));
+ colors[i].pixel =
+ (((colors[i].red >> (16 - visual->red_prec)) << visual->red_shift) +
+ ((colors[i].green >> (16 - visual->green_prec)) << visual->green_shift) +
+ ((colors[i].blue >> (16 - visual->blue_prec)) << visual->blue_shift));
success[i] = TRUE;
}
break;
case GDK_VISUAL_STATIC_GRAY:
case GDK_VISUAL_STATIC_COLOR:
- for (i=0; i<ncolors; i++)
+ for (i = 0; i < ncolors; i++)
{
- xcolor.peRed = colors[i].red >> 8;
- xcolor.peGreen = colors[i].green >> 8;
- xcolor.peBlue = colors[i].blue >> 8;
- if (alloc_color (private->xcolormap, &xcolor, &colors[i].pixel))
+ pe.peRed = colors[i].red >> 8;
+ pe.peGreen = colors[i].green >> 8;
+ pe.peBlue = colors[i].blue >> 8;
+ if (alloc_color (colormap, &pe, &colors[i].pixel))
success[i] = TRUE;
else
nremaining++;
@@ -1260,6 +1270,7 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
case GDK_VISUAL_DIRECT_COLOR:
g_assert_not_reached ();
}
+
return nremaining;
}
@@ -1274,29 +1285,31 @@ gdk_colormap_query_color (GdkColormap *colormap,
visual = gdk_colormap_get_visual (colormap);
- switch (visual->type) {
- case GDK_VISUAL_DIRECT_COLOR:
- case GDK_VISUAL_TRUE_COLOR:
- result->red = 65535. * (double)((pixel & visual->red_mask) >> visual->red_shift) / ((1 << visual->red_prec) - 1);
- result->green = 65535. * (double)((pixel & visual->green_mask) >> visual->green_shift) / ((1 << visual->green_prec) - 1);
- result->blue = 65535. * (double)((pixel & visual->blue_mask) >> visual->blue_shift) / ((1 << visual->blue_prec) - 1);
- break;
- case GDK_VISUAL_STATIC_GRAY:
- case GDK_VISUAL_GRAYSCALE:
- result->red = result->green = result->blue = 65535. * (double)pixel/((1<<visual->depth) - 1);
- break;
- case GDK_VISUAL_STATIC_COLOR:
- g_assert_not_reached ();
- break;
- case GDK_VISUAL_PSEUDO_COLOR:
- result->red = colormap->colors[pixel].red;
- result->green = colormap->colors[pixel].green;
- result->blue = colormap->colors[pixel].blue;
- break;
- default:
- g_assert_not_reached ();
- break;
- }
+ switch (visual->type)
+ {
+ case GDK_VISUAL_DIRECT_COLOR:
+ case GDK_VISUAL_TRUE_COLOR:
+ result->red = 65535. * (double)((pixel & visual->red_mask) >> visual->red_shift) / ((1 << visual->red_prec) - 1);
+ result->green = 65535. * (double)((pixel & visual->green_mask) >> visual->green_shift) / ((1 << visual->green_prec) - 1);
+ result->blue = 65535. * (double)((pixel & visual->blue_mask) >> visual->blue_shift) / ((1 << visual->blue_prec) - 1);
+ break;
+
+ case GDK_VISUAL_STATIC_GRAY:
+ case GDK_VISUAL_GRAYSCALE:
+ result->red = result->green = result->blue = 65535. * (double)pixel/((1<<visual->depth) - 1);
+ break;
+
+ case GDK_VISUAL_STATIC_COLOR:
+ case GDK_VISUAL_PSEUDO_COLOR:
+ result->red = colormap->colors[pixel].red;
+ result->green = colormap->colors[pixel].green;
+ result->blue = colormap->colors[pixel].blue;
+ break;
+
+ default:
+ g_assert_not_reached ();
+ break;
+ }
}
gboolean
@@ -1304,21 +1317,25 @@ gdk_color_change (GdkColormap *colormap,
GdkColor *color)
{
GdkColormapPrivateWin32 *private;
- XColor xcolor;
+ PALETTEENTRY pe;
g_return_val_if_fail (GDK_IS_COLORMAP (colormap), FALSE);
g_return_val_if_fail (color != NULL, FALSE);
- private = GDK_COLORMAP_PRIVATE_DATA (colormap);
+ private = GDK_WIN32_COLORMAP_DATA (colormap);
+
+ if (color->pixel < 0 || color->pixel >= colormap->size)
+ return FALSE;
+
+ if (private->use[color->pixel] == GDK_WIN32_PE_STATIC)
+ return FALSE;
- xcolor.peRed = color->red >> 8;
- xcolor.peGreen = color->green >> 8;
- xcolor.peBlue = color->blue >> 8;
+ pe.peRed = color->red >> 8;
+ pe.peGreen = color->green >> 8;
+ pe.peBlue = color->blue >> 8;
- if (SetPaletteEntries (private->xcolormap->palette,
- color->pixel, 1, &xcolor) == 0)
+ if (SetPaletteEntries (private->hpal, color->pixel, 1, &pe) == 0)
WIN32_GDI_FAILED ("SetPaletteEntries");
- private->xcolormap->stale = TRUE;
return TRUE;
}
@@ -1329,7 +1346,7 @@ gdk_colormap_match_color (GdkColormap *cmap,
const gchar *available)
{
GdkColor *colors;
- guint sum, max;
+ guint sum, min;
gint rdiff, gdiff, bdiff;
gint i, index;
@@ -1337,7 +1354,7 @@ gdk_colormap_match_color (GdkColormap *cmap,
g_return_val_if_fail (color != NULL, 0);
colors = cmap->colors;
- max = 3 * (65536);
+ min = 3 * (65536);
index = -1;
for (i = 0; i < cmap->size; i++)
@@ -1350,81 +1367,13 @@ gdk_colormap_match_color (GdkColormap *cmap,
sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
- if (sum < max)
+ if (sum < min)
{
index = i;
- max = sum;
+ min = sum;
}
}
}
return index;
}
-
-GdkColormap*
-gdk_colormap_lookup (Colormap xcolormap)
-{
- GdkColormap *cmap;
-
- if (!colormap_hash)
- return NULL;
-
- cmap = g_hash_table_lookup (colormap_hash, &xcolormap);
- return cmap;
-}
-
-static void
-gdk_colormap_add (GdkColormap *cmap)
-{
- GdkColormapPrivateWin32 *private;
-
- if (!colormap_hash)
- colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
- (GEqualFunc) gdk_colormap_equal);
-
- private = GDK_COLORMAP_PRIVATE_DATA (cmap);
-
- g_hash_table_insert (colormap_hash, &private->xcolormap, cmap);
-}
-
-static void
-gdk_colormap_remove (GdkColormap *cmap)
-{
- GdkColormapPrivateWin32 *private;
-
- if (!colormap_hash)
- colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
- (GEqualFunc) gdk_colormap_equal);
-
- private = GDK_COLORMAP_PRIVATE_DATA (cmap);
-
- g_hash_table_remove (colormap_hash, &private->xcolormap);
-}
-
-static guint
-gdk_colormap_hash (Colormap *cmap)
-{
- return (guint) *cmap;
-}
-
-static gboolean
-gdk_colormap_equal (Colormap *a,
- Colormap *b)
-{
- return (*a == *b);
-}
-
-#ifdef G_ENABLE_DEBUG
-
-gchar *
-gdk_win32_color_to_string (const GdkColor *color)
-{
- static char buf[100];
-
- sprintf (buf, "(%.04x,%.04x,%.04x):%.06x",
- color->red, color->green, color->blue, color->pixel);
-
- return buf;
-}
-
-#endif
diff --git a/gdk/win32/gdkcursor-win32.c b/gdk/win32/gdkcursor-win32.c
index 6fceb2a5d1..85e040c089 100644
--- a/gdk/win32/gdkcursor-win32.c
+++ b/gdk/win32/gdkcursor-win32.c
@@ -1,5 +1,6 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * Copyright (C) 1998-2002 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -28,7 +29,7 @@ _gdk_win32_data_to_wcursor (GdkCursorType cursor_type)
gint i, j, x, y, ofs;
HCURSOR rv = NULL;
gint w, h;
- guchar *ANDplane, *XORplane;
+ guchar *and_plane, *xor_plane;
for (i = 0; i < G_N_ELEMENTS (cursors); i++)
if (cursors[i].type == cursor_type)
@@ -40,10 +41,10 @@ _gdk_win32_data_to_wcursor (GdkCursorType cursor_type)
w = GetSystemMetrics (SM_CXCURSOR);
h = GetSystemMetrics (SM_CYCURSOR);
- ANDplane = g_malloc ((w/8) * h);
- memset (ANDplane, 0xff, (w/8) * h);
- XORplane = g_malloc ((w/8) * h);
- memset (XORplane, 0, (w/8) * h);
+ and_plane = g_malloc ((w/8) * h);
+ memset (and_plane, 0xff, (w/8) * h);
+ xor_plane = g_malloc ((w/8) * h);
+ memset (xor_plane, 0, (w/8) * h);
#define SET_BIT(v,b) (v |= (1 << b))
#define RESET_BIT(v,b) (v &= ~(1 << b))
@@ -61,9 +62,9 @@ _gdk_win32_data_to_wcursor (GdkCursorType cursor_type)
if (data)
{
- RESET_BIT (ANDplane[pofs], bit);
+ RESET_BIT (and_plane[pofs], bit);
if (data == 1)
- SET_BIT (XORplane[pofs], bit);
+ SET_BIT (xor_plane[pofs], bit);
}
}
}
@@ -72,11 +73,11 @@ _gdk_win32_data_to_wcursor (GdkCursorType cursor_type)
#undef RESET_BIT
rv = CreateCursor (gdk_app_hmodule, cursors[i].hotx, cursors[i].hoty,
- w, h, ANDplane, XORplane);
+ w, h, and_plane, xor_plane);
if (rv == NULL)
WIN32_API_FAILED ("CreateCursor");
- g_free (ANDplane);
- g_free (XORplane);
+ g_free (and_plane);
+ g_free (xor_plane);
return rv;
}
@@ -153,16 +154,52 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
residue = (1 << ((8-(width%8))%8)) - 1;
- source_image = gdk_image_get (source, 0, 0, width, height);
- mask_image = gdk_image_get (mask, 0, 0, width, height);
+ source_image = source_impl->image;
+ mask_image = mask_impl->image;
- if (source_image->depth != 1 || mask_image->depth != 1)
+ g_return_val_if_fail (source_image->depth == 1 && mask_image->depth == 1,
+ NULL);
+
+#ifdef G_ENABLE_DEBUG
+ if (_gdk_debug_flags & GDK_DEBUG_CURSOR)
{
- gdk_image_unref (source_image);
- gdk_image_unref (mask_image);
- g_return_val_if_fail (source_image->depth == 1 && mask_image->depth == 1,
- NULL);
+ g_print ("gdk_cursor_new_from_pixmap: source=%p:\n",
+ source_impl->parent_instance.handle);
+ for (iy = 0; iy < height; iy++)
+ {
+ if (iy == 16)
+ break;
+
+ p = (guchar *) source_image->mem + iy*source_image->bpl;
+ for (ix = 0; ix < width; ix++)
+ {
+ if (ix == 79)
+ break;
+ g_print ("%c", ".X"[((*p)>>(7-(ix%8)))&1]);
+ if ((ix%8) == 7)
+ p++;
+ }
+ g_print ("\n");
+ }
+ g_print ("...mask=%p:\n", mask_impl->parent_instance.handle);
+ for (iy = 0; iy < height; iy++)
+ {
+ if (iy == 16)
+ break;
+
+ p = (guchar *) mask_image->mem + iy*source_image->bpl;
+ for (ix = 0; ix < width; ix++)
+ {
+ if (ix == 79)
+ break;
+ g_print ("%c", ".X"[((*p)>>(7-(ix%8)))&1]);
+ if ((ix%8) == 7)
+ p++;
+ }
+ g_print ("\n");
+ }
}
+#endif
/* Such complex bit manipulation for this simple task, sigh.
* The X cursor and Windows cursor concepts are quite different.
@@ -237,9 +274,6 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
g_free (xor_mask);
g_free (and_mask);
- gdk_image_unref (source_image);
- gdk_image_unref (mask_image);
-
private = g_new (GdkCursorPrivate, 1);
private->hcursor = hcursor;
cursor = (GdkCursor*) private;
diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c
index 33a13a66ed..b1b7125832 100644
--- a/gdk/win32/gdkdnd-win32.c
+++ b/gdk/win32/gdkdnd-win32.c
@@ -984,20 +984,31 @@ gdk_dropfiles_filter (GdkXEvent *xev,
result = g_string_new (NULL);
for (i = 0; i < nfiles; i++)
{
- g_string_append (result, "file:");
+ gchar *uri;
+
DragQueryFile (hdrop, i, fileName, MAX_PATH);
/* Resolve shortcuts */
if (resolve_link (msg->hwnd, fileName, linkedFile, NULL))
{
- g_string_append (result, linkedFile);
- GDK_NOTE (DND, g_print ("...%s link to %s\n",
- fileName, linkedFile));
+ uri = g_filename_to_uri (linkedFile, NULL, NULL);
+ if (uri != NULL)
+ {
+ g_string_append (result, uri);
+ GDK_NOTE (DND, g_print ("...%s link to %s: %s\n",
+ fileName, linkedFile, uri));
+ g_free (uri);
+ }
}
else
{
- g_string_append (result, fileName);
- GDK_NOTE (DND, g_print ("...%s\n", fileName));
+ uri = g_filename_to_uri (fileName, NULL, NULL);
+ if (uri != NULL)
+ {
+ g_string_append (result, uri);
+ GDK_NOTE (DND, g_print ("...%s: %s\n", fileName, uri));
+ g_free (uri);
+ }
}
g_string_append (result, "\015\012");
}
diff --git a/gdk/win32/gdkdrawable-win32.c b/gdk/win32/gdkdrawable-win32.c
index e42b3426c1..a4dc7298b0 100644
--- a/gdk/win32/gdkdrawable-win32.c
+++ b/gdk/win32/gdkdrawable-win32.c
@@ -1,5 +1,6 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * Copyright (C) 1998-2002 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -25,6 +26,7 @@
*/
#include <math.h>
+#include <stdio.h>
#include <glib.h>
#include <pango/pangowin32.h>
@@ -118,6 +120,39 @@ static void gdk_drawable_impl_win32_finalize (GObject *object);
static gpointer parent_class = NULL;
+#ifdef G_ENABLE_DEBUG
+
+gchar *
+gdk_win32_drawable_description (GdkDrawable *d)
+{
+ GdkVisual *v;
+ static gchar buf[1000];
+ static gchar *bufp = buf;
+ gchar *msg;
+ gint width, height;
+ gchar *retval;
+
+ gdk_drawable_get_size (d, &width, &height);
+ msg = g_strdup_printf
+ ("%s:%p:%dx%dx%d",
+ G_OBJECT_TYPE_NAME (d),
+ GDK_DRAWABLE_HANDLE (d),
+ width, height,
+ (GDK_IS_PIXMAP (d) ? GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (d)->impl)->image->depth
+ : ((v = gdk_drawable_get_visual (d)) ? v->depth : gdk_visual_get_system ()->depth)));
+
+ if (bufp + strlen (msg) + 1 > buf + sizeof (buf))
+ bufp = buf;
+ retval = bufp;
+ strcpy (bufp, msg);
+ bufp += strlen (msg) + 1;
+ g_free (msg);
+
+ return retval;
+}
+
+#endif
+
GType
gdk_drawable_impl_win32_get_type (void)
{
@@ -175,8 +210,6 @@ gdk_drawable_impl_win32_class_init (GdkDrawableImplWin32Class *klass)
drawable_class->get_depth = gdk_win32_get_depth;
drawable_class->get_visual = gdk_win32_get_visual;
- drawable_class->get_image = _gdk_win32_get_image;
-
drawable_class->_copy_to_image = _gdk_win32_copy_to_image;
}
@@ -195,20 +228,14 @@ gdk_drawable_impl_win32_finalize (GObject *object)
static GdkColormap*
gdk_win32_get_colormap (GdkDrawable *drawable)
{
- GdkDrawableImplWin32 *impl;
-
- impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
-
- return impl->colormap;
+ return GDK_DRAWABLE_IMPL_WIN32 (drawable)->colormap;
}
static void
gdk_win32_set_colormap (GdkDrawable *drawable,
GdkColormap *colormap)
{
- GdkDrawableImplWin32 *impl;
-
- impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
+ GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
if (impl->colormap == colormap)
return;
@@ -239,8 +266,8 @@ gdk_win32_draw_rectangle (GdkDrawable *drawable,
POINT pts[4];
gboolean ok = TRUE;
- GDK_NOTE (MISC, g_print ("gdk_win32_draw_rectangle: %#x (%p) %s%dx%d@+%d+%d\n",
- (guint) GDK_DRAWABLE_IMPL_WIN32 (drawable)->handle,
+ GDK_NOTE (MISC, g_print ("gdk_win32_draw_rectangle: %s (%p) %s%dx%d@+%d+%d\n",
+ gdk_win32_drawable_description (drawable),
gc_private,
(filled ? "fill " : ""),
width, height, x, y));
@@ -318,11 +345,12 @@ gdk_win32_draw_rectangle (GdkDrawable *drawable,
old_pen_or_brush = SelectObject (hdc, GetStockObject (NULL_PEN));
else
old_pen_or_brush = SelectObject (hdc, GetStockObject (HOLLOW_BRUSH));
-
- if (!Rectangle (hdc, x, y, x+width+1, y+height+1))
+ if (old_pen_or_brush == NULL)
+ WIN32_GDI_FAILED ("SelectObject");
+ else if (!Rectangle (hdc, x, y, x+width+1, y+height+1))
WIN32_GDI_FAILED ("Rectangle");
-
- SelectObject (hdc, old_pen_or_brush);
+ else
+ SelectObject (hdc, old_pen_or_brush);
}
gdk_win32_hdc_release (drawable, gc, mask);
@@ -343,8 +371,8 @@ gdk_win32_draw_arc (GdkDrawable *drawable,
HDC hdc;
int nXStartArc, nYStartArc, nXEndArc, nYEndArc;
- GDK_NOTE (MISC, g_print ("gdk_draw_arc: %#x %d,%d,%d,%d %d %d\n",
- (guint) GDK_DRAWABLE_IMPL_WIN32 (drawable)->handle,
+ GDK_NOTE (MISC, g_print ("gdk_draw_arc: %s %d,%d,%d,%d %d %d\n",
+ gdk_win32_drawable_description (drawable),
x, y, width, height, angle1, angle2));
/* Seems that drawing arcs with width or height <= 2 fails, at least
@@ -414,8 +442,8 @@ gdk_win32_draw_polygon (GdkDrawable *drawable,
gboolean ok = TRUE;
int i;
- GDK_NOTE (MISC, g_print ("gdk_win32_draw_polygon: %#x (%p) %d\n",
- (guint) GDK_DRAWABLE_IMPL_WIN32 (drawable)->handle,
+ GDK_NOTE (MISC, g_print ("gdk_win32_draw_polygon: %s (%p) %d\n",
+ gdk_win32_drawable_description (drawable),
gc_private,
npoints));
@@ -539,8 +567,8 @@ gdk_win32_draw_text (GdkDrawable *drawable,
arg.y = y;
arg.hdc = gdk_win32_hdc_get (drawable, gc, mask);
- GDK_NOTE (MISC, g_print ("gdk_draw_text: %#x (%d,%d) \"%.*s\" (len %d)\n",
- (guint) GDK_DRAWABLE_HANDLE (drawable),
+ GDK_NOTE (MISC, g_print ("gdk_draw_text: %s (%d,%d) \"%.*s\" (len %d)\n",
+ gdk_win32_drawable_description (drawable),
x, y,
(text_length > 10 ? 10 : text_length),
text, text_length));
@@ -588,8 +616,8 @@ gdk_win32_draw_text_wc (GdkDrawable *drawable,
arg.y = y;
arg.hdc = gdk_win32_hdc_get (drawable, gc, mask);
- GDK_NOTE (MISC, g_print ("gdk_draw_text_wc: %#x (%d,%d) len: %d\n",
- (guint) GDK_DRAWABLE_HANDLE (drawable),
+ GDK_NOTE (MISC, g_print ("gdk_draw_text_wc: %s (%d,%d) len: %d\n",
+ gdk_win32_drawable_description (drawable),
x, y, text_length));
if (sizeof (wchar_t) != sizeof (GdkWChar))
@@ -621,167 +649,31 @@ gdk_win32_draw_drawable (GdkDrawable *drawable,
gint width,
gint height)
{
- HDC hdc;
- HDC srcdc;
- HGDIOBJ hgdiobj;
- HRGN src_rgn, draw_rgn, outside_rgn;
- RECT r;
- gint src_width, src_height;
- gboolean ok = TRUE;
- GdkDrawableImplWin32 *impl;
- HANDLE src_handle;
-
- impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
- if (GDK_IS_DRAWABLE_IMPL_WIN32(src))
- src_handle = GDK_DRAWABLE_IMPL_WIN32 (src)->handle;
- else
- src_handle = GDK_DRAWABLE_HANDLE (src);
-
- GDK_NOTE (MISC, g_print ("gdk_win32_draw_drawable: dest: %#x @+%d+%d"
- " src: %#x %dx%d@+%d+%d\n",
- (guint) impl->handle,
- xdest, ydest,
- (guint) src_handle,
- width, height, xsrc, ysrc));
-
- hdc = gdk_win32_hdc_get (drawable, gc, 0);
-
- gdk_drawable_get_size (src, &src_width, &src_height);
- src_rgn = CreateRectRgn (0, 0, src_width + 1, src_height + 1);
- draw_rgn = CreateRectRgn (xsrc, ysrc, xsrc + width + 1, ysrc + height + 1);
-
-#if 0 /* HB: I dont't see reason to do this ... */
- if (GDK_IS_WINDOW_IMPL_WIN32 (drawable))
- {
- /* If we are drawing on a window, calculate the region that is
- * outside the source pixmap, and invalidate that, causing it to
- * be cleared. XXX
- */
- SetRectEmpty (&r);
- outside_rgn = CreateRectRgnIndirect (&r);
- if (CombineRgn (outside_rgn, draw_rgn, src_rgn, RGN_DIFF) != NULLREGION)
- {
- if (ERROR == OffsetRgn (outside_rgn, xdest, ydest))
- WIN32_GDI_FAILED ("OffsetRgn");
- GDK_NOTE (MISC, (GetRgnBox (outside_rgn, &r),
- g_print ("...calling InvalidateRgn, "
- "bbox: %ldx%ld@+%ld+%ld\n",
- r.right - r.left - 1, r.bottom - r.top - 1,
- r.left, r.top)));
- if (!InvalidateRgn (impl->handle, outside_rgn, TRUE))
- WIN32_GDI_FAILED ("InvalidateRgn");
- }
- if (!DeleteObject (outside_rgn))
- WIN32_GDI_FAILED ("DeleteObject");
- }
-#endif
-
-#if 1 /* Don't know if this is necessary */
- if (CombineRgn (draw_rgn, draw_rgn, src_rgn, RGN_AND) == COMPLEXREGION)
- g_warning ("gdk_win32_draw_drawable: CombineRgn returned a COMPLEXREGION");
-
- if (0 == GetRgnBox (draw_rgn, &r))
- WIN32_GDI_FAILED("GetRgnBox");
- if (r.left != xsrc
- || r.top != ysrc
- || r.right != xsrc + width + 1
- || r.bottom != ysrc + height + 1)
- {
- xdest += r.left - xsrc;
- xsrc = r.left;
- ydest += r.top - ysrc;
- ysrc = r.top;
- width = r.right - xsrc - 1;
- height = r.bottom - ysrc - 1;
-
- GDK_NOTE (MISC, g_print ("... restricted to src: %dx%d@+%d+%d, "
- "dest: @+%d+%d\n",
- width, height, xsrc, ysrc,
- xdest, ydest));
- }
-#endif
-
- if (!DeleteObject (src_rgn))
- WIN32_GDI_FAILED ("DeleteObject");
- if (!DeleteObject (draw_rgn))
- WIN32_GDI_FAILED ("DeleteObject");
+ g_assert (GDK_IS_DRAWABLE_IMPL_WIN32 (drawable));
- /* This function is called also to bitblt from a window.
- */
- if (GDK_IS_PIXMAP_IMPL_WIN32 (src) || GDK_IS_PIXMAP(src))
- {
- if ((srcdc = CreateCompatibleDC (hdc)) == NULL)
- WIN32_GDI_FAILED ("CreateCompatibleDC"), ok = FALSE;
-
- if (ok && (hgdiobj = SelectObject (srcdc, src_handle)) == NULL)
- WIN32_GDI_FAILED ("SelectObject"), ok = FALSE;
-
- if (ok && !BitBlt (hdc, xdest, ydest, width, height,
- srcdc, xsrc, ysrc, SRCCOPY))
- WIN32_GDI_FAILED ("BitBlt");
-
- if (ok && (SelectObject (srcdc, hgdiobj) == NULL))
- WIN32_GDI_FAILED ("SelectObject");
-
- if (srcdc != NULL && !DeleteDC (srcdc))
- WIN32_GDI_FAILED ("DeleteDC");
- }
- else if (impl->handle == src_handle)
- {
- /* Blitting inside a window, use ScrollDC */
- RECT scrollRect, clipRect, emptyRect;
- HRGN updateRgn;
-
- scrollRect.left = MIN (xsrc, xdest);
- scrollRect.top = MIN (ysrc, ydest);
- scrollRect.right = MAX (xsrc + width + 1, xdest + width + 1);
- scrollRect.bottom = MAX (ysrc + height + 1, ydest + height + 1);
-
- clipRect.left = xdest;
- clipRect.top = ydest;
- clipRect.right = xdest + width + 1;
- clipRect.bottom = ydest + height + 1;
-
- SetRectEmpty (&emptyRect);
- updateRgn = CreateRectRgnIndirect (&emptyRect);
- if (!ScrollDC (hdc, xdest - xsrc, ydest - ysrc,
- &scrollRect, &clipRect,
- updateRgn, NULL))
- WIN32_GDI_FAILED ("ScrollDC"), ok = FALSE;
- if (ok && !InvalidateRgn (impl->handle, updateRgn, FALSE))
- WIN32_GDI_FAILED ("InvalidateRgn"), ok = FALSE;
- if (ok && !UpdateWindow (impl->handle))
- WIN32_GDI_FAILED ("UpdateWindow");
- if (!DeleteObject (updateRgn))
- WIN32_GDI_FAILED ("DeleteObject");
- }
- else
- {
- if ((srcdc = GetDC (src_handle)) == NULL)
- WIN32_GDI_FAILED ("GetDC"), ok = FALSE;
-
- if (ok && !BitBlt (hdc, xdest, ydest, width, height,
- srcdc, xsrc, ysrc, SRCCOPY))
- WIN32_GDI_FAILED ("BitBlt");
- if (ok && !ReleaseDC (src_handle, srcdc))
- WIN32_GDI_FAILED ("ReleaseDC");
- }
- gdk_win32_hdc_release (drawable, gc, 0);
+ _gdk_win32_blit (FALSE, (GdkDrawableImplWin32 *) drawable,
+ gc, src, xsrc, ysrc,
+ xdest, ydest, width, height);
}
void
_gdk_win32_draw_tiles (GdkDrawable *drawable,
- GdkGC *gc,
- GdkPixmap *tile,
- gint x_from,
- gint y_from,
- gint max_width,
- gint max_height)
+ GdkGC *gc,
+ GdkPixmap *tile,
+ gint x_from,
+ gint y_from,
+ gint max_width,
+ gint max_height)
{
gint x = x_from, y = y_from;
gint tile_width, tile_height;
gint width, height;
+ GDK_NOTE (MISC, g_print ("_gdk_win32_draw_tiles: %s tile=%s +%d+%d %d,%d\n",
+ gdk_win32_drawable_description (drawable),
+ gdk_win32_drawable_description (tile),
+ x_from, y_from, max_width, max_height));
+
gdk_drawable_get_size (drawable, &width, &height);
gdk_drawable_get_size (tile, &tile_width, &tile_height);
@@ -796,11 +688,11 @@ _gdk_win32_draw_tiles (GdkDrawable *drawable,
x = x_from;
while (x < width)
{
- gdk_win32_draw_drawable (drawable, gc, tile,
- x % tile_width, /* xsrc */
- y % tile_height, /* ysrc */
- x, y, /* dest */
- tile_width, tile_height);
+ gdk_draw_drawable (drawable, gc, tile,
+ x % tile_width, /* xsrc */
+ y % tile_height, /* ysrc */
+ x, y, /* dest */
+ tile_width, tile_height);
x += tile_width;
}
y += tile_height;
@@ -823,8 +715,8 @@ gdk_win32_draw_points (GdkDrawable *drawable,
fg = _gdk_win32_colormap_color (impl->colormap, gc_private->foreground);
- GDK_NOTE (MISC, g_print ("gdk_draw_points: %#x %dx%.06x\n",
- (guint) GDK_DRAWABLE_IMPL_WIN32 (drawable)->handle,
+ GDK_NOTE (MISC, g_print ("gdk_draw_points: %s %dx%.06x\n",
+ gdk_win32_drawable_description (drawable),
npoints, (guint) fg));
for (i = 0; i < npoints; i++)
@@ -845,8 +737,8 @@ gdk_win32_draw_segments (GdkDrawable *drawable,
gboolean ok = TRUE;
int i;
- GDK_NOTE (MISC, g_print ("gdk_win32_draw_segments: %#x nsegs: %d\n",
- (guint) GDK_DRAWABLE_IMPL_WIN32 (drawable)->handle, nsegs));
+ GDK_NOTE (MISC, g_print ("gdk_win32_draw_segments: %s nsegs: %d\n",
+ gdk_win32_drawable_description (drawable), nsegs));
hdc = gdk_win32_hdc_get (drawable, gc, mask);
@@ -1002,88 +894,363 @@ gdk_win32_draw_glyphs (GdkDrawable *drawable,
}
static void
-gdk_win32_draw_image (GdkDrawable *drawable,
- GdkGC *gc,
- GdkImage *image,
- gint xsrc,
- gint ysrc,
- gint xdest,
- gint ydest,
- gint width,
- gint height)
+blit_from_pixmap (gboolean use_fg_bg,
+ GdkDrawableImplWin32 *dest,
+ HDC hdc,
+ GdkPixmapImplWin32 *src,
+ GdkGCWin32 *gcwin32,
+ gint xsrc,
+ gint ysrc,
+ gint xdest,
+ gint ydest,
+ gint width,
+ gint height)
{
- GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
- GdkImagePrivateWin32 *image_private = IMAGE_PRIVATE_DATA (image);
- GdkColormapPrivateWin32 *colormap_private = (GdkColormapPrivateWin32 *) impl->colormap;
- HDC hdc, memdc;
- HGDIOBJ oldbitmap;
- DIBSECTION ds;
- static struct {
- BITMAPINFOHEADER bmiHeader;
- WORD bmiIndices[256];
- } bmi;
- static gboolean bmi_inited = FALSE;
- gboolean ok = TRUE;
- int i;
+ HDC srcdc;
+ HBITMAP holdbitmap;
+ RGBQUAD oldtable[256], newtable[256];
+ COLORREF bg, fg;
- hdc = gdk_win32_hdc_get (drawable, gc, 0);
+ gint newtable_size = 0, oldtable_size = 0;
+ gboolean ok = TRUE;
+
+ GDK_NOTE (MISC, g_print ("blit_from_pixmap\n"));
- if (image->visual && image->visual->type == GDK_VISUAL_PSEUDO_COLOR &&
- colormap_private && colormap_private->xcolormap->rc_palette)
+ if (!(srcdc = CreateCompatibleDC (NULL)))
{
- if (!bmi_inited)
+ WIN32_GDI_FAILED ("CreateCompatibleDC");
+ return;
+ }
+
+ if (!(holdbitmap = SelectObject (srcdc, ((GdkDrawableImplWin32 *) src)->handle)))
+ WIN32_GDI_FAILED ("SelectObject");
+ else
+ {
+ if (src->image->depth <= 8)
{
- for (i = 0; i < 256; i++)
- bmi.bmiIndices[i] = i;
- bmi_inited = TRUE;
+ /* Blitting from a 1, 4 or 8-bit pixmap */
+
+ if ((oldtable_size = GetDIBColorTable (srcdc, 0, 256, oldtable)) == 0)
+ WIN32_GDI_FAILED ("GetDIBColorTable");
+ else if (src->image->depth == 1)
+ {
+ /* Blitting from an 1-bit pixmap */
+
+ gint bgix, fgix;
+
+ if (use_fg_bg)
+ {
+ bgix = gcwin32->background;
+ fgix = gcwin32->foreground;
+ }
+ else
+ {
+ bgix = 0;
+ fgix = 1;
+ }
+
+ if (GDK_IS_PIXMAP_IMPL_WIN32 (dest) &&
+ ((GdkPixmapImplWin32 *) dest)->image->depth <= 8)
+ {
+ /* Destination is also pixmap, get fg and bg from
+ * its palette. Either use the foreground and
+ * background pixel values in the GC (only in the
+ * case of gdk_image_put(), cf. XPutImage()), or 0
+ * and 1 to index the palette.
+ */
+ if (!GetDIBColorTable (hdc, bgix, 1, newtable) ||
+ !GetDIBColorTable (hdc, fgix, 1, newtable+1))
+ WIN32_GDI_FAILED ("GetDIBColorTable"), ok = FALSE;
+ }
+ else
+ {
+ /* Destination is a window, get fg and bg from its
+ * colormap
+ */
+
+ bg = _gdk_win32_colormap_color (dest->colormap, bgix);
+ fg = _gdk_win32_colormap_color (dest->colormap, fgix);
+ newtable[0].rgbBlue = GetBValue (bg);
+ newtable[0].rgbGreen = GetGValue (bg);
+ newtable[0].rgbRed = GetRValue (bg);
+ newtable[0].rgbReserved = 0;
+ newtable[1].rgbBlue = GetBValue (fg);
+ newtable[1].rgbGreen = GetGValue (fg);
+ newtable[1].rgbRed = GetRValue (fg);
+ newtable[1].rgbReserved = 0;
+ }
+ if (ok)
+ GDK_NOTE (MISC, g_print ("bg: %02x %02x %02x "
+ "fg: %02x %02x %02x\n",
+ newtable[0].rgbRed,
+ newtable[0].rgbGreen,
+ newtable[0].rgbBlue,
+ newtable[1].rgbRed,
+ newtable[1].rgbGreen,
+ newtable[1].rgbBlue));
+ newtable_size = 2;
+ }
+ else if (GDK_IS_PIXMAP_IMPL_WIN32 (dest))
+ {
+ /* Destination is pixmap, get its color table */
+
+ if ((newtable_size = GetDIBColorTable (hdc, 0, 256, newtable)) == 0)
+ WIN32_GDI_FAILED ("GetDIBColorTable"), ok = FALSE;
+ }
+
+ /* If blitting between pixmaps, set source's color table */
+ if (ok && newtable_size > 0)
+ {
+ GDK_NOTE (MISC_OR_COLORMAP,
+ g_print ("blit_from_pixmap: set color table"
+ " hdc=%p count=%d\n",
+ srcdc, newtable_size));
+ if (!SetDIBColorTable (srcdc, 0, newtable_size, newtable))
+ WIN32_GDI_FAILED ("SetDIBColorTable"), ok = FALSE;
+ }
}
+
+ if (ok && !BitBlt (hdc, xdest, ydest, width, height,
+ srcdc, xsrc, ysrc, SRCCOPY))
+ WIN32_GDI_FAILED ("BitBlt");
+
+ /* Restore source's color table if necessary */
+ if (ok && newtable_size > 0 && oldtable_size > 0)
+ {
+ GDK_NOTE (MISC_OR_COLORMAP,
+ g_print ("blit_from_pixmap: reset color table"
+ " hdc=%p count=%d\n",
+ srcdc, oldtable_size));
+ if (!SetDIBColorTable (srcdc, 0, oldtable_size, oldtable))
+ WIN32_GDI_FAILED ("SetDIBColorTable");
+ }
+
+ if (!SelectObject (srcdc, holdbitmap))
+ WIN32_GDI_FAILED ("SelectObject");
+ }
+ if (!DeleteDC (srcdc))
+ WIN32_GDI_FAILED ("DeleteDC");
+}
- if (GetObject (image_private->hbitmap, sizeof (DIBSECTION),
- &ds) != sizeof (DIBSECTION))
- WIN32_GDI_FAILED ("GetObject"), ok = FALSE;
-#if 0
- g_print("xdest = %d, ydest = %d, xsrc = %d, ysrc = %d, width = %d, height = %d\n",
- xdest, ydest, xsrc, ysrc, width, height);
- g_print("bmWidth = %d, bmHeight = %d, bmBitsPixel = %d, bmBits = %p\n",
- ds.dsBm.bmWidth, ds.dsBm.bmHeight, ds.dsBm.bmBitsPixel, ds.dsBm.bmBits);
- g_print("biWidth = %d, biHeight = %d, biBitCount = %d, biClrUsed = %d\n",
- ds.dsBmih.biWidth, ds.dsBmih.biHeight, ds.dsBmih.biBitCount, ds.dsBmih.biClrUsed);
-#endif
- bmi.bmiHeader = ds.dsBmih;
- /* I have spent hours on getting the parameters to
- * SetDIBitsToDevice right. I wonder what drugs the guys in
- * Redmond were on when they designed this API.
- */
- if (ok && SetDIBitsToDevice (hdc,
- xdest, ydest,
- width, height,
- xsrc, (-ds.dsBmih.biHeight)-height-ysrc,
- 0, -ds.dsBmih.biHeight,
- ds.dsBm.bmBits,
- (CONST BITMAPINFO *) &bmi,
- DIB_PAL_COLORS) == 0)
- WIN32_GDI_FAILED ("SetDIBitsToDevice");
+static void
+blit_inside_window (GdkDrawableImplWin32 *window,
+ HDC hdc,
+ gint xsrc,
+ gint ysrc,
+ gint xdest,
+ gint ydest,
+ gint width,
+ gint height)
+
+{
+ RECT scrollRect, clipRect, emptyRect;
+ HRGN updateRgn;
+
+ GDK_NOTE (MISC, g_print ("blit_inside_window\n"));
+
+ scrollRect.left = MIN (xsrc, xdest);
+ scrollRect.top = MIN (ysrc, ydest);
+ scrollRect.right = MAX (xsrc + width + 1, xdest + width + 1);
+ scrollRect.bottom = MAX (ysrc + height + 1, ydest + height + 1);
+
+ clipRect.left = xdest;
+ clipRect.top = ydest;
+ clipRect.right = xdest + width + 1;
+ clipRect.bottom = ydest + height + 1;
+
+ SetRectEmpty (&emptyRect);
+ updateRgn = CreateRectRgnIndirect (&emptyRect);
+ if (!ScrollDC (hdc, xdest - xsrc, ydest - ysrc,
+ &scrollRect, &clipRect,
+ updateRgn, NULL))
+ WIN32_GDI_FAILED ("ScrollDC");
+ else if (!InvalidateRgn (window->handle, updateRgn, FALSE))
+ WIN32_GDI_FAILED ("InvalidateRgn");
+ else if (!UpdateWindow (window->handle))
+ WIN32_GDI_FAILED ("UpdateWindow");
+
+ if (!DeleteObject (updateRgn))
+ WIN32_GDI_FAILED ("DeleteObject");
+}
+
+static void
+blit_from_window (HDC hdc,
+ GdkDrawableImplWin32 *src,
+ gint xsrc,
+ gint ysrc,
+ gint xdest,
+ gint ydest,
+ gint width,
+ gint height)
+{
+ HDC srcdc;
+ HPALETTE holdpal = NULL;
+ GdkColormap *cmap = gdk_colormap_get_system ();
+
+ GDK_NOTE (MISC, g_print ("blit_from_window\n"));
+
+ if ((srcdc = GetDC (src->handle)) == NULL)
+ {
+ WIN32_GDI_FAILED ("GetDC");
+ return;
}
- else
+
+ if (cmap->visual->type == GDK_VISUAL_PSEUDO_COLOR ||
+ cmap->visual->type == GDK_VISUAL_STATIC_COLOR)
{
+ gint k;
+
+ if (!(holdpal = SelectPalette (srcdc, GDK_WIN32_COLORMAP_DATA (cmap)->hpal, FALSE)))
+ WIN32_GDI_FAILED ("SelectPalette");
+ else if ((k = RealizePalette (srcdc)) == GDI_ERROR)
+ WIN32_GDI_FAILED ("RealizePalette");
+ else if (k > 0)
+ GDK_NOTE (MISC_OR_COLORMAP,
+ g_print ("blit_from_window: realized %d\n", k));
+ }
+
+ if (!BitBlt (hdc, xdest, ydest, width, height,
+ srcdc, xsrc, ysrc, SRCCOPY))
+ WIN32_GDI_FAILED ("BitBlt");
+
+ if (holdpal != NULL)
+ SelectPalette (srcdc, holdpal, FALSE);
+
+ if (!ReleaseDC (src->handle, srcdc))
+ WIN32_GDI_FAILED ("ReleaseDC");
+}
- if ((memdc = CreateCompatibleDC (hdc)) == NULL)
- WIN32_GDI_FAILED ("CreateCompatibleDC"), ok = FALSE;
+void
+_gdk_win32_blit (gboolean use_fg_bg,
+ GdkDrawableImplWin32 *drawable,
+ GdkGC *gc,
+ GdkDrawable *src,
+ gint xsrc,
+ gint ysrc,
+ gint xdest,
+ gint ydest,
+ gint width,
+ gint height)
+{
+ HDC hdc;
+ HRGN src_rgn, draw_rgn, outside_rgn;
+ RECT r;
+ GdkDrawableImplWin32 *draw_impl;
+ GdkDrawableImplWin32 *src_impl;
+ gint src_width, src_height;
+
+ GDK_NOTE (MISC, g_print ("_gdk_win32_blit: src:%s %dx%d@+%d+%d\n"
+ " dst:%s @+%d+%d use_fg_bg=%d\n",
+ gdk_win32_drawable_description (src),
+ width, height, xsrc, ysrc,
+ gdk_win32_drawable_description ((GdkDrawable *) drawable),
+ xdest, ydest,
+ use_fg_bg));
- if (ok && (oldbitmap = SelectObject (memdc, image_private->hbitmap)) == NULL)
- WIN32_GDI_FAILED ("SelectObject"), ok = FALSE;
+ draw_impl = (GdkDrawableImplWin32 *) drawable;
- if (ok && !BitBlt (hdc, xdest, ydest, width, height,
- memdc, xsrc, ysrc, SRCCOPY))
- WIN32_GDI_FAILED ("BitBlt");
+ if (GDK_IS_DRAWABLE_IMPL_WIN32 (src))
+ src_impl = (GdkDrawableImplWin32 *) src;
+ else if (GDK_IS_WINDOW (src))
+ src_impl = (GdkDrawableImplWin32 *) GDK_WINDOW_OBJECT (src)->impl;
+ else if (GDK_IS_PIXMAP (src))
+ src_impl = (GdkDrawableImplWin32 *) GDK_PIXMAP_OBJECT (src)->impl;
+ else
+ g_assert_not_reached ();
- if (oldbitmap != NULL && SelectObject (memdc, oldbitmap) == NULL)
- WIN32_GDI_FAILED ("SelectObject");
+ hdc = gdk_win32_hdc_get ((GdkDrawable *) drawable, gc, GDK_GC_FOREGROUND);
- if (memdc != NULL && !DeleteDC (memdc))
- WIN32_GDI_FAILED ("DeleteDC");
+ gdk_drawable_get_size (src, &src_width, &src_height);
+
+ if ((src_rgn = CreateRectRgn (0, 0, src_width + 1, src_height + 1)) == NULL)
+ WIN32_GDI_FAILED ("CreateRectRgn");
+ else if ((draw_rgn = CreateRectRgn (xsrc, ysrc,
+ xsrc + width + 1,
+ ysrc + height + 1)) == NULL)
+ WIN32_GDI_FAILED ("CreateRectRgn");
+ else
+ {
+ if (GDK_IS_WINDOW_IMPL_WIN32 (draw_impl))
+ {
+ int comb;
+
+ /* If we are drawing on a window, calculate the region that is
+ * outside the source pixmap, and invalidate that, causing it to
+ * be cleared. Not completely sure whether this is always needed. XXX
+ */
+ SetRectEmpty (&r);
+ outside_rgn = CreateRectRgnIndirect (&r);
+
+ if ((comb = CombineRgn (outside_rgn,
+ draw_rgn, src_rgn,
+ RGN_DIFF)) == ERROR)
+ WIN32_GDI_FAILED ("CombineRgn");
+ else if (comb != NULLREGION)
+ {
+ OffsetRgn (outside_rgn, xdest, ydest);
+ GDK_NOTE (MISC, (GetRgnBox (outside_rgn, &r),
+ g_print ("...calling InvalidateRgn, "
+ "bbox: %ldx%ld@+%ld+%ld\n",
+ r.right - r.left - 1, r.bottom - r.top - 1,
+ r.left, r.top)));
+ InvalidateRgn (draw_impl->handle, outside_rgn, TRUE);
+ }
+ DeleteObject (outside_rgn);
+ }
+
+#if 1 /* Don't know if this is necessary XXX */
+ if (CombineRgn (draw_rgn, draw_rgn, src_rgn, RGN_AND) == COMPLEXREGION)
+ g_warning ("gdk_win32_blit: CombineRgn returned a COMPLEXREGION");
+
+ GetRgnBox (draw_rgn, &r);
+ if (r.left != xsrc || r.top != ysrc ||
+ r.right != xsrc + width + 1 || r.bottom != ysrc + height + 1)
+ {
+ xdest += r.left - xsrc;
+ xsrc = r.left;
+ ydest += r.top - ysrc;
+ ysrc = r.top;
+ width = r.right - xsrc - 1;
+ height = r.bottom - ysrc - 1;
+
+ GDK_NOTE (MISC, g_print ("... restricted to src: %dx%d@+%d+%d, "
+ "dest: @+%d+%d\n",
+ width, height, xsrc, ysrc,
+ xdest, ydest));
+ }
+#endif
+
+ DeleteObject (src_rgn);
+ DeleteObject (draw_rgn);
}
- gdk_win32_hdc_release (drawable, gc, 0);
+
+ if (GDK_IS_PIXMAP_IMPL_WIN32 (src_impl))
+ blit_from_pixmap (use_fg_bg, draw_impl, hdc,
+ (GdkPixmapImplWin32 *) src_impl, GDK_GC_WIN32 (gc),
+ xsrc, ysrc, xdest, ydest, width, height);
+ else if (draw_impl->handle == src_impl->handle)
+ blit_inside_window (src_impl, hdc, xsrc, ysrc, xdest, ydest, width, height);
+ else
+ blit_from_window (hdc, src_impl, xsrc, ysrc, xdest, ydest, width, height);
+ gdk_win32_hdc_release ((GdkDrawable *) drawable, gc, GDK_GC_FOREGROUND);
+}
+
+static void
+gdk_win32_draw_image (GdkDrawable *drawable,
+ GdkGC *gc,
+ GdkImage *image,
+ gint xsrc,
+ gint ysrc,
+ gint xdest,
+ gint ydest,
+ gint width,
+ gint height)
+{
+ g_assert (GDK_IS_DRAWABLE_IMPL_WIN32 (drawable));
+
+ _gdk_win32_blit (TRUE, (GdkDrawableImplWin32 *) drawable,
+ gc, (GdkPixmap *) image->windowing_data,
+ xsrc, ysrc, xdest, ydest, width, height);
}
static gint
@@ -1100,8 +1267,8 @@ gdk_win32_get_visual (GdkDrawable *drawable)
return gdk_drawable_get_visual (GDK_DRAWABLE_IMPL_WIN32 (drawable)->wrapper);
}
-HWND
+HGDIOBJ
gdk_win32_drawable_get_handle (GdkDrawable *drawable)
{
- return GDK_DRAWABLE_HANDLE(drawable);
+ return GDK_DRAWABLE_HANDLE (drawable);
}
diff --git a/gdk/win32/gdkdrawable-win32.h b/gdk/win32/gdkdrawable-win32.h
index a18d456b9d..c145c50df6 100644
--- a/gdk/win32/gdkdrawable-win32.h
+++ b/gdk/win32/gdkdrawable-win32.h
@@ -50,11 +50,8 @@ typedef struct _GdkDrawableImplWin32Class GdkDrawableImplWin32Class;
struct _GdkDrawableImplWin32
{
GdkDrawable parent_instance;
-
GdkDrawable *wrapper;
-
GdkColormap *colormap;
-
HANDLE handle;
};
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 0a0bbd0c5b..98859a1955 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -1,6 +1,6 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- * Copyright (C) 1998-1999 Tor Lillqvist
+ * Copyright (C) 1998-2002 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -280,13 +280,13 @@ _gdk_win32_window_procedure (HWND hwnd,
{
LRESULT retval;
- GDK_NOTE (MISC, g_print ("_gdk_win32_window_procedure: %#lx %s\n",
- (gulong) hwnd, gdk_win32_message_name (message)));
+ GDK_NOTE (MISC, g_print ("_gdk_win32_window_procedure: %p %s\n",
+ hwnd, gdk_win32_message_name (message)));
retval = real_window_procedure (hwnd, message, wparam, lparam);
- GDK_NOTE (MISC, g_print ("_gdk_win32_window_procedure: %#lx returns %ld\n",
- (gulong) hwnd, retval));
+ GDK_NOTE (MISC, g_print ("_gdk_win32_window_procedure: %p returns %ld\n",
+ hwnd, retval));
return retval;
}
@@ -533,10 +533,10 @@ gdk_pointer_grab (GdkWindow *window,
{
if (!GDK_WINDOW_DESTROYED (window))
{
- GDK_NOTE (EVENTS, g_print ("gdk_pointer_grab: %#lx %s %#lx %s\n",
- (gulong) GDK_WINDOW_HWND (window),
+ GDK_NOTE (EVENTS, g_print ("gdk_pointer_grab: %p %s %p %s\n",
+ GDK_WINDOW_HWND (window),
(owner_events ? "TRUE" : "FALSE"),
- (gulong) hcursor,
+ hcursor,
event_mask_string (event_mask)));
p_grab_mask = event_mask;
p_grab_owner_events = (owner_events != 0);
@@ -698,8 +698,8 @@ gdk_keyboard_grab (GdkWindow *window,
g_return_val_if_fail (window != NULL, 0);
g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
- GDK_NOTE (EVENTS, g_print ("gdk_keyboard_grab %#lx\n",
- (gulong) GDK_WINDOW_HWND (window)));
+ GDK_NOTE (EVENTS, g_print ("gdk_keyboard_grab %p\n",
+ GDK_WINDOW_HWND (window)));
if (!GDK_WINDOW_DESTROYED (window))
{
@@ -1024,7 +1024,7 @@ print_event (GdkEvent *event)
CASE (GDK_SETTING);
#undef CASE
}
- g_print ("%#lx ", (gulong) GDK_WINDOW_HWND (event->any.window));
+ g_print ("%p ", GDK_WINDOW_HWND (event->any.window));
switch (event->any.type)
{
@@ -1287,6 +1287,127 @@ synthesize_crossing_events (GdkWindow *window,
gdk_window_ref (current_window);
}
+#if 0
+
+static GList *
+get_descendants (GdkWindow *window)
+{
+ GList *list = gdk_window_get_children (window);
+ GList *head = list;
+ GList *tmp = NULL;
+
+ while (list)
+ {
+ tmp = g_list_concat (tmp, get_descendants ((GdkWindow *) list->data));
+ list = list->next;
+ }
+
+ return g_list_concat (tmp, head);
+}
+
+#endif
+
+static void
+synthesize_expose_events (GdkWindow *window)
+{
+ RECT r;
+ HDC hdc;
+ GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
+ GList *list = gdk_window_get_children (window);
+ GList *head = list;
+ GdkEvent *event;
+ int k;
+
+ while (list)
+ {
+ synthesize_expose_events ((GdkWindow *) list->data);
+ list = list->next;
+ }
+
+ g_list_free (head);
+
+ if (!(hdc = GetDC (impl->handle)))
+ WIN32_GDI_FAILED ("GetDC");
+ else
+ {
+ if ((k = GetClipBox (hdc, &r)) == ERROR)
+ WIN32_GDI_FAILED ("GetClipBox");
+ else if (k != NULLREGION)
+ {
+ event = _gdk_event_new ();
+ event->expose.type = GDK_EXPOSE;
+ event->expose.window = window;
+ gdk_window_ref (window);
+ event->expose.area.x = r.left;
+ event->expose.area.y = r.top;
+ event->expose.area.width = r.right - r.left;
+ event->expose.area.height = r.bottom - r.top;
+ event->expose.region = gdk_region_rectangle (&(event->expose.area));
+ event->expose.count = 0;
+
+ _gdk_event_queue_append (event);
+
+ GDK_NOTE (EVENTS_OR_COLORMAP, print_event (event));
+ }
+ if (!ReleaseDC (impl->handle, hdc))
+ WIN32_GDI_FAILED ("ReleaseDC");
+ }
+}
+
+static void
+update_colors (GdkWindow *window,
+ gboolean top)
+{
+ HDC hdc;
+ GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
+ GList *list = gdk_window_get_children (window);
+ GList *head = list;
+
+ GDK_NOTE (COLORMAP, (top ? g_print ("update_colors:") : (void) 0));
+
+ while (list)
+ {
+ update_colors ((GdkWindow *) list->data, FALSE);
+ list = list->next;
+ }
+ g_list_free (head);
+
+ if (((GdkWindowObject *) window)->input_only ||
+ impl->colormap == NULL)
+ return;
+
+ if (!(hdc = GetDC (impl->handle)))
+ WIN32_GDI_FAILED ("GetDC");
+ else
+ {
+ GdkColormapPrivateWin32 *cmapp = GDK_WIN32_COLORMAP_DATA (impl->colormap);
+ HPALETTE holdpal;
+ gint k;
+
+ if ((holdpal = SelectPalette (hdc, cmapp->hpal, TRUE)) == NULL)
+ WIN32_GDI_FAILED ("SelectPalette");
+ else if ((k = RealizePalette (hdc)) == GDI_ERROR)
+ WIN32_GDI_FAILED ("RealizePalette");
+ else
+ {
+ GDK_NOTE (COLORMAP,
+ (k > 0 ?
+ g_print (" %p pal=%p: realized %d colors\n"
+ "update_colors:",
+ impl->handle, cmapp->hpal, k) :
+ (void) 0,
+ g_print (" %p", impl->handle)));
+ if (!UpdateColors (hdc))
+ WIN32_GDI_FAILED ("UpdateColors");
+ SelectPalette (hdc, holdpal, TRUE);
+ RealizePalette (hdc);
+ }
+ if (!ReleaseDC (impl->handle, hdc))
+ WIN32_GDI_FAILED ("ReleaseDC");
+ }
+ GDK_NOTE (COLORMAP, (top ? g_print ("\n") : (void) 0));
+}
+
static void
translate_mouse_coords (GdkWindow *window1,
GdkWindow *window2,
@@ -1324,8 +1445,8 @@ propagate (GdkWindow **window,
}
else
{
- GDK_NOTE (EVENTS, g_print ("...sending to grabber %#lx\n",
- (gulong) GDK_WINDOW_HWND (grab_window)));
+ GDK_NOTE (EVENTS, g_print ("...sending to grabber %p\n",
+ GDK_WINDOW_HWND (grab_window)));
gdk_drawable_unref (*window);
*window = grab_window;
gdk_drawable_ref (*window);
@@ -1354,8 +1475,8 @@ propagate (GdkWindow **window,
{
/* Grabbed! */
GDK_NOTE (EVENTS,
- g_print ("...sending to grabber %#lx\n",
- (gulong) GDK_WINDOW_HWND (grab_window)));
+ g_print ("...sending to grabber %p\n",
+ GDK_WINDOW_HWND (grab_window)));
gdk_drawable_unref (*window);
*window = grab_window;
gdk_drawable_ref (*window);
@@ -1373,9 +1494,9 @@ propagate (GdkWindow **window,
gdk_drawable_unref (*window);
*window = GDK_WINDOW (GDK_WINDOW_OBJECT (*window)->parent);
gdk_drawable_ref (*window);
- GDK_NOTE (EVENTS, g_print ("%s %#lx",
+ GDK_NOTE (EVENTS, g_print ("%s %p",
(in_propagation ? "," : " ...propagating to"),
- (gulong) GDK_WINDOW_HWND (*window)));
+ GDK_WINDOW_HWND (*window)));
/* The only branch where we actually continue the loop */
in_propagation = TRUE;
}
@@ -1462,6 +1583,199 @@ decode_key_lparam (LPARAM lParam)
return buf;
}
+static void
+erase_background (GdkWindow *window,
+ HDC hdc)
+{
+ HDC bgdc = NULL;
+ HBRUSH hbr = NULL;
+ HPALETTE holdpal = NULL;
+ RECT rect;
+ COLORREF bg;
+ GdkColormap *colormap;
+ GdkColormapPrivateWin32 *colormap_private;
+ int i, j;
+
+ if (GDK_WINDOW_OBJECT (window)->input_only ||
+ GDK_WINDOW_OBJECT (window)->bg_pixmap == GDK_NO_BG ||
+ GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->position_info.no_bg)
+ return;
+
+ colormap = gdk_drawable_get_colormap (window);
+
+ if (colormap &&
+ (colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR ||
+ colormap->visual->type == GDK_VISUAL_STATIC_COLOR))
+ {
+ int k;
+
+ colormap_private = GDK_WIN32_COLORMAP_DATA (colormap);
+
+ if (!(holdpal = SelectPalette (hdc, colormap_private->hpal, FALSE)))
+ WIN32_GDI_FAILED ("SelectPalette");
+ else if ((k = RealizePalette (hdc)) == GDI_ERROR)
+ WIN32_GDI_FAILED ("RealizePalette");
+ else if (k > 0)
+ GDK_NOTE (COLORMAP, g_print ("gdk_win32_erase_background: realized %p: %d colors\n",
+ colormap_private->hpal, k));
+ }
+
+ while (window && GDK_WINDOW_OBJECT (window)->bg_pixmap == GDK_PARENT_RELATIVE_BG)
+ {
+ /* 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.)
+ */
+ window = GDK_WINDOW (GDK_WINDOW_OBJECT (window)->parent);
+ }
+
+ if (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->position_info.no_bg)
+ {
+ /* Improves scolling effect, e.g. main buttons of testgtk */
+ return;
+ }
+
+ if (GDK_WINDOW_OBJECT (window)->bg_pixmap == NULL)
+ {
+ bg = _gdk_win32_colormap_color (GDK_DRAWABLE_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->colormap,
+ GDK_WINDOW_OBJECT (window)->bg_color.pixel);
+
+ GetClipBox (hdc, &rect);
+ GDK_NOTE (EVENTS,
+ g_print ("...%ldx%ld@+%ld+%ld bg %06lx\n",
+ rect.right - rect.left,
+ rect.bottom - rect.top,
+ rect.left, rect.top,
+ (gulong) bg));
+ if (!(hbr = CreateSolidBrush (bg)))
+ WIN32_GDI_FAILED ("CreateSolidBrush");
+ else if (!FillRect (hdc, &rect, hbr))
+ WIN32_GDI_FAILED ("FillRect");
+ if (hbr != NULL)
+ DeleteObject (hbr);
+ }
+ else if (GDK_WINDOW_OBJECT (window)->bg_pixmap != NULL &&
+ GDK_WINDOW_OBJECT (window)->bg_pixmap != GDK_NO_BG)
+ {
+ GdkPixmap *pixmap = GDK_WINDOW_OBJECT (window)->bg_pixmap;
+ GdkPixmapImplWin32 *pixmap_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
+
+ GetClipBox (hdc, &rect);
+
+ if (pixmap_impl->width <= 8 && pixmap_impl->height <= 8)
+ {
+ GDK_NOTE (EVENTS, g_print ("...small pixmap, using brush\n"));
+ if (!(hbr = CreatePatternBrush (GDK_PIXMAP_HBITMAP (pixmap))))
+ WIN32_GDI_FAILED ("CreatePatternBrush");
+ else if (!FillRect (hdc, &rect, hbr))
+ WIN32_GDI_FAILED ("FillRect");
+ if (hbr != NULL)
+ DeleteObject (hbr);
+ }
+ else
+ {
+ HGDIOBJ oldbitmap;
+
+ GDK_NOTE (EVENTS,
+ g_print ("...blitting pixmap %p (%dx%d) "
+ "all over the place,\n"
+ "...clip box = %ldx%ld@+%ld+%ld\n",
+ GDK_PIXMAP_HBITMAP (pixmap),
+ pixmap_impl->width, pixmap_impl->height,
+ rect.right - rect.left, rect.bottom - rect.top,
+ rect.left, rect.top));
+
+ if (!(bgdc = CreateCompatibleDC (hdc)))
+ {
+ WIN32_GDI_FAILED ("CreateCompatibleDC");
+ return;
+ }
+ if (!(oldbitmap = SelectObject (bgdc, GDK_PIXMAP_HBITMAP (pixmap))))
+ {
+ WIN32_GDI_FAILED ("SelectObject");
+ DeleteDC (bgdc);
+ return;
+ }
+ i = 0;
+ while (i < rect.right)
+ {
+ j = 0;
+ while (j < rect.bottom)
+ {
+ if (i + pixmap_impl->width >= rect.left
+ && j + pixmap_impl->height >= rect.top)
+ {
+ if (!BitBlt (hdc, i, j,
+ pixmap_impl->width, pixmap_impl->height,
+ bgdc, 0, 0, SRCCOPY))
+ {
+ WIN32_GDI_FAILED ("BitBlt");
+ SelectObject (bgdc, oldbitmap);
+ DeleteDC (bgdc);
+ return;
+ }
+ }
+ j += pixmap_impl->height;
+ }
+ i += pixmap_impl->width;
+ }
+ SelectObject (bgdc, oldbitmap);
+ DeleteDC (bgdc);
+ }
+ }
+ else
+ {
+ GDK_NOTE (EVENTS, g_print ("...BLACK_BRUSH (?)\n"));
+ hbr = GetStockObject (BLACK_BRUSH);
+ GetClipBox (hdc, &rect);
+ if (!FillRect (hdc, &rect, hbr))
+ WIN32_GDI_FAILED ("FillRect");
+ }
+}
+
+static GdkRegion *
+_gdk_win32_hrgn_to_region (HRGN hrgn)
+{
+ RGNDATA *rgndata;
+ RECT *rects;
+ GdkRegion *result;
+ gint nbytes;
+ gint i;
+
+ if ((nbytes = GetRegionData (hrgn, 0, NULL)) == 0)
+ {
+ WIN32_GDI_FAILED ("GetRegionData");
+ return NULL;
+ }
+
+ rgndata = (RGNDATA *) g_malloc (nbytes);
+
+ if (GetRegionData (hrgn, nbytes, rgndata) == 0)
+ {
+ WIN32_GDI_FAILED ("GetRegionData");
+ g_free (rgndata);
+ return NULL;
+ }
+
+ result = gdk_region_new ();
+ rects = (RECT *) rgndata->Buffer;
+ for (i = 0; i < rgndata->rdh.nCount; i++)
+ {
+ GdkRectangle r;
+
+ r.x = rects[i].left;
+ r.y = rects[i].top;
+ r.width = rects[i].right - r.x;
+ r.height = rects[i].bottom - r.y;
+
+ gdk_region_union_with_rect (result, &r);
+ }
+
+ g_free (rgndata);
+
+ return result;
+}
+
static gboolean
gdk_event_translate (GdkEvent *event,
MSG *msg,
@@ -1473,15 +1787,12 @@ gdk_event_translate (GdkEvent *event,
DWORD pidThis;
PAINTSTRUCT paintstruct;
HDC hdc;
- HDC bgdc;
- HGDIOBJ oldbitmap;
- HBRUSH hbr;
- COLORREF bg;
RECT rect;
POINT pt;
MINMAXINFO *mmi;
HWND hwnd;
HCURSOR hcursor;
+ HRGN hrgn;
/* Invariant:
* window_impl == GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)
@@ -1493,19 +1804,14 @@ gdk_event_translate (GdkEvent *event,
window_impl = (window ? GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl) : NULL))
GdkWindow *orig_window, *new_window;
- GdkColormap *colormap;
- GdkColormapPrivateWin32 *colormap_private;
- GdkPixmap *pixmap;
- GdkPixmapImplWin32 *pixmap_impl;
gint xoffset, yoffset;
- int button;
- int i, j;
+ static gint update_colors_counter = 0;
+ gint button;
+ gint k;
gchar buf[256];
- gboolean return_val;
-
- return_val = FALSE;
+ gboolean return_val = FALSE;
if (ret_val_flagp)
*ret_val_flagp = FALSE;
@@ -1537,8 +1843,8 @@ gdk_event_translate (GdkEvent *event,
* removed it. Repost the same message to our queue so that
* we will get it later when we are prepared.
*/
- GDK_NOTE(MISC, g_print("gdk_event_translate: %#lx %s posted.\n",
- (gulong) msg->hwnd,
+ GDK_NOTE(MISC, g_print("gdk_event_translate: %p %s posted.\n",
+ msg->hwnd,
msg->message == WM_MOVE ?
"WM_MOVE" : "WM_SIZE"));
@@ -1598,8 +1904,8 @@ gdk_event_translate (GdkEvent *event,
if (msg->message == msh_mousewheel_msg)
{
- GDK_NOTE (EVENTS, g_print ("MSH_MOUSEWHEEL: %#lx %d\n",
- (gulong) msg->hwnd, msg->wParam));
+ GDK_NOTE (EVENTS, g_print ("MSH_MOUSEWHEEL: %p %d\n",
+ msg->hwnd, msg->wParam));
event->scroll.type = GDK_SCROLL;
@@ -1706,8 +2012,8 @@ gdk_event_translate (GdkEvent *event,
{
case WM_INPUTLANGCHANGE:
GDK_NOTE (EVENTS,
- g_print ("WM_INPUTLANGCHANGE: %#lx charset %lu locale %lx\n",
- (gulong) msg->hwnd, (gulong) msg->wParam, msg->lParam));
+ g_print ("WM_INPUTLANGCHANGE: %p charset %lu locale %lx\n",
+ msg->hwnd, (gulong) msg->wParam, msg->lParam));
window_impl->input_locale = (HKL) msg->lParam;
TranslateCharsetInfo ((DWORD FAR *) msg->wParam,
&window_impl->charset_info,
@@ -1717,9 +2023,9 @@ gdk_event_translate (GdkEvent *event,
case WM_SYSKEYUP:
case WM_SYSKEYDOWN:
GDK_NOTE (EVENTS,
- g_print ("WM_SYSKEY%s: %#lx %s %#x %s\n",
+ g_print ("WM_SYSKEY%s: %p %s %#x %s\n",
(msg->message == WM_SYSKEYUP ? "UP" : "DOWN"),
- (gulong) msg->hwnd,
+ msg->hwnd,
(GetKeyNameText (msg->lParam, buf,
sizeof (buf)) > 0 ?
buf : ""),
@@ -1745,9 +2051,9 @@ gdk_event_translate (GdkEvent *event,
case WM_KEYUP:
case WM_KEYDOWN:
GDK_NOTE (EVENTS,
- g_print ("WM_KEY%s: %#lx %s %#x %s\n",
+ g_print ("WM_KEY%s: %p %s %#x %s\n",
(msg->message == WM_KEYUP ? "UP" : "DOWN"),
- (gulong) msg->hwnd,
+ msg->hwnd,
(GetKeyNameText (msg->lParam, buf,
sizeof (buf)) > 0 ?
buf : ""),
@@ -2030,24 +2336,24 @@ gdk_event_translate (GdkEvent *event,
if (!use_ime_composition)
break;
- GDK_NOTE (EVENTS, g_print ("WM_IME_COMPOSITION: %#lx %#lx\n",
- (gulong) msg->hwnd, msg->lParam));
+ GDK_NOTE (EVENTS, g_print ("WM_IME_COMPOSITION: %p %#lx\n",
+ msg->hwnd, msg->lParam));
if (msg->lParam & GCS_RESULTSTR)
goto wm_char;
break;
case WM_IME_CHAR:
GDK_NOTE (EVENTS,
- g_print ("WM_IME_CHAR: %#lx bytes: %#.04x\n",
- (gulong) msg->hwnd, msg->wParam));
+ g_print ("WM_IME_CHAR: %p bytes: %#.04x\n",
+ msg->hwnd, msg->wParam));
goto wm_char;
case WM_CHAR:
case WM_SYSCHAR:
GDK_NOTE (EVENTS,
- g_print ("WM_%sCHAR: %#lx %#x %s %s\n",
+ g_print ("WM_%sCHAR: %p %#x %s %s\n",
(msg->message == WM_CHAR ? "" : "SYS"),
- (gulong) msg->hwnd, msg->wParam,
+ msg->hwnd, msg->wParam,
decode_key_lparam (msg->lParam),
(ignore_wm_char ? "ignored" : "")));
@@ -2115,9 +2421,9 @@ gdk_event_translate (GdkEvent *event,
buttondown0:
GDK_NOTE (EVENTS,
- g_print ("WM_%cBUTTONDOWN: %#lx (%d,%d)\n",
+ g_print ("WM_%cBUTTONDOWN: %p (%d,%d)\n",
" LMR"[button],
- (gulong) msg->hwnd,
+ msg->hwnd,
LOWORD (msg->lParam), HIWORD (msg->lParam)));
if (GDK_WINDOW_OBJECT (window)->extension_events != 0
@@ -2186,9 +2492,9 @@ gdk_event_translate (GdkEvent *event,
buttonup0:
GDK_NOTE (EVENTS,
- g_print ("WM_%cBUTTONUP: %#lx (%d,%d)\n",
+ g_print ("WM_%cBUTTONUP: %p (%d,%d)\n",
" LMR"[button],
- (gulong) msg->hwnd,
+ msg->hwnd,
LOWORD (msg->lParam), HIWORD (msg->lParam)));
ASSIGN_WINDOW (find_window_for_pointer_event (window, msg));
@@ -2237,8 +2543,8 @@ gdk_event_translate (GdkEvent *event,
case WM_MOUSEMOVE:
GDK_NOTE (EVENTS,
- g_print ("WM_MOUSEMOVE: %#lx %#x (%d,%d)\n",
- (gulong) msg->hwnd, msg->wParam,
+ g_print ("WM_MOUSEMOVE: %p %#x (%d,%d)\n",
+ msg->hwnd, msg->wParam,
LOWORD (msg->lParam), HIWORD (msg->lParam)));
ASSIGN_WINDOW (find_window_for_pointer_event (window, msg));
@@ -2295,8 +2601,8 @@ gdk_event_translate (GdkEvent *event,
case WM_NCMOUSEMOVE:
GDK_NOTE (EVENTS,
- g_print ("WM_NCMOUSEMOVE: %#lx x,y: %d %d\n",
- (gulong) msg->hwnd,
+ g_print ("WM_NCMOUSEMOVE: %p x,y: %d %d\n",
+ msg->hwnd,
LOWORD (msg->lParam), HIWORD (msg->lParam)));
if (track_mouse_event == NULL
&& current_window != NULL
@@ -2329,8 +2635,8 @@ gdk_event_translate (GdkEvent *event,
break;
case WM_MOUSEWHEEL:
- GDK_NOTE (EVENTS, g_print ("WM_MOUSEWHEEL: %#lx %d\n",
- (gulong) msg->hwnd, HIWORD (msg->wParam)));
+ GDK_NOTE (EVENTS, g_print ("WM_MOUSEWHEEL: %p %d\n",
+ msg->hwnd, HIWORD (msg->wParam)));
event->scroll.type = GDK_SCROLL;
@@ -2387,7 +2693,7 @@ gdk_event_translate (GdkEvent *event,
#ifdef USE_TRACKMOUSEEVENT
case WM_MOUSELEAVE:
- GDK_NOTE (EVENTS, g_print ("WM_MOUSELEAVE: %#lx\n", (gulong) msg->hwnd));
+ GDK_NOTE (EVENTS, g_print ("WM_MOUSELEAVE: %p\n", msg->hwnd));
if (!(window_impl->event_mask & GDK_LEAVE_NOTIFY_MASK))
break;
@@ -2423,12 +2729,40 @@ gdk_event_translate (GdkEvent *event,
break;
#endif
+ case WM_QUERYNEWPALETTE:
+ GDK_NOTE (EVENTS_OR_COLORMAP, g_print ("WM_QUERYNEWPALETTE: %p\n",
+ msg->hwnd));
+ synthesize_expose_events (window);
+ update_colors_counter = 0;
+ *ret_val_flagp = TRUE;
+ *ret_valp = FALSE;
+ break;
+
+ case WM_PALETTECHANGED:
+ GDK_NOTE (EVENTS_OR_COLORMAP, g_print ("WM_PALETTECHANGED: %p %p\n",
+ msg->hwnd, (HWND) msg->wParam));
+ *ret_val_flagp = TRUE;
+ *ret_valp = FALSE;
+
+ if (msg->hwnd == (HWND) msg->wParam)
+ break;
+
+ if (++update_colors_counter == 5)
+ {
+ synthesize_expose_events (window);
+ update_colors_counter = 0;
+ break;
+ }
+
+ update_colors (window, TRUE);
+ break;
+
case WM_SETFOCUS:
case WM_KILLFOCUS:
- GDK_NOTE (EVENTS, g_print ("WM_%sFOCUS: %#lx\n",
+ GDK_NOTE (EVENTS, g_print ("WM_%sFOCUS: %p\n",
(msg->message == WM_SETFOCUS ?
"SET" : "KILL"),
- (gulong) msg->hwnd));
+ msg->hwnd));
if (!(window_impl->event_mask & GDK_FOCUS_CHANGE_MASK))
break;
@@ -2440,178 +2774,36 @@ gdk_event_translate (GdkEvent *event,
break;
case WM_ERASEBKGND:
- GDK_NOTE (EVENTS, g_print ("WM_ERASEBKGND: %#lx dc %#x\n",
- (gulong) msg->hwnd, msg->wParam));
+ GDK_NOTE (EVENTS, g_print ("WM_ERASEBKGND: %p dc %#x\n",
+ msg->hwnd, msg->wParam));
if (GDK_WINDOW_DESTROYED (window))
break;
+ erase_background (window, (HDC) msg->wParam);
*ret_val_flagp = TRUE; /* always claim as handled */
*ret_valp = 1;
- if (GDK_WINDOW_OBJECT (window)->input_only)
- break;
-
- if (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->position_info.no_bg)
- {
- /* improves scolling effect, e.g. main buttons of testgtk */
- *ret_val_flagp = TRUE;
- *ret_valp = 1;
- break;
- }
-
- colormap = gdk_drawable_get_colormap (window);
- if (colormap)
- colormap_private = GDK_COLORMAP_PRIVATE_DATA (colormap);
- hdc = (HDC) msg->wParam;
- if (colormap && colormap_private->xcolormap->rc_palette)
- {
- int k;
-
- if (SelectPalette (hdc, colormap_private->xcolormap->palette,
- FALSE) == NULL)
- WIN32_GDI_FAILED ("SelectPalette");
- if ((k = RealizePalette (hdc)) == GDI_ERROR)
- WIN32_GDI_FAILED ("RealizePalette");
-#if 0
- g_print ("WM_ERASEBKGND: selected %#x, realized %d colors\n",
- colormap_private->xcolormap->palette, k);
-#endif
- }
-
- if (GDK_WINDOW_OBJECT (window)->bg_pixmap == GDK_PARENT_RELATIVE_BG)
- {
- /* If this window should have the same background as the
- * parent, fetch the parent. (And if the same goes for
- * the parent, fetch the grandparent, etc.)
- */
- while (window && GDK_WINDOW_OBJECT (window)->bg_pixmap == GDK_PARENT_RELATIVE_BG)
- {
- gdk_drawable_unref (window);
- ASSIGN_WINDOW (GDK_WINDOW (GDK_WINDOW_OBJECT (window)->parent));
- gdk_drawable_ref (window);
- }
- }
+ break;
- if (GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->position_info.no_bg)
+ case WM_PAINT:
+ if (!GetUpdateRect (msg->hwnd, NULL, FALSE))
{
- /* improves scolling effect, e.g. main buttons of testgtk */
- *ret_val_flagp = TRUE;
- *ret_valp = 1;
+ GDK_NOTE (EVENTS, g_print ("WM_PAINT: %p no update rgn\n",
+ msg->hwnd));
break;
}
- if (GDK_WINDOW_OBJECT (window)->bg_pixmap == NULL)
- {
- bg = _gdk_win32_colormap_color (GDK_DRAWABLE_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->colormap,
- GDK_WINDOW_OBJECT (window)->bg_color.pixel);
-
- GetClipBox (hdc, &rect);
- GDK_NOTE (EVENTS,
- g_print ("...%ldx%ld@+%ld+%ld BG_PIXEL %.06lx\n",
- rect.right - rect.left,
- rect.bottom - rect.top,
- rect.left, rect.top,
- (gulong) bg));
- hbr = CreateSolidBrush (bg);
-#if 0
- g_print ("...CreateSolidBrush (%.08x) = %.08x\n", bg, hbr);
-#endif
- if (!FillRect (hdc, &rect, hbr))
- WIN32_GDI_FAILED ("FillRect");
- DeleteObject (hbr);
- }
- else if (GDK_WINDOW_OBJECT (window)->bg_pixmap != NULL &&
- GDK_WINDOW_OBJECT (window)->bg_pixmap != GDK_NO_BG)
- {
- pixmap = GDK_WINDOW_OBJECT (window)->bg_pixmap;
- pixmap_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
- GetClipBox (hdc, &rect);
-
- if (pixmap_impl->width <= 8 && pixmap_impl->height <= 8)
- {
- GDK_NOTE (EVENTS, g_print ("...small pixmap, using brush\n"));
- hbr = CreatePatternBrush (GDK_PIXMAP_HBITMAP (pixmap));
- if (!FillRect (hdc, &rect, hbr))
- WIN32_GDI_FAILED ("FillRect");
- DeleteObject (hbr);
- }
- else
- {
- GDK_NOTE (EVENTS,
- g_print ("...blitting pixmap %#lx (%dx%d) "
- "all over the place,\n"
- "...clip box = %ldx%ld@+%ld+%ld\n",
- (gulong) GDK_PIXMAP_HBITMAP (pixmap),
- pixmap_impl->width, pixmap_impl->height,
- rect.right - rect.left, rect.bottom - rect.top,
- rect.left, rect.top));
-
- if (!(bgdc = CreateCompatibleDC (hdc)))
- {
- WIN32_GDI_FAILED ("CreateCompatibleDC");
- break;
- }
- if (!(oldbitmap = SelectObject (bgdc, GDK_PIXMAP_HBITMAP (pixmap))))
- {
- WIN32_GDI_FAILED ("SelectObject");
- DeleteDC (bgdc);
- break;
- }
- i = 0;
- while (i < rect.right)
- {
- j = 0;
- while (j < rect.bottom)
- {
- if (i + pixmap_impl->width >= rect.left
- && j + pixmap_impl->height >= rect.top)
- {
- if (!BitBlt (hdc, i, j,
- pixmap_impl->width, pixmap_impl->height,
- bgdc, 0, 0, SRCCOPY))
- {
- WIN32_GDI_FAILED ("BitBlt");
- goto loopexit;
- }
- }
- j += pixmap_impl->height;
- }
- i += pixmap_impl->width;
- }
- loopexit:
- SelectObject (bgdc, oldbitmap);
- DeleteDC (bgdc);
- }
- }
- else
- {
- GDK_NOTE (EVENTS, g_print ("...BLACK_BRUSH (?)\n"));
- hbr = GetStockObject (BLACK_BRUSH);
- GetClipBox (hdc, &rect);
- if (!FillRect (hdc, &rect, hbr))
- WIN32_GDI_FAILED ("FillRect");
- }
- break;
-
- case WM_PAINT:
- if (!GetUpdateRect(msg->hwnd, NULL, FALSE))
- {
- GDK_NOTE (EVENTS, g_print ("WM_PAINT: %#lx no update rect\n",
- (gulong) msg->hwnd));
- break;
- }
-
hdc = BeginPaint (msg->hwnd, &paintstruct);
GDK_NOTE (EVENTS,
- g_print ("WM_PAINT: %#lx %ldx%ld@+%ld+%ld %s dc %#lx\n",
- (gulong) msg->hwnd,
+ g_print ("WM_PAINT: %p %ldx%ld@+%ld+%ld %s dc %p\n",
+ msg->hwnd,
paintstruct.rcPaint.right - paintstruct.rcPaint.left,
paintstruct.rcPaint.bottom - paintstruct.rcPaint.top,
paintstruct.rcPaint.left, paintstruct.rcPaint.top,
(paintstruct.fErase ? "erase" : ""),
- (gulong) hdc));
+ hdc));
EndPaint (msg->hwnd, &paintstruct);
@@ -2633,15 +2825,26 @@ gdk_event_translate (GdkEvent *event,
if (return_exposes)
{
+ hrgn = CreateRectRgn (0, 0, 0, 0);
+ if ((k = GetUpdateRgn (msg->hwnd, hrgn, FALSE)) == ERROR)
+ WIN32_GDI_FAILED ("GetUpdateRgn");
+ else if (k == NULLREGION)
+ {
+ DeleteObject (hrgn);
+ break;
+ }
+
event->expose.type = GDK_EXPOSE;
event->expose.window = window;
event->expose.area.x = paintstruct.rcPaint.left;
event->expose.area.y = paintstruct.rcPaint.top;
event->expose.area.width = paintstruct.rcPaint.right - paintstruct.rcPaint.left;
event->expose.area.height = paintstruct.rcPaint.bottom - paintstruct.rcPaint.top;
- event->expose.region = gdk_region_rectangle (&(event->expose.area));
+ event->expose.region = _gdk_win32_hrgn_to_region (hrgn);
event->expose.count = 0;
+ DeleteObject (hrgn);
+
return_val = !GDK_WINDOW_DESTROYED (window);
if (return_val)
{
@@ -2673,14 +2876,14 @@ gdk_event_translate (GdkEvent *event,
break;
case WM_GETICON:
- GDK_NOTE (EVENTS, g_print ("WM_GETICON: %#lx %s\n",
- (gulong) msg->hwnd,
+ GDK_NOTE (EVENTS, g_print ("WM_GETICON: %p %s\n",
+ msg->hwnd,
(ICON_BIG == msg->wParam ? "big" : "small")));
break;
case WM_SETCURSOR:
- GDK_NOTE (EVENTS, g_print ("WM_SETCURSOR: %#lx %#x %#x\n",
- (gulong) msg->hwnd,
+ GDK_NOTE (EVENTS, g_print ("WM_SETCURSOR: %p %#x %#x\n",
+ msg->hwnd,
LOWORD (msg->lParam), HIWORD (msg->lParam)));
if (LOWORD (msg->lParam) != HTCLIENT)
@@ -2695,7 +2898,7 @@ gdk_event_translate (GdkEvent *event,
if (hcursor != NULL)
{
- GDK_NOTE (EVENTS, g_print ("...SetCursor(%#lx)\n", (gulong) hcursor));
+ GDK_NOTE (EVENTS, g_print ("...SetCursor(%p)\n", hcursor));
SetCursor (hcursor);
*ret_val_flagp = TRUE;
*ret_valp = TRUE;
@@ -2703,9 +2906,8 @@ gdk_event_translate (GdkEvent *event,
break;
case WM_SHOWWINDOW:
- GDK_NOTE (EVENTS, g_print ("WM_SHOWWINDOW: %#lx %d\n",
- (gulong) msg->hwnd,
- msg->wParam));
+ GDK_NOTE (EVENTS, g_print ("WM_SHOWWINDOW: %p %d\n",
+ msg->hwnd, msg->wParam));
if (!(window_impl->event_mask & GDK_STRUCTURE_MASK))
break;
@@ -2726,8 +2928,8 @@ gdk_event_translate (GdkEvent *event,
case WM_SIZE:
GDK_NOTE (EVENTS,
- g_print ("WM_SIZE: %#lx %s %dx%d\n",
- (gulong) msg->hwnd,
+ g_print ("WM_SIZE: %p %s %dx%d\n",
+ msg->hwnd,
(msg->wParam == SIZE_MAXHIDE ? "MAXHIDE" :
(msg->wParam == SIZE_MAXIMIZED ? "MAXIMIZED" :
(msg->wParam == SIZE_MAXSHOW ? "MAXSHOW" :
@@ -2818,7 +3020,7 @@ gdk_event_translate (GdkEvent *event,
break;
#endif
case WM_GETMINMAXINFO:
- GDK_NOTE (EVENTS, g_print ("WM_GETMINMAXINFO: %#lx\n", (gulong) msg->hwnd));
+ GDK_NOTE (EVENTS, g_print ("WM_GETMINMAXINFO: %p\n", msg->hwnd));
mmi = (MINMAXINFO*) msg->lParam;
if (window_impl->hint_flags & GDK_HINT_MIN_SIZE)
@@ -2849,8 +3051,8 @@ gdk_event_translate (GdkEvent *event,
break;
case WM_MOVE:
- GDK_NOTE (EVENTS, g_print ("WM_MOVE: %#lx (%d,%d)\n",
- (gulong) msg->hwnd,
+ GDK_NOTE (EVENTS, g_print ("WM_MOVE: %p (%d,%d)\n",
+ msg->hwnd,
LOWORD (msg->lParam), HIWORD (msg->lParam)));
if (!(window_impl->event_mask & GDK_STRUCTURE_MASK))
@@ -2902,8 +3104,8 @@ gdk_event_translate (GdkEvent *event,
return_val = !GDK_WINDOW_DESTROYED (window);
- GDK_NOTE (EVENTS, g_print ("WM_WINDOWPOSCHANGED: %#lx %ldx%ld@+%ld+%ld\n",
- (gulong) msg->hwnd,
+ GDK_NOTE (EVENTS, g_print ("WM_WINDOWPOSCHANGED: %p %ldx%ld@+%ld+%ld\n",
+ msg->hwnd,
lpwp->cx, lpwp->cy, lpwp->x, lpwp->y));
if (ret_val_flagp)
@@ -2914,7 +3116,7 @@ gdk_event_translate (GdkEvent *event,
break;
#endif
case WM_CLOSE:
- GDK_NOTE (EVENTS, g_print ("WM_CLOSE: %#lx\n", (gulong) msg->hwnd));
+ GDK_NOTE (EVENTS, g_print ("WM_CLOSE: %p\n", msg->hwnd));
event->any.type = GDK_DELETE;
event->any.window = window;
@@ -2937,10 +3139,10 @@ gdk_event_translate (GdkEvent *event,
flag = FALSE;
GDK_NOTE (EVENTS, flag = TRUE);
if (flag)
- g_print ("WM_%s: %#lx %#x (%s)\n",
+ g_print ("WM_%s: %p %#x (%s)\n",
(msg->message == WM_RENDERFORMAT ? "RENDERFORMAT" :
"RENDERALLFORMATS"),
- (gulong) msg->hwnd,
+ msg->hwnd,
msg->wParam,
(msg->wParam == CF_TEXT ? "CF_TEXT" :
(msg->wParam == CF_DIB ? "CF_DIB" :
@@ -2982,7 +3184,7 @@ gdk_event_translate (GdkEvent *event,
#endif /* No delayed rendering */
case WM_DESTROY:
- GDK_NOTE (EVENTS, g_print ("WM_DESTROY: %#lx\n", (gulong) msg->hwnd));
+ GDK_NOTE (EVENTS, g_print ("WM_DESTROY: %p\n", msg->hwnd));
event->any.type = GDK_DESTROY;
event->any.window = window;
@@ -3011,20 +3213,18 @@ gdk_event_translate (GdkEvent *event,
* constants as case labels.
*/
case WT_PACKET:
- GDK_NOTE (EVENTS, g_print ("WT_PACKET: %#lx %d %#lx\n",
- (gulong) msg->hwnd,
- msg->wParam, msg->lParam));
+ GDK_NOTE (EVENTS, g_print ("WT_PACKET: %p %d %#lx\n",
+ msg->hwnd, msg->wParam, msg->lParam));
goto wintab;
case WT_CSRCHANGE:
- GDK_NOTE (EVENTS, g_print ("WT_CSRCHANGE: %#lx %d %#lx\n",
- (gulong) msg->hwnd,
- msg->wParam, msg->lParam));
+ GDK_NOTE (EVENTS, g_print ("WT_CSRCHANGE: %p %d %#lx\n",
+ msg->hwnd, msg->wParam, msg->lParam));
goto wintab;
case WT_PROXIMITY:
- GDK_NOTE (EVENTS, g_print ("WT_PROXIMITY: %#lx %#x %d %d\n",
- (gulong) msg->hwnd, msg->wParam,
+ GDK_NOTE (EVENTS, g_print ("WT_PROXIMITY: %p %#x %d %d\n",
+ msg->hwnd, msg->wParam,
LOWORD (msg->lParam),
HIWORD (msg->lParam)));
/* Fall through */
@@ -3035,10 +3235,9 @@ gdk_event_translate (GdkEvent *event,
#endif
default:
- GDK_NOTE (EVENTS, g_print ("%s: %#lx %#x %#lx\n",
+ GDK_NOTE (EVENTS, g_print ("%s: %p %#x %#lx\n",
gdk_win32_message_name (msg->message),
- (gulong) msg->hwnd,
- msg->wParam, msg->lParam));
+ msg->hwnd, msg->wParam, msg->lParam));
}
done:
@@ -3077,8 +3276,8 @@ _gdk_events_queue (void)
while (!_gdk_event_queue_find_first ()
&& PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
{
- GDK_NOTE (EVENTS, g_print ("PeekMessage: %#lx %s\n",
- (gulong) msg.hwnd, gdk_win32_message_name (msg.message)));
+ GDK_NOTE (EVENTS, g_print ("PeekMessage: %p %s\n",
+ msg.hwnd, gdk_win32_message_name (msg.message)));
#ifndef HAVE_DIMM_H
TranslateMessage (&msg);
#else
@@ -3197,14 +3396,14 @@ gdk_event_send_clientmessage_toall (GdkEvent *event)
void
gdk_flush (void)
{
+#if 0
MSG msg;
-#if 0
/* Process all messages currently available */
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
{
- TranslateMessage (&msg); /* Translate virt. key codes */
- DispatchMessage (&msg); /* Dispatch msg. to window */
+ TranslateMessage (&msg);
+ DispatchMessage (&msg);
}
#endif
diff --git a/gdk/win32/gdkfont-win32.c b/gdk/win32/gdkfont-win32.c
index c7cde75a2e..87aab50b52 100644
--- a/gdk/win32/gdkfont-win32.c
+++ b/gdk/win32/gdkfont-win32.c
@@ -1,5 +1,6 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * Copyright (C) 1998-2002 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/gdk/win32/gdkgc-win32.c b/gdk/win32/gdkgc-win32.c
index 670a4bb590..a5efc8b2c9 100644
--- a/gdk/win32/gdkgc-win32.c
+++ b/gdk/win32/gdkgc-win32.c
@@ -1,5 +1,6 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * Copyright (C) 1998-2002 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -118,22 +119,22 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values,
char *s = "";
gint sw, sh;
- GDK_NOTE (MISC, g_print ("{"));
+ GDK_NOTE (GC, g_print ("{"));
if (mask & GDK_GC_FOREGROUND)
{
win32_gc->foreground = values->foreground.pixel;
win32_gc->values_mask |= GDK_GC_FOREGROUND;
- GDK_NOTE (MISC, (g_print ("fg=%.06lx", win32_gc->foreground),
- s = ","));
+ GDK_NOTE (GC, (g_print ("fg=%.06lx", win32_gc->foreground),
+ s = ","));
}
if (mask & GDK_GC_BACKGROUND)
{
win32_gc->background = values->background.pixel;
win32_gc->values_mask |= GDK_GC_BACKGROUND;
- GDK_NOTE (MISC, (g_print ("%sbg=%.06lx", s, win32_gc->background),
- s = ","));
+ GDK_NOTE (GC, (g_print ("%sbg=%.06lx", s, win32_gc->background),
+ s = ","));
}
if ((mask & GDK_GC_FONT) && (values->font->type == GDK_FONT_FONT
@@ -148,89 +149,43 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values,
gdk_font_ref (win32_gc->font);
win32_gc->values_mask |= GDK_GC_FONT;
- GDK_NOTE (MISC, (xlfd = gdk_font_full_name_get (win32_gc->font),
- g_print ("%sfont=%s", s, xlfd),
- s = ",",
- gdk_font_full_name_free (xlfd)));
+ GDK_NOTE (GC, (xlfd = gdk_font_full_name_get (win32_gc->font),
+ g_print ("%sfont=%s", s, xlfd),
+ s = ",",
+ gdk_font_full_name_free (xlfd)));
}
else
{
win32_gc->values_mask &= ~GDK_GC_FONT;
- GDK_NOTE (MISC, (g_print ("%sfont=NULL", s),
- s = ","));
+ GDK_NOTE (GC, (g_print ("%sfont=NULL", s),
+ s = ","));
}
}
if (mask & GDK_GC_FUNCTION)
{
- GDK_NOTE (MISC, (g_print ("%srop2=", s),
- s = ","));
+ GDK_NOTE (GC, (g_print ("%srop2=", s),
+ s = ","));
switch (values->function)
{
- case GDK_COPY:
- win32_gc->rop2 = R2_COPYPEN;
- GDK_NOTE (MISC, g_print ("COPYPEN"));
- break;
- case GDK_INVERT:
- win32_gc->rop2 = R2_NOT;
- GDK_NOTE (MISC, g_print ("NOT"));
- break;
- case GDK_XOR:
- win32_gc->rop2 = R2_XORPEN;
- GDK_NOTE (MISC, g_print ("XORPEN"));
- break;
- case GDK_CLEAR:
- win32_gc->rop2 = R2_BLACK;
- GDK_NOTE (MISC, g_print ("BLACK"));
- break;
- case GDK_AND:
- win32_gc->rop2 = R2_MASKPEN;
- GDK_NOTE (MISC, g_print ("MASKPEN"));
- break;
- case GDK_AND_REVERSE:
- win32_gc->rop2 = R2_MASKPENNOT;
- GDK_NOTE (MISC, g_print ("MASKPENNOT"));
- break;
- case GDK_AND_INVERT:
- win32_gc->rop2 = R2_MASKNOTPEN;
- GDK_NOTE (MISC, g_print ("MASKNOTPEN"));
- break;
- case GDK_NOOP:
- win32_gc->rop2 = R2_NOP;
- GDK_NOTE (MISC, g_print ("NOP"));
- break;
- case GDK_OR:
- win32_gc->rop2 = R2_MERGEPEN;
- GDK_NOTE (MISC, g_print ("MERGEPEN"));
- break;
- case GDK_EQUIV:
- win32_gc->rop2 = R2_NOTXORPEN;
- GDK_NOTE (MISC, g_print ("NOTXORPEN"));
- break;
- case GDK_OR_REVERSE:
- win32_gc->rop2 = R2_MERGEPENNOT;
- GDK_NOTE (MISC, g_print ("MERGEPENNOT"));
- break;
- case GDK_COPY_INVERT:
- win32_gc->rop2 = R2_NOTCOPYPEN;
- GDK_NOTE (MISC, g_print ("NOTCOPYPEN"));
- break;
- case GDK_OR_INVERT:
- win32_gc->rop2 = R2_MERGENOTPEN;
- GDK_NOTE (MISC, g_print ("MERGENOTPEN"));
- break;
- case GDK_NAND:
- win32_gc->rop2 = R2_NOTMASKPEN;
- GDK_NOTE (MISC, g_print ("NOTMASKPEN"));
- break;
- case GDK_NOR:
- win32_gc->rop2 = R2_NOTMERGEPEN;
- GDK_NOTE (MISC, g_print ("NOTMERGEPEN"));
- break;
- case GDK_SET:
- win32_gc->rop2 = R2_WHITE;
- GDK_NOTE (MISC, g_print ("WHITE"));
- break;
+#define CASE(x,y) case GDK_##x: win32_gc->rop2 = R2_##y; GDK_NOTE (GC, g_print (#y)); break
+ CASE (COPY, COPYPEN);
+ CASE (INVERT, NOT);
+ CASE (XOR, XORPEN);
+ CASE (CLEAR, BLACK);
+ CASE (AND, MASKPEN);
+ CASE (AND_REVERSE, MASKPENNOT);
+ CASE (AND_INVERT, MASKNOTPEN);
+ CASE (NOOP, NOP);
+ CASE (OR, MERGEPEN);
+ CASE (EQUIV, NOTXORPEN);
+ CASE (OR_REVERSE, MERGEPENNOT);
+ CASE (COPY_INVERT, NOTCOPYPEN);
+ CASE (OR_INVERT, MERGENOTPEN);
+ CASE (NAND, NOTMASKPEN);
+ CASE (NOR, NOTMERGEPEN);
+ CASE (SET, WHITE);
+#undef CASE
}
win32_gc->values_mask |= GDK_GC_FUNCTION;
}
@@ -239,8 +194,8 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values,
{
win32_gc->fill_style = values->fill;
win32_gc->values_mask |= GDK_GC_FILL;
- GDK_NOTE (MISC, (g_print ("%sfill=%d", s, win32_gc->fill_style),
- s = ","));
+ GDK_NOTE (GC, (g_print ("%sfill=%d", s, win32_gc->fill_style),
+ s = ","));
}
if (mask & GDK_GC_TILE)
@@ -252,16 +207,16 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values,
{
gdk_drawable_ref (win32_gc->tile);
win32_gc->values_mask |= GDK_GC_TILE;
- GDK_NOTE (MISC,
- (g_print ("%stile=%#x", s,
- (guint) GDK_PIXMAP_HBITMAP (win32_gc->tile)),
+ GDK_NOTE (GC,
+ (g_print ("%stile=%p", s,
+ GDK_PIXMAP_HBITMAP (win32_gc->tile)),
s = ","));
}
else
{
win32_gc->values_mask &= ~GDK_GC_TILE;
- GDK_NOTE (MISC, (g_print ("%stile=NULL", s),
- s = ","));
+ GDK_NOTE (GC, (g_print ("%stile=NULL", s),
+ s = ","));
}
}
@@ -309,16 +264,16 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values,
#endif
gdk_drawable_ref (win32_gc->stipple);
win32_gc->values_mask |= GDK_GC_STIPPLE;
- GDK_NOTE (MISC,
- (g_print ("%sstipple=%#x", s,
- (guint) GDK_PIXMAP_HBITMAP (win32_gc->stipple)),
+ GDK_NOTE (GC,
+ (g_print ("%sstipple=%p", s,
+ GDK_PIXMAP_HBITMAP (win32_gc->stipple)),
s = ","));
}
else
{
win32_gc->values_mask &= ~GDK_GC_STIPPLE;
- GDK_NOTE (MISC, (g_print ("%sstipple=NULL", s),
- s = ","));
+ GDK_NOTE (GC, (g_print ("%sstipple=NULL", s),
+ s = ","));
}
}
@@ -339,7 +294,7 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values,
if (values->clip_mask != NULL)
{
win32_gc->hcliprgn =
- BitmapToRegion ((HBITMAP) GDK_PIXMAP_HBITMAP (values->clip_mask));
+ _gdk_win32_bitmap_to_region (values->clip_mask);
win32_gc->values_mask |= GDK_GC_CLIP_MASK;
}
else
@@ -347,82 +302,82 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values,
win32_gc->hcliprgn = NULL;
win32_gc->values_mask &= ~GDK_GC_CLIP_MASK;
}
- GDK_NOTE (MISC, (g_print ("%sclip=%#x", s, (guint) win32_gc->hcliprgn),
- s = ","));
+ GDK_NOTE (GC, (g_print ("%sclip=%p", s, win32_gc->hcliprgn),
+ s = ","));
}
if (mask & GDK_GC_SUBWINDOW)
{
win32_gc->subwindow_mode = values->subwindow_mode;
win32_gc->values_mask |= GDK_GC_SUBWINDOW;
- GDK_NOTE (MISC, (g_print ("%ssubw=%d", s, win32_gc->subwindow_mode),
- s = ","));
+ GDK_NOTE (GC, (g_print ("%ssubw=%d", s, win32_gc->subwindow_mode),
+ s = ","));
}
if (mask & GDK_GC_TS_X_ORIGIN)
{
win32_gc->values_mask |= GDK_GC_TS_X_ORIGIN;
- GDK_NOTE (MISC, (g_print ("%sts_x=%d", s, values->ts_x_origin),
- s = ","));
+ GDK_NOTE (GC, (g_print ("%sts_x=%d", s, values->ts_x_origin),
+ s = ","));
}
if (mask & GDK_GC_TS_Y_ORIGIN)
{
win32_gc->values_mask |= GDK_GC_TS_Y_ORIGIN;
- GDK_NOTE (MISC, (g_print ("%sts_y=%d", s, values->ts_y_origin),
- s = ","));
+ GDK_NOTE (GC, (g_print ("%sts_y=%d", s, values->ts_y_origin),
+ s = ","));
}
if (mask & GDK_GC_CLIP_X_ORIGIN)
{
win32_gc->values_mask |= GDK_GC_CLIP_X_ORIGIN;
- GDK_NOTE (MISC, (g_print ("%sclip_x=%d", s, values->clip_x_origin),
- s = ","));
+ GDK_NOTE (GC, (g_print ("%sclip_x=%d", s, values->clip_x_origin),
+ s = ","));
}
if (mask & GDK_GC_CLIP_Y_ORIGIN)
{
win32_gc->values_mask |= GDK_GC_CLIP_Y_ORIGIN;
- GDK_NOTE (MISC, (g_print ("%sclip_y=%d", s, values->clip_y_origin),
- s = ","));
+ GDK_NOTE (GC, (g_print ("%sclip_y=%d", s, values->clip_y_origin),
+ s = ","));
}
if (mask & GDK_GC_EXPOSURES)
{
win32_gc->graphics_exposures = values->graphics_exposures;
win32_gc->values_mask |= GDK_GC_EXPOSURES;
- GDK_NOTE (MISC, (g_print ("%sexp=%d", s, win32_gc->graphics_exposures),
- s = ","));
+ GDK_NOTE (GC, (g_print ("%sexp=%d", s, win32_gc->graphics_exposures),
+ s = ","));
}
if (mask & GDK_GC_LINE_WIDTH)
{
win32_gc->pen_width = values->line_width;
win32_gc->values_mask |= GDK_GC_LINE_WIDTH;
- GDK_NOTE (MISC, (g_print ("%spw=%d", s, win32_gc->pen_width),
- s = ","));
+ GDK_NOTE (GC, (g_print ("%spw=%d", s, win32_gc->pen_width),
+ s = ","));
}
if (mask & GDK_GC_LINE_STYLE)
{
- GDK_NOTE (MISC, (g_print ("%sps|=", s),
- s = ","));
switch (values->line_style)
{
case GDK_LINE_SOLID:
win32_gc->pen_style &= ~(PS_STYLE_MASK);
- GDK_NOTE (MISC, g_print ("LINE_SOLID"));
+ GDK_NOTE (GC, (g_print ("%sps|=LINE_SOLID", s),
+ s = ","));
win32_gc->pen_style |= PS_SOLID;
break;
case GDK_LINE_ON_OFF_DASH:
case GDK_LINE_DOUBLE_DASH: /* ??? */
- /* only set the linestyle here, if it isn't already set
+ /* Only set the linestyle here, if it isn't already set
* gdk_win32_gc_set_dashes () knows better
*/
if (0 == (win32_gc->values_mask & GDK_GC_LINE_STYLE))
{
win32_gc->pen_style &= ~(PS_STYLE_MASK);
- GDK_NOTE (MISC, g_print ("DASH"));
+ GDK_NOTE (GC, (g_print ("%sps|=DASH", s),
+ s = ","));
win32_gc->pen_style |= PS_DASH;
}
break;
@@ -433,21 +388,22 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values,
if (mask & GDK_GC_CAP_STYLE)
{
win32_gc->pen_style &= ~(PS_ENDCAP_MASK);
- GDK_NOTE (MISC, (g_print ("%sps|=", s),
- s = ","));
switch (values->cap_style)
{
case GDK_CAP_NOT_LAST: /* ??? */
case GDK_CAP_BUTT:
- GDK_NOTE (MISC, g_print ("ENDCAP_FLAT"));
+ GDK_NOTE (GC, (g_print ("%sps|=ENDCAP_FLAT", s),
+ s = ","));
win32_gc->pen_style |= PS_ENDCAP_FLAT;
break;
case GDK_CAP_ROUND:
- GDK_NOTE (MISC, g_print ("ENDCAP_ROUND"));
+ GDK_NOTE (GC, (g_print ("%sps|=ENDCAP_ROUND", s),
+ s = ","));
win32_gc->pen_style |= PS_ENDCAP_ROUND;
break;
case GDK_CAP_PROJECTING:
- GDK_NOTE (MISC, g_print ("ENDCAP_SQUARE"));
+ GDK_NOTE (GC, (g_print ("%sps|=ENDCAP_SQUARE", s),
+ s = ","));
win32_gc->pen_style |= PS_ENDCAP_SQUARE;
break;
}
@@ -457,26 +413,27 @@ gdk_win32_gc_values_to_win32values (GdkGCValues *values,
if (mask & GDK_GC_JOIN_STYLE)
{
win32_gc->pen_style &= ~(PS_JOIN_MASK);
- GDK_NOTE (MISC, (g_print ("%sps|=", s),
- s = ","));
switch (values->join_style)
{
case GDK_JOIN_MITER:
- GDK_NOTE (MISC, g_print ("JOIN_MITER"));
+ GDK_NOTE (GC, (g_print ("%sps|=JOIN_MITER", s),
+ s = ","));
win32_gc->pen_style |= PS_JOIN_MITER;
break;
case GDK_JOIN_ROUND:
- GDK_NOTE (MISC, g_print ("JOIN_ROUND"));
+ GDK_NOTE (GC, (g_print ("%sps|=JOIN_ROUND", s),
+ s = ","));
win32_gc->pen_style |= PS_JOIN_ROUND;
break;
case GDK_JOIN_BEVEL:
- GDK_NOTE (MISC, g_print ("JOIN_BEVEL"));
+ GDK_NOTE (GC, (g_print ("%sps|=JOIN_BEVEL", s),
+ s = ","));
win32_gc->pen_style |= PS_JOIN_BEVEL;
break;
}
win32_gc->values_mask |= GDK_GC_JOIN_STYLE;
}
- GDK_NOTE (MISC, g_print ("}\n"));
+ GDK_NOTE (GC, g_print ("}\n"));
}
GdkGC*
@@ -514,12 +471,12 @@ _gdk_win32_gc_new (GdkDrawable *drawable,
win32_gc->values_mask = GDK_GC_FUNCTION | GDK_GC_FILL;
- GDK_NOTE (MISC, g_print ("_gdk_win32_gc_new: "));
+ GDK_NOTE (GC, g_print ("_gdk_win32_gc_new: "));
gdk_win32_gc_values_to_win32values (values, mask, win32_gc);
win32_gc->hwnd = NULL;
- GDK_NOTE (MISC, g_print (" = %p\n", gc));
+ GDK_NOTE (GC, g_print (" = %p\n", gc));
return gc;
}
@@ -617,7 +574,7 @@ gdk_win32_gc_set_values (GdkGC *gc,
{
g_return_if_fail (GDK_IS_GC (gc));
- GDK_NOTE (MISC, g_print ("gdk_win32_gc_set_values: "));
+ GDK_NOTE (GC, g_print ("gdk_win32_gc_set_values: "));
gdk_win32_gc_values_to_win32values (values, mask, GDK_GC_WIN32 (gc));
}
@@ -652,46 +609,48 @@ gdk_win32_gc_set_dashes (GdkGC *gc,
*/
if (!IS_WIN_NT () && win32_gc->pen_width > 1)
{
- GDK_NOTE (MISC, g_print ("gdk_win32_gc_set_dashes: not fully supported\n"));
+ GDK_NOTE (GC, g_print ("gdk_win32_gc_set_dashes: not fully supported\n"));
win32_gc->pen_style |= PS_SOLID;
return;
}
win32_gc->pen_style = PS_COSMETIC; /* ??? */
- if (2 == n)
+ switch (n)
{
+ case 2:
if ((dash_list[0] == dash_list[1]) && (dash_list[0] > 2))
{
win32_gc->pen_style |= PS_DASH;
- GDK_NOTE (MISC, g_print("gdk_win32_gc_set_dashes: PS_DASH (%d,%d)\n",
- dash_list[0], dash_list[1]));
+ GDK_NOTE (GC, g_print ("gdk_win32_gc_set_dashes: PS_DASH (%d,%d)\n",
+ dash_list[0], dash_list[1]));
}
else
{
win32_gc->pen_style |= PS_DOT;
- GDK_NOTE (MISC, g_print("gdk_win32_gc_set_dashes: PS_DOT (%d,%d)\n",
- dash_list[0], dash_list[1]));
+ GDK_NOTE (GC, g_print ("gdk_win32_gc_set_dashes: PS_DOT (%d,%d)\n",
+ dash_list[0], dash_list[1]));
}
- }
- else if (4 == n)
- {
+ break;
+
+ case 4:
win32_gc->pen_style |= PS_DASHDOT;
- GDK_NOTE (MISC, g_print("gdk_win32_gc_set_dashes: PS_DASHDOT (%d,%d,%d,%d)\n",
- dash_list[0], dash_list[1],
- dash_list[2], dash_list[3]));
- }
- else if (6 == n)
- {
+ GDK_NOTE (GC, g_print ("gdk_win32_gc_set_dashes: PS_DASHDOT (%d,%d,%d,%d)\n",
+ dash_list[0], dash_list[1],
+ dash_list[2], dash_list[3]));
+ break;
+
+ case 6:
win32_gc->pen_style |= PS_DASHDOTDOT;
- GDK_NOTE (MISC, g_print("gdk_win32_gc_set_dashes: PS_DASHDOTDOT (%d,%d,%d,%d,%d,%d)\n",
- dash_list[0], dash_list[1],
- dash_list[2], dash_list[3],
- dash_list[4], dash_list[5]));
- }
- else
- {
+ GDK_NOTE (GC, g_print ("gdk_win32_gc_set_dashes: PS_DASHDOTDOT (%d,%d,%d,%d,%d,%d)\n",
+ dash_list[0], dash_list[1],
+ dash_list[2], dash_list[3],
+ dash_list[4], dash_list[5]));
+ break;
+
+ default:
win32_gc->pen_style |= PS_DASH;
- GDK_NOTE (MISC, g_print("gdk_win32_gc_set_dashes: no guess for %d dashes\n", n));
+ GDK_NOTE (GC, g_print ("gdk_win32_gc_set_dashes: no guess for %d dashes\n", n));
+ break;
}
}
@@ -716,7 +675,7 @@ gdk_gc_set_clip_rectangle (GdkGC *gc,
if (rectangle)
{
- GDK_NOTE (MISC,
+ GDK_NOTE (GC,
g_print ("gdk_gc_set_clip_rectangle: %dx%d@+%d+%d\n",
rectangle->width, rectangle->height,
rectangle->x, rectangle->y));
@@ -725,7 +684,7 @@ gdk_gc_set_clip_rectangle (GdkGC *gc,
}
else
{
- GDK_NOTE (MISC, g_print ("gdk_gc_set_clip_rectangle: NULL\n"));
+ GDK_NOTE (GC, g_print ("gdk_gc_set_clip_rectangle: NULL\n"));
win32_gc->clip_region = NULL;
win32_gc->values_mask &= ~GDK_GC_CLIP_MASK;
@@ -748,7 +707,7 @@ gdk_gc_set_clip_region (GdkGC *gc,
if (region)
{
- GDK_NOTE (MISC, g_print ("gdk_gc_set_clip_region: %dx%d+%d+%d\n",
+ GDK_NOTE (GC, g_print ("gdk_gc_set_clip_region: %dx%d+%d+%d\n",
region->extents.x2 - region->extents.x1,
region->extents.y2 - region->extents.y1,
region->extents.x1, region->extents.y1));
@@ -758,7 +717,7 @@ gdk_gc_set_clip_region (GdkGC *gc,
}
else
{
- GDK_NOTE (MISC, g_print ("gdk_gc_set_clip_region: NULL\n"));
+ GDK_NOTE (GC, g_print ("gdk_gc_set_clip_region: NULL\n"));
win32_gc->clip_region = NULL;
win32_gc->values_mask &= ~GDK_GC_CLIP_MASK;
@@ -799,7 +758,7 @@ gdk_gc_copy (GdkGC *dst_gc,
if (dst_win32_gc->hcliprgn)
{
/* create a new region, to copy to */
- dst_win32_gc->hcliprgn = CreateRectRgn(0,0,1,1);
+ dst_win32_gc->hcliprgn = CreateRectRgn (0,0,1,1);
/* overwrite from source */
CombineRgn (dst_win32_gc->hcliprgn, src_win32_gc->hcliprgn,
NULL, RGN_COPY);
@@ -825,24 +784,33 @@ _gdk_win32_colormap_color (GdkColormap *colormap,
guchar r, g, b;
if (colormap == NULL)
- return PALETTEINDEX (pixel);
+ return DIBINDEX (pixel);
- colormap_private = GDK_COLORMAP_PRIVATE_DATA (colormap);
+ colormap_private = GDK_WIN32_COLORMAP_DATA (colormap);
- g_return_val_if_fail(colormap_private != NULL, RGB (0,0,0));
-
- if (colormap_private->xcolormap->rc_palette)
- return PALETTEINDEX (pixel);
+ g_assert (colormap_private != NULL);
visual = colormap->visual;
- r = (pixel & visual->red_mask) >> visual->red_shift;
- r = (r * 255) / bitmask[visual->red_prec];
- g = (pixel & visual->green_mask) >> visual->green_shift;
- g = (g * 255) / bitmask[visual->green_prec];
- b = (pixel & visual->blue_mask) >> visual->blue_shift;
- b = (b * 255) / bitmask[visual->blue_prec];
-
- return RGB (r, g, b);
+ switch (visual->type)
+ {
+ case GDK_VISUAL_GRAYSCALE:
+ case GDK_VISUAL_PSEUDO_COLOR:
+ case GDK_VISUAL_STATIC_COLOR:
+ return PALETTEINDEX (pixel);
+
+ case GDK_VISUAL_TRUE_COLOR:
+ r = (pixel & visual->red_mask) >> visual->red_shift;
+ r = (r * 255) / bitmask[visual->red_prec];
+ g = (pixel & visual->green_mask) >> visual->green_shift;
+ g = (g * 255) / bitmask[visual->green_prec];
+ b = (pixel & visual->blue_mask) >> visual->blue_shift;
+ b = (b * 255) / bitmask[visual->blue_prec];
+ return RGB (r, g, b);
+
+ default:
+ g_assert_not_reached ();
+ return 0;
+ }
}
static void
@@ -850,71 +818,35 @@ predraw_set_foreground (GdkGC *gc,
GdkColormap *colormap,
gboolean *ok)
{
- GdkGCWin32 *win32_gc = (GdkGCWin32 *) gc;
- GdkColormapPrivateWin32 *colormap_private;
COLORREF fg;
LOGBRUSH logbrush;
HPEN hpen;
HBRUSH hbr;
+ GdkGCWin32 *win32_gc = (GdkGCWin32 *) gc;
+ GdkColormapPrivateWin32 *colormap_private;
+ gint k;
- if (colormap == NULL)
+ if (colormap &&
+ (colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR ||
+ colormap->visual->type == GDK_VISUAL_STATIC_COLOR))
{
- /* A 1 bit deep bitmap */
- struct
- {
- WORD palVersion;
- WORD palNumEntries;
- PALETTEENTRY palPalEntry[2];
- } logpal;
- static HPALETTE hpal = NULL;
+ colormap_private = GDK_WIN32_COLORMAP_DATA (colormap);
- if (hpal == NULL)
- {
- /* Create a b&w palette */
- logpal.palVersion = 0x300;
- logpal.palNumEntries = 2;
- logpal.palPalEntry[0].peRed =
- logpal.palPalEntry[0].peGreen =
- logpal.palPalEntry[0].peBlue = 0x00;
- logpal.palPalEntry[0].peFlags = 0x00;
- logpal.palPalEntry[1].peRed =
- logpal.palPalEntry[1].peGreen =
- logpal.palPalEntry[1].peBlue = 0xFF;
- logpal.palPalEntry[1].peFlags = 0x00;
- if ((hpal = CreatePalette ((LOGPALETTE *) &logpal)) == NULL)
- WIN32_GDI_FAILED ("CreatePalette"), *ok = FALSE;
- }
- SelectPalette (win32_gc->hdc, hpal, FALSE);
- RealizePalette (win32_gc->hdc);
- fg = PALETTEINDEX (win32_gc->foreground);
- }
- else
- {
- colormap_private = GDK_COLORMAP_PRIVATE_DATA (colormap);
- /* maybe this should bail out with g_return_if_fail
- * (colormap_private != NULL) ?
- */
- if (colormap_private && colormap_private->xcolormap->rc_palette)
- {
- int k;
- if (SelectPalette (win32_gc->hdc, colormap_private->xcolormap->palette,
- FALSE) == NULL)
- WIN32_GDI_FAILED ("SelectPalette"), *ok = FALSE;
- if (TRUE || colormap_private->xcolormap->stale)
- {
- if ((k = RealizePalette (win32_gc->hdc)) == GDI_ERROR)
- WIN32_GDI_FAILED ("RealizePalette"), *ok = FALSE;
- colormap_private->xcolormap->stale = FALSE;
- }
-#if 0
- g_print ("Selected palette %#x for gc %#x, realized %d colors\n",
- colormap_private->xcolormap->palette, win32_gc->hdc, k);
-#endif
- }
+ g_assert (colormap_private != NULL);
+
+ if (!(win32_gc->holdpal = SelectPalette (win32_gc->hdc, colormap_private->hpal, FALSE)))
+ WIN32_GDI_FAILED ("SelectPalette"), *ok = FALSE;
+ else if ((k = RealizePalette (win32_gc->hdc)) == GDI_ERROR)
+ WIN32_GDI_FAILED ("RealizePalette"), *ok = FALSE;
+ else if (k > 0)
+ GDK_NOTE (COLORMAP, g_print ("predraw_set_foreground: realized %p: %d colors\n",
+ colormap_private->hpal, k));
}
fg = _gdk_win32_colormap_color (colormap, win32_gc->foreground);
+ GDK_NOTE (GC, g_print ("predraw_set_foreground: fg=%06lx\n", fg));
+
if (SetTextColor (win32_gc->hdc, fg) == CLR_INVALID)
WIN32_GDI_FAILED ("SetTextColor"), *ok = FALSE;
@@ -942,6 +874,7 @@ predraw_set_foreground (GdkGC *gc,
WIN32_GDI_FAILED ("SetBrushOrgEx"), *ok = FALSE;
break;
+
case GDK_SOLID:
default:
if (*ok && (hbr = CreateSolidBrush (fg)) == NULL)
@@ -953,8 +886,6 @@ predraw_set_foreground (GdkGC *gc,
HBRUSH old_hbr = SelectObject (win32_gc->hdc, hbr);
if (old_hbr == NULL)
WIN32_GDI_FAILED ("SelectObject"), *ok = FALSE;
- else if (!DeleteObject (old_hbr))
- WIN32_GDI_FAILED ("DeleteObject");
}
}
@@ -974,7 +905,7 @@ predraw_set_background (GdkGC *gc,
}
else
{
- if (0 == SetBkMode (win32_gc->hdc, TRANSPARENT))
+ if (!SetBkMode (win32_gc->hdc, TRANSPARENT))
WIN32_GDI_FAILED ("SetBkMode"), *ok = FALSE;
}
}
@@ -1025,9 +956,7 @@ gdk_win32_hdc_get (GdkDrawable *drawable,
if (ok && (usage & GDK_GC_FOREGROUND))
predraw_set_foreground (gc, impl->colormap, &ok);
- if (ok
- && (usage & GDK_GC_BACKGROUND)
- /* && (win32_gc->values_mask & GDK_GC_BACKGROUND) */)
+ if (ok && (usage & GDK_GC_BACKGROUND))
predraw_set_background (gc, impl->colormap, &ok);
if (ok && (usage & GDK_GC_FONT))
@@ -1078,11 +1007,11 @@ gdk_win32_hdc_get (GdkDrawable *drawable,
rect->bottom = CLAMP (boxes[i].y2 + gc->clip_y_origin,
G_MINSHORT, G_MAXSHORT);
- GDK_NOTE (MISC, g_print ("clip rgn box %d: %ldx%ld@+%ld+%ld\n",
- i,
- rect->right-rect->left,
- rect->bottom-rect->top,
- rect->left, rect->top));
+ GDK_NOTE (GC, g_print ("clip rgn box %d: %ldx%ld@+%ld+%ld\n",
+ i,
+ rect->right-rect->left,
+ rect->bottom-rect->top,
+ rect->left, rect->top));
if (rect->left < rgndata->rdh.rcBound.left)
rgndata->rdh.rcBound.left = rect->left;
@@ -1104,7 +1033,7 @@ gdk_win32_hdc_get (GdkDrawable *drawable,
if ( (win32_gc->values_mask & GDK_GC_STIPPLE)
&& (win32_gc->values_mask & GDK_GC_FILL) && (win32_gc->fill_style == GDK_STIPPLED))
{
- HRGN hstipplergn = BitmapToRegion ((HBITMAP) GDK_PIXMAP_HBITMAP (win32_gc->stipple));
+ HRGN hstipplergn = _gdk_win32_bitmap_to_region (win32_gc->stipple);
if (OffsetRgn (hstipplergn,
win32_gc->values_mask & GDK_GC_TS_X_ORIGIN ? gc->ts_x_origin : 0,
@@ -1132,8 +1061,8 @@ gdk_win32_hdc_get (GdkDrawable *drawable,
win32_gc->values_mask & GDK_GC_CLIP_Y_ORIGIN ? gc->clip_y_origin : 0))
WIN32_API_FAILED ("OffsetClipRgn"), ok = FALSE;
}
-
- if (_gdk_debug_flags & GDK_DEBUG_MISC)
+#ifdef G_ENABLE_DEBUG
+ if (_gdk_debug_flags & GDK_DEBUG_GC)
{
HGDIOBJ obj;
LOGBRUSH logbrush;
@@ -1141,10 +1070,10 @@ gdk_win32_hdc_get (GdkDrawable *drawable,
HRGN hrgn;
RECT rect;
- g_print ("gdk_win32_hdc_get: %#x\n", (guint) win32_gc->hdc);
+ g_print ("gdk_win32_hdc_get: %p\n", win32_gc->hdc);
obj = GetCurrentObject (win32_gc->hdc, OBJ_BRUSH);
GetObject (obj, sizeof (LOGBRUSH), &logbrush);
- g_print ("brush: style: %s color: %.06lx hatch: %#lx\n",
+ g_print ("brush: style: %s color: %06lx hatch: %#lx\n",
(logbrush.lbStyle == BS_HOLLOW ? "HOLLOW" :
(logbrush.lbStyle == BS_PATTERN ? "PATTERN" :
(logbrush.lbStyle == BS_SOLID ? "SOLID" :
@@ -1196,8 +1125,9 @@ gdk_win32_hdc_get (GdkDrawable *drawable,
rect.bottom - rect.top,
rect.left, rect.top);
}
+ DeleteObject (hrgn);
}
-
+#endif
return win32_gc->hdc;
}
@@ -1211,6 +1141,8 @@ gdk_win32_hdc_release (GdkDrawable *drawable,
HGDIOBJ hpen = NULL;
HGDIOBJ hbr = NULL;
+ GDK_NOTE (GC, g_print ("gdk_win32_hdc_release: %p\n", win32_gc->hdc));
+
if (GDK_IS_DRAWABLE_IMPL_WIN32 (drawable))
impl = GDK_DRAWABLE_IMPL_WIN32(drawable);
else if (GDK_IS_WINDOW (drawable))
@@ -1220,6 +1152,20 @@ gdk_win32_hdc_release (GdkDrawable *drawable,
else
g_assert_not_reached ();
+ if (win32_gc->holdpal != NULL)
+ {
+ gint k;
+
+ if (!SelectPalette (win32_gc->hdc, win32_gc->holdpal, FALSE))
+ WIN32_GDI_FAILED ("SelectPalette");
+ else if ((k = RealizePalette (win32_gc->hdc)) == GDI_ERROR)
+ WIN32_GDI_FAILED ("RealizePalette");
+ else if (k > 0)
+ GDK_NOTE (COLORMAP, g_print ("gdk_win32_hdc_release: realized %p: %d colors\n",
+ win32_gc->holdpal, k));
+ win32_gc->holdpal = NULL;
+ }
+
if (usage & GDK_GC_FOREGROUND)
{
if ((hpen = GetCurrentObject (win32_gc->hdc, OBJ_PEN)) == NULL)
@@ -1231,16 +1177,7 @@ gdk_win32_hdc_release (GdkDrawable *drawable,
if (!RestoreDC (win32_gc->hdc, win32_gc->saved_dc))
WIN32_GDI_FAILED ("RestoreDC");
-#if 0
- if (colormap_private != NULL
- && colormap_private->xcolormap->rc_palette
- && colormap_private->xcolormap->stale)
- {
- SelectPalette (win32_gc->hdc, GetStockObject (DEFAULT_PALETTE), FALSE);
- if (!UnrealizeObject (colormap_private->xcolormap->palette))
- WIN32_GDI_FAILED ("UnrealizeObject");
- }
-#endif
+
if (GDK_IS_PIXMAP_IMPL_WIN32 (impl))
{
if (!DeleteDC (win32_gc->hdc))
@@ -1264,165 +1201,29 @@ gdk_win32_hdc_release (GdkDrawable *drawable,
}
/* This function originally from Jean-Edouard Lachand-Robert, and
- * available at www.codeguru.com. Simplified for our needs, now
- * handles just one-bit deep bitmaps (in Window parlance, ie those
- * that GDK calls bitmaps (and not pixmaps), with zero pixels being
- * transparent.
+ * available at www.codeguru.com. Simplified for our needs, not sure
+ * how much of the original code left any longer. Now handles just
+ * one-bit deep bitmaps (in Window parlance, ie those that GDK calls
+ * bitmaps (and not pixmaps), with zero pixels being transparent.
*/
-/*
- * BitmapToRegion : Create a region from the "non-transparent" pixels of
- * a bitmap
- * Author : Jean-Edouard Lachand-Robert
- * (http://www.geocities.com/Paris/LeftBank/1160/resume.htm), June 1998.
+/* _gdk_win32_bitmap_to_region : Create a region from the
+ * "non-transparent" pixels of a bitmap.
*/
HRGN
-BitmapToRegion (HBITMAP hBmp)
+_gdk_win32_bitmap_to_region (GdkPixmap *pixmap)
{
HRGN hRgn = NULL;
- HDC hMemDC;
- BITMAP bm;
-
- struct
- {
- BITMAPINFOHEADER bmiHeader;
-#if 1
- WORD bmiColors[2];
-#else
- RGBQUAD bmiColors[2];
-#endif
- } bmi;
- VOID *pbits8;
- HBITMAP hbm8;
- struct
- {
- WORD palVersion;
- WORD palNumEntries;
- PALETTEENTRY palPalEntry[2];
- } logpal;
- static HPALETTE bwPalette = NULL;
-
- HBITMAP holdBmp;
- HDC hDC;
-
- BITMAP bm8;
- HBITMAP holdBmp2;
+ HRGN h;
DWORD maxRects;
RGNDATA *pData;
- BYTE *p8;
- int x, y;
- HRGN h;
-
- /* Create a B&W palette */
- if (bwPalette == NULL)
- {
- /* Create a b&w palette */
- logpal.palVersion = 0x300;
- logpal.palNumEntries = 2;
- logpal.palPalEntry[0].peRed =
- logpal.palPalEntry[0].peGreen =
- logpal.palPalEntry[0].peBlue = 0;
- logpal.palPalEntry[0].peFlags = 0;
- logpal.palPalEntry[1].peRed =
- logpal.palPalEntry[1].peGreen =
- logpal.palPalEntry[1].peBlue = 0xFF;
- logpal.palPalEntry[1].peFlags = 0;
- if ((bwPalette = CreatePalette ((LOGPALETTE *) &logpal)) == NULL)
- WIN32_GDI_FAILED ("CreatePalette");
- }
+ GdkImage *image;
+ guchar *p;
+ gint x, y;
- /* Create a memory DC inside which we will scan the bitmap content */
- hMemDC = CreateCompatibleDC (NULL);
- if (!hMemDC)
- {
- WIN32_GDI_FAILED ("CreateCompatibleDC");
- return NULL;
- }
-
- SelectPalette (hMemDC, bwPalette, FALSE);
- RealizePalette (hMemDC);
-
- /* Get bitmap size */
- GetObject(hBmp, sizeof(bm), &bm);
-
- /* Create a 8 bits depth bitmap and select it into the memory DC */
- bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = bm.bmWidth;
- bmi.bmiHeader.biHeight = bm.bmHeight;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = 8;
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biSizeImage = 0;
- bmi.bmiHeader.biXPelsPerMeter = 0;
- bmi.bmiHeader.biYPelsPerMeter = 0;
- bmi.bmiHeader.biClrUsed = 2;
- bmi.bmiHeader.biClrImportant = 2;
-#if 1
- bmi.bmiColors[0] = 0;
- bmi.bmiColors[1] = 1;
- hbm8 = CreateDIBSection (hMemDC, (BITMAPINFO *)&bmi,
- DIB_PAL_COLORS, &pbits8, NULL, 0);
-#else
- bmi.bmiColors[0].rgbBlue =
- bmi.bmiColors[0].rgbGreen =
- bmi.bmiColors[0].rgbRed = 0x00;
- bmi.bmiColors[0].rgbReserved = 0x00;
-
- bmi.bmiColors[1].rgbBlue =
- bmi.bmiColors[1].rgbGreen =
- bmi.bmiColors[1].rgbRed = 0xFF;
- bmi.bmiColors[0].rgbReserved = 0x00;
-
- hbm8 = CreateDIBSection (hMemDC, (BITMAPINFO *)&bmi,
- DIB_RGB_COLORS, &pbits8, NULL, 0);
-#endif
- if (!hbm8)
- {
- WIN32_GDI_FAILED ("CreateDIBSection");
- DeleteDC (hMemDC);
- return NULL;
- }
-
- holdBmp = (HBITMAP) SelectObject (hMemDC, hbm8);
-
- /* Create a DC just to copy the bitmap into the memory DC*/
- hDC = CreateCompatibleDC (hMemDC);
- if (!hDC)
- {
- WIN32_GDI_FAILED ("CreateCompatibleDC");
- SelectObject (hMemDC, holdBmp);
- DeleteObject (hbm8);
- DeleteDC (hMemDC);
- return NULL;
- }
-
- /* Get how many bytes per row we have for the bitmap bits */
- GetObject (hbm8, sizeof (bm8), &bm8);
-
- /* Hans Breuer found a fix to the long-standing erroneous behaviour
- * on NT 4.0: There seems to be a bug in Win NT 4.0 GDI: scanlines
- * in bitmaps are dword aligned on both Win95 and NT. In the case of
- * a bitmap with 22 bytes worth of width, GetObject above returns
- * with bmWidth == 22. On Win95 bmWidthBytes == 24, as it should be,
- * but on NT is it 22. We need to correct this here.
- */
- bm8.bmWidthBytes = (((bm8.bmWidthBytes-1)/4)+1)*4; /* dword aligned!! */
-
- /* Copy the bitmap into the memory DC*/
- holdBmp2 = (HBITMAP) SelectObject (hDC, hBmp);
-
- if (!BitBlt (hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, hDC, 0, 0, SRCCOPY))
- {
- WIN32_GDI_FAILED ("BitBlt");
- SelectObject (hDC, holdBmp2);
- SelectObject (hMemDC, holdBmp);
- DeleteObject (hbm8);
- DeleteDC (hMemDC);
- return NULL;
- }
- SelectObject (hDC, holdBmp2);
- DeleteDC (hDC);
+ image = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->image;
+ g_assert (image->depth == 1);
/* For better performances, we will use the ExtCreateRegion()
* function to create the region. This function take a RGNDATA
@@ -1438,22 +1239,19 @@ BitmapToRegion (HBITMAP hBmp)
pData->rdh.nCount = pData->rdh.nRgnSize = 0;
SetRect (&pData->rdh.rcBound, MAXLONG, MAXLONG, 0, 0);
- /* Scan each bitmap from bottom to top (the bitmap is inverted vertically)*/
- p8 = (BYTE *) pbits8 + (bm8.bmHeight - 1) * bm8.bmWidthBytes;
- for (y = 0; y < bm.bmHeight; y++)
+ for (y = 0; y < image->height; y++)
{
/* Scan each bitmap row from left to right*/
- for (x = 0; x < bm.bmWidth; x++)
+ p = (guchar *) image->mem + y * image->bpl;
+ for (x = 0; x < image->width; x++)
{
/* Search for a continuous range of "non transparent pixels"*/
- int x0 = x;
- BYTE *p = p8 + x;
- while (x < bm.bmWidth)
+ gint x0 = x;
+ while (x < image->width)
{
- if (*p == 0)
+ if ((((p[x/8])>>(7-(x%8)))&1) == 0)
/* This pixel is "transparent"*/
break;
- p++;
x++;
}
@@ -1501,9 +1299,6 @@ BitmapToRegion (HBITMAP hBmp)
}
}
}
-
- /* Go to next row (remember, the bitmap is inverted vertically)*/
- p8 -= bm8.bmWidthBytes;
}
/* Create or extend the region with the remaining rectangles*/
@@ -1519,9 +1314,6 @@ BitmapToRegion (HBITMAP hBmp)
/* Clean up*/
g_free (pData);
- SelectObject(hMemDC, holdBmp);
- DeleteObject (hbm8);
- DeleteDC (hMemDC);
return hRgn;
}
diff --git a/gdk/win32/gdkglobals-win32.c b/gdk/win32/gdkglobals-win32.c
index 6a6a248d0f..6e86176251 100644
--- a/gdk/win32/gdkglobals-win32.c
+++ b/gdk/win32/gdkglobals-win32.c
@@ -1,5 +1,6 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * Copyright (C) 1998-2002 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -45,7 +46,8 @@ GdkAtom gdk_ole2_dnd;
GdkAtom _gdk_selection_property;
-DWORD windows_version = 0;
+DWORD windows_version;
gint gdk_input_ignore_wintab = FALSE;
gint gdk_event_func_from_window_proc = FALSE;
+gint gdk_max_colors = 0;
diff --git a/gdk/win32/gdkim-win32.c b/gdk/win32/gdkim-win32.c
index 40019a2d32..b31b1b5dd3 100644
--- a/gdk/win32/gdkim-win32.c
+++ b/gdk/win32/gdkim-win32.c
@@ -1,5 +1,6 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * Copyright (C) 1998-2002 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/gdk/win32/gdkimage-win32.c b/gdk/win32/gdkimage-win32.c
index 8d2bf900a7..c6d3075223 100644
--- a/gdk/win32/gdkimage-win32.c
+++ b/gdk/win32/gdkimage-win32.c
@@ -1,5 +1,6 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * Copyright (C) 1998-2002 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -67,7 +68,7 @@ gdk_image_get_type (void)
static void
gdk_image_init (GdkImage *image)
{
- image->windowing_data = g_new0 (GdkImagePrivateWin32, 1);
+ image->windowing_data = NULL;
}
static void
@@ -103,202 +104,30 @@ _gdk_image_exit (void)
}
GdkImage *
-gdk_image_new_bitmap (GdkVisual *visual,
- gpointer data,
- gint w,
- gint h)
-/*
- * Desc: create a new bitmap image
- */
+_gdk_win32_setup_pixmap_image (GdkPixmap *pixmap,
+ GdkWindow *window,
+ gint width,
+ gint height,
+ gint depth,
+ guchar *bits)
{
- Visual *xvisual;
GdkImage *image;
- GdkImagePrivateWin32 *private;
- struct {
- BITMAPINFOHEADER bmiHeader;
- union {
- WORD bmiIndices[2];
- RGBQUAD bmiColors[2];
- } u;
- } bmi;
- char *bits;
- int bpl = (w-1)/8 + 1;
- int bpl32 = ((w-1)/32 + 1)*4;
image = g_object_new (gdk_image_get_type (), NULL);
- private = IMAGE_PRIVATE_DATA (image);
-
+ image->windowing_data = pixmap;
image->type = GDK_IMAGE_SHARED;
- image->visual = visual;
- image->width = w;
- image->height = h;
- image->depth = 1;
- xvisual = ((GdkVisualPrivate*) visual)->xvisual;
-
- GDK_NOTE (MISC, g_print ("gdk_image_new_bitmap: %dx%d\n", w, h));
-
- bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = w;
- bmi.bmiHeader.biHeight = -h;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = 1;
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biSizeImage = 0;
- bmi.bmiHeader.biXPelsPerMeter =
- bmi.bmiHeader.biYPelsPerMeter = 0;
- bmi.bmiHeader.biClrUsed = 0;
- bmi.bmiHeader.biClrImportant = 0;
-
- bmi.u.bmiColors[0].rgbBlue =
- bmi.u.bmiColors[0].rgbGreen =
- bmi.u.bmiColors[0].rgbRed = 0x00;
- bmi.u.bmiColors[0].rgbReserved = 0x00;
-
- bmi.u.bmiColors[1].rgbBlue =
- bmi.u.bmiColors[1].rgbGreen =
- bmi.u.bmiColors[1].rgbRed = 0xFF;
- bmi.u.bmiColors[1].rgbReserved = 0x00;
-
- private->hbitmap = CreateDIBSection (gdk_display_hdc, (BITMAPINFO *) &bmi,
- DIB_RGB_COLORS, &bits, NULL, 0);
- if (bpl != bpl32)
- {
- /* Win32 expects scanlines in DIBs to be 32 bit aligned */
- int i;
- for (i = 0; i < h; i++)
- memmove (bits + i*bpl32, ((char *) data) + i*bpl, bpl);
- }
- else
- memmove (bits, data, bpl*h);
- image->mem = bits;
- image->bpl = bpl32;
- image->byte_order = GDK_MSB_FIRST;
-
- image->bits_per_pixel = 1;
- image->bpp = 1;
-
- /* free data right now, in contrast to the X11 version we have made
- * our own copy. Use free, it was malloc()ed.
- */
- free (data);
- return(image);
-} /* gdk_image_new_bitmap() */
-
-void
-_gdk_windowing_image_init (void)
-{
- /* Nothing needed AFAIK */
-}
-
-GdkImage*
-_gdk_image_new_for_depth (GdkImageType type,
- GdkVisual *visual,
- gint width,
- gint height,
- gint depth)
-{
- GdkImage *image;
- GdkImagePrivateWin32 *private;
- Visual *xvisual = NULL;
- struct {
- BITMAPINFOHEADER bmiHeader;
- union {
- WORD bmiIndices[256];
- DWORD bmiMasks[3];
- RGBQUAD bmiColors[256];
- } u;
- } bmi;
- UINT iUsage;
- int i;
-
- g_return_val_if_fail (!visual || GDK_IS_VISUAL (visual), NULL);
- g_return_val_if_fail (visual || depth != -1, NULL);
-
- if (visual)
- depth = visual->depth;
-
- if (type == GDK_IMAGE_FASTEST || type == GDK_IMAGE_NORMAL)
- type = GDK_IMAGE_SHARED;
-
- GDK_NOTE (MISC, g_print ("gdk_image_new: %dx%d %s\n",
- width, height,
- (type == GDK_IMAGE_SHARED ? "shared" :
- "???")));
-
- image = g_object_new (gdk_image_get_type (), NULL);
- private = IMAGE_PRIVATE_DATA (image);
-
- image->type = type;
- image->visual = visual;
+ image->visual = gdk_drawable_get_visual (window);
+ image->byte_order = GDK_LSB_FIRST;
image->width = width;
image->height = height;
image->depth = depth;
-
- if (visual)
- xvisual = ((GdkVisualPrivate*) visual)->xvisual;
-
- bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = width;
- bmi.bmiHeader.biHeight = -height;
- bmi.bmiHeader.biPlanes = 1;
- if (image->depth == 15)
- bmi.bmiHeader.biBitCount = 16;
- else
- bmi.bmiHeader.biBitCount = image->depth;
- if (image->depth == 16)
- bmi.bmiHeader.biCompression = BI_BITFIELDS;
- else
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biSizeImage = 0;
- bmi.bmiHeader.biXPelsPerMeter =
- bmi.bmiHeader.biYPelsPerMeter = 0;
- bmi.bmiHeader.biClrUsed = 0;
- bmi.bmiHeader.biClrImportant = 0;
-
- if ( (image->visual && image->visual->type == GDK_VISUAL_PSEUDO_COLOR)
- || (8 == image->depth))
- {
- iUsage = DIB_PAL_COLORS;
- for (i = 0; i < 256; i++)
- bmi.u.bmiIndices[i] = i;
- }
- else
- {
- iUsage = DIB_RGB_COLORS;
- if (image->depth == 1)
- {
- bmi.u.bmiColors[0].rgbBlue =
- bmi.u.bmiColors[0].rgbGreen =
- bmi.u.bmiColors[0].rgbRed = 0x00;
- bmi.u.bmiColors[0].rgbReserved = 0x00;
-
- bmi.u.bmiColors[1].rgbBlue =
- bmi.u.bmiColors[1].rgbGreen =
- bmi.u.bmiColors[1].rgbRed = 0xFF;
- bmi.u.bmiColors[1].rgbReserved = 0x00;
-
- }
- else if (image->depth == 16)
- {
- bmi.u.bmiMasks[0] = visual ? visual->red_mask : 0x0000F800;
- bmi.u.bmiMasks[1] = visual ? visual->green_mask : 0x000007E0;
- bmi.u.bmiMasks[2] = visual ? visual->blue_mask : 0x0000001F;
- }
- }
-
- private->hbitmap = CreateDIBSection (gdk_display_hdc, (BITMAPINFO *) &bmi,
- iUsage, &image->mem, NULL, 0);
-
- if (private->hbitmap == NULL)
- {
- WIN32_GDI_FAILED ("CreateDIBSection");
- g_free (image);
- return NULL;
- }
-
- switch (image->depth)
+ switch (depth)
{
case 1:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
case 8:
image->bpp = 1;
break;
@@ -313,273 +142,92 @@ _gdk_image_new_for_depth (GdkImageType type,
image->bpp = 4;
break;
default:
- g_warning ("gdk_image_new: depth = %d", image->depth);
+ g_warning ("_gdk_win32_setup_pixmap_image: depth=%d", image->depth);
g_assert_not_reached ();
}
- image->bits_per_pixel = image->depth;
- image->byte_order = GDK_LSB_FIRST;
- if (image->depth == 1)
- image->bpl = ((width-1)/32 + 1)*4;
+ if (depth == 1)
+ image->bpl = ((width - 1)/32 + 1)*4;
+ else if (depth == 4)
+ image->bpl = ((width - 1)/8 + 1)*4;
else
image->bpl = ((width*image->bpp - 1)/4 + 1)*4;
-
- GDK_NOTE (MISC, g_print ("... = %#x mem = %p, bpl = %d\n",
- (guint) private->hbitmap, image->mem, image->bpl));
+ image->bits_per_pixel = image->depth;
+ image->mem = bits;
return image;
}
-GdkImage*
-gdk_image_new (GdkImageType type,
- GdkVisual *visual,
- gint width,
- gint height)
-{
- return _gdk_image_new_for_depth (type, visual, width, height, -1);
-}
-
-
-GdkImage*
-_gdk_win32_get_image (GdkDrawable *drawable,
- gint x,
- gint y,
- gint width,
- gint height)
+GdkImage *
+gdk_image_new_bitmap (GdkVisual *visual,
+ gpointer data,
+ gint w,
+ gint h)
{
+ GdkPixmap *pixmap;
GdkImage *image;
- GdkImagePrivateWin32 *private;
- GdkDrawableImplWin32 *impl;
- HDC hdc, memdc;
- struct {
- BITMAPINFOHEADER bmiHeader;
- union {
- WORD bmiIndices[256];
- DWORD bmiMasks[3];
- RGBQUAD bmiColors[256];
- } u;
- } bmi;
- HGDIOBJ oldbitmap1 = NULL, oldbitmap2;
- UINT iUsage;
- BITMAP bm;
- int i;
-
- g_return_val_if_fail (GDK_IS_DRAWABLE_IMPL_WIN32 (drawable), NULL);
-
- GDK_NOTE (MISC, g_print ("_gdk_win32_get_image: %#x %dx%d@+%d+%d\n",
- (guint) GDK_DRAWABLE_IMPL_WIN32 (drawable)->handle,
- width, height, x, y));
+ gint data_bpl = (w-1)/8 + 1;
+ gint i;
- impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
+ pixmap = gdk_pixmap_new (NULL, w, h, 1);
- image = g_object_new (gdk_image_get_type (), NULL);
- private = IMAGE_PRIVATE_DATA (image);
-
- image->type = GDK_IMAGE_SHARED;
- image->visual = gdk_drawable_get_visual (drawable);
- image->width = width;
- image->height = height;
-
- /* This function is called both to blit from a window and from
- * a pixmap.
- */
- if (GDK_IS_PIXMAP_IMPL_WIN32 (drawable))
- {
- if ((hdc = CreateCompatibleDC (NULL)) == NULL)
- {
- WIN32_GDI_FAILED ("CreateCompatibleDC");
- g_free (image);
- return NULL;
- }
- if ((oldbitmap1 = SelectObject (hdc, impl->handle)) == NULL)
- {
- WIN32_GDI_FAILED ("SelectObject");
- DeleteDC (hdc);
- g_free (image);
- return NULL;
- }
- GetObject (impl->handle, sizeof (BITMAP), &bm);
- GDK_NOTE (MISC,
- g_print ("gdk_image_get: bmWidth:%ld bmHeight:%ld bmWidthBytes:%ld bmBitsPixel:%d\n",
- bm.bmWidth, bm.bmHeight, bm.bmWidthBytes, bm.bmBitsPixel));
- image->depth = bm.bmBitsPixel;
- if (image->depth <= 8)
- {
- iUsage = DIB_PAL_COLORS;
- for (i = 0; i < 256; i++)
- bmi.u.bmiIndices[i] = i;
- }
- else
- iUsage = DIB_RGB_COLORS;
- }
- else
- {
- if ((hdc = GetDC (impl->handle)) == NULL)
- {
- WIN32_GDI_FAILED ("GetDC");
- g_free (image);
- return NULL;
- }
- image->depth = gdk_visual_get_system ()->depth;
- if (image->visual && image->visual->type == GDK_VISUAL_PSEUDO_COLOR)
- {
- iUsage = DIB_PAL_COLORS;
- for (i = 0; i < 256; i++)
- bmi.u.bmiIndices[i] = i;
- }
- else
- iUsage = DIB_RGB_COLORS;
- }
+ if (pixmap == NULL)
+ return NULL;
- if ((memdc = CreateCompatibleDC (hdc)) == NULL)
- {
- WIN32_GDI_FAILED ("CreateCompatibleDC");
- if (GDK_IS_PIXMAP_IMPL_WIN32 (drawable))
- {
- SelectObject (hdc, oldbitmap1);
- if (!DeleteDC (hdc))
- WIN32_GDI_FAILED ("DeleteDC");
- }
- else
- {
- if (!ReleaseDC (impl->handle, hdc))
- WIN32_GDI_FAILED ("ReleaseDC");
- }
- g_free (image);
- return NULL;
- }
+ image = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->image;
- bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = width;
- bmi.bmiHeader.biHeight = -height;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = image->depth;
- if (image->depth == 16)
+ GDK_NOTE (IMAGE, g_print ("gdk_image_new_bitmap: %dx%d=%p\n",
+ w, h, GDK_PIXMAP_HBITMAP (pixmap)));
+
+ if (data_bpl != image->bpl)
{
- bmi.bmiHeader.biCompression = BI_BITFIELDS;
- if (image->visual == NULL)
- {
- /* XXX ??? Is it always this if depth==16 and a pixmap? Guess so. */
- bmi.u.bmiMasks[0] = 0xf800;
- bmi.u.bmiMasks[1] = 0x07e0;
- bmi.u.bmiMasks[2] = 0x001f;
- }
- else
- {
- bmi.u.bmiMasks[0] = image->visual->red_mask;
- bmi.u.bmiMasks[1] = image->visual->green_mask;
- bmi.u.bmiMasks[2] = image->visual->blue_mask;
- }
+ for (i = 0; i < h; i++)
+ memmove ((guchar *) image->mem + i*image->bpl, ((guchar *) data) + i*data_bpl, data_bpl);
}
else
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biSizeImage = 0;
- bmi.bmiHeader.biXPelsPerMeter =
- bmi.bmiHeader.biYPelsPerMeter = 0;
- bmi.bmiHeader.biClrUsed = 0;
- bmi.bmiHeader.biClrImportant = 0;
-
- if ((private->hbitmap = CreateDIBSection (hdc, (BITMAPINFO *) &bmi, iUsage,
- &image->mem, NULL, 0)) == NULL)
- {
- WIN32_GDI_FAILED ("CreateDIBSection");
- DeleteDC (memdc);
- if (GDK_IS_PIXMAP (drawable))
- {
- SelectObject (hdc, oldbitmap1);
- DeleteDC (hdc);
- }
- else
- {
- ReleaseDC (impl->handle, hdc);
- }
- g_free (image);
- return NULL;
- }
+ memmove (image->mem, data, data_bpl*h);
- if ((oldbitmap2 = SelectObject (memdc, private->hbitmap)) == NULL)
- {
- WIN32_GDI_FAILED ("SelectObject");
- DeleteObject (private->hbitmap);
- DeleteDC (memdc);
- if (GDK_IS_PIXMAP (drawable))
- {
- SelectObject (hdc, oldbitmap1);
- DeleteDC (hdc);
- }
- else
- {
- ReleaseDC (impl->handle, hdc);
- }
- g_free (image);
- return NULL;
- }
+ return image;
+}
- if (!BitBlt (memdc, 0, 0, width, height, hdc, x, y, SRCCOPY))
- {
- WIN32_GDI_FAILED ("BitBlt");
- SelectObject (memdc, oldbitmap2);
- DeleteObject (private->hbitmap);
- DeleteDC (memdc);
- if (GDK_IS_PIXMAP (drawable))
- {
- SelectObject (hdc, oldbitmap1);
- DeleteDC (hdc);
- }
- else
- {
- ReleaseDC (impl->handle, hdc);
- }
- g_free (image);
- return NULL;
- }
+void
+_gdk_windowing_image_init (void)
+{
+ /* Nothing needed AFAIK */
+}
- if (SelectObject (memdc, oldbitmap2) == NULL)
- WIN32_GDI_FAILED ("SelectObject");
+GdkImage*
+_gdk_image_new_for_depth (GdkImageType type,
+ GdkVisual *visual,
+ gint width,
+ gint height,
+ gint depth)
+{
+ GdkPixmap *pixmap;
- if (!DeleteDC (memdc))
- WIN32_GDI_FAILED ("DeleteDC");
+ g_return_val_if_fail (!visual || GDK_IS_VISUAL (visual), NULL);
+ g_return_val_if_fail (visual || depth != -1, NULL);
+
+ if (visual)
+ depth = visual->depth;
- if (GDK_IS_PIXMAP_IMPL_WIN32 (drawable))
- {
- SelectObject (hdc, oldbitmap1);
- DeleteDC (hdc);
- }
- else
- {
- ReleaseDC (impl->handle, hdc);
- }
+ pixmap = gdk_pixmap_new (NULL, width, height, depth);
- switch (image->depth)
- {
- case 1:
- case 8:
- image->bpp = 1;
- break;
- case 15:
- case 16:
- image->bpp = 2;
- break;
- case 24:
- image->bpp = 3;
- break;
- case 32:
- image->bpp = 4;
- break;
- default:
- g_warning ("_gdk_win32_get_image: image->depth = %d", image->depth);
- g_assert_not_reached ();
- }
- image->bits_per_pixel = image->depth;
- image->byte_order = GDK_LSB_FIRST;
- if (image->depth == 1)
- image->bpl = ((width - 1)/32 + 1)*4;
- else
- image->bpl = ((width*image->bpp - 1)/4 + 1)*4;
+ if (pixmap == NULL)
+ return NULL;
- GDK_NOTE (MISC, g_print ("... = %#x mem = %p, bpl = %d\n",
- (guint) private->hbitmap, image->mem, image->bpl));
+ GDK_NOTE (IMAGE, g_print ("_gdk_image_new_for_depth: %dx%dx%d=%p\n",
+ width, height, depth, GDK_PIXMAP_HBITMAP (pixmap)));
+
+ return GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->image;
+}
- return image;
+GdkImage*
+gdk_image_new (GdkImageType type,
+ GdkVisual *visual,
+ gint width,
+ gint height)
+{
+ return _gdk_image_new_for_depth (type, visual, width, height, -1);
}
GdkImage*
@@ -592,73 +240,24 @@ _gdk_win32_copy_to_image (GdkDrawable *drawable,
gint width,
gint height)
{
- GdkImagePrivateWin32 *private;
- GdkDrawableImplWin32 *impl;
- GdkVisual *visual;
- GdkGC *gc = NULL;
- gboolean ok = TRUE, is_window_impl;
- HBITMAP holdbmp = NULL;
- HDC src_dc = NULL, dest_dc = NULL;
+ GdkGC *gc;
g_return_val_if_fail (GDK_IS_DRAWABLE_IMPL_WIN32 (drawable), NULL);
g_return_val_if_fail (image != NULL || (dest_x == 0 && dest_y == 0), NULL);
- visual = gdk_drawable_get_visual (drawable);
- impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
- is_window_impl = GDK_IS_WINDOW_IMPL_WIN32 (drawable);
-
- if (!image && !is_window_impl)
- return _gdk_win32_get_image (drawable, src_x, src_y, width, height);
+ GDK_NOTE (IMAGE, g_print ("_gdk_win32_copy_to_image: %p\n",
+ GDK_DRAWABLE_HANDLE (drawable)));
if (!image)
- image = _gdk_image_new_for_depth (GDK_IMAGE_FASTEST, visual, width, height, -1);
+ image = _gdk_image_new_for_depth (GDK_IMAGE_FASTEST, NULL, width, height,
+ gdk_drawable_get_depth (drawable));
- private = IMAGE_PRIVATE_DATA (image);
-
- if (is_window_impl)
- src_dc = GetDC (impl->handle);
- else
- {
- gc = gdk_gc_new (drawable);
- src_dc = gdk_win32_hdc_get (drawable, gc, 0);
- }
- ok = !!src_dc;
-
- if (ok)
- {
- dest_dc = CreateCompatibleDC (NULL);
- ok = !!dest_dc;
- }
-
- if (ok)
- {
- holdbmp = SelectObject (dest_dc, private->hbitmap);
- ok = !!holdbmp;
- }
-
- if (ok && !BitBlt (dest_dc, dest_x, dest_y, width, height,
- src_dc, src_x, src_y, SRCCOPY))
- WIN32_GDI_FAILED ("BitBlt");
-
- if (is_window_impl)
- {
- if (src_dc && !ReleaseDC (impl->handle, src_dc))
- WIN32_GDI_FAILED ("ReleaseDC");
- }
- else
- {
- gdk_win32_hdc_release (drawable, gc, 0);
- g_object_unref (gc);
- }
-
- if (dest_dc)
- {
- if (holdbmp)
- SelectObject (dest_dc, holdbmp);
- if (!DeleteDC (dest_dc))
- WIN32_GDI_FAILED ("DeleteDC");
- }
- g_return_val_if_fail (ok, image);
+ gc = gdk_gc_new ((GdkDrawable *) image->windowing_data);
+ _gdk_win32_blit
+ (FALSE,
+ GDK_DRAWABLE_IMPL_WIN32 (GDK_PIXMAP_OBJECT (image->windowing_data)->impl),
+ gc, drawable, src_x, src_y, dest_x, dest_y, width, height);
+ gdk_gc_unref (gc);
return image;
}
@@ -668,7 +267,7 @@ gdk_image_get_pixel (GdkImage *image,
gint x,
gint y)
{
- guint32 pixel = 0;
+ guchar *pixelp;
g_return_val_if_fail (GDK_IS_IMAGE (image), 0);
@@ -676,37 +275,36 @@ gdk_image_get_pixel (GdkImage *image,
return 0;
if (image->depth == 1)
- pixel = (((char *) image->mem)[y * image->bpl + (x >> 3)] & (1 << (7 - (x & 0x7)))) != 0;
- else
- {
- guchar *pixelp = (guchar *) image->mem + y * image->bpl + x * image->bpp;
-
- switch (image->bpp)
- {
- case 1:
- pixel = *pixelp;
- break;
+ return (((guchar *) image->mem)[y * image->bpl + (x >> 3)] & (1 << (7 - (x & 0x7)))) != 0;
- /* Windows is always LSB, no need to check image->byte_order. */
- case 2:
- pixel = pixelp[0] | (pixelp[1] << 8);
- break;
-
- case 3:
- pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16);
- break;
-
- case 4:
- pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16);
- break;
+ if (image->depth == 4)
+ {
+ pixelp = (guchar *) image->mem + y * image->bpl + (x >> 1);
+ if (x&1)
+ return (*pixelp) & 0x0F;
- default:
- g_warning ("gdk_image_get_pixel(): bpp = %d", image->bpp);
- g_assert_not_reached ();
- }
+ return (*pixelp) >> 4;
}
+
+ pixelp = (guchar *) image->mem + y * image->bpl + x * image->bpp;
+
+ switch (image->bpp)
+ {
+ case 1:
+ return *pixelp;
+
+ /* Windows is always LSB, no need to check image->byte_order. */
+ case 2:
+ return pixelp[0] | (pixelp[1] << 8);
+
+ case 3:
+ return pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16);
- return pixel;
+ case 4:
+ return pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16);
+ }
+ g_assert_not_reached ();
+ return 0;
}
void
@@ -715,19 +313,37 @@ gdk_image_put_pixel (GdkImage *image,
gint y,
guint32 pixel)
{
+ guchar *pixelp;
+
g_return_if_fail (image != NULL);
if (!(x >= 0 && x < image->width && y >= 0 && y < image->height))
return;
+ GdiFlush ();
if (image->depth == 1)
if (pixel & 1)
((guchar *) image->mem)[y * image->bpl + (x >> 3)] |= (1 << (7 - (x & 0x7)));
else
((guchar *) image->mem)[y * image->bpl + (x >> 3)] &= ~(1 << (7 - (x & 0x7)));
+ else if (image->depth == 4)
+ {
+ pixelp = (guchar *) image->mem + y * image->bpl + (x >> 1);
+
+ if (x&1)
+ {
+ *pixelp &= 0xF0;
+ *pixelp |= (pixel & 0x0F);
+ }
+ else
+ {
+ *pixelp &= 0x0F;
+ *pixelp |= (pixel << 4);
+ }
+ }
else
{
- guchar *pixelp = (guchar *) image->mem + y * image->bpl + x * image->bpp;
+ pixelp = (guchar *) image->mem + y * image->bpl + x * image->bpp;
/* Windows is always LSB, no need to check image->byte_order. */
switch (image->bpp)
@@ -747,46 +363,55 @@ gdk_image_put_pixel (GdkImage *image,
static void
gdk_win32_image_destroy (GdkImage *image)
{
- GdkImagePrivateWin32 *private;
+ GdkPixmap *pixmap;
g_return_if_fail (GDK_IS_IMAGE (image));
- private = IMAGE_PRIVATE_DATA (image);
+ pixmap = image->windowing_data;
- if (private == NULL) /* This means that _gdk_image_exit() destroyed the
- * image already, and now we're called a second
- * time from _finalize()
- */
+ if (pixmap == NULL) /* This means that _gdk_image_exit()
+ * destroyed the image already, and
+ * now we're called a second time from
+ * _finalize()
+ */
return;
- GDK_NOTE (MISC, g_print ("gdk_win32_image_destroy: %#x\n",
- (guint) private->hbitmap));
-
- switch (image->type)
- {
- case GDK_IMAGE_SHARED:
- if (!DeleteObject (private->hbitmap))
- WIN32_GDI_FAILED ("DeleteObject");
- break;
+ GDK_NOTE (IMAGE, g_print ("gdk_win32_image_destroy: %p\n",
+ GDK_PIXMAP_HBITMAP (pixmap)));
- default:
- g_assert_not_reached ();
- }
-
- g_free (private);
+ gdk_pixmap_unref (pixmap);
image->windowing_data = NULL;
}
gint
_gdk_windowing_get_bits_for_depth (gint depth)
{
- if ((1 == depth) || (8 == depth) || (16 == depth) ||
- (24 == depth) || (32 == depth))
- return depth;
- else if (15 == depth)
- return 16;
- else
- g_assert_not_reached ();
+ switch (depth)
+ {
+ case 1:
+ return 1;
+ case 2:
+ case 3:
+ case 4:
+ return 4;
+
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ return 8;
+
+ case 15:
+ case 16:
+ return 16;
+
+ case 24:
+ return 24;
+
+ case 32:
+ return 32;
+ }
+ g_assert_not_reached ();
return 0;
}
diff --git a/gdk/win32/gdkinput-win32.c b/gdk/win32/gdkinput-win32.c
index 6840c87b75..0e065d5929 100644
--- a/gdk/win32/gdkinput-win32.c
+++ b/gdk/win32/gdkinput-win32.c
@@ -1,6 +1,6 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- * Copyright (C) 1999 Tor Lillqvist
+ * Copyright (C) 1998-2002 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -217,23 +217,23 @@ gdk_input_wintab_init (void)
WTInfo (0, 0, NULL))
{
WTInfo (WTI_INTERFACE, IFC_SPECVERSION, &specversion);
- GDK_NOTE (MISC, g_print ("Wintab interface version %d.%d\n",
+ GDK_NOTE (INPUT, g_print ("Wintab interface version %d.%d\n",
HIBYTE (specversion), LOBYTE (specversion)));
#if USE_SYSCONTEXT
WTInfo (WTI_DEFSYSCTX, 0, &defcontext);
#if DEBUG_WINTAB
- GDK_NOTE (MISC, (g_print("DEFSYSCTX:\n"), print_lc(&defcontext)));
+ GDK_NOTE (INPUT, (g_print("DEFSYSCTX:\n"), print_lc(&defcontext)));
#endif
#else
WTInfo (WTI_DEFCONTEXT, 0, &defcontext);
#if DEBUG_WINTAB
- GDK_NOTE (MISC, (g_print("DEFCONTEXT:\n"), print_lc(&defcontext)));
+ GDK_NOTE (INPUT, (g_print("DEFCONTEXT:\n"), print_lc(&defcontext)));
#endif
#endif
WTInfo (WTI_INTERFACE, IFC_NDEVICES, &ndevices);
WTInfo (WTI_INTERFACE, IFC_NCURSORS, &ncursors);
#if DEBUG_WINTAB
- GDK_NOTE (MISC, g_print ("NDEVICES: %d, NCURSORS: %d\n",
+ GDK_NOTE (INPUT, g_print ("NDEVICES: %d, NCURSORS: %d\n",
ndevices, ncursors));
#endif
/* Create a dummy window to receive wintab events */
@@ -324,7 +324,7 @@ gdk_input_wintab_init (void)
#endif
}
#if DEBUG_WINTAB
- GDK_NOTE (MISC, (g_print("context for device %d:\n", devix),
+ GDK_NOTE (INPUT, (g_print("context for device %d:\n", devix),
print_lc(&lc)));
#endif
hctx = g_new (HCTX, 1);
@@ -333,7 +333,7 @@ gdk_input_wintab_init (void)
g_warning ("_gdk_input_init: WTOpen failed");
return;
}
- GDK_NOTE (MISC, g_print ("opened Wintab device %d %p\n",
+ GDK_NOTE (INPUT, g_print ("opened Wintab device %d %p\n",
devix, *hctx));
wintab_contexts = g_list_append (wintab_contexts, hctx);
@@ -343,7 +343,7 @@ gdk_input_wintab_init (void)
WTOverlap (*hctx, TRUE);
#if DEBUG_WINTAB
- GDK_NOTE (MISC, (g_print("context for device %d after WTOpen:\n", devix),
+ GDK_NOTE (INPUT, (g_print("context for device %d after WTOpen:\n", devix),
print_lc(&lc)));
#endif
for (cursorix = firstcsr; cursorix < firstcsr + ncsrtypes; cursorix++)
@@ -453,13 +453,13 @@ gdk_input_wintab_init (void)
}
gdkdev->info.num_keys = 0;
gdkdev->info.keys = NULL;
- GDK_NOTE (EVENTS,
+ GDK_NOTE (INPUT,
g_print ("device: (%d) %s axes: %d\n",
cursorix,
gdkdev->info.name,
gdkdev->info.num_axes));
for (i = 0; i < gdkdev->info.num_axes; i++)
- GDK_NOTE (EVENTS,
+ GDK_NOTE (INPUT,
g_print ("...axis %d: %d--%d@%d (%d--%d@%d)\n",
i,
gdkdev->axes[i].xmin_value,
@@ -720,9 +720,9 @@ _gdk_input_other_event (GdkEvent *event,
gdk_drawable_ref (window);
- GDK_NOTE (EVENTS,
- g_print ("gdk_input_win32_other_event: window=%#x (%d,%d)\n",
- (guint) GDK_WINDOW_HWND (window), x, y));
+ GDK_NOTE (EVENTS_OR_INPUT,
+ g_print ("gdk_input_win32_other_event: window=%p (%d,%d)\n",
+ GDK_WINDOW_HWND (window), x, y));
#else
/* ??? This code is pretty bogus */
@@ -749,7 +749,7 @@ _gdk_input_other_event (GdkEvent *event,
case WT_PACKET:
if (window == _gdk_parent_root)
{
- GDK_NOTE (EVENTS, g_print ("...is root\n"));
+ GDK_NOTE (EVENTS_OR_INPUT, g_print ("...is root\n"));
return FALSE;
}
@@ -813,7 +813,7 @@ _gdk_input_other_event (GdkEvent *event,
if (!impl->extension_events_selected
|| !(obj->extension_events & masktest))
{
- GDK_NOTE (EVENTS, g_print ("...not selected\n"));
+ GDK_NOTE (EVENTS_OR_INPUT, g_print ("...not selected\n"));
if (obj->parent == GDK_WINDOW_OBJECT (_gdk_parent_root))
return FALSE;
@@ -828,8 +828,8 @@ _gdk_input_other_event (GdkEvent *event,
ScreenToClient (GDK_WINDOW_HWND (window), &pt);
x = pt.x;
y = pt.y;
- GDK_NOTE (EVENTS, g_print ("...propagating to %#x, (%d,%d)\n",
- (guint) GDK_WINDOW_HWND (window), x, y));
+ GDK_NOTE (EVENTS_OR_INPUT, g_print ("...propagating to %p (%d,%d)\n",
+ GDK_WINDOW_HWND (window), x, y));
goto dijkstra;
}
@@ -866,11 +866,12 @@ _gdk_input_other_event (GdkEvent *event,
& (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK
| GDK_BUTTON3_MASK | GDK_BUTTON4_MASK
| GDK_BUTTON5_MASK));
- GDK_NOTE (EVENTS, g_print ("WINTAB button %s:%d %g,%g\n",
- (event->button.type == GDK_BUTTON_PRESS ?
- "press" : "release"),
- event->button.button,
- event->button.x, event->button.y));
+ GDK_NOTE (EVENTS_OR_INPUT,
+ g_print ("WINTAB button %s:%d %g,%g\n",
+ (event->button.type == GDK_BUTTON_PRESS ?
+ "press" : "release"),
+ event->button.button,
+ event->button.x, event->button.y));
}
else
{
@@ -889,8 +890,9 @@ _gdk_input_other_event (GdkEvent *event,
| GDK_BUTTON3_MASK | GDK_BUTTON4_MASK
| GDK_BUTTON5_MASK));
- GDK_NOTE (EVENTS, g_print ("WINTAB motion: %g,%g\n",
- event->motion.x, event->motion.y));
+ GDK_NOTE (EVENTS_OR_INPUT,
+ g_print ("WINTAB motion: %g,%g\n",
+ event->motion.x, event->motion.y));
/* Check for missing release or press events for the normal
* pressure button. At least on my ArtPadII I sometimes miss a
@@ -919,12 +921,13 @@ _gdk_input_other_event (GdkEvent *event,
| GDK_BUTTON3_MASK | GDK_BUTTON4_MASK
| GDK_BUTTON5_MASK));
event2->button.button = 1;
- GDK_NOTE (EVENTS, g_print ("WINTAB synthesized button %s: %d %g,%gg\n",
- (event2->button.type == GDK_BUTTON_PRESS ?
- "press" : "release"),
- event2->button.button,
- event2->button.x,
- event2->button.y));
+ GDK_NOTE (EVENTS_OR_INPUT,
+ g_print ("WINTAB synthesized button %s: %d %g,%gg\n",
+ (event2->button.type == GDK_BUTTON_PRESS ?
+ "press" : "release"),
+ event2->button.button,
+ event2->button.x,
+ event2->button.y));
_gdk_event_queue_append (event2);
}
}
@@ -944,9 +947,10 @@ _gdk_input_other_event (GdkEvent *event,
event->proximity.time = msg->time;
event->proximity.device = &gdkdev->info;
- GDK_NOTE (EVENTS, g_print ("WINTAB proximity %s\n",
- (event->proximity.type == GDK_PROXIMITY_IN ?
- "in" : "out")));
+ GDK_NOTE (EVENTS_OR_INPUT,
+ g_print ("WINTAB proximity %s\n",
+ (event->proximity.type == GDK_PROXIMITY_IN ?
+ "in" : "out")));
return TRUE;
}
#endif
@@ -996,7 +1000,7 @@ _gdk_input_grab_pointer (GdkWindow *window,
new_window = NULL;
need_ungrab = FALSE;
- GDK_NOTE (MISC, g_print ("gdk_input_win32_grab_pointer: %#x %d %#x\n",
+ GDK_NOTE (INPUT, g_print ("gdk_input_win32_grab_pointer: %#x %d %#x\n",
(guint) GDK_WINDOW_HWND (window),
owner_events,
(confine_to ? (guint) GDK_WINDOW_HWND (confine_to) : 0)));
@@ -1078,7 +1082,7 @@ _gdk_input_ungrab_pointer (guint32 time)
GdkDevicePrivate *gdkdev;
GList *tmp_list;
- GDK_NOTE (MISC, g_print ("gdk_input_win32_ungrab_pointer\n"));
+ GDK_NOTE (INPUT, g_print ("gdk_input_win32_ungrab_pointer\n"));
tmp_list = _gdk_input_windows;
while (tmp_list)
diff --git a/gdk/win32/gdkkeys-win32.c b/gdk/win32/gdkkeys-win32.c
index 0fe0e18f2c..91f73770b3 100644
--- a/gdk/win32/gdkkeys-win32.c
+++ b/gdk/win32/gdkkeys-win32.c
@@ -43,8 +43,6 @@ guint _gdk_keymap_serial = 0;
static gint min_keycode = 0;
static gint max_keycode = 0;
-static gint keysyms_per_keycode = 0;
-static GdkModifierType group_switch_mask = 0;
static GdkKeymap *default_keymap = NULL;
GdkKeymap*
diff --git a/gdk/win32/gdkmain-win32.c b/gdk/win32/gdkmain-win32.c
index 758113aeaf..70137bf50c 100644
--- a/gdk/win32/gdkmain-win32.c
+++ b/gdk/win32/gdkmain-win32.c
@@ -1,6 +1,6 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- * Copyright (C) 1998-1999 Tor Lillqvist
+ * Copyright (C) 1998-2002 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -52,6 +52,7 @@ GdkArgDesc _gdk_windowing_args[] = {
{ "event-func-from-window-proc",
GDK_ARG_BOOL, &gdk_event_func_from_window_proc,
(GdkArgFunc) NULL},
+ { "max-colors", GDK_ARG_INT, &gdk_max_colors, (GdkArgFunc) NULL},
{ NULL }
};
diff --git a/gdk/win32/gdkpixmap-win32.c b/gdk/win32/gdkpixmap-win32.c
index 2902383ebb..f467ca95b5 100644
--- a/gdk/win32/gdkpixmap-win32.c
+++ b/gdk/win32/gdkpixmap-win32.c
@@ -1,6 +1,6 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- * Copyright (C) 1998-1999 Tor Lillqvist
+ * Copyright (C) 1998-2002 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -102,8 +102,8 @@ gdk_pixmap_impl_win32_finalize (GObject *object)
GdkPixmapImplWin32 *impl = GDK_PIXMAP_IMPL_WIN32 (object);
GdkPixmap *wrapper = GDK_PIXMAP (GDK_DRAWABLE_IMPL_WIN32 (impl)->wrapper);
- GDK_NOTE (MISC, g_print ("gdk_pixmap_impl_win32_finalize: %#x\n",
- (guint) GDK_PIXMAP_HBITMAP (wrapper)));
+ GDK_NOTE (PIXMAP, g_print ("gdk_pixmap_impl_win32_finalize: %p\n",
+ GDK_PIXMAP_HBITMAP (wrapper)));
if (!DeleteObject (GDK_PIXMAP_HBITMAP (wrapper)))
WIN32_GDI_FAILED ("DeleteObject");
@@ -125,18 +125,12 @@ gdk_pixmap_impl_win32_get_size (GdkDrawable *drawable,
}
GdkPixmap*
-gdk_pixmap_new (GdkWindow *window,
- gint width,
- gint height,
- gint depth)
+_gdk_win32_pixmap_new (GdkWindow *window,
+ GdkVisual *visual,
+ gint width,
+ gint height,
+ gint depth)
{
- GdkPixmap *pixmap;
- GdkDrawableImplWin32 *draw_impl;
- GdkPixmapImplWin32 *pix_impl;
- GdkVisual *visual;
- GdkColormap *cmap = NULL;
- gint window_depth;
-
struct {
BITMAPINFOHEADER bmiHeader;
union {
@@ -147,26 +141,17 @@ gdk_pixmap_new (GdkWindow *window,
} bmi;
UINT iUsage;
HDC hdc;
-
+ HPALETTE holdpal = NULL;
+ HBITMAP hbitmap;
+ GdkPixmap *pixmap;
+ GdkDrawableImplWin32 *drawable_impl;
+ GdkPixmapImplWin32 *pixmap_impl;
guchar *bits;
gint i;
g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
g_return_val_if_fail ((window != NULL) || (depth != -1), NULL);
-#if 1
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
-#else
- /* HB: Not The Right Thing to do, but a nice way to debug
- * the backing store facility without immediate crashes ...
- */
- if (width == 0 || height == 0)
- {
- g_warning("gdk_pixmap_new: size requested: %ld %ld", width, height);
- /* testing: where does it crash next? */
- if (width == 0) width = 1;
- if (height == 0) height = 1;
- }
-#endif
if (!window)
window = _gdk_parent_root;
@@ -174,23 +159,29 @@ gdk_pixmap_new (GdkWindow *window,
if (GDK_WINDOW_DESTROYED (window))
return NULL;
- visual = gdk_drawable_get_visual (window);
+ if (!visual)
+ {
+ if (window)
+ visual = gdk_drawable_get_visual (window);
+ else
+ visual = gdk_visual_get_system ();
+ }
- window_depth = gdk_drawable_get_depth (GDK_DRAWABLE (window));
if (depth == -1)
- depth = window_depth;
+ depth = visual->depth;
- GDK_NOTE (MISC, g_print ("gdk_pixmap_new: %dx%dx%d\n",
- width, height, depth));
+ GDK_NOTE (PIXMAP, g_print ("_gdk_win32_pixmap_new: %dx%dx%d "
+ "window=%p visual=%p\n",
+ width, height, depth, window, visual));
pixmap = g_object_new (gdk_pixmap_get_type (), NULL);
- draw_impl = GDK_DRAWABLE_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
- pix_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
- draw_impl->wrapper = GDK_DRAWABLE (pixmap);
+ drawable_impl = GDK_DRAWABLE_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
+ pixmap_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
+ drawable_impl->wrapper = GDK_DRAWABLE (pixmap);
- pix_impl->is_foreign = FALSE;
- pix_impl->width = width;
- pix_impl->height = height;
+ pixmap_impl->is_foreign = FALSE;
+ pixmap_impl->width = width;
+ pixmap_impl->height = height;
GDK_PIXMAP_OBJECT (pixmap)->depth = depth;
if ((hdc = GetDC (GDK_WINDOW_HWND (window))) == NULL)
@@ -204,14 +195,40 @@ gdk_pixmap_new (GdkWindow *window,
bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = -height;
bmi.bmiHeader.biPlanes = 1;
- if (depth == 15)
- bmi.bmiHeader.biBitCount = 16;
- else
- bmi.bmiHeader.biBitCount = depth;
- if (depth == 16)
+ switch (depth)
+ {
+ case 1:
+ case 24:
+ case 32:
+ bmi.bmiHeader.biBitCount = depth;
+ break;
+
+ case 4:
+ bmi.bmiHeader.biBitCount = 4;
+ break;
+
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ bmi.bmiHeader.biBitCount = 8;
+ break;
+
+ case 15:
+ case 16:
+ bmi.bmiHeader.biBitCount = 16;
+ break;
+
+ default:
+ g_warning ("gdk_win32_pixmap_new: depth = %d", depth);
+ g_assert_not_reached ();
+ }
+
+ if (bmi.bmiHeader.biBitCount == 16)
bmi.bmiHeader.biCompression = BI_BITFIELDS;
else
bmi.bmiHeader.biCompression = BI_RGB;
+
bmi.bmiHeader.biSizeImage = 0;
bmi.bmiHeader.biXPelsPerMeter =
bmi.bmiHeader.biYPelsPerMeter = 0;
@@ -230,57 +247,83 @@ gdk_pixmap_new (GdkWindow *window,
bmi.u.bmiColors[1].rgbGreen =
bmi.u.bmiColors[1].rgbRed = 0xFF;
bmi.u.bmiColors[1].rgbReserved = 0x00;
- draw_impl->colormap = NULL;
+ drawable_impl->colormap = NULL;
}
else
{
- if (depth == 8)
+ if (depth > 8 && depth != visual->depth)
+ g_warning ("_gdk_win32_pixmap_new: depth %d doesn't match display depth %d",
+ depth, visual->depth);
+
+ drawable_impl->colormap = GDK_DRAWABLE_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl)->colormap;
+
+ if (drawable_impl->colormap == NULL)
+ drawable_impl->colormap = gdk_colormap_get_system ();
+ gdk_colormap_ref (drawable_impl->colormap);
+
+ if (depth <= 8)
{
+ GdkColormapPrivateWin32 *cmapp =
+ GDK_WIN32_COLORMAP_DATA (drawable_impl->colormap);
+ gint k;
+
+ if ((holdpal = SelectPalette (hdc, cmapp->hpal, FALSE)) == NULL)
+ WIN32_GDI_FAILED ("SelectPalette");
+ else if ((k = RealizePalette (hdc)) == GDI_ERROR)
+ WIN32_GDI_FAILED ("RealizePalette");
+ else if (k > 0)
+ GDK_NOTE (PIXMAP_OR_COLORMAP, g_print ("_gdk_win32_pixmap_new: realized %p: %d colors\n",
+ cmapp->hpal, k));
+
iUsage = DIB_PAL_COLORS;
for (i = 0; i < 256; i++)
bmi.u.bmiIndices[i] = i;
}
- else
+ else if (bmi.bmiHeader.biBitCount == 16)
{
- if (depth != visual->depth)
- g_warning ("gdk_pixmap_new: depth %d doesn't match display depth %d",
- depth, visual->depth);
- if (depth == 16)
- {
- bmi.u.bmiMasks[0] = visual->red_mask;
- bmi.u.bmiMasks[1] = visual->green_mask;
- bmi.u.bmiMasks[2] = visual->blue_mask;
- }
+ bmi.u.bmiMasks[0] = visual->red_mask;
+ bmi.u.bmiMasks[1] = visual->green_mask;
+ bmi.u.bmiMasks[2] = visual->blue_mask;
}
}
- if ((draw_impl->handle = CreateDIBSection (hdc, (BITMAPINFO *) &bmi,
- iUsage, (PVOID *) &bits,
- NULL, 0)) == NULL)
+
+ hbitmap = CreateDIBSection (hdc, (BITMAPINFO *) &bmi,
+ iUsage, (PVOID *) &bits, NULL, 0);
+ if (holdpal != NULL)
+ SelectPalette (hdc, holdpal, FALSE);
+
+ if (!ReleaseDC (GDK_WINDOW_HWND (window), hdc))
+ WIN32_GDI_FAILED ("ReleaseDC");
+
+ GDK_NOTE (PIXMAP, g_print ("...=%p bits=%p\n", hbitmap, bits));
+
+ if (hbitmap == NULL)
{
WIN32_GDI_FAILED ("CreateDIBSection");
ReleaseDC (GDK_WINDOW_HWND (window), hdc);
g_object_unref ((GObject *) pixmap);
return NULL;
}
- ReleaseDC (GDK_WINDOW_HWND (window), hdc);
-
- if (depth == window_depth)
- {
- cmap = gdk_drawable_get_colormap (window);
- if (cmap)
- gdk_drawable_set_colormap (pixmap, cmap);
- }
- GDK_NOTE (MISC, g_print ("... colormap %p\n", cmap));
-
- GDK_NOTE (MISC, g_print ("... = %#x\n",
- (guint) GDK_PIXMAP_HBITMAP (pixmap)));
+ drawable_impl->handle = hbitmap;
+ pixmap_impl->image = _gdk_win32_setup_pixmap_image (pixmap, window,
+ width, height,
+ depth, bits);
gdk_win32_handle_table_insert (&GDK_PIXMAP_HBITMAP (pixmap), pixmap);
return pixmap;
}
+GdkPixmap*
+gdk_pixmap_new (GdkWindow *window,
+ gint width,
+ gint height,
+ gint depth)
+{
+ return _gdk_win32_pixmap_new (window, NULL, width, height, depth);
+}
+
static unsigned char mirror[256] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
@@ -323,9 +366,8 @@ gdk_bitmap_create_from_data (GdkWindow *window,
gint height)
{
GdkPixmap *pixmap;
- GdkDrawableImplWin32 *draw_impl;
- GdkPixmapImplWin32 *pix_impl;
- gint i, j, bpl, aligned_bpl;
+ GdkPixmapImplWin32 *pixmap_impl;
+ gint i, j, data_bpl, image_bpl;
guchar *bits;
g_return_val_if_fail (data != NULL, NULL);
@@ -338,33 +380,22 @@ gdk_bitmap_create_from_data (GdkWindow *window,
if (GDK_WINDOW_DESTROYED (window))
return NULL;
- pixmap = g_object_new (gdk_pixmap_get_type (), NULL);
- draw_impl = GDK_DRAWABLE_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
- pix_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
- draw_impl->wrapper = GDK_DRAWABLE (pixmap);
-
- pix_impl->is_foreign = FALSE;
- pix_impl->width = width;
- pix_impl->height = height;
- GDK_PIXMAP_OBJECT (pixmap)->depth = 1;
+ pixmap = gdk_pixmap_new (window, width, height, 1);
- bpl = ((width - 1) / 8 + 1);
- aligned_bpl = ((bpl - 1) / 2 + 1) * 2;
- bits = g_malloc (aligned_bpl * height);
- for (i = 0; i < height; i++)
- for (j = 0; j < bpl; j++)
- bits[i*aligned_bpl + j] = mirror[(guchar) data[i*bpl + j]];
+ if (pixmap == NULL)
+ return NULL;
- draw_impl->handle = CreateBitmap (width, height, 1, 1, bits);
+ pixmap_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
+ bits = pixmap_impl->image->mem;
+ data_bpl = ((width - 1) / 8 + 1);
+ image_bpl = pixmap_impl->image->bpl;
- GDK_NOTE (MISC, g_print ("gdk_bitmap_create_from_data: %dx%d = %#x\n",
- width, height,
- (guint) GDK_PIXMAP_HBITMAP (pixmap)));
+ for (i = 0; i < height; i++)
+ for (j = 0; j < data_bpl; j++)
+ bits[i*image_bpl + j] = mirror[(guchar) data[i*data_bpl + j]];
- g_free (bits);
-
- draw_impl->colormap = NULL;
- gdk_win32_handle_table_insert (&GDK_PIXMAP_HBITMAP (pixmap), pixmap);
+ GDK_NOTE (PIXMAP, g_print ("gdk_bitmap_create_from_data: %dx%d=%p\n",
+ width, height, GDK_PIXMAP_HBITMAP (pixmap)));
return pixmap;
}
@@ -398,13 +429,16 @@ gdk_pixmap_create_from_data (GdkWindow *window,
gdk_gc_set_foreground (gc, fg);
gdk_gc_set_background (gc, bg);
- gdk_draw_drawable (result, gc, source, 0, 0, 0, 0, width, height);
+ _gdk_win32_blit
+ (TRUE,
+ GDK_DRAWABLE_IMPL_WIN32 (GDK_PIXMAP_OBJECT (result)->impl),
+ gc, source, 0, 0, 0, 0, width, height);
gdk_drawable_unref (source);
gdk_gc_unref (gc);
- GDK_NOTE (MISC, g_print ("gdk_pixmap_create_from_data: %dx%dx%d = %#x\n",
- width, height, depth,
- (guint) GDK_PIXMAP_HBITMAP (result)));
+ GDK_NOTE (PIXMAP, g_print ("gdk_pixmap_create_from_data: %dx%dx%d=%p\n",
+ width, height, depth,
+ GDK_PIXMAP_HBITMAP (result)));
return result;
}
@@ -417,21 +451,18 @@ gdk_pixmap_foreign_new (GdkNativeWindow anid)
GdkPixmapImplWin32 *pix_impl;
HBITMAP hbitmap;
SIZE size;
- unsigned int w_ret, h_ret;
- /* check to make sure we were passed a HBITMAP */
- g_return_val_if_fail(GetObjectType ((HGDIOBJ) anid) == OBJ_BITMAP, NULL);
+ /* Check to make sure we were passed a HBITMAP */
+ g_return_val_if_fail (GetObjectType ((HGDIOBJ) anid) == OBJ_BITMAP, NULL);
- /* set the pixmap to the passed in value */
hbitmap = (HBITMAP) anid;
- /* get information about the bitmap to fill in the structure for
- the gdk window */
+ /* Get information about the bitmap to fill in the structure for the
+ * GDK window.
+ */
GetBitmapDimensionEx (hbitmap, &size);
- w_ret = size.cx;
- h_ret = size.cy;
- /* allocate a new gdk pixmap */
+ /* Allocate a new GDK pixmap */
pixmap = g_object_new (gdk_pixmap_get_type (), NULL);
draw_impl = GDK_DRAWABLE_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
pix_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
@@ -439,8 +470,13 @@ gdk_pixmap_foreign_new (GdkNativeWindow anid)
draw_impl->handle = hbitmap;
draw_impl->colormap = NULL;
- pix_impl->width = w_ret;
- pix_impl->height = h_ret;
+ pix_impl->width = size.cx;
+ pix_impl->height = size.cy;
+ pix_impl->image =
+ _gdk_win32_setup_pixmap_image (pixmap, _gdk_parent_root,
+ size.cx, size.cy,
+ gdk_visual_get_system ()->depth,
+ NULL);
gdk_win32_handle_table_insert (&GDK_PIXMAP_HBITMAP (pixmap), pixmap);
diff --git a/gdk/win32/gdkpixmap-win32.h b/gdk/win32/gdkpixmap-win32.h
index 69114fd4b8..0b3589995d 100644
--- a/gdk/win32/gdkpixmap-win32.h
+++ b/gdk/win32/gdkpixmap-win32.h
@@ -54,13 +54,15 @@ struct _GdkPixmapImplWin32
gint width;
gint height;
+ GdkImage *image; /* A pointer to the GdkImage
+ * containing the pixels.
+ */
guint is_foreign : 1;
};
struct _GdkPixmapImplWin32Class
{
GdkDrawableImplWin32Class parent_class;
-
};
GType _gdk_pixmap_impl_win32_get_type (void);
diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h
index e8a2f7b7cd..1fafb86017 100644
--- a/gdk/win32/gdkprivate-win32.h
+++ b/gdk/win32/gdkprivate-win32.h
@@ -188,36 +188,11 @@
#define CopyCursor(pcur) ((HCURSOR)CopyIcon((HICON)(pcur)))
#endif
-/* Define corresponding Windows types for some X11 types, just for laziness. */
-typedef PALETTEENTRY XColor;
-
-/* Some structs are somewhat useful to emulate internally. */
-typedef struct {
- HPALETTE palette; /* Palette handle used when drawing. */
- guint size; /* Number of entries in the palette. */
- gboolean stale; /* 1 if palette needs to be realized,
- * otherwise 0. */
- gboolean *in_use;
- gboolean rc_palette; /* If RC_PALETTE is on in the RASTERCAPS */
- gulong sizepalette; /* SIZEPALETTE if rc_palette */
-} ColormapStruct, *Colormap;
-
-typedef struct {
- gint map_entries;
- guint visualid;
- guint bitspixel;
-} Visual;
-
-typedef struct {
- Colormap colormap;
- unsigned long red_max;
- unsigned long red_mult;
- unsigned long green_max;
- unsigned long green_mult;
- unsigned long blue_max;
- unsigned long blue_mult;
- unsigned long base_pixel;
-} XStandardColormap;
+/* Define some combinations of GdkDebugFlags */
+#define GDK_DEBUG_EVENTS_OR_COLORMAP (GDK_DEBUG_EVENTS|GDK_DEBUG_COLORMAP)
+#define GDK_DEBUG_EVENTS_OR_INPUT (GDK_DEBUG_EVENTS|GDK_DEBUG_INPUT)
+#define GDK_DEBUG_PIXMAP_OR_COLORMAP (GDK_DEBUG_PIXMAP|GDK_DEBUG_COLORMAP)
+#define GDK_DEBUG_MISC_OR_COLORMAP (GDK_DEBUG_MISC|GDK_DEBUG_COLORMAP)
#define GDK_TYPE_GC_WIN32 (_gdk_gc_win32_get_type ())
#define GDK_GC_WIN32(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GC_WIN32, GdkGCWin32))
@@ -230,10 +205,8 @@ typedef struct _GdkColormapPrivateWin32 GdkColormapPrivateWin32;
typedef struct _GdkCursorPrivate GdkCursorPrivate;
typedef struct _GdkWin32SingleFont GdkWin32SingleFont;
typedef struct _GdkFontPrivateWin32 GdkFontPrivateWin32;
-typedef struct _GdkImagePrivateWin32 GdkImagePrivateWin32;
-typedef struct _GdkVisualPrivate GdkVisualPrivate;
-typedef struct _GdkGCWin32 GdkGCWin32;
-typedef struct _GdkGCWin32Class GdkGCWin32Class;
+typedef struct _GdkGCWin32 GdkGCWin32;
+typedef struct _GdkGCWin32Class GdkGCWin32Class;
struct _GdkCursorPrivate
{
@@ -261,25 +234,21 @@ struct _GdkVisualClass
GObjectClass parent_class;
};
-struct _GdkVisualPrivate
-{
- GdkVisual visual;
- Visual *xvisual;
-};
+typedef enum {
+ GDK_WIN32_PE_STATIC,
+ GDK_WIN32_PE_AVAILABLE,
+ GDK_WIN32_PE_INUSE
+} GdkWin32PalEntryState;
struct _GdkColormapPrivateWin32
{
- Colormap xcolormap;
+ HPALETTE hpal;
+ gint current_size; /* Current size of hpal */
+ GdkWin32PalEntryState *use;
gint private_val;
GHashTable *hash;
GdkColorInfo *info;
- DWORD last_sync_time;
-};
-
-struct _GdkImagePrivateWin32
-{
- HBITMAP hbitmap;
};
struct _GdkGCWin32
@@ -296,6 +265,8 @@ struct _GdkGCWin32
*/
HDC hdc;
+ int saved_dc;
+
GdkRegion *clip_region;
HRGN hcliprgn;
@@ -316,7 +287,7 @@ struct _GdkGCWin32
HANDLE hwnd; /* If a HDC is allocated, for which window,
* or what bitmap is selected into it
*/
- int saved_dc;
+ HPALETTE holdpal;
};
struct _GdkGCWin32Class
@@ -327,14 +298,12 @@ struct _GdkGCWin32Class
GType _gdk_gc_win32_get_type (void);
/* Routines from gdkgeometry-win32.c */
-void
-_gdk_window_init_position (GdkWindow *window);
-void
-_gdk_window_move_resize_child (GdkWindow *window,
- gint x,
- gint y,
- gint width,
- gint height);
+void _gdk_window_init_position (GdkWindow *window);
+void _gdk_window_move_resize_child (GdkWindow *window,
+ gint x,
+ gint y,
+ gint width,
+ gint height);
void _gdk_window_process_expose (GdkWindow *window,
gulong serial,
GdkRectangle *area);
@@ -351,35 +320,59 @@ void _gdk_win32_draw_tiles (GdkDrawable *drawable,
void _gdk_win32_selection_init (void);
void _gdk_win32_dnd_exit (void);
-void gdk_win32_handle_table_insert (HANDLE *handle,
- gpointer data);
-void gdk_win32_handle_table_remove (HANDLE handle);
-
-GdkGC * _gdk_win32_gc_new (GdkDrawable *drawable,
- GdkGCValues *values,
- GdkGCValuesMask values_mask);
-
-GdkImage* _gdk_win32_get_image (GdkDrawable *drawable,
- gint x,
- gint y,
- gint width,
- gint height);
-
-GdkImage *_gdk_win32_copy_to_image (GdkDrawable *drawable,
- GdkImage *image,
- gint src_x,
- gint src_y,
- gint dest_x,
- gint dest_y,
- gint width,
- gint height);
-
-COLORREF _gdk_win32_colormap_color (GdkColormap *colormap,
- gulong pixel);
-
-HRGN BitmapToRegion (HBITMAP hBmp);
-
-gchar *gdk_font_full_name_get (GdkFont *font);
+void gdk_win32_handle_table_insert (HANDLE *handle,
+ gpointer data);
+void gdk_win32_handle_table_remove (HANDLE handle);
+
+GdkGC *_gdk_win32_gc_new (GdkDrawable *drawable,
+ GdkGCValues *values,
+ GdkGCValuesMask values_mask);
+
+GdkImage *_gdk_win32_get_image (GdkDrawable *drawable,
+ gint x,
+ gint y,
+ gint width,
+ gint height);
+
+GdkImage *_gdk_win32_copy_to_image (GdkDrawable *drawable,
+ GdkImage *image,
+ gint src_x,
+ gint src_y,
+ gint dest_x,
+ gint dest_y,
+ gint width,
+ gint height);
+
+GdkPixmap *_gdk_win32_pixmap_new (GdkWindow *window,
+ GdkVisual *visual,
+ gint width,
+ gint height,
+ gint depth);
+
+GdkImage *_gdk_win32_setup_pixmap_image (GdkPixmap *pixmap,
+ GdkWindow *window,
+ gint width,
+ gint height,
+ gint depth,
+ guchar *bits);
+
+void _gdk_win32_blit (gboolean use_fg_bg,
+ GdkDrawableImplWin32 *drawable,
+ GdkGC *gc,
+ GdkDrawable *src,
+ gint xsrc,
+ gint ysrc,
+ gint xdest,
+ gint ydest,
+ gint width,
+ gint height);
+
+COLORREF _gdk_win32_colormap_color (GdkColormap *colormap,
+ gulong pixel);
+
+HRGN _gdk_win32_bitmap_to_region (GdkPixmap *bitmap);
+
+gchar *gdk_font_full_name_get (GdkFont *font);
void _gdk_selection_property_store (GdkWindow *owner,
GdkAtom type,
@@ -473,7 +466,8 @@ extern DWORD windows_version;
/* Options */
extern gboolean gdk_input_ignore_wintab;
extern gboolean gdk_event_func_from_window_proc;
+extern gint gdk_max_colors;
-#define IMAGE_PRIVATE_DATA(image) ((GdkImagePrivateWin32 *) GDK_IMAGE (image)->windowing_data)
+#define GDK_WIN32_COLORMAP_DATA(cmap) ((GdkColormapPrivateWin32 *) GDK_COLORMAP (cmap)->windowing_data)
#endif /* __GDK_PRIVATE_WIN32_H__ */
diff --git a/gdk/win32/gdkvisual-win32.c b/gdk/win32/gdkvisual-win32.c
index 67c04577ad..c05f5525ac 100644
--- a/gdk/win32/gdkvisual-win32.c
+++ b/gdk/win32/gdkvisual-win32.c
@@ -1,5 +1,6 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * Copyright (C) 1998-2002 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -33,7 +34,7 @@ static void gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec);
-static GdkVisualPrivate *system_visual = NULL;
+static GdkVisual *system_visual = NULL;
static gint available_depths[1];
@@ -51,7 +52,6 @@ gdk_visual_class_init (GObjectClass *class)
class->finalize = gdk_visual_finalize;
}
-
GType
gdk_visual_get_type (void)
{
@@ -67,7 +67,7 @@ gdk_visual_get_type (void)
(GClassInitFunc) gdk_visual_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
- sizeof (GdkVisualPrivate),
+ sizeof (GdkVisual),
0, /* n_preallocs */
(GInstanceInitFunc) NULL,
};
@@ -94,44 +94,83 @@ _gdk_visual_init (void)
} bmi;
HBITMAP hbm;
- int rastercaps, numcolors, sizepalette, bitspixel;
-
- system_visual = g_new (GdkVisualPrivate, 1);
+ const gint rastercaps = GetDeviceCaps (gdk_display_hdc, RASTERCAPS);
+ gint bitspixel = GetDeviceCaps (gdk_display_hdc, BITSPIXEL);
+ gint map_entries = 0;
- bitspixel = GetDeviceCaps (gdk_display_hdc, BITSPIXEL);
- rastercaps = GetDeviceCaps (gdk_display_hdc, RASTERCAPS);
- system_visual->xvisual = g_new (Visual, 1);
- system_visual->xvisual->visualid = 0;
- system_visual->xvisual->bitspixel = bitspixel;
+ system_visual = g_object_new (GDK_TYPE_VISUAL, NULL);
if (rastercaps & RC_PALETTE)
{
- if (!getenv ("GDK_WIN32_ENABLE_BROKEN_PSEUDOCOLOR_VISUAL"))
- g_error ("Palettized display (%d-colour) mode not supported on Windows.",
- GetDeviceCaps (gdk_display_hdc, SIZEPALETTE));
- system_visual->visual.type = GDK_VISUAL_PSEUDO_COLOR;
- numcolors = GetDeviceCaps (gdk_display_hdc, NUMCOLORS);
- sizepalette = GetDeviceCaps (gdk_display_hdc, SIZEPALETTE);
- system_visual->xvisual->map_entries = sizepalette;
+ const int sizepalette = GetDeviceCaps (gdk_display_hdc, SIZEPALETTE);
+ const int numcolors = GetDeviceCaps (gdk_display_hdc, NUMCOLORS);
+ gchar *max_colors = getenv ("GDK_WIN32_MAX_COLORS");
+ system_visual->type = GDK_VISUAL_PSEUDO_COLOR;
+
+ GDK_NOTE (COLORMAP, g_print ("BITSPIXEL=%d NUMCOLORS=%d SIZEPALETTE=%d\n",
+ bitspixel, numcolors, sizepalette));
+ g_assert (sizepalette == 256);
+
+ if (max_colors != NULL)
+ gdk_max_colors = atoi (max_colors);
+
+ map_entries = gdk_max_colors;
+
+ if (map_entries >= 16 && map_entries < sizepalette)
+ {
+ /* The calls to gdk_rgb_set_min_colors() here have knowledge
+ * of what color cubes gdk_rgb_do_colormaps() will try, and
+ * of the static system palette colors... XXX
+ */
+ if (map_entries < 32)
+ {
+ map_entries = 16;
+ system_visual->type = GDK_VISUAL_STATIC_COLOR;
+ bitspixel = 4;
+ gdk_rgb_set_min_colors (2*2*2);
+ }
+ else if (map_entries < 64)
+ {
+ map_entries = 32;
+ bitspixel = 5;
+ gdk_rgb_set_min_colors (3*3*3);
+ }
+ else if (map_entries < 128)
+ {
+ map_entries = 64;
+ bitspixel = 6;
+ gdk_rgb_set_min_colors (3*3*3);
+ }
+ else if (map_entries < 256)
+ {
+ map_entries = 128;
+ bitspixel = 7;
+ gdk_rgb_set_min_colors (5*5*4);
+ }
+ else
+ g_assert_not_reached ();
+ }
+ else
+ map_entries = sizepalette;
}
else if (bitspixel == 1)
{
- system_visual->visual.type = GDK_VISUAL_STATIC_GRAY;
- system_visual->xvisual->map_entries = 2;
+ system_visual->type = GDK_VISUAL_STATIC_GRAY;
+ map_entries = 2;
}
else if (bitspixel == 4)
{
- system_visual->visual.type = GDK_VISUAL_STATIC_COLOR;
- system_visual->xvisual->map_entries = 16;
+ system_visual->type = GDK_VISUAL_STATIC_COLOR;
+ map_entries = 16;
}
else if (bitspixel == 8)
{
- system_visual->visual.type = GDK_VISUAL_STATIC_COLOR;
- system_visual->xvisual->map_entries = 256;
+ system_visual->type = GDK_VISUAL_STATIC_COLOR;
+ map_entries = 256;
}
else if (bitspixel == 16)
{
- system_visual->visual.type = GDK_VISUAL_TRUE_COLOR;
+ system_visual->type = GDK_VISUAL_TRUE_COLOR;
#if 1
/* This code by Mike Enright,
* see http://www.users.cts.com/sd/m/menright/display.html
@@ -157,9 +196,9 @@ _gdk_visual_init (void)
{
/* It's 555 */
bitspixel = 15;
- system_visual->visual.red_mask = 0x00007C00;
- system_visual->visual.green_mask = 0x000003E0;
- system_visual->visual.blue_mask = 0x0000001F;
+ system_visual->red_mask = 0x00007C00;
+ system_visual->green_mask = 0x000003E0;
+ system_visual->blue_mask = 0x0000001F;
}
else
{
@@ -178,75 +217,74 @@ _gdk_visual_init (void)
allmasks/=2;
}
bitspixel = k;
- system_visual->visual.red_mask = bmi.u.fields[0];
- system_visual->visual.green_mask = bmi.u.fields[1];
- system_visual->visual.blue_mask = bmi.u.fields[2];
+ system_visual->red_mask = bmi.u.fields[0];
+ system_visual->green_mask = bmi.u.fields[1];
+ system_visual->blue_mask = bmi.u.fields[2];
}
#else
/* Old, incorrect (but still working) code. */
#if 0
- system_visual->visual.red_mask = 0x0000F800;
- system_visual->visual.green_mask = 0x000007E0;
- system_visual->visual.blue_mask = 0x0000001F;
+ system_visual->red_mask = 0x0000F800;
+ system_visual->green_mask = 0x000007E0;
+ system_visual->blue_mask = 0x0000001F;
#else
- system_visual->visual.red_mask = 0x00007C00;
- system_visual->visual.green_mask = 0x000003E0;
- system_visual->visual.blue_mask = 0x0000001F;
+ system_visual->red_mask = 0x00007C00;
+ system_visual->green_mask = 0x000003E0;
+ system_visual->blue_mask = 0x0000001F;
#endif
#endif
}
else if (bitspixel == 24 || bitspixel == 32)
{
bitspixel = 24;
- system_visual->visual.type = GDK_VISUAL_TRUE_COLOR;
- system_visual->visual.red_mask = 0x00FF0000;
- system_visual->visual.green_mask = 0x0000FF00;
- system_visual->visual.blue_mask = 0x000000FF;
+ system_visual->type = GDK_VISUAL_TRUE_COLOR;
+ system_visual->red_mask = 0x00FF0000;
+ system_visual->green_mask = 0x0000FF00;
+ system_visual->blue_mask = 0x000000FF;
}
else
g_error ("_gdk_visual_init: unsupported BITSPIXEL: %d\n", bitspixel);
- system_visual->visual.depth = bitspixel;
- system_visual->visual.byte_order = GDK_LSB_FIRST;
- system_visual->visual.bits_per_rgb = 42; /* Not used? */
+ system_visual->depth = bitspixel;
+ system_visual->byte_order = GDK_LSB_FIRST;
+ system_visual->bits_per_rgb = 42; /* Not used? */
- if ((system_visual->visual.type == GDK_VISUAL_TRUE_COLOR) ||
- (system_visual->visual.type == GDK_VISUAL_DIRECT_COLOR))
+ if ((system_visual->type == GDK_VISUAL_TRUE_COLOR) ||
+ (system_visual->type == GDK_VISUAL_DIRECT_COLOR))
{
- gdk_visual_decompose_mask (system_visual->visual.red_mask,
- &system_visual->visual.red_shift,
- &system_visual->visual.red_prec);
-
- gdk_visual_decompose_mask (system_visual->visual.green_mask,
- &system_visual->visual.green_shift,
- &system_visual->visual.green_prec);
-
- gdk_visual_decompose_mask (system_visual->visual.blue_mask,
- &system_visual->visual.blue_shift,
- &system_visual->visual.blue_prec);
- system_visual->xvisual->map_entries =
- 1 << (MAX (system_visual->visual.red_prec,
- MAX (system_visual->visual.green_prec,
- system_visual->visual.blue_prec)));
+ gdk_visual_decompose_mask (system_visual->red_mask,
+ &system_visual->red_shift,
+ &system_visual->red_prec);
+
+ gdk_visual_decompose_mask (system_visual->green_mask,
+ &system_visual->green_shift,
+ &system_visual->green_prec);
+
+ gdk_visual_decompose_mask (system_visual->blue_mask,
+ &system_visual->blue_shift,
+ &system_visual->blue_prec);
+ map_entries = 1 << (MAX (system_visual->red_prec,
+ MAX (system_visual->green_prec,
+ system_visual->blue_prec)));
}
else
{
- system_visual->visual.red_mask = 0;
- system_visual->visual.red_shift = 0;
- system_visual->visual.red_prec = 0;
+ system_visual->red_mask = 0;
+ system_visual->red_shift = 0;
+ system_visual->red_prec = 0;
- system_visual->visual.green_mask = 0;
- system_visual->visual.green_shift = 0;
- system_visual->visual.green_prec = 0;
+ system_visual->green_mask = 0;
+ system_visual->green_shift = 0;
+ system_visual->green_prec = 0;
- system_visual->visual.blue_mask = 0;
- system_visual->visual.blue_shift = 0;
- system_visual->visual.blue_prec = 0;
+ system_visual->blue_mask = 0;
+ system_visual->blue_shift = 0;
+ system_visual->blue_prec = 0;
}
- system_visual->visual.colormap_size = system_visual->xvisual->map_entries;
+ system_visual->colormap_size = map_entries;
- available_depths[0] = system_visual->visual.depth;
- available_types[0] = system_visual->visual.type;
+ available_depths[0] = system_visual->depth;
+ available_types[0] = system_visual->type;
}
gint
@@ -276,7 +314,7 @@ gdk_visual_get_best (void)
GdkVisual*
gdk_visual_get_best_with_depth (gint depth)
{
- if (depth == system_visual->visual.depth)
+ if (depth == system_visual->depth)
return (GdkVisual*) system_visual;
else
return NULL;
@@ -285,8 +323,8 @@ gdk_visual_get_best_with_depth (gint depth)
GdkVisual*
gdk_visual_get_best_with_type (GdkVisualType visual_type)
{
- if (visual_type == system_visual->visual.type)
- return (GdkVisual*) system_visual;
+ if (visual_type == system_visual->type)
+ return system_visual;
else
return NULL;
}
@@ -295,9 +333,8 @@ GdkVisual*
gdk_visual_get_best_with_both (gint depth,
GdkVisualType visual_type)
{
- if ((depth == system_visual->visual.depth) &&
- (visual_type == system_visual->visual.type))
- return (GdkVisual*) system_visual;
+ if ((depth == system_visual->depth) && (visual_type == system_visual->type))
+ return system_visual;
else
return NULL;
}
@@ -324,15 +361,6 @@ gdk_list_visuals (void)
return g_list_append (NULL, (gpointer) system_visual);
}
-GdkVisual*
-gdk_visual_lookup (Visual *xvisual)
-{
- if (system_visual->xvisual == xvisual)
- return (GdkVisual *) system_visual;
- else
- return NULL;
-}
-
static void
gdk_visual_decompose_mask (gulong mask,
gint *shift,
diff --git a/gdk/win32/gdkwin32.h b/gdk/win32/gdkwin32.h
index 3d7a160f52..ee11e58952 100644
--- a/gdk/win32/gdkwin32.h
+++ b/gdk/win32/gdkwin32.h
@@ -47,12 +47,8 @@ G_BEGIN_DECLS
#define GDK_ROOT_PARENT() ((GdkWindow *) _gdk_parent_root)
#define GDK_WINDOW_HWND(win) (GDK_DRAWABLE_IMPL_WIN32(((GdkWindowObject *)win)->impl)->handle)
#define GDK_PIXMAP_HBITMAP(pixmap) (GDK_DRAWABLE_IMPL_WIN32(((GdkPixmapObject *)pixmap)->impl)->handle)
-#define GDK_DRAWABLE_HANDLE(win) (GDK_IS_WINDOW (win) ? (GDK_WINDOW_HWND (win)) : (GDK_PIXMAP_HBITMAP (win)))
-#define GDK_IMAGE_HBM(image) (((GdkImagePrivateWin32 *) GDK_IMAGE (image)->windowing_data)->hbm)
-#define GDK_COLORMAP_PRIVATE_DATA(cmap) ((GdkColormapPrivateWin32 *) GDK_COLORMAP (cmap)->windowing_data)
-#define GDK_COLORMAP_WIN32COLORMAP(cmap) (((GdkColormapPrivateWin32 *)GDK_COLORMAP (cmap)->windowing_data)->xcolormap)
-#define GDK_VISUAL_XVISUAL(vis) (((GdkVisualPrivate *) vis)->xvisual)
-
+#define GDK_DRAWABLE_IMPL_WIN32_HANDLE(d) (((GdkDrawableImplWin32 *) d)->handle)
+#define GDK_DRAWABLE_HANDLE(win) (GDK_IS_WINDOW (win) ? GDK_WINDOW_HWND (win) : (GDK_IS_PIXMAP (win) ? GDK_PIXMAP_HBITMAP (win) : (GDK_IS_DRAWABLE_IMPL_WIN32 (win) ? GDK_DRAWABLE_IMPL_WIN32_HANDLE (win) : 0)))
#else
/* definition for exported 'internals' go here */
#define GDK_WINDOW_HWND(d) (gdk_win32_drawable_get_handle (d))
@@ -65,8 +61,8 @@ G_BEGIN_DECLS
/* Return the Gdk* for a particular HANDLE */
gpointer gdk_win32_handle_table_lookup (GdkNativeWindow handle);
-/* Translate from drawable to windows handle */
-HWND gdk_win32_drawable_get_handle (GdkDrawable *drawable);
+/* Translate from drawable to Windows handle */
+HGDIOBJ gdk_win32_drawable_get_handle (GdkDrawable *drawable);
/* Return a device context to draw in a drawable, given a GDK GC,
* and a mask indicating which GC values might be used (for efficiency,
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index 4a331243ce..9b051316db 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -1,6 +1,6 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- * Copyright (C) 1998-1999 Tor Lillqvist
+ * Copyright (C) 1998-2002 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -154,12 +154,10 @@ static GdkColormap*
gdk_window_impl_win32_get_colormap (GdkDrawable *drawable)
{
GdkDrawableImplWin32 *drawable_impl;
- GdkWindowImplWin32 *window_impl;
g_return_val_if_fail (GDK_IS_WINDOW_IMPL_WIN32 (drawable), NULL);
drawable_impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
- window_impl = GDK_WINDOW_IMPL_WIN32 (drawable);
if (!((GdkWindowObject *) drawable_impl->wrapper)->input_only &&
drawable_impl->colormap == NULL)
@@ -245,6 +243,8 @@ _gdk_windowing_window_init (void)
draw_impl->handle = gdk_root_window;
draw_impl->wrapper = GDK_DRAWABLE (private);
+ draw_impl->colormap = gdk_colormap_get_system ();
+ gdk_colormap_ref (draw_impl->colormap);
private->window_type = GDK_WINDOW_ROOT;
private->depth = gdk_visual_get_system ()->depth;
@@ -299,7 +299,7 @@ RegisterGdkClass (GdkWindowType wtype)
static WNDCLASSEX wcl;
ATOM klass = 0;
- wcl.cbSize = sizeof(WNDCLASSEX);
+ wcl.cbSize = sizeof (WNDCLASSEX);
wcl.style = 0; /* DON'T set CS_<H,V>REDRAW. It causes total redraw
* on WM_SIZE and WM_MOVE. Flicker, Performance!
*/
@@ -338,22 +338,22 @@ RegisterGdkClass (GdkWindowType wtype)
#define ONCE_PER_CLASS() \
wcl.hIcon = CopyIcon (hAppIcon); \
wcl.hIconSm = CopyIcon (hAppIcon); \
- wcl.hbrBackground = NULL; /* CreateSolidBrush (RGB (0,0,0)); */ \
+ wcl.hbrBackground = NULL; \
wcl.hCursor = LoadCursor (NULL, IDC_ARROW);
switch (wtype)
- {
- case GDK_WINDOW_TOPLEVEL:
- if (0 == klassTOPLEVEL)
- {
- wcl.lpszClassName = "gdkWindowToplevel";
-
- ONCE_PER_CLASS();
- klassTOPLEVEL = RegisterClassEx (&wcl);
- }
- klass = klassTOPLEVEL;
- break;
-
+ {
+ case GDK_WINDOW_TOPLEVEL:
+ if (0 == klassTOPLEVEL)
+ {
+ wcl.lpszClassName = "gdkWindowToplevel";
+
+ ONCE_PER_CLASS();
+ klassTOPLEVEL = RegisterClassEx (&wcl);
+ }
+ klass = klassTOPLEVEL;
+ break;
+
case GDK_WINDOW_CHILD:
if (0 == klassCHILD)
{
@@ -365,34 +365,34 @@ RegisterGdkClass (GdkWindowType wtype)
}
klass = klassCHILD;
break;
-
- case GDK_WINDOW_DIALOG:
- if (0 == klassDIALOG)
- {
- wcl.lpszClassName = "gdkWindowDialog";
- wcl.style |= CS_SAVEBITS;
- ONCE_PER_CLASS();
- klassDIALOG = RegisterClassEx (&wcl);
- }
- klass = klassDIALOG;
- break;
-
- case GDK_WINDOW_TEMP:
- if (0 == klassTEMP)
- {
- wcl.lpszClassName = "gdkWindowTemp";
- wcl.style |= CS_SAVEBITS;
- ONCE_PER_CLASS();
- klassTEMP = RegisterClassEx (&wcl);
- }
- klass = klassTEMP;
- break;
-
- default:
- g_assert_not_reached ();
- break;
- }
-
+
+ case GDK_WINDOW_DIALOG:
+ if (0 == klassDIALOG)
+ {
+ wcl.lpszClassName = "gdkWindowDialog";
+ wcl.style |= CS_SAVEBITS;
+ ONCE_PER_CLASS();
+ klassDIALOG = RegisterClassEx (&wcl);
+ }
+ klass = klassDIALOG;
+ break;
+
+ case GDK_WINDOW_TEMP:
+ if (0 == klassTEMP)
+ {
+ wcl.lpszClassName = "gdkWindowTemp";
+ wcl.style |= CS_SAVEBITS;
+ ONCE_PER_CLASS();
+ klassTEMP = RegisterClassEx (&wcl);
+ }
+ klass = klassTEMP;
+ break;
+
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
if (klass == 0)
{
WIN32_API_FAILED ("RegisterClassEx");
@@ -406,19 +406,15 @@ gdk_window_new (GdkWindow *parent,
GdkWindowAttr *attributes,
gint attributes_mask)
{
+ HANDLE hparent;
+ ATOM klass = 0;
+ DWORD dwStyle, dwExStyle;
+ RECT rect;
GdkWindow *window;
GdkWindowObject *private;
GdkWindowImplWin32 *impl;
GdkDrawableImplWin32 *draw_impl;
-
GdkVisual *visual;
-
- HANDLE hparent;
- ATOM klass = 0;
- DWORD dwStyle, dwExStyle;
- RECT rect;
- Visual *xvisual;
-
int width, height;
int x, y;
char *title;
@@ -485,7 +481,6 @@ gdk_window_new (GdkWindow *parent,
visual = attributes->visual;
else
visual = gdk_visual_get_system ();
- xvisual = ((GdkVisualPrivate*) visual)->xvisual;
if (attributes_mask & GDK_WA_TITLE)
title = attributes->title;
@@ -515,19 +510,7 @@ gdk_window_new (GdkWindow *parent,
}
else
{
- if ((((GdkVisualPrivate*)gdk_visual_get_system ())->xvisual) == xvisual)
- {
- draw_impl->colormap = gdk_colormap_get_system ();
- gdk_colormap_ref (draw_impl->colormap);
- GDK_NOTE (MISC, g_print ("...using system colormap %p\n",
- draw_impl->colormap));
- }
- else
- {
- draw_impl->colormap = gdk_colormap_new (visual, FALSE);
- GDK_NOTE (MISC, g_print ("...using new colormap %p\n",
- draw_impl->colormap));
- }
+ draw_impl->colormap = gdk_colormap_get_system ();
}
}
else
@@ -636,9 +619,9 @@ gdk_window_new (GdkWindow *parent,
window);
if (GDK_WINDOW_HWND (window) != hwndNew)
{
- g_warning("gdk_window_new: gdk_event_translate::WM_CREATE (%#x, %#x) HWND mismatch.",
- (guint) GDK_WINDOW_HWND (window),
- (guint) hwndNew);
+ g_warning("gdk_window_new: gdk_event_translate::WM_CREATE (%p, %p) HWND mismatch.",
+ GDK_WINDOW_HWND (window),
+ hwndNew);
/* HB: IHMO due to a race condition the handle was increased by
* one, which causes much trouble. Because I can't find the
@@ -661,12 +644,12 @@ gdk_window_new (GdkWindow *parent,
#endif
GDK_NOTE (MISC,
- g_print ("... \"%s\" %dx%d@+%d+%d %#x = %#x\n"
+ g_print ("... \"%s\" %dx%d@+%d+%d %p = %p\n"
"... locale %#x codepage %d\n",
mbtitle,
width, height, (x == CW_USEDEFAULT ? -9999 : x), y,
- (guint) hparent,
- (guint) GDK_WINDOW_HWND (window),
+ hparent,
+ GDK_WINDOW_HWND (window),
(guint) impl->input_locale,
(guint) impl->charset_info.ciACP));
@@ -756,8 +739,8 @@ _gdk_windowing_window_destroy (GdkWindow *window,
g_return_if_fail (GDK_IS_WINDOW (window));
- GDK_NOTE (MISC, g_print ("_gdk_windowing_window_destroy %#x\n",
- (guint) GDK_WINDOW_HWND (window)));
+ GDK_NOTE (MISC, g_print ("_gdk_windowing_window_destroy %p\n",
+ GDK_WINDOW_HWND (window)));
if (private->extension_events != 0)
gdk_input_window_destroy (window);
@@ -797,15 +780,15 @@ gdk_window_destroy_notify (GdkWindow *window)
g_return_if_fail (GDK_IS_WINDOW (window));
GDK_NOTE (EVENTS,
- g_print ("gdk_window_destroy_notify: %#x %s\n",
- (guint) GDK_WINDOW_HWND (window),
+ g_print ("gdk_window_destroy_notify: %p %s\n",
+ GDK_WINDOW_HWND (window),
(GDK_WINDOW_DESTROYED (window) ? "(destroyed)" : "")));
if (!GDK_WINDOW_DESTROYED (window))
{
if (GDK_WINDOW_TYPE(window) != GDK_WINDOW_FOREIGN)
- g_warning ("window %#x unexpectedly destroyed",
- (guint) GDK_WINDOW_HWND (window));
+ g_warning ("window %p unexpectedly destroyed",
+ GDK_WINDOW_HWND (window));
_gdk_window_destroy (window, TRUE);
}
@@ -824,8 +807,8 @@ show_window_internal (GdkWindow *window,
if (!private->destroyed)
{
- GDK_NOTE (MISC, g_print ("gdk_window_show: %#x\n",
- (guint) GDK_WINDOW_HWND (window)));
+ GDK_NOTE (MISC, g_print ("gdk_window_show: %p\n",
+ GDK_WINDOW_HWND (window)));
private->state &= (~GDK_WINDOW_STATE_WITHDRAWN);
if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TEMP)
@@ -897,8 +880,8 @@ gdk_window_hide (GdkWindow *window)
private = (GdkWindowObject*) window;
if (!private->destroyed)
{
- GDK_NOTE (MISC, g_print ("gdk_window_hide: %#x\n",
- (guint) GDK_WINDOW_HWND (window)));
+ GDK_NOTE (MISC, g_print ("gdk_window_hide: %p\n",
+ GDK_WINDOW_HWND (window)));
private->state |= GDK_WINDOW_STATE_WITHDRAWN;
@@ -929,8 +912,8 @@ gdk_window_withdraw (GdkWindow *window)
private = (GdkWindowObject*) window;
if (!private->destroyed)
{
- GDK_NOTE (MISC, g_print ("gdk_window_withdraw: %#x\n",
- (guint) GDK_WINDOW_HWND (window)));
+ GDK_NOTE (MISC, g_print ("gdk_window_withdraw: %p\n",
+ GDK_WINDOW_HWND (window)));
gdk_window_hide (window); /* ??? */
}
@@ -1047,8 +1030,8 @@ gdk_window_move_resize (GdkWindow *window,
DWORD dwStyle;
DWORD dwExStyle;
- GDK_NOTE (MISC, g_print ("gdk_window_move_resize: %#x %dx%d@+%d+%d\n",
- (guint) GDK_WINDOW_HWND (window),
+ GDK_NOTE (MISC, g_print ("gdk_window_move_resize: %p %dx%d@+%d+%d\n",
+ GDK_WINDOW_HWND (window),
width, height, x, y));
if (GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD)
@@ -1065,8 +1048,8 @@ gdk_window_move_resize (GdkWindow *window,
if (!AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle))
WIN32_API_FAILED ("AdjustWindowRectEx");
- GDK_NOTE (MISC, g_print ("...SetWindowPos(%#x,%ldx%ld@+%ld+%ld)\n",
- (guint) GDK_WINDOW_HWND (window),
+ GDK_NOTE (MISC, g_print ("...SetWindowPos(%p,%ldx%ld@+%ld+%ld)\n",
+ GDK_WINDOW_HWND (window),
rect.right - rect.left, rect.bottom - rect.top,
rect.left, rect.top));
if (!SetWindowPos (GDK_WINDOW_HWND (window), NULL,
@@ -1104,9 +1087,9 @@ gdk_window_reparent (GdkWindow *window,
if (!GDK_WINDOW_DESTROYED (window) && !GDK_WINDOW_DESTROYED (new_parent))
{
- GDK_NOTE (MISC, g_print ("gdk_window_reparent: %#x %#x\n",
- (guint) GDK_WINDOW_HWND (window),
- (guint) GDK_WINDOW_HWND (new_parent)));
+ GDK_NOTE (MISC, g_print ("gdk_window_reparent: %p %p\n",
+ GDK_WINDOW_HWND (window),
+ GDK_WINDOW_HWND (new_parent)));
if (!SetParent (GDK_WINDOW_HWND (window),
GDK_WINDOW_HWND (new_parent)))
WIN32_API_FAILED ("SetParent");
@@ -1160,8 +1143,8 @@ _gdk_windowing_window_clear_area (GdkWindow *window,
if (height == 0)
height = impl->height - y;
GDK_NOTE (MISC, g_print ("_gdk_windowing_window_clear_area: "
- "%#x %dx%d@+%d+%d\n",
- (guint) GDK_WINDOW_HWND (window),
+ "%p %dx%d@+%d+%d\n",
+ GDK_WINDOW_HWND (window),
width, height, x, y));
hdc = GetDC (GDK_WINDOW_HWND (window));
IntersectClipRect (hdc, x, y, x + width + 1, y + height + 1);
@@ -1186,8 +1169,8 @@ _gdk_windowing_window_clear_area_e (GdkWindow *window,
RECT rect;
GDK_NOTE (MISC, g_print ("_gdk_windowing_window_clear_area_e: "
- "%#x %dx%d@+%d+%d\n",
- (guint) GDK_WINDOW_HWND (window),
+ "%p %dx%d@+%d+%d\n",
+ GDK_WINDOW_HWND (window),
width, height, x, y));
rect.left = x;
@@ -1208,8 +1191,8 @@ gdk_window_raise (GdkWindow *window)
if (!GDK_WINDOW_DESTROYED (window))
{
- GDK_NOTE (MISC, g_print ("gdk_window_raise: %#x\n",
- (guint) GDK_WINDOW_HWND (window)));
+ GDK_NOTE (MISC, g_print ("gdk_window_raise: %p\n",
+ GDK_WINDOW_HWND (window)));
if (!BringWindowToTop (GDK_WINDOW_HWND (window)))
WIN32_API_FAILED ("BringWindowToTop");
@@ -1224,8 +1207,8 @@ gdk_window_lower (GdkWindow *window)
if (!GDK_WINDOW_DESTROYED (window))
{
- GDK_NOTE (MISC, g_print ("gdk_window_lower: %#x\n",
- (guint) GDK_WINDOW_HWND (window)));
+ GDK_NOTE (MISC, g_print ("gdk_window_lower: %p\n",
+ GDK_WINDOW_HWND (window)));
if (!SetWindowPos (GDK_WINDOW_HWND (window), HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE))
@@ -1258,8 +1241,8 @@ gdk_window_set_hints (GdkWindow *window,
impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
- GDK_NOTE (MISC, g_print ("gdk_window_set_hints: %#x %dx%d..%dx%d @+%d+%d\n",
- (guint) GDK_WINDOW_HWND (window),
+ GDK_NOTE (MISC, g_print ("gdk_window_set_hints: %p %dx%d..%dx%d @+%d+%d\n",
+ GDK_WINDOW_HWND (window),
min_width, min_height, max_width, max_height,
x, y));
@@ -1479,8 +1462,8 @@ gdk_window_set_title (GdkWindow *window,
if (!title[0])
title = ".";
- GDK_NOTE (MISC, g_print ("gdk_window_set_title: %#x %s\n",
- (guint) GDK_WINDOW_HWND (window), title));
+ GDK_NOTE (MISC, g_print ("gdk_window_set_title: %p %s\n",
+ GDK_WINDOW_HWND (window), title));
if (!GDK_WINDOW_DESTROYED (window))
{
@@ -1502,8 +1485,8 @@ gdk_window_set_role (GdkWindow *window,
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- GDK_NOTE (MISC, g_print ("gdk_window_set_role: %#x %s\n",
- (guint) GDK_WINDOW_HWND (window),
+ GDK_NOTE (MISC, g_print ("gdk_window_set_role: %p %s\n",
+ GDK_WINDOW_HWND (window),
(role ? role : "NULL")));
/* XXX */
}
@@ -1518,9 +1501,9 @@ gdk_window_set_transient_for (GdkWindow *window,
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- GDK_NOTE (MISC, g_print ("gdk_window_set_transient_for: %#x %#x\n",
- (guint) GDK_WINDOW_HWND (window),
- (guint) GDK_WINDOW_HWND (parent)));
+ GDK_NOTE (MISC, g_print ("gdk_window_set_transient_for: %p %p\n",
+ GDK_WINDOW_HWND (window),
+ GDK_WINDOW_HWND (parent)));
if (GDK_WINDOW_DESTROYED (window) || GDK_WINDOW_DESTROYED (parent))
return;
@@ -1561,8 +1544,8 @@ gdk_window_set_background (GdkWindow *window,
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- GDK_NOTE (MISC, g_print ("gdk_window_set_background: %#x %s\n",
- (guint) GDK_WINDOW_HWND (window),
+ GDK_NOTE (MISC, g_print ("gdk_window_set_background: %p %s\n",
+ GDK_WINDOW_HWND (window),
gdk_win32_color_to_string (color)));
private->bg_color = *color;
@@ -1634,9 +1617,9 @@ gdk_window_set_cursor (GdkWindow *window,
else
hcursor = cursor_private->hcursor;
- GDK_NOTE (MISC, g_print ("gdk_window_set_cursor: %#x %#x\n",
- (guint) GDK_WINDOW_HWND (window),
- (guint) hcursor));
+ GDK_NOTE (MISC, g_print ("gdk_window_set_cursor: %p %p\n",
+ GDK_WINDOW_HWND (window),
+ hcursor));
/* First get the old cursor, if any (we wait to free the old one
* since it may be the current cursor set in the Win32 API right
@@ -1656,8 +1639,8 @@ gdk_window_set_cursor (GdkWindow *window,
*/
if ((impl->hcursor = CopyCursor (hcursor)) == NULL)
WIN32_API_FAILED ("CopyCursor");
- GDK_NOTE (MISC, g_print ("...CopyCursor (%#x) = %#x\n",
- (guint) hcursor, (guint) impl->hcursor));
+ GDK_NOTE (MISC, g_print ("...CopyCursor (%p) = %p\n",
+ hcursor, impl->hcursor));
}
/* Set new cursor in all cases if we're over our window */
@@ -1673,8 +1656,8 @@ gdk_window_set_cursor (GdkWindow *window,
if (GetCursor() == hprevcursor)
SetCursor (NULL);
- GDK_NOTE (MISC, g_print ("...DestroyCursor (%#x)\n",
- (guint) hprevcursor));
+ GDK_NOTE (MISC, g_print ("...DestroyCursor (%p)\n",
+ hprevcursor));
if (!DestroyCursor (hprevcursor))
WIN32_API_FAILED ("DestroyCursor");
@@ -1744,8 +1727,8 @@ gdk_window_get_origin (GdkWindow *window,
if (y)
*y = ty;
- GDK_NOTE (MISC, g_print ("gdk_window_get_origin: %#x: +%d+%d\n",
- (guint) GDK_WINDOW_HWND (window),
+ GDK_NOTE (MISC, g_print ("gdk_window_get_origin: %p: +%d+%d\n",
+ GDK_WINDOW_HWND (window),
tx, ty));
return return_val;
}
@@ -1763,38 +1746,17 @@ gdk_window_get_root_origin (GdkWindow *window,
gint *x,
gint *y)
{
- GdkWindowObject *rover;
- POINT pt;
+ GdkRectangle rect;
- g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
- rover = (GdkWindowObject*) window;
- if (x)
- *x = 0;
- if (y)
- *y = 0;
-
- if (GDK_WINDOW_DESTROYED (window))
- return;
-
- while (rover->parent && ((GdkWindowObject*) rover->parent)->parent)
- rover = (GdkWindowObject *) rover->parent;
- if (rover->destroyed)
- return;
+ gdk_window_get_frame_extents (window, &rect);
- pt.x = 0;
- pt.y = 0;
- ClientToScreen (GDK_WINDOW_HWND (rover), &pt);
if (x)
- *x = pt.x;
- if (y)
- *y = pt.y;
+ *x = rect.x;
- GDK_NOTE (MISC, g_print ("gdk_window_get_root_origin: %#x: (%#x) +%ld+%ld\n",
- (guint) GDK_WINDOW_HWND (window),
- (guint) GDK_WINDOW_HWND (rover),
- pt.x, pt.y));
+ if (y)
+ *y = rect.y;
}
void
@@ -1822,6 +1784,7 @@ gdk_window_get_frame_extents (GdkWindow *window,
private = (GdkWindowObject*) private->parent;
hwnd = GDK_WINDOW_HWND (window);
+
/* find the frame window */
while (HWND_DESKTOP != GetParent (hwnd))
{
@@ -1954,9 +1917,9 @@ _gdk_windowing_window_at_pointer (GdkScreen *screen,
*win_y = point.y - rect.top;
}
- GDK_NOTE (MISC, g_print ("gdk_window_at_pointer: +%ld+%ld %#x%s\n",
+ GDK_NOTE (MISC, g_print ("gdk_window_at_pointer: +%ld+%ld %p%s\n",
point.x, point.y,
- (guint) hwnd,
+ hwnd,
(window == NULL ? " NULL" : "")));
return window;
@@ -1997,8 +1960,8 @@ gdk_window_shape_combine_mask (GdkWindow *window,
if (!mask)
{
- GDK_NOTE (MISC, g_print ("gdk_window_shape_combine_mask: %#x none\n",
- (guint) GDK_WINDOW_HWND (window)));
+ GDK_NOTE (MISC, g_print ("gdk_window_shape_combine_mask: %p none\n",
+ GDK_WINDOW_HWND (window)));
SetWindowRgn (GDK_WINDOW_HWND (window), NULL, TRUE);
}
else
@@ -2009,11 +1972,11 @@ gdk_window_shape_combine_mask (GdkWindow *window,
RECT rect;
/* Convert mask bitmap to region */
- hrgn = BitmapToRegion (GDK_WINDOW_HWND (mask));
+ hrgn = _gdk_win32_bitmap_to_region (mask);
- GDK_NOTE (MISC, g_print ("gdk_window_shape_combine_mask: %#x %#x\n",
- (guint) GDK_WINDOW_HWND (window),
- (guint) GDK_WINDOW_HWND (mask)));
+ GDK_NOTE (MISC, g_print ("gdk_window_shape_combine_mask: %p %p\n",
+ GDK_WINDOW_HWND (window),
+ GDK_WINDOW_HWND (mask)));
/* SetWindowRgn wants window (not client) coordinates */
dwStyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);
@@ -2027,9 +1990,9 @@ gdk_window_shape_combine_mask (GdkWindow *window,
/* If this is a top-level window, add the title bar to the region */
if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_TOPLEVEL)
{
- CombineRgn (hrgn, hrgn,
- CreateRectRgn (0, 0, rect.right - rect.left, -rect.top),
- RGN_OR);
+ HRGN tmp = CreateRectRgn (0, 0, rect.right - rect.left, -rect.top);
+ CombineRgn (hrgn, hrgn, tmp, RGN_OR);
+ DeleteObject (tmp);
}
SetWindowRgn (GDK_WINDOW_HWND (window), hrgn, TRUE);
@@ -2451,7 +2414,7 @@ gdk_window_stick (GdkWindow *window)
/* "stick" means stick to all desktops _and_ do not scroll with the
* viewport. i.e. glue to the monitor glass in all cases.
*/
- g_warning ("gdk_window_stick (%#x) ???", (guint) GDK_WINDOW_HWND (window));
+ g_warning ("gdk_window_stick (%p) ???", GDK_WINDOW_HWND (window));
}
else
{
@@ -2472,7 +2435,7 @@ gdk_window_unstick (GdkWindow *window)
if (GDK_WINDOW_IS_MAPPED (window))
{
- g_warning ("gdk_window_unstick (%#x) ???", (guint) GDK_WINDOW_HWND (window));
+ g_warning ("gdk_window_unstick (%p) ???", GDK_WINDOW_HWND (window));
}
else
{
@@ -2583,8 +2546,8 @@ gdk_window_set_type_hint (GdkWindow *window,
* XXX ???
*/
GDK_NOTE (MISC,
- g_print ("gdk_window_set_type_hint (%#x)\n",
- (guint) GDK_WINDOW_HWND (window)));
+ g_print ("gdk_window_set_type_hint (%p)\n",
+ GDK_WINDOW_HWND (window)));
}
void
diff --git a/gdk/win32/gdkwindow-win32.h b/gdk/win32/gdkwindow-win32.h
index 65325aaa52..e57b088dda 100644
--- a/gdk/win32/gdkwindow-win32.h
+++ b/gdk/win32/gdkwindow-win32.h
@@ -47,7 +47,8 @@ struct _GdkWin32PositionInfo
gboolean mapped : 1;
gboolean no_bg : 1; /* Set when the window background
* is temporarily unset during resizing
- * and scaling */
+ * and scaling
+ */
GdkRectangle clip_rect; /* visible rectangle of window */
};