[PATCH] Scroll wheel support for libzvt
- From: Anders Carlsson <andersca gnu org>
- To: gnome-hackers gnome org
- Subject: [PATCH] Scroll wheel support for libzvt
- Date: 11 Dec 2001 07:45:29 +0100
Hello,
this patch adds scroll wheel support for libzvt.
OK to commit?
//andersca
andersca gnu org
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libzvt/libzvt/ChangeLog,v
retrieving revision 1.306
diff -u -r1.306 ChangeLog
--- ChangeLog 2001/12/06 22:58:55 1.306
+++ ChangeLog 2001/12/11 06:45:07
@@ -1,3 +1,10 @@
+2001-12-11 Anders Carlsson <andersca gnu org>
+
+ * zvtterm.c (zvt_term_scroll_event): Implement scroll event
+ handler.
+ (zvt_term_button_release): Don't ignore button 4 and 5 events
+ since they never get here anymore.
+
2001-12-04 Marc Mulcahy <marc mulcahy sun com>
* vt.h update.c zvtterm.c: Added selection_changed signal
Index: zvtterm.c
===================================================================
RCS file: /cvs/gnome/libzvt/libzvt/zvtterm.c,v
retrieving revision 1.165
diff -u -r1.165 zvtterm.c
--- zvtterm.c 2001/12/06 22:58:56 1.165
+++ zvtterm.c 2001/12/11 06:45:07
@@ -78,6 +78,7 @@
static gint zvt_term_key_press (GtkWidget *widget, GdkEventKey *event);
static gint zvt_term_focus_in (GtkWidget *widget, GdkEventFocus *event);
static gint zvt_term_focus_out (GtkWidget *widget, GdkEventFocus *event);
+static gint zvt_term_scroll_event (GtkWidget *widget, GdkEventScroll *event);
static gint zvt_term_selection_clear (GtkWidget *widget, GdkEventSelection *event);
static void zvt_term_selection_get (GtkWidget *widget,
GtkSelectionData *selection_data_ptr,
@@ -268,7 +269,8 @@
widget_class->button_press_event = zvt_term_button_press;
widget_class->button_release_event = zvt_term_button_release;
widget_class->motion_notify_event = zvt_term_motion_notify;
-
+ widget_class->scroll_event = zvt_term_scroll_event;
+
widget_class->selection_clear_event = zvt_term_selection_clear;
widget_class->selection_get = zvt_term_selection_get;
@@ -1027,6 +1029,22 @@
}
}
+static gint
+zvt_term_scroll_event (GtkWidget *widget, GdkEventScroll *event)
+{
+ GtkAdjustment *adj = ZVT_TERM (widget)->adjustment;
+ gdouble 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;
+}
static gint
zvt_term_focus_in(GtkWidget *widget, GdkEventFocus *event)
@@ -1740,11 +1758,6 @@
zp->scrollselect_id=-1;
}
- /* ignore wheel mice buttons (4 and 5) */
- /* otherwise they affect the selection */
- if (event->button == 4 || event->button == 5)
- return FALSE;
-
if (vx->selectiontype == VT_SELTYPE_NONE) {
/* report mouse to terminal */
if (!(event->state & GDK_SHIFT_MASK))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]