Bug 14711 - RenderThemeGdk's buttons are state-agnostic (pressed, hovered)
Summary: RenderThemeGdk's buttons are state-agnostic (pressed, hovered)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 523.x (Safari 3)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-22 04:19 PDT by Nigel Tao
Modified: 2007-07-28 18:39 PDT (History)
0 users

See Also:


Attachments
Simple Patch (1.74 KB, patch)
2007-07-22 04:20 PDT, Nigel Tao
no flags Details | Formatted Diff | Diff
Better Simple Patch (1.78 KB, patch)
2007-07-23 05:32 PDT, Nigel Tao
no flags Details | Formatted Diff | Diff
Make use of widget state in RenderThemeGdk (6.40 KB, patch)
2007-07-24 11:23 PDT, Alp Toker
aroben: review+
Details | Formatted Diff | Diff
Make use of widget state in RenderThemeGdk (6.40 KB, patch)
2007-07-24 11:27 PDT, Alp Toker
aroben: review+
Details | Formatted Diff | Diff
Follow-up for shadow state and theming bug workaround (4.12 KB, patch)
2007-07-28 18:25 PDT, Alp Toker
no flags Details | Formatted Diff | Diff
Follow-up for shadow state and theming bug workaround (take two) (4.13 KB, patch)
2007-07-28 18:27 PDT, Alp Toker
mrowe: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nigel Tao 2007-07-22 04:19:22 PDT
On the GTK platform (built using "./build-webkit --gdk") the buttons don't look any different when pressed, or when hovered over, even though the GTK theme supports this.
Comment 1 Nigel Tao 2007-07-22 04:20:41 PDT
Created attachment 15618 [details]
Simple Patch
Comment 2 Adam Roben (:aroben) 2007-07-22 12:11:39 PDT
Comment on attachment 15618 [details]
Simple Patch

+    GtkStateType state_type = isHovered(o)
+        ? (isPressed(o) ? GTK_STATE_ACTIVE : GTK_STATE_PRELIGHT)
+        : GTK_STATE_NORMAL;

I think this line would be clearer as:

GtkStateType state_type = isPressed(o) ? GTK_STATE_ACTIVE : (isHovered(o) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL);

...or...

GtkStateType state_type = GTK_STATE_NORMAL;
if (isPressed(o))
    state_type = GTK_STATE_ACTIVE;
else if (isHovered(o))
    state_type = GTK_STATE_PRELIGHT;

I personally prefer the second one.

Also, the variable name sould be `stateType` to adhere to our style guidelines <http://webkit.org/coding/coding-style.html>
Comment 3 Nigel Tao 2007-07-23 05:32:19 PDT
Created attachment 15647 [details]
Better Simple Patch
Comment 4 Alp Toker 2007-07-24 11:23:28 PDT
Created attachment 15666 [details]
Make use of widget state in RenderThemeGdk
Comment 5 Alp Toker 2007-07-24 11:27:23 PDT
Created attachment 15667 [details]
Make use of widget state in RenderThemeGdk

Indentation corrected in this revision.
Comment 6 Adam Roben (:aroben) 2007-07-24 11:28:59 PDT
Comment on attachment 15666 [details]
Make use of widget state in RenderThemeGdk

isChecked(o) ? GTK_SHADOW_IN : GTK_SHADOW_OUT

Perhaps this code should become another helper function called `checkedState` (or shadowState if that makes more sense in Gtk terminology)

r=me
Comment 7 Adam Roben (:aroben) 2007-07-24 11:32:22 PDT
Comment on attachment 15667 [details]
Make use of widget state in RenderThemeGdk

r=me to this one too, same comments as above.
Comment 8 Alp Toker 2007-07-24 11:41:37 PDT
Fixed in r24595.
Comment 9 Nigel Tao 2007-07-26 06:15:38 PDT
It looks like Alp Toker's patch has landed in trunk, but the pushbuttons' backgrounds are still being (incorrectly) filled in.  You can see the problem in the screenshot at http://blogs.gnome.org/nigeltao/files/2007/07/gdk-webkit-buttons.png

You might want to apply this part of my patch:

Index: WebCore/platform/gdk/RenderThemeGdk.cpp
===================================================================
--- WebCore/platform/gdk/RenderThemeGdk.cpp     (revision 24641)
+++ WebCore/platform/gdk/RenderThemeGdk.cpp     (working copy)
@@ -288,7 +288,13 @@
 {
     if (!m_container) {
         m_unmappedWindow = gtk_window_new(GTK_WINDOW_POPUP);
-        m_container = gtk_fixed_new();
+        // Some GTK themes (i.e. Clearlooks) draw the buttons differently
+        // (in particular, call gtk_style_apply_default_background) if they
+        // are unallocated and are children of a GtkFixed widget, which is
+        // apparently what some "make Firefox buttons look like GTK" code
+        // does.  To avoid this ugly look, we use a GtkHBox as a parent,
+        // rather than a GtkFixed.
+        m_container = gtk_hbox_new(false, 0);
         gtk_container_add(GTK_CONTAINER(m_unmappedWindow), m_container);
         gtk_widget_realize(m_unmappedWindow);
     }
Comment 10 Alp Toker 2007-07-28 18:25:01 PDT
Created attachment 15721 [details]
Follow-up for shadow state and theming bug workaround
Comment 11 Alp Toker 2007-07-28 18:27:35 PDT
Created attachment 15722 [details]
Follow-up for shadow state and theming bug workaround (take two)

Remove the old code we're replacing this time.
Comment 12 Mark Rowe (bdash) 2007-07-28 18:32:03 PDT
Comment on attachment 15722 [details]
Follow-up for shadow state and theming bug workaround (take two)

r=me