Commit eec6970f authored by Tor Lillqvist's avatar Tor Lillqvist
Browse files

Intermediate commit. I go to bed now.

parent 3a330a3d
......@@ -293,10 +293,10 @@ alloc_color(Colormap colormap,
*/
static void
XFreeColors(Colormap colormap,
gulong *pixels,
gint npixels,
gulong planes)
free_colors (Colormap colormap,
gulong *pixels,
gint npixels,
gulong planes)
{
gint i;
PALETTEENTRY entries[256];
......@@ -329,11 +329,11 @@ XFreeColors(Colormap colormap,
if (SetPaletteEntries (colormap->palette, lowestpixel,
highestpixel - lowestpixel + 1,
entries + lowestpixel) == 0)
g_warning ("XFreeColors: SetPaletteEntries failed");
g_warning ("free_colors: SetPaletteEntries failed");
#endif
colormap->stale = TRUE;
#if 0
g_print("XFreeColors %#x lowestpixel = %d, highestpixel = %d\n",
g_print("free_colors %#x lowestpixel = %d, highestpixel = %d\n",
colormap->palette, lowestpixel, highestpixel);
#endif
}
......@@ -358,7 +358,7 @@ XFreeColors(Colormap colormap,
static Colormap
create_colormap (HWND w,
Visual *visual,
int alloc)
gboolean alloc)
{
char logPalBuf[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)];
LOGPALETTE *logPalettePtr;
......@@ -420,7 +420,7 @@ create_colormap (HWND w,
*/
static void
XFreeColormap(Colormap colormap)
free_colormap(Colormap colormap)
{
if (!DeleteObject (colormap->palette))
......@@ -1304,7 +1304,7 @@ parse_color(Colormap map,
/* End of code from Tk8.0 */
static Colormap
DefaultColormap ()
default_colormap ()
{
static Colormap colormap;
gint i;
......@@ -1312,7 +1312,7 @@ DefaultColormap ()
if (colormap)
return colormap;
colormap = create_colormap ( NULL, NULL, AllocNone);
colormap = create_colormap ( NULL, NULL, FALSE);
return colormap;
}
......@@ -1321,18 +1321,18 @@ gdk_colormap_new (GdkVisual *visual,
gint private_cmap)
{
GdkColormap *colormap;
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
Visual *xvisual;
int size;
unsigned int i;
int i;
g_return_val_if_fail (visual != NULL, NULL);
private = g_new (GdkColormapPrivate, 1);
private = g_new (GdkColormapPrivateWin32, 1);
colormap = (GdkColormap*) private;
private->visual = visual;
private->ref_count = 1;
private->base.visual = visual;
private->base.ref_count = 1;
private->hash = NULL;
private->last_sync_time = 0;
......@@ -1354,7 +1354,7 @@ gdk_colormap_new (GdkVisual *visual,
private->private_val = private_cmap;
private->xcolormap = create_colormap (gdk_root_window, xvisual,
(private_cmap) ? (AllocAll) : (AllocNone));
private_cmap);
if (private_cmap)
{
......@@ -1387,7 +1387,7 @@ gdk_colormap_new (GdkVisual *visual,
case GDK_VISUAL_TRUE_COLOR:
private->private_val = FALSE;
private->xcolormap = create_colormap (gdk_root_window,
xvisual, AllocNone);
xvisual, FALSE);
break;
}
......@@ -1399,13 +1399,13 @@ gdk_colormap_new (GdkVisual *visual,
void
_gdk_colormap_real_destroy (GdkColormap *colormap)
{
GdkColormapPrivate *private = (GdkColormapPrivate*) colormap;
GdkColormapPrivateWin32 *private = (GdkColormapPrivateWin32 *) colormap;
g_return_if_fail (colormap != NULL);
g_return_if_fail (private->ref_count == 0);
g_return_if_fail (private->base.ref_count == 0);
gdk_colormap_remove (colormap);
XFreeColormap (private->xcolormap);
free_colormap (private->xcolormap);
if (private->hash)
g_hash_table_destroy (private->hash);
......@@ -1422,7 +1422,7 @@ gdk_colormap_sync (GdkColormap *colormap,
gboolean force)
{
time_t current_time;
GdkColormapPrivate *private = (GdkColormapPrivate *)colormap;
GdkColormapPrivateWin32 *private = (GdkColormapPrivateWin32 *) colormap;
XColor *xpalette;
gint nlookup;
gint i;
......@@ -1460,33 +1460,32 @@ gdk_colormap_sync (GdkColormap *colormap,
g_free (xpalette);
}
GdkColormap*
gdk_colormap_get_system (void)
{
static GdkColormap *colormap = NULL;
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
gint i;
if (!colormap)
{
private = g_new (GdkColormapPrivate, 1);
private = g_new (GdkColormapPrivateWin32, 1);
colormap = (GdkColormap*) private;
private->xcolormap = DefaultColormap ();
private->visual = gdk_visual_get_system ();
private->xcolormap = default_colormap ();
private->base.visual = gdk_visual_get_system ();
private->private_val = FALSE;
private->ref_count = 1;
private->base.ref_count = 1;
private->hash = NULL;
private->last_sync_time = 0;
private->info = NULL;
colormap->colors = NULL;
colormap->size = private->visual->colormap_size;
colormap->size = private->base.visual->colormap_size;
if ((private->visual->type == GDK_VISUAL_GRAYSCALE) ||
(private->visual->type == GDK_VISUAL_PSEUDO_COLOR))
if ((private->base.visual->type == GDK_VISUAL_GRAYSCALE) ||
(private->base.visual->type == GDK_VISUAL_PSEUDO_COLOR))
{
private->info = g_new0 (GdkColorInfo, colormap->size);
colormap->colors = g_new (GdkColor, colormap->size);
......@@ -1527,7 +1526,7 @@ void
gdk_colormap_change (GdkColormap *colormap,
gint ncolors)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
GdkVisual *visual;
XColor *palette;
gint shift;
......@@ -1539,8 +1538,8 @@ gdk_colormap_change (GdkColormap *colormap,
palette = g_new (XColor, ncolors);
private = (GdkColormapPrivate*) colormap;
switch (private->visual->type)
private = (GdkColormapPrivateWin32 *) colormap;
switch (private->base.visual->type)
{
case GDK_VISUAL_GRAYSCALE:
case GDK_VISUAL_PSEUDO_COLOR:
......@@ -1573,13 +1572,13 @@ gdk_colors_alloc (GdkColormap *colormap,
gulong *pixels,
gint npixels)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
gint return_val;
gint i;
g_return_val_if_fail (colormap != NULL, 0);
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
return_val = alloc_color_cells (private->xcolormap, contiguous,
planes, nplanes, pixels, npixels);
......@@ -1593,7 +1592,7 @@ gdk_colors_alloc (GdkColormap *colormap,
}
}
return return_val;
return return_val != 0;
}
gboolean
......@@ -1602,19 +1601,13 @@ gdk_color_parse (const gchar *spec,
{
Colormap xcolormap;
XColor xcolor;
gboolean return_val;
g_return_val_if_fail (spec != NULL, FALSE);
g_return_val_if_fail (color != NULL, FALSE);
xcolormap = DefaultColormap ();
if (parse_color (xcolormap, spec, color))
return_val = TRUE;
else
return_val = FALSE;
xcolormap = default_colormap ();
return return_val;
return parse_color (xcolormap, spec, color);
}
/* This is almost identical to gdk_colormap_free_colors.
......@@ -1626,7 +1619,7 @@ gdk_colors_free (GdkColormap *colormap,
gint in_npixels,
gulong planes)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
gulong *pixels;
gint npixels = 0;
gint i;
......@@ -1634,10 +1627,10 @@ gdk_colors_free (GdkColormap *colormap,
g_return_if_fail (colormap != NULL);
g_return_if_fail (in_pixels != NULL);
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
(private->visual->type != GDK_VISUAL_GRAYSCALE))
if ((private->base.visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
(private->base.visual->type != GDK_VISUAL_GRAYSCALE))
return;
pixels = g_new (gulong, in_npixels);
......@@ -1654,15 +1647,14 @@ gdk_colors_free (GdkColormap *colormap,
{
pixels[npixels++] = pixel;
if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
g_hash_table_remove (private->hash, &colormap->colors[in_pixels[i]]);
g_hash_table_remove (private->hash, &colormap->colors[pixel]);
private->info[pixel].flags = 0;
}
}
}
if (npixels)
XFreeColors (private->xcolormap, pixels, npixels, planes);
free_colors (private->xcolormap, pixels, npixels, planes);
g_free (pixels);
}
......@@ -1675,7 +1667,7 @@ gdk_colormap_free_colors (GdkColormap *colormap,
GdkColor *colors,
gint ncolors)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
gulong *pixels;
gint npixels = 0;
gint i;
......@@ -1683,10 +1675,10 @@ gdk_colormap_free_colors (GdkColormap *colormap,
g_return_if_fail (colormap != NULL);
g_return_if_fail (colors != NULL);
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
(private->visual->type != GDK_VISUAL_GRAYSCALE))
if ((private->base.visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
(private->base.visual->type != GDK_VISUAL_GRAYSCALE))
return;
pixels = g_new (gulong, ncolors);
......@@ -1703,13 +1695,13 @@ gdk_colormap_free_colors (GdkColormap *colormap,
{
pixels[npixels++] = pixel;
if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
g_hash_table_remove (private->hash, &colors[i]);
g_hash_table_remove (private->hash, &colormap->colors[pixel]);
private->info[pixel].flags = 0;
}
}
}
if (npixels)
XFreeColors (private->xcolormap, pixels, npixels, 0);
free_colors (private->xcolormap, pixels, npixels, 0);
g_free (pixels);
}
......@@ -1725,10 +1717,10 @@ gdk_colormap_alloc1 (GdkColormap *colormap,
GdkColor *color,
GdkColor *ret)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
XColor xcolor;
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
xcolor.peRed = color->red >> 8;
xcolor.peGreen = color->green >> 8;
......@@ -1772,12 +1764,12 @@ gdk_colormap_alloc_colors_writeable (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
gulong *pixels;
Status status;
gint i, index;
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
if (private->private_val)
{
......@@ -1802,8 +1794,8 @@ gdk_colormap_alloc_colors_writeable (GdkColormap *colormap,
else
{
pixels = g_new (gulong, ncolors);
/* Allocation of a writeable color cells */
status = alloc_color_cells (private->xcolormap, FALSE, NULL,
0, pixels, ncolors);
if (status)
......@@ -1830,13 +1822,13 @@ gdk_colormap_alloc_colors_private (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
gint i, index;
XColor *store = g_new (XColor, ncolors);
gint nstore = 0;
gint nremaining = 0;
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
index = -1;
/* First, store the colors we have room for */
......@@ -1892,6 +1884,7 @@ gdk_colormap_alloc_colors_private (GdkColormap *colormap,
{
colors[i] = colormap->colors[index];
private->info[index].ref_count++;
success[i] = TRUE;
nremaining--;
}
......@@ -1911,12 +1904,12 @@ gdk_colormap_alloc_colors_shared (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
gint i, index;
gint nremaining = 0;
gint nfailed = 0;
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
index = -1;
for (i=0; i<ncolors; i++)
......@@ -2003,12 +1996,12 @@ gdk_colormap_alloc_colors_pseudocolor (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
GdkColor *lookup_color;
gint i;
gint nremaining = 0;
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
/* Check for an exact match among previously allocated colors */
......@@ -2050,7 +2043,7 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
GdkVisual *visual;
gint i;
gint nremaining = 0;
......@@ -2059,14 +2052,14 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
g_return_val_if_fail (colormap != NULL, FALSE);
g_return_val_if_fail (colors != NULL, FALSE);
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
for (i=0; i<ncolors; i++)
{
success[i] = FALSE;
}
switch (private->visual->type)
switch (private->base.visual->type)
{
case GDK_VISUAL_PSEUDO_COLOR:
case GDK_VISUAL_GRAYSCALE:
......@@ -2079,7 +2072,7 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
break;
case GDK_VISUAL_TRUE_COLOR:
visual = private->visual;
visual = private->base.visual;
for (i=0; i<ncolors; i++)
{
......@@ -2111,13 +2104,13 @@ gboolean
gdk_color_change (GdkColormap *colormap,
GdkColor *color)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
XColor xcolor;
g_return_val_if_fail (colormap != NULL, FALSE);
g_return_val_if_fail (color != NULL, FALSE);
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
xcolor.peRed = color->red >> 8;
xcolor.peGreen = color->green >> 8;
......@@ -2184,13 +2177,13 @@ gdk_colormap_lookup (Colormap xcolormap)
static void
gdk_colormap_add (GdkColormap *cmap)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
if (!colormap_hash)
colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
(GCompareFunc) gdk_colormap_cmp);
private = (GdkColormapPrivate*) cmap;
private = (GdkColormapPrivateWin32 *) cmap;
g_hash_table_insert (colormap_hash, &private->xcolormap, cmap);
}
......@@ -2198,13 +2191,13 @@ gdk_colormap_add (GdkColormap *cmap)
static void
gdk_colormap_remove (GdkColormap *cmap)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
if (!colormap_hash)
colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
(GCompareFunc) gdk_colormap_cmp);
private = (GdkColormapPrivate*) cmap;
private = (GdkColormapPrivateWin32 *) cmap;
g_hash_table_remove (colormap_hash, &private->xcolormap);
}
......@@ -2223,7 +2216,7 @@ gdk_colormap_cmp (Colormap *a,
}
char *
gdk_color_to_string (GdkColor *color)
gdk_color_to_string (const GdkColor *color)
{
static char buf[100];
......
......@@ -20,7 +20,7 @@
#include "config.h"
#include "gdkcursor.h"
#include "gdkprivate.h"
#include "gdkwin32.h"
static const struct { const char *name; int type; } cursors[] = {
{ "x_cursor", 0 },
......@@ -109,7 +109,6 @@ gdk_cursor_new (GdkCursorType cursor_type)
GdkCursorPrivate *private;
GdkCursor *cursor;
HCURSOR xcursor;
int i;
for (i = 0; cursors[i].name != NULL && cursors[i].type != cursor_type; i++)
......@@ -235,9 +234,9 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
GDK_NOTE (MISC, g_print ("gdk_cursor_new_from_pixmap: "
"%#x (%dx%d) %#x (%dx%d) = %#x (%dx%d)\n",
source_private->xwindow,
GDK_DRAWABLE_XID (source),
source_private->width, source_private->height,
mask_private->xwindow,
GDK_DRAWABLE_XID (mask),
mask_private->width, mask_private->height,
xcursor, cursor_width, cursor_height));
......
......@@ -36,7 +36,7 @@
#include "gdkdnd.h"
#include "gdkproperty.h"
#include "gdkprivate.h"
#include "gdkx.h"
#include "gdkwin32.h"
#ifdef OLE2_DND
#include <ole2.h>
......@@ -671,7 +671,7 @@ gdk_dropfiles_filter (GdkXEvent *xev,
private = (GdkDragContextPrivate *) context;
context->protocol = GDK_DRAG_PROTO_WIN32_DROPFILES;
context->is_source = FALSE;
context->source_window = (GdkWindow *) gdk_root_parent;
context->source_window = gdk_parent_root;
context->dest_window = event->any.window;
gdk_window_ref (context->dest_window);
/* WM_DROPFILES drops are always file names */
......@@ -713,8 +713,8 @@ gdk_dropfiles_filter (GdkXEvent *xev,
}
g_string_append (result, "\015\012");
}
gdk_sel_prop_store ((GdkWindow *) gdk_root_parent,
text_uri_list_atom, 8, result->str, result->len + 1);
gdk_sel_prop_store (gdk_parent_root, text_uri_list_atom, 8,
result->str, result->len + 1);
DragFinish (hdrop);
......@@ -816,7 +816,7 @@ gdk_drag_find_window (GdkDragContext *context,
POINT pt;
GDK_NOTE (DND, g_print ("gdk_drag_find_window: %#x +%d+%d\n",
(drag_window ? drag_window_private->xwindow : 0),
(drag_window ? GDK_DRAWABLE_XID (drag_window) : 0),
x_root, y_root));
pt.x = x_root;
......@@ -911,7 +911,6 @@ gdk_destroy_filter (GdkXEvent *xev,
void
gdk_window_register_dnd (GdkWindow *window)
{
GdkDrawablePrivate *private = (GdkDrawablePrivate *) window;
#ifdef OLE2_DND
target_drag_context *context;
HRESULT hres;
......@@ -919,7 +918,8 @@ gdk_window_register_dnd (GdkWindow *window)
g_return_if_fail (window != NULL);
GDK_NOTE (DND, g_print ("gdk_window_register_dnd: %#x\n", private->xwindow));
GDK_NOTE (DND, g_print ("gdk_window_register_dnd: %#x\n",
GDK_DRAWABLE_XID (window)));
/* We always claim to accept dropped files, but in fact we might not,
* of course. This function is called in such a way that it cannot know
......@@ -927,7 +927,7 @@ gdk_window_register_dnd (GdkWindow *window)
* (in gtk, data of type text/uri-list) or not.
*/
gdk_window_add_filter (window, gdk_dropfiles_filter, NULL);
DragAcceptFiles (private->xwindow, TRUE);
DragAcceptFiles (GDK_DRAWABLE_XID (window), TRUE);
#ifdef OLE2_DND
/* Register for OLE2 d&d */
......@@ -937,7 +937,7 @@ gdk_window_register_dnd (GdkWindow *window)
g_warning ("gdk_window_register_dnd: CoLockObjectExternal failed");
else
{
hres = RegisterDragDrop (private->xwindow, &context->idt);
hres = RegisterDragDrop (GDK_DRAWABLE_XID (window), &context->idt);
if (hres == DRAGDROP_E_ALREADYREGISTERED)
{
g_print ("DRAGDROP_E_ALREADYREGISTERED\n");
......
This diff is collapsed.
This diff is collapsed.
......@@ -899,9 +899,10 @@ gdk_gc_copy (GdkGC *dst_gc, GdkGC *src_gc)
}
HDC
gdk_gc_predraw (GdkDrawablePrivate *drawable_private,
GdkGCPrivate *gc_private)
gdk_gc_predraw (GdkDrawable *drawable,
GdkGCPrivate *gc_private)
{
GdkDrawablePrivate *drawable_private = (GdkDrawablePrivate *) drawable;
GdkColormapPrivate *colormap_private =
(GdkColormapPrivate *) drawable_private->colormap;
COLORREF bg;
......@@ -912,7 +913,7 @@ gdk_gc_predraw (GdkDrawablePrivate *drawable_private,
g_assert (gc_private->xgc == NULL);
if (drawable_private->window_type == GDK_DRAWABLE_PIXMAP)
if (GDK_DRAWABLE_TYPE (drawable) == GDK_DRAWABLE_PIXMAP)
{
if ((gc_private->xgc = CreateCompatibleDC (NULL)) == NULL)
g_warning ("gdk_gc_predraw: CreateCompatibleDC failed");
......@@ -1082,13 +1083,14 @@ gdk_gc_predraw (GdkDrawablePrivate *drawable_private,
}
void
gdk_gc_postdraw (GdkDrawablePrivate *drawable_private,
GdkGCPrivate *gc_private)
gdk_gc_postdraw (GdkDrawable *drawable_private,
GdkGCPrivate *gc_private)
{
HGDIOBJ hpen;
HGDIOBJ hbr;
GdkDrawablePrivate *drawable_private = (GdkDrawablePrivate *) drawable;