summaryrefslogtreecommitdiff
path: root/src/gtkutil.c
diff options
context:
space:
mode:
authorJan Djärv <jan.h.d@swipnet.se>2009-12-13 13:31:35 +0000
committerJan Djärv <jan.h.d@swipnet.se>2009-12-13 13:31:35 +0000
commite5f0bc9ada3729749b83cfa246b39dd0d6fceca0 (patch)
tree4b64bb983b115353fb9b5be07c06cbfa361e3204 /src/gtkutil.c
parent223e5fc656a6c8a95e5aac334e8c7b82cc9d2a4b (diff)
downloademacs-e5f0bc9ada3729749b83cfa246b39dd0d6fceca0.tar.gz
Bug 5177: Scroll bar thumb did not move when scrolling with mouse wheel.
* xterm.c (xg_scroll_callback): Parameter list changed, use parameter GtkScrollType to determine scroll/line/page. Only allow dragging if a button < 4 is grabbed (bug #5177). (xg_end_scroll_callback): New function. (x_create_toolkit_scroll_bar): Pass xg_end_scroll_callback to xg_create_scroll_bar. * gtkutil.c (xg_gtk_scroll_destroy): Remove XG_LAST_SB_DATA handling. (scroll_end_callback): Remove. (xg_create_scroll_bar): Add parameter end_callback, bind it to button-release-event. Replace value-changed event with change-value, bug #5177, (xg_event_is_for_scrollbar): Only return true if button is less than 4, bug #5177. * gtkutil.h (XG_LAST_SB_DATA): Remove. (xg_create_scroll_bar): Add GCallback end_callback.
Diffstat (limited to 'src/gtkutil.c')
-rw-r--r--src/gtkutil.c39
1 files changed, 13 insertions, 26 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 8c12f04991a..cd9c930c7c2 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -3085,38 +3085,23 @@ xg_gtk_scroll_destroy (widget, data)
GtkWidget *widget;
gpointer data;
{
- gpointer p;
int id = (int) (EMACS_INT) data; /* The EMACS_INT cast avoids a warning. */
-
- p = g_object_get_data (G_OBJECT (widget), XG_LAST_SB_DATA);
- xfree (p);
xg_remove_widget_from_map (id);
}
-/* Callback for button release. Sets dragging to Qnil when dragging is done. */
-
-static gboolean
-scroll_end_callback (GtkWidget *widget,
- GdkEventButton *event,
- gpointer user_data)
-{
- struct scroll_bar *bar = (struct scroll_bar *) user_data;
- bar->dragging = Qnil;
- return FALSE;
-}
-
/* Create a scroll bar widget for frame F. Store the scroll bar
in BAR.
SCROLL_CALLBACK is the callback to invoke when the value of the
bar changes.
+ END_CALLBACK is the callback to invoke when scrolling ends.
SCROLL_BAR_NAME is the name we use for the scroll bar. Can be used
to set resources for the widget. */
void
-xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name)
+xg_create_scroll_bar (f, bar, scroll_callback, end_callback, scroll_bar_name)
FRAME_PTR f;
struct scroll_bar *bar;
- GCallback scroll_callback;
+ GCallback scroll_callback, end_callback;
char *scroll_bar_name;
{
GtkWidget *wscroll;
@@ -3133,22 +3118,22 @@ xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name)
webox = gtk_event_box_new ();
gtk_widget_set_name (wscroll, scroll_bar_name);
gtk_range_set_update_policy (GTK_RANGE (wscroll), GTK_UPDATE_CONTINUOUS);
+ g_object_set_data (G_OBJECT (wscroll), XG_FRAME_DATA, (gpointer)f);
scroll_id = xg_store_widget_in_map (wscroll);
- g_signal_connect (G_OBJECT (wscroll),
- "value-changed",
- scroll_callback,
- (gpointer) bar);
/* The EMACS_INT cast avoids a warning. */
g_signal_connect (G_OBJECT (wscroll),
"destroy",
G_CALLBACK (xg_gtk_scroll_destroy),
(gpointer) (EMACS_INT) scroll_id);
-
+ g_signal_connect (G_OBJECT (wscroll),
+ "change-value",
+ scroll_callback,
+ (gpointer) bar);
g_signal_connect (G_OBJECT (wscroll),
"button-release-event",
- G_CALLBACK (scroll_end_callback),
+ end_callback,
(gpointer) bar);
/* The scroll bar widget does not draw on a window of its own. Instead
@@ -3327,14 +3312,16 @@ xg_event_is_for_scrollbar (f, event)
{
int retval = 0;
- if (f && event->type == ButtonPress)
+ if (f && event->type == ButtonPress && event->xbutton.button < 4)
{
/* Check if press occurred outside the edit widget. */
GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f));
retval = gdk_display_get_window_at_pointer (gdpy, NULL, NULL)
!= f->output_data.x->edit_widget->window;
}
- else if (f && (event->type == ButtonRelease || event->type == MotionNotify))
+ else if (f
+ && ((event->type == ButtonRelease && event->xbutton.button < 4)
+ || event->type == MotionNotify))
{
/* If we are releasing or moving the scroll bar, it has the grab. */
retval = gtk_grab_get_current () != 0