Hrvoje Niksic <hniksic(a)srce.hr> writes:
I've now looked at the specifier code, and decided that I have no
clue
how to implement this. I started out with something like this:
So, if you want to have these two specifiers by 21.0, someone else
will have to implement them. Kirill?
I agree the scrollbar-visible-p variable is too much of a
hack. Because of this, I started to write real specifiers for scrollbar
visibility too. I have something more or less working for b37. The only
visible bug I can notice is that if you toggle visibility several times, the
frame size decreases. I don't have time to work on it more than that right
now, but here it is in case somebody else wants to look at it and improve
it. This shouldn't be applied like this. It will probably break msw
too. Moreover, I'm not sure I got the right semantics in several changes I
made. For instance, would we need a THEORETICAL_SCROLLBAR_VISIBLE as weel as a
REAL_SCROLLBAR_VISIBLE thing like it's done for the toolbar ? Maybe Ben could
comment on what's good and bad in this patch.
Anyway, ... /this is against b37/ 'hope this can be of some help.
[ Bogus changelog ;) ]
console.h: new console methods fields. (visibility changed)
frameslots.h: new fields for scrollbar visibility.
frame.h: modified the ..._WIDTH and ..._HEIGHT macros to return 0 in
case visibility is null.
window.h: new fields for scrollbar visiblity.
window.c: updated misc functions regarding window configs.
scrollbar_width and _height return 0 is visiblity is null.
scrollbar-x.c: new methods for scrollbar visibility.
scrollbar.c: new specifiers for scrollbar visibility.
[ Bogus patch ]
---
src/console.h.org Wed Apr 29 16:22:11 1998
+++ src/console.h Wed Apr 29 18:54:29 1998
@@ -237,6 +237,10 @@
void (*scrollbar_height_changed_in_frame_method) (Lisp_Object,
struct frame *,
Lisp_Object);
+ void (*horizontal_scrollbar_visible_p_changed_in_frame_method)
+ (Lisp_Object, struct frame *, Lisp_Object);
+ void (*vertical_scrollbar_visible_p_changed_in_frame_method)
+ (Lisp_Object, struct frame *, Lisp_Object);
void (*update_scrollbar_instance_values_method) (struct window *,
struct scrollbar_instance *,
int, int, int, int, int,
---
src/frame.h.org Wed Apr 29 16:53:17 1998
+++ src/frame.h Thu Apr 30 18:08:10 1998
@@ -391,8 +391,12 @@
#define FRAME_PIXHEIGHT(f) ((f)->pixheight)
#define FRAME_PIXWIDTH(f) ((f)->pixwidth)
#ifdef HAVE_SCROLLBARS
-#define FRAME_SCROLLBAR_WIDTH(f) XINT ((f)->scrollbar_width)
-#define FRAME_SCROLLBAR_HEIGHT(f) XINT ((f)->scrollbar_height)
+#define FRAME_SCROLLBAR_WIDTH(f) \
+ (NILP ((f)->vertical_scrollbar_visible_p) ? \
+ 0 : XINT ((f)->scrollbar_width))
+#define FRAME_SCROLLBAR_HEIGHT(f) \
+ (NILP ((f)->horizontal_scrollbar_visible_p) ? \
+ 0 : XINT ((f)->scrollbar_height))
#else
#define FRAME_SCROLLBAR_WIDTH(f) 0
#define FRAME_SCROLLBAR_HEIGHT(f) 0
---
src/frameslots.h.org Wed Apr 29 15:24:45 1998
+++ src/frameslots.h Wed Apr 29 18:59:13 1998
@@ -102,6 +102,9 @@
/* Width and height of the scrollbars. */
MARKED_SLOT (scrollbar_width);
MARKED_SLOT (scrollbar_height);
+ /* Whether the scrollbars are visible */
+ MARKED_SLOT (horizontal_scrollbar_visible_p);
+ MARKED_SLOT (vertical_scrollbar_visible_p);
#endif
#ifdef HAVE_TOOLBARS
---
src/window.h.org Wed Apr 29 14:59:49 1998
+++ src/window.h Thu Apr 30 17:23:32 1998
@@ -194,6 +194,9 @@
Lisp_Object scrollbar_width;
/* Height of horizontal scrollbars. */
Lisp_Object scrollbar_height;
+ /* Whether the scrollbars are visible */
+ Lisp_Object horizontal_scrollbar_visible_p;
+ Lisp_Object vertical_scrollbar_visible_p;
/* Pointer to use for vertical and horizontal scrollbars. */
Lisp_Object scrollbar_pointer;
#endif /* HAVE_SCROLLBARS */
---
src/window.c.org Wed Apr 29 14:59:55 1998
+++ src/window.c Thu Apr 30 17:29:33 1998
@@ -157,6 +157,8 @@
#ifdef HAVE_SCROLLBARS
((markobj) (window->scrollbar_width));
((markobj) (window->scrollbar_height));
+ ((markobj) (window->horizontal_scrollbar_visible_p));
+ ((markobj) (window->vertical_scrollbar_visible_p));
((markobj) (window->scrollbar_pointer));
#endif /* HAVE_SCROLLBARS */
((markobj) (window->left_margin_width));
@@ -310,6 +312,8 @@
#ifdef HAVE_SCROLLBARS
p->scrollbar_width = Qnil;
p->scrollbar_height = Qnil;
+ p->horizontal_scrollbar_visible_p = Qnil;
+ p->vertical_scrollbar_visible_p = Qnil;
#endif
p->left_margin_width = Qnil;
p->right_margin_width = Qnil;
@@ -790,7 +794,8 @@
/* #### when does NILP (w->buffer) happen? */
return 0;
- return XINT (w->scrollbar_width);
+ return (NILP (w->vertical_scrollbar_visible_p) ? 0 :
+ XINT (w->scrollbar_width));
#else
return 0;
#endif /* HAVE_SCROLLBARS */
@@ -808,7 +813,8 @@
|| !window_truncation_on (w))
return 0;
- return XINT (w->scrollbar_height);
+ return (NILP (w->horizontal_scrollbar_visible_p) ? 0 :
+ XINT (w->scrollbar_height));
#else
return 0;
#endif /* HAVE_SCROLLBARS */
@@ -4559,6 +4565,8 @@
#ifdef HAVE_SCROLLBARS
Lisp_Object scrollbar_width;
Lisp_Object scrollbar_height;
+ Lisp_Object horizontal_scrollbar_visible_p;
+ Lisp_Object vertical_scrollbar_visible_p;
Lisp_Object scrollbar_pointer;
#endif /* HAVE_SCROLLBARS */
#ifdef HAVE_TOOLBARS
@@ -4698,6 +4706,10 @@
#ifdef HAVE_SCROLLBARS
EQ(win1->scrollbar_width, win2->scrollbar_width) &&
EQ(win1->scrollbar_height, win2->scrollbar_height) &&
+ EQ(win1->horizontal_scrollbar_visible_p,
+ win2->horizontal_scrollbar_visible_p) &&
+ EQ(win1->vertical_scrollbar_visible_p,
+ win2->vertical_scrollbar_visible_p) &&
EQ(win1->scrollbar_pointer, win2->scrollbar_pointer) &&
#endif /* HAVE_SCROLLBARS */
#ifdef HAVE_TOOLBARS
@@ -5017,6 +5029,9 @@
#ifdef HAVE_SCROLLBARS
w->scrollbar_width = p->scrollbar_width;
w->scrollbar_height = p->scrollbar_height;
+ w->horizontal_scrollbar_visible_p =
+ p->horizontal_scrollbar_visible_p;
+ w->vertical_scrollbar_visible_p = p->vertical_scrollbar_visible_p;
w->scrollbar_pointer = p->scrollbar_pointer;
#endif /* HAVE_SCROLLBARS */
#ifdef HAVE_TOOLBARS
@@ -5278,6 +5293,8 @@
#ifdef HAVE_SCROLLBARS
p->scrollbar_width = w->scrollbar_width;
p->scrollbar_height = w->scrollbar_height;
+ p->horizontal_scrollbar_visible_p = w->horizontal_scrollbar_visible_p;
+ p->vertical_scrollbar_visible_p = w->vertical_scrollbar_visible_p;
p->scrollbar_pointer = w->scrollbar_pointer;
#endif /* HAVE_SCROLLBARS */
#ifdef HAVE_TOOLBARS
---
src/scrollbar-x.c.org Wed Apr 29 16:14:03 1998
+++ src/scrollbar-x.c Thu Apr 30 19:02:09 1998
@@ -373,6 +373,69 @@
in_specifier_change_function--;
}
+/* A device method. */
+static void
+x_horizontal_scrollbar_visible_p_changed_in_frame (Lisp_Object specifier,
+ struct frame *f,
+ Lisp_Object oldval)
+{
+ XtWidgetGeometry req, repl;
+
+ in_specifier_change_function++;
+
+ if (!in_resource_setting)
+ Xt_SET_VALUE (FRAME_X_TEXT_WIDGET (f), XtNscrollBarHeight,
+ (NILP (f->horizontal_scrollbar_visible_p) ? 0 :
+ f->scrollbar_height));
+
+ if (XtIsRealized (FRAME_X_CONTAINER_WIDGET (f)))
+ {
+ req.request_mode = 0;
+
+ XtQueryGeometry (FRAME_X_CONTAINER_WIDGET (f), &req, &repl);
+ if (NILP (f->horizontal_scrollbar_visible_p))
+ repl.height -= f->scrollbar_height;
+ else
+ repl.height += f->scrollbar_height;
+ EmacsManagerChangeSize (FRAME_X_CONTAINER_WIDGET (f), repl.width,
+ repl.height);
+ }
+
+ in_specifier_change_function--;
+}
+
+
+/* A device method. */
+static void
+x_vertical_scrollbar_visible_p_changed_in_frame (Lisp_Object specifier,
+ struct frame *f,
+ Lisp_Object oldval)
+{
+ XtWidgetGeometry req, repl;
+
+ in_specifier_change_function++;
+
+ if (!in_resource_setting)
+ Xt_SET_VALUE (FRAME_X_TEXT_WIDGET (f), XtNscrollBarWidth,
+ (NILP (f->vertical_scrollbar_visible_p) ? 0 :
+ f->scrollbar_width));
+
+ if (XtIsRealized (FRAME_X_CONTAINER_WIDGET (f)))
+ {
+ req.request_mode = 0;
+
+ XtQueryGeometry (FRAME_X_CONTAINER_WIDGET (f), &req, &repl);
+ if (NILP (f->vertical_scrollbar_visible_p))
+ repl.width -= f->scrollbar_width;
+ else
+ repl.width += f->scrollbar_width;
+ EmacsManagerChangeSize (FRAME_X_CONTAINER_WIDGET (f), repl.width,
+ repl.height);
+ }
+
+ in_specifier_change_function--;
+}
+
enum x_scrollbar_loop
{
X_FIND_SCROLLBAR_WINDOW_MIRROR,
@@ -819,6 +882,8 @@
CONSOLE_HAS_METHOD (x, update_scrollbar_instance_status);
CONSOLE_HAS_METHOD (x, scrollbar_width_changed_in_frame);
CONSOLE_HAS_METHOD (x, scrollbar_height_changed_in_frame);
+ CONSOLE_HAS_METHOD (x, horizontal_scrollbar_visible_p_changed_in_frame);
+ CONSOLE_HAS_METHOD (x, vertical_scrollbar_visible_p_changed_in_frame);
CONSOLE_HAS_METHOD (x, scrollbar_pointer_changed_in_window);
#ifdef MEMORY_USAGE_STATS
CONSOLE_HAS_METHOD (x, compute_scrollbar_instance_usage);
---
src/scrollbar.c.org Wed Apr 29 14:03:58 1998
+++ src/scrollbar.c Thu Apr 30 17:22:18 1998
@@ -56,6 +56,7 @@
#define DEFAULT_SCROLLBAR_WIDTH 15
#define DEFAULT_SCROLLBAR_HEIGHT 15
+#define DEFAULT_SCROLLBAR_VISIBLE_P Qt
/* Width of the scrollbar. */
Lisp_Object Vscrollbar_width;
@@ -63,6 +64,9 @@
/* Height of the scrollbar. */
Lisp_Object Vscrollbar_height;
+/* Whether the scrollbars are visible */
+Lisp_Object Vhorizontal_scrollbar_visible_p, Vvertical_scrollbar_visible_p;
+
Lisp_Object Vscrollbar_pointer_glyph;
static void update_scrollbar_instance (struct window *w, int vertical,
@@ -601,6 +605,28 @@
}
/* This function is called as a result of a change to the
+ `horizontal-scrollbar-visible-p specifier. */
+static void
+horizontal_scrollbar_visible_p_changed_in_frame (Lisp_Object specifier,
+ struct frame *f,
+ Lisp_Object oldval)
+{
+ MAYBE_FRAMEMETH (f, horizontal_scrollbar_visible_p_changed_in_frame,
+ (specifier, f, oldval));
+}
+
+/* This function is called as a result of a change to the
+ `vertical-scrollbar-visible-p specifier. */
+static void
+vertical_scrollbar_visible_p_changed_in_frame (Lisp_Object specifier,
+ struct frame *f,
+ Lisp_Object oldval)
+{
+ MAYBE_FRAMEMETH (f, vertical_scrollbar_visible_p_changed_in_frame,
+ (specifier, f, oldval));
+}
+
+/* This function is called as a result of a change to the
`scrollbar-pointer' glyph. */
static void
scrollbar_pointer_changed_in_window (Lisp_Object specifier, struct window *w,
@@ -930,6 +956,8 @@
void
specifier_vars_of_scrollbar (void)
{
+ Lisp_Object fallback;
+
DEFVAR_SPECIFIER ("scrollbar-width", &Vscrollbar_width /*
*Width of vertical scrollbars.
This is a specifier; use `set-specifier' to change it.
@@ -961,6 +989,37 @@
slot_offset (struct frame,
scrollbar_height),
scrollbar_height_changed_in_frame);
+
+ fallback = list1 (Fcons (Qnil, DEFAULT_SCROLLBAR_VISIBLE_P));
+
+ DEFVAR_SPECIFIER ("horizontal-scrollbar-visible-p",
+ &Vhorizontal_scrollbar_visible_p /*
+*Whether the horizontal scrollbar is visible.
+This is a specifier; use `set-specifier' to change it.
+*/ );
+ Vhorizontal_scrollbar_visible_p = Fmake_specifier (Qboolean);
+ set_specifier_fallback (Vhorizontal_scrollbar_visible_p, fallback);
+ set_specifier_caching (Vhorizontal_scrollbar_visible_p,
+ slot_offset (struct window,
+ horizontal_scrollbar_visible_p),
+ some_window_value_changed,
+ slot_offset (struct frame,
+ horizontal_scrollbar_visible_p),
+ horizontal_scrollbar_visible_p_changed_in_frame);
+ DEFVAR_SPECIFIER ("vertical-scrollbar-visible-p",
+ &Vvertical_scrollbar_visible_p /*
+*Whether the vertical scrollbar is visible.
+This is a specifier; use `set-specifier' to change it.
+*/ );
+ Vvertical_scrollbar_visible_p = Fmake_specifier (Qboolean);
+ set_specifier_fallback (Vvertical_scrollbar_visible_p, fallback);
+ set_specifier_caching (Vvertical_scrollbar_visible_p,
+ slot_offset (struct window,
+ vertical_scrollbar_visible_p),
+ some_window_value_changed,
+ slot_offset (struct frame,
+ vertical_scrollbar_visible_p),
+ vertical_scrollbar_visible_p_changed_in_frame);
}
void