Hack scrollwheel support into the eventloop, by treating button 4-5

Wed Jan 27 18:40:50 1999  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkmain.c (gtk_main_do_event): Hack scrollwheel
	support into the eventloop, by treating button 4-5
	presses on scrolled windows and scrollbars specially.
	Put it here to keep the ugliness small and confined.
	(We need to intercept the normal propagation in any case
	to have this work reliably right now, since some
	subwidgets will trap the button presses)

	* gtk/gtkviewport.c (gtk_viewport_realize): Select for
	BUTTON_PRESS to	support the above hack.
This commit is contained in:
Owen Taylor 1999-01-28 00:57:18 +00:00 committed by Owen Taylor
parent 7934cf9aea
commit 9e5e63f0a1
9 changed files with 139 additions and 6 deletions

View File

@ -1,3 +1,16 @@
Wed Jan 27 18:40:50 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmain.c (gtk_main_do_event): Hack scrollwheel
support into the eventloop, by treating button 4-5
presses on scrolled windows and scrollbars specially.
Put it here to keep the ugliness small and confined.
(We need to intercept the normal propagation in any case
to have this work reliably right now, since some
subwidgets will trap the button presses)
* gtk/gtkviewport.c (gtk_viewport_realize): Select for
BUTTON_PRESS to support the above hack.
Tue Jan 26 14:02:50 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's

View File

@ -1,3 +1,16 @@
Wed Jan 27 18:40:50 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmain.c (gtk_main_do_event): Hack scrollwheel
support into the eventloop, by treating button 4-5
presses on scrolled windows and scrollbars specially.
Put it here to keep the ugliness small and confined.
(We need to intercept the normal propagation in any case
to have this work reliably right now, since some
subwidgets will trap the button presses)
* gtk/gtkviewport.c (gtk_viewport_realize): Select for
BUTTON_PRESS to support the above hack.
Tue Jan 26 14:02:50 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's

View File

@ -1,3 +1,16 @@
Wed Jan 27 18:40:50 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmain.c (gtk_main_do_event): Hack scrollwheel
support into the eventloop, by treating button 4-5
presses on scrolled windows and scrollbars specially.
Put it here to keep the ugliness small and confined.
(We need to intercept the normal propagation in any case
to have this work reliably right now, since some
subwidgets will trap the button presses)
* gtk/gtkviewport.c (gtk_viewport_realize): Select for
BUTTON_PRESS to support the above hack.
Tue Jan 26 14:02:50 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's

View File

@ -1,3 +1,16 @@
Wed Jan 27 18:40:50 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmain.c (gtk_main_do_event): Hack scrollwheel
support into the eventloop, by treating button 4-5
presses on scrolled windows and scrollbars specially.
Put it here to keep the ugliness small and confined.
(We need to intercept the normal propagation in any case
to have this work reliably right now, since some
subwidgets will trap the button presses)
* gtk/gtkviewport.c (gtk_viewport_realize): Select for
BUTTON_PRESS to support the above hack.
Tue Jan 26 14:02:50 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's

View File

@ -1,3 +1,16 @@
Wed Jan 27 18:40:50 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmain.c (gtk_main_do_event): Hack scrollwheel
support into the eventloop, by treating button 4-5
presses on scrolled windows and scrollbars specially.
Put it here to keep the ugliness small and confined.
(We need to intercept the normal propagation in any case
to have this work reliably right now, since some
subwidgets will trap the button presses)
* gtk/gtkviewport.c (gtk_viewport_realize): Select for
BUTTON_PRESS to support the above hack.
Tue Jan 26 14:02:50 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's

View File

@ -1,3 +1,16 @@
Wed Jan 27 18:40:50 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmain.c (gtk_main_do_event): Hack scrollwheel
support into the eventloop, by treating button 4-5
presses on scrolled windows and scrollbars specially.
Put it here to keep the ugliness small and confined.
(We need to intercept the normal propagation in any case
to have this work reliably right now, since some
subwidgets will trap the button presses)
* gtk/gtkviewport.c (gtk_viewport_realize): Select for
BUTTON_PRESS to support the above hack.
Tue Jan 26 14:02:50 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's

View File

@ -1,3 +1,16 @@
Wed Jan 27 18:40:50 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmain.c (gtk_main_do_event): Hack scrollwheel
support into the eventloop, by treating button 4-5
presses on scrolled windows and scrollbars specially.
Put it here to keep the ugliness small and confined.
(We need to intercept the normal propagation in any case
to have this work reliably right now, since some
subwidgets will trap the button presses)
* gtk/gtkviewport.c (gtk_viewport_realize): Select for
BUTTON_PRESS to support the above hack.
Tue Jan 26 14:02:50 1999 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's

View File

@ -29,6 +29,7 @@
#include "gtkmain.h"
#include "gtkpreview.h"
#include "gtkrc.h"
#include "gtkscrolledwindow.h"
#include "gtkselection.h"
#include "gtksignal.h"
#include "gtktable.h"
@ -629,7 +630,7 @@ gtk_main_do_event (GdkEvent *event)
{
grab_widget = event_widget;
}
/* Not all events get sent to the grabbing widget.
* The delete, destroy, expose, focus change and resize
* events still get sent to the event widget because
@ -675,7 +676,49 @@ gtk_main_do_event (GdkEvent *event)
case GDK_VISIBILITY_NOTIFY:
gtk_widget_event (event_widget, event);
break;
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;
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
if (key_snoopers)
@ -685,9 +728,6 @@ gtk_main_do_event (GdkEvent *event)
}
/* else fall through */
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
case GDK_PROXIMITY_IN:
case GDK_PROXIMITY_OUT:

View File

@ -430,7 +430,9 @@ gtk_viewport_realize (GtkWidget *widget)
attributes.colormap = gtk_widget_get_colormap (widget);
event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
attributes.event_mask = event_mask;
/* We select on button_press_mask so that button 4-5 scrolls are trapped.
*/
attributes.event_mask = event_mask | GDK_BUTTON_PRESS_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;