(g2-UU+5B73): Add `=decomposition@hanyo-denshi'.
[chise/xemacs-chise.git.1] / src / frame-x.c
index c81b27e..780367d 100644 (file)
@@ -23,6 +23,8 @@ Boston, MA 02111-1307, USA.  */
 
 /* Substantially rewritten for XEmacs.  */
 
+/* 7-8-00 !!#### This file needs definite Mule review. */
+
 #include <config.h>
 #include "lisp.h"
 
@@ -50,6 +52,7 @@ Boston, MA 02111-1307, USA.  */
 #include "faces.h"
 #include "frame.h"
 #include "window.h"
+#include "gutter.h"
 
 #ifdef HAVE_DRAGNDROP
 #include "dragdrop.h"
@@ -113,7 +116,7 @@ x_any_window_to_frame (struct device *d, Window wdesc)
 
   /* We used to map over all frames here and then map over all widgets
      belonging to that frame. However it turns out that this was very fragile
-     as it requires our display stuctures to be in sync _and_ that the
+     as it requires our display structures to be in sync _and_ that the
      loop is told about every new widget somebody adds. Therefore we
      now let Xt find it for us (which does a bottom-up search which
      could even be faster) */
@@ -207,14 +210,14 @@ decode_x_frame (Lisp_Object frame)
 void
 x_wm_mark_shell_size_user_specified (Widget wmshell)
 {
-  if (! XtIsWMShell (wmshell)) abort ();
+  if (! XtIsWMShell (wmshell)) ABORT ();
   EmacsShellSetSizeUserSpecified (wmshell);
 }
 
 void
 x_wm_mark_shell_position_user_specified (Widget wmshell)
 {
-  if (! XtIsWMShell (wmshell)) abort ();
+  if (! XtIsWMShell (wmshell)) ABORT ();
   EmacsShellSetPositionUserSpecified (wmshell);
 }
 
@@ -223,7 +226,7 @@ x_wm_mark_shell_position_user_specified (Widget wmshell)
 void
 x_wm_set_shell_iconic_p (Widget shell, int iconic_p)
 {
-  if (! XtIsWMShell (shell)) abort ();
+  if (! XtIsWMShell (shell)) ABORT ();
 
   /* Because of questionable logic in Shell.c, this sequence can't work:
 
@@ -253,9 +256,9 @@ x_wm_set_cell_size (Widget wmshell, int cw, int ch)
   Arg al [2];
 
   if (!XtIsWMShell (wmshell))
-    abort ();
+    ABORT ();
   if (cw <= 0 || ch <= 0)
-    abort ();
+    ABORT ();
 
   XtSetArg (al [0], XtNwidthInc,  cw);
   XtSetArg (al [1], XtNheightInc, ch);
@@ -268,7 +271,7 @@ x_wm_set_variable_size (Widget wmshell, int width, int height)
   Arg al [2];
 
   if (!XtIsWMShell (wmshell))
-    abort ();
+    ABORT ();
 #ifdef DEBUG_GEOMETRY_MANAGEMENT
   /* See comment in EmacsShell.c */
   printf ("x_wm_set_variable_size: %d %d\n", width, height);
@@ -335,7 +338,7 @@ x_wm_store_class_hints (Widget shell, char *frame_name)
   XClassHint classhint;
 
   if (!XtIsWMShell (shell))
-    abort ();
+    ABORT ();
 
   XtGetApplicationNameAndClass (dpy, &app_name, &app_class);
   classhint.res_name = frame_name;
@@ -351,7 +354,7 @@ x_wm_maybe_store_wm_command (struct frame *f)
   struct device *d = XDEVICE (FRAME_DEVICE (f));
 
   if (!XtIsWMShell (w))
-    abort ();
+    ABORT ();
 
   if (NILP (DEVICE_X_WM_COMMAND_FRAME (d)))
     {
@@ -661,9 +664,7 @@ x_set_frame_text_value (struct frame *f, Bufbyte *value,
       {
         const char * tmp;
         encoding = DEVICE_XATOM_COMPOUND_TEXT (XDEVICE (FRAME_DEVICE (f)));
-       TO_EXTERNAL_FORMAT (C_STRING, value,
-                           C_STRING_ALLOCA, tmp,
-                           Qctext);
+       C_STRING_TO_EXTERNAL (value, tmp, Qctext);
         new_XtValue = (String) tmp;
         break;
       }
@@ -765,9 +766,7 @@ x_set_frame_properties (struct frame *f, Lisp_Object plist)
          if (XSTRING_LENGTH (prop) == 0)
            continue;
 
-         TO_EXTERNAL_FORMAT (LISP_STRING, prop,
-                             C_STRING_ALLOCA, extprop,
-                             Qctext);
+         LISP_STRING_TO_EXTERNAL (prop, extprop, Qctext);
          if (STRINGP (val))
            {
              const Extbyte *extval;
@@ -1146,12 +1145,12 @@ WARNING: can only handle plain/text and file: transfers!
          x_event.xbutton.y_root = lisp_event->event.button.y;
        }
       modifier = lisp_event->event.button.modifiers;
-      if (modifier & MOD_SHIFT)   state |= ShiftMask;
-      if (modifier & MOD_CONTROL) state |= ControlMask;
-      if (modifier & MOD_META)    state |= xd->MetaMask;
-      if (modifier & MOD_SUPER)   state |= xd->SuperMask;
-      if (modifier & MOD_HYPER)   state |= xd->HyperMask;
-      if (modifier & MOD_ALT)     state |= xd->AltMask;
+      if (modifier & XEMACS_MOD_SHIFT)   state |= ShiftMask;
+      if (modifier & XEMACS_MOD_CONTROL) state |= ControlMask;
+      if (modifier & XEMACS_MOD_META)    state |= xd->MetaMask;
+      if (modifier & XEMACS_MOD_SUPER)   state |= xd->SuperMask;
+      if (modifier & XEMACS_MOD_HYPER)   state |= xd->HyperMask;
+      if (modifier & XEMACS_MOD_ALT)     state |= xd->AltMask;
       state |= Button1Mask << (lisp_event->event.button.button-1);
 
       x_event.xbutton.state = state;
@@ -1412,12 +1411,12 @@ The type defaults to DndText (4).
        }
 
       modifier = lisp_event->event.button.modifiers;
-      if (modifier & MOD_SHIFT)   state |= ShiftMask;
-      if (modifier & MOD_CONTROL) state |= ControlMask;
-      if (modifier & MOD_META)    state |= xd->MetaMask;
-      if (modifier & MOD_SUPER)   state |= xd->SuperMask;
-      if (modifier & MOD_HYPER)   state |= xd->HyperMask;
-      if (modifier & MOD_ALT)     state |= xd->AltMask;
+      if (modifier & XEMACS_MOD_SHIFT)   state |= ShiftMask;
+      if (modifier & XEMACS_MOD_CONTROL) state |= ControlMask;
+      if (modifier & XEMACS_MOD_META)    state |= xd->MetaMask;
+      if (modifier & XEMACS_MOD_SUPER)   state |= xd->SuperMask;
+      if (modifier & XEMACS_MOD_HYPER)   state |= xd->HyperMask;
+      if (modifier & XEMACS_MOD_ALT)     state |= xd->AltMask;
       state |= Button1Mask << (lisp_event->event.button.button-1);
 
       x_event.xbutton.state = state;
@@ -1550,13 +1549,16 @@ x_initialize_frame_size (struct frame *f)
   {
     struct window *win = XWINDOW (f->root_window);
 
-    WINDOW_LEFT (win) = FRAME_LEFT_BORDER_END (f);
-    WINDOW_TOP (win) = FRAME_TOP_BORDER_END (f);
+    WINDOW_LEFT (win) = FRAME_LEFT_BORDER_END (f)
+      + FRAME_LEFT_GUTTER_BOUNDS (f);
+    WINDOW_TOP (win) = FRAME_TOP_BORDER_END (f)
+      + FRAME_TOP_GUTTER_BOUNDS (f);
 
     if (!NILP (f->minibuffer_window))
       {
        win = XWINDOW (f->minibuffer_window);
-       WINDOW_LEFT (win) = FRAME_LEFT_BORDER_END (f);
+       WINDOW_LEFT (win) = FRAME_LEFT_BORDER_END (f)
+         + FRAME_LEFT_GUTTER_BOUNDS (f);
       }
   }
 
@@ -1635,7 +1637,7 @@ x_initialize_frame_size (struct frame *f)
   /* OK, we're a top-level shell. */
 
   if (!XtIsWMShell (wmshell))
-    abort ();
+    ABORT ();
 
   /* If the EmacsFrame doesn't have a geometry but the shell does,
      treat that as the geometry of the frame.
@@ -1809,10 +1811,14 @@ x_layout_widgets (Widget w, XtPointer client_data, XtPointer call_data)
 #endif
 
   /* finally the text area */
-  XtConfigureWidget (text, text_x, text_y,
-                    width - 2*textbord,
-                    height - text_y - 2*textbord,
-                    textbord);
+  {
+    Dimension nw = width - 2*textbord;
+    Dimension nh = height - text_y - 2*textbord;
+
+    if (nh != f->pixheight || nw != f->pixwidth)
+      MARK_FRAME_SIZE_SLIPPED (f);
+    XtConfigureWidget (text, text_x, text_y, nw, nh, textbord);
+  }
 }
 
 static void
@@ -1872,9 +1878,7 @@ x_create_widgets (struct frame *f, Lisp_Object lisp_window_id,
 #endif
 
   if (STRINGP (f->name))
-    TO_EXTERNAL_FORMAT (LISP_STRING, f->name,
-                       C_STRING_ALLOCA, name,
-                       Qctext);
+    LISP_STRING_TO_EXTERNAL (f->name, name, Qctext);
   else
     name = "emacs";
 
@@ -2486,6 +2490,18 @@ x_lower_frame (struct frame *f)
     }
 }
 
+static void
+x_enable_frame (struct frame *f)
+{
+  XtSetSensitive (FRAME_X_SHELL_WIDGET (f), True);
+}
+
+static void
+x_disable_frame (struct frame *f)
+{
+  XtSetSensitive (FRAME_X_SHELL_WIDGET (f), False);
+}
+
 /* Change from withdrawn state to mapped state. */
 static void
 x_make_frame_visible (struct frame *f)
@@ -2642,7 +2658,7 @@ x_focus_on_frame (struct frame *f)
   XFlush (XtDisplay (shell_widget)); /* hey, I'd like to DEBUG this... */
 }
 
-/* Destroy the X window of frame S.  */
+/* Destroy the X window of frame F.  */
 static void
 x_delete_frame (struct frame *f)
 {
@@ -2661,14 +2677,14 @@ x_delete_frame (struct frame *f)
   dpy = XtDisplay (FRAME_X_SHELL_WIDGET (f));
 
 #ifdef EXTERNAL_WIDGET
-  expect_x_error (XtDisplay (FRAME_X_SHELL_WIDGET (f)));
+  expect_x_error (dpy);
   /* for obscure reasons having (I think) to do with the internal
      window-to-widget hierarchy maintained by Xt, we have to call
      XtUnrealizeWidget() here.  Xt can really suck. */
   if (f->being_deleted)
     XtUnrealizeWidget (FRAME_X_SHELL_WIDGET (f));
   XtDestroyWidget (FRAME_X_SHELL_WIDGET (f));
-  x_error_occurred_p (XtDisplay (FRAME_X_SHELL_WIDGET (f)));
+  x_error_occurred_p (dpy);
 #else
   XtDestroyWidget (FRAME_X_SHELL_WIDGET (f));
   /* make sure the windows are really gone! */
@@ -2732,12 +2748,14 @@ x_update_frame_external_traits (struct frame* frm, Lisp_Object name)
      Lisp_Object font = FACE_FONT (Vdefault_face, frame, Vcharset_ascii);
 
      if (!EQ (font, Vthe_null_font_instance))
-       XtSetArg (al[ac], XtNfont,
-                (void *) FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font)));
-     ac++;
+       {
+        XtSetArg (al[ac], XtNfont,
+                  (void *) FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font)));
+        ac++;
+       }
    }
   else
-   abort ();
+   ABORT ();
 
   XtSetValues (FRAME_X_TEXT_WIDGET (frm), al, ac);
 
@@ -2789,6 +2807,8 @@ console_type_create_frame_x (void)
   CONSOLE_HAS_METHOD (x, set_mouse_position);
   CONSOLE_HAS_METHOD (x, raise_frame);
   CONSOLE_HAS_METHOD (x, lower_frame);
+  CONSOLE_HAS_METHOD (x, enable_frame);
+  CONSOLE_HAS_METHOD (x, disable_frame);
   CONSOLE_HAS_METHOD (x, make_frame_visible);
   CONSOLE_HAS_METHOD (x, make_frame_invisible);
   CONSOLE_HAS_METHOD (x, iconify_frame);