repo: rxvt-unicode-sixel
action: commit
revision: 
path_from: 
revision_from: b241ebd65fd7000ca55dff441f1cac917078712d:
path_to: 
revision_to: 
git.thebackupbox.net
rxvt-unicode-sixel
git clone git://git.thebackupbox.net/rxvt-unicode-sixel
commit b241ebd65fd7000ca55dff441f1cac917078712d
Author: Marc Lehmann 
Date:   Sun Feb 13 11:07:57 2005 +0000

    *** empty log message ***

diff --git a/Changes b/Changes
index 430a4c04dbdb566d4146633000a7f5de2ae734e5..
index ..5524b321ef01a6bcab9423bdd6442d83499eddc7 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,4 @@
 TODO: manpage 900mb update
-TODO: maybe just output the error and continue on x errors, especially for XIM-management
 TODO: safer command: keymap processing.
 TODO: read property sequence is broken with respect to utf-8 etc.
 WISH: keyboard modification via esc-sequences.
@@ -15,6 +14,7 @@ WISH: just for fun, do shade and tint with XRender.
 	- fix a bug when parsing fontnames and another one
           for empty keymaps which could result in crashes
           (Kuang-che Wu).
+        - only warn on X errors, *try* to continue (frills).
         - add COPYING back, which got lost somehow.

 5.0  Fri Feb 11 18:31:48 CET 2005
diff --git a/README.FAQ b/README.FAQ
index 11ea49d534169a8fa9a418697102f045945e0e03..
index ..51966a828d9a4d51b893e0014c0408b62ea3522f 100644
--- a/README.FAQ
+++ b/README.FAQ
@@ -390,6 +390,17 @@ FREQUENTLY ASKED QUESTIONS
         be able to input characters outside "EUC-JP" in a normal way then,
         as your input method limits you.

+    Rxvt-unicode crashes when the X Input Method changes or exits.
+        Unfortunately, this is unavoidable, as the XIM protocol is racy by
+        design. Applications can avoid some crashes at the expense of memory
+        leaks, and Input Methods can avoid some crashes by careful ordering
+        at exit time. kinput2 (and derived input methods) generally
+        succeeds, while SCIM (or similar input methods) fails. In the end,
+        however, crashes cannot be completely avoided even if both sides
+        cooperate.
+
+        So the only workaround is not to kill your Input Method Servers.
+
     Rxvt-unicode uses gobs of memory, how can I reduce that?
         Rxvt-unicode tries to obey the rule of not charging you for
         something you don't use. One thing you should try is to configure
diff --git a/doc/rxvt.7.html b/doc/rxvt.7.html
index c318216e14cafa35b4a5f10663f5f8fc1f2a83e7..
index ..a4725aa32cbcabf72a13517169875c53b9c15d68 100644
--- a/doc/rxvt.7.html
+++ b/doc/rxvt.7.html
@@ -586,6 +586,20 @@ input characters outside EUC-JP in a normal way then, as your input
 method limits you.

+
Rxvt-unicode crashes when the X Input Method changes or exits.
+
+
+Unfortunately, this is unavoidable, as the XIM protocol is racy by +design. Applications can avoid some crashes at the expense of memory +leaks, and Input Methods can avoid some crashes by careful ordering at +exit time. kinput2 (and derived input methods) generally succeeds, +while SCIM (or similar input methods) fails. In the end, however, +crashes cannot be completely avoided even if both sides cooperate. +
+
+

So the only workaround is not to kill your Input Method Servers.

+
+

Rxvt-unicode uses gobs of memory, how can I reduce that?
diff --git a/doc/rxvt.7.man.in b/doc/rxvt.7.man.in
index 8e42310984e26c5b3c3d030fcb169c07b995aa08..
index ..1d9963f5634024c0b740af960a91daff9f955cc5 100644
--- a/doc/rxvt.7.man.in
+++ b/doc/rxvt.7.man.in
@@ -129,7 +129,7 @@
 .\" ========================================================================
 .\"
 .IX Title "rxvt 7"
-.TH rxvt 7 "2005-02-11" "5.0" "RXVT-UNICODE"
+.TH rxvt 7 "2005-02-13" "5.1" "RXVT-UNICODE"
 .SH "NAME"
 RXVT REFERENCE \- FAQ, command sequences and other background information
 .SH "SYNOPSIS"
@@ -576,6 +576,16 @@ Now you can start your terminal with \f(CW\*(C`LC_CTYPE=ja_JP.UTF\-8\*(C'\fR and
 use your input method. Please note, however, that you will not be able to
 input characters outside \f(CW\*(C`EUC\-JP\*(C'\fR in a normal way then, as your input
 method limits you.
+.IP "Rxvt-unicode crashes when the X Input Method changes or exits." 4
+.IX Item "Rxvt-unicode crashes when the X Input Method changes or exits."
+Unfortunately, this is unavoidable, as the \s-1XIM\s0 protocol is racy by
+design. Applications can avoid some crashes at the expense of memory
+leaks, and Input Methods can avoid some crashes by careful ordering at
+exit time. \fBkinput2\fR (and derived input methods) generally succeeds,
+while \fB\s-1SCIM\s0\fR (or similar input methods) fails. In the end, however,
+crashes cannot be completely avoided even if both sides cooperate.
+.Sp
+So the only workaround is not to kill your Input Method Servers.
 .IP "Rxvt-unicode uses gobs of memory, how can I reduce that?" 4
 .IX Item "Rxvt-unicode uses gobs of memory, how can I reduce that?"
 Rxvt-unicode tries to obey the rule of not charging you for something you
diff --git a/doc/rxvt.7.pod b/doc/rxvt.7.pod
index 0e29fc9691a39fe24ab1d2cc4ad0164c021afdd0..
index ..1a867ec4a7458880cd4a557974f6355cac47cfde 100644
--- a/doc/rxvt.7.pod
+++ b/doc/rxvt.7.pod
@@ -423,6 +423,17 @@ use your input method. Please note, however, that you will not be able to
 input characters outside C in a normal way then, as your input
 method limits you.

+=item Rxvt-unicode crashes when the X Input Method changes or exits.
+
+Unfortunately, this is unavoidable, as the XIM protocol is racy by
+design. Applications can avoid some crashes at the expense of memory
+leaks, and Input Methods can avoid some crashes by careful ordering at
+exit time. B (and derived input methods) generally succeeds,
+while B (or similar input methods) fails. In the end, however,
+crashes cannot be completely avoided even if both sides cooperate.
+
+So the only workaround is not to kill your Input Method Servers.
+
 =item Rxvt-unicode uses gobs of memory, how can I reduce that?

 Rxvt-unicode tries to obey the rule of not charging you for something you
diff --git a/doc/rxvt.7.txt b/doc/rxvt.7.txt
index b4c335378f41956f2fdba25f9b44ce0cf6a2c6ad..
index ..68adb58659ac369e5bc505b2cba1622d609e46f1 100644
--- a/doc/rxvt.7.txt
+++ b/doc/rxvt.7.txt
@@ -411,6 +411,17 @@ FREQUENTLY ASKED QUESTIONS
         be able to input characters outside "EUC-JP" in a normal way then,
         as your input method limits you.

+    Rxvt-unicode crashes when the X Input Method changes or exits.
+        Unfortunately, this is unavoidable, as the XIM protocol is racy by
+        design. Applications can avoid some crashes at the expense of memory
+        leaks, and Input Methods can avoid some crashes by careful ordering
+        at exit time. kinput2 (and derived input methods) generally
+        succeeds, while SCIM (or similar input methods) fails. In the end,
+        however, crashes cannot be completely avoided even if both sides
+        cooperate.
+
+        So the only workaround is not to kill your Input Method Servers.
+
     Rxvt-unicode uses gobs of memory, how can I reduce that?
         Rxvt-unicode tries to obey the rule of not charging you for
         something you don't use. One thing you should try is to configure
diff --git a/src/main.C b/src/main.C
index 04e13d92775376aa889f48b8416a5cdd34de0598..
index ..a17d577bd2ccb62b0486ae1f5189491cfbcc69e6 100644
--- a/src/main.C
+++ b/src/main.C
@@ -364,6 +364,55 @@ rxvt_emergency_cleanup ()
     (*t)->emergency_cleanup ();
 }

+#if ENABLE_FRILLS
+static void
+print_x_error (Display *dpy, XErrorEvent *event)
+{
+    char buffer[BUFSIZ];
+    char mesg[BUFSIZ];
+    char number[32];
+    char *mtype = "XlibMessage";
+    XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
+    XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
+    rxvt_warn ("An X Error occured, trying to continue after report.\n");
+    rxvt_warn ("%s:  %s\n", mesg, buffer);
+    XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ);
+    rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code);
+    sprintf(number, "%d", event->request_code);
+    XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
+    rxvt_warn ("(which is %s)\n", buffer);
+    if (event->request_code >= 128) {
+	XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
+			      mesg, BUFSIZ);
+        rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code);
+    }
+    if ((event->error_code == BadWindow) ||
+	       (event->error_code == BadPixmap) ||
+	       (event->error_code == BadCursor) ||
+	       (event->error_code == BadFont) ||
+	       (event->error_code == BadDrawable) ||
+	       (event->error_code == BadColor) ||
+	       (event->error_code == BadGC) ||
+	       (event->error_code == BadIDChoice) ||
+	       (event->error_code == BadValue) ||
+	       (event->error_code == BadAtom)) {
+	if (event->error_code == BadValue)
+	    XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
+				  mesg, BUFSIZ);
+	else if (event->error_code == BadAtom)
+	    XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
+				  mesg, BUFSIZ);
+	else
+	    XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
+				  mesg, BUFSIZ);
+	rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid);
+    }
+    XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", 
+			  mesg, BUFSIZ);
+    rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial);
+}
+#endif
+
 int
 rxvt_xerror_handler (Display *display, XErrorEvent *event)
 {
@@ -373,8 +422,11 @@ rxvt_xerror_handler (Display *display, XErrorEvent *event)
     {
       //TODO: GET_R is most likely not the terminal which caused the error
       //TODO: maybe just output the error and continue?
+#if ENABLE_FRILLS
+      print_x_error (display, event);
+#else
       old_xerror_handler (display, event);
-      GET_R->destroy ();
+#endif
     }

   return 0;
@@ -1503,6 +1555,8 @@ rxvt_term::im_cb ()
   char **s;
   char buf[IMBUFSIZ];

+  SET_R (this);
+
   im_destroy ();

   D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()"));
diff --git a/src/rxvttoolkit.C b/src/rxvttoolkit.C
index 446f553f886c35d3c1df0c3f71ee087b14ef8c3f..
index ..d04b5060b79784c17aafa9a8babaf736a2185f5f 100644
--- a/src/rxvttoolkit.C
+++ b/src/rxvttoolkit.C
@@ -233,7 +233,7 @@ void rxvt_display::im_change_cb ()

 void rxvt_display::im_change_check ()
 {
-  // make sure we only call im_change_cb when a new input method
+  // try to only call im_change_cb when a new input method
   // registers, as xlib crashes due to a race otherwise.
   Atom actual_type, *atoms;
   int actual_format;

-----END OF PAGE-----