summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Rudalics <rudalics@gmx.at>2014-01-02 16:58:48 +0100
committerMartin Rudalics <rudalics@gmx.at>2014-01-02 16:58:48 +0100
commit44c5e192bebd669e687423145cb4949567f64314 (patch)
tree87e71c3367932103e9921e385c24d22853d0e623
parentc4377e925acc4d9beabc516501e2eef0400197de (diff)
downloademacs-44c5e192bebd669e687423145cb4949567f64314.tar.gz
Further adjust frame/window scrollbar width calculations.
* window.c (apply_window_adjustment): Set windows_or_buffers_changed. (Fwindow_scroll_bars): Return actual scrollbar width. * xfns.c (x_set_scroll_bar_default_width): Rename wid to unit. For non-toolkit builds again use 14 as minimum width and set FRAME_CONFIG_SCROLL_BAR_WIDTH accordingly. * xterm.c (XTset_vertical_scroll_bar): Take width from WINDOW_SCROLL_BAR_AREA_WIDTH. (x_new_font): Rename wid to unit. Base calculation of new scrollbar width on toolkit used and make it analogous to that of x_set_scroll_bar_default_width. * w32fns.c (x_set_scroll_bar_default_width): Rename wid to unit. (Fx_create_frame): Call x_set_scroll_bar_default_width instead of GetSystemMetrics. * w32term.c (w32_set_vertical_scroll_bar): Take width from WINDOW_SCROLL_BAR_AREA_WIDTH. (x_new_font): Make it correspond to changes in xterm.c.
-rw-r--r--src/ChangeLog21
-rw-r--r--src/frame.c2
-rw-r--r--src/w32fns.c8
-rw-r--r--src/w32term.c20
-rw-r--r--src/window.c5
-rw-r--r--src/xfns.c16
-rw-r--r--src/xterm.c32
7 files changed, 62 insertions, 42 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 1291815a4bc..325e428bfeb 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,24 @@
+2014-01-02 Martin Rudalics <rudalics@gmx.at>
+
+ Further adjust frame/window scrollbar width calculations.
+ * window.c (apply_window_adjustment): Set
+ windows_or_buffers_changed.
+ (Fwindow_scroll_bars): Return actual scrollbar width.
+ * xfns.c (x_set_scroll_bar_default_width): Rename wid to unit.
+ For non-toolkit builds again use 14 as minimum width and set
+ FRAME_CONFIG_SCROLL_BAR_WIDTH accordingly.
+ * xterm.c (XTset_vertical_scroll_bar): Take width from
+ WINDOW_SCROLL_BAR_AREA_WIDTH.
+ (x_new_font): Rename wid to unit. Base calculation of new
+ scrollbar width on toolkit used and make it analogous to that of
+ x_set_scroll_bar_default_width.
+ * w32fns.c (x_set_scroll_bar_default_width): Rename wid to unit.
+ (Fx_create_frame): Call x_set_scroll_bar_default_width instead
+ of GetSystemMetrics.
+ * w32term.c (w32_set_vertical_scroll_bar): Take width from
+ WINDOW_SCROLL_BAR_AREA_WIDTH.
+ (x_new_font): Make it correspond to changes in xterm.c.
+
2014-01-01 Paul Eggert <eggert@cs.ucla.edu>
* lisp.h (EMACS_INT): Configure based on INTPTR_MAX, not LONG_MAX.
diff --git a/src/frame.c b/src/frame.c
index 8fd83058520..6024c0c5be5 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -3584,6 +3584,8 @@ x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
do_pending_window_change (0);
}
+ /* Eventually remove the following call. It should have been done by
+ x_set_window_size already. */
change_frame_size (f, 0, 0, 0, 0, 0, 1);
XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0;
XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0;
diff --git a/src/w32fns.c b/src/w32fns.c
index 3d300d7e5df..25dad980aa7 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -1851,11 +1851,11 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
void
x_set_scroll_bar_default_width (struct frame *f)
{
- int wid = FRAME_COLUMN_WIDTH (f);
+ int unit = FRAME_COLUMN_WIDTH (f);
FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = GetSystemMetrics (SM_CXVSCROLL);
- FRAME_CONFIG_SCROLL_BAR_COLS (f) = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) +
- wid - 1) / wid;
+ FRAME_CONFIG_SCROLL_BAR_COLS (f)
+ = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) + unit - 1) / unit;
}
@@ -4407,7 +4407,7 @@ This function is an internal primitive--use `make-frame' instead. */)
XSETFRAME (frame, f);
/* By default, make scrollbars the system standard width. */
- FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = GetSystemMetrics (SM_CXVSCROLL);
+ x_set_scroll_bar_default_width (f);
f->terminal = dpyinfo->terminal;
diff --git a/src/w32term.c b/src/w32term.c
index c66c5b3e573..91235507b21 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3716,7 +3716,7 @@ w32_set_vertical_scroll_bar (struct window *w,
/* Compute the left edge and the width of the scroll bar area. */
left = WINDOW_SCROLL_BAR_AREA_X (w);
- width = WINDOW_CONFIG_SCROLL_BAR_WIDTH (w);
+ width = WINDOW_SCROLL_BAR_AREA_WIDTH (w);
/* Does the scroll bar exist yet? */
if (NILP (w->vertical_scroll_bar))
@@ -5361,6 +5361,7 @@ Lisp_Object
x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
{
struct font *font = XFONT_OBJECT (font_object);
+ int unit;
if (fontset < 0)
fontset = fontset_from_font (font_object);
@@ -5372,22 +5373,21 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
FRAME_FONT (f) = font;
FRAME_BASELINE_OFFSET (f) = font->baseline_offset;
- FRAME_COLUMN_WIDTH (f) = font->average_width;
+ FRAME_COLUMN_WIDTH (f) = unit = font->average_width;
FRAME_LINE_HEIGHT (f) = font->height;
compute_fringe_widths (f, 1);
- /* Compute the scroll bar width in character columns. */
+ /* Compute number of scrollbar columns. */
+ unit = FRAME_COLUMN_WIDTH (f);
if (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0)
- {
- int wid = FRAME_COLUMN_WIDTH (f);
- FRAME_CONFIG_SCROLL_BAR_COLS (f)
- = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) + wid - 1) / wid;
- }
+ FRAME_CONFIG_SCROLL_BAR_COLS (f)
+ = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) + unit - 1) / unit;
else
{
- int wid = FRAME_COLUMN_WIDTH (f);
- FRAME_CONFIG_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
+ FRAME_CONFIG_SCROLL_BAR_COLS (f) = (14 + unit - 1) / unit;
+ FRAME_CONFIG_SCROLL_BAR_WIDTH (f) =
+ FRAME_CONFIG_SCROLL_BAR_COLS (f) * unit;
}
/* Now make the frame display the given font. */
diff --git a/src/window.c b/src/window.c
index aa6a3c500f6..f85627ac49f 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6631,6 +6631,7 @@ apply_window_adjustment (struct window *w)
adjust_window_margins (w);
clear_glyph_matrix (w->current_matrix);
w->window_end_valid = 0;
+ windows_or_buffers_changed = 30;
wset_redisplay (w);
adjust_frame_glyphs (XFRAME (WINDOW_FRAME (w)));
}
@@ -6834,9 +6835,7 @@ value. */)
{
struct window *w = decode_live_window (window);
- return list4 (make_number ((WINDOW_CONFIG_SCROLL_BAR_WIDTH (w)
- ? WINDOW_CONFIG_SCROLL_BAR_WIDTH (w)
- : WINDOW_SCROLL_BAR_AREA_WIDTH (w))),
+ return list4 (make_number (WINDOW_SCROLL_BAR_AREA_WIDTH (w)),
make_number (WINDOW_SCROLL_BAR_COLS (w)),
w->vertical_scroll_bar_type, Qnil);
}
diff --git a/src/xfns.c b/src/xfns.c
index 39c895301dc..a78c2bf6b76 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1488,7 +1488,7 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
void
x_set_scroll_bar_default_width (struct frame *f)
{
- int wid = FRAME_COLUMN_WIDTH (f);
+ int unit = FRAME_COLUMN_WIDTH (f);
#ifdef USE_TOOLKIT_SCROLL_BARS
#ifdef USE_GTK
int minw = xg_get_default_scrollbar_width ();
@@ -1496,16 +1496,14 @@ x_set_scroll_bar_default_width (struct frame *f)
int minw = 16;
#endif
/* A minimum width of 14 doesn't look good for toolkit scroll bars. */
- FRAME_CONFIG_SCROLL_BAR_COLS (f) = (minw + wid - 1) / wid;
+ FRAME_CONFIG_SCROLL_BAR_COLS (f) = (minw + unit - 1) / unit;
FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = minw;
#else
- /* Make the actual width 16 pixels and a multiple of a
- character width. */
- FRAME_CONFIG_SCROLL_BAR_COLS (f) = (16 + wid - 1) / wid;
-
- /* Use all of that space (aside from required margins) for the
- scroll bar. */
- FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = 16;
+ /* The width of a non-toolkit scrollbar is at least 14 pixels and a
+ multiple of the frame's character width. */
+ FRAME_CONFIG_SCROLL_BAR_COLS (f) = (14 + unit - 1) / unit;
+ FRAME_CONFIG_SCROLL_BAR_WIDTH (f)
+ = FRAME_CONFIG_SCROLL_BAR_COLS (f) * unit;
#endif
}
diff --git a/src/xterm.c b/src/xterm.c
index bffd85c8de4..f47d73cf7ed 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -5096,7 +5096,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
/* Compute the left edge and the width of the scroll bar area. */
left = WINDOW_SCROLL_BAR_AREA_X (w);
- width = WINDOW_CONFIG_SCROLL_BAR_WIDTH (w);
+ width = WINDOW_SCROLL_BAR_AREA_WIDTH (w);
/* Does the scroll bar exist yet? */
if (NILP (w->vertical_scroll_bar))
@@ -7675,6 +7675,7 @@ Lisp_Object
x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
{
struct font *font = XFONT_OBJECT (font_object);
+ int unit;
if (fontset < 0)
fontset = fontset_from_font (font_object);
@@ -7694,21 +7695,20 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
compute_fringe_widths (f, 1);
- /* Compute the scroll bar width in character columns. */
- if (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0)
- {
- int wid = FRAME_COLUMN_WIDTH (f);
-
- FRAME_CONFIG_SCROLL_BAR_COLS (f)
- = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) + wid-1) / wid;
- }
- else
- {
- int wid = FRAME_COLUMN_WIDTH (f);
-
- FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = 14;
- FRAME_CONFIG_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
- }
+ unit = FRAME_COLUMN_WIDTH (f);
+#ifdef USE_TOOLKIT_SCROLL_BARS
+ /* The width of a toolkit scrollbar does not change with the new
+ font but we have to calculate the number of columns it occupies
+ anew. */
+ FRAME_CONFIG_SCROLL_BAR_COLS (f)
+ = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) + unit - 1) / unit;
+#else
+ /* The width of a non-toolkit scrollbar is at least 14 pixels and a
+ multiple of the frame's character width. */
+ FRAME_CONFIG_SCROLL_BAR_COLS (f) = (14 + unit - 1) / unit;
+ FRAME_CONFIG_SCROLL_BAR_WIDTH (f)
+ = FRAME_CONFIG_SCROLL_BAR_COLS (f) * unit;
+#endif
if (FRAME_X_WINDOW (f) != 0)
{