After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 148535 - add drop shadow to menus, tooltips, etc. under Windows XP
add drop shadow to menus, tooltips, etc. under Windows XP
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Win32
2.4.x
Other Windows
: Low enhancement
: Small feature
Assigned To: gtk-win32 maintainers
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2004-07-27 02:05 UTC by Tim Evans
Modified: 2007-06-10 18:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch against gtk+-2.4.1 (1.14 KB, patch)
2004-07-27 02:15 UTC, Tim Evans
none Details | Review
Patch, along the lines of what Owen requested (4.36 KB, patch)
2006-03-25 19:31 UTC, Dominic Lachowicz
none Details | Review
previous patch, sans typo (4.36 KB, patch)
2006-03-28 03:19 UTC, Dominic Lachowicz
none Details | Review
Experimental patch to implement drop shadows from type hints (6.74 KB, patch)
2007-01-31 05:31 UTC, Tim Evans
none Details | Review
Updated patch (7.40 KB, patch)
2007-01-31 23:38 UTC, Tim Evans
committed Details | Review

Description Tim Evans 2004-07-27 02:05:01 UTC
On Windows XP, it is normal for tooltips, menus, and other similar windows to
have a drop shadow displayed under them.  This type of window is what the GDK
window type GDK_WINDOW_TEMP covers, so it would seem that all windows of this
type should have a drop shadow.  The drop shadow is created by setting the
CS_DROPSHADOW bit in the class style.  Windows 2000 or less does not support
drop shadows.

I will create a patch that adds this feature.
Comment 1 Tim Evans 2004-07-27 02:15:17 UTC
Created attachment 29918 [details] [review]
Patch against gtk+-2.4.1

Note that as well as adding the CS_DROPSHADOW class style, I have changed
gtkdnd-win32.c so that it ignores the drop shadow (which is implemented by
win32 as a separate window) when searching for drop windows.
Comment 2 Owen Taylor 2004-07-27 13:22:52 UTC
Temporary windows have no semantic meaning and may be used for any
borderless window that doesn't need to receive focus. You'd have
to modify the GTK+ core in some way to provide the necesarry
semantic information.
Comment 3 Tim Evans 2004-07-28 01:25:34 UTC
Ah, I see.  I assume that the correct way to do this be to add
GDK_DECOR_DROPSHADOW to GdkWMDecoration?  The appropriate parts of GTK (menus,
tooltips, ...) could then set this decoration on their windows when they are
realized.

The difficulty here is that the drop shadow is a window class style, and cannot
be set on individual windows.   I could change GDK to create shadowed and
non-shadowed versions of all its window classes, but it's not possible to change
a window's class after the window has been created.  Maybe the solution is for
me to work out how to manually create and attach a window of the "SysShadow"
class for the existing window.
Comment 4 Owen Taylor 2004-07-28 14:13:38 UTC
The natural way in the GTK+ framework would be to use 
gtk_window_set_role() to set rules like "gtk-menu" on the GdkWindows
and then to interpret that in the Windows backend.

If you can't change the drop shadow on the fly, we could extend
GdkWindowAttr so that the role can be set on creation and make
GtkWindow use that. Though it would certainly not be ideal.
Comment 5 Tim Evans 2004-07-28 21:56:05 UTC
From reading the docs, it would seem that gtk_window_set_type_hint would be
better.  It would maybe require a new GDK_WINDOW_TYPE_HINT_TOOLTIP and maybe
even something for dnd-icon windows.  The type hint also has the advantage that
the documentation already says that it must be set before the window becomes
visible.
Comment 6 Todd A. Fisher 2004-09-19 03:13:48 UTC
According to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windowclasses/aboutwindow.asp
CS_DROPSHADOW
Windows XP: Enables the drop shadow effect on a window. The effect is turned on
and off through SPI_SETDROPSHADOW. Typically, this is enabled for small,
short-lived windows such as menus to emphasize their Z order relationship to
other windows.
Comment 7 Dominic Lachowicz 2006-03-24 18:19:42 UTC
As a theme author, I'd like to see this patch committed. It makes GTK+ apps feel less alien on Windows XP.

There is a strong relationship between GDK_WINDOW_TEMP's semantics ("override redirect temporary window") and the semantics that SPI_SETDROPSHADOW implies. More importantly, their use cases (primarily used to designate menus, tooltips, auto-complete, and combo box popups) overlap in practice. So, this behavior is correct 9 times out of 10, instead of maybe 1 out of 10. Changing the default behavior to accomodate the primary use cases seems like the right thing to do.
Comment 8 Owen Taylor 2006-03-24 18:33:27 UTC
I really think this should be done right (see my previous comment),
then with a bad hack that improves 90% of windows and breaks 10% of
windows....
Comment 9 Owen Taylor 2006-03-24 18:36:11 UTC
BTW - auto-complete and combo box popups don't normally have drop
shadows in XP...
Comment 10 Dominic Lachowicz 2006-03-25 19:31:52 UTC
Created attachment 61998 [details] [review]
Patch, along the lines of what Owen requested

This is hopefully more to Owen's liking
Comment 11 Dominic Lachowicz 2006-03-28 03:19:27 UTC
Created attachment 62171 [details] [review]
previous patch, sans typo
Comment 12 Matthias Clasen 2006-05-05 03:28:30 UTC
IMO, we should use the window type hints that soeren recently introduced
for this.
Comment 13 Tim Evans 2007-01-31 05:14:38 UTC
With the structure of gtk and win32 it's not at all easy to use type hints to add drop shadows.  The choice of shadow or not must be made when creating the HWND, as it's a choice between two win32 window classes.  The HWND behind a GdkWindow is created when the GdkWindow is created.  GtkWindow sets the type hint on the GdkWindow right after creating it, which is too late -- the HWND is already there and using the wrong class.  Unless I'm missing something the patch above fails because of this problem.
Comment 14 Tim Evans 2007-01-31 05:31:16 UTC
Created attachment 81568 [details] [review]
Experimental patch to implement drop shadows from type hints

This patch (based on the patch from Dom Lachowicz) implements drop shadows based on the window type hint.  To do this, I added a new function gdk_window_new_with_type_hint() that lets me pass the type hint in when the window is created.  If this approach is acceptable I'll clean the patch up for inclusion.
Comment 15 Owen Taylor 2007-01-31 15:18:30 UTC
I would suggest extending GdkWindowAttr instead; this can be done while
preserving source and binary compatibility because of the use of a mask
saying which fields are set.

(Obviously any final patch for this would have to handle the other
backends as well...)
Comment 16 Tim Evans 2007-01-31 23:38:14 UTC
Created attachment 81634 [details] [review]
Updated patch

Updated patch attached that modifies GdkWindowAttr instead.  Added code to the other backends to get the type hint out of the GdkWindowAttr structure, but I don't have any way to test it.  Added basic documentation of the changes but again I don't have a build environment for the docs.

Could gdk_window_set_type_hint() be deprecated with these changes, or would that be too large a change to non-win32 applications?
Comment 17 Cody Russell 2007-04-25 23:50:36 UTC
Tested and applied to trunk and gtk-2-10.