(Yet Another) Patch for mouse wheel support and a request for advice
- From: Guillaume Laurent <glaurent worldnet fr>
- To: gtk-devel-list redhat com
- cc: Colas Nahaboo <colas sophia inria fr>
- Subject: (Yet Another) Patch for mouse wheel support and a request for advice
- Date: 06 Sep 1998 13:10:22 +0200
This patch will automagically turn button4/5 events into PgUp/PgDown
key events. It should apply to gdk 1.1.1.
For more consistency with the "usual" settings for mouse wheel, I
thought I could try to turn them into Up/Down instead of PgUp/PgDown
if Shift is on, but I'd first like to know what people are thinking of
it. Brutally changing button events into key events is rather
radical.
It does provide slightly more "complete" support than my previous
patch, although it seem not all scrollbars react to PgUp/PgDown.
There is still a problem with scrolled windows, in that it won't work
if the wheel is used over the window itself, only if over the
scrollbar (while pressing PgUp/Down works fine).
--- gdk.c Fri Jul 10 02:40:49 1998
+++ gdk.c.new Sun Sep 6 12:55:12 1998
@@ -1968,6 +1968,26 @@
gdk_input_ignore_core)
break;
+ if (xevent->xbutton.button == 4 || xevent->xbutton.button == 5)
+ {
+ /* Mutate event into a PgUp/PgDown keypress */
+ event->key.type = GDK_KEY_PRESS;
+ event->key.window = window;
+ event->key.time = xevent->xkey.time;
+
+ if(xevent->xbutton.button == 4)
+ event->key.keyval = GDK_Page_Up;
+ else
+ event->key.keyval = GDK_Page_Down;
+
+ event->key.state = (GdkModifierType) xevent->xbutton.state;
+ event->key.string = g_strdup ("");
+ event->key.length = 0;
+ return_val = window_private && !window_private->destroyed;
+ break;
+ }
+
+
event->button.type = GDK_BUTTON_PRESS;
event->button.window = window;
event->button.time = xevent->xbutton.time;
@@ -2074,6 +2094,25 @@
gdk_input_ignore_core)
break;
+ if (xevent->xbutton.button == 4 || xevent->xbutton.button == 5)
+ {
+ /* Mutate event into a PgUp/PgDown keyrelease */
+ event->key.type = GDK_KEY_RELEASE;
+ event->key.window = window;
+ event->key.time = xevent->xkey.time;
+
+ if(xevent->xbutton.button == 4)
+ event->key.keyval = GDK_Page_Up;
+ else
+ event->key.keyval = GDK_Page_Down;
+
+ event->key.state = (GdkModifierType) xevent->xbutton.state;
+ event->key.string = NULL;
+ event->key.length = 0;
+ return_val = window_private && !window_private->destroyed;
+ break;
+ }
+
event->button.type = GDK_BUTTON_RELEASE;
event->button.window = window;
event->button.time = xevent->xbutton.time;
--
Guillaume.
http://www.worldnet.fr/~glaurent
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]