aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Blandy1992-12-24 06:19:31 +0000
committerJim Blandy1992-12-24 06:19:31 +0000
commit179956b9a45158eafca42eb0d9071281a63bd3c2 (patch)
tree32c76c656248fcc3bb17216974b76df1f2781f31 /src
parent30c566e465ab310e39f9c0189623532851c4445f (diff)
downloademacs-179956b9a45158eafca42eb0d9071281a63bd3c2.tar.gz
emacs-179956b9a45158eafca42eb0d9071281a63bd3c2.zip
* frame.h (struct frame): New fields `can_have_scrollbars' and
`has_vertical_scrollbars'. (FRAME_CAN_HAVE_SCROLLBARS, FRAME_HAS_VERTICAL_SCROLLBARS): New accessors, for both the MULTI_FRAME and non-MULTI_FRAME. (VERTICAL_SCROLLBAR_WIDTH, WINDOW_VERTICAL_SCROLLBAR, WINDOW_VERTICAL_SCROLLBAR_COLUMN, WINDOW_VERTICAL_SCROLLBAR_HEIGHT): New macros. * window.h (struct window): New field `vertical_scrollbar'. * xterm.h (struct x_display): vertical_scrollbars, judge_timestamp, vertical_scrollbar_extra: New fields. (struct scrollbar): New struct. (VERTICAL_SCROLLBAR_PIXEL_WIDTH, VERTICAL_SCROLLBAR_PIXEL_HEIGHT, VERTICAL_SCROLLBAR_LEFT_BORDER, VERTICAL_SCROLLBAR_RIGHT_BORDER, VERTICAL_SCROLLBAR_TOP_BORDER, VERTICAL_SCROLLBAR_BOTTOM_BORDER, CHAR_TO_PIXEL_WIDTH, CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_WIDTH, PIXEL_TO_CHAR_HEIGHT): New accessors and macros. * frame.c (make_frame): Initialize the `can_have_scrollbars' and `has_vertical_scrollbars' fields of the frame. * term.c (term_init): Note that TERMCAP terminals don't support scrollbars. (mouse_position_hook): Document new args. (set_vertical_scrollbar_hook, condemn_scrollbars_hook, redeem_scrollbar_hook, judge_scrollbars_hook): New hooks. * termhooks.h: Declare and document them. (enum scrollbar_part): New type. (struct input_event): Describe the new form of the scrollbar_click event type. Change `part' from a Lisp_Object to an enum scrollbar_part. Add a new field `scrollbar'. * keyboard.c (kbd_buffer_get_event): Pass appropriate new parameters to *mouse_position_hook, and make_lispy_movement. * xfns.c (x_set_vertical_scrollbar): New function. (x_figure_window_size): Use new macros to calculate frame size. (Fx_create_frame): Note that X Windows frames do support scroll bars. Default to "yes". * xterm.c: #include <X11/cursorfont.h> and "window.h". (x_vertical_scrollbar_cursor): New variable. (x_term_init): Initialize it. (last_mouse_bar, last_mouse_bar_frame, last_mouse_part, last_mouse_scroll_range_start, last_mouse_scroll_range_end): New variables. (XTmouse_position): Use them to return scrollbar movement events. Take new arguments, for that purpose. (x_window_to_scrollbar, x_scrollbar_create, x_scrollbar_set_handle, x_scrollbar_remove, x_scrollbar_move, XTset_scrollbar, XTcondemn_scrollbars, XTredeem_scrollbar, XTjudge_scrollbars, x_scrollbar_expose, x_scrollbar_background_expose, x_scrollbar_handle_click, x_scrollbar_handle_motion): New functions to implement scrollbars. (x_term_init): Set the termhooks.h hooks to point to them. (x_set_window_size): Use new macros to calculate frame size. Set vertical_scrollbar_extra field. (x_make_frame_visible): Use the frame accessor FRAME_HAS_VERTICAL_SCROLLBARS to decide if we need to map the frame's subwindows as well. (XTread_socket): Use new size-calculation macros from xterm.h when processing ConfigureNotify events. (x_wm_set_size_hint): Use PIXEL_TO_CHAR_WIDTH and PIXEL_TO_CHAR_HEIGHT macros. * ymakefile (xdisp.o): This now depends on termhooks.h. (xterm.o): This now depends on window.h. * xterm.h (struct x_display): Delete v_scrollbar, v_thumbup, v_thumbdown, v_slider, h_scrollbar, h_thumbup, h_thumbdown, h_slider, v_scrollbar_width, h_scrollbar_height fields. * keyboard.c (Qvscrollbar_part, Qvslider_part, Qvthumbup_part, Qvthumbdown_part, Qhscrollbar_part, Qhslider_part, Qhthumbup_part, Qhthumbdown_part, Qscrollbar_click): Deleted; part of an obsolete interface. (head_table): Removed from here as well. (syms_of_keyboard): And here. * keyboard.h: And here. (POSN_SCROLLBAR_BUTTON): Removed. * xscrollbar.h: File removed - no longer necessary. * xfns.c: Don't #include it any more. (Qhorizontal_scroll_bar, Qvertical_scroll_bar): Deleted. (syms_of_xfns): Don't initialize or staticpro them. (gray_bits): Salvaged from xscrollbar.h. (x_window_to_scrollbar): Deleted. (x_set_horizontal_scrollbar): Deleted. (enum x_frame_parm, x_frame_parms): Remove references to x_set_horizontal_scrollbar. (x_set_foreground_color, x_set_background_color, x_set_border_pixel): Remove special code to support scrollbars. (Fx_create_frame): Remove old scrollbar setup code. (install_vertical_scrollbar, install_horizontal_scrollbar, adjust_scrollbars, x_resize_scrollbars): Deleted. * xterm.c (construct_mouse_click): This doesn't need to take care of scrollbar clicks anymore. (XTread_socket): Remove old code to support scrollbars. Call new functions instead for events which occur in scrollbar windows. (XTupdate_end): Remove call to adjust_scrollbars; the main redisplay code takes care of that now. (enum window_type): Deleted. * ymakefile: Note that xfns.o no longer depends on xscrollbar.h. * xfns.c (syms_of_xfns): Delete defvars for x_mouse_x and x_mouse_y. That interface hasn't been live for years. (x_mouse_x, x_mouse_y): Delete these variables. * xfns.c (Fx_create_frame): Don't initialize the wm_hints field here. (x_window): Do it here, along with all the similar stuff. It's a pain to remember that you can't assign to FRAME->visible. Let's change all references to the `visible' member of struct frame to use the accessor macros, and then write a setter for the `visible' field that does the right thing. * frame.h (FRAME_VISIBLE_P): Make this not an l-value. (FRAME_SET_VISIBLE): New macro. * frame.c (make_terminal_frame, Fdelete_frame): Use FRAME_SET_VISIBLE. (Fframe_visible_p, Fvisible_frame_list): Use FRAME_VISIBLE_P and FRAME_ICONIFIED_P. * dispnew.c (Fredraw_display): Use the FRAME_VISIBLE_P and FRAME_GARBAGED_P accessors. * xdisp.c (redisplay): Use the FRAME_VISIBLE_P accessor. * xfns.c (x_set_foreground_color, x_set_background_color, x_set_cursor_color, x_set_border_pixel, x_set_icon_type): Use the FRAME_VISIBLE_P accessor. (Fx_create_frame): Use FRAME_SET_VISIBILITY. * xterm.c (clear_cursor, x_display_bar_cursor, x_display_box_cursor): Use FRAME_SET_VISIBILITY.
Diffstat (limited to 'src')
-rw-r--r--src/xfns.c903
1 files changed, 44 insertions, 859 deletions
diff --git a/src/xfns.c b/src/xfns.c
index ef09ffaefbf..d0826835d06 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -32,7 +32,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
32#include "window.h" 32#include "window.h"
33#include "buffer.h" 33#include "buffer.h"
34#include "dispextern.h" 34#include "dispextern.h"
35#include "xscrollbar.h"
36#include "keyboard.h" 35#include "keyboard.h"
37 36
38#ifdef HAVE_X_WINDOWS 37#ifdef HAVE_X_WINDOWS
@@ -177,7 +176,7 @@ extern Atom Xatom_wm_window_moved; /* When the WM moves us. */
177 176
178#else /* X10 */ 177#else /* X10 */
179 178
180/* Default size of an Emacs window without scroll bar. */ 179/* Default size of an Emacs window. */
181static char *default_window = "=80x24+0+0"; 180static char *default_window = "=80x24+0+0";
182 181
183#define MAXICID 80 182#define MAXICID 80
@@ -235,7 +234,6 @@ Lisp_Object Qcursor_color;
235Lisp_Object Qfont; 234Lisp_Object Qfont;
236Lisp_Object Qforeground_color; 235Lisp_Object Qforeground_color;
237Lisp_Object Qgeometry; 236Lisp_Object Qgeometry;
238Lisp_Object Qhorizontal_scroll_bar;
239Lisp_Object Qicon_left; 237Lisp_Object Qicon_left;
240Lisp_Object Qicon_top; 238Lisp_Object Qicon_top;
241Lisp_Object Qicon_type; 239Lisp_Object Qicon_type;
@@ -248,7 +246,6 @@ Lisp_Object Qsuppress_icon;
248Lisp_Object Qsuppress_initial_map; 246Lisp_Object Qsuppress_initial_map;
249Lisp_Object Qtop; 247Lisp_Object Qtop;
250Lisp_Object Qundefined_color; 248Lisp_Object Qundefined_color;
251Lisp_Object Qvertical_scroll_bar;
252Lisp_Object Qwindow_id; 249Lisp_Object Qwindow_id;
253Lisp_Object Qx_frame_parameter; 250Lisp_Object Qx_frame_parameter;
254 251
@@ -263,6 +260,14 @@ extern Lisp_Object Vglobal_mouse_map;
263 260
264/* Points to table of defined typefaces. */ 261/* Points to table of defined typefaces. */
265struct face *x_face_table[MAX_FACES_AND_GLYPHS]; 262struct face *x_face_table[MAX_FACES_AND_GLYPHS];
263
264static char gray_bits[] =
265 {
266 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
267 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
268 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
269 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa
270 };
266 271
267/* Return the Emacs frame-object corresponding to an X window. 272/* Return the Emacs frame-object corresponding to an X window.
268 It could be the frame's main window or an icon window. */ 273 It could be the frame's main window or an icon window. */
@@ -287,80 +292,6 @@ x_window_to_frame (wdesc)
287 return 0; 292 return 0;
288} 293}
289 294
290/* Map an X window that implements a scroll bar to the Emacs frame it
291 belongs to. Also store in *PART a symbol identifying which part of
292 the scroll bar it is. */
293
294struct frame *
295x_window_to_scrollbar (wdesc, part_ptr, prefix_ptr)
296 int wdesc;
297 Lisp_Object *part_ptr;
298 enum scroll_bar_prefix *prefix_ptr;
299{
300 Lisp_Object tail, frame;
301 struct frame *f;
302
303 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
304 {
305 frame = XCONS (tail)->car;
306 if (XTYPE (frame) != Lisp_Frame)
307 continue;
308
309 f = XFRAME (frame);
310 if (part_ptr == 0 && prefix_ptr == 0)
311 return f;
312
313 if (f->display.x->v_scrollbar == wdesc)
314 {
315 *part_ptr = Qvscrollbar_part;
316 *prefix_ptr = VSCROLL_BAR_PREFIX;
317 return f;
318 }
319 else if (f->display.x->v_slider == wdesc)
320 {
321 *part_ptr = Qvslider_part;
322 *prefix_ptr = VSCROLL_SLIDER_PREFIX;
323 return f;
324 }
325 else if (f->display.x->v_thumbup == wdesc)
326 {
327 *part_ptr = Qvthumbup_part;
328 *prefix_ptr = VSCROLL_THUMBUP_PREFIX;
329 return f;
330 }
331 else if (f->display.x->v_thumbdown == wdesc)
332 {
333 *part_ptr = Qvthumbdown_part;
334 *prefix_ptr = VSCROLL_THUMBDOWN_PREFIX;
335 return f;
336 }
337 else if (f->display.x->h_scrollbar == wdesc)
338 {
339 *part_ptr = Qhscrollbar_part;
340 *prefix_ptr = HSCROLL_BAR_PREFIX;
341 return f;
342 }
343 else if (f->display.x->h_slider == wdesc)
344 {
345 *part_ptr = Qhslider_part;
346 *prefix_ptr = HSCROLL_SLIDER_PREFIX;
347 return f;
348 }
349 else if (f->display.x->h_thumbleft == wdesc)
350 {
351 *part_ptr = Qhthumbleft_part;
352 *prefix_ptr = HSCROLL_THUMBLEFT_PREFIX;
353 return f;
354 }
355 else if (f->display.x->h_thumbright == wdesc)
356 {
357 *part_ptr = Qhthumbright_part;
358 *prefix_ptr = HSCROLL_THUMBRIGHT_PREFIX;
359 return f;
360 }
361 }
362 return 0;
363}
364 295
365/* Connect the frame-parameter names for X frames 296/* Connect the frame-parameter names for X frames
366 to the ways of passing the parameter values to the window system. 297 to the ways of passing the parameter values to the window system.
@@ -384,7 +315,6 @@ enum x_frame_parm
384 X_PARM_AUTORAISE, 315 X_PARM_AUTORAISE,
385 X_PARM_AUTOLOWER, 316 X_PARM_AUTOLOWER,
386 X_PARM_VERT_SCROLLBAR, 317 X_PARM_VERT_SCROLLBAR,
387 X_PARM_HORIZ_SCROLLBAR,
388}; 318};
389 319
390 320
@@ -407,7 +337,6 @@ void x_explicitly_set_name ();
407void x_set_autoraise (); 337void x_set_autoraise ();
408void x_set_autolower (); 338void x_set_autolower ();
409void x_set_vertical_scrollbar (); 339void x_set_vertical_scrollbar ();
410void x_set_horizontal_scrollbar ();
411 340
412static struct x_frame_parm_table x_frame_parms[] = 341static struct x_frame_parm_table x_frame_parms[] =
413{ 342{
@@ -424,7 +353,6 @@ static struct x_frame_parm_table x_frame_parms[] =
424 "autoraise", x_set_autoraise, 353 "autoraise", x_set_autoraise,
425 "autolower", x_set_autolower, 354 "autolower", x_set_autolower,
426 "vertical-scrollbar", x_set_vertical_scrollbar, 355 "vertical-scrollbar", x_set_vertical_scrollbar,
427 "horizontal-scrollbar", x_set_horizontal_scrollbar,
428}; 356};
429 357
430/* Attach the `x-frame-parameter' properties to 358/* Attach the `x-frame-parameter' properties to
@@ -637,98 +565,9 @@ x_set_foreground_color (f, arg, oldval)
637 f->display.x->foreground_pixel); 565 f->display.x->foreground_pixel);
638 XSetBackground (x_current_display, f->display.x->reverse_gc, 566 XSetBackground (x_current_display, f->display.x->reverse_gc,
639 f->display.x->foreground_pixel); 567 f->display.x->foreground_pixel);
640 if (f->display.x->v_scrollbar)
641 {
642 Pixmap up_arrow_pixmap, down_arrow_pixmap, slider_pixmap;
643
644 XSetWindowBorder (x_current_display, f->display.x->v_scrollbar,
645 f->display.x->foreground_pixel);
646
647 slider_pixmap =
648 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
649 gray_bits, 16, 16,
650 f->display.x->foreground_pixel,
651 f->display.x->background_pixel,
652 DefaultDepth (x_current_display,
653 XDefaultScreen (x_current_display)));
654 up_arrow_pixmap =
655 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
656 up_arrow_bits, 16, 16,
657 f->display.x->foreground_pixel,
658 f->display.x->background_pixel,
659 DefaultDepth (x_current_display,
660 XDefaultScreen (x_current_display)));
661 down_arrow_pixmap =
662 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
663 down_arrow_bits, 16, 16,
664 f->display.x->foreground_pixel,
665 f->display.x->background_pixel,
666 DefaultDepth (x_current_display,
667 XDefaultScreen (x_current_display)));
668
669 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->v_thumbup,
670 up_arrow_pixmap);
671 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->v_thumbdown,
672 down_arrow_pixmap);
673 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->v_slider,
674 slider_pixmap);
675
676 XClearWindow (XDISPLAY f->display.x->v_thumbup);
677 XClearWindow (XDISPLAY f->display.x->v_thumbdown);
678 XClearWindow (XDISPLAY f->display.x->v_slider);
679
680 XFreePixmap (x_current_display, down_arrow_pixmap);
681 XFreePixmap (x_current_display, up_arrow_pixmap);
682 XFreePixmap (x_current_display, slider_pixmap);
683 }
684 if (f->display.x->h_scrollbar)
685 {
686 Pixmap left_arrow_pixmap, right_arrow_pixmap, slider_pixmap;
687
688 XSetWindowBorder (x_current_display, f->display.x->h_scrollbar,
689 f->display.x->foreground_pixel);
690
691 slider_pixmap =
692 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
693 gray_bits, 16, 16,
694 f->display.x->foreground_pixel,
695 f->display.x->background_pixel,
696 DefaultDepth (x_current_display,
697 XDefaultScreen (x_current_display)));
698
699 left_arrow_pixmap =
700 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
701 up_arrow_bits, 16, 16,
702 f->display.x->foreground_pixel,
703 f->display.x->background_pixel,
704 DefaultDepth (x_current_display,
705 XDefaultScreen (x_current_display)));
706 right_arrow_pixmap =
707 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
708 down_arrow_bits, 16, 16,
709 f->display.x->foreground_pixel,
710 f->display.x->background_pixel,
711 DefaultDepth (x_current_display,
712 XDefaultScreen (x_current_display)));
713
714 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->h_slider,
715 slider_pixmap);
716 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->h_thumbleft,
717 left_arrow_pixmap);
718 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->h_thumbright,
719 right_arrow_pixmap);
720
721 XClearWindow (XDISPLAY f->display.x->h_thumbleft);
722 XClearWindow (XDISPLAY f->display.x->h_thumbright);
723 XClearWindow (XDISPLAY f->display.x->h_slider);
724
725 XFreePixmap (x_current_display, slider_pixmap);
726 XFreePixmap (x_current_display, left_arrow_pixmap);
727 XFreePixmap (x_current_display, right_arrow_pixmap);
728 }
729 UNBLOCK_INPUT; 568 UNBLOCK_INPUT;
730#endif /* HAVE_X11 */ 569#endif /* HAVE_X11 */
731 if (f->visible) 570 if (FRAME_VISIBLE_P (f))
732 redraw_frame (f); 571 redraw_frame (f);
733 } 572 }
734} 573}
@@ -755,96 +594,6 @@ x_set_background_color (f, arg, oldval)
755 XSetWindowBackground (x_current_display, FRAME_X_WINDOW (f), 594 XSetWindowBackground (x_current_display, FRAME_X_WINDOW (f),
756 f->display.x->background_pixel); 595 f->display.x->background_pixel);
757 596
758 /* Scroll bars. */
759 if (f->display.x->v_scrollbar)
760 {
761 Pixmap up_arrow_pixmap, down_arrow_pixmap, slider_pixmap;
762
763 XSetWindowBackground (x_current_display, f->display.x->v_scrollbar,
764 f->display.x->background_pixel);
765
766 slider_pixmap =
767 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
768 gray_bits, 16, 16,
769 f->display.x->foreground_pixel,
770 f->display.x->background_pixel,
771 DefaultDepth (x_current_display,
772 XDefaultScreen (x_current_display)));
773 up_arrow_pixmap =
774 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
775 up_arrow_bits, 16, 16,
776 f->display.x->foreground_pixel,
777 f->display.x->background_pixel,
778 DefaultDepth (x_current_display,
779 XDefaultScreen (x_current_display)));
780 down_arrow_pixmap =
781 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
782 down_arrow_bits, 16, 16,
783 f->display.x->foreground_pixel,
784 f->display.x->background_pixel,
785 DefaultDepth (x_current_display,
786 XDefaultScreen (x_current_display)));
787
788 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->v_thumbup,
789 up_arrow_pixmap);
790 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->v_thumbdown,
791 down_arrow_pixmap);
792 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->v_slider,
793 slider_pixmap);
794
795 XClearWindow (XDISPLAY f->display.x->v_thumbup);
796 XClearWindow (XDISPLAY f->display.x->v_thumbdown);
797 XClearWindow (XDISPLAY f->display.x->v_slider);
798
799 XFreePixmap (x_current_display, down_arrow_pixmap);
800 XFreePixmap (x_current_display, up_arrow_pixmap);
801 XFreePixmap (x_current_display, slider_pixmap);
802 }
803 if (f->display.x->h_scrollbar)
804 {
805 Pixmap left_arrow_pixmap, right_arrow_pixmap, slider_pixmap;
806
807 XSetWindowBackground (x_current_display, f->display.x->h_scrollbar,
808 f->display.x->background_pixel);
809
810 slider_pixmap =
811 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
812 gray_bits, 16, 16,
813 f->display.x->foreground_pixel,
814 f->display.x->background_pixel,
815 DefaultDepth (x_current_display,
816 XDefaultScreen (x_current_display)));
817
818 left_arrow_pixmap =
819 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
820 up_arrow_bits, 16, 16,
821 f->display.x->foreground_pixel,
822 f->display.x->background_pixel,
823 DefaultDepth (x_current_display,
824 XDefaultScreen (x_current_display)));
825 right_arrow_pixmap =
826 XCreatePixmapFromBitmapData (XDISPLAY FRAME_X_WINDOW (f),
827 down_arrow_bits, 16, 16,
828 f->display.x->foreground_pixel,
829 f->display.x->background_pixel,
830 DefaultDepth (x_current_display,
831 XDefaultScreen (x_current_display)));
832
833 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->h_slider,
834 slider_pixmap);
835 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->h_thumbleft,
836 left_arrow_pixmap);
837 XSetWindowBackgroundPixmap (XDISPLAY f->display.x->h_thumbright,
838 right_arrow_pixmap);
839
840 XClearWindow (XDISPLAY f->display.x->h_thumbleft);
841 XClearWindow (XDISPLAY f->display.x->h_thumbright);
842 XClearWindow (XDISPLAY f->display.x->h_slider);
843
844 XFreePixmap (x_current_display, slider_pixmap);
845 XFreePixmap (x_current_display, left_arrow_pixmap);
846 XFreePixmap (x_current_display, right_arrow_pixmap);
847 }
848#else 597#else
849 temp = XMakeTile (f->display.x->background_pixel); 598 temp = XMakeTile (f->display.x->background_pixel);
850 XChangeBackground (FRAME_X_WINDOW (f), temp); 599 XChangeBackground (FRAME_X_WINDOW (f), temp);
@@ -852,7 +601,7 @@ x_set_background_color (f, arg, oldval)
852#endif /* not HAVE_X11 */ 601#endif /* not HAVE_X11 */
853 UNBLOCK_INPUT; 602 UNBLOCK_INPUT;
854 603
855 if (f->visible) 604 if (FRAME_VISIBLE_P (f))
856 redraw_frame (f); 605 redraw_frame (f);
857 } 606 }
858} 607}
@@ -995,7 +744,7 @@ x_set_cursor_color (f, arg, oldval)
995 UNBLOCK_INPUT; 744 UNBLOCK_INPUT;
996#endif /* HAVE_X11 */ 745#endif /* HAVE_X11 */
997 746
998 if (f->visible) 747 if (FRAME_VISIBLE_P (f))
999 { 748 {
1000 x_display_cursor (f, 0); 749 x_display_cursor (f, 0);
1001 x_display_cursor (f, 1); 750 x_display_cursor (f, 1);
@@ -1056,12 +805,6 @@ x_set_border_pixel (f, pix)
1056#ifdef HAVE_X11 805#ifdef HAVE_X11
1057 XSetWindowBorder (x_current_display, FRAME_X_WINDOW (f), 806 XSetWindowBorder (x_current_display, FRAME_X_WINDOW (f),
1058 pix); 807 pix);
1059 if (f->display.x->h_scrollbar)
1060 XSetWindowBorder (x_current_display, f->display.x->h_slider,
1061 pix);
1062 if (f->display.x->v_scrollbar)
1063 XSetWindowBorder (x_current_display, f->display.x->v_slider,
1064 pix);
1065#else 808#else
1066 if (pix < 0) 809 if (pix < 0)
1067 temp = XMakePixmap ((Bitmap) XStoreBitmap (16, 16, gray_bits), 810 temp = XMakePixmap ((Bitmap) XStoreBitmap (16, 16, gray_bits),
@@ -1073,7 +816,7 @@ x_set_border_pixel (f, pix)
1073#endif /* not HAVE_X11 */ 816#endif /* not HAVE_X11 */
1074 UNBLOCK_INPUT; 817 UNBLOCK_INPUT;
1075 818
1076 if (f->visible) 819 if (FRAME_VISIBLE_P (f))
1077 redraw_frame (f); 820 redraw_frame (f);
1078 } 821 }
1079} 822}
@@ -1103,7 +846,7 @@ x_set_icon_type (f, arg, oldval)
1103 846
1104 /* If the window was unmapped (and its icon was mapped), 847 /* If the window was unmapped (and its icon was mapped),
1105 the new icon is not mapped, so map the window in its stead. */ 848 the new icon is not mapped, so map the window in its stead. */
1106 if (f->visible) 849 if (FRAME_VISIBLE_P (f))
1107 XMapWindow (XDISPLAY FRAME_X_WINDOW (f)); 850 XMapWindow (XDISPLAY FRAME_X_WINDOW (f));
1108 851
1109 XFlushQueue (); 852 XFlushQueue ();
@@ -1285,6 +1028,19 @@ x_set_autolower (f, arg, oldval)
1285{ 1028{
1286 f->auto_lower = !EQ (Qnil, arg); 1029 f->auto_lower = !EQ (Qnil, arg);
1287} 1030}
1031
1032void
1033x_set_vertical_scrollbar (f, arg, oldval)
1034 struct frame *f;
1035 Lisp_Object arg, oldval;
1036{
1037 if (NILP (arg) != ! FRAME_HAS_VERTICAL_SCROLLBARS (f))
1038 {
1039 FRAME_HAS_VERTICAL_SCROLLBARS (f) = ! NILP (arg);
1040
1041 x_set_window_size (f, FRAME_WIDTH (f), FRAME_HEIGHT (f));
1042 }
1043}
1288 1044
1289#ifdef HAVE_X11 1045#ifdef HAVE_X11
1290int n_faces; 1046int n_faces;
@@ -1800,10 +1556,8 @@ x_figure_window_size (f, parms)
1800 else if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound)) 1556 else if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))
1801 error ("Must specify *both* height and width"); 1557 error ("Must specify *both* height and width");
1802 1558
1803 f->display.x->pixel_width = (FONT_WIDTH (f->display.x->font) * f->width 1559 f->display.x->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width);
1804 + 2 * f->display.x->internal_border_width); 1560 f->display.x->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height);
1805 f->display.x->pixel_height = (FONT_HEIGHT (f->display.x->font) * f->height
1806 + 2 * f->display.x->internal_border_width);
1807 1561
1808 tem0 = x_get_arg (parms, Qtop, 0, number); 1562 tem0 = x_get_arg (parms, Qtop, 0, number);
1809 tem1 = x_get_arg (parms, Qleft, 0, number); 1563 tem1 = x_get_arg (parms, Qleft, 0, number);
@@ -1883,6 +1637,15 @@ x_window (f)
1883 class_hints.res_class = EMACS_CLASS; 1637 class_hints.res_class = EMACS_CLASS;
1884 XSetClassHint (x_current_display, FRAME_X_WINDOW (f), &class_hints); 1638 XSetClassHint (x_current_display, FRAME_X_WINDOW (f), &class_hints);
1885 1639
1640 /* This indicates that we use the "Passive Input" input model.
1641 Unless we do this, we don't get the Focus{In,Out} events that we
1642 need to draw the cursor correctly. Accursed bureaucrats.
1643 XWhipsAndChains (x_current_display, IronMaiden, &TheRack); */
1644
1645 f->display.x->wm_hints.input = True;
1646 f->display.x->wm_hints.flags |= InputHint;
1647 XSetWMHints (x_current_display, FRAME_X_WINDOW (f), &f->display.x->wm_hints);
1648
1886 /* x_set_name normally ignores requests to set the name if the 1649 /* x_set_name normally ignores requests to set the name if the
1887 requested name is the same as the current name. This is the one 1650 requested name is the same as the current name. This is the one
1888 place where that assumption isn't correct; f->name is set, but 1651 place where that assumption isn't correct; f->name is set, but
@@ -2070,6 +1833,9 @@ be shared by the new frame.")
2070 else 1833 else
2071 f = make_frame (1); 1834 f = make_frame (1);
2072 1835
1836 /* Note that X Windows does support scrollbars. */
1837 FRAME_CAN_HAVE_SCROLLBARS (f) = 1;
1838
2073 /* Set the name; the functions to which we pass f expect the 1839 /* Set the name; the functions to which we pass f expect the
2074 name to be set. */ 1840 name to be set. */
2075 f->name = name; 1841 f->name = name;
@@ -2093,6 +1859,8 @@ be shared by the new frame.")
2093 /* This defaults to 2 in order to match XTerms. */ 1859 /* This defaults to 2 in order to match XTerms. */
2094 x_default_parameter (f, parms, Qinternal_border_width, 1860 x_default_parameter (f, parms, Qinternal_border_width,
2095 make_number (2), "InternalBorderWidth", number); 1861 make_number (2), "InternalBorderWidth", number);
1862 x_default_parameter (f, parms, Qvertical_scrollbar,
1863 Qt, "VerticalScrollbars", boolean);
2096 1864
2097 /* Also do the stuff which must be set before the window exists. */ 1865 /* Also do the stuff which must be set before the window exists. */
2098 x_default_parameter (f, parms, Qforeground_color, 1866 x_default_parameter (f, parms, Qforeground_color,
@@ -2104,22 +1872,6 @@ be shared by the new frame.")
2104 x_default_parameter (f, parms, Qborder_color, 1872 x_default_parameter (f, parms, Qborder_color,
2105 build_string ("black"), "border", string); 1873 build_string ("black"), "border", string);
2106 1874
2107 /* When XSetWMHints eventually gets called, this will indicate that
2108 we use the "Passive Input" input model. Unless we do this, we
2109 don't get the Focus{In,Out} events that we need to draw the
2110 cursor correctly. Accursed bureaucrats.
2111
2112 We set this here and leave it, because we know, being decidedly
2113 non-humble programmers (nay, weigh'd low by our hubris!), that
2114 Fx_create_frame calls x_icon which begat x_wm_set_window_state
2115 which begat XSetWMHints, which will get this information to the
2116 right parties. -JimB
2117
2118 XWhipsAndChains (x_current_display, IronMaiden, &TheRack); */
2119
2120 f->display.x->wm_hints.input = True;
2121 f->display.x->wm_hints.flags |= InputHint;
2122
2123 f->display.x->parent_desc = ROOT_WINDOW; 1875 f->display.x->parent_desc = ROOT_WINDOW;
2124 window_prompting = x_figure_window_size (f, parms); 1876 window_prompting = x_figure_window_size (f, parms);
2125 1877
@@ -2148,12 +1900,6 @@ be shared by the new frame.")
2148 tem = x_get_arg (parms, Qunsplittable, 0, boolean); 1900 tem = x_get_arg (parms, Qunsplittable, 0, boolean);
2149 f->no_split = minibuffer_only || EQ (tem, Qt); 1901 f->no_split = minibuffer_only || EQ (tem, Qt);
2150 1902
2151 /* Now handle the rest of the parameters. */
2152 x_default_parameter (f, parms, Qhorizontal_scroll_bar,
2153 Qnil, "HScrollBar", boolean);
2154 x_default_parameter (f, parms, Qvertical_scroll_bar,
2155 Qnil, "VScrollBar", boolean);
2156
2157 /* Make the window appear on the frame and enable display. */ 1903 /* Make the window appear on the frame and enable display. */
2158 if (!EQ (x_get_arg (parms, Qsuppress_initial_map, 0, boolean), Qt)) 1904 if (!EQ (x_get_arg (parms, Qsuppress_initial_map, 0, boolean), Qt))
2159 x_make_frame_visible (f); 1905 x_make_frame_visible (f);
@@ -2262,8 +2008,7 @@ be shared by the new frame.")
2262 / FONT_WIDTH (f->display.x->font); 2008 / FONT_WIDTH (f->display.x->font);
2263 f->display.x->left_pos = wininfo.x; 2009 f->display.x->left_pos = wininfo.x;
2264 f->display.x->top_pos = wininfo.y; 2010 f->display.x->top_pos = wininfo.y;
2265 f->async_visible = wininfo.mapped != 0; 2011 FRAME_SET_VISIBILITY (f, wininfo.mapped != 0);
2266 f->visible = f->async_visible;
2267 f->display.x->border_width = wininfo.bdrwidth; 2012 f->display.x->border_width = wininfo.bdrwidth;
2268 f->display.x->parent_desc = parent; 2013 f->display.x->parent_desc = parent;
2269 } 2014 }
@@ -2389,11 +2134,6 @@ be shared by the new frame.")
2389 2134
2390 Fmodify_frame_parameters (frame, parms); 2135 Fmodify_frame_parameters (frame, parms);
2391 2136
2392 if (!NILP (vscroll))
2393 install_vertical_scrollbar (f, pixelwidth, pixelheight);
2394 if (!NILP (hscroll))
2395 install_horizontal_scrollbar (f, pixelwidth, pixelheight);
2396
2397 /* Make the window appear on the frame and enable display. */ 2137 /* Make the window appear on the frame and enable display. */
2398 2138
2399 if (!EQ (x_get_arg (parms, Qsuppress_initial_map, 0, boolean), Qt)) 2139 if (!EQ (x_get_arg (parms, Qsuppress_initial_map, 0, boolean), Qt))
@@ -2514,549 +2254,6 @@ x_rubber_band (f, x, y, width, height, geo, str, hscroll, vscroll)
2514} 2254}
2515#endif /* not HAVE_X11 */ 2255#endif /* not HAVE_X11 */
2516 2256
2517/* Set whether frame F has a horizontal scroll bar.
2518 VAL is t or nil to specify it. */
2519
2520static void
2521x_set_horizontal_scrollbar (f, val, oldval)
2522 struct frame *f;
2523 Lisp_Object val, oldval;
2524{
2525 if (!NILP (val))
2526 {
2527 if (FRAME_X_WINDOW (f) != 0)
2528 {
2529 BLOCK_INPUT;
2530 f->display.x->h_scrollbar_height = HSCROLL_HEIGHT;
2531 x_set_window_size (f, f->width, f->height);
2532 install_horizontal_scrollbar (f);
2533 SET_FRAME_GARBAGED (f);
2534 UNBLOCK_INPUT;
2535 }
2536 }
2537 else
2538 if (f->display.x->h_scrollbar)
2539 {
2540 BLOCK_INPUT;
2541 f->display.x->h_scrollbar_height = 0;
2542 XDestroyWindow (XDISPLAY f->display.x->h_scrollbar);
2543 f->display.x->h_scrollbar = 0;
2544 x_set_window_size (f, f->width, f->height);
2545 f->garbaged++;
2546 frame_garbaged++;
2547 BLOCK_INPUT;
2548 }
2549}
2550
2551/* Set whether frame F has a vertical scroll bar.
2552 VAL is t or nil to specify it. */
2553
2554static void
2555x_set_vertical_scrollbar (f, val, oldval)
2556 struct frame *f;
2557 Lisp_Object val, oldval;
2558{
2559 if (!NILP (val))
2560 {
2561 if (FRAME_X_WINDOW (f) != 0)
2562 {
2563 BLOCK_INPUT;
2564 f->display.x->v_scrollbar_width = VSCROLL_WIDTH;
2565 x_set_window_size (f, f->width, f->height);
2566 install_vertical_scrollbar (f);
2567 SET_FRAME_GARBAGED (f);
2568 UNBLOCK_INPUT;
2569 }
2570 }
2571 else
2572 if (f->display.x->v_scrollbar != 0)
2573 {
2574 BLOCK_INPUT;
2575 f->display.x->v_scrollbar_width = 0;
2576 XDestroyWindow (XDISPLAY f->display.x->v_scrollbar);
2577 f->display.x->v_scrollbar = 0;
2578 x_set_window_size (f, f->width, f->height);
2579 SET_FRAME_GARBAGED (f);
2580 UNBLOCK_INPUT;
2581 }
2582}
2583
2584/* Create the X windows for a vertical scroll bar
2585 for a frame X that already has an X window but no scroll bar. */
2586
2587static void
2588install_vertical_scrollbar (f)
2589 struct frame *f;
2590{
2591 int ibw = f->display.x->internal_border_width;
2592 Window parent;
2593 XColor fore_color, back_color;
2594 Pixmap up_arrow_pixmap, down_arrow_pixmap, slider_pixmap;
2595 int pix_x, pix_y, width, height, border;
2596
2597 height = f->display.x->pixel_height - ibw - 2;
2598 width = VSCROLL_WIDTH - 2;
2599 pix_x = f->display.x->pixel_width - ibw/2;
2600 pix_y = ibw / 2;
2601 border = 1;
2602
2603#ifdef HAVE_X11
2604 up_arrow_pixmap =
2605 XCreatePixmapFromBitmapData (x_current_display, FRAME_X_WINDOW (f),
2606 up_arrow_bits, 16, 16,
2607 f->display.x->foreground_pixel,
2608 f->display.x->background_pixel,
2609 DefaultDepth (x_current_display,
2610 XDefaultScreen (x_current_display)));
2611
2612 down_arrow_pixmap =
2613 XCreatePixmapFromBitmapData (x_current_display, FRAME_X_WINDOW (f),
2614 down_arrow_bits, 16, 16,
2615 f->display.x->foreground_pixel,
2616 f->display.x->background_pixel,
2617 DefaultDepth (x_current_display,
2618 XDefaultScreen (x_current_display)));
2619
2620 slider_pixmap =
2621 XCreatePixmapFromBitmapData (x_current_display, FRAME_X_WINDOW (f),
2622 gray_bits, 16, 16,
2623 f->display.x->foreground_pixel,
2624 f->display.x->background_pixel,
2625 DefaultDepth (x_current_display,
2626 XDefaultScreen (x_current_display)));
2627
2628 /* These cursor shapes will be installed when the mouse enters
2629 the appropriate window. */
2630
2631 up_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_up_arrow);
2632 down_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_down_arrow);
2633 v_double_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_v_double_arrow);
2634
2635 f->display.x->v_scrollbar =
2636 XCreateSimpleWindow (x_current_display, FRAME_X_WINDOW (f),
2637 pix_x, pix_y, width, height, border,
2638 f->display.x->foreground_pixel,
2639 f->display.x->background_pixel);
2640 XFlush (x_current_display);
2641 XDefineCursor (x_current_display, f->display.x->v_scrollbar,
2642 v_double_arrow_cursor);
2643
2644 /* Create slider window */
2645 f->display.x->v_slider =
2646 XCreateSimpleWindow (x_current_display, f->display.x->v_scrollbar,
2647 0, VSCROLL_WIDTH - 2,
2648 VSCROLL_WIDTH - 4, VSCROLL_WIDTH - 4,
2649 1, f->display.x->border_pixel,
2650 f->display.x->foreground_pixel);
2651 XFlush (x_current_display);
2652 XDefineCursor (x_current_display, f->display.x->v_slider,
2653 v_double_arrow_cursor);
2654 XSetWindowBackgroundPixmap (x_current_display, f->display.x->v_slider,
2655 slider_pixmap);
2656
2657 f->display.x->v_thumbup =
2658 XCreateSimpleWindow (x_current_display, f->display.x->v_scrollbar,
2659 0, 0,
2660 VSCROLL_WIDTH - 2, VSCROLL_WIDTH - 2,
2661 0, f->display.x->foreground_pixel,
2662 f->display.x-> background_pixel);
2663 XFlush (x_current_display);
2664 XDefineCursor (x_current_display, f->display.x->v_thumbup,
2665 up_arrow_cursor);
2666 XSetWindowBackgroundPixmap (x_current_display, f->display.x->v_thumbup,
2667 up_arrow_pixmap);
2668
2669 f->display.x->v_thumbdown =
2670 XCreateSimpleWindow (x_current_display, f->display.x->v_scrollbar,
2671 0, height - VSCROLL_WIDTH + 2,
2672 VSCROLL_WIDTH - 2, VSCROLL_WIDTH - 2,
2673 0, f->display.x->foreground_pixel,
2674 f->display.x->background_pixel);
2675 XFlush (x_current_display);
2676 XDefineCursor (x_current_display, f->display.x->v_thumbdown,
2677 down_arrow_cursor);
2678 XSetWindowBackgroundPixmap (x_current_display, f->display.x->v_thumbdown,
2679 down_arrow_pixmap);
2680
2681 fore_color.pixel = f->display.x->mouse_pixel;
2682 back_color.pixel = f->display.x->background_pixel;
2683 XQueryColor (x_current_display,
2684 DefaultColormap (x_current_display,
2685 DefaultScreen (x_current_display)),
2686 &fore_color);
2687 XQueryColor (x_current_display,
2688 DefaultColormap (x_current_display,
2689 DefaultScreen (x_current_display)),
2690 &back_color);
2691 XRecolorCursor (x_current_display, up_arrow_cursor,
2692 &fore_color, &back_color);
2693 XRecolorCursor (x_current_display, down_arrow_cursor,
2694 &fore_color, &back_color);
2695 XRecolorCursor (x_current_display, v_double_arrow_cursor,
2696 &fore_color, &back_color);
2697
2698 XFreePixmap (x_current_display, slider_pixmap);
2699 XFreePixmap (x_current_display, up_arrow_pixmap);
2700 XFreePixmap (x_current_display, down_arrow_pixmap);
2701 XFlush (x_current_display);
2702
2703 XSelectInput (x_current_display, f->display.x->v_scrollbar,
2704 ButtonPressMask | ButtonReleaseMask
2705 | PointerMotionMask | PointerMotionHintMask
2706 | EnterWindowMask);
2707 XSelectInput (x_current_display, f->display.x->v_slider,
2708 ButtonPressMask | ButtonReleaseMask);
2709 XSelectInput (x_current_display, f->display.x->v_thumbdown,
2710 ButtonPressMask | ButtonReleaseMask);
2711 XSelectInput (x_current_display, f->display.x->v_thumbup,
2712 ButtonPressMask | ButtonReleaseMask);
2713 XFlush (x_current_display);
2714
2715 /* This should be done at the same time as the main window. */
2716 XMapWindow (x_current_display, f->display.x->v_scrollbar);
2717 XMapSubwindows (x_current_display, f->display.x->v_scrollbar);
2718 XFlush (x_current_display);
2719#else /* not HAVE_X11 */
2720 Bitmap b;
2721 Pixmap fore_tile, back_tile, bord_tile;
2722 static short up_arrow_bits[] = {
2723 0x0000, 0x0180, 0x03c0, 0x07e0,
2724 0x0ff0, 0x1ff8, 0x3ffc, 0x7ffe,
2725 0x0180, 0x0180, 0x0180, 0x0180,
2726 0x0180, 0x0180, 0x0180, 0xffff};
2727 static short down_arrow_bits[] = {
2728 0xffff, 0x0180, 0x0180, 0x0180,
2729 0x0180, 0x0180, 0x0180, 0x0180,
2730 0x7ffe, 0x3ffc, 0x1ff8, 0x0ff0,
2731 0x07e0, 0x03c0, 0x0180, 0x0000};
2732
2733 fore_tile = XMakeTile (f->display.x->foreground_pixel);
2734 back_tile = XMakeTile (f->display.x->background_pixel);
2735 bord_tile = XMakeTile (f->display.x->border_pixel);
2736
2737 b = XStoreBitmap (VSCROLL_WIDTH - 2, VSCROLL_WIDTH - 2, up_arrow_bits);
2738 up_arrow_pixmap = XMakePixmap (b,
2739 f->display.x->foreground_pixel,
2740 f->display.x->background_pixel);
2741 XFreeBitmap (b);
2742
2743 b = XStoreBitmap (VSCROLL_WIDTH - 2, VSCROLL_WIDTH - 2, down_arrow_bits);
2744 down_arrow_pixmap = XMakePixmap (b,
2745 f->display.x->foreground_pixel,
2746 f->display.x->background_pixel);
2747 XFreeBitmap (b);
2748
2749 ibw = f->display.x->internal_border_width;
2750
2751 f->display.x->v_scrollbar = XCreateWindow (FRAME_X_WINDOW (f),
2752 width - VSCROLL_WIDTH - ibw/2,
2753 ibw/2,
2754 VSCROLL_WIDTH - 2,
2755 height - ibw - 2,
2756 1, bord_tile, back_tile);
2757
2758 f->display.x->v_scrollbar_width = VSCROLL_WIDTH;
2759
2760 f->display.x->v_thumbup = XCreateWindow (f->display.x->v_scrollbar,
2761 0, 0,
2762 VSCROLL_WIDTH - 2,
2763 VSCROLL_WIDTH - 2,
2764 0, 0, up_arrow_pixmap);
2765 XTileAbsolute (f->display.x->v_thumbup);
2766
2767 f->display.x->v_thumbdown = XCreateWindow (f->display.x->v_scrollbar,
2768 0,
2769 height - ibw - VSCROLL_WIDTH,
2770 VSCROLL_WIDTH - 2,
2771 VSCROLL_WIDTH - 2,
2772 0, 0, down_arrow_pixmap);
2773 XTileAbsolute (f->display.x->v_thumbdown);
2774
2775 f->display.x->v_slider = XCreateWindow (f->display.x->v_scrollbar,
2776 0, VSCROLL_WIDTH - 2,
2777 VSCROLL_WIDTH - 4,
2778 VSCROLL_WIDTH - 4,
2779 1, back_tile, fore_tile);
2780
2781 XSelectInput (f->display.x->v_scrollbar,
2782 (ButtonPressed | ButtonReleased | KeyPressed));
2783 XSelectInput (f->display.x->v_thumbup,
2784 (ButtonPressed | ButtonReleased | KeyPressed));
2785
2786 XSelectInput (f->display.x->v_thumbdown,
2787 (ButtonPressed | ButtonReleased | KeyPressed));
2788
2789 XMapWindow (f->display.x->v_thumbup);
2790 XMapWindow (f->display.x->v_thumbdown);
2791 XMapWindow (f->display.x->v_slider);
2792 XMapWindow (f->display.x->v_scrollbar);
2793
2794 XFreePixmap (fore_tile);
2795 XFreePixmap (back_tile);
2796 XFreePixmap (up_arrow_pixmap);
2797 XFreePixmap (down_arrow_pixmap);
2798#endif /* not HAVE_X11 */
2799}
2800
2801static void
2802install_horizontal_scrollbar (f)
2803 struct frame *f;
2804{
2805 int ibw = f->display.x->internal_border_width;
2806 Window parent;
2807 Pixmap left_arrow_pixmap, right_arrow_pixmap, slider_pixmap;
2808 int pix_x, pix_y;
2809 int width;
2810
2811 pix_x = ibw;
2812 pix_y = PIXEL_HEIGHT (f) - HSCROLL_HEIGHT - ibw ;
2813 width = PIXEL_WIDTH (f) - 2 * ibw;
2814 if (f->display.x->v_scrollbar_width)
2815 width -= (f->display.x->v_scrollbar_width + 1);
2816
2817#ifdef HAVE_X11
2818 left_arrow_pixmap =
2819 XCreatePixmapFromBitmapData (x_current_display, FRAME_X_WINDOW (f),
2820 left_arrow_bits, 16, 16,
2821 f->display.x->foreground_pixel,
2822 f->display.x->background_pixel,
2823 DefaultDepth (x_current_display,
2824 XDefaultScreen (x_current_display)));
2825
2826 right_arrow_pixmap =
2827 XCreatePixmapFromBitmapData (x_current_display, FRAME_X_WINDOW (f),
2828 right_arrow_bits, 16, 16,
2829 f->display.x->foreground_pixel,
2830 f->display.x->background_pixel,
2831 DefaultDepth (x_current_display,
2832 XDefaultScreen (x_current_display)));
2833
2834 slider_pixmap =
2835 XCreatePixmapFromBitmapData (x_current_display, FRAME_X_WINDOW (f),
2836 gray_bits, 16, 16,
2837 f->display.x->foreground_pixel,
2838 f->display.x->background_pixel,
2839 DefaultDepth (x_current_display,
2840 XDefaultScreen (x_current_display)));
2841
2842 left_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_left_arrow);
2843 right_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_right_arrow);
2844 h_double_arrow_cursor = XCreateFontCursor (x_current_display, XC_sb_h_double_arrow);
2845
2846 f->display.x->h_scrollbar =
2847 XCreateSimpleWindow (x_current_display, FRAME_X_WINDOW (f),
2848 pix_x, pix_y,
2849 width - ibw - 2, HSCROLL_HEIGHT - 2, 1,
2850 f->display.x->foreground_pixel,
2851 f->display.x->background_pixel);
2852 XDefineCursor (x_current_display, f->display.x->h_scrollbar,
2853 h_double_arrow_cursor);
2854
2855 f->display.x->h_slider =
2856 XCreateSimpleWindow (x_current_display, f->display.x->h_scrollbar,
2857 0, 0,
2858 HSCROLL_HEIGHT - 4, HSCROLL_HEIGHT - 4,
2859 1, f->display.x->foreground_pixel,
2860 f->display.x->background_pixel);
2861 XDefineCursor (x_current_display, f->display.x->h_slider,
2862 h_double_arrow_cursor);
2863 XSetWindowBackgroundPixmap (x_current_display, f->display.x->h_slider,
2864 slider_pixmap);
2865
2866 f->display.x->h_thumbleft =
2867 XCreateSimpleWindow (x_current_display, f->display.x->h_scrollbar,
2868 0, 0,
2869 HSCROLL_HEIGHT - 2, HSCROLL_HEIGHT - 2,
2870 0, f->display.x->foreground_pixel,
2871 f->display.x->background_pixel);
2872 XDefineCursor (x_current_display, f->display.x->h_thumbleft,
2873 left_arrow_cursor);
2874 XSetWindowBackgroundPixmap (x_current_display, f->display.x->h_thumbleft,
2875 left_arrow_pixmap);
2876
2877 f->display.x->h_thumbright =
2878 XCreateSimpleWindow (x_current_display, f->display.x->h_scrollbar,
2879 width - ibw - HSCROLL_HEIGHT, 0,
2880 HSCROLL_HEIGHT - 2, HSCROLL_HEIGHT -2,
2881 0, f->display.x->foreground_pixel,
2882 f->display.x->background_pixel);
2883 XDefineCursor (x_current_display, f->display.x->h_thumbright,
2884 right_arrow_cursor);
2885 XSetWindowBackgroundPixmap (x_current_display, f->display.x->h_thumbright,
2886 right_arrow_pixmap);
2887
2888 XFreePixmap (x_current_display, slider_pixmap);
2889 XFreePixmap (x_current_display, left_arrow_pixmap);
2890 XFreePixmap (x_current_display, right_arrow_pixmap);
2891
2892 XSelectInput (x_current_display, f->display.x->h_scrollbar,
2893 ButtonPressMask | ButtonReleaseMask
2894 | PointerMotionMask | PointerMotionHintMask
2895 | EnterWindowMask);
2896 XSelectInput (x_current_display, f->display.x->h_slider,
2897 ButtonPressMask | ButtonReleaseMask);
2898 XSelectInput (x_current_display, f->display.x->h_thumbright,
2899 ButtonPressMask | ButtonReleaseMask);
2900 XSelectInput (x_current_display, f->display.x->h_thumbleft,
2901 ButtonPressMask | ButtonReleaseMask);
2902
2903 XMapWindow (x_current_display, f->display.x->h_scrollbar);
2904 XMapSubwindows (x_current_display, f->display.x->h_scrollbar);
2905#else /* not HAVE_X11 */
2906 Bitmap b;
2907 Pixmap fore_tile, back_tile, bord_tile;
2908#endif
2909}
2910
2911#ifndef HAVE_X11 /* X10 */
2912#define XMoveResizeWindow XConfigureWindow
2913#endif /* not HAVE_X11 */
2914
2915/* Adjust the displayed position in the scroll bar for window W. */
2916
2917void
2918adjust_scrollbars (f)
2919 struct frame *f;
2920{
2921 int pos;
2922 int first_char_in_window, char_beyond_window, chars_in_window;
2923 int chars_in_buffer, buffer_size;
2924 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
2925
2926 if (! FRAME_X_P (f))
2927 return;
2928
2929 if (f->display.x->v_scrollbar != 0)
2930 {
2931 int h, height;
2932 struct buffer *b = XBUFFER (w->buffer);
2933
2934 buffer_size = Z - BEG;
2935 chars_in_buffer = ZV - BEGV;
2936 first_char_in_window = marker_position (w->start);
2937 char_beyond_window = buffer_size + 1 - XFASTINT (w->window_end_pos);
2938 chars_in_window = char_beyond_window - first_char_in_window;
2939
2940 /* Calculate height of scrollbar area */
2941
2942 height = f->height * FONT_HEIGHT (f->display.x->font)
2943 + f->display.x->internal_border_width
2944 - 2 * (f->display.x->v_scrollbar_width);
2945
2946 /* Figure starting position for the scrollbar slider */
2947
2948 if (chars_in_buffer <= 0)
2949 pos = 0;
2950 else
2951 pos = ((first_char_in_window - BEGV - BEG) * height
2952 / chars_in_buffer);
2953 pos = max (0, pos);
2954 pos = min (pos, height - 2);
2955
2956 /* Figure length of the slider */
2957
2958 if (chars_in_buffer <= 0)
2959 h = height;
2960 else
2961 h = (chars_in_window * height) / chars_in_buffer;
2962 h = min (h, height - pos);
2963 h = max (h, 1);
2964
2965 /* Add thumbup offset to starting position of slider */
2966
2967 pos += (f->display.x->v_scrollbar_width - 2);
2968
2969 XMoveResizeWindow (XDISPLAY
2970 f->display.x->v_slider,
2971 0, pos,
2972 f->display.x->v_scrollbar_width - 4, h);
2973 }
2974
2975 if (f->display.x->h_scrollbar != 0)
2976 {
2977 int l, length; /* Length of the scrollbar area */
2978
2979 length = f->width * FONT_WIDTH (f->display.x->font)
2980 + f->display.x->internal_border_width
2981 - 2 * (f->display.x->h_scrollbar_height);
2982
2983 /* Starting position for horizontal slider */
2984 if (! XINT (w->hscroll))
2985 pos = 0;
2986 else
2987 pos = (XINT (w->hscroll) * length) / (XINT (w->hscroll) + f->width);
2988 pos = max (0, pos);
2989 pos = min (pos, length - 2);
2990
2991 /* Length of slider */
2992 l = length - pos;
2993
2994 /* Add thumbup offset */
2995 pos += (f->display.x->h_scrollbar_height - 2);
2996
2997 XMoveResizeWindow (XDISPLAY
2998 f->display.x->h_slider,
2999 pos, 0,
3000 l, f->display.x->h_scrollbar_height - 4);
3001 }
3002}
3003
3004/* Adjust the size of the scroll bars of frame F,
3005 when the frame size has changed. */
3006
3007void
3008x_resize_scrollbars (f)
3009 struct frame *f;
3010{
3011 int ibw = f->display.x->internal_border_width;
3012 int pixelwidth, pixelheight;
3013
3014 if (f == 0
3015 || f->display.x == 0
3016 || (f->display.x->v_scrollbar == 0
3017 && f->display.x->h_scrollbar == 0))
3018 return;
3019
3020 /* Get the size of the frame. */
3021 pixelwidth = (f->width * FONT_WIDTH (f->display.x->font)
3022 + 2 * ibw + f->display.x->v_scrollbar_width);
3023 pixelheight = (f->height * FONT_HEIGHT (f->display.x->font)
3024 + 2 * ibw + f->display.x->h_scrollbar_height);
3025
3026 if (f->display.x->v_scrollbar_width && f->display.x->v_scrollbar)
3027 {
3028 BLOCK_INPUT;
3029 XMoveResizeWindow (XDISPLAY
3030 f->display.x->v_scrollbar,
3031 pixelwidth - f->display.x->v_scrollbar_width - ibw/2,
3032 ibw/2,
3033 f->display.x->v_scrollbar_width - 2,
3034 pixelheight - ibw - 2);
3035 XMoveWindow (XDISPLAY
3036 f->display.x->v_thumbdown, 0,
3037 pixelheight - ibw - f->display.x->v_scrollbar_width);
3038 UNBLOCK_INPUT;
3039 }
3040
3041 if (f->display.x->h_scrollbar_height && f->display.x->h_scrollbar)
3042 {
3043 if (f->display.x->v_scrollbar_width)
3044 pixelwidth -= f->display.x->v_scrollbar_width + 1;
3045
3046 BLOCK_INPUT;
3047 XMoveResizeWindow (XDISPLAY
3048 f->display.x->h_scrollbar,
3049 ibw / 2,
3050 pixelheight - f->display.x->h_scrollbar_height - ibw / 2,
3051 pixelwidth - ibw - 2,
3052 f->display.x->h_scrollbar_height - 2);
3053 XMoveWindow (XDISPLAY
3054 f->display.x->h_thumbright,
3055 pixelwidth - ibw - f->display.x->h_scrollbar_height, 0);
3056 UNBLOCK_INPUT;
3057 }
3058}
3059
3060x_pixel_width (f) 2257x_pixel_width (f)
3061 register struct frame *f; 2258 register struct frame *f;
3062{ 2259{
@@ -4560,8 +3757,6 @@ syms_of_xfns ()
4560 staticpro (&Qforeground_color); 3757 staticpro (&Qforeground_color);
4561 Qgeometry = intern ("geometry"); 3758 Qgeometry = intern ("geometry");
4562 staticpro (&Qgeometry); 3759 staticpro (&Qgeometry);
4563 Qhorizontal_scroll_bar = intern ("horizontal-scroll-bar");
4564 staticpro (&Qhorizontal_scroll_bar);
4565 Qicon_left = intern ("icon-left"); 3760 Qicon_left = intern ("icon-left");
4566 staticpro (&Qicon_left); 3761 staticpro (&Qicon_left);
4567 Qicon_top = intern ("icon-top"); 3762 Qicon_top = intern ("icon-top");
@@ -4586,8 +3781,6 @@ syms_of_xfns ()
4586 staticpro (&Qtop); 3781 staticpro (&Qtop);
4587 Qundefined_color = intern ("undefined-color"); 3782 Qundefined_color = intern ("undefined-color");
4588 staticpro (&Qundefined_color); 3783 staticpro (&Qundefined_color);
4589 Qvertical_scroll_bar = intern ("vertical-scroll-bar");
4590 staticpro (&Qvertical_scroll_bar);
4591 Qwindow_id = intern ("window-id"); 3784 Qwindow_id = intern ("window-id");
4592 staticpro (&Qwindow_id); 3785 staticpro (&Qwindow_id);
4593 Qx_frame_parameter = intern ("x-frame-parameter"); 3786 Qx_frame_parameter = intern ("x-frame-parameter");
@@ -4601,14 +3794,6 @@ syms_of_xfns ()
4601 3794
4602 init_x_parm_symbols (); 3795 init_x_parm_symbols ();
4603 3796
4604 DEFVAR_INT ("mouse-x-position", &x_mouse_x,
4605 "The X coordinate of the mouse position, in characters.");
4606 x_mouse_x = 0;
4607
4608 DEFVAR_INT ("mouse-y-position", &x_mouse_y,
4609 "The Y coordinate of the mouse position, in characters.");
4610 x_mouse_y = 0;
4611
4612 DEFVAR_INT ("mouse-buffer-offset", &mouse_buffer_offset, 3797 DEFVAR_INT ("mouse-buffer-offset", &mouse_buffer_offset,
4613 "The buffer offset of the character under the pointer."); 3798 "The buffer offset of the character under the pointer.");
4614 mouse_buffer_offset = 0; 3799 mouse_buffer_offset = 0;