comparison src/xterm.c @ 50324:d9a401f2769d

(take_vertical_position_into_account): Remove. (xt_action_hook): Call set_vertical_scroll_bar if needed. (XM_SB_MIN, XM_SB_RANGE): Remove (min is now set to 0). (xm_scroll_callback, x_create_toolkit_scroll_bar) (x_set_toolkit_scroll_bar_thumb): Simplify. (x_scroll_bar_expose): Only compile if !USE_TOOLKIT_SCROLL_BARS. (XTread_socket): Remove unused var. (x_make_frame_invisible): Replace goto with else.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 28 Mar 2003 14:20:09 +0000
parents fa50953c02dc
children d63b3eeca844
comparison
equal deleted inserted replaced
50323:c0fcb555d31d 50324:d9a401f2769d
349 GC, int)); 349 GC, int));
350 static void x_flush P_ ((struct frame *f)); 350 static void x_flush P_ ((struct frame *f));
351 static void x_update_begin P_ ((struct frame *)); 351 static void x_update_begin P_ ((struct frame *));
352 static void x_update_window_begin P_ ((struct window *)); 352 static void x_update_window_begin P_ ((struct window *));
353 static void x_after_update_window_line P_ ((struct glyph_row *)); 353 static void x_after_update_window_line P_ ((struct glyph_row *));
354 static INLINE void take_vertical_position_into_account P_ ((struct it *));
355 static struct scroll_bar *x_window_to_scroll_bar P_ ((Window)); 354 static struct scroll_bar *x_window_to_scroll_bar P_ ((Window));
356 static void x_scroll_bar_report_motion P_ ((struct frame **, Lisp_Object *, 355 static void x_scroll_bar_report_motion P_ ((struct frame **, Lisp_Object *,
357 enum scroll_bar_part *, 356 enum scroll_bar_part *,
358 Lisp_Object *, Lisp_Object *, 357 Lisp_Object *, Lisp_Object *,
359 unsigned long *)); 358 unsigned long *));
3948 thumb. If not, resizing the thumb needs to be done more carefully 3947 thumb. If not, resizing the thumb needs to be done more carefully
3949 to avoid jerkyness. */ 3948 to avoid jerkyness. */
3950 3949
3951 static Boolean xaw3d_pick_top; 3950 static Boolean xaw3d_pick_top;
3952 3951
3952 extern void set_vertical_scroll_bar P_ ((struct window *));
3953 3953
3954 /* Action hook installed via XtAppAddActionHook when toolkit scroll 3954 /* Action hook installed via XtAppAddActionHook when toolkit scroll
3955 bars are used.. The hook is responsible for detecting when 3955 bars are used.. The hook is responsible for detecting when
3956 the user ends an interaction with the scroll bar, and generates 3956 the user ends an interaction with the scroll bar, and generates
3957 a `end-scroll' SCROLL_BAR_CLICK_EVENT' event if so. */ 3957 a `end-scroll' SCROLL_BAR_CLICK_EVENT' event if so. */
3984 struct window *w; 3984 struct window *w;
3985 3985
3986 x_send_scroll_bar_event (window_being_scrolled, 3986 x_send_scroll_bar_event (window_being_scrolled,
3987 scroll_bar_end_scroll, 0, 0); 3987 scroll_bar_end_scroll, 0, 0);
3988 w = XWINDOW (window_being_scrolled); 3988 w = XWINDOW (window_being_scrolled);
3989
3990 if (!NILP (XSCROLL_BAR (w->vertical_scroll_bar)->dragging))
3991 /* The thumb size is incorrect while dragging: fix it. */
3992 set_vertical_scroll_bar (w);
3993
3989 XSCROLL_BAR (w->vertical_scroll_bar)->dragging = Qnil; 3994 XSCROLL_BAR (w->vertical_scroll_bar)->dragging = Qnil;
3990 window_being_scrolled = Qnil; 3995 window_being_scrolled = Qnil;
3991 last_scroll_bar_part = -1; 3996 last_scroll_bar_part = -1;
3992 3997
3993 /* Xt timeouts no longer needed. */ 3998 /* Xt timeouts no longer needed. */
4103 4108
4104 #ifdef USE_MOTIF 4109 #ifdef USE_MOTIF
4105 4110
4106 /* Minimum and maximum values used for Motif scroll bars. */ 4111 /* Minimum and maximum values used for Motif scroll bars. */
4107 4112
4108 #define XM_SB_MIN 1
4109 #define XM_SB_MAX 10000000 4113 #define XM_SB_MAX 10000000
4110 #define XM_SB_RANGE (XM_SB_MAX - XM_SB_MIN)
4111 4114
4112 4115
4113 /* Scroll bar callback for Motif scroll bars. WIDGET is the scroll 4116 /* Scroll bar callback for Motif scroll bars. WIDGET is the scroll
4114 bar widget. CLIENT_DATA is a pointer to the scroll_bar structure. 4117 bar widget. CLIENT_DATA is a pointer to the scroll_bar structure.
4115 CALL_DATA is a pointer to a XmScrollBarCallbackStruct. */ 4118 CALL_DATA is a pointer to a XmScrollBarCallbackStruct. */
4156 break; 4159 break;
4157 4160
4158 case XmCR_DRAG: 4161 case XmCR_DRAG:
4159 { 4162 {
4160 int slider_size; 4163 int slider_size;
4161 int dragging_down_p = (INTEGERP (bar->dragging)
4162 && XINT (bar->dragging) <= cs->value);
4163 4164
4164 /* Get the slider size. */ 4165 /* Get the slider size. */
4165 BLOCK_INPUT; 4166 BLOCK_INPUT;
4166 XtVaGetValues (widget, XmNsliderSize, &slider_size, NULL); 4167 XtVaGetValues (widget, XmNsliderSize, &slider_size, NULL);
4167 UNBLOCK_INPUT; 4168 UNBLOCK_INPUT;
4168 4169
4169 whole = XM_SB_RANGE - slider_size; 4170 whole = XM_SB_MAX;
4170 portion = min (cs->value - XM_SB_MIN, whole); 4171 portion = min (cs->value, whole);
4171 part = scroll_bar_handle; 4172 part = scroll_bar_handle;
4172 bar->dragging = make_number (cs->value); 4173 bar->dragging = make_number (cs->value);
4173 } 4174 }
4174 break; 4175 break;
4175 4176
4380 BLOCK_INPUT; 4381 BLOCK_INPUT;
4381 4382
4382 #ifdef USE_MOTIF 4383 #ifdef USE_MOTIF
4383 /* Set resources. Create the widget. */ 4384 /* Set resources. Create the widget. */
4384 XtSetArg (av[ac], XtNmappedWhenManaged, False); ++ac; 4385 XtSetArg (av[ac], XtNmappedWhenManaged, False); ++ac;
4385 XtSetArg (av[ac], XmNminimum, XM_SB_MIN); ++ac; 4386 XtSetArg (av[ac], XmNminimum, 0); ++ac;
4386 XtSetArg (av[ac], XmNmaximum, XM_SB_MAX); ++ac; 4387 XtSetArg (av[ac], XmNmaximum, XM_SB_MAX); ++ac;
4387 XtSetArg (av[ac], XmNorientation, XmVERTICAL); ++ac; 4388 XtSetArg (av[ac], XmNorientation, XmVERTICAL); ++ac;
4388 XtSetArg (av[ac], XmNprocessingDirection, XmMAX_ON_BOTTOM), ++ac; 4389 XtSetArg (av[ac], XmNprocessingDirection, XmMAX_ON_BOTTOM), ++ac;
4389 XtSetArg (av[ac], XmNincrement, 1); ++ac; 4390 XtSetArg (av[ac], XmNincrement, 1); ++ac;
4390 XtSetArg (av[ac], XmNpageIncrement, 1); ++ac; 4391 XtSetArg (av[ac], XmNpageIncrement, 1); ++ac;
4605 int size, value; 4606 int size, value;
4606 4607
4607 /* Slider size. Must be in the range [1 .. MAX - MIN] where MAX 4608 /* Slider size. Must be in the range [1 .. MAX - MIN] where MAX
4608 is the scroll bar's maximum and MIN is the scroll bar's minimum 4609 is the scroll bar's maximum and MIN is the scroll bar's minimum
4609 value. */ 4610 value. */
4610 size = shown * XM_SB_RANGE; 4611 size = shown * XM_SB_MAX;
4611 size = min (size, XM_SB_RANGE); 4612 size = min (size, XM_SB_MAX);
4612 size = max (size, 1); 4613 size = max (size, 1);
4613 4614
4614 /* Position. Must be in the range [MIN .. MAX - SLIDER_SIZE]. */ 4615 /* Position. Must be in the range [MIN .. MAX - SLIDER_SIZE]. */
4615 value = top * XM_SB_RANGE; 4616 value = top * XM_SB_MAX;
4616 value = min (value, XM_SB_MAX - size); 4617 value = min (value, XM_SB_MAX - size);
4617 value = max (value, XM_SB_MIN);
4618 4618
4619 XmScrollBarSetValues (widget, value, size, 0, 0, False); 4619 XmScrollBarSetValues (widget, value, size, 0, 0, False);
4620 } 4620 }
4621 #else /* !USE_MOTIF i.e. use Xaw */ 4621 #else /* !USE_MOTIF i.e. use Xaw */
4622 4622
5238 /* Now there should be no references to the condemned scroll bars, 5238 /* Now there should be no references to the condemned scroll bars,
5239 and they should get garbage-collected. */ 5239 and they should get garbage-collected. */
5240 } 5240 }
5241 5241
5242 5242
5243 #ifndef USE_TOOLKIT_SCROLL_BARS
5243 /* Handle an Expose or GraphicsExpose event on a scroll bar. This 5244 /* Handle an Expose or GraphicsExpose event on a scroll bar. This
5244 is a no-op when using toolkit scroll bars. 5245 is a no-op when using toolkit scroll bars.
5245 5246
5246 This may be called from a signal handler, so we have to ignore GC 5247 This may be called from a signal handler, so we have to ignore GC
5247 mark bits. */ 5248 mark bits. */
5249 static void 5250 static void
5250 x_scroll_bar_expose (bar, event) 5251 x_scroll_bar_expose (bar, event)
5251 struct scroll_bar *bar; 5252 struct scroll_bar *bar;
5252 XEvent *event; 5253 XEvent *event;
5253 { 5254 {
5254 #ifndef USE_TOOLKIT_SCROLL_BARS
5255
5256 Window w = SCROLL_BAR_X_WINDOW (bar); 5255 Window w = SCROLL_BAR_X_WINDOW (bar);
5257 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 5256 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
5258 GC gc = f->output_data.x->normal_gc; 5257 GC gc = f->output_data.x->normal_gc;
5259 int width_trim = VERTICAL_SCROLL_BAR_WIDTH_TRIM; 5258 int width_trim = VERTICAL_SCROLL_BAR_WIDTH_TRIM;
5260 5259
5270 XINT (bar->width) - 1 - width_trim - width_trim, 5269 XINT (bar->width) - 1 - width_trim - width_trim,
5271 XINT (bar->height) - 1); 5270 XINT (bar->height) - 1);
5272 5271
5273 UNBLOCK_INPUT; 5272 UNBLOCK_INPUT;
5274 5273
5274 }
5275 #endif /* not USE_TOOLKIT_SCROLL_BARS */ 5275 #endif /* not USE_TOOLKIT_SCROLL_BARS */
5276 }
5277 5276
5278 /* Handle a mouse click on the scroll bar BAR. If *EMACS_EVENT's kind 5277 /* Handle a mouse click on the scroll bar BAR. If *EMACS_EVENT's kind
5279 is set to something other than NO_EVENT, it is enqueued. 5278 is set to something other than NO_EVENT, it is enqueued.
5280 5279
5281 This may be called from a signal handler, so we have to ignore GC 5280 This may be called from a signal handler, so we have to ignore GC
7041 /* register */ struct input_event *bufp; 7040 /* register */ struct input_event *bufp;
7042 /* register */ int numchars; 7041 /* register */ int numchars;
7043 int expected; 7042 int expected;
7044 { 7043 {
7045 int count = 0; 7044 int count = 0;
7046 int nbytes = 0;
7047 XEvent event; 7045 XEvent event;
7048 int event_found = 0; 7046 int event_found = 0;
7049 struct x_display_info *dpyinfo; 7047 struct x_display_info *dpyinfo;
7050 7048
7051 if (interrupt_input_blocked) 7049 if (interrupt_input_blocked)
8857 by hand again (they have already done that once for this window.) */ 8855 by hand again (they have already done that once for this window.) */
8858 x_wm_set_size_hint (f, (long) 0, 1); 8856 x_wm_set_size_hint (f, (long) 0, 1);
8859 8857
8860 #ifdef USE_GTK 8858 #ifdef USE_GTK
8861 if (FRAME_GTK_OUTER_WIDGET (f)) 8859 if (FRAME_GTK_OUTER_WIDGET (f))
8862 { 8860 gtk_widget_hide (FRAME_GTK_OUTER_WIDGET (f));
8863 gtk_widget_hide (FRAME_GTK_OUTER_WIDGET (f)); 8861 else
8864 goto out; 8862 #endif
8865 } 8863 {
8866 #endif
8867
8868 #ifdef HAVE_X11R4 8864 #ifdef HAVE_X11R4
8869 8865
8870 if (! XWithdrawWindow (FRAME_X_DISPLAY (f), window, 8866 if (! XWithdrawWindow (FRAME_X_DISPLAY (f), window,
8871 DefaultScreen (FRAME_X_DISPLAY (f)))) 8867 DefaultScreen (FRAME_X_DISPLAY (f))))
8872 { 8868 {
8896 } 8892 }
8897 8893
8898 /* Unmap the window ourselves. Cheeky! */ 8894 /* Unmap the window ourselves. Cheeky! */
8899 XUnmapWindow (FRAME_X_DISPLAY (f), window); 8895 XUnmapWindow (FRAME_X_DISPLAY (f), window);
8900 #endif /* ! defined (HAVE_X11R4) */ 8896 #endif /* ! defined (HAVE_X11R4) */
8901 8897 }
8902 out: 8898
8903 /* We can't distinguish this from iconification 8899 /* We can't distinguish this from iconification
8904 just by the event that we get from the server. 8900 just by the event that we get from the server.
8905 So we can't win using the usual strategy of letting 8901 So we can't win using the usual strategy of letting
8906 FRAME_SAMPLE_VISIBILITY set this. So do it by hand, 8902 FRAME_SAMPLE_VISIBILITY set this. So do it by hand,
8907 and synchronize with the server to make sure we agree. */ 8903 and synchronize with the server to make sure we agree. */