gtk2/gdk
Tor Lillqvist 3f4c73d0d5 Bug 559408 - Transparency lost when images are copied between GTK+ and the
2009-01-29  Tor Lillqvist  <tml@novell.com>

	Bug 559408 - Transparency lost when images are copied between GTK+
	and the clipboard on Windows

	The code in gdkselection-win32.c is simplified quite a lot. When
	an image is stored on the clipboard from GTK+, only the "PNG" and
	CF_DIB formats are advertised. PNG is our preferred format because
	it can losslessly represent any image that gdk-pixbuf can handle,
	even with alpha, unambiguously. CF_DIB is also advertised because
	of its ubiquitous support in Windows software.

	Delayed rendering is used as before, so for other data than text
	nothing is actually stored on the clipboard until some app asks
	for it.

	It's pointless to advertise images formats like "image/png" or
	"image/x-MS-bmp" that no other Windows application is going to
	look for anyway. Likewise it's pointless to store text under
	formats like "text/plain" or "UTF8_STRING". Just store
	CF_UNICODETEXT. CF_TEXT will be available as a synthesized format
	anyways.

	Office 2007 offers and asks for images in PNG format using the
	registered clipboard format name "PNG", so we do likewise. If the
	"PNG" format is available that is preferred when copying to GTK+
	from the clipboard.

	Unfortunately Word 2007 still uses CF_DIB without handling
	alpha. But PowerPoint 2007 uses PNG if available and handles alpha
	correctly. Both Word and Powerpoint offer PNG with alpha nicely.

	Firefox and IE7 offer images that contain alpha as 32-bit version
	3 BI_RGB DIBs with the undocumented "extra" bytes actually being
	alpha. Also, alpha is premultiplied into the RGB bytes, presumably
	because that is how AlphaBlend() wants such DIBs. That is also
	taken care of. At least for Firefox it easy to be sure that a
	CF_DIB on the clipboard is from Firefox.

	Also some general stylistic cleanup, comment improvements, and
	improvements of debugging printout especially in the clipboard
	handling. Those are not detailled below.

	* gdk/win32/gdkprivate-win32.h
	* gdk/win32/gdkglobals-win32.c
	* gdk/win32/gdkgmain-win32.c: Move some globals that were used
	only in gdkselection-win32.c to be local to that file.

	* gdk/win32/gdkproperty-win32.c (gdk_property_change): Don't
	bother checking if text to be placed on the clipboard consists of
	only ASCII.

	* gdk/win32/gdkselection-win32.c: Add static variables for a list
	of GdkPixbuf-supported formats, well-known registered clipboard
	formats for images, and for GdkAtoms for well-known image and text
	formats.

	(_gdk_win32_selection_init): Initialize above static variables.

	(selection_property_store) (gdk_selection_property_get)
	(_gdk_selection_property_delete): Don't use a FIFO of GdkSelProps
	for a window after all, it breaks testtext. See bug #163844.

	(gdk_selection_convert): When converting to the TARGETS format,
	i.e. when the caller wants to know what clipboard formats are
	available, if PNG is available we report just that and skip
	CF_DIB, JPEG and GIF even if advertised.

	If CF_UNICODETEXT is available, report only UTF8_STRING.

	When converting to the UTF8_STRING format, i.e. when the caller
	wants text from the clipboard, try just CF_UNICODETEXT. There is
	no point in trying CF_TEXT as Windows will synthesize
	CF_UNICODETEXT from CF_TEXT anyway, if some app has stored just
	CF_TEXT.

	When converting to the image/bmp format, i.e. when the caller
	wants an CF_DIB image from the clipboard, we check if the DIB is a
	version 3 32-bit BI_RGB one that is likely to actually contain
	alpha in the "extra" bytes. Such a DIB is likely to have
	premultiplied alpha even, at least in the case of Firefox 3 and
	IE7. We then edit the DIB in-place into a version 5 one in
	BI_BITFIELDS format and undo the alpha premultiplication.

	In any case, prepend a BMP file header before letting go of the
	data which will be fed to the gdk-pixbuf bmp loader by upper
	levels.

	(gdk_win32_selection_add_targets): If some kind of pixmap image
	format is being added, actually advertise just PNG and
	CF_DIB. Note that alpha won't be stored on the clipboard through
	CF_DIB. This is because gdk-pixbuf's bmp loader doesn't save
	alpha. Furthermore, few if any non-GTK+ Windows apps seem to
	understand a version 5 DIB with proper alpha anyway.

	(_gdk_win32_selection_convert_to_dib): Simplified muchly.



svn path=/trunk/; revision=22255
2009-01-30 01:16:47 +00:00
..
directfb Fix a typo 2008-12-13 05:20:10 +00:00
quartz Bug 566628 – gdk_display_close always asserts on win32 and quartz 2009-01-26 20:31:18 +00:00
tests Use the g_test_*() API for this test reviewed by: Richard Hult 2008-08-15 18:57:31 +00:00
win32 Bug 559408 - Transparency lost when images are copied between GTK+ and the 2009-01-30 01:16:47 +00:00
x11 Don't update blank cursors 2009-01-24 21:29:36 +00:00
abicheck.sh Commit a patch by Behdad to fix typos, omissions and other errors in the 2006-09-10 06:39:16 +00:00
COPYING [ Merges from gtk-1-2 ] 1999-09-28 20:19:13 +00:00
gdk.c A GOptionArgFunc should return gboolean and take also a GError pointer 2009-01-12 12:05:13 +00:00
gdk.h Add gdk_threads_add_timeout_seconds{_full} 2008-07-31 22:11:44 +00:00
gdk.symbols add missing #ifndef GDK_DISABLE_DEPRECATED. 2008-12-09 15:37:59 +00:00
gdkapplaunchcontext.c Typo fixes and small doc improvements 2008-12-26 04:20:28 +00:00
gdkapplaunchcontext.h fix typo in the type name so the macro becomes usable. 2008-10-15 15:50:10 +00:00
gdkcairo.c Add a note that cairo contexts cannot be cached for handling expose 2008-07-07 00:28:37 +00:00
gdkcairo.h Revert name change 2008-07-01 22:57:50 +00:00
gdkcolor.c Revert name change 2008-07-01 22:57:50 +00:00
gdkcolor.h Revert name change 2008-07-01 22:57:50 +00:00
gdkconfig.h.win32 Define GDK_NATIVE_WINDOW_POINTER on 32-bit Windows, too. It just makes 2008-08-04 22:20:53 +00:00
gdkcursor.c Update docs on blank cursors 2009-01-20 02:27:57 +00:00
gdkcursor.h Cache cursors to avoid libXcursor theme lookup overhead. 2009-01-20 02:15:59 +00:00
gdkdisplay.c Correct the documentation. Patch by Paul Davis 2008-12-08 01:46:43 +00:00
gdkdisplay.h define __GDK_H_INSIDE__ around including all other headers. 2008-05-28 14:01:57 +00:00
gdkdisplaymanager.c gdk/gdkkeys.c gdk/gdkscreen.c use canonical signal names. 2008-08-11 09:15:37 +00:00
gdkdisplaymanager.h Revert name change 2008-07-01 22:57:50 +00:00
gdkdnd.c Bug 544684 - Win64 issue, window handles are assumed to be 32-bit 2008-08-04 22:35:16 +00:00
gdkdnd.h Bug 544684 - Win64 issue, window handles are assumed to be 32-bit 2008-08-04 22:35:16 +00:00
gdkdraw.c gdk/gdkdraw.c gdk/gdkimage.c gdk/gdkscreen.c replace assertions for obj != 2008-10-21 21:42:39 +00:00
gdkdrawable.h Revert name change 2008-07-01 22:57:50 +00:00
gdkenumtypes.c.template Use templates for glib-mkenums calls instead of complicated commandlines 2007-11-26 17:32:19 +00:00
gdkenumtypes.h.template do not hard code the prefix of the enum, use @ENUMPREFIX@ instead (you 2008-06-23 12:09:15 +00:00
gdkevents.c Bug 551063 – deprecated marking without a link to what new code should 2008-09-06 17:26:33 +00:00
gdkevents.h Bug 56070 – Can't click button after setting it sensitive. 2008-08-01 03:30:50 +00:00
gdkfont.c Revert name change 2008-07-01 22:57:50 +00:00
gdkfont.h Revert name change 2008-07-01 22:57:50 +00:00
gdkgc.c Revert name change 2008-07-01 22:57:50 +00:00
gdkgc.h Revert name change 2008-07-01 22:57:50 +00:00
gdkglobals.c Revert name change 2008-07-01 22:57:50 +00:00
gdki18n.h Revert name change 2008-07-01 22:57:50 +00:00
gdkimage.c gdk/gdkdraw.c gdk/gdkimage.c gdk/gdkscreen.c replace assertions for obj != 2008-10-21 21:42:39 +00:00
gdkimage.h Revert name change 2008-07-01 22:57:50 +00:00
gdkinput.h Revert name change 2008-07-01 22:57:50 +00:00
gdkinternals.h Bug 550942 – [patch] Rework of gdkeventloop-quartz.c 2008-11-12 13:30:22 +00:00
gdkintl.h Revert name change 2008-07-01 22:57:50 +00:00
gdkkeynames.c Revert name change 2008-07-01 22:57:50 +00:00
gdkkeys.c Typo fixes and small doc improvements 2008-12-26 04:20:28 +00:00
gdkkeys.h Bug 107000 – Add signals to GdkKeymap for monitoring caps_lock, etc. 2008-09-29 20:40:45 +00:00
gdkkeysyms-update.pl Revert name change 2008-07-01 22:57:50 +00:00
gdkkeysyms.h Bug 550062 – Small update in gdk/gdkkeysyms.h 2008-09-07 00:54:41 +00:00
gdkkeyuni.c Revert name change 2008-07-01 22:57:50 +00:00
gdkmarshalers.list New demo for window migration between different displays and screens. 2002-08-01 23:43:13 +00:00
gdkmedialib.c Revert name change 2008-07-01 22:57:50 +00:00
gdkmedialib.h Revert name change 2008-07-01 22:57:50 +00:00
gdkpango.c examples/gtkdial/gtkdial.c gdk/gdkapplaunchcontext.c gdk/gdkpango.c 2008-08-12 09:51:16 +00:00
gdkpango.h Revert name change 2008-07-01 22:57:50 +00:00
gdkpixbuf-drawable.c Include "config.h" instead of <config.h> Command used: find -name 2008-06-22 14:28:52 +00:00
gdkpixbuf-render.c Include "config.h" instead of <config.h> Command used: find -name 2008-06-22 14:28:52 +00:00
gdkpixbuf.h Revert name change 2008-07-01 22:57:50 +00:00
gdkpixmap.c Revert name change 2008-07-01 22:57:50 +00:00
gdkpixmap.h Revert name change 2008-07-01 22:57:50 +00:00
gdkpoly-generic.h Merge no-flicker branch into HEAD 2000-03-28 01:24:44 +00:00
gdkpolyreg-generic.c Include "config.h" instead of <config.h> Command used: find -name 2008-06-22 14:28:52 +00:00
gdkprivate.h Revert name change 2008-07-01 22:57:50 +00:00
gdkproperty.h Revert name change 2008-07-01 22:57:50 +00:00
gdkrectangle.c Revert name change 2008-07-01 22:57:50 +00:00
gdkregion-generic.c Include "config.h" instead of <config.h> Command used: find -name 2008-06-22 14:28:52 +00:00
gdkregion-generic.h Handle a borderline case correctly 2007-04-18 15:19:58 +00:00
gdkregion.h Revert name change 2008-07-01 22:57:50 +00:00
gdkrgb.c use g_error() instead of a combination of g_warning+exit to avoid 2008-08-07 14:23:07 +00:00
gdkrgb.h Revert name change 2008-07-01 22:57:50 +00:00
gdkscreen.c gdk/gdkdraw.c gdk/gdkimage.c gdk/gdkscreen.c replace assertions for obj != 2008-10-21 21:42:39 +00:00
gdkscreen.h define __GDK_H_INSIDE__ around including all other headers. 2008-05-28 14:01:57 +00:00
gdkselection.c Bug 544684 - Win64 issue, window handles are assumed to be 32-bit 2008-08-04 22:43:57 +00:00
gdkselection.h Bug 544684 - Win64 issue, window handles are assumed to be 32-bit 2008-08-04 22:43:57 +00:00
gdkspawn.h define __GDK_H_INSIDE__ around including all other headers. 2008-05-28 14:01:57 +00:00
gdktestutils.h gdk/gdkapplaunchcontext.h gdk/gdktestutils.h gtk/gtkmountoperation.h 2008-05-30 12:08:30 +00:00
gdktypes.h Revert name change 2008-07-01 22:57:50 +00:00
gdkvisual.c Revert name change 2008-07-01 22:57:50 +00:00
gdkvisual.h Revert name change 2008-07-01 22:57:50 +00:00
gdkwindow.c Use a different approach to snapshotting that is in line with what is done 2009-01-23 05:34:14 +00:00
gdkwindow.h Bug 539263 – Deprecate gdk_window_get_toplevels 2008-11-30 05:04:29 +00:00
gdkwindowimpl.c Fix make check 2008-07-04 04:02:35 +00:00
gdkwindowimpl.h Revert name change 2008-07-01 22:57:50 +00:00
gen-keyname-table.pl Generate N_() calls for translatable key names. 2005-06-10 06:41:04 +00:00
keyname-table.h fix small typo. 2008-10-28 22:55:23 +00:00
keynames.txt Mark arrow keys as translatable 2006-12-21 05:11:00 +00:00
makeenums.pl Add GdkEventSetting event for notification of changes to system settings, 2001-04-02 23:33:47 +00:00
Makefile.am Bug 569435 – make maintainer-clean removes non-generated sources 2009-01-29 07:35:33 +00:00
makefile.msc build gdkwindowimpl 2008-08-01 14:43:22 +00:00
makegdkalias.pl Make PLT-reduction work with gcc4, and don't include everything in 2005-03-16 03:17:27 +00:00
pltcheck.sh Commit a patch by Behdad to fix typos, omissions and other errors in the 2006-09-10 06:39:16 +00:00
testgdk.c Include "config.h" instead of <config.h> Command used: find -name 2008-06-22 14:28:52 +00:00