Commit 815ffe2e authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Stop the timer on destroy, or when we are notified that we are shadowed by

Tue Jan 15 18:10:24 2002  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkspinbutton.c (gtk_spin_button_grab_notify): Stop
	the timer on destroy, or when we are notified that we are
	shadowed by a modal dialog.

	* gtk/gtkspinbutton.c: Remove explicit gtk_grab_add()/remove() -
	not needed any more.

	* gtk/gtkmain.c (gtk_grab_notify): Fix problem where notifications
	weren't sent out for the default grab group.

	* gtk/gtkmain.c (gtk_grab_notify): Fix notification of widgets that
	were getting events because they were part of the previous grab.
parent 08431c79
Tue Jan 15 18:10:24 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkspinbutton.c (gtk_spin_button_grab_notify): Stop
the timer on destroy, or when we are notified that we are
shadowed by a modal dialog.
* gtk/gtkspinbutton.c: Remove explicit gtk_grab_add()/remove() -
not needed any more.
* gtk/gtkmain.c (gtk_grab_notify): Fix problem where notifications
weren't sent out for the default grab group.
* gtk/gtkmain.c (gtk_grab_notify): Fix notification of widgets that
were getting events because they were part of the previous grab.
Tue Jan 15 12:23:33 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtknotebook.c (gtk_notebook_mnemonic_activate_switch_page):
......
Tue Jan 15 18:10:24 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkspinbutton.c (gtk_spin_button_grab_notify): Stop
the timer on destroy, or when we are notified that we are
shadowed by a modal dialog.
* gtk/gtkspinbutton.c: Remove explicit gtk_grab_add()/remove() -
not needed any more.
* gtk/gtkmain.c (gtk_grab_notify): Fix problem where notifications
weren't sent out for the default grab group.
* gtk/gtkmain.c (gtk_grab_notify): Fix notification of widgets that
were getting events because they were part of the previous grab.
Tue Jan 15 12:23:33 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtknotebook.c (gtk_notebook_mnemonic_activate_switch_page):
......
Tue Jan 15 18:10:24 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkspinbutton.c (gtk_spin_button_grab_notify): Stop
the timer on destroy, or when we are notified that we are
shadowed by a modal dialog.
* gtk/gtkspinbutton.c: Remove explicit gtk_grab_add()/remove() -
not needed any more.
* gtk/gtkmain.c (gtk_grab_notify): Fix problem where notifications
weren't sent out for the default grab group.
* gtk/gtkmain.c (gtk_grab_notify): Fix notification of widgets that
were getting events because they were part of the previous grab.
Tue Jan 15 12:23:33 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtknotebook.c (gtk_notebook_mnemonic_activate_switch_page):
......
Tue Jan 15 18:10:24 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkspinbutton.c (gtk_spin_button_grab_notify): Stop
the timer on destroy, or when we are notified that we are
shadowed by a modal dialog.
* gtk/gtkspinbutton.c: Remove explicit gtk_grab_add()/remove() -
not needed any more.
* gtk/gtkmain.c (gtk_grab_notify): Fix problem where notifications
weren't sent out for the default grab group.
* gtk/gtkmain.c (gtk_grab_notify): Fix notification of widgets that
were getting events because they were part of the previous grab.
Tue Jan 15 12:23:33 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtknotebook.c (gtk_notebook_mnemonic_activate_switch_page):
......
Tue Jan 15 18:10:24 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkspinbutton.c (gtk_spin_button_grab_notify): Stop
the timer on destroy, or when we are notified that we are
shadowed by a modal dialog.
* gtk/gtkspinbutton.c: Remove explicit gtk_grab_add()/remove() -
not needed any more.
* gtk/gtkmain.c (gtk_grab_notify): Fix problem where notifications
weren't sent out for the default grab group.
* gtk/gtkmain.c (gtk_grab_notify): Fix notification of widgets that
were getting events because they were part of the previous grab.
Tue Jan 15 12:23:33 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtknotebook.c (gtk_notebook_mnemonic_activate_switch_page):
......
Tue Jan 15 18:10:24 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkspinbutton.c (gtk_spin_button_grab_notify): Stop
the timer on destroy, or when we are notified that we are
shadowed by a modal dialog.
* gtk/gtkspinbutton.c: Remove explicit gtk_grab_add()/remove() -
not needed any more.
* gtk/gtkmain.c (gtk_grab_notify): Fix problem where notifications
weren't sent out for the default grab group.
* gtk/gtkmain.c (gtk_grab_notify): Fix notification of widgets that
were getting events because they were part of the previous grab.
Tue Jan 15 12:23:33 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtknotebook.c (gtk_notebook_mnemonic_activate_switch_page):
......
Tue Jan 15 18:10:24 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkspinbutton.c (gtk_spin_button_grab_notify): Stop
the timer on destroy, or when we are notified that we are
shadowed by a modal dialog.
* gtk/gtkspinbutton.c: Remove explicit gtk_grab_add()/remove() -
not needed any more.
* gtk/gtkmain.c (gtk_grab_notify): Fix problem where notifications
weren't sent out for the default grab group.
* gtk/gtkmain.c (gtk_grab_notify): Fix notification of widgets that
were getting events because they were part of the previous grab.
Tue Jan 15 12:23:33 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtknotebook.c (gtk_notebook_mnemonic_activate_switch_page):
......
......@@ -1157,25 +1157,37 @@ gtk_main_get_window_group (GtkWidget *widget)
typedef struct
{
gboolean was_grabbed;
GtkWidget *grab_widget;
GtkWidget *old_grab_widget;
GtkWidget *new_grab_widget;
} GrabNotifyInfo;
static gboolean
check_is_grabbed (GtkWidget *widget,
GtkWidget *grab_widget)
{
if (grab_widget)
return !(widget == grab_widget || gtk_widget_is_ancestor (widget, grab_widget));
else
return TRUE;
}
static void
gtk_grab_notify_foreach (GtkWidget *child,
gpointer data)
{
GrabNotifyInfo *info = data;
gboolean was_grabbed = check_is_grabbed (child, info->old_grab_widget);
gboolean is_grabbed = check_is_grabbed (child, info->new_grab_widget);
if (child != info->grab_widget)
if (was_grabbed != is_grabbed)
{
g_object_ref (G_OBJECT (child));
gtk_signal_emit_by_name (GTK_OBJECT (child), "grab_notify", info->was_grabbed);
gtk_signal_emit_by_name (GTK_OBJECT (child), "grab_notify", was_grabbed);
if (GTK_IS_CONTAINER (child))
gtk_container_foreach (GTK_CONTAINER (child), gtk_grab_notify_foreach, info);
gtk_container_foreach (GTK_CONTAINER (child), gtk_grab_notify_foreach, info);
g_object_unref (G_OBJECT (child));
}
......@@ -1189,8 +1201,16 @@ gtk_grab_notify (GtkWindowGroup *group,
GList *toplevels;
GrabNotifyInfo info;
info.grab_widget = grab_widget;
info.was_grabbed = was_grabbed;
if (was_grabbed)
{
info.old_grab_widget = grab_widget;
info.new_grab_widget = group->grabs ? group->grabs->data : NULL;
}
else
{
info.old_grab_widget = (group->grabs && group->grabs->next) ? group->grabs->next->data : NULL;
info.new_grab_widget = grab_widget;
}
g_object_ref (group);
g_object_ref (grab_widget);
......@@ -1203,7 +1223,7 @@ gtk_grab_notify (GtkWindowGroup *group,
GtkWindow *toplevel = toplevels->data;
toplevels = g_list_delete_link (toplevels, toplevels);
if (group == toplevel->group)
if (group == _gtk_window_get_group (toplevel))
gtk_container_foreach (GTK_CONTAINER (toplevel), gtk_grab_notify_foreach, &info);
g_object_unref (toplevel);
}
......@@ -1231,8 +1251,7 @@ gtk_grab_add (GtkWidget *widget)
gtk_widget_ref (widget);
group->grabs = g_slist_prepend (group->grabs, widget);
if (!was_grabbed)
gtk_grab_notify (group, widget, FALSE);
gtk_grab_notify (group, widget, FALSE);
}
}
......@@ -1264,8 +1283,7 @@ gtk_grab_remove (GtkWidget *widget)
gtk_widget_unref (widget);
if (!group->grabs)
gtk_grab_notify (group, widget, TRUE);
gtk_grab_notify (group, widget, TRUE);
}
}
......
......@@ -72,6 +72,7 @@ static void gtk_spin_button_class_init (GtkSpinButtonClass *klass);
static void gtk_spin_button_editable_init (GtkEditableClass *iface);
static void gtk_spin_button_init (GtkSpinButton *spin_button);
static void gtk_spin_button_finalize (GObject *object);
static void gtk_spin_button_destroy (GtkObject *object);
static void gtk_spin_button_set_property (GObject *object,
guint prop_id,
const GValue *value,
......@@ -102,9 +103,12 @@ static gint gtk_spin_button_leave_notify (GtkWidget *widget,
GdkEventCrossing *event);
static gint gtk_spin_button_focus_out (GtkWidget *widget,
GdkEventFocus *event);
static void gtk_spin_button_grab_notify (GtkWidget *widget,
gboolean was_grabbed);
static void gtk_spin_button_draw_arrow (GtkSpinButton *spin_button,
guint arrow);
static gint gtk_spin_button_timer (GtkSpinButton *spin_button);
static void gtk_spin_button_stop_spinning (GtkSpinButton *spin);
static void gtk_spin_button_value_changed (GtkAdjustment *adjustment,
GtkSpinButton *spin_button);
static gint gtk_spin_button_key_press (GtkWidget *widget,
......@@ -186,6 +190,8 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
gobject_class->set_property = gtk_spin_button_set_property;
gobject_class->get_property = gtk_spin_button_get_property;
object_class->destroy = gtk_spin_button_destroy;
widget_class->map = gtk_spin_button_map;
widget_class->unmap = gtk_spin_button_unmap;
widget_class->realize = gtk_spin_button_realize;
......@@ -202,6 +208,7 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
widget_class->enter_notify_event = gtk_spin_button_enter_notify;
widget_class->leave_notify_event = gtk_spin_button_leave_notify;
widget_class->focus_out_event = gtk_spin_button_focus_out;
widget_class->grab_notify = gtk_spin_button_grab_notify;
entry_class->activate = gtk_spin_button_activate;
......@@ -444,6 +451,14 @@ gtk_spin_button_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gtk_spin_button_destroy (GtkObject *object)
{
gtk_spin_button_stop_spinning (GTK_SPIN_BUTTON (object));
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
gtk_spin_button_map (GtkWidget *widget)
{
......@@ -891,6 +906,14 @@ gtk_spin_button_focus_out (GtkWidget *widget,
return GTK_WIDGET_CLASS (parent_class)->focus_out_event (widget, event);
}
static void
gtk_spin_button_grab_notify (GtkWidget *widget,
gboolean was_grabbed)
{
if (!was_grabbed)
gtk_spin_button_stop_spinning (GTK_SPIN_BUTTON (widget));
}
static gint
gtk_spin_button_scroll (GtkWidget *widget,
GdkEventScroll *event)
......@@ -920,6 +943,40 @@ gtk_spin_button_scroll (GtkWidget *widget,
return TRUE;
}
static void
gtk_spin_button_stop_spinning(GtkSpinButton *spin)
{
if (spin->timer)
{
gtk_timeout_remove (spin->timer);
spin->timer = 0;
spin->timer_calls = 0;
spin->need_timer = FALSE;
}
spin->button = 0;
spin->timer = 0;
}
static void
start_spinning (GtkSpinButton *spin,
GtkArrowType click_child,
gfloat step)
{
spin->click_child = click_child;
gtk_spin_button_real_spin (spin, click_child == GTK_ARROW_UP ? step : -step);
if (!spin->timer)
{
spin->timer_step = step;
spin->need_timer = TRUE;
spin->timer = gtk_timeout_add (SPIN_BUTTON_INITIAL_TIMER_DELAY,
(GtkFunction) gtk_spin_button_timer, (gpointer) spin);
}
gtk_spin_button_draw_arrow (spin, click_child);
}
static gint
gtk_spin_button_button_press (GtkWidget *widget,
GdkEventButton *event)
......@@ -937,7 +994,6 @@ gtk_spin_button_button_press (GtkWidget *widget,
{
if (!GTK_WIDGET_HAS_FOCUS (widget))
gtk_widget_grab_focus (widget);
gtk_grab_add (widget);
spin->button = event->button;
if (GTK_ENTRY (widget)->editable)
......@@ -945,65 +1001,17 @@ gtk_spin_button_button_press (GtkWidget *widget,
if (event->y <= widget->requisition.height / 2)
{
spin->click_child = GTK_ARROW_UP;
if (event->button == 1)
{
gtk_spin_button_real_spin (spin,
spin->adjustment->step_increment);
if (!spin->timer)
{
spin->timer_step = spin->adjustment->step_increment;
spin->need_timer = TRUE;
spin->timer = gtk_timeout_add
(SPIN_BUTTON_INITIAL_TIMER_DELAY,
(GtkFunction) gtk_spin_button_timer, (gpointer) spin);
}
}
start_spinning (spin, GTK_ARROW_UP, spin->adjustment->step_increment);
else if (event->button == 2)
{
gtk_spin_button_real_spin (spin,
spin->adjustment->page_increment);
if (!spin->timer)
{
spin->timer_step = spin->adjustment->page_increment;
spin->need_timer = TRUE;
spin->timer = gtk_timeout_add
(SPIN_BUTTON_INITIAL_TIMER_DELAY,
(GtkFunction) gtk_spin_button_timer, (gpointer) spin);
}
}
gtk_spin_button_draw_arrow (spin, GTK_ARROW_UP);
start_spinning (spin, GTK_ARROW_UP, spin->adjustment->page_increment);
}
else
{
spin->click_child = GTK_ARROW_DOWN;
if (event->button == 1)
{
gtk_spin_button_real_spin (spin,
-spin->adjustment->step_increment);
if (!spin->timer)
{
spin->timer_step = spin->adjustment->step_increment;
spin->need_timer = TRUE;
spin->timer = gtk_timeout_add
(SPIN_BUTTON_INITIAL_TIMER_DELAY,
(GtkFunction) gtk_spin_button_timer, (gpointer) spin);
}
}
start_spinning (spin, GTK_ARROW_DOWN, spin->adjustment->step_increment);
else if (event->button == 2)
{
gtk_spin_button_real_spin (spin,
-spin->adjustment->page_increment);
if (!spin->timer)
{
spin->timer_step = spin->adjustment->page_increment;
spin->need_timer = TRUE;
spin->timer = gtk_timeout_add
(SPIN_BUTTON_INITIAL_TIMER_DELAY,
(GtkFunction) gtk_spin_button_timer, (gpointer) spin);
}
}
gtk_spin_button_draw_arrow (spin, GTK_ARROW_DOWN);
start_spinning (spin, GTK_ARROW_DOWN, spin->adjustment->page_increment);
}
return TRUE;
}
......@@ -1030,13 +1038,7 @@ gtk_spin_button_button_release (GtkWidget *widget,
{
guint click_child;
if (spin->timer)
{
gtk_timeout_remove (spin->timer);
spin->timer = 0;
spin->timer_calls = 0;
spin->need_timer = FALSE;
}
gtk_spin_button_stop_spinning (spin);
if (event->button == 3)
{
......@@ -1064,10 +1066,8 @@ gtk_spin_button_button_release (GtkWidget *widget,
}
}
}
gtk_grab_remove (widget);
click_child = spin->click_child;
spin->click_child = 2;
spin->button = 0;
gtk_spin_button_draw_arrow (spin, click_child);
return TRUE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment