XEmacs 21.4.9 "Informed Management".
[chise/xemacs-chise.git.1] / src / toolbar.c
index 963d373..dd742ff 100644 (file)
@@ -73,24 +73,8 @@ mark_toolbar_button (Lisp_Object obj)
   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, 0,
+                              mark_toolbar_button, 0, 0, 0, 0, 0,
                               struct toolbar_button);
 
 DEFUN ("toolbar-button-p", Ftoolbar_button_p, 1, 1, 0, /*
@@ -728,13 +712,26 @@ compute_frame_toolbars_data (struct frame *f)
   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;
 
@@ -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));
     }
 
@@ -1006,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");
@@ -1040,7 +1058,7 @@ whole, use `check-valid-instantiator' with a specifier type of 'toolbar.
         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. */
       value = Fsymbol_value (elt[0]);
@@ -1160,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))
 {
@@ -1438,7 +1451,7 @@ For the other vector formats (specifying blank areas of the toolbar):
   set_specifier_caching (Vdefault_toolbar,
                         offsetof (struct window, default_toolbar),
                         default_toolbar_specs_changed,
-                        0, 0);
+                        0, 0, 0);
 
   DEFVAR_SPECIFIER ("top-toolbar",
                    &Vtoolbar[TOP_TOOLBAR] /*
@@ -1450,7 +1463,7 @@ See `default-toolbar' for a description of a valid toolbar instantiator.
   set_specifier_caching (Vtoolbar[TOP_TOOLBAR],
                         offsetof (struct window, toolbar[TOP_TOOLBAR]),
                         toolbar_specs_changed,
-                        0, 0);
+                        0, 0, 0);
 
   DEFVAR_SPECIFIER ("bottom-toolbar",
                    &Vtoolbar[BOTTOM_TOOLBAR] /*
@@ -1467,7 +1480,7 @@ displayed even if you provide a value for `bottom-toolbar'.
   set_specifier_caching (Vtoolbar[BOTTOM_TOOLBAR],
                         offsetof (struct window, toolbar[BOTTOM_TOOLBAR]),
                         toolbar_specs_changed,
-                        0, 0);
+                        0, 0, 0);
 
   DEFVAR_SPECIFIER ("left-toolbar",
                    &Vtoolbar[LEFT_TOOLBAR] /*
@@ -1484,7 +1497,7 @@ displayed even if you provide a value for `left-toolbar'.
   set_specifier_caching (Vtoolbar[LEFT_TOOLBAR],
                         offsetof (struct window, toolbar[LEFT_TOOLBAR]),
                         toolbar_specs_changed,
-                        0, 0);
+                        0, 0, 0);
 
   DEFVAR_SPECIFIER ("right-toolbar",
                    &Vtoolbar[RIGHT_TOOLBAR] /*
@@ -1501,7 +1514,7 @@ displayed even if you provide a value for `right-toolbar'.
   set_specifier_caching (Vtoolbar[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'. */
@@ -1556,7 +1569,7 @@ is not visible, so it is expanded to take up the slack.
                         offsetof (struct window, default_toolbar_height),
                         default_toolbar_size_changed_in_window,
                         offsetof (struct frame, default_toolbar_height),
-                        default_toolbar_size_changed_in_frame);
+                        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.
@@ -1569,7 +1582,7 @@ See `default-toolbar-height' for more information.
                         offsetof (struct window, default_toolbar_width),
                         default_toolbar_size_changed_in_window,
                         offsetof (struct frame, default_toolbar_width),
-                        default_toolbar_size_changed_in_frame);
+                        default_toolbar_size_changed_in_frame, 0);
 
   DEFVAR_SPECIFIER ("top-toolbar-height",
                    &Vtoolbar_size[TOP_TOOLBAR] /*
@@ -1583,7 +1596,7 @@ See `default-toolbar-height' for more information.
                         offsetof (struct window, toolbar_size[TOP_TOOLBAR]),
                         toolbar_geometry_changed_in_window,
                         offsetof (struct frame, toolbar_size[TOP_TOOLBAR]),
-                        frame_size_slipped);
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("bottom-toolbar-height",
                    &Vtoolbar_size[BOTTOM_TOOLBAR] /*
@@ -1597,7 +1610,7 @@ See `default-toolbar-height' for more information.
                         offsetof (struct window, toolbar_size[BOTTOM_TOOLBAR]),
                         toolbar_geometry_changed_in_window,
                         offsetof (struct frame, toolbar_size[BOTTOM_TOOLBAR]),
-                        frame_size_slipped);
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("left-toolbar-width",
                    &Vtoolbar_size[LEFT_TOOLBAR] /*
@@ -1611,7 +1624,7 @@ See `default-toolbar-height' for more information.
                         offsetof (struct window, toolbar_size[LEFT_TOOLBAR]),
                         toolbar_geometry_changed_in_window,
                         offsetof (struct frame, toolbar_size[LEFT_TOOLBAR]),
-                        frame_size_slipped);
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("right-toolbar-width",
                    &Vtoolbar_size[RIGHT_TOOLBAR] /*
@@ -1625,12 +1638,15 @@ See `default-toolbar-height' for more information.
                         offsetof (struct window, toolbar_size[RIGHT_TOOLBAR]),
                         toolbar_geometry_changed_in_window,
                         offsetof (struct frame, toolbar_size[RIGHT_TOOLBAR]),
-                        frame_size_slipped);
+                        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
@@ -1645,6 +1661,9 @@ 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
@@ -1688,7 +1707,7 @@ the value in a window domain will not.
                         offsetof (struct window, default_toolbar_border_width),
                         default_toolbar_border_width_changed_in_window,
                         offsetof (struct frame, default_toolbar_border_width),
-                        default_toolbar_border_width_changed_in_frame);
+                        default_toolbar_border_width_changed_in_frame, 0);
 
   DEFVAR_SPECIFIER ("top-toolbar-border-width",
                    &Vtoolbar_border_width[TOP_TOOLBAR] /*
@@ -1704,7 +1723,7 @@ See `default-toolbar-height' for more information.
                         toolbar_geometry_changed_in_window,
                         offsetof (struct frame,
                                   toolbar_border_width[TOP_TOOLBAR]),
-                        frame_size_slipped);
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("bottom-toolbar-border-width",
                    &Vtoolbar_border_width[BOTTOM_TOOLBAR] /*
@@ -1720,7 +1739,7 @@ See `default-toolbar-height' for more information.
                         toolbar_geometry_changed_in_window,
                         offsetof (struct frame,
                                   toolbar_border_width[BOTTOM_TOOLBAR]),
-                        frame_size_slipped);
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("left-toolbar-border-width",
                    &Vtoolbar_border_width[LEFT_TOOLBAR] /*
@@ -1736,7 +1755,7 @@ See `default-toolbar-height' for more information.
                         toolbar_geometry_changed_in_window,
                         offsetof (struct frame,
                                   toolbar_border_width[LEFT_TOOLBAR]),
-                        frame_size_slipped);
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("right-toolbar-border-width",
                    &Vtoolbar_border_width[RIGHT_TOOLBAR] /*
@@ -1752,7 +1771,7 @@ See `default-toolbar-height' for more information.
                         toolbar_geometry_changed_in_window,
                         offsetof (struct frame,
                                   toolbar_border_width[RIGHT_TOOLBAR]),
-                        frame_size_slipped);
+                        frame_size_slipped, 0);
 
   fb = Qnil;
 #ifdef HAVE_TTY
@@ -1761,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
@@ -1798,7 +1820,7 @@ visibility specifiers have a fallback value of true.
                         offsetof (struct window, default_toolbar_visible_p),
                         default_toolbar_visible_p_changed_in_window,
                         offsetof (struct frame, default_toolbar_visible_p),
-                        default_toolbar_visible_p_changed_in_frame);
+                        default_toolbar_visible_p_changed_in_frame, 0);
 
   DEFVAR_SPECIFIER ("top-toolbar-visible-p",
                    &Vtoolbar_visible_p[TOP_TOOLBAR] /*
@@ -1814,7 +1836,7 @@ See `default-toolbar-visible-p' for more information.
                         toolbar_geometry_changed_in_window,
                         offsetof (struct frame,
                                   toolbar_visible_p[TOP_TOOLBAR]),
-                        frame_size_slipped);
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("bottom-toolbar-visible-p",
                    &Vtoolbar_visible_p[BOTTOM_TOOLBAR] /*
@@ -1830,7 +1852,7 @@ See `default-toolbar-visible-p' for more information.
                         toolbar_geometry_changed_in_window,
                         offsetof (struct frame,
                                   toolbar_visible_p[BOTTOM_TOOLBAR]),
-                        frame_size_slipped);
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("left-toolbar-visible-p",
                    &Vtoolbar_visible_p[LEFT_TOOLBAR] /*
@@ -1846,7 +1868,7 @@ See `default-toolbar-visible-p' for more information.
                         toolbar_geometry_changed_in_window,
                         offsetof (struct frame,
                                   toolbar_visible_p[LEFT_TOOLBAR]),
-                        frame_size_slipped);
+                        frame_size_slipped, 0);
 
   DEFVAR_SPECIFIER ("right-toolbar-visible-p",
                    &Vtoolbar_visible_p[RIGHT_TOOLBAR] /*
@@ -1862,7 +1884,7 @@ See `default-toolbar-visible-p' for more information.
                         toolbar_geometry_changed_in_window,
                         offsetof (struct frame,
                                   toolbar_visible_p[RIGHT_TOOLBAR]),
-                        frame_size_slipped);
+                        frame_size_slipped, 0);
 
   /* initially, top inherits from default; this can be
      changed with `set-default-toolbar-position'. */
@@ -1885,7 +1907,7 @@ This is a specifier; use `set-specifier' to change it.
   set_specifier_caching (Vtoolbar_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)));
 }