forked from AuroraMiddleware/gtk
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:
parent
7934cf9aea
commit
9e5e63f0a1
13
ChangeLog
13
ChangeLog
@ -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>
|
Tue Jan 26 14:02:50 1999 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's
|
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's
|
||||||
|
@ -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>
|
Tue Jan 26 14:02:50 1999 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's
|
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's
|
||||||
|
@ -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>
|
Tue Jan 26 14:02:50 1999 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's
|
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's
|
||||||
|
@ -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>
|
Tue Jan 26 14:02:50 1999 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's
|
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's
|
||||||
|
@ -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>
|
Tue Jan 26 14:02:50 1999 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's
|
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's
|
||||||
|
@ -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>
|
Tue Jan 26 14:02:50 1999 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's
|
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's
|
||||||
|
@ -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>
|
Tue Jan 26 14:02:50 1999 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's
|
* gdk/gdkwindow.c (gdk_window_show/hide): Remove TimJ's
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "gtkmain.h"
|
#include "gtkmain.h"
|
||||||
#include "gtkpreview.h"
|
#include "gtkpreview.h"
|
||||||
#include "gtkrc.h"
|
#include "gtkrc.h"
|
||||||
|
#include "gtkscrolledwindow.h"
|
||||||
#include "gtkselection.h"
|
#include "gtkselection.h"
|
||||||
#include "gtksignal.h"
|
#include "gtksignal.h"
|
||||||
#include "gtktable.h"
|
#include "gtktable.h"
|
||||||
@ -676,6 +677,48 @@ gtk_main_do_event (GdkEvent *event)
|
|||||||
gtk_widget_event (event_widget, event);
|
gtk_widget_event (event_widget, event);
|
||||||
break;
|
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_PRESS:
|
||||||
case GDK_KEY_RELEASE:
|
case GDK_KEY_RELEASE:
|
||||||
if (key_snoopers)
|
if (key_snoopers)
|
||||||
@ -685,9 +728,6 @@ gtk_main_do_event (GdkEvent *event)
|
|||||||
}
|
}
|
||||||
/* else fall through */
|
/* else fall through */
|
||||||
case GDK_MOTION_NOTIFY:
|
case GDK_MOTION_NOTIFY:
|
||||||
case GDK_BUTTON_PRESS:
|
|
||||||
case GDK_2BUTTON_PRESS:
|
|
||||||
case GDK_3BUTTON_PRESS:
|
|
||||||
case GDK_BUTTON_RELEASE:
|
case GDK_BUTTON_RELEASE:
|
||||||
case GDK_PROXIMITY_IN:
|
case GDK_PROXIMITY_IN:
|
||||||
case GDK_PROXIMITY_OUT:
|
case GDK_PROXIMITY_OUT:
|
||||||
|
@ -430,7 +430,9 @@ gtk_viewport_realize (GtkWidget *widget)
|
|||||||
attributes.colormap = gtk_widget_get_colormap (widget);
|
attributes.colormap = gtk_widget_get_colormap (widget);
|
||||||
|
|
||||||
event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
|
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;
|
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user