From 4a75c94d14f7a3c50014d1cc12ee519eb955c1ed Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Mon, 4 Aug 2014 18:47:27 +0200 Subject: [PATCH] Fix scroll bar handling for non-toolkit builds. * 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 | 18 ++++++++++++++++++ src/frame.c | 19 ++++++++++++------- src/frame.h | 13 ++++++++++--- src/w32term.c | 4 ++-- src/window.c | 53 +++++++++++++++++++++++++++++++---------------------- src/window.h | 4 +++- src/xterm.c | 5 +++-- 7 files changed, 79 insertions(+), 37 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index ab0ba1b6758..e936863ce1d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,21 @@ +2014-08-04 Martin Rudalics + + * 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 * keyboard.c (safe_run_hook_funcall): Avoid consing around diff --git a/src/frame.c b/src/frame.c index 457024f3ca2..c72b474512f 100644 --- a/src/frame.c +++ b/src/frame.c @@ -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; diff --git a/src/frame.h b/src/frame.h index 5d45dbfb268..0f34770d9b4 100644 --- a/src/frame.h +++ b/src/frame.h @@ -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. */ diff --git a/src/w32term.c b/src/w32term.c index dfda29fb903..0ded4398949 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -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. */ diff --git a/src/window.c b/src/window.c index e3554ea032e..049c0d122a3 100644 --- a/src/window.c +++ b/src/window.c @@ -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; } diff --git a/src/window.h b/src/window.h index cdf8da93138..7e1c7d619b9 100644 --- a/src/window.h +++ b/src/window.h @@ -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 \ diff --git a/src/xterm.c b/src/xterm.c index 4fa4b7ab02b..b106c51c01c 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -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. */ -- 2.11.4.GIT