]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix scroll bar handling for non-toolkit builds.
authorMartin Rudalics <rudalics@gmx.at>
Mon, 4 Aug 2014 16:47:27 +0000 (18:47 +0200)
committerMartin Rudalics <rudalics@gmx.at>
Mon, 4 Aug 2014 16:47:27 +0000 (18:47 +0200)
* frame.h (FRAME_HAS_HORIZONTAL_SCROLL_BARS): Condition
correctly according to toolkit used.
* frame.c (make_initial_frame, make_terminal_frame)
(x_set_horizontal_scroll_bars, x_set_scroll_bar_height)
(Vdefault_frame_horizontal_scroll_bars): Correctly condition
assignments according to presence of toolkit scrollbars.
* window.h (WINDOW_HAS_HORIZONTAL_SCROLL_BAR): Condition
correctly according to toolkit used.
* window.c (set_window_scroll_bars): Set horizontal scroll bar
only if toolkit supports it.
* w32term.c (w32_redeem_scroll_bar): Always redeem scroll bar if
present.
* xterm.c (x_scroll_bar_create): Initialize horizontal slot for
non-toolkit builds.
(XTredeem_scroll_bar): Always redeem scroll bar if present.

src/ChangeLog
src/frame.c
src/frame.h
src/w32term.c
src/window.c
src/window.h
src/xterm.c

index ab0ba1b67583ff411c1e8dadab8ed9ddfc85bdb1..e936863ce1d0e52a86336ceeb30a01a7c1f95819 100644 (file)
@@ -1,3 +1,21 @@
+2014-08-04  Martin Rudalics  <rudalics@gmx.at>
+
+       * frame.h (FRAME_HAS_HORIZONTAL_SCROLL_BARS): Condition
+       correctly according to toolkit used.
+       * frame.c (make_initial_frame, make_terminal_frame)
+       (x_set_horizontal_scroll_bars, x_set_scroll_bar_height)
+       (Vdefault_frame_horizontal_scroll_bars): Correctly condition
+       assignments according to presence of toolkit scrollbars.
+       * window.h (WINDOW_HAS_HORIZONTAL_SCROLL_BAR): Condition
+       correctly according to toolkit used.
+       * window.c (set_window_scroll_bars): Set horizontal scroll bar
+       only if toolkit supports it.
+       * w32term.c (w32_redeem_scroll_bar): Always redeem scroll bar if
+       present.
+       * xterm.c (x_scroll_bar_create): Initialize horizontal slot for
+       non-toolkit builds.
+       (XTredeem_scroll_bar): Always redeem scroll bar if present.
+
 2014-08-04 Dmitry Antipov  <dmantipov@yandex.ru>
 
        * keyboard.c (safe_run_hook_funcall): Avoid consing around
index 457024f3ca23b027fcad2799bbad6ae69ec33cb6..c72b474512fd399fd637c963c67ef65627e611a0 100644 (file)
@@ -860,7 +860,7 @@ make_initial_frame (void)
 
 #ifdef HAVE_WINDOW_SYSTEM
   f->vertical_scroll_bar_type = vertical_scroll_bar_none;
-  FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) = false;
+  f->horizontal_scroll_bars = false;
 #endif
 
   /* The default value of menu-bar-mode is t.  */
@@ -913,7 +913,7 @@ make_terminal_frame (struct terminal *terminal)
 
 #ifdef HAVE_WINDOW_SYSTEM
   f->vertical_scroll_bar_type = vertical_scroll_bar_none;
-  FRAME_HAS_HORIZONTAL_SCROLL_BARS (f) = false;
+  f->horizontal_scroll_bars = false;
 #endif
 
   FRAME_MENU_BAR_LINES (f) = NILP (Vmenu_bar_mode) ? 0 : 1;
@@ -3793,12 +3793,13 @@ x_set_vertical_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval
 void
 x_set_horizontal_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
-#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI)
+#if (defined (HAVE_WINDOW_SYSTEM)                                      \
+     && ((defined (USE_TOOLKIT_SCROLL_BARS) && !defined (HAVE_NS))     \
+        || defined (HAVE_NTGUI)))
   if ((NILP (arg) && FRAME_HAS_HORIZONTAL_SCROLL_BARS (f))
       || (!NILP (arg) && !FRAME_HAS_HORIZONTAL_SCROLL_BARS (f)))
     {
-      FRAME_HAS_HORIZONTAL_SCROLL_BARS (f)
-       = NILP (arg) ? false : true;
+      f->horizontal_scroll_bars = NILP (arg) ? false : true;
 
       /* We set this parameter before creating the X window for the
         frame, so we can get the geometry right from the start.
@@ -3844,7 +3845,9 @@ x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 void
 x_set_scroll_bar_height (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
-#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI)
+#if (defined (HAVE_WINDOW_SYSTEM)                                      \
+     && ((defined (USE_TOOLKIT_SCROLL_BARS) && !defined (HAVE_NS))     \
+        || defined (HAVE_NTGUI)))
   int unit = FRAME_LINE_HEIGHT (f);
 
   if (NILP (arg))
@@ -4891,7 +4894,9 @@ Setting this variable does not affect existing frames, only new ones.  */);
 
   DEFVAR_LISP ("default-frame-horizontal-scroll-bars", Vdefault_frame_horizontal_scroll_bars,
               doc: /* Default value for horizontal scroll bars on this window-system.  */);
-#ifdef HAVE_WINDOW_SYSTEM
+#if (defined (HAVE_WINDOW_SYSTEM)                                      \
+     && ((defined (USE_TOOLKIT_SCROLL_BARS) && !defined (HAVE_NS))     \
+        || defined (HAVE_NTGUI)))
   Vdefault_frame_horizontal_scroll_bars = Qt;
 #else
   Vdefault_frame_horizontal_scroll_bars = Qnil;
index 5d45dbfb2684c42301490d7d29647239d49b996e..0f34770d9b43f688693084939e4be64fe63d0f9f 100644 (file)
@@ -852,8 +852,6 @@ default_pixels_per_inch_y (void)
 #define FRAME_VERTICAL_SCROLL_BAR_TYPE(f) ((f)->vertical_scroll_bar_type)
 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) \
   ((f)->vertical_scroll_bar_type != vertical_scroll_bar_none)
-#define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) \
-  ((f)->horizontal_scroll_bars)
 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) \
   ((f)->vertical_scroll_bar_type == vertical_scroll_bar_left)
 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) \
@@ -866,10 +864,19 @@ default_pixels_per_inch_y (void)
 #define FRAME_HAS_VERTICAL_SCROLL_BARS(f) ((void) f, 0)
 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT(f) ((void) f, 0)
 #define FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT(f) ((void) f, 0)
-#define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) ((void) f, 0)
 
 #endif /* HAVE_WINDOW_SYSTEM */
 
+/* Whether horizontal scroll bars are currently enabled for frame F.  */
+#if (defined (HAVE_WINDOW_SYSTEM)                                      \
+     && ((defined (USE_TOOLKIT_SCROLL_BARS) && !defined (HAVE_NS))     \
+        || defined (HAVE_NTGUI)))
+#define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) \
+  ((f)->horizontal_scroll_bars)
+#else
+#define FRAME_HAS_HORIZONTAL_SCROLL_BARS(f) ((void) f, 0)
+#endif
+
 /* Width that a scroll bar in frame F should have, if there is one.
    Measured in pixels.
    If scroll bars are turned off, this is still nonzero.  */
index dfda29fb903993fff5f4beacfa98ef0a167e8fbc..0ded4398949a2df67e960c824a7d86f719bcf987 100644 (file)
@@ -4041,7 +4041,7 @@ w32_redeem_scroll_bar (struct window *w)
   if (NILP (w->vertical_scroll_bar) && NILP (w->horizontal_scroll_bar))
     emacs_abort ();
 
-  if (!NILP (w->vertical_scroll_bar) && WINDOW_HAS_VERTICAL_SCROLL_BAR (w))
+  if (!NILP (w->vertical_scroll_bar))
     {
       bar = XSCROLL_BAR (w->vertical_scroll_bar);
       /* Unlink it from the condemned list.  */
@@ -4076,7 +4076,7 @@ w32_redeem_scroll_bar (struct window *w)
     }
 
  horizontal:
-  if (!NILP (w->horizontal_scroll_bar) && WINDOW_HAS_HORIZONTAL_SCROLL_BAR (w))
+  if (!NILP (w->horizontal_scroll_bar))
     {
       bar = XSCROLL_BAR (w->horizontal_scroll_bar);
       /* Unlink it from the condemned list.  */
index e3554ea032e9bfc14b409d0bb1d630473223d38e..049c0d122a385919185ed3712c6fa2cead519cc3 100644 (file)
@@ -7299,7 +7299,6 @@ set_window_scroll_bars (struct window *w, Lisp_Object width,
                        Lisp_Object horizontal_type)
 {
   int iwidth = (NILP (width) ? -1 : (CHECK_NATNUM (width), XINT (width)));
-  int iheight = (NILP (height) ? -1 : (CHECK_NATNUM (height), XINT (height)));
   bool changed = 0;
 
   if (iwidth == 0)
@@ -7327,29 +7326,39 @@ set_window_scroll_bars (struct window *w, Lisp_Object width,
        }
     }
 
-  if (MINI_WINDOW_P (w) || iheight == 0)
-    horizontal_type = Qnil;
+#if (defined (HAVE_WINDOW_SYSTEM)                                      \
+     && ((defined (USE_TOOLKIT_SCROLL_BARS) && !defined (HAVE_NS))     \
+        || defined (HAVE_NTGUI)))
+  {
+    int iheight = (NILP (height) ? -1 : (CHECK_NATNUM (height), XINT (height)));
 
-  if (!(NILP (horizontal_type)
-       || EQ (horizontal_type, Qbottom)
-       || EQ (horizontal_type, Qt)))
-    error ("Invalid type of horizontal scroll bar");
+    if (MINI_WINDOW_P (w) || iheight == 0)
+      horizontal_type = Qnil;
 
-  if (w->scroll_bar_height != iheight
-      || !EQ (w->horizontal_scroll_bar_type, horizontal_type))
-    {
-      /* Don't change anything if new scroll bar won't fit.  */
-      if ((WINDOW_PIXEL_HEIGHT (w)
-          - WINDOW_HEADER_LINE_HEIGHT (w)
-          - WINDOW_MODE_LINE_HEIGHT (w)
-          - max (iheight, 0))
-         >= MIN_SAFE_WINDOW_PIXEL_HEIGHT (w))
-       {
-         w->scroll_bar_height = iheight;
-         wset_horizontal_scroll_bar_type (w, horizontal_type);
-         changed = 1;
-       }
-    }
+    if (!(NILP (horizontal_type)
+         || EQ (horizontal_type, Qbottom)
+         || EQ (horizontal_type, Qt)))
+      error ("Invalid type of horizontal scroll bar");
+
+    if (w->scroll_bar_height != iheight
+       || !EQ (w->horizontal_scroll_bar_type, horizontal_type))
+      {
+       /* Don't change anything if new scroll bar won't fit.  */
+       if ((WINDOW_PIXEL_HEIGHT (w)
+            - WINDOW_HEADER_LINE_HEIGHT (w)
+            - WINDOW_MODE_LINE_HEIGHT (w)
+            - max (iheight, 0))
+           >= MIN_SAFE_WINDOW_PIXEL_HEIGHT (w))
+         {
+           w->scroll_bar_height = iheight;
+           wset_horizontal_scroll_bar_type (w, horizontal_type);
+           changed = 1;
+         }
+      }
+  }
+#else
+  wset_horizontal_scroll_bar_type (w, Qnil);
+#endif
 
   return changed ? w : NULL;
 }
index cdf8da931380004c05ff6c7b4b05f697788119cd..7e1c7d619b94ea945e4d9ca83b56fbb8c2aa1713 100644 (file)
@@ -787,7 +787,9 @@ wset_next_buffers (struct window *w, Lisp_Object val)
 
 /* Say whether horizontal scroll bars are currently enabled for window
    W.  Horizontal scrollbars exist for toolkit versions only.  */
-#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI)
+#if (defined (HAVE_WINDOW_SYSTEM)                                      \
+     && ((defined (USE_TOOLKIT_SCROLL_BARS) && !defined (HAVE_NS))     \
+        || defined (HAVE_NTGUI)))
 #define WINDOW_HAS_HORIZONTAL_SCROLL_BAR(W)                    \
   ((WINDOW_PSEUDO_P (W) || MINI_NON_ONLY_WINDOW_P (W))         \
    ? false                                                     \
index 4fa4b7ab02b6040cf8a841057897184ff606238c..b106c51c01c80a29e7bcfa293c6c768590e02213 100644 (file)
@@ -5474,6 +5474,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height,
   bar->start = 0;
   bar->end = 0;
   bar->dragging = -1;
+  bar->horizontal = horizontal;
 #if defined (USE_TOOLKIT_SCROLL_BARS) && defined (USE_LUCID)
   bar->last_seen_part = scroll_bar_nowhere;
 #endif
@@ -5947,7 +5948,7 @@ XTredeem_scroll_bar (struct window *w)
   if (NILP (w->vertical_scroll_bar) && NILP (w->horizontal_scroll_bar))
     emacs_abort ();
 
-  if (!NILP (w->vertical_scroll_bar) && WINDOW_HAS_VERTICAL_SCROLL_BAR (w))
+  if (!NILP (w->vertical_scroll_bar))
     {
       bar = XSCROLL_BAR (w->vertical_scroll_bar);
       /* Unlink it from the condemned list.  */
@@ -5982,7 +5983,7 @@ XTredeem_scroll_bar (struct window *w)
     }
 
  horizontal:
-  if (!NILP (w->horizontal_scroll_bar) && WINDOW_HAS_HORIZONTAL_SCROLL_BAR (w))
+  if (!NILP (w->horizontal_scroll_bar))
     {
       bar = XSCROLL_BAR (w->horizontal_scroll_bar);
       /* Unlink it from the condemned list.  */