Commit c8a2382b authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Remove OwnerGrabButtonMask from button entries for GDK_BUTTON_PRESS /

Fri Feb 18 14:37:29 2000  Owen Taylor  <otaylor@redhat.com>

	* gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Remove
	OwnerGrabButtonMask from button entries for
	GDK_BUTTON_PRESS / GDK_BUTTON_RELEASE.

	* gtk/gtklayout.c (gtk_layout_realize): Always add GDK_SCROLL
	to the event mask (which will result in button/press release
	being added to the event mask on Unix) so scrolling works
	for layouts in scroll windows.

	* gdk/gdkevents.h (enum): Fix up GDK_ALL_EVENTS_MASK.

	Patch from Anders Carlsson  <andersca@picard.andersnet> to add
	a scroll event.

 	* gtk/testgtk.c (scroll_test_scroll): Added an example of mouse wheel
 	scrolling to the "Test Scrolling" part of testgtk.

 	* gtk/gtkwidget.h (struct _GtkWidgetClass): Added scroll_event signal.

 	* gtk/gtkwidget.c: Added "scroll_event" GTK+ signal and matched
 	it against GDK_SCROLL.

 	* gtk/gtkrange.c (gtk_range_scroll_event): Updated to use the new
 	way of mouse wheel scrolling.

 	* gtk/gtkscrolledwindow.c (gtk_scrolled_window_scroll_event): Likewise.

 	* gtk/gtkspinbutton.c (gtk_spin_button_scroll): Likewise.

 	* gtk/gtkmain.c: Removed previous mouse wheel hack.

 	* gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Added entry in
 	gdk_event_mask_table.

 	* gdk/x11/gdkevents-x11.c (gdk_event_translate): Added
 	GdkEventScroll handler.

 	* gdk/gdkevents.h: Added GdkEventScroll structure.
parent ab1deac8
Fri Feb 18 14:37:29 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Remove
OwnerGrabButtonMask from button entries for
GDK_BUTTON_PRESS / GDK_BUTTON_RELEASE.
* gtk/gtklayout.c (gtk_layout_realize): Always add GDK_SCROLL
to the event mask (which will result in button/press release
being added to the event mask on Unix) so scrolling works
for layouts in scroll windows.
* gdk/gdkevents.h (enum): Fix up GDK_ALL_EVENTS_MASK.
Patch from Anders Carlsson <andersca@picard.andersnet> to add
a scroll event.
* gtk/testgtk.c (scroll_test_scroll): Added an example of mouse wheel
scrolling to the "Test Scrolling" part of testgtk.
* gtk/gtkwidget.h (struct _GtkWidgetClass): Added scroll_event signal.
* gtk/gtkwidget.c: Added "scroll_event" GTK+ signal and matched
it against GDK_SCROLL.
* gtk/gtkrange.c (gtk_range_scroll_event): Updated to use the new
way of mouse wheel scrolling.
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_scroll_event): Likewise.
* gtk/gtkspinbutton.c (gtk_spin_button_scroll): Likewise.
* gtk/gtkmain.c: Removed previous mouse wheel hack.
* gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Added entry in
gdk_event_mask_table.
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Added
GdkEventScroll handler.
* gdk/gdkevents.h: Added GdkEventScroll structure.
Thu Feb 17 17:10:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gt{h,k,}vpaned.[ch]: Add patch from Jonathan Blandford
......
Fri Feb 18 14:37:29 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Remove
OwnerGrabButtonMask from button entries for
GDK_BUTTON_PRESS / GDK_BUTTON_RELEASE.
* gtk/gtklayout.c (gtk_layout_realize): Always add GDK_SCROLL
to the event mask (which will result in button/press release
being added to the event mask on Unix) so scrolling works
for layouts in scroll windows.
* gdk/gdkevents.h (enum): Fix up GDK_ALL_EVENTS_MASK.
Patch from Anders Carlsson <andersca@picard.andersnet> to add
a scroll event.
* gtk/testgtk.c (scroll_test_scroll): Added an example of mouse wheel
scrolling to the "Test Scrolling" part of testgtk.
* gtk/gtkwidget.h (struct _GtkWidgetClass): Added scroll_event signal.
* gtk/gtkwidget.c: Added "scroll_event" GTK+ signal and matched
it against GDK_SCROLL.
* gtk/gtkrange.c (gtk_range_scroll_event): Updated to use the new
way of mouse wheel scrolling.
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_scroll_event): Likewise.
* gtk/gtkspinbutton.c (gtk_spin_button_scroll): Likewise.
* gtk/gtkmain.c: Removed previous mouse wheel hack.
* gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Added entry in
gdk_event_mask_table.
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Added
GdkEventScroll handler.
* gdk/gdkevents.h: Added GdkEventScroll structure.
Thu Feb 17 17:10:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gt{h,k,}vpaned.[ch]: Add patch from Jonathan Blandford
......
Fri Feb 18 14:37:29 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Remove
OwnerGrabButtonMask from button entries for
GDK_BUTTON_PRESS / GDK_BUTTON_RELEASE.
* gtk/gtklayout.c (gtk_layout_realize): Always add GDK_SCROLL
to the event mask (which will result in button/press release
being added to the event mask on Unix) so scrolling works
for layouts in scroll windows.
* gdk/gdkevents.h (enum): Fix up GDK_ALL_EVENTS_MASK.
Patch from Anders Carlsson <andersca@picard.andersnet> to add
a scroll event.
* gtk/testgtk.c (scroll_test_scroll): Added an example of mouse wheel
scrolling to the "Test Scrolling" part of testgtk.
* gtk/gtkwidget.h (struct _GtkWidgetClass): Added scroll_event signal.
* gtk/gtkwidget.c: Added "scroll_event" GTK+ signal and matched
it against GDK_SCROLL.
* gtk/gtkrange.c (gtk_range_scroll_event): Updated to use the new
way of mouse wheel scrolling.
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_scroll_event): Likewise.
* gtk/gtkspinbutton.c (gtk_spin_button_scroll): Likewise.
* gtk/gtkmain.c: Removed previous mouse wheel hack.
* gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Added entry in
gdk_event_mask_table.
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Added
GdkEventScroll handler.
* gdk/gdkevents.h: Added GdkEventScroll structure.
Thu Feb 17 17:10:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gt{h,k,}vpaned.[ch]: Add patch from Jonathan Blandford
......
Fri Feb 18 14:37:29 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Remove
OwnerGrabButtonMask from button entries for
GDK_BUTTON_PRESS / GDK_BUTTON_RELEASE.
* gtk/gtklayout.c (gtk_layout_realize): Always add GDK_SCROLL
to the event mask (which will result in button/press release
being added to the event mask on Unix) so scrolling works
for layouts in scroll windows.
* gdk/gdkevents.h (enum): Fix up GDK_ALL_EVENTS_MASK.
Patch from Anders Carlsson <andersca@picard.andersnet> to add
a scroll event.
* gtk/testgtk.c (scroll_test_scroll): Added an example of mouse wheel
scrolling to the "Test Scrolling" part of testgtk.
* gtk/gtkwidget.h (struct _GtkWidgetClass): Added scroll_event signal.
* gtk/gtkwidget.c: Added "scroll_event" GTK+ signal and matched
it against GDK_SCROLL.
* gtk/gtkrange.c (gtk_range_scroll_event): Updated to use the new
way of mouse wheel scrolling.
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_scroll_event): Likewise.
* gtk/gtkspinbutton.c (gtk_spin_button_scroll): Likewise.
* gtk/gtkmain.c: Removed previous mouse wheel hack.
* gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Added entry in
gdk_event_mask_table.
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Added
GdkEventScroll handler.
* gdk/gdkevents.h: Added GdkEventScroll structure.
Thu Feb 17 17:10:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gt{h,k,}vpaned.[ch]: Add patch from Jonathan Blandford
......
Fri Feb 18 14:37:29 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Remove
OwnerGrabButtonMask from button entries for
GDK_BUTTON_PRESS / GDK_BUTTON_RELEASE.
* gtk/gtklayout.c (gtk_layout_realize): Always add GDK_SCROLL
to the event mask (which will result in button/press release
being added to the event mask on Unix) so scrolling works
for layouts in scroll windows.
* gdk/gdkevents.h (enum): Fix up GDK_ALL_EVENTS_MASK.
Patch from Anders Carlsson <andersca@picard.andersnet> to add
a scroll event.
* gtk/testgtk.c (scroll_test_scroll): Added an example of mouse wheel
scrolling to the "Test Scrolling" part of testgtk.
* gtk/gtkwidget.h (struct _GtkWidgetClass): Added scroll_event signal.
* gtk/gtkwidget.c: Added "scroll_event" GTK+ signal and matched
it against GDK_SCROLL.
* gtk/gtkrange.c (gtk_range_scroll_event): Updated to use the new
way of mouse wheel scrolling.
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_scroll_event): Likewise.
* gtk/gtkspinbutton.c (gtk_spin_button_scroll): Likewise.
* gtk/gtkmain.c: Removed previous mouse wheel hack.
* gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Added entry in
gdk_event_mask_table.
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Added
GdkEventScroll handler.
* gdk/gdkevents.h: Added GdkEventScroll structure.
Thu Feb 17 17:10:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gt{h,k,}vpaned.[ch]: Add patch from Jonathan Blandford
......
Fri Feb 18 14:37:29 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Remove
OwnerGrabButtonMask from button entries for
GDK_BUTTON_PRESS / GDK_BUTTON_RELEASE.
* gtk/gtklayout.c (gtk_layout_realize): Always add GDK_SCROLL
to the event mask (which will result in button/press release
being added to the event mask on Unix) so scrolling works
for layouts in scroll windows.
* gdk/gdkevents.h (enum): Fix up GDK_ALL_EVENTS_MASK.
Patch from Anders Carlsson <andersca@picard.andersnet> to add
a scroll event.
* gtk/testgtk.c (scroll_test_scroll): Added an example of mouse wheel
scrolling to the "Test Scrolling" part of testgtk.
* gtk/gtkwidget.h (struct _GtkWidgetClass): Added scroll_event signal.
* gtk/gtkwidget.c: Added "scroll_event" GTK+ signal and matched
it against GDK_SCROLL.
* gtk/gtkrange.c (gtk_range_scroll_event): Updated to use the new
way of mouse wheel scrolling.
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_scroll_event): Likewise.
* gtk/gtkspinbutton.c (gtk_spin_button_scroll): Likewise.
* gtk/gtkmain.c: Removed previous mouse wheel hack.
* gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Added entry in
gdk_event_mask_table.
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Added
GdkEventScroll handler.
* gdk/gdkevents.h: Added GdkEventScroll structure.
Thu Feb 17 17:10:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gt{h,k,}vpaned.[ch]: Add patch from Jonathan Blandford
......
Fri Feb 18 14:37:29 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Remove
OwnerGrabButtonMask from button entries for
GDK_BUTTON_PRESS / GDK_BUTTON_RELEASE.
* gtk/gtklayout.c (gtk_layout_realize): Always add GDK_SCROLL
to the event mask (which will result in button/press release
being added to the event mask on Unix) so scrolling works
for layouts in scroll windows.
* gdk/gdkevents.h (enum): Fix up GDK_ALL_EVENTS_MASK.
Patch from Anders Carlsson <andersca@picard.andersnet> to add
a scroll event.
* gtk/testgtk.c (scroll_test_scroll): Added an example of mouse wheel
scrolling to the "Test Scrolling" part of testgtk.
* gtk/gtkwidget.h (struct _GtkWidgetClass): Added scroll_event signal.
* gtk/gtkwidget.c: Added "scroll_event" GTK+ signal and matched
it against GDK_SCROLL.
* gtk/gtkrange.c (gtk_range_scroll_event): Updated to use the new
way of mouse wheel scrolling.
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_scroll_event): Likewise.
* gtk/gtkspinbutton.c (gtk_spin_button_scroll): Likewise.
* gtk/gtkmain.c: Removed previous mouse wheel hack.
* gdk/x11/gdkwindow-x11.c (gdk_event_mask_table): Added entry in
gdk_event_mask_table.
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Added
GdkEventScroll handler.
* gdk/gdkevents.h: Added GdkEventScroll structure.
Thu Feb 17 17:10:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gt{h,k,}vpaned.[ch]: Add patch from Jonathan Blandford
......
......@@ -13,3 +13,9 @@ Incompatible Changes from GTK+-1.2 to GTK+-1.4:
- gtk_paned_set_gutter_size() has been removed, since the small handle tab
has been changed to include the entire area previously occupied by
the gutter.
- GDK no longer selects OwnerGrabButtonMask for button presses. This means
that the automatic grab that occurs when the user presses a button
will have owner_events = FALSE, so all events are redirected to the
grab window, even events that would normally go to other windows of the
window's owner.
\ No newline at end of file
......@@ -410,6 +410,7 @@ gdk_event_get_time (GdkEvent *event)
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
case GDK_SCROLL:
return event->button.time;
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
......
......@@ -17,6 +17,7 @@ typedef struct _GdkEventNoExpose GdkEventNoExpose;
typedef struct _GdkEventVisibility GdkEventVisibility;
typedef struct _GdkEventMotion GdkEventMotion;
typedef struct _GdkEventButton GdkEventButton;
typedef struct _GdkEventScroll GdkEventScroll;
typedef struct _GdkEventKey GdkEventKey;
typedef struct _GdkEventFocus GdkEventFocus;
typedef struct _GdkEventCrossing GdkEventCrossing;
......@@ -69,6 +70,7 @@ typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
* Map: A window has been mapped. (It is now visible on the screen).
* Unmap: A window has been unmapped. (It is no longer visible on
* the screen).
* Scroll: A mouse wheel was scrolled either up or down.
*/
typedef enum
{
......@@ -103,7 +105,8 @@ typedef enum
GDK_DROP_FINISHED = 27,
GDK_CLIENT_EVENT = 28,
GDK_VISIBILITY_NOTIFY = 29,
GDK_NO_EXPOSE = 30
GDK_NO_EXPOSE = 30,
GDK_SCROLL = 31
} GdkEventType;
/* Event masks. (Used to select what types of events a window
......@@ -131,15 +134,25 @@ typedef enum
GDK_PROXIMITY_IN_MASK = 1 << 18,
GDK_PROXIMITY_OUT_MASK = 1 << 19,
GDK_SUBSTRUCTURE_MASK = 1 << 20,
GDK_ALL_EVENTS_MASK = 0x0FFFFF
GDK_SCROLL_MASK = 1 << 21,
GDK_ALL_EVENTS_MASK = 0x3FFFFE
} GdkEventMask;
typedef enum {
typedef enum
{
GDK_VISIBILITY_UNOBSCURED,
GDK_VISIBILITY_PARTIAL,
GDK_VISIBILITY_FULLY_OBSCURED
} GdkVisibilityState;
typedef enum
{
GDK_SCROLL_UP,
GDK_SCROLL_DOWN,
GDK_SCROLL_LEFT,
GDK_SCROLL_RIGHT
} GdkScrollDirection;
/* Types of enter/leave notifications.
* Ancestor:
* Virtual:
......@@ -244,6 +257,24 @@ struct _GdkEventButton
gdouble x_root, y_root;
};
struct _GdkEventScroll
{
GdkEventType type;
GdkWindow *window;
gint8 send_event;
guint32 time;
gdouble x;
gdouble y;
gdouble pressure;
gdouble xtilt;
gdouble ytilt;
guint state;
GdkScrollDirection direction;
GdkInputSource source;
guint32 deviceid;
gdouble x_root, y_root;
};
struct _GdkEventKey
{
GdkEventType type;
......@@ -361,6 +392,7 @@ union _GdkEvent
GdkEventVisibility visibility;
GdkEventMotion motion;
GdkEventButton button;
GdkEventScroll scroll;
GdkEventKey key;
GdkEventCrossing crossing;
GdkEventFocus focus_change;
......
......@@ -700,23 +700,46 @@ gdk_event_translate (GdkEvent *event,
break;
}
event->button.type = GDK_BUTTON_PRESS;
event->button.window = window;
event->button.time = xevent->xbutton.time;
event->button.x = xevent->xbutton.x;
event->button.y = xevent->xbutton.y;
event->button.x_root = (gfloat)xevent->xbutton.x_root;
event->button.y_root = (gfloat)xevent->xbutton.y_root;
event->button.pressure = 0.5;
event->button.xtilt = 0;
event->button.ytilt = 0;
event->button.state = (GdkModifierType) xevent->xbutton.state;
event->button.button = xevent->xbutton.button;
event->button.source = GDK_SOURCE_MOUSE;
event->button.deviceid = GDK_CORE_POINTER;
/* If we get a ButtonPress event where the button is 4 or 5,
it's a Scroll event */
if (xevent->xbutton.button == 4 || xevent->xbutton.button == 5)
{
event->scroll.type = GDK_SCROLL;
event->scroll.direction = (xevent->xbutton.button == 4) ?
GDK_SCROLL_UP : GDK_SCROLL_DOWN;
event->scroll.window = window;
event->scroll.time = xevent->xbutton.x;
event->scroll.x = xevent->xbutton.x;
event->scroll.y = xevent->xbutton.y;
event->scroll.x_root = (gfloat)xevent->xbutton.x_root;
event->scroll.y_root = (gfloat)xevent->xbutton.y_root;
event->scroll.pressure = 0.5;
event->scroll.xtilt = 0;
event->scroll.ytilt = 0;
event->scroll.state = (GdkModifierType) xevent->xbutton.state;
event->scroll.source = GDK_SOURCE_MOUSE;
event->scroll.deviceid = GDK_CORE_POINTER;
}
else
{
event->button.type = GDK_BUTTON_PRESS;
event->button.window = window;
event->button.time = xevent->xbutton.time;
event->button.x = xevent->xbutton.x;
event->button.y = xevent->xbutton.y;
event->button.x_root = (gfloat)xevent->xbutton.x_root;
event->button.y_root = (gfloat)xevent->xbutton.y_root;
event->button.pressure = 0.5;
event->button.xtilt = 0;
event->button.ytilt = 0;
event->button.state = (GdkModifierType) xevent->xbutton.state;
event->button.button = xevent->xbutton.button;
event->button.source = GDK_SOURCE_MOUSE;
event->button.deviceid = GDK_CORE_POINTER;
gdk_event_button_generate (event);
}
gdk_event_button_generate (event);
break;
case ButtonRelease:
......@@ -736,6 +759,13 @@ gdk_event_translate (GdkEvent *event,
break;
}
/* We treat button presses as scroll wheel events, so ignore the release */
if (xevent->xbutton.button == 4 || xevent->xbutton.button == 5)
{
return_val = FALSE;
break;
}
event->button.type = GDK_BUTTON_RELEASE;
event->button.window = window;
event->button.time = xevent->xbutton.time;
......
......@@ -46,7 +46,7 @@
#include <X11/extensions/shape.h>
#endif
const int gdk_event_mask_table[20] =
const int gdk_event_mask_table[21] =
{
ExposureMask,
PointerMotionMask,
......@@ -55,8 +55,8 @@ const int gdk_event_mask_table[20] =
Button1MotionMask,
Button2MotionMask,
Button3MotionMask,
ButtonPressMask | OwnerGrabButtonMask,
ButtonReleaseMask | OwnerGrabButtonMask,
ButtonPressMask,
ButtonReleaseMask,
KeyPressMask,
KeyReleaseMask,
EnterWindowMask,
......@@ -67,7 +67,8 @@ const int gdk_event_mask_table[20] =
VisibilityChangeMask,
0, /* PROXIMITY_IN */
0, /* PROXIMTY_OUT */
SubstructureNotifyMask
SubstructureNotifyMask,
ButtonPressMask /* SCROLL; on X mouse wheel events is treated as mouse button 4/5 */
};
const int gdk_nevent_masks = sizeof (gdk_event_mask_table) / sizeof (int);
......
......@@ -467,7 +467,7 @@ gtk_layout_realize (GtkWidget *widget)
attributes.x = 0;
attributes.y = 0;
attributes.event_mask = GDK_EXPOSURE_MASK |
attributes.event_mask = GDK_EXPOSURE_MASK | GDK_SCROLL_MASK |
gtk_widget_get_events (widget);
layout->bin_window = gdk_window_new (widget->window,
......
......@@ -757,45 +757,10 @@ gtk_main_do_event (GdkEvent *event)
gtk_widget_event (event_widget, event);
break;
case GDK_SCROLL:
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
/* We treat button 4-5 specially, assume we have
* a MS-style scrollwheel mouse, and try to find
* a plausible widget to scroll. We also trap
* button 4-5 double and triple clicks here, since
* they will be generated if the user scrolls quickly.
*/
if ((grab_widget == event_widget) &&
(event->button.button == 4 || event->button.button == 5))
{
GtkWidget *range = NULL;
GtkWidget *scrollwin;
if (GTK_IS_RANGE (event_widget))
range = event_widget;
else
{
scrollwin = gtk_widget_get_ancestor (event_widget,
GTK_TYPE_SCROLLED_WINDOW);
if (scrollwin)
range = GTK_SCROLLED_WINDOW (scrollwin)->vscrollbar;
}
if (range && GTK_WIDGET_VISIBLE (range))
{
if (event->type == GDK_BUTTON_PRESS)
{
GtkAdjustment *adj = GTK_RANGE (range)->adjustment;
gfloat new_value = adj->value + ((event->button.button == 4) ?
-adj->page_increment / 2:
adj->page_increment / 2);
new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
break;
}
}
gtk_propagate_event (grab_widget, event);
break;
......
......@@ -73,6 +73,8 @@ static gint gtk_range_focus_in (GtkWidget *widget,
GdkEventFocus *event);
static gint gtk_range_focus_out (GtkWidget *widget,
GdkEventFocus *event);
static gint gtk_range_scroll_event (GtkWidget *widget,
GdkEventScroll *event);
static void gtk_range_style_set (GtkWidget *widget,
GtkStyle *previous_style);
......@@ -153,6 +155,7 @@ gtk_range_class_init (GtkRangeClass *class)
widget_class->button_press_event = gtk_range_button_press;
widget_class->button_release_event = gtk_range_button_release;
widget_class->motion_notify_event = gtk_range_motion_notify;
widget_class->scroll_event = gtk_range_scroll_event;
widget_class->key_press_event = gtk_range_key_press;
widget_class->enter_notify_event = gtk_range_enter_notify;
widget_class->leave_notify_event = gtk_range_leave_notify;
......@@ -978,6 +981,30 @@ gtk_range_button_release (GtkWidget *widget,
return FALSE;
}
static gint
gtk_range_scroll_event (GtkWidget *widget,
GdkEventScroll *event)
{
GtkRange *range;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_RANGE (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
range = GTK_RANGE (widget);
if (GTK_WIDGET_VISIBLE (range)) {
GtkAdjustment *adj = GTK_RANGE (range)->adjustment;
gfloat new_value = adj->value + ((event->direction == GDK_SCROLL_UP) ?
-adj->page_increment / 2:
adj->page_increment / 2);
new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
return FALSE;
}
static gint
gtk_range_motion_notify (GtkWidget *widget,
GdkEventMotion *event)
......
......@@ -95,6 +95,8 @@ static void gtk_scrolled_window_size_request (GtkWidget *widg
GtkRequisition *requisition);
static void gtk_scrolled_window_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gint gtk_scrolled_window_scroll_event (GtkWidget *widget,
GdkEventScroll *event);
static void gtk_scrolled_window_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_scrolled_window_remove (GtkContainer *container,
......@@ -108,7 +110,6 @@ static void gtk_scrolled_window_relative_allocation(GtkWidget *widg
static void gtk_scrolled_window_adjustment_changed (GtkAdjustment *adjustment,
gpointer data);
static GtkContainerClass *parent_class = NULL;
......@@ -180,6 +181,7 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
widget_class->draw = gtk_scrolled_window_draw;
widget_class->size_request = gtk_scrolled_window_size_request;
widget_class->size_allocate = gtk_scrolled_window_size_allocate;
widget_class->scroll_event = gtk_scrolled_window_scroll_event;
container_class->add = gtk_scrolled_window_add;
container_class->remove = gtk_scrolled_window_remove;
......@@ -270,6 +272,7 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
scrolled_window->hscrollbar_visible = FALSE;
scrolled_window->vscrollbar_visible = FALSE;
scrolled_window->window_placement = GTK_CORNER_TOP_LEFT;
}
GtkWidget*
......@@ -848,6 +851,39 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
gtk_widget_hide (scrolled_window->vscrollbar);
}
static gint
gtk_scrolled_window_scroll_event (GtkWidget *widget,
GdkEventScroll *event)
{
GtkWidget *range;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_DOWN)
range = GTK_SCROLLED_WINDOW (widget)->vscrollbar;
else
range = GTK_SCROLLED_WINDOW (widget)->hscrollbar;
if (range && GTK_WIDGET_VISIBLE (range))
{
GtkAdjustment *adj = GTK_RANGE (range)->adjustment;
gfloat new_value;
if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_LEFT)
new_value = adj->value - adj->page_increment / 2;
else
new_value = adj->value + adj->page_increment / 2;
new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
return TRUE;
}
return FALSE;
}
static void
gtk_scrolled_window_adjustment_changed (GtkAdjustment *adjustment,
......
......@@ -45,8 +45,6 @@
#define MAX_TEXT_LENGTH 256
#define MAX_TIMER_CALLS 5
#define EPSILON 1e-5
#define WHEEL_UP_BUTTON 4
#define WHEEL_DOWN_BUTTON 5
enum {
ARG_0,
......@@ -113,6 +111,8 @@ static gint gtk_spin_button_key_press (GtkWidget *widget,
GdkEventKey *event);
static gint gtk_spin_button_key_release (GtkWidget *widget,
GdkEventKey *event);
static gint gtk_spin_button_scroll (GtkWidget *widget,
GdkEventScroll *event);
static void gtk_spin_button_activate (GtkEditable *editable);
static void gtk_spin_button_snap (GtkSpinButton *spin_button,
gfloat val);
......@@ -235,6 +235,7 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
widget_class->size_allocate = gtk_spin_button_size_allocate;
widget_class->draw = gtk_spin_button_draw;
widget_class->expose_event = gtk_spin_button_expose;
widget_class->scroll_event = gtk_spin_button_scroll;
widget_class->button_press_event = gtk_spin_button_button_press;
widget_class->button_release_event = gtk_spin_button_button_release;
widget_class->motion_notify_event = gtk_spin_button_motion_notify;
......@@ -751,6 +752,36 @@ gtk_spin_button_focus_out (GtkWidget *widget,
return GTK_WIDGET_CLASS (parent_class)->focus_out_event (widget, event);
}
static gint
gtk_spin_button_scroll (GtkWidget *widget,
GdkEventScroll *event)
{
GtkSpinButton *spin;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_SPIN_BUTTON (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
spin = GTK_SPIN_BUTTON (widget);
if (event->direction == GDK_SCROLL_UP)
{
if (!GTK_WIDGET_HAS_FOCUS (widget))
gtk_widget_grab_focus (widget);
gtk_spin_button_real_spin (spin, spin->adjustment->step_increment);
}
else if (event->direction == GDK_SCROLL_DOWN)
{
if (!GTK_WIDGET_HAS_FOCUS (widget))
gtk_widget_grab_focus (widget);
gtk_spin_button_real_spin (spin, -spin->adjustment->step_increment);
}
else