changeset 1783:8e7932110418

* window.c (window_internal_width): New function, which accounts for scrollbars if present. * lisp.h (window_internal_height, window_internal_width): Add extern declarations for these. * dispnew.c (direct_output_for_insert, direct_output_forward_char, buffer_posn_from_coords): Use window_internal_width instead of writing out its definition. * indent.c (compute_motion): Doc fix; mention scrollbars and window_internal_width. (pos_tab_offset, Fvertical_motion): Use window_internal_width instead of writing it out. * window.c (Fpos_visible_in_window_p, Fwindow_width, Fscroll_left, Fscroll_right): Same. * xdisp.c (redisplay, try_window, try_window_id, display_text_line): Same. * termhooks.h (mouse_position_hook): Doc fix. (set_vertical_scrollbar_hook): This doesn't return anything any more, and doesn't take a struct scrollbar * argument any more. (condemn_scrollbars_hook, redeem_scrollbar_hook, judge_scrollbars_hook): Doc fixes. * term.c (mouse_position_hook): Doc fix. (set_vertical_scrollbar_hook): This doesn't return anything any more. Doc fixes. * keyboard.c (kbd_buffer_get_event): Receive the scrollbar's window from *mouse_position_hook and pass it to make_lispy_movement, instead of working with a pointer to a struct scrollbar. (make_lispy_event): We don't need a window_from_scrollbar function anymore; we are given the window directly in *EVENT. Unify the code which generates text-area mouse clicks and scrollbar clicks; use the same code to distinguish clicks from drags on the scrollbar as in the text area. Distinguish clicks from drags by storing a copy of the lispy position list returned as part of the event. (button_down_location): Make this a lisp vector, rather than an array of random structures. (struct mouse_position): Remove this; it's been replaced by a lisp list. (make_lispy_movement): Accept the scrollbar's window as a parameter, rather than the scrollbar itself. If FRAME is zero, assume that the other arguments are garbage. (syms_of_keyboard): No need to staticpro each window of button_down_location now; just initialize and staticpro it. * window.c (window_from_scrollbar): Function deleted; no longer needed. * xdisp.c (redisplay_window): Just pass the window to set_vertical_scrollbar hook; don't pass the scrollbar object too. * xterm.c (XTmouse_position): Don't return a pointer to the scrollbar for scrollbar motion; instead, return the scrollbar's window.
author Jim Blandy <jimb@redhat.com>
date Thu, 14 Jan 1993 15:17:11 +0000
parents 5d58b9f1ff22
children 11f62e53acff
files src/window.c
diffstat 1 files changed, 37 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/window.c	Thu Jan 14 15:15:15 1993 +0000
+++ b/src/window.c	Thu Jan 14 15:17:11 1993 +0000
@@ -1,6 +1,6 @@
 /* Window creation, deletion and examination for GNU Emacs.
    Does not include redisplay.
-   Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -225,9 +225,7 @@
 
       /* If that info is not correct, calculate afresh */
       posval = *compute_motion (top, 0, 0, posint, height, 0,
-				XFASTINT (w->width) - 1
-				- (XFASTINT (w->width) + XFASTINT (w->left)
-				   != FRAME_WIDTH (XFRAME (w->frame))),
+				window_internal_width (w) - 1,
 				XINT (w->hscroll), 0);
 
       return posval.vpos < height ? Qt : Qnil;
@@ -269,11 +267,7 @@
   register struct window *w = decode_window (window);
   register int width = XFASTINT (w->width);
 
-  /* If this window does not end at the right margin,
-     must deduct one column for the border */
-  if ((width + XFASTINT (w->left)) == FRAME_WIDTH (XFRAME (WINDOW_FRAME (w))))
-    return make_number (width);
-  return make_number (width - 1);
+  return make_number (window_internal_width (w));
 }
 
 DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0,
@@ -432,34 +426,6 @@
   return Qnil;
 }
 
-/* Find the window containing the scrollbar BAR on FRAME.  We need to
-   search for scrollbars, rather than just having a field in the
-   scrollbar saying what window it's attached to, because scrollbars
-   may be deallocated before the events which occurred on them are
-   dequeued.  We can't dereference a scrollbar pointer until we know
-   it's live by finding it in a window structure.  */
-
-Lisp_Object
-window_from_scrollbar (frame, bar)
-     FRAME_PTR frame;
-     struct scrollbar *bar;
-{
-  register Lisp_Object tem, first;
-
-  tem = first = FRAME_SELECTED_WINDOW (frame);
-
-  do
-    {
-      if (WINDOW_VERTICAL_SCROLLBAR (XWINDOW (tem)) == bar)
-	return tem;
-
-      tem = Fnext_window (tem, Qt, Qlambda);
-    }
-  while (! EQ (tem, first));
-  
-  return Qnil;
-}
-
 DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0,
   "Return window containing row ROW, column COLUMN on FRAME.\n\
 If omitted, FRAME defaults to the currently selected frame.\n\
@@ -1676,9 +1642,8 @@
 
       if (!NILP (window)
 	  && window_height (window) >= split_height_threshold
-	  &&
-	  (XFASTINT (XWINDOW (window)->width)
-	   == FRAME_WIDTH (XFRAME (WINDOW_FRAME (XWINDOW (window))))))
+	  && (XFASTINT (XWINDOW (window)->width)
+	      == FRAME_WIDTH (XFRAME (WINDOW_FRAME (XWINDOW (window))))))
 	window = Fsplit_window (window, Qnil, Qnil);
       else
 	{
@@ -2055,6 +2020,36 @@
   return ht;
 }
 
+
+/* Return the number of columns in W.
+   Don't count columns occupied by scrollbars or the vertical bar
+   separating W from the sibling to its right.  */
+int
+window_internal_width (w)
+     struct window *w;
+{
+  FRAME_PTR f = XFRAME (WINDOW_FRAME (w));
+  int left = XINT (w->left);
+  int width = XINT (w->width);
+
+  /* If this window is flush against the right edge of the frame, its
+     internal width is its full width.  */
+  if (left + width >= FRAME_WIDTH (f))
+    return width;
+
+  /* If we are not flush right, then our rightmost columns are
+     occupied by some sort of separator.  */
+
+  /* Scrollbars occupy a few columns.  */
+  if (FRAME_HAS_VERTICAL_SCROLLBARS (f))
+    return width - VERTICAL_SCROLLBAR_WIDTH;
+
+  /* The column of `|' characters separating side-by-side windows
+     occupies one column only.  */
+  return width - 1;
+}
+
+
 /* Scroll contents of window WINDOW up N lines.  */
 
 void
@@ -2252,7 +2247,7 @@
 {
 
   if (NILP (arg))
-    XFASTINT (arg) = XFASTINT (XWINDOW (selected_window)->width) - 2;
+    XFASTINT (arg) = window_internal_width (selected_window) - 2;
   else
     arg = Fprefix_numeric_value (arg);
 
@@ -2269,7 +2264,7 @@
      register Lisp_Object arg;
 {
   if (NILP (arg))
-    XFASTINT (arg) = XFASTINT (XWINDOW (selected_window)->width) - 2;
+    XFASTINT (arg) = window_internal_width (selected_window) - 2;
   else
     arg = Fprefix_numeric_value (arg);