Implement it. Obscure bit manipulation needed.

* gdk/win32/gdkcursor.c (gdk_cursor_new_from_pixmap): Implement
 	it. Obscure bit manipulation needed.

	* gdk/win32/gdkevents.c: Logging.

	* gtk/gtkthemes.c (gtk_theme_engine_get): (Win32) Use new DLL naming
	style (file name include compiler name) for theme engines.
This commit is contained in:
Tor Lillqvist 1999-07-14 23:30:15 +00:00
parent 7d03e87069
commit 38aa9a941b
13 changed files with 299 additions and 112 deletions

View File

@ -1,3 +1,13 @@
1999-07-15 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkcursor.c (gdk_cursor_new_from_pixmap): Implement
it. Obscure bit manipulation needed.
* gdk/win32/gdkevents.c: Logging.
* gtk/gtkthemes.c (gtk_theme_engine_get): (Win32) Use new DLL naming
style (file name include compiler name) for theme engines.
1999-07-13 Tor Lillqvist <tml@iki.fi> 1999-07-13 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_pixmap): Less logging verbiage. * gdk/win32/gdkdraw.c (gdk_draw_pixmap): Less logging verbiage.

View File

@ -1,3 +1,13 @@
1999-07-15 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkcursor.c (gdk_cursor_new_from_pixmap): Implement
it. Obscure bit manipulation needed.
* gdk/win32/gdkevents.c: Logging.
* gtk/gtkthemes.c (gtk_theme_engine_get): (Win32) Use new DLL naming
style (file name include compiler name) for theme engines.
1999-07-13 Tor Lillqvist <tml@iki.fi> 1999-07-13 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_pixmap): Less logging verbiage. * gdk/win32/gdkdraw.c (gdk_draw_pixmap): Less logging verbiage.

View File

@ -1,3 +1,13 @@
1999-07-15 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkcursor.c (gdk_cursor_new_from_pixmap): Implement
it. Obscure bit manipulation needed.
* gdk/win32/gdkevents.c: Logging.
* gtk/gtkthemes.c (gtk_theme_engine_get): (Win32) Use new DLL naming
style (file name include compiler name) for theme engines.
1999-07-13 Tor Lillqvist <tml@iki.fi> 1999-07-13 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_pixmap): Less logging verbiage. * gdk/win32/gdkdraw.c (gdk_draw_pixmap): Less logging verbiage.

View File

@ -1,3 +1,13 @@
1999-07-15 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkcursor.c (gdk_cursor_new_from_pixmap): Implement
it. Obscure bit manipulation needed.
* gdk/win32/gdkevents.c: Logging.
* gtk/gtkthemes.c (gtk_theme_engine_get): (Win32) Use new DLL naming
style (file name include compiler name) for theme engines.
1999-07-13 Tor Lillqvist <tml@iki.fi> 1999-07-13 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_pixmap): Less logging verbiage. * gdk/win32/gdkdraw.c (gdk_draw_pixmap): Less logging verbiage.

View File

@ -1,3 +1,13 @@
1999-07-15 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkcursor.c (gdk_cursor_new_from_pixmap): Implement
it. Obscure bit manipulation needed.
* gdk/win32/gdkevents.c: Logging.
* gtk/gtkthemes.c (gtk_theme_engine_get): (Win32) Use new DLL naming
style (file name include compiler name) for theme engines.
1999-07-13 Tor Lillqvist <tml@iki.fi> 1999-07-13 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_pixmap): Less logging verbiage. * gdk/win32/gdkdraw.c (gdk_draw_pixmap): Less logging verbiage.

View File

@ -1,3 +1,13 @@
1999-07-15 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkcursor.c (gdk_cursor_new_from_pixmap): Implement
it. Obscure bit manipulation needed.
* gdk/win32/gdkevents.c: Logging.
* gtk/gtkthemes.c (gtk_theme_engine_get): (Win32) Use new DLL naming
style (file name include compiler name) for theme engines.
1999-07-13 Tor Lillqvist <tml@iki.fi> 1999-07-13 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_pixmap): Less logging verbiage. * gdk/win32/gdkdraw.c (gdk_draw_pixmap): Less logging verbiage.

View File

@ -1,3 +1,13 @@
1999-07-15 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkcursor.c (gdk_cursor_new_from_pixmap): Implement
it. Obscure bit manipulation needed.
* gdk/win32/gdkevents.c: Logging.
* gtk/gtkthemes.c (gtk_theme_engine_get): (Win32) Use new DLL naming
style (file name include compiler name) for theme engines.
1999-07-13 Tor Lillqvist <tml@iki.fi> 1999-07-13 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdraw.c (gdk_draw_pixmap): Less logging verbiage. * gdk/win32/gdkdraw.c (gdk_draw_pixmap): Less logging verbiage.

View File

@ -4,10 +4,11 @@ port, see http://www.gimp.org/tml/gimp/win32/ or
http://www.iki.fi/tml/gimp/win32/ . http://www.iki.fi/tml/gimp/win32/ .
To build GTk+ on Win32, you need either Microsoft compiler and tools, To build GTk+ on Win32, you need either Microsoft compiler and tools,
or egcs-1.1.2 running under cygwin-b20.1. Compile in gdk\win32 and gtk or egcs-1.1.2 (or gcc-2.95 or later) running under
with `nmake -f makefile.msc` or `make -f makefile.cygwin`. Before cygwin-b20.1. Compile in gdk\win32 and gtk with `nmake -f
doing a install, check the BIN definition in gdk\win32\makefile.msc makefile.msc` or `make -f makefile.cygwin`. Before doing a install,
(or makefile.cygwin) and gtk\makefile.msc (or makefile.cygwin). check the BIN definition in gdk\win32\makefile.msc (or
makefile.cygwin) and gtk\makefile.msc (or makefile.cygwin).
See the README.win32 file in the GLib distribution for preparations to See the README.win32 file in the GLib distribution for preparations to
build with egcs on cygwin. build with egcs on cygwin.

View File

@ -138,77 +138,118 @@ gdk_cursor_new (GdkCursorType cursor_type)
} }
GdkCursor* GdkCursor*
gdk_cursor_new_from_pixmap (GdkPixmap *source, GdkPixmap *mask, GdkColor *fg, GdkColor *bg, gint x, gint y) gdk_cursor_new_from_pixmap (GdkPixmap *source,
GdkPixmap *mask,
GdkColor *fg,
GdkColor *bg,
gint x,
gint y)
{ {
#if 0 /* I don't understand cursors, sigh */
GdkCursorPrivate *private; GdkCursorPrivate *private;
GdkCursor *cursor; GdkCursor *cursor;
GdkPixmap *s2;
GdkPixmapPrivate *source_private, *mask_private; GdkPixmapPrivate *source_private, *mask_private;
GdkPixmapPrivate *s2_private; GdkImage *source_image, *mask_image;
GdkGC *gc;
ICONINFO iconinfo;
HCURSOR xcursor; HCURSOR xcursor;
HBITMAP invmask; guchar *p, *q, *XORmask, *ANDmask;
HDC hdc1, hdc2; gint width, height, width32, height32;
HGDIOBJ oldbm1, oldbm2; guchar residue;
gint ix, iy;
g_return_val_if_fail (source != NULL, NULL);
g_return_val_if_fail (mask != NULL, NULL);
source_private = (GdkPixmapPrivate *) source; source_private = (GdkPixmapPrivate *) source;
mask_private = (GdkPixmapPrivate *) mask; mask_private = (GdkPixmapPrivate *) mask;
s2 = gdk_pixmap_new (source, source_private->width, source_private->height, 1); g_return_val_if_fail (source_private->width == mask_private->width
gc = gdk_gc_new (s2); && source_private->height == mask_private->height,
gdk_gc_set_foreground (gc, fg); NULL);
gdk_gc_set_background (gc, bg); width = source_private->width;
gdk_draw_pixmap (s2, gc, source, 0, 0, 0, 0, height = source_private->height;
source_private->width, source_private->height); width32 = ((width-1)/32+1)*32;
gdk_gc_unref (gc); height32 = ((height-1)/32+1)*32;
iconinfo.fIcon = FALSE;
iconinfo.xHotspot = x;
iconinfo.yHotspot = y;
#if 1
invmask = CreateBitmap (mask_private->width, mask_private->height, 1, 1, NULL);
hdc1 = CreateCompatibleDC (gdk_DC);
oldbm1 = SelectObject (hdc1, invmask);
hdc2 = CreateCompatibleDC (gdk_DC);
oldbm2 = SelectObject (hdc2, mask_private->xwindow);
BitBlt (hdc1, 0, 0, mask_private->width, mask_private->height, hdc2, 0, 0, NOTSRCCOPY);
SelectObject (hdc2, oldbm2);
DeleteDC (hdc2);
SelectObject (hdc1, oldbm1);
DeleteDC (hdc1);
iconinfo.hbmMask = invmask;
#else
iconinfo.hbmMask = mask_private->xwindow;;
#endif
iconinfo.hbmColor = ((GdkPixmapPrivate *) s2)->xwindow;
if ((xcursor = CreateIconIndirect (&iconinfo)) == NULL) 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);
if (source_image->depth != 1 || mask_image->depth != 1)
{ {
g_warning ("gdk_cursor_new_from_private: CreateIconIndirect failed"); gdk_image_destroy (source_image);
gdk_pixmap_unref (s2); gdk_image_destroy (mask_image);
return gdk_cursor_new (GDK_PIRATE); g_return_val_if_fail (source_image->depth == 1 && mask_image->depth == 1,
NULL);
} }
GDK_NOTE (MISC, /* Such complex bit manipulation for this simple task, sigh.
g_print ("gdk_cursor_new_from_private: %#x (%dx%d) %#x (%dx%d) = %#x\n", * The X cursor and Windows cursor concepts are quite different.
source_private->xwindow, * We assume here that we are always called with fg == black and
source_private->width, source_private->height, * bg == white.
mask_private->xwindow, */
mask_private->width, mask_private->height,
xcursor)); /* First set masked-out source bits, as all source bits matter on Windoze.
* As we invert them below, they will be clear in the final XORmask.
*/
for (iy = 0; iy < height; iy++)
{
p = source_image->mem + iy*source_image->bpl;
q = mask_image->mem + iy*mask_image->bpl;
for (ix = 0; ix < ((width-1)/8+1); ix++)
*p++ |= ~(*q++);
}
/* XOR mask is initialized to zero */
XORmask = g_malloc0 (width32/8 * height32);
for (iy = 0; iy < height; iy++)
{
p = source_image->mem + iy*source_image->bpl;
q = XORmask + iy*width32/8;
for (ix = 0; ix < ((width-1)/8+1); ix++)
*q++ = ~(*p++);
q[-1] &= ~residue; /* Clear left-over bits */
}
/* AND mask is initialized to ones */
ANDmask = g_malloc (width32/8 * height32);
memset (ANDmask, 0xFF, width32/8 * height32);
for (iy = 0; iy < height; iy++)
{
p = mask_image->mem + iy*mask_image->bpl;
q = ANDmask + iy*width32/8;
for (ix = 0; ix < ((width-1)/8+1); ix++)
*q++ = ~(*p++);
q[-1] |= residue; /* Set left-over bits */
}
xcursor = CreateCursor (gdk_ProgInstance, x, y, width32, height32,
ANDmask, XORmask);
GDK_NOTE (MISC, g_print ("gdk_cursor_new_from_pixmap: "
"%#x (%dx%d) %#x (%dx%d) = %#x (%dx%d)\n",
source_private->xwindow,
source_private->width, source_private->height,
mask_private->xwindow,
mask_private->width, mask_private->height,
xcursor, width32, height32));
g_free (XORmask);
g_free (ANDmask);
gdk_image_destroy (source_image);
gdk_image_destroy (mask_image);
gdk_pixmap_unref (s2);
private = g_new (GdkCursorPrivate, 1); private = g_new (GdkCursorPrivate, 1);
private->xcursor = xcursor; private->xcursor = xcursor;
cursor = (GdkCursor*) private; cursor = (GdkCursor*) private;
cursor->type = GDK_CURSOR_IS_PIXMAP; cursor->type = GDK_CURSOR_IS_PIXMAP;
return cursor; return cursor;
#else /* Just return some cursor ;-) */
return gdk_cursor_new (GDK_PIRATE);
#endif
} }
void void
@ -219,8 +260,12 @@ gdk_cursor_destroy (GdkCursor *cursor)
g_return_if_fail (cursor != NULL); g_return_if_fail (cursor != NULL);
private = (GdkCursorPrivate *) cursor; private = (GdkCursorPrivate *) cursor;
GDK_NOTE (MISC, g_print ("gdk_cursor_destroy: %#x\n",
(cursor->type == GDK_CURSOR_IS_PIXMAP) ? private->xcursor : 0));
if (cursor->type == GDK_CURSOR_IS_PIXMAP) if (cursor->type == GDK_CURSOR_IS_PIXMAP)
DestroyIcon (private->xcursor); if (!DestroyIcon (private->xcursor))
g_warning ("gdk_cursor_destroy: DestroyIcon failed");
g_free (private); g_free (private);
} }

View File

@ -138,77 +138,118 @@ gdk_cursor_new (GdkCursorType cursor_type)
} }
GdkCursor* GdkCursor*
gdk_cursor_new_from_pixmap (GdkPixmap *source, GdkPixmap *mask, GdkColor *fg, GdkColor *bg, gint x, gint y) gdk_cursor_new_from_pixmap (GdkPixmap *source,
GdkPixmap *mask,
GdkColor *fg,
GdkColor *bg,
gint x,
gint y)
{ {
#if 0 /* I don't understand cursors, sigh */
GdkCursorPrivate *private; GdkCursorPrivate *private;
GdkCursor *cursor; GdkCursor *cursor;
GdkPixmap *s2;
GdkPixmapPrivate *source_private, *mask_private; GdkPixmapPrivate *source_private, *mask_private;
GdkPixmapPrivate *s2_private; GdkImage *source_image, *mask_image;
GdkGC *gc;
ICONINFO iconinfo;
HCURSOR xcursor; HCURSOR xcursor;
HBITMAP invmask; guchar *p, *q, *XORmask, *ANDmask;
HDC hdc1, hdc2; gint width, height, width32, height32;
HGDIOBJ oldbm1, oldbm2; guchar residue;
gint ix, iy;
g_return_val_if_fail (source != NULL, NULL);
g_return_val_if_fail (mask != NULL, NULL);
source_private = (GdkPixmapPrivate *) source; source_private = (GdkPixmapPrivate *) source;
mask_private = (GdkPixmapPrivate *) mask; mask_private = (GdkPixmapPrivate *) mask;
s2 = gdk_pixmap_new (source, source_private->width, source_private->height, 1); g_return_val_if_fail (source_private->width == mask_private->width
gc = gdk_gc_new (s2); && source_private->height == mask_private->height,
gdk_gc_set_foreground (gc, fg); NULL);
gdk_gc_set_background (gc, bg); width = source_private->width;
gdk_draw_pixmap (s2, gc, source, 0, 0, 0, 0, height = source_private->height;
source_private->width, source_private->height); width32 = ((width-1)/32+1)*32;
gdk_gc_unref (gc); height32 = ((height-1)/32+1)*32;
iconinfo.fIcon = FALSE;
iconinfo.xHotspot = x;
iconinfo.yHotspot = y;
#if 1
invmask = CreateBitmap (mask_private->width, mask_private->height, 1, 1, NULL);
hdc1 = CreateCompatibleDC (gdk_DC);
oldbm1 = SelectObject (hdc1, invmask);
hdc2 = CreateCompatibleDC (gdk_DC);
oldbm2 = SelectObject (hdc2, mask_private->xwindow);
BitBlt (hdc1, 0, 0, mask_private->width, mask_private->height, hdc2, 0, 0, NOTSRCCOPY);
SelectObject (hdc2, oldbm2);
DeleteDC (hdc2);
SelectObject (hdc1, oldbm1);
DeleteDC (hdc1);
iconinfo.hbmMask = invmask;
#else
iconinfo.hbmMask = mask_private->xwindow;;
#endif
iconinfo.hbmColor = ((GdkPixmapPrivate *) s2)->xwindow;
if ((xcursor = CreateIconIndirect (&iconinfo)) == NULL) 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);
if (source_image->depth != 1 || mask_image->depth != 1)
{ {
g_warning ("gdk_cursor_new_from_private: CreateIconIndirect failed"); gdk_image_destroy (source_image);
gdk_pixmap_unref (s2); gdk_image_destroy (mask_image);
return gdk_cursor_new (GDK_PIRATE); g_return_val_if_fail (source_image->depth == 1 && mask_image->depth == 1,
NULL);
} }
GDK_NOTE (MISC, /* Such complex bit manipulation for this simple task, sigh.
g_print ("gdk_cursor_new_from_private: %#x (%dx%d) %#x (%dx%d) = %#x\n", * The X cursor and Windows cursor concepts are quite different.
source_private->xwindow, * We assume here that we are always called with fg == black and
source_private->width, source_private->height, * bg == white.
mask_private->xwindow, */
mask_private->width, mask_private->height,
xcursor)); /* First set masked-out source bits, as all source bits matter on Windoze.
* As we invert them below, they will be clear in the final XORmask.
*/
for (iy = 0; iy < height; iy++)
{
p = source_image->mem + iy*source_image->bpl;
q = mask_image->mem + iy*mask_image->bpl;
for (ix = 0; ix < ((width-1)/8+1); ix++)
*p++ |= ~(*q++);
}
/* XOR mask is initialized to zero */
XORmask = g_malloc0 (width32/8 * height32);
for (iy = 0; iy < height; iy++)
{
p = source_image->mem + iy*source_image->bpl;
q = XORmask + iy*width32/8;
for (ix = 0; ix < ((width-1)/8+1); ix++)
*q++ = ~(*p++);
q[-1] &= ~residue; /* Clear left-over bits */
}
/* AND mask is initialized to ones */
ANDmask = g_malloc (width32/8 * height32);
memset (ANDmask, 0xFF, width32/8 * height32);
for (iy = 0; iy < height; iy++)
{
p = mask_image->mem + iy*mask_image->bpl;
q = ANDmask + iy*width32/8;
for (ix = 0; ix < ((width-1)/8+1); ix++)
*q++ = ~(*p++);
q[-1] |= residue; /* Set left-over bits */
}
xcursor = CreateCursor (gdk_ProgInstance, x, y, width32, height32,
ANDmask, XORmask);
GDK_NOTE (MISC, g_print ("gdk_cursor_new_from_pixmap: "
"%#x (%dx%d) %#x (%dx%d) = %#x (%dx%d)\n",
source_private->xwindow,
source_private->width, source_private->height,
mask_private->xwindow,
mask_private->width, mask_private->height,
xcursor, width32, height32));
g_free (XORmask);
g_free (ANDmask);
gdk_image_destroy (source_image);
gdk_image_destroy (mask_image);
gdk_pixmap_unref (s2);
private = g_new (GdkCursorPrivate, 1); private = g_new (GdkCursorPrivate, 1);
private->xcursor = xcursor; private->xcursor = xcursor;
cursor = (GdkCursor*) private; cursor = (GdkCursor*) private;
cursor->type = GDK_CURSOR_IS_PIXMAP; cursor->type = GDK_CURSOR_IS_PIXMAP;
return cursor; return cursor;
#else /* Just return some cursor ;-) */
return gdk_cursor_new (GDK_PIRATE);
#endif
} }
void void
@ -219,8 +260,12 @@ gdk_cursor_destroy (GdkCursor *cursor)
g_return_if_fail (cursor != NULL); g_return_if_fail (cursor != NULL);
private = (GdkCursorPrivate *) cursor; private = (GdkCursorPrivate *) cursor;
GDK_NOTE (MISC, g_print ("gdk_cursor_destroy: %#x\n",
(cursor->type == GDK_CURSOR_IS_PIXMAP) ? private->xcursor : 0));
if (cursor->type == GDK_CURSOR_IS_PIXMAP) if (cursor->type == GDK_CURSOR_IS_PIXMAP)
DestroyIcon (private->xcursor); if (!DestroyIcon (private->xcursor))
g_warning ("gdk_cursor_destroy: DestroyIcon failed");
g_free (private); g_free (private);
} }

View File

@ -2475,11 +2475,18 @@ gdk_event_translate (GdkEvent *event,
if (LOWORD (xevent->lParam) != HTCLIENT) if (LOWORD (xevent->lParam) != HTCLIENT)
break; break;
if (p_grab_window != NULL && p_grab_cursor != NULL) if (p_grab_window != NULL && p_grab_cursor != NULL)
SetCursor (p_grab_cursor); {
GDK_NOTE (EVENTS, g_print ("...SetCursor(%#x)\n", p_grab_cursor));
SetCursor (p_grab_cursor);
}
else if (window_private else if (window_private
&& !window_private->destroyed && !window_private->destroyed
&& window_private->xcursor) && window_private->xcursor)
SetCursor (window_private->xcursor); {
GDK_NOTE (EVENTS, g_print ("...SetCursor(%#x)\n",
window_private->xcursor));
SetCursor (window_private->xcursor);
}
*ret_val_flagp = TRUE; *ret_val_flagp = TRUE;
*ret_valp = FALSE; *ret_valp = FALSE;
break; break;

View File

@ -2475,11 +2475,18 @@ gdk_event_translate (GdkEvent *event,
if (LOWORD (xevent->lParam) != HTCLIENT) if (LOWORD (xevent->lParam) != HTCLIENT)
break; break;
if (p_grab_window != NULL && p_grab_cursor != NULL) if (p_grab_window != NULL && p_grab_cursor != NULL)
SetCursor (p_grab_cursor); {
GDK_NOTE (EVENTS, g_print ("...SetCursor(%#x)\n", p_grab_cursor));
SetCursor (p_grab_cursor);
}
else if (window_private else if (window_private
&& !window_private->destroyed && !window_private->destroyed
&& window_private->xcursor) && window_private->xcursor)
SetCursor (window_private->xcursor); {
GDK_NOTE (EVENTS, g_print ("...SetCursor(%#x)\n",
window_private->xcursor));
SetCursor (window_private->xcursor);
}
*ret_val_flagp = TRUE; *ret_val_flagp = TRUE;
*ret_valp = FALSE; *ret_valp = FALSE;
break; break;

View File

@ -83,7 +83,19 @@ gtk_theme_engine_get (gchar *name)
GModule *library; GModule *library;
#ifndef __EMX__ #ifndef __EMX__
#if defined (NATIVE_WIN32) && defined (__GNUC__)
{
/* When built with gcc on Win32, use DLLs named *.gcc.dll,
* because MSVC-compiled GTK code is not fully binary compatible
* with gcc-compiled.
*/
gchar *gccname = g_strconcat (name, ".gcc", NULL);
fullname = g_module_build_path (NULL, gccname);
g_free (gccname);
}
#else
fullname = g_module_build_path (NULL, name); fullname = g_module_build_path (NULL, name);
#endif
#else #else
fullname = g_malloc (13); fullname = g_malloc (13);
gen_8_3_dll_name(name, fullname); gen_8_3_dll_name(name, fullname);