aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Djärv2009-12-13 13:31:35 +0000
committerJan Djärv2009-12-13 13:31:35 +0000
commite5f0bc9ada3729749b83cfa246b39dd0d6fceca0 (patch)
tree4b64bb983b115353fb9b5be07c06cbfa361e3204 /src
parent223e5fc656a6c8a95e5aac334e8c7b82cc9d2a4b (diff)
downloademacs-e5f0bc9ada3729749b83cfa246b39dd0d6fceca0.tar.gz
emacs-e5f0bc9ada3729749b83cfa246b39dd0d6fceca0.zip
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')
-rw-r--r--src/ChangeLog18
-rw-r--r--src/gtkutil.c39
-rw-r--r--src/gtkutil.h6
-rw-r--r--src/xterm.c99
4 files changed, 88 insertions, 74 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 348300ee2da..bf71cc3ea32 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,23 @@
12009-12-13 Jan Djärv <jan.h.d@swipnet.se> 12009-12-13 Jan Djärv <jan.h.d@swipnet.se>
2 2
3 * xterm.c (xg_scroll_callback): Parameter list changed,
4 use parameter GtkScrollType to determine scroll/line/page.
5 Only allow dragging if a button < 4 is grabbed (bug #5177).
6 (xg_end_scroll_callback): New function.
7 (x_create_toolkit_scroll_bar): Pass xg_end_scroll_callback to
8 xg_create_scroll_bar.
9
10 * gtkutil.c (xg_gtk_scroll_destroy): Remove XG_LAST_SB_DATA handling.
11 (scroll_end_callback): Remove.
12 (xg_create_scroll_bar): Add parameter end_callback, bind it to
13 button-release-event. Replace value-changed event with change-value,
14 bug #5177,
15 (xg_event_is_for_scrollbar): Only return true if button is less than 4,
16 bug #5177.
17
18 * gtkutil.h (XG_LAST_SB_DATA): Remove.
19 (xg_create_scroll_bar): Add GCallback end_callback.
20
3 * xftfont.c (QClcdfilter): New variable. 21 * xftfont.c (QClcdfilter): New variable.
4 (xftfont_open): Parse constant names for RGBA, HINT_STYLE and LCDFILTER. 22 (xftfont_open): Parse constant names for RGBA, HINT_STYLE and LCDFILTER.
5 (syms_of_xftfont): Initialize QClcdfilter. 23 (syms_of_xftfont): Initialize QClcdfilter.
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)
3085 GtkWidget *widget; 3085 GtkWidget *widget;
3086 gpointer data; 3086 gpointer data;
3087{ 3087{
3088 gpointer p;
3089 int id = (int) (EMACS_INT) data; /* The EMACS_INT cast avoids a warning. */ 3088 int id = (int) (EMACS_INT) data; /* The EMACS_INT cast avoids a warning. */
3090
3091 p = g_object_get_data (G_OBJECT (widget), XG_LAST_SB_DATA);
3092 xfree (p);
3093 xg_remove_widget_from_map (id); 3089 xg_remove_widget_from_map (id);
3094} 3090}
3095 3091
3096/* Callback for button release. Sets dragging to Qnil when dragging is done. */
3097
3098static gboolean
3099scroll_end_callback (GtkWidget *widget,
3100 GdkEventButton *event,
3101 gpointer user_data)
3102{
3103 struct scroll_bar *bar = (struct scroll_bar *) user_data;
3104 bar->dragging = Qnil;
3105 return FALSE;
3106}
3107
3108/* Create a scroll bar widget for frame F. Store the scroll bar 3092/* Create a scroll bar widget for frame F. Store the scroll bar
3109 in BAR. 3093 in BAR.
3110 SCROLL_CALLBACK is the callback to invoke when the value of the 3094 SCROLL_CALLBACK is the callback to invoke when the value of the
3111 bar changes. 3095 bar changes.
3096 END_CALLBACK is the callback to invoke when scrolling ends.
3112 SCROLL_BAR_NAME is the name we use for the scroll bar. Can be used 3097 SCROLL_BAR_NAME is the name we use for the scroll bar. Can be used
3113 to set resources for the widget. */ 3098 to set resources for the widget. */
3114 3099
3115void 3100void
3116xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name) 3101xg_create_scroll_bar (f, bar, scroll_callback, end_callback, scroll_bar_name)
3117 FRAME_PTR f; 3102 FRAME_PTR f;
3118 struct scroll_bar *bar; 3103 struct scroll_bar *bar;
3119 GCallback scroll_callback; 3104 GCallback scroll_callback, end_callback;
3120 char *scroll_bar_name; 3105 char *scroll_bar_name;
3121{ 3106{
3122 GtkWidget *wscroll; 3107 GtkWidget *wscroll;
@@ -3133,22 +3118,22 @@ xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name)
3133 webox = gtk_event_box_new (); 3118 webox = gtk_event_box_new ();
3134 gtk_widget_set_name (wscroll, scroll_bar_name); 3119 gtk_widget_set_name (wscroll, scroll_bar_name);
3135 gtk_range_set_update_policy (GTK_RANGE (wscroll), GTK_UPDATE_CONTINUOUS); 3120 gtk_range_set_update_policy (GTK_RANGE (wscroll), GTK_UPDATE_CONTINUOUS);
3121 g_object_set_data (G_OBJECT (wscroll), XG_FRAME_DATA, (gpointer)f);
3136 3122
3137 scroll_id = xg_store_widget_in_map (wscroll); 3123 scroll_id = xg_store_widget_in_map (wscroll);
3138 3124
3139 g_signal_connect (G_OBJECT (wscroll),
3140 "value-changed",
3141 scroll_callback,
3142 (gpointer) bar);
3143 /* The EMACS_INT cast avoids a warning. */ 3125 /* The EMACS_INT cast avoids a warning. */
3144 g_signal_connect (G_OBJECT (wscroll), 3126 g_signal_connect (G_OBJECT (wscroll),
3145 "destroy", 3127 "destroy",
3146 G_CALLBACK (xg_gtk_scroll_destroy), 3128 G_CALLBACK (xg_gtk_scroll_destroy),
3147 (gpointer) (EMACS_INT) scroll_id); 3129 (gpointer) (EMACS_INT) scroll_id);
3148 3130 g_signal_connect (G_OBJECT (wscroll),
3131 "change-value",
3132 scroll_callback,
3133 (gpointer) bar);
3149 g_signal_connect (G_OBJECT (wscroll), 3134 g_signal_connect (G_OBJECT (wscroll),
3150 "button-release-event", 3135 "button-release-event",
3151 G_CALLBACK (scroll_end_callback), 3136 end_callback,
3152 (gpointer) bar); 3137 (gpointer) bar);
3153 3138
3154 /* The scroll bar widget does not draw on a window of its own. Instead 3139 /* 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)
3327{ 3312{
3328 int retval = 0; 3313 int retval = 0;
3329 3314
3330 if (f && event->type == ButtonPress) 3315 if (f && event->type == ButtonPress && event->xbutton.button < 4)
3331 { 3316 {
3332 /* Check if press occurred outside the edit widget. */ 3317 /* Check if press occurred outside the edit widget. */
3333 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f)); 3318 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f));
3334 retval = gdk_display_get_window_at_pointer (gdpy, NULL, NULL) 3319 retval = gdk_display_get_window_at_pointer (gdpy, NULL, NULL)
3335 != f->output_data.x->edit_widget->window; 3320 != f->output_data.x->edit_widget->window;
3336 } 3321 }
3337 else if (f && (event->type == ButtonRelease || event->type == MotionNotify)) 3322 else if (f
3323 && ((event->type == ButtonRelease && event->xbutton.button < 4)
3324 || event->type == MotionNotify))
3338 { 3325 {
3339 /* If we are releasing or moving the scroll bar, it has the grab. */ 3326 /* If we are releasing or moving the scroll bar, it has the grab. */
3340 retval = gtk_grab_get_current () != 0 3327 retval = gtk_grab_get_current () != 0
diff --git a/src/gtkutil.h b/src/gtkutil.h
index 6d9f6da2699..f70a60581c2 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -32,12 +32,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
32#define XG_SB_MAX 10000000 32#define XG_SB_MAX 10000000
33#define XG_SB_RANGE (XG_SB_MAX-XG_SB_MIN) 33#define XG_SB_RANGE (XG_SB_MAX-XG_SB_MIN)
34 34
35/* Key for data that is valid for menus in a frame */ 35/* Key for data that is valid for menus and scroll bars in a frame */
36#define XG_FRAME_DATA "emacs_frame" 36#define XG_FRAME_DATA "emacs_frame"
37 37
38/* Key for data that is the last scrollbar value */
39#define XG_LAST_SB_DATA "emacs_last_sb_value"
40
41/* Key for data that menu items hold. */ 38/* Key for data that menu items hold. */
42#define XG_ITEM_DATA "emacs_menuitem" 39#define XG_ITEM_DATA "emacs_menuitem"
43 40
@@ -164,6 +161,7 @@ extern int xg_get_scroll_id_for_window P_ ((Display *dpy, Window wid));
164extern void xg_create_scroll_bar P_ ((FRAME_PTR f, 161extern void xg_create_scroll_bar P_ ((FRAME_PTR f,
165 struct scroll_bar *bar, 162 struct scroll_bar *bar,
166 GCallback scroll_callback, 163 GCallback scroll_callback,
164 GCallback end_callback,
167 char *scroll_bar_name)); 165 char *scroll_bar_name));
168extern void xg_show_scroll_bar P_ ((int scrollbar_id)); 166extern void xg_show_scroll_bar P_ ((int scrollbar_id));
169extern void xg_remove_scroll_bar P_ ((FRAME_PTR f, int scrollbar_id)); 167extern void xg_remove_scroll_bar P_ ((FRAME_PTR f, int scrollbar_id));
diff --git a/src/xterm.c b/src/xterm.c
index 9feb6c8966a..231275ea205 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -4374,63 +4374,51 @@ xm_scroll_callback (widget, client_data, call_data)
4374/* Scroll bar callback for GTK scroll bars. WIDGET is the scroll 4374/* Scroll bar callback for GTK scroll bars. WIDGET is the scroll
4375 bar widget. DATA is a pointer to the scroll_bar structure. */ 4375 bar widget. DATA is a pointer to the scroll_bar structure. */
4376 4376
4377static void 4377static gboolean
4378xg_scroll_callback (widget, data) 4378xg_scroll_callback (GtkRange *range,
4379 GtkRange *widget; 4379 GtkScrollType scroll,
4380 gpointer data; 4380 gdouble value,
4381 gpointer user_data)
4381{ 4382{
4382 struct scroll_bar *bar = (struct scroll_bar *) data; 4383 struct scroll_bar *bar = (struct scroll_bar *) user_data;
4383 gdouble previous;
4384 gdouble position; 4384 gdouble position;
4385 gdouble *p;
4386 int diff;
4387
4388 int part = -1, whole = 0, portion = 0; 4385 int part = -1, whole = 0, portion = 0;
4389 GtkAdjustment *adj = GTK_ADJUSTMENT (gtk_range_get_adjustment (widget)); 4386 GtkAdjustment *adj = GTK_ADJUSTMENT (gtk_range_get_adjustment (range));
4387 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (range), XG_FRAME_DATA);
4390 4388
4389 if (xg_ignore_gtk_scrollbar) return FALSE;
4391 position = gtk_adjustment_get_value (adj); 4390 position = gtk_adjustment_get_value (adj);
4392 4391
4393 p = g_object_get_data (G_OBJECT (widget), XG_LAST_SB_DATA);
4394 if (! p)
4395 {
4396 p = (gdouble*) xmalloc (sizeof (gdouble));
4397 *p = XG_SB_MIN;
4398 g_object_set_data (G_OBJECT (widget), XG_LAST_SB_DATA, p);
4399 }
4400
4401 previous = *p;
4402 *p = position;
4403 4392
4404 if (xg_ignore_gtk_scrollbar) return; 4393 switch (scroll)
4405
4406 diff = (int) (position - previous);
4407
4408 if (diff == (int) adj->step_increment)
4409 {
4410 part = scroll_bar_down_arrow;
4411 bar->dragging = Qnil;
4412 }
4413 else if (-diff == (int) adj->step_increment)
4414 { 4394 {
4395 case GTK_SCROLL_JUMP:
4396 /* Buttons 1 2 or 3 must be grabbed. */
4397 if (FRAME_X_DISPLAY_INFO (f)->grabbed != 0
4398 && FRAME_X_DISPLAY_INFO (f)->grabbed < (1 << 4))
4399 {
4400 part = scroll_bar_handle;
4401 whole = adj->upper - adj->page_size;
4402 portion = min ((int)position, whole);
4403 bar->dragging = make_number ((int)portion);
4404 }
4405 break;
4406 case GTK_SCROLL_STEP_BACKWARD:
4415 part = scroll_bar_up_arrow; 4407 part = scroll_bar_up_arrow;
4416 bar->dragging = Qnil; 4408 bar->dragging = Qnil;
4417 } 4409 break;
4418 else if (diff == (int) adj->page_increment) 4410 case GTK_SCROLL_STEP_FORWARD:
4419 { 4411 part = scroll_bar_down_arrow;
4420 part = scroll_bar_below_handle;
4421 bar->dragging = Qnil; 4412 bar->dragging = Qnil;
4422 } 4413 break;
4423 else if (-diff == (int) adj->page_increment) 4414 case GTK_SCROLL_PAGE_BACKWARD:
4424 {
4425 part = scroll_bar_above_handle; 4415 part = scroll_bar_above_handle;
4426 bar->dragging = Qnil; 4416 bar->dragging = Qnil;
4427 } 4417 break;
4428 else 4418 case GTK_SCROLL_PAGE_FORWARD:
4429 { 4419 part = scroll_bar_below_handle;
4430 part = scroll_bar_handle; 4420 bar->dragging = Qnil;
4431 whole = adj->upper - adj->page_size; 4421 break;
4432 portion = min ((int)position, whole);
4433 bar->dragging = make_number ((int)portion);
4434 } 4422 }
4435 4423
4436 if (part >= 0) 4424 if (part >= 0)
@@ -4439,8 +4427,30 @@ xg_scroll_callback (widget, data)
4439 last_scroll_bar_part = part; 4427 last_scroll_bar_part = part;
4440 x_send_scroll_bar_event (bar->window, part, portion, whole); 4428 x_send_scroll_bar_event (bar->window, part, portion, whole);
4441 } 4429 }
4430
4431 return FALSE;
4442} 4432}
4443 4433
4434/* Callback for button release. Sets dragging to Qnil when dragging is done. */
4435
4436static gboolean
4437xg_end_scroll_callback (GtkWidget *widget,
4438 GdkEventButton *event,
4439 gpointer user_data)
4440{
4441 struct scroll_bar *bar = (struct scroll_bar *) user_data;
4442 bar->dragging = Qnil;
4443 if (WINDOWP (window_being_scrolled))
4444 {
4445 x_send_scroll_bar_event (window_being_scrolled,
4446 scroll_bar_end_scroll, 0, 0);
4447 window_being_scrolled = Qnil;
4448 }
4449
4450 return FALSE;
4451}
4452
4453
4444#else /* not USE_GTK and not USE_MOTIF */ 4454#else /* not USE_GTK and not USE_MOTIF */
4445 4455
4446/* Xaw scroll bar callback. Invoked when the thumb is dragged. 4456/* Xaw scroll bar callback. Invoked when the thumb is dragged.
@@ -4541,6 +4551,7 @@ x_create_toolkit_scroll_bar (f, bar)
4541 4551
4542 BLOCK_INPUT; 4552 BLOCK_INPUT;
4543 xg_create_scroll_bar (f, bar, G_CALLBACK (xg_scroll_callback), 4553 xg_create_scroll_bar (f, bar, G_CALLBACK (xg_scroll_callback),
4554 G_CALLBACK (xg_end_scroll_callback),
4544 scroll_bar_name); 4555 scroll_bar_name);
4545 UNBLOCK_INPUT; 4556 UNBLOCK_INPUT;
4546} 4557}