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 98207 - gtk_widget_unparent doesn't correctly reset the widget state
gtk_widget_unparent doesn't correctly reset the widget state
Status: RESOLVED WONTFIX
Product: gtk+
Classification: Platform
Component: Widget: Other
2.0.x
Other other
: Normal normal
: Medium fix
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 109213
 
 
Reported: 2002-11-11 03:06 UTC by Ian Peters
Modified: 2014-03-22 19:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
testcase to demonstrate bug (1.20 KB, text/plain)
2002-11-11 03:07 UTC, Ian Peters
  Details
proposed fix (1.02 KB, patch)
2002-11-11 03:07 UTC, Ian Peters
needs-work Details | Review
Patch to the test case demonstrating other side of bug (447 bytes, text/plain)
2002-12-09 22:02 UTC, Owen Taylor
  Details

Description Ian Peters 2002-11-11 03:06:28 UTC
The attached testcase demonstrates how widgets aren't having their state
reset when they are unparented.  In the example program, move your mouse
over the checkbutton, so that it has prelight.  Then, press Alt-O,
activating the Ok button, and the checkbutton will disappear.  Press Alt-O
another time, and the checkbutton will reappear (not underneath the mouse),
but it will still have prelight drawn, as will the Ok button.

The attached patch adds code to call gtk_widget_set_state (widget,
GTK_STATE_NORMAL) on a widget and all of its children when it is
unparented.  This has no affect on a widget that becomes visible underneath
the mouse pointer, etc.
Comment 1 Ian Peters 2002-11-11 03:07:17 UTC
Created attachment 12220 [details]
testcase to demonstrate bug
Comment 2 Ian Peters 2002-11-11 03:07:44 UTC
Created attachment 12221 [details] [review]
proposed fix
Comment 3 Luis Villa 2002-11-12 05:46:36 UTC
Adding the patch keyword.
Comment 4 Owen Taylor 2002-12-09 22:02:43 UTC
Created attachment 12878 [details]
Patch to the test case demonstrating other side of bug
Comment 5 Owen Taylor 2002-12-09 22:04:11 UTC
But simply resetting the state doesn't really work either ...
make the check button draw as a toggle button, and you'll
see that your patch ends up rmeoving the "active" coloring
from a pressed togglebutton when you remove it and add it
back.
Comment 6 Owen Taylor 2002-12-09 22:29:08 UTC
Thinking about it a bit, I think the right approach is:

 - When propagating state, keep track of whether the state
   of the widget is the result of set_state() on the widget
   itself or on a parent using a private GtkWidget flag

 - Consider GTK_WIDGET_STATE_NORMAL to be the "inherite
   from the parent" state.
 
 - When changing the hierarchy, use the private GtkWidget
   flag to properly update inherited states.

 - Make people who call gtk_widget_set_state(widget, foo) 
   responsible for calling gtk_widget_set_state(widget, NORMAL)

This sounds like quite a reasonable amount of work, and the
severity of the bug is small, so I'm going to put on 2.2.1.


 Consider 
Comment 7 Owen Taylor 2002-12-17 15:55:42 UTC
Bug 93389 points out something of a problem with the above
scheme; sometimes a parent widget will want to propagate
different states to different children.

Comment 8 Owen Taylor 2003-05-22 14:38:40 UTC
See also bug 109213 for a case where state should *not*
propagate.

Thinking through all of this is going to be a semi-major project
so I'm going to put on the 2.4 milestone.
Comment 9 Matthias Clasen 2014-03-22 19:58:56 UTC
This has all changed considerably since 2003, I don't think keeping this bug open is useful.