update.
[chise/xemacs-chise.git.1] / src / toolbar.c
index d45beca..95a455f 100644 (file)
@@ -57,40 +57,24 @@ Lisp_Object Qinit_toolbar_from_resources;
 
 \f
 static Lisp_Object
-mark_toolbar_button (Lisp_Object obj, void (*markobj) (Lisp_Object))
+mark_toolbar_button (Lisp_Object obj)
 {
-  struct toolbar_button *data = (struct toolbar_button *) XPNTR (obj);
-  ((markobj) (data->next));
-  ((markobj) (data->frame));
-  ((markobj) (data->up_glyph));
-  ((markobj) (data->down_glyph));
-  ((markobj) (data->disabled_glyph));
-  ((markobj) (data->cap_up_glyph));
-  ((markobj) (data->cap_down_glyph));
-  ((markobj) (data->cap_disabled_glyph));
-  ((markobj) (data->callback));
-  ((markobj) (data->enabled_p));
+  struct toolbar_button *data = XTOOLBAR_BUTTON (obj);
+  mark_object (data->next);
+  mark_object (data->frame);
+  mark_object (data->up_glyph);
+  mark_object (data->down_glyph);
+  mark_object (data->disabled_glyph);
+  mark_object (data->cap_up_glyph);
+  mark_object (data->cap_down_glyph);
+  mark_object (data->cap_disabled_glyph);
+  mark_object (data->callback);
+  mark_object (data->enabled_p);
   return data->help_string;
 }
 
-static void
-print_toolbar_button (Lisp_Object obj, Lisp_Object printcharfun,
-                     int escapeflag)
-{
-  struct toolbar_button *tb = XTOOLBAR_BUTTON (obj);
-  char buf[100];
-
-  if (print_readably)
-    error ("printing unreadable object #<toolbar-button 0x%x>",
-          tb->header.uid);
-
-  sprintf (buf, "#<toolbar-button 0x%x>", tb->header.uid);
-  write_c_string (buf, printcharfun);
-}
-
 DEFINE_LRECORD_IMPLEMENTATION ("toolbar-button", toolbar_button,
-                              mark_toolbar_button, print_toolbar_button,
-                              0, 0, 0,
+                              mark_toolbar_button, 0, 0, 0, 0, 0,
                               struct toolbar_button);
 
 DEFUN ("toolbar-button-p", Ftoolbar_button_p, 1, 1, 0, /*
@@ -303,7 +287,7 @@ update_toolbar_button (struct frame *f, struct toolbar_button *tb,
 
   if (!tb)
     {
-      tb = alloc_lcrecord_type (struct toolbar_button, lrecord_toolbar_button);
+      tb = alloc_lcrecord_type (struct toolbar_button, &lrecord_toolbar_button);
       tb->next = Qnil;
       XSETFRAME (tb->frame, f);
       tb->up_glyph = Qnil;
@@ -722,29 +706,42 @@ set_frame_toolbar (struct frame *f, enum toolbar_pos pos)
 static void
 compute_frame_toolbars_data (struct frame *f)
 {
-  set_frame_toolbar (f, TOP_TOOLBAR);                   
-  set_frame_toolbar (f, BOTTOM_TOOLBAR);                        
-  set_frame_toolbar (f, LEFT_TOOLBAR);                  
-  set_frame_toolbar (f, RIGHT_TOOLBAR);                         
+  set_frame_toolbar (f, TOP_TOOLBAR);
+  set_frame_toolbar (f, BOTTOM_TOOLBAR);
+  set_frame_toolbar (f, LEFT_TOOLBAR);
+  set_frame_toolbar (f, RIGHT_TOOLBAR);
 }
 
+/* Update the toolbar geometry separately from actually displaying the
+   toolbar. This is necessary because both the gutter and the toolbar
+   are competing for redisplay cycles and, unfortunately, gutter
+   updates happen late in the game. Firstly they are done inside of
+   redisplay proper and secondly subcontrols may not get moved until
+   the next screen refresh. Only after subcontrols have been moved to
+   their final destinations can we be certain of updating the
+   toolbar. Under X this probably is exacerbated by the toolbar button
+   dirty flags which prevent updates happening when they possibly
+   should. */
 void
-update_frame_toolbars (struct frame *f)
+update_frame_toolbars_geometry (struct frame *f)
 {
   struct device *d = XDEVICE (f->device);
 
   if (DEVICE_SUPPORTS_TOOLBARS_P (d)
-      && (f->toolbar_changed || f->frame_changed || f->clear))
+      && (f->toolbar_changed 
+         || f->frame_layout_changed
+         || f->frame_changed
+         || f->clear))
     {
       int pos;
-      
+
       /* We're not officially "in redisplay", so we still have a
         chance to re-layout toolbars and windows. This is done here,
         because toolbar is the only thing which currently might
-        necesseritate this layout, as it is outside any windows. We
+        necessitate this layout, as it is outside any windows. We
         take care not to change size if toolbar geometry is really
         unchanged, as it will hose windows whose pixsizes are not
-        multiple of character sizes */
+        multiple of character sizes. */
 
       for (pos = 0; pos < 4; pos++)
        if (FRAME_REAL_TOOLBAR_SIZE (f, pos)
@@ -754,18 +751,39 @@ update_frame_toolbars (struct frame *f)
            pixel_to_char_size (f, FRAME_PIXWIDTH (f), FRAME_PIXHEIGHT (f),
                                &width, &height);
            change_frame_size (f, height, width, 0);
+           MARK_FRAME_LAYOUT_CHANGED (f);
            break;
          }
 
-      for (pos = 0; pos < 4; pos++)
+      for (pos = 0; pos < 4; pos++) {
        f->current_toolbar_size[pos] = FRAME_REAL_TOOLBAR_SIZE (f, pos);
+      }
 
       /* Removed the check for the minibuffer here.  We handle this
         more correctly now by consistently using
         FRAME_LAST_NONMINIBUF_WINDOW instead of FRAME_SELECTED_WINDOW
         throughout the toolbar code. */
       compute_frame_toolbars_data (f);
+      
+      /* Clear the previous toolbar locations. If we do it later
+        (after redisplay) we end up clearing what we have just
+        displayed. */
+      MAYBE_DEVMETH (d, clear_frame_toolbars, (f));
+    }
+}
 
+/* Actually redisplay the toolbar buttons. */
+void
+update_frame_toolbars (struct frame *f)
+{
+  struct device *d = XDEVICE (f->device);
+
+  if (DEVICE_SUPPORTS_TOOLBARS_P (d)
+      && (f->toolbar_changed 
+         || f->frame_layout_changed
+         || f->frame_changed 
+         || f->clear))
+    {
       DEVMETH (d, output_frame_toolbars, (f));
     }
 
@@ -890,34 +908,31 @@ get_toolbar_coords (struct frame *f, enum toolbar_pos pos, int *x, int *y,
       *vert = 1;
       break;
     default:
-      abort ();
+      ABORT ();
     }
 }
 
-#define CHECK_TOOLBAR(pos)                                             \
-  do                                                                   \
+#define CHECK_TOOLBAR(pos) do {                                                \
+  if (FRAME_REAL_##pos##_VISIBLE (f))                                  \
     {                                                                  \
+      int x, y, width, height, vert;                                   \
+                                                                       \
       get_toolbar_coords (f, pos, &x, &y, &width, &height, &vert, 0);  \
       if ((x_coord >= x) && (x_coord < (x + width)))                   \
        {                                                               \
          if ((y_coord >= y) && (y_coord < (y + height)))               \
            return FRAME_TOOLBAR_BUTTONS (f, pos);                      \
        }                                                               \
-    } while (0)
+    }                                                                  \
+} while (0)
 
 static Lisp_Object
 toolbar_buttons_at_pixpos (struct frame *f, int x_coord, int y_coord)
 {
-  int x, y, width, height, vert;
-
-  if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
-    CHECK_TOOLBAR (TOP_TOOLBAR);
-  if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
-    CHECK_TOOLBAR (BOTTOM_TOOLBAR);
-  if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
-    CHECK_TOOLBAR (LEFT_TOOLBAR);
-  if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
-    CHECK_TOOLBAR (RIGHT_TOOLBAR);
+  CHECK_TOOLBAR (TOP_TOOLBAR);
+  CHECK_TOOLBAR (BOTTOM_TOOLBAR);
+  CHECK_TOOLBAR (LEFT_TOOLBAR);
+  CHECK_TOOLBAR (RIGHT_TOOLBAR);
 
   return Qnil;
 }
@@ -931,9 +946,6 @@ toolbar_button_at_pixpos (struct frame *f, int x_coord, int y_coord)
 {
   Lisp_Object buttons = toolbar_buttons_at_pixpos (f, x_coord, y_coord);
 
-  if (NILP (buttons))
-    return Qnil;
-
   while (!NILP (buttons))
     {
       struct toolbar_button *tb = XTOOLBAR_BUTTON (buttons);
@@ -953,7 +965,7 @@ toolbar_button_at_pixpos (struct frame *f, int x_coord, int y_coord)
       buttons = tb->next;
     }
 
-  /* We must be over a blank in the toolbar. */
+  /* We are not over a toolbar or we are over a blank in the toolbar. */
   return Qnil;
 }
 
@@ -964,13 +976,10 @@ toolbar_button_at_pixpos (struct frame *f, int x_coord, int y_coord)
 
 DEFINE_SPECIFIER_TYPE (toolbar);
 
-#define CTB_ERROR(msg)                                         \
-  do                                                           \
-    {                                                          \
-      maybe_signal_simple_error (msg, button, Qtoolbar, errb); \
-      RETURN__ Qnil;                                           \
-    }                                                          \
-  while (0)
+#define CTB_ERROR(msg) do {                                    \
+  maybe_signal_simple_error (msg, button, Qtoolbar, errb);     \
+  RETURN_SANS_WARNINGS Qnil;                                   \
+} while (0)
 
 /* Returns Q_style if key was :style, Qt if ok otherwise, Qnil if error. */
 static Lisp_Object
@@ -979,7 +988,7 @@ check_toolbar_button_keywords (Lisp_Object button, Lisp_Object key,
 {
   if (!KEYWORDP (key))
     {
-      maybe_signal_simple_error_2 ("not a keyword", key, button, Qtoolbar,
+      maybe_signal_simple_error_2 ("Not a keyword", key, button, Qtoolbar,
                                   errb);
       return Qnil;
     }
@@ -990,7 +999,7 @@ check_toolbar_button_keywords (Lisp_Object button, Lisp_Object key,
          && !EQ (val, Q3D)
          && !EQ (val, Q2d)
          && !EQ (val, Q3d))
-       CTB_ERROR ("unrecognized toolbar blank style");
+       CTB_ERROR ("Unrecognized toolbar blank style");
 
       return Q_style;
     }
@@ -1015,11 +1024,11 @@ Verify the syntax of entry BUTTON in a toolbar description list.
 If you want to verify the syntax of a toolbar description list as a
 whole, use `check-valid-instantiator' with a specifier type of 'toolbar.
 */
-       (button, no_error))
+       (button, noerror))
 {
   Lisp_Object *elt, glyphs, value;
   int len;
-  Error_behavior errb = decode_error_behavior_flag (no_error);
+  Error_behavior errb = decode_error_behavior_flag (noerror);
 
   if (!VECTORP (button))
     CTB_ERROR ("toolbar button descriptors must be vectors");
@@ -1046,9 +1055,9 @@ whole, use `check-valid-instantiator' with a specifier type of 'toolbar.
   if (!CONSP (elt[0]))
     {
       /* We can't check the buffer-local here because we don't know
-         which buffer to check in.  #### I think this is a bad thing.
-         See if we can't get enough information to this function so
-         that it can check.
+        which buffer to check in.  #### I think this is a bad thing.
+        See if we can't get enough information to this function so
+        that it can check.
 
         #### Wrong.  We shouldn't be checking the value at all here.
         The user might set or change the value at any time. */
@@ -1139,18 +1148,18 @@ toolbar_validate (Lisp_Object instantiator)
     return;
 
   if (!CONSP (instantiator))
-    signal_simple_error ("toolbar spec must be list or nil", instantiator);
+    signal_simple_error ("Toolbar spec must be list or nil", instantiator);
 
   for (rest = instantiator; !NILP (rest); rest = XCDR (rest))
     {
       if (!CONSP (rest))
-       signal_simple_error ("bad list in toolbar spec", instantiator);
+       signal_simple_error ("Bad list in toolbar spec", instantiator);
 
       if (NILP (XCAR (rest)))
        {
          if (pushright_seen)
            error
-             ("more than one partition (nil) in instantiator description");
+             ("More than one partition (nil) in instantiator description");
          else
            pushright_seen = 1;
        }
@@ -1169,14 +1178,9 @@ toolbar_after_change (Lisp_Object specifier, Lisp_Object locale)
 
 DEFUN ("toolbar-specifier-p", Ftoolbar_specifier_p, 1, 1, 0, /*
 Return non-nil if OBJECT is a toolbar specifier.
-Toolbar specifiers are used to specify the format of a toolbar.
-The values of the variables `default-toolbar', `top-toolbar',
-`left-toolbar', `right-toolbar', and `bottom-toolbar' are always
-toolbar specifiers.
-
-Valid toolbar instantiators are called "toolbar descriptors"
-and are lists of vectors.  See `default-toolbar' for a description
-of the exact format.
+
+See `make-toolbar-specifier' for a description of possible toolbar
+instantiators.
 */
        (object))
 {
@@ -1200,7 +1204,7 @@ toolbar_specs_changed (Lisp_Object specifier, struct window *w,
                       Lisp_Object oldval)
 {
   /* This could be smarter but I doubt that it would make any
-     noticable difference given the infrequency with which this is
+     noticeable difference given the infrequency with which this is
      probably going to be called.
      */
   MARK_TOOLBAR_CHANGED;
@@ -1272,7 +1276,7 @@ toolbar_buttons_captioned_p_changed (Lisp_Object specifier, struct window *w,
                                     Lisp_Object oldval)
 {
   /* This could be smarter but I doubt that it would make any
-     noticable difference given the infrequency with which this is
+     noticeable difference given the infrequency with which this is
      probably going to be called. */
   MARK_TOOLBAR_CHANGED;
 }
@@ -1281,6 +1285,8 @@ toolbar_buttons_captioned_p_changed (Lisp_Object specifier, struct window *w,
 void
 syms_of_toolbar (void)
 {
+  INIT_LRECORD_IMPLEMENTATION (toolbar_button);
+
   defsymbol (&Qtoolbar_buttonp, "toolbar-button-p");
   defsymbol (&Q2D, "2D");
   defsymbol (&Q3D, "3D");
@@ -1321,6 +1327,12 @@ specifier_type_create_toolbar (void)
 }
 
 void
+reinit_specifier_type_create_toolbar (void)
+{
+  REINITIALIZE_SPECIFIER_TYPE (toolbar);
+}
+
+void
 specifier_vars_of_toolbar (void)
 {
   Lisp_Object fb;
@@ -1437,10 +1449,9 @@ For the other vector formats (specifying blank areas of the toolbar):
      automatically knew about specifier fallbacks, so we didn't
      have to do it ourselves. */
   set_specifier_caching (Vdefault_toolbar,
-                        slot_offset (struct window,
-                                     default_toolbar),
+                        offsetof (struct window, default_toolbar),
                         default_toolbar_specs_changed,
-                        0, 0);
+                        0, 0, 0);
 
   DEFVAR_SPECIFIER ("top-toolbar",
                    &Vtoolbar[TOP_TOOLBAR] /*
@@ -1450,10 +1461,9 @@ See `default-toolbar' for a description of a valid toolbar instantiator.
 */ );
   Vtoolbar[TOP_TOOLBAR] = Fmake_specifier (Qtoolbar);
   set_specifier_caching (Vtoolbar[TOP_TOOLBAR],
-                        slot_offset (struct window,
-                                     toolbar[TOP_TOOLBAR]),
+                        offsetof (struct window, toolbar[TOP_TOOLBAR]),
                         toolbar_specs_changed,
-                        0, 0);
+                        0, 0, 0);
 
   DEFVAR_SPECIFIER ("bottom-toolbar",
                    &Vtoolbar[BOTTOM_TOOLBAR] /*
@@ -1468,10 +1478,9 @@ displayed even if you provide a value for `bottom-toolbar'.
 */ );
   Vtoolbar[BOTTOM_TOOLBAR] = Fmake_specifier (Qtoolbar);
   set_specifier_caching (Vtoolbar[BOTTOM_TOOLBAR],
-                        slot_offset (struct window,
-                                     toolbar[BOTTOM_TOOLBAR]),
+                        offsetof (struct window, toolbar[BOTTOM_TOOLBAR]),
                         toolbar_specs_changed,
-                        0, 0);
+                        0, 0, 0);
 
   DEFVAR_SPECIFIER ("left-toolbar",
                    &Vtoolbar[LEFT_TOOLBAR] /*
@@ -1486,10 +1495,9 @@ displayed even if you provide a value for `left-toolbar'.
 */ );
   Vtoolbar[LEFT_TOOLBAR] = Fmake_specifier (Qtoolbar);
   set_specifier_caching (Vtoolbar[LEFT_TOOLBAR],
-                        slot_offset (struct window,
-                                     toolbar[LEFT_TOOLBAR]),
+                        offsetof (struct window, toolbar[LEFT_TOOLBAR]),
                         toolbar_specs_changed,
-                        0, 0);
+                        0, 0, 0);
 
   DEFVAR_SPECIFIER ("right-toolbar",
                    &Vtoolbar[RIGHT_TOOLBAR] /*
@@ -1504,10 +1512,9 @@ displayed even if you provide a value for `right-toolbar'.
 */ );
   Vtoolbar[RIGHT_TOOLBAR] = Fmake_specifier (Qtoolbar);
   set_specifier_caching (Vtoolbar[RIGHT_TOOLBAR],
-                        slot_offset (struct window,
-                                     toolbar[RIGHT_TOOLBAR]),
+                        offsetof (struct window, toolbar[RIGHT_TOOLBAR]),
                         toolbar_specs_changed,
-                        0, 0);
+                        0, 0, 0);
 
   /* initially, top inherits from default; this can be
      changed with `set-default-toolbar-position'. */
@@ -1559,12 +1566,10 @@ is not visible, so it is expanded to take up the slack.
 */ );
   Vdefault_toolbar_height = Fmake_specifier (Qnatnum);
   set_specifier_caching (Vdefault_toolbar_height,
-                        slot_offset (struct window,
-                                     default_toolbar_height),
+                        offsetof (struct window, default_toolbar_height),
                         default_toolbar_size_changed_in_window,
-                        slot_offset (struct frame,
-                                     default_toolbar_height),
-                        default_toolbar_size_changed_in_frame);
+                        offsetof (struct frame, default_toolbar_height),
+                        default_toolbar_size_changed_in_frame, 0);
 
   DEFVAR_SPECIFIER ("default-toolbar-width", &Vdefault_toolbar_width /*
 *Width of the default toolbar, if it's oriented vertically.
@@ -1574,12 +1579,10 @@ See `default-toolbar-height' for more information.
 */ );
   Vdefault_toolbar_width = Fmake_specifier (Qnatnum);
   set_specifier_caching (Vdefault_toolbar_width,
-                        slot_offset (struct window,
-                                     default_toolbar_width),
+                        offsetof (struct window, default_toolbar_width),
                         default_toolbar_size_changed_in_window,
-                        slot_offset (struct frame,
-                                     default_toolbar_width),
-                        default_toolbar_size_changed_in_frame);
+                        offsetof (struct frame, default_toolbar_width),
+                        default_toolbar_size_changed_in_frame, 0);
 
   DEFVAR_SPECIFIER ("top-toolbar-height",
                    &Vtoolbar_size[TOP_TOOLBAR] /*
@@ -1590,12 +1593,10 @@ See `default-toolbar-height' for more information.
 */ );
   Vtoolbar_size[TOP_TOOLBAR] = Fmake_specifier (Qnatnum);
   set_specifier_caching (Vtoolbar_size[TOP_TOOLBAR],
-                        slot_offset (struct window,
-                                     toolbar_size[TOP_TOOLBAR]),
+                        offsetof (struct window, toolbar_size[TOP_TOOLBAR]),
                         toolbar_geometry_changed_in_window,
-                        slot_offset (struct frame,
-                                     toolbar_size[TOP_TOOLBAR]),
-                        frame_size_slipped);
+                        offsetof (struct frame, toolbar_size[TOP_TOOLBAR]),
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("bottom-toolbar-height",
                    &Vtoolbar_size[BOTTOM_TOOLBAR] /*
@@ -1606,12 +1607,10 @@ See `default-toolbar-height' for more information.
 */ );
   Vtoolbar_size[BOTTOM_TOOLBAR] = Fmake_specifier (Qnatnum);
   set_specifier_caching (Vtoolbar_size[BOTTOM_TOOLBAR],
-                        slot_offset (struct window,
-                                     toolbar_size[BOTTOM_TOOLBAR]),
+                        offsetof (struct window, toolbar_size[BOTTOM_TOOLBAR]),
                         toolbar_geometry_changed_in_window,
-                        slot_offset (struct frame,
-                                     toolbar_size[BOTTOM_TOOLBAR]),
-                        frame_size_slipped);
+                        offsetof (struct frame, toolbar_size[BOTTOM_TOOLBAR]),
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("left-toolbar-width",
                    &Vtoolbar_size[LEFT_TOOLBAR] /*
@@ -1622,12 +1621,10 @@ See `default-toolbar-height' for more information.
 */ );
   Vtoolbar_size[LEFT_TOOLBAR] = Fmake_specifier (Qnatnum);
   set_specifier_caching (Vtoolbar_size[LEFT_TOOLBAR],
-                        slot_offset (struct window,
-                                     toolbar_size[LEFT_TOOLBAR]),
+                        offsetof (struct window, toolbar_size[LEFT_TOOLBAR]),
                         toolbar_geometry_changed_in_window,
-                        slot_offset (struct frame,
-                                     toolbar_size[LEFT_TOOLBAR]),
-                        frame_size_slipped);
+                        offsetof (struct frame, toolbar_size[LEFT_TOOLBAR]),
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("right-toolbar-width",
                    &Vtoolbar_size[RIGHT_TOOLBAR] /*
@@ -1638,22 +1635,23 @@ See `default-toolbar-height' for more information.
 */ );
   Vtoolbar_size[RIGHT_TOOLBAR] = Fmake_specifier (Qnatnum);
   set_specifier_caching (Vtoolbar_size[RIGHT_TOOLBAR],
-                        slot_offset (struct window,
-                                     toolbar_size[RIGHT_TOOLBAR]),
+                        offsetof (struct window, toolbar_size[RIGHT_TOOLBAR]),
                         toolbar_geometry_changed_in_window,
-                        slot_offset (struct frame,
-                                     toolbar_size[RIGHT_TOOLBAR]),
-                        frame_size_slipped);
+                        offsetof (struct frame, toolbar_size[RIGHT_TOOLBAR]),
+                        frame_size_slipped, 0);
 
   fb = Qnil;
 #ifdef HAVE_TTY
   fb = Fcons (Fcons (list1 (Qtty), Qzero), fb);
 #endif
+#ifdef HAVE_GTK
+  fb = Fcons (Fcons (list1 (Qgtk), make_int (DEFAULT_TOOLBAR_HEIGHT)), fb);
+#endif
 #ifdef HAVE_X_WINDOWS
   fb = Fcons (Fcons (list1 (Qx), make_int (DEFAULT_TOOLBAR_HEIGHT)), fb);
 #endif
 #ifdef HAVE_MS_WINDOWS
-  fb = Fcons (Fcons (list1 (Qmswindows), 
+  fb = Fcons (Fcons (list1 (Qmswindows),
                     make_int (MSWINDOWS_DEFAULT_TOOLBAR_HEIGHT)), fb);
 #endif
   if (!NILP (fb))
@@ -1663,11 +1661,14 @@ See `default-toolbar-height' for more information.
 #ifdef HAVE_TTY
   fb = Fcons (Fcons (list1 (Qtty), Qzero), fb);
 #endif
+#ifdef HAVE_GTK
+  fb = Fcons (Fcons (list1 (Qgtk), make_int (DEFAULT_TOOLBAR_WIDTH)), fb);
+#endif
 #ifdef HAVE_X_WINDOWS
   fb = Fcons (Fcons (list1 (Qx), make_int (DEFAULT_TOOLBAR_WIDTH)), fb);
 #endif
 #ifdef HAVE_MS_WINDOWS
-  fb = Fcons (Fcons (list1 (Qmswindows), 
+  fb = Fcons (Fcons (list1 (Qmswindows),
                     make_int (MSWINDOWS_DEFAULT_TOOLBAR_WIDTH)), fb);
 #endif
   if (!NILP (fb))
@@ -1703,12 +1704,10 @@ the value in a window domain will not.
 */ );
   Vdefault_toolbar_border_width = Fmake_specifier (Qnatnum);
   set_specifier_caching (Vdefault_toolbar_border_width,
-                        slot_offset (struct window,
-                                     default_toolbar_border_width),
+                        offsetof (struct window, default_toolbar_border_width),
                         default_toolbar_border_width_changed_in_window,
-                        slot_offset (struct frame,
-                                     default_toolbar_border_width),
-                        default_toolbar_border_width_changed_in_frame);
+                        offsetof (struct frame, default_toolbar_border_width),
+                        default_toolbar_border_width_changed_in_frame, 0);
 
   DEFVAR_SPECIFIER ("top-toolbar-border-width",
                    &Vtoolbar_border_width[TOP_TOOLBAR] /*
@@ -1719,12 +1718,12 @@ See `default-toolbar-height' for more information.
 */ );
   Vtoolbar_border_width[TOP_TOOLBAR] = Fmake_specifier (Qnatnum);
   set_specifier_caching (Vtoolbar_border_width[TOP_TOOLBAR],
-                        slot_offset (struct window,
-                                     toolbar_border_width[TOP_TOOLBAR]),
+                        offsetof (struct window,
+                                  toolbar_border_width[TOP_TOOLBAR]),
                         toolbar_geometry_changed_in_window,
-                        slot_offset (struct frame,
-                                     toolbar_border_width[TOP_TOOLBAR]),
-                        frame_size_slipped);
+                        offsetof (struct frame,
+                                  toolbar_border_width[TOP_TOOLBAR]),
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("bottom-toolbar-border-width",
                    &Vtoolbar_border_width[BOTTOM_TOOLBAR] /*
@@ -1735,12 +1734,12 @@ See `default-toolbar-height' for more information.
 */ );
   Vtoolbar_border_width[BOTTOM_TOOLBAR] = Fmake_specifier (Qnatnum);
   set_specifier_caching (Vtoolbar_border_width[BOTTOM_TOOLBAR],
-                        slot_offset (struct window,
-                                     toolbar_border_width[BOTTOM_TOOLBAR]),
+                        offsetof (struct window,
+                                  toolbar_border_width[BOTTOM_TOOLBAR]),
                         toolbar_geometry_changed_in_window,
-                        slot_offset (struct frame,
-                                     toolbar_border_width[BOTTOM_TOOLBAR]),
-                        frame_size_slipped);
+                        offsetof (struct frame,
+                                  toolbar_border_width[BOTTOM_TOOLBAR]),
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("left-toolbar-border-width",
                    &Vtoolbar_border_width[LEFT_TOOLBAR] /*
@@ -1751,12 +1750,12 @@ See `default-toolbar-height' for more information.
 */ );
   Vtoolbar_border_width[LEFT_TOOLBAR] = Fmake_specifier (Qnatnum);
   set_specifier_caching (Vtoolbar_border_width[LEFT_TOOLBAR],
-                        slot_offset (struct window,
-                                     toolbar_border_width[LEFT_TOOLBAR]),
+                        offsetof (struct window,
+                                  toolbar_border_width[LEFT_TOOLBAR]),
                         toolbar_geometry_changed_in_window,
-                        slot_offset (struct frame,
-                                     toolbar_border_width[LEFT_TOOLBAR]),
-                        frame_size_slipped);
+                        offsetof (struct frame,
+                                  toolbar_border_width[LEFT_TOOLBAR]),
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("right-toolbar-border-width",
                    &Vtoolbar_border_width[RIGHT_TOOLBAR] /*
@@ -1767,12 +1766,12 @@ See `default-toolbar-height' for more information.
 */ );
   Vtoolbar_border_width[RIGHT_TOOLBAR] = Fmake_specifier (Qnatnum);
   set_specifier_caching (Vtoolbar_border_width[RIGHT_TOOLBAR],
-                        slot_offset (struct window,
-                                     toolbar_border_width[RIGHT_TOOLBAR]),
+                        offsetof (struct window,
+                                  toolbar_border_width[RIGHT_TOOLBAR]),
                         toolbar_geometry_changed_in_window,
-                        slot_offset (struct frame,
-                                     toolbar_border_width[RIGHT_TOOLBAR]),
-                        frame_size_slipped);
+                        offsetof (struct frame,
+                                  toolbar_border_width[RIGHT_TOOLBAR]),
+                        frame_size_slipped, 0);
 
   fb = Qnil;
 #ifdef HAVE_TTY
@@ -1781,6 +1780,9 @@ See `default-toolbar-height' for more information.
 #ifdef HAVE_X_WINDOWS
   fb = Fcons (Fcons (list1 (Qx), make_int (DEFAULT_TOOLBAR_BORDER_WIDTH)), fb);
 #endif
+#ifdef HAVE_GTK
+  fb = Fcons (Fcons (list1 (Qgtk), make_int (DEFAULT_TOOLBAR_BORDER_WIDTH)), fb);
+#endif
 #ifdef HAVE_MS_WINDOWS
   fb = Fcons (Fcons (list1 (Qmswindows), make_int (MSWINDOWS_DEFAULT_TOOLBAR_BORDER_WIDTH)), fb);
 #endif
@@ -1815,12 +1817,10 @@ visibility specifiers have a fallback value of true.
 */ );
   Vdefault_toolbar_visible_p = Fmake_specifier (Qboolean);
   set_specifier_caching (Vdefault_toolbar_visible_p,
-                        slot_offset (struct window,
-                                     default_toolbar_visible_p),
+                        offsetof (struct window, default_toolbar_visible_p),
                         default_toolbar_visible_p_changed_in_window,
-                        slot_offset (struct frame,
-                                     default_toolbar_visible_p),
-                        default_toolbar_visible_p_changed_in_frame);
+                        offsetof (struct frame, default_toolbar_visible_p),
+                        default_toolbar_visible_p_changed_in_frame, 0);
 
   DEFVAR_SPECIFIER ("top-toolbar-visible-p",
                    &Vtoolbar_visible_p[TOP_TOOLBAR] /*
@@ -1831,12 +1831,12 @@ See `default-toolbar-visible-p' for more information.
 */ );
   Vtoolbar_visible_p[TOP_TOOLBAR] = Fmake_specifier (Qboolean);
   set_specifier_caching (Vtoolbar_visible_p[TOP_TOOLBAR],
-                        slot_offset (struct window,
-                                     toolbar_visible_p[TOP_TOOLBAR]),
+                        offsetof (struct window,
+                                  toolbar_visible_p[TOP_TOOLBAR]),
                         toolbar_geometry_changed_in_window,
-                        slot_offset (struct frame,
-                                     toolbar_visible_p[TOP_TOOLBAR]),
-                        frame_size_slipped);
+                        offsetof (struct frame,
+                                  toolbar_visible_p[TOP_TOOLBAR]),
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("bottom-toolbar-visible-p",
                    &Vtoolbar_visible_p[BOTTOM_TOOLBAR] /*
@@ -1847,12 +1847,12 @@ See `default-toolbar-visible-p' for more information.
 */ );
   Vtoolbar_visible_p[BOTTOM_TOOLBAR] = Fmake_specifier (Qboolean);
   set_specifier_caching (Vtoolbar_visible_p[BOTTOM_TOOLBAR],
-                        slot_offset (struct window,
-                                     toolbar_visible_p[BOTTOM_TOOLBAR]),
+                        offsetof (struct window,
+                                  toolbar_visible_p[BOTTOM_TOOLBAR]),
                         toolbar_geometry_changed_in_window,
-                        slot_offset (struct frame,
-                                     toolbar_visible_p[BOTTOM_TOOLBAR]),
-                        frame_size_slipped);
+                        offsetof (struct frame,
+                                  toolbar_visible_p[BOTTOM_TOOLBAR]),
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("left-toolbar-visible-p",
                    &Vtoolbar_visible_p[LEFT_TOOLBAR] /*
@@ -1863,12 +1863,12 @@ See `default-toolbar-visible-p' for more information.
 */ );
   Vtoolbar_visible_p[LEFT_TOOLBAR] = Fmake_specifier (Qboolean);
   set_specifier_caching (Vtoolbar_visible_p[LEFT_TOOLBAR],
-                        slot_offset (struct window,
-                                     toolbar_visible_p[LEFT_TOOLBAR]),
+                        offsetof (struct window,
+                                  toolbar_visible_p[LEFT_TOOLBAR]),
                         toolbar_geometry_changed_in_window,
-                        slot_offset (struct frame,
-                                     toolbar_visible_p[LEFT_TOOLBAR]),
-                        frame_size_slipped);
+                        offsetof (struct frame,
+                                  toolbar_visible_p[LEFT_TOOLBAR]),
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("right-toolbar-visible-p",
                    &Vtoolbar_visible_p[RIGHT_TOOLBAR] /*
@@ -1879,12 +1879,12 @@ See `default-toolbar-visible-p' for more information.
 */ );
   Vtoolbar_visible_p[RIGHT_TOOLBAR] = Fmake_specifier (Qboolean);
   set_specifier_caching (Vtoolbar_visible_p[RIGHT_TOOLBAR],
-                        slot_offset (struct window,
-                                     toolbar_visible_p[RIGHT_TOOLBAR]),
+                        offsetof (struct window,
+                                  toolbar_visible_p[RIGHT_TOOLBAR]),
                         toolbar_geometry_changed_in_window,
-                        slot_offset (struct frame,
-                                     toolbar_visible_p[RIGHT_TOOLBAR]),
-                        frame_size_slipped);
+                        offsetof (struct frame,
+                                  toolbar_visible_p[RIGHT_TOOLBAR]),
+                        frame_size_slipped, 0);
 
   /* initially, top inherits from default; this can be
      changed with `set-default-toolbar-position'. */
@@ -1905,10 +1905,9 @@ This is a specifier; use `set-specifier' to change it.
 */ );
   Vtoolbar_buttons_captioned_p = Fmake_specifier (Qboolean);
   set_specifier_caching (Vtoolbar_buttons_captioned_p,
-                        slot_offset (struct window,
-                                     toolbar_buttons_captioned_p),
+                        offsetof (struct window, toolbar_buttons_captioned_p),
                         toolbar_buttons_captioned_p_changed,
-                        0, 0);
+                        0, 0, 0);
   set_specifier_fallback (Vtoolbar_buttons_captioned_p,
                          list1 (Fcons (Qnil, Qt)));
 }