Massive changes. Too many to list here, but I'll try a summary:

2002-02-17  Tor Lillqvist  <tml@iki.fi>

	* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
	try a summary:

	1) Unify GdkPixmap and GdkImage implementation: For each
	GdkPixmap, allocate a GdkImage, and vice versa.
	GdkPixmapImplWin32Data has a pointer to the GdkImage.
	GdkImage::windowing_data is a pointer to the GdkPixmap.

	This simplifies many pixmap and image related functions a lot, and
	reduces duplicated code snippets. For instance, there is only one
	place in gdk/win32 where CreateDIBSection() is called, in the
	function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
	to a Windows region is almost trivial, with the bitmap bits being
	readily accessible in the associated GdkImage.

	All blitting between GdkPixmaps, GdkWindows and GdkImages goes
	through handled the _gdk_win32_blit() function, which calls
	different functions to handle the cases of blitting from pixmaps,
	inside windows (scrolling), or from windows, which all require
	somewhat different handling.

	2) Support 256-color mode. This has long been very broken, now it
	works more or less OK. Keep the logical palette for each colormap
	as small as possible while allocating and freeing colors. Select
	and realize the logical palette associated with a GdkColormap into
	a DC before drawing or blitting.

	When the display is in 256-color mode, make it possible for the
	user to override the size of the palette(s) used with either the
	GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
	command line option. It is possible to reduce the palette size all
	the way down to using just the 16 static colors (which causes the
	system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
	possibly be useful if one desperately wants to avoid color
	flashing. (Note that in order for this to work properly, an as of
	yet not commited fix to gdkrgb.c is needed.)

	Handle the palette messages. On WM_PALETTECHANGED, call
	UpdateColors() for the given window hierarchy. Do this only if a
	window in some other top-level window hierarchy caused the palette
	change (realized a palette). Do this max five times in a row (an
	arbitrarily chosen limit), though, otherwise redraw by generating
	expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
	window hierarchy by generating GDK_EXPOSE events.

	3) Code cleanup in general. For instance, remove the "emulated"
	X11 structs ColormapStruct, Visual and XStandardColormap. Use the
	new GDK_DEBUG_* flags for debugging output in the relevant source
	files. Remove the unused colormap hash table in gdkcolor-win32.c

	4) Plug some resource leaks.

2002-02-14  Tor Lillqvist  <tml@iki.fi>

	* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
	g_filename_to_uri() to actually create legal URIs in the
	text/uri-list data.
This commit is contained in:
Tor Lillqvist 2002-02-17 00:25:05 +00:00 committed by Tor Lillqvist
parent ff612419cd
commit bc1ec5c14a
30 changed files with 2846 additions and 2641 deletions

View File

@ -1,3 +1,63 @@
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-16 Manish Singh <yosh@gimp.org>
* gtk/gtkfilesel.[ch]: Added multiple selection API
@ -1903,11 +1963,7 @@ Sat Jan 12 16:57:31 2002 Kristian Rietveld <kris@gtk.org>
cursor, set the Windows cursor to none first.
* gdk/win32/gdkgc-win32.c (predraw_set_foreground): Delete the old
brush that was in the DC, like the win32-production branch does. I
guess this plugs a resource leak? With the HDC cache, the old
brush might be something we created ourselves, and not a stock
brush. And it doesn't do any harm to call DeleteObject on stock
brushes.
brush that was in the DC, like the win32-production branch does.
* gdk/win32/gdkwindow-win32.c (gdk_window_impl_win32_finalize): If
the window has a cursor which is the current Windows cursor,

View File

@ -1,3 +1,63 @@
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-16 Manish Singh <yosh@gimp.org>
* gtk/gtkfilesel.[ch]: Added multiple selection API
@ -1903,11 +1963,7 @@ Sat Jan 12 16:57:31 2002 Kristian Rietveld <kris@gtk.org>
cursor, set the Windows cursor to none first.
* gdk/win32/gdkgc-win32.c (predraw_set_foreground): Delete the old
brush that was in the DC, like the win32-production branch does. I
guess this plugs a resource leak? With the HDC cache, the old
brush might be something we created ourselves, and not a stock
brush. And it doesn't do any harm to call DeleteObject on stock
brushes.
brush that was in the DC, like the win32-production branch does.
* gdk/win32/gdkwindow-win32.c (gdk_window_impl_win32_finalize): If
the window has a cursor which is the current Windows cursor,

View File

@ -1,3 +1,63 @@
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-16 Manish Singh <yosh@gimp.org>
* gtk/gtkfilesel.[ch]: Added multiple selection API
@ -1903,11 +1963,7 @@ Sat Jan 12 16:57:31 2002 Kristian Rietveld <kris@gtk.org>
cursor, set the Windows cursor to none first.
* gdk/win32/gdkgc-win32.c (predraw_set_foreground): Delete the old
brush that was in the DC, like the win32-production branch does. I
guess this plugs a resource leak? With the HDC cache, the old
brush might be something we created ourselves, and not a stock
brush. And it doesn't do any harm to call DeleteObject on stock
brushes.
brush that was in the DC, like the win32-production branch does.
* gdk/win32/gdkwindow-win32.c (gdk_window_impl_win32_finalize): If
the window has a cursor which is the current Windows cursor,

View File

@ -1,3 +1,63 @@
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-16 Manish Singh <yosh@gimp.org>
* gtk/gtkfilesel.[ch]: Added multiple selection API
@ -1903,11 +1963,7 @@ Sat Jan 12 16:57:31 2002 Kristian Rietveld <kris@gtk.org>
cursor, set the Windows cursor to none first.
* gdk/win32/gdkgc-win32.c (predraw_set_foreground): Delete the old
brush that was in the DC, like the win32-production branch does. I
guess this plugs a resource leak? With the HDC cache, the old
brush might be something we created ourselves, and not a stock
brush. And it doesn't do any harm to call DeleteObject on stock
brushes.
brush that was in the DC, like the win32-production branch does.
* gdk/win32/gdkwindow-win32.c (gdk_window_impl_win32_finalize): If
the window has a cursor which is the current Windows cursor,

View File

@ -1,3 +1,63 @@
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-16 Manish Singh <yosh@gimp.org>
* gtk/gtkfilesel.[ch]: Added multiple selection API
@ -1903,11 +1963,7 @@ Sat Jan 12 16:57:31 2002 Kristian Rietveld <kris@gtk.org>
cursor, set the Windows cursor to none first.
* gdk/win32/gdkgc-win32.c (predraw_set_foreground): Delete the old
brush that was in the DC, like the win32-production branch does. I
guess this plugs a resource leak? With the HDC cache, the old
brush might be something we created ourselves, and not a stock
brush. And it doesn't do any harm to call DeleteObject on stock
brushes.
brush that was in the DC, like the win32-production branch does.
* gdk/win32/gdkwindow-win32.c (gdk_window_impl_win32_finalize): If
the window has a cursor which is the current Windows cursor,

View File

@ -1,3 +1,63 @@
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-16 Manish Singh <yosh@gimp.org>
* gtk/gtkfilesel.[ch]: Added multiple selection API
@ -1903,11 +1963,7 @@ Sat Jan 12 16:57:31 2002 Kristian Rietveld <kris@gtk.org>
cursor, set the Windows cursor to none first.
* gdk/win32/gdkgc-win32.c (predraw_set_foreground): Delete the old
brush that was in the DC, like the win32-production branch does. I
guess this plugs a resource leak? With the HDC cache, the old
brush might be something we created ourselves, and not a stock
brush. And it doesn't do any harm to call DeleteObject on stock
brushes.
brush that was in the DC, like the win32-production branch does.
* gdk/win32/gdkwindow-win32.c (gdk_window_impl_win32_finalize): If
the window has a cursor which is the current Windows cursor,

View File

@ -1,3 +1,63 @@
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/*.c: Massive changes. Too many to list here, but I'll
try a summary:
1) Unify GdkPixmap and GdkImage implementation: For each
GdkPixmap, allocate a GdkImage, and vice versa.
GdkPixmapImplWin32Data has a pointer to the GdkImage.
GdkImage::windowing_data is a pointer to the GdkPixmap.
This simplifies many pixmap and image related functions a lot, and
reduces duplicated code snippets. For instance, there is only one
place in gdk/win32 where CreateDIBSection() is called, in the
function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap)
to a Windows region is almost trivial, with the bitmap bits being
readily accessible in the associated GdkImage.
All blitting between GdkPixmaps, GdkWindows and GdkImages goes
through handled the _gdk_win32_blit() function, which calls
different functions to handle the cases of blitting from pixmaps,
inside windows (scrolling), or from windows, which all require
somewhat different handling.
2) Support 256-color mode. This has long been very broken, now it
works more or less OK. Keep the logical palette for each colormap
as small as possible while allocating and freeing colors. Select
and realize the logical palette associated with a GdkColormap into
a DC before drawing or blitting.
When the display is in 256-color mode, make it possible for the
user to override the size of the palette(s) used with either the
GDK_WIN32_MAX_COLORS environment variable, or a -max-colors
command line option. It is possible to reduce the palette size all
the way down to using just the 16 static colors (which causes the
system visual to be of type GDK_VISUAL_STATIC_COLOR. This could
possibly be useful if one desperately wants to avoid color
flashing. (Note that in order for this to work properly, an as of
yet not commited fix to gdkrgb.c is needed.)
Handle the palette messages. On WM_PALETTECHANGED, call
UpdateColors() for the given window hierarchy. Do this only if a
window in some other top-level window hierarchy caused the palette
change (realized a palette). Do this max five times in a row (an
arbitrarily chosen limit), though, otherwise redraw by generating
expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole
window hierarchy by generating GDK_EXPOSE events.
3) Code cleanup in general. For instance, remove the "emulated"
X11 structs ColormapStruct, Visual and XStandardColormap. Use the
new GDK_DEBUG_* flags for debugging output in the relevant source
files. Remove the unused colormap hash table in gdkcolor-win32.c
4) Plug some resource leaks.
2002-02-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use
g_filename_to_uri() to actually create legal URIs in the
text/uri-list data.
2002-02-16 Manish Singh <yosh@gimp.org>
* gtk/gtkfilesel.[ch]: Added multiple selection API
@ -1903,11 +1963,7 @@ Sat Jan 12 16:57:31 2002 Kristian Rietveld <kris@gtk.org>
cursor, set the Windows cursor to none first.
* gdk/win32/gdkgc-win32.c (predraw_set_foreground): Delete the old
brush that was in the DC, like the win32-production branch does. I
guess this plugs a resource leak? With the HDC cache, the old
brush might be something we created ourselves, and not a stock
brush. And it doesn't do any harm to call DeleteObject on stock
brushes.
brush that was in the DC, like the win32-production branch does.
* gdk/win32/gdkwindow-win32.c (gdk_window_impl_win32_finalize): If
the window has a cursor which is the current Windows cursor,

View File

@ -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

View File

@ -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
#define GDK_HAVE_WCHAR_H 1
#define GDK_HAVE_WCTYPE_H 1
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* GDKCONFIG_H */

File diff suppressed because it is too large Load Diff

View File

@ -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;

View File

@ -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");
}

View File

@ -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;
g_assert (GDK_IS_DRAWABLE_IMPL_WIN32 (drawable));
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");
/* 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);
@ -1001,6 +893,348 @@ gdk_win32_draw_glyphs (GdkDrawable *drawable,
gdk_win32_hdc_release (drawable, gc, mask);
}
static void
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)
{
HDC srcdc;
HBITMAP holdbitmap;
RGBQUAD oldtable[256], newtable[256];
COLORREF bg, fg;
gint newtable_size = 0, oldtable_size = 0;
gboolean ok = TRUE;
GDK_NOTE (MISC, g_print ("blit_from_pixmap\n"));
if (!(srcdc = CreateCompatibleDC (NULL)))
{
WIN32_GDI_FAILED ("CreateCompatibleDC");
return;
}
if (!(holdbitmap = SelectObject (srcdc, ((GdkDrawableImplWin32 *) src)->handle)))
WIN32_GDI_FAILED ("SelectObject");
else
{
if (src->image->depth <= 8)
{
/* 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");
}
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;
}
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");
}
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));
draw_impl = (GdkDrawableImplWin32 *) drawable;
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 ();
hdc = gdk_win32_hdc_get ((GdkDrawable *) drawable, gc, GDK_GC_FOREGROUND);
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);
}
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,
@ -1012,78 +1246,11 @@ gdk_win32_draw_image (GdkDrawable *drawable,
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;
g_assert (GDK_IS_DRAWABLE_IMPL_WIN32 (drawable));
hdc = gdk_win32_hdc_get (drawable, gc, 0);
if (image->visual && image->visual->type == GDK_VISUAL_PSEUDO_COLOR &&
colormap_private && colormap_private->xcolormap->rc_palette)
{
if (!bmi_inited)
{
for (i = 0; i < 256; i++)
bmi.bmiIndices[i] = i;
bmi_inited = TRUE;
}
if (GetObject (image_private->hbitmap, sizeof (DIBSECTION),
&ds) != sizeof (DIBSECTION))
WIN32_GDI_FAILED ("GetObject"), ok = FALSE;
#if 0
g_print("xdest = %d, ydest = %d, xsrc = %d, ysrc = %d, width = %d, height = %d\n",
xdest, ydest, xsrc, ysrc, width, height);
g_print("bmWidth = %d, bmHeight = %d, bmBitsPixel = %d, bmBits = %p\n",
ds.dsBm.bmWidth, ds.dsBm.bmHeight, ds.dsBm.bmBitsPixel, ds.dsBm.bmBits);
g_print("biWidth = %d, biHeight = %d, biBitCount = %d, biClrUsed = %d\n",
ds.dsBmih.biWidth, ds.dsBmih.biHeight, ds.dsBmih.biBitCount, ds.dsBmih.biClrUsed);
#endif
bmi.bmiHeader = ds.dsBmih;
/* I have spent hours on getting the parameters to
* SetDIBitsToDevice right. I wonder what drugs the guys in
* Redmond were on when they designed this API.
*/
if (ok && SetDIBitsToDevice (hdc,
xdest, ydest,
width, height,
xsrc, (-ds.dsBmih.biHeight)-height-ysrc,
0, -ds.dsBmih.biHeight,
ds.dsBm.bmBits,
(CONST BITMAPINFO *) &bmi,
DIB_PAL_COLORS) == 0)
WIN32_GDI_FAILED ("SetDIBitsToDevice");
}
else
{
if ((memdc = CreateCompatibleDC (hdc)) == NULL)
WIN32_GDI_FAILED ("CreateCompatibleDC"), ok = FALSE;
if (ok && (oldbitmap = SelectObject (memdc, image_private->hbitmap)) == NULL)
WIN32_GDI_FAILED ("SelectObject"), ok = FALSE;
if (ok && !BitBlt (hdc, xdest, ydest, width, height,
memdc, xsrc, ysrc, SRCCOPY))
WIN32_GDI_FAILED ("BitBlt");
if (oldbitmap != NULL && SelectObject (memdc, oldbitmap) == NULL)
WIN32_GDI_FAILED ("SelectObject");
if (memdc != NULL && !DeleteDC (memdc))
WIN32_GDI_FAILED ("DeleteDC");
}
gdk_win32_hdc_release (drawable, gc, 0);
_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);
}

View File

@ -50,11 +50,8 @@ typedef struct _GdkDrawableImplWin32Class GdkDrawableImplWin32Class;
struct _GdkDrawableImplWin32
{
GdkDrawable parent_instance;
GdkDrawable *wrapper;
GdkColormap *colormap;
HANDLE handle;
};

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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;
GdkImage *image;
guchar *p;
gint x, y;
/* 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");
}
/* 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;
}

View File

@ -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;

View File

@ -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

View File

@ -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
@ -102,87 +103,91 @@ _gdk_image_exit (void)
}
}
GdkImage *
_gdk_win32_setup_pixmap_image (GdkPixmap *pixmap,
GdkWindow *window,
gint width,
gint height,
gint depth,
guchar *bits)
{
GdkImage *image;
image = g_object_new (gdk_image_get_type (), NULL);
image->windowing_data = pixmap;
image->type = GDK_IMAGE_SHARED;
image->visual = gdk_drawable_get_visual (window);
image->byte_order = GDK_LSB_FIRST;
image->width = width;
image->height = height;
image->depth = depth;
switch (depth)
{
case 1:
case 4:
case 5:
case 6:
case 7:
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_setup_pixmap_image: depth=%d", image->depth);
g_assert_not_reached ();
}
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;
image->bits_per_pixel = image->depth;
image->mem = bits;
return image;
}
GdkImage *
gdk_image_new_bitmap (GdkVisual *visual,
gpointer data,
gint w,
gint h)
/*
* Desc: create a new bitmap image
*/
{
Visual *xvisual;
GdkPixmap *pixmap;
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;
gint data_bpl = (w-1)/8 + 1;
gint i;
image = g_object_new (gdk_image_get_type (), NULL);
private = IMAGE_PRIVATE_DATA (image);
pixmap = gdk_pixmap_new (NULL, w, h, 1);
image->type = GDK_IMAGE_SHARED;
image->visual = visual;
image->width = w;
image->height = h;
image->depth = 1;
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
if (pixmap == NULL)
return NULL;
GDK_NOTE (MISC, g_print ("gdk_image_new_bitmap: %dx%d\n", w, h));
image = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->image;
GDK_NOTE (IMAGE, g_print ("gdk_image_new_bitmap: %dx%d=%p\n",
w, h, GDK_PIXMAP_HBITMAP (pixmap)));
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)
if (data_bpl != image->bpl)
{
/* 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);
memmove ((guchar *) image->mem + i*image->bpl, ((guchar *) data) + i*data_bpl, data_bpl);
}
else
memmove (bits, data, bpl*h);
image->mem = bits;
image->bpl = bpl32;
image->byte_order = GDK_MSB_FIRST;
memmove (image->mem, data, data_bpl*h);
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() */
return image;
}
void
_gdk_windowing_image_init (void)
@ -197,19 +202,7 @@ _gdk_image_new_for_depth (GdkImageType type,
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;
GdkPixmap *pixmap;
g_return_val_if_fail (!visual || GDK_IS_VISUAL (visual), NULL);
g_return_val_if_fail (visual || depth != -1, NULL);
@ -217,116 +210,15 @@ _gdk_image_new_for_depth (GdkImageType type,
if (visual)
depth = visual->depth;
if (type == GDK_IMAGE_FASTEST || type == GDK_IMAGE_NORMAL)
type = GDK_IMAGE_SHARED;
pixmap = gdk_pixmap_new (NULL, width, height, depth);
GDK_NOTE (MISC, g_print ("gdk_image_new: %dx%d %s\n",
width, height,
(type == GDK_IMAGE_SHARED ? "shared" :
"???")));
if (pixmap == NULL)
return NULL;
GDK_NOTE (IMAGE, g_print ("_gdk_image_new_for_depth: %dx%dx%d=%p\n",
width, height, depth, GDK_PIXMAP_HBITMAP (pixmap)));
image = g_object_new (gdk_image_get_type (), NULL);
private = IMAGE_PRIVATE_DATA (image);
image->type = type;
image->visual = visual;
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)
{
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_image_new: 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;
GDK_NOTE (MISC, g_print ("... = %#x mem = %p, bpl = %d\n",
(guint) private->hbitmap, image->mem, image->bpl));
return image;
return GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl)->image;
}
GdkImage*
@ -338,250 +230,6 @@ gdk_image_new (GdkImageType type,
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 *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));
impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
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 ((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;
}
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)
{
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;
}
}
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;
}
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;
}
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;
}
if (SelectObject (memdc, oldbitmap2) == NULL)
WIN32_GDI_FAILED ("SelectObject");
if (!DeleteDC (memdc))
WIN32_GDI_FAILED ("DeleteDC");
if (GDK_IS_PIXMAP_IMPL_WIN32 (drawable))
{
SelectObject (hdc, oldbitmap1);
DeleteDC (hdc);
}
else
{
ReleaseDC (impl->handle, hdc);
}
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;
GDK_NOTE (MISC, g_print ("... = %#x mem = %p, bpl = %d\n",
(guint) private->hbitmap, image->mem, image->bpl));
return image;
}
GdkImage*
_gdk_win32_copy_to_image (GdkDrawable *drawable,
GdkImage *image,
@ -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
return (((guchar *) image->mem)[y * image->bpl + (x >> 3)] & (1 << (7 - (x & 0x7)))) != 0;
if (image->depth == 4)
{
guchar *pixelp = (guchar *) image->mem + y * image->bpl + x * image->bpp;
switch (image->bpp)
{
case 1:
pixel = *pixelp;
break;
pixelp = (guchar *) image->mem + y * image->bpl + (x >> 1);
if (x&1)
return (*pixelp) & 0x0F;
/* 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;
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;
}

View File

@ -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)

View File

@ -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*

View File

@ -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 }
};

View File

@ -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);
pixmap = gdk_pixmap_new (window, width, height, 1);
pix_impl->is_foreign = FALSE;
pix_impl->width = width;
pix_impl->height = height;
GDK_PIXMAP_OBJECT (pixmap)->depth = 1;
if (pixmap == NULL)
return NULL;
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;
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]];
for (j = 0; j < data_bpl; j++)
bits[i*image_bpl + j] = mirror[(guchar) data[i*data_bpl + j]];
draw_impl->handle = CreateBitmap (width, height, 1, 1, bits);
GDK_NOTE (MISC, g_print ("gdk_bitmap_create_from_data: %dx%d = %#x\n",
width, height,
(guint) GDK_PIXMAP_HBITMAP (pixmap)));
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);

View File

@ -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);

View File

@ -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);
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);
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_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);
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);
GdkPixmap *_gdk_win32_pixmap_new (GdkWindow *window,
GdkVisual *visual,
gint width,
gint height,
gint depth);
HRGN BitmapToRegion (HBITMAP hBmp);
GdkImage *_gdk_win32_setup_pixmap_image (GdkPixmap *pixmap,
GdkWindow *window,
gint width,
gint height,
gint depth,
guchar *bits);
gchar *gdk_font_full_name_get (GdkFont *font);
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__ */

View File

@ -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;
const gint rastercaps = GetDeviceCaps (gdk_display_hdc, RASTERCAPS);
gint bitspixel = GetDeviceCaps (gdk_display_hdc, BITSPIXEL);
gint map_entries = 0;
system_visual = g_new (GdkVisualPrivate, 1);
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->red_mask,
&system_visual->red_shift,
&system_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->green_mask,
&system_visual->green_shift,
&system_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->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,

View File

@ -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,

View File

@ -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)
{
GdkWindow *window;
GdkWindowObject *private;
GdkWindowImplWin32 *impl;
GdkDrawableImplWin32 *draw_impl;
GdkVisual *visual;
HANDLE hparent;
ATOM klass = 0;
DWORD dwStyle, dwExStyle;
RECT rect;
Visual *xvisual;
GdkWindow *window;
GdkWindowObject *private;
GdkWindowImplWin32 *impl;
GdkDrawableImplWin32 *draw_impl;
GdkVisual *visual;
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;
gdk_window_get_frame_extents (window, &rect);
if (x)
*x = 0;
*x = rect.x;
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;
pt.x = 0;
pt.y = 0;
ClientToScreen (GDK_WINDOW_HWND (rover), &pt);
if (x)
*x = pt.x;
if (y)
*y = pt.y;
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));
*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

View File

@ -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 */
};