[PATCH] Wheelmouse support for zvtterm
- From: Richard Hult <rhult hem2 passagen se>
- To: gnome-devel-list gnome org
- Subject: [PATCH] Wheelmouse support for zvtterm
- Date: Wed, 10 Mar 1999 00:00:20 +0100 (CET)
I have made a small patch that makes gnome-terminal and other apps that
use zvtterm support scrollwheel mice. I'm not a guru so it might be
totally off. At least it works for me ;)
Feel free to commit it or throw it away, or even better, please make it
work the right way if it's wrong :)
Richard
Index: zvtterm.c
===================================================================
RCS file: /cvs/gnome/gnome-libs/zvt/zvtterm.c,v
retrieving revision 1.95
diff -u -r1.95 zvtterm.c
--- zvtterm.c 1999/03/09 05:00:23 1.95
+++ zvtterm.c 1999/03/09 22:57:41
@@ -91,6 +91,7 @@
static void zvt_term_fix_scrollbar (ZvtTerm *term);
static void vtx_unrender_selection (struct _vtx *vx);
static void zvt_term_scroll (ZvtTerm *term, int n);
+static void zvt_term_scroll_by_lines (ZvtTerm *term, int n);
/* transparent terminal prototypes */
@@ -1363,6 +1364,19 @@
NULL, NULL, 0);
}
break;
+
+ /* Handle scrollwheel mice. These are most commonly configured (at
+ * least when using XFree86), to transform the wheel movement into
+ * button 4 (up) and 5 (down) events. 12 lines matches gtk+ scrollbar
+ * scrollwheel mouse behaviour.
+ */
+ case 4:
+ zvt_term_scroll_by_lines (term, -12);
+ break;
+
+ case 5:
+ zvt_term_scroll_by_lines (term, 12);
+ break;
}
return FALSE;
}
@@ -1390,6 +1404,11 @@
x = x/term->charwidth;
y = y/term->charheight + vx->vt.scrollbackoffset;
+ /* ignore wheel mice buttons (4 and 5) */
+ /* otherwise they affect the selection */
+ if (event->button == 4 || event->button == 5)
+ return FALSE;
+
/* report mouse to terminal */
if (!(event->state & GDK_SHIFT_MASK))
if (vt_report_button(&vx->vt, 0, event->state, x, y))
@@ -1738,6 +1757,30 @@
n > 0 ? MIN(new_value, term->adjustment->upper- term->adjustment->page_size) :
MAX(new_value, term->adjustment->lower));
}
+
+static void
+zvt_term_scroll_by_lines (ZvtTerm *term, int n)
+{
+ gfloat new_value = 0;
+
+ if (n > 0)
+ {
+ new_value = MIN(term->adjustment->value + n, term->adjustment->upper - n);
+ }
+ else if (n < 0)
+ {
+ new_value = MAX(term->adjustment->value + n, term->adjustment->lower);
+ }
+ else
+ {
+ return;
+ }
+
+ gtk_adjustment_set_value (
+ term->adjustment,
+ new_value);
+}
+
/*
* Keyboard input callback
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]