Commit 4a75c94d authored by Martin Rudalics's avatar Martin Rudalics

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.
parent 44a651f0
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
......
......@@ -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;
......
......@@ -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. */
......
......@@ -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. */
......
......@@ -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;
}
......
......@@ -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 \
......
......@@ -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. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment