From ff8ea494f9374353d654eea5e83f35935c363253 Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Thu, 9 Mar 2006 18:48:38 +0000 Subject: [PATCH] Turn off prelighting when gtk-touchscreen-mode is enabled (#135666) 2006-03-09 Ross Burton * gtk/gtkwidget.c: * gtk/gtkrange.c: * gtk/gtktogglebutton.c: Turn off prelighting when gtk-touchscreen-mode is enabled (#135666) --- ChangeLog | 7 +++++++ ChangeLog.pre-2-10 | 7 +++++++ gtk/gtkrange.c | 15 ++++++++++----- gtk/gtktogglebutton.c | 8 ++++++-- gtk/gtkwidget.c | 9 +++++++++ 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index b56c639e9b..9837c110d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-03-09 Ross Burton + + * gtk/gtkwidget.c: + * gtk/gtkrange.c: + * gtk/gtktogglebutton.c: + Turn off prelighting when gtk-touchscreen-mode is enabled (#135666) + Thu Mar 9 14:29:43 2006 Tim Janik * gtk/gtkobject.c (gtk_object_init): move the floating flag from diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index b56c639e9b..9837c110d5 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +2006-03-09 Ross Burton + + * gtk/gtkwidget.c: + * gtk/gtkrange.c: + * gtk/gtktogglebutton.c: + Turn off prelighting when gtk-touchscreen-mode is enabled (#135666) + Thu Mar 9 14:29:43 2006 Tim Janik * gtk/gtkobject.c (gtk_object_init): move the floating flag from diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index eb39e10d15..c3cdf88f66 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -1153,6 +1153,11 @@ gtk_range_expose (GtkWidget *widget, GdkRectangle area; gint focus_line_width = 0; gint focus_padding = 0; + gboolean touchscreen; + + g_object_get (gtk_widget_get_settings (widget), + "gtk-touchscreen-mode", &touchscreen, + NULL); range = GTK_RANGE (widget); @@ -1208,7 +1213,7 @@ gtk_range_expose (GtkWidget *widget, if (!sensitive) state = GTK_STATE_INSENSITIVE; - else if (range->layout->mouse_location == MOUSE_SLIDER) + else if (!touchscreen && range->layout->mouse_location == MOUSE_SLIDER) state = GTK_STATE_PRELIGHT; else state = GTK_STATE_NORMAL; @@ -1238,28 +1243,28 @@ gtk_range_expose (GtkWidget *widget, draw_stepper (range, &range->layout->stepper_a, range->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_UP : GTK_ARROW_LEFT, range->layout->grab_location == MOUSE_STEPPER_A, - range->layout->mouse_location == MOUSE_STEPPER_A, + !touchscreen && range->layout->mouse_location == MOUSE_STEPPER_A, &expose_area); if (range->has_stepper_b) draw_stepper (range, &range->layout->stepper_b, range->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_DOWN : GTK_ARROW_RIGHT, range->layout->grab_location == MOUSE_STEPPER_B, - range->layout->mouse_location == MOUSE_STEPPER_B, + !touchscreen && range->layout->mouse_location == MOUSE_STEPPER_B, &expose_area); if (range->has_stepper_c) draw_stepper (range, &range->layout->stepper_c, range->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_UP : GTK_ARROW_LEFT, range->layout->grab_location == MOUSE_STEPPER_C, - range->layout->mouse_location == MOUSE_STEPPER_C, + !touchscreen && range->layout->mouse_location == MOUSE_STEPPER_C, &expose_area); if (range->has_stepper_d) draw_stepper (range, &range->layout->stepper_d, range->orientation == GTK_ORIENTATION_VERTICAL ? GTK_ARROW_DOWN : GTK_ARROW_RIGHT, range->layout->grab_location == MOUSE_STEPPER_D, - range->layout->mouse_location == MOUSE_STEPPER_D, + !touchscreen && range->layout->mouse_location == MOUSE_STEPPER_D, &expose_area); return FALSE; diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c index a850f3d5b4..5552ec3a63 100644 --- a/gtk/gtktogglebutton.c +++ b/gtk/gtktogglebutton.c @@ -483,9 +483,13 @@ static void gtk_toggle_button_update_state (GtkButton *button) { GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button); - gboolean depressed; + gboolean depressed, touchscreen; GtkStateType new_state; + g_object_get (gtk_widget_get_settings (GTK_WIDGET (button)), + "gtk-touchscreen-mode", &touchscreen, + NULL); + if (toggle_button->inconsistent) depressed = FALSE; else if (button->in_button && button->button_down) @@ -493,7 +497,7 @@ gtk_toggle_button_update_state (GtkButton *button) else depressed = toggle_button->active; - if (button->in_button && (!button->button_down || toggle_button->draw_indicator)) + if (!touchscreen && button->in_button && (!button->button_down || toggle_button->draw_indicator)) new_state = GTK_STATE_PRELIGHT; else new_state = depressed ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 2872df9327..d7687ddef4 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -4317,11 +4317,20 @@ void gtk_widget_set_state (GtkWidget *widget, GtkStateType state) { + gboolean touchscreen; + g_return_if_fail (GTK_IS_WIDGET (widget)); if (state == GTK_WIDGET_STATE (widget)) return; + g_object_get (gtk_widget_get_settings (widget), + "gtk-touchscreen-mode", &touchscreen, + NULL); + + if (touchscreen && state == GTK_STATE_PRELIGHT) + state = GTK_STATE_NORMAL; + if (state == GTK_STATE_INSENSITIVE) gtk_widget_set_sensitive (widget, FALSE); else