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 135666 - GtkWidget style property to disable prelight
GtkWidget style property to disable prelight
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2004-02-28 08:32 UTC by Miro Halas
Modified: 2014-08-03 14:59 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
Patch (1.75 KB, patch)
2006-03-02 15:28 UTC, Ross Burton
none Details | Review
Revised patch using gtk-touchscreen-mode (1008 bytes, patch)
2006-03-08 17:44 UTC, Ross Burton
none Details | Review
Cunning change (828 bytes, patch)
2006-03-08 18:06 UTC, Ross Burton
none Details | Review
Revised patch (3.40 KB, patch)
2006-03-09 09:20 UTC, Ross Burton
none Details | Review
Getting there (4.54 KB, patch)
2006-03-09 09:51 UTC, Ross Burton
none Details | Review

Description Miro Halas 2004-02-28 08:32:22 UTC
There is no ability to disable prelight and I think there should be.

I have seen references that it is enough to set prelight to normal, but 
it is not correct, because prelight can be reach from normal or from 
active.

My problem is that I am using touchscreen and there users don't move 
cursor around screen they just touch on one place and the cursor remains 
there until they touch again.

If the user interface contains for example toggle buttons (pushed = on, 
not pushed = off) then when they touch the cursor remains on the button 
so the button is prelighted and the user cannot see if the button is 
pushed or not so they have no confirmation of their action until they 
touch somewhere else.
Comment 1 Soren Sandmann Pedersen 2004-02-28 09:54:12 UTC
> I have seen references that it is enough to set prelight to normal, 
> but it is not correct, because prelight can be reach from normal or
> from active.

So, what you are saying is that a widget in the ACTIVE state is
sometimes prelighted, and if you set the prelight color to the NORMAL
color, you will still see the prelighting?
Comment 2 Miro Halas 2004-02-28 09:59:10 UTC
No, let say the button is in normal state with normal color and user 
tap on it and it changes it to active but since the cursor stays on 
the button, the button shows as prelighted so user doesn't really 
see any difference. So he taps on it again and changes it back to 
normal but again, the bursor stays on the button and the button 
shows as prelighted and user doesn't see any difference. To actually 
see the outcome of his/her action, user must tap somewhere else to 
see in what state the button is.
Comment 3 Soren Sandmann Pedersen 2004-02-28 10:13:34 UTC
But a toggle button is showed pushed down when it is active, so even
if its color is the prelight one, it is still possible to see the
difference.

Comment 4 Miro Halas 2004-02-28 10:19:20 UTC
Definitely not on my screen or maybe not in my eyes. Since the 
background color is the same when it is on or off, because cursor is 
over the button, the only think you can go by is the border of the 
button. That is not enough, the difference is very small. Especially 
if your monitor is not extra sharp. I am working on applicatiosn 
with touchscreens, these are used in conditions, when the light is 
not ideal, the screen is often dirty from fingers and to go just by 
difference in one line 1-2 pixel wide is not enough. The users 
really need to see the difference and the color would help much 
better.
Comment 5 Owen Taylor 2004-02-28 19:59:11 UTC
Of course, really the *right* solution here in some sense 
is to use XInput drivers for your touchscreen that give
ProximityIn/Out events, have GTK+ enable the input device
in extended mode, and then react to the ProximtyIn/Out events.

But since it's pretty hard to get everything there done,
disabling prelight is an easier way of handling this, certainly.
It would presumbaly be done as a GtkWidget style property,
which we would then make all the widgets that prelight obey.

(Style property should probably be GtkWidget::enable-prelight
defaulting to TRUE)



Comment 6 Ross Burton 2006-03-02 15:28:08 UTC
Created attachment 60502 [details] [review]
Patch

The attached patch semi-works: if I change the default value of the enable-prelight property to FALSE there is no prelighting on GtkButtons.

However, if I try and change it in a gtkrc file with:

style "testing" {
  GtkWidget::enable-prelight = FALSE
}
class "GtkWidget" style "testing"

I get an error message:

Gtk-Message: /home/ross/.gtkrc-2.0:33: failed to retrieve property `GtkWidget::enable-prelight' of type `gboolean' from rc file value "((GString*) 0x8149cc0)" of type `GString'

Not sure why that is...
Comment 7 Ross Burton 2006-03-02 15:43:09 UTC
My mistake, I need to use 0 rather than FALSE.  The patch works as expected.
Comment 8 Ross Burton 2006-03-08 17:44:40 UTC
Created attachment 60927 [details] [review]
Revised patch using gtk-touchscreen-mode

A different take using the gtk-touchscreen-mode property.  I'm not sure if calling g_object_get in every paint event is sane.
Comment 9 Ross Burton 2006-03-08 18:06:03 UTC
Created attachment 60929 [details] [review]
Cunning change

This patch is an alternative way of doing patch 60927, which modifies gtk_widget_set_state() to change all prelight states to normal.  This is a deeper change, and doesn't effect all widgets as expected: for example scrollbar arrows are still prelighting.  However, this change may effect more widgets on its own, but will it break anything?
Comment 10 Matthias Clasen 2006-03-09 05:57:52 UTC
I don't think it will break things. I like this approach; we'll have to handle
the few widgets separately which prelight in some other way.
Comment 11 Ross Burton 2006-03-09 07:25:35 UTC
Okay, I'll carry on with this approach.  I'm currently looking at GtkRange.
Comment 12 Michael Natterer 2006-03-09 09:07:46 UTC
Indeed, that looks very nice and much less invasive than changing
many widgets individually.

Comment 13 Ross Burton 2006-03-09 09:20:26 UTC
Created attachment 60954 [details] [review]
Revised patch

Updated patch, now handling GtkWidget and GtkRange.

How expensive is calling g_object_get(gtk_widget_get_settings(widget)) every expose?  Should I listen for notify::gtk-touchscreen-mode when the widget is created instead?
Comment 14 Ross Burton 2006-03-09 09:51:12 UTC
Created attachment 60956 [details] [review]
Getting there

Now patching gtktogglebutton, so The Widget Factory isn't showing any prelighting at all.
Comment 15 Matthias Clasen 2006-03-09 14:33:56 UTC
I do agree with Owens comment #5, btw that the really correct way to handle
prelighting on touchscreens would make use of proximity events.
But that is probably a longer-term project...
Comment 16 Michael Natterer 2006-03-09 14:52:43 UTC
I tend to disagree, because proximity requires an active pen, which is
only not available if the "pen" is your finger or the 770 stylus.
Comment 17 Matthias Clasen 2006-03-09 18:32:27 UTC
Ross, that patch looks good to me.
Comment 18 Ross Burton 2006-03-09 18:49:05 UTC
Committed to HEAD, thanks.
Comment 19 Michael Natterer 2006-07-27 12:03:52 UTC
Unfortunately, it doesn't work this way :( At least not generically
in gtkwidget.c

Using PRELIGHT for drawing doesn't neccessarily mean the mouse is
hovering the widget (I know it actually should mean that, but it doesn't).

For example in GtkMenuItem, we set the item's state to PRELIGHT when
it is selected, and there are probably other cases that do similar things.

What confuses me quite a bit is that the menu item appears as if it
was in SELECTED state, even tho it was set to PRELIGHT. Can anyone
un-confuse me please?
Comment 20 Michael Natterer 2006-07-27 12:18:00 UTC
Hm, I just replaced all PRELIGHT in the menu code by SELECTED, and
it appears to work perfecty, both with any without touchscreen mode
enabled.

However this doesn't fix my confusion from the previous comment,
why does the menu code use PRELIGHT at all, and why does it work?
Comment 21 Matthias Clasen 2006-08-01 19:09:00 UTC
Mitch you had some newer findings on this, right ?
Comment 22 Michael Natterer 2006-08-01 19:27:27 UTC
Yes, i figured that the default PRELIGHT color for menu items is hardcoded
in a parsed rc string in gtkrc.c, so this mystery is solved.

However since GtkMenuItem uses PRELIGHT where it should use SELECTED,
we have a problem here. With the patch from this bug which disables
PRELIGHT in gtkwidget.c, it is no longer possible to select any menu
item.

We can hardly change the states of GtkMenuItem since that would
break themes and (rarely) code which checks the states, so the change
to gtkwidget.c should probably be reverted.
Comment 23 Owen Taylor 2006-08-01 20:01:01 UTC
In case it isn't obvious, at one point, menu items in GTK+ were 
prelighted identically to buttons, not "selected" in a darker color.

So using PRELIGHT wasn't weird at all and it wasn't really possible
to change it.

I pretty much stand by my comment #5 from two years ago; this needs
to be done widget by widget.

States in GTK+ are too close to being "colors" to make any assumption
about what GtkStateType is used for what semantic meaning.
Comment 24 Amund Hov 2009-04-24 20:20:27 UTC
What's the status of this? I'm having the exact same issue using touch-screens and would very much like this patch or something equivalent to be available.
Comment 25 Matthias Clasen 2014-08-03 14:59:19 UTC
I believe that this is mostly addressed now with touch support in gtk3