*** empty log message ***
authorroot <root>
Sat, 19 Feb 2005 01:07:57 +0000 (01:07 +0000)
committerroot <root>
Sat, 19 Feb 2005 01:07:57 +0000 (01:07 +0000)
Changes
doc/embed
doc/rxvt.1.html
doc/rxvt.1.man.in
doc/rxvt.1.pod
doc/rxvt.1.txt
src/command.C
src/init.C
src/main.C
src/rxvt.h
src/xdefaults.C

diff --git a/Changes b/Changes
index 42ca0d946604885de52c9f5cb3cca6093b330be1..b1c6519febe65857a2f2e84395d21e2c755e2190 100644 (file)
--- a/Changes
+++ b/Changes
@@ -16,6 +16,7 @@ WISH: just for fun, do shade and tint with XRender.
        - new option -pty-fd that makes the terminal a slave
           that uses an existing pty for I/O instead of starting
           a command.
+        - implement enough of XEMBED to allow for correct focus.
         - SYNCCVS. backported bugfixes done to rxvt
           (sourceforge bugs #1028739, #1028732), except for
           pts/%s fix as it seems to collide with freebsd,
@@ -26,6 +27,8 @@ WISH: just for fun, do shade and tint with XRender.
           needs to be US-ASCII all the time).
         - toggle default application keypad/cursor mode to help
           some apps who fail to set the correct mode.
+        - check for WM_PROTOCOLS type in ClientMessage as to
+          not destroy the window for other types of messages.
        - remove shared library (or any library) support - it is
           of no use currently (and -embed is a better way to embed
           rxvt-unicode).
index ee6737382aada5c0aa9f0f283dadbac713288bdb..7566ecc3c10cba993d9f93b95c3934ef1d0bd54c 100755 (executable)
--- a/doc/embed
+++ b/doc/embed
@@ -17,7 +17,7 @@ my $frame = new Gtk2::Frame "embedded rxvt-unicode terminal";
 
 $window->add ($frame);
 
-my $rxvt = new Gtk2::DrawingArea;
+my $rxvt = new Gtk2::Socket;
 $frame->add ($rxvt);
 $frame->set_size_request (700, 400);
 $window->show_all;
index 415c99b12e3e048483eb35a130d67bae8e9cce8a..9d8a2c75bb9253d4c7ccd271bd932428d80049f4 100644 (file)
@@ -547,14 +547,11 @@ used (a longer example is in <em>doc/embed</em>):</p>
 </dd>
 <dd>
 <pre>
-   my $rxvt = new Gtk2::DrawingArea;
-   $...-&gt;add ($rxvt); # important to add it somewhere first
-   $rxvt-&gt;realize; # now it can be realized
-   my $xid = $rxvt-&gt;window-&gt;get_xid;</pre>
-</dd>
-<dd>
-<pre>
-   system &quot;rxvt -embed $xid &amp;&quot;;</pre>
+   my $rxvt = new Gtk2::Socket;
+   $rxvt-&gt;signal_connect_after (realize =&gt; sub {
+      my $xid = $_[0]-&gt;window-&gt;get_xid;
+      system &quot;rxvt -embed $xid &amp;&quot;;
+   });</pre>
 </dd>
 <p></p>
 <dt><strong><a name="item__2dpty_2dfd_fileno"><strong>-pty-fd</strong> <em>fileno</em></a></strong><br />
index 4dbce07971aa8e9624a526b1ad54380c0a3fc38f..be3e16f9423a5234263dd0a05524b459daecc7e8 100644 (file)
 .\" ========================================================================
 .\"
 .IX Title "rxvt 1"
-.TH rxvt 1 "2005-02-18" "5.2" "RXVT-UNICODE"
+.TH rxvt 1 "2005-02-19" "5.2" "RXVT-UNICODE"
 .SH "NAME"
 rxvt\-unicode (ouR XVT, unicode) \- (a VT102 emulator for the X window system)
 .SH "SYNOPSIS"
@@ -467,15 +467,12 @@ not.
 Here is a short Gtk2\-perl snippet that illustrates how this option can be
 used (a longer example is in \fIdoc/embed\fR):
 .Sp
-.Vb 4
-\&   my $rxvt = new Gtk2::DrawingArea;
-\&   $...->add ($rxvt); # important to add it somewhere first
-\&   $rxvt->realize; # now it can be realized
-\&   my $xid = $rxvt->window->get_xid;
-.Ve
-.Sp
-.Vb 1
-\&   system "@@RXVT_NAME@@ -embed $xid &";
+.Vb 5
+\&   my $rxvt = new Gtk2::Socket;
+\&   $rxvt->signal_connect_after (realize => sub {
+\&      my $xid = $_[0]->window->get_xid;
+\&      system "@@RXVT_NAME@@ -embed $xid &";
+\&   });
 .Ve
 .IP "\fB\-pty\-fd\fR \fIfileno\fR" 4
 .IX Item "-pty-fd fileno"
index 3c4d081e9a332ce0146b8403288409493a72e676..32f757d431a4d328c3ebec31bf61feb4639252dd 100644 (file)
@@ -395,12 +395,11 @@ not.
 Here is a short Gtk2-perl snippet that illustrates how this option can be
 used (a longer example is in F<doc/embed>):
 
-   my $rxvt = new Gtk2::DrawingArea;
-   $...->add ($rxvt); # important to add it somewhere first
-   $rxvt->realize; # now it can be realized
-   my $xid = $rxvt->window->get_xid;
-
-   system "@@RXVT_NAME@@ -embed $xid &";
+   my $rxvt = new Gtk2::Socket;
+   $rxvt->signal_connect_after (realize => sub {
+      my $xid = $_[0]->window->get_xid;
+      system "@@RXVT_NAME@@ -embed $xid &";
+   });
 
 =item B<-pty-fd> I<fileno>
 
index 757f1e72afe1c0d718a4f4a4cfdf97f31b2f9948..b301bc757a62671013e0d4e2d02bbf9618c714a1 100644 (file)
@@ -336,12 +336,11 @@ OPTIONS
         Here is a short Gtk2-perl snippet that illustrates how this option
         can be used (a longer example is in doc/embed):
 
-           my $rxvt = new Gtk2::DrawingArea;
-           $...->add ($rxvt); # important to add it somewhere first
-           $rxvt->realize; # now it can be realized
-           my $xid = $rxvt->window->get_xid;
-
-           system "rxvt -embed $xid &";
+           my $rxvt = new Gtk2::Socket;
+           $rxvt->signal_connect_after (realize => sub {
+              my $xid = $_[0]->window->get_xid;
+              system "rxvt -embed $xid &";
+           });
 
     -pty-fd *fileno*
         Tells rxvt NOT to execute any commands or create a new pty/tty pair
index 2b71770ca444ff13a1cb54fb3df9b313aaaaecdc..0c150aad3106bce527b91be3ba9885801ab97b2e 100644 (file)
@@ -1332,14 +1332,25 @@ rxvt_term::x_cb (XEvent &ev)
 
       case ClientMessage:
         if (ev.xclient.format == 32
-            && (Atom)ev.xclient.data.l[0] == xa[XA_WMDELETEWINDOW])
-          destroy ();
+            && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]
+            && ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW])
+           destroy ();
+#if ENABLE_XEMBED
+        else if (ev.xclient.format == 32
+                 && ev.xclient.message_type == xa[XA_XEMBED])
+          {
+            if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN)
+              focus_in ();
+            else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT)
+              focus_out ();
+          }
+#endif
 #ifdef OFFIX_DND
         /* OffiX Dnd (drag 'n' drop) protocol */
-        else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL]
-                 && (ev.xclient.data.l[0] == DndFile
-                     || ev.xclient.data.l[0] == DndDir
-                     || ev.xclient.data.l[0] == DndLink))
+          else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL]
+            && (ev.xclient.data.l[0] == DndFile
+                || ev.xclient.data.l[0] == DndDir
+                || ev.xclient.data.l[0] == DndLink))
           {
             /* Get Dnd data */
             Atom ActualType;
@@ -1392,61 +1403,11 @@ rxvt_term::x_cb (XEvent &ev)
         break;
 
       case FocusIn:
-        if (!TermWin.focus)
-          {
-            TermWin.focus = 1;
-            want_refresh = 1;
-#ifdef USE_XIM
-            if (Input_Context != NULL)
-              {
-                IMSetStatusPosition ();
-                XSetICFocus (Input_Context);
-              }
-#endif
-#ifdef CURSOR_BLINK
-            if (options & Opt_cursorBlink)
-              cursor_blink_ev.start (NOW + BLINK_INTERVAL);
-#endif
-#ifdef OFF_FOCUS_FADING
-            if (rs[Rs_fade])
-              {
-                pix_colors = pix_colors_focused;
-                scr_recolour ();
-              }
-#endif
-
-          }
+        focus_in ();
         break;
 
       case FocusOut:
-        if (TermWin.focus)
-          {
-            TermWin.focus = 0;
-            want_refresh = 1;
-
-#if ENABLE_FRILLS || ISO_14755
-            iso14755buf = 0;
-#endif
-#if ENABLE_OVERLAY
-            scr_overlay_off ();
-#endif
-#ifdef USE_XIM
-            if (Input_Context != NULL)
-              XUnsetICFocus (Input_Context);
-#endif
-#ifdef CURSOR_BLINK
-            if (options & Opt_cursorBlink)
-              cursor_blink_ev.stop ();
-            hidden_cursor = 0;
-#endif
-#ifdef OFF_FOCUS_FADING
-            if (rs[Rs_fade])
-              {
-                pix_colors = pix_colors_unfocused;
-                scr_recolour ();
-              }
-#endif
-          }
+        focus_out ();
         break;
 
       case ConfigureNotify:
@@ -1673,6 +1634,67 @@ rxvt_term::x_cb (XEvent &ev)
     }
 }
 
+void
+rxvt_term::focus_in ()
+{
+  if (!TermWin.focus)
+    {
+      TermWin.focus = 1;
+      want_refresh = 1;
+#ifdef USE_XIM
+      if (Input_Context != NULL)
+        {
+          IMSetStatusPosition ();
+          XSetICFocus (Input_Context);
+        }
+#endif
+#ifdef CURSOR_BLINK
+      if (options & Opt_cursorBlink)
+        cursor_blink_ev.start (NOW + BLINK_INTERVAL);
+#endif
+#ifdef OFF_FOCUS_FADING
+      if (rs[Rs_fade])
+        {
+          pix_colors = pix_colors_focused;
+          scr_recolour ();
+        }
+#endif
+    }
+}
+
+void
+rxvt_term::focus_out ()
+{
+  if (TermWin.focus)
+    {
+      TermWin.focus = 0;
+      want_refresh = 1;
+
+#if ENABLE_FRILLS || ISO_14755
+      iso14755buf = 0;
+#endif
+#if ENABLE_OVERLAY
+      scr_overlay_off ();
+#endif
+#ifdef USE_XIM
+      if (Input_Context != NULL)
+        XUnsetICFocus (Input_Context);
+#endif
+#ifdef CURSOR_BLINK
+      if (options & Opt_cursorBlink)
+        cursor_blink_ev.stop ();
+      hidden_cursor = 0;
+#endif
+#ifdef OFF_FOCUS_FADING
+      if (rs[Rs_fade])
+        {
+          pix_colors = pix_colors_unfocused;
+          scr_recolour ();
+        }
+#endif
+    }
+}
+
 #if TRANSPARENT
 void
 rxvt_term::rootwin_cb (XEvent &ev)
index 7b0b6d091fb1a76a4ecec306fa8ff27d6e06d1d2..e47996d8275834975aaf03d43ef75d61c4ef4754 100644 (file)
@@ -183,6 +183,7 @@ const char *const xa_names[] =
     "TIMESTAMP",
     "VT_SELECTION",
     "INCR",
+    "WM_PROTOCOLS",
     "WM_DELETE_WINDOW",
     "CLIPBOARD",
 #if ENABLE_FRILLS
@@ -201,6 +202,9 @@ const char *const xa_names[] =
 #ifdef OFFIX_DND
     "DndProtocol",
     "DndSelection",
+#endif
+#if ENABLE_XEMBED
+    "_XEMBED",
 #endif
   };
 
@@ -975,7 +979,7 @@ rxvt_term::create_windows (int argc, const char *const *argv)
   if (!set_fonts ())
     rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n");
 
-#if ENABLE_FRILLS
+#if ENABLE_XEMBED
   if (rs[Rs_embed])
     {
       XWindowAttributes wattr;
@@ -1013,19 +1017,19 @@ rxvt_term::create_windows (int argc, const char *const *argv)
       attributes.border_pixel = pix_colors_focused[Color_border];
       attributes.colormap = display->cmap;
       top = XCreateWindow (disp, DefaultRootWindow (disp),
-                                         szHint.x, szHint.y,
-                                         szHint.width, szHint.height,
-                                         TermWin.ext_bwidth,
-                                         display->depth, InputOutput,
-                                         display->visual,
-                                         CWColormap | CWBackPixel | CWBorderPixel, &attributes);
+                           szHint.x, szHint.y,
+                           szHint.width, szHint.height,
+                           TermWin.ext_bwidth,
+                           display->depth, InputOutput,
+                           display->visual,
+                           CWColormap | CWBackPixel | CWBorderPixel, &attributes);
 #else
       top = XCreateSimpleWindow (disp, DefaultRootWindow (disp),
-                                               szHint.x, szHint.y,
-                                               szHint.width, szHint.height,
-                                               TermWin.ext_bwidth,
-                                               pix_colors_focused[Color_border],
-                                               pix_colors_focused[Color_border]);
+                                 szHint.x, szHint.y,
+                                 szHint.width, szHint.height,
+                                 TermWin.ext_bwidth,
+                                 pix_colors_focused[Color_border],
+                                 pix_colors_focused[Color_border]);
 #endif
     }
 
@@ -1049,7 +1053,7 @@ rxvt_term::create_windows (int argc, const char *const *argv)
                     (char **)argv, argc, &szHint, &wmHint, &classHint);
 
   /* Enable delete window protocol */
-  XSetWMProtocols (disp, top, &xa[XA_WMDELETEWINDOW], 1);
+  XSetWMProtocols (disp, top, &xa[XA_WM_DELETE_WINDOW], 1);
 
 #if ENABLE_FRILLS
   long pid = getpid ();
@@ -1065,8 +1069,8 @@ rxvt_term::create_windows (int argc, const char *const *argv)
                 | KeyReleaseMask
 #endif
                 | FocusChangeMask | VisibilityChangeMask
-                | ExposureMask
-                | StructureNotifyMask);
+                | ExposureMask | StructureNotifyMask);
+
   termwin_ev.start (display, top);
 
 #if ENABLE_FRILLS
index eebe70b382fe4d17552f6ec0eab6bf13e41cba77..7828b46db3b0d69f6ae304c20c182f48dd0986e7 100644 (file)
@@ -255,7 +255,7 @@ rxvt_term::~rxvt_term ()
       delete TermWin.drawable;
       // destroy all windows
       if (TermWin.parent[0]
-#if ENABLE_FRILLS
+#if ENABLE_XEMBED
           && !rs[Rs_embed]
 #endif
           )
index f68138dc06c329cabbc33131f45d5563480b2053..4c23ea6f3c7bbc07b89bed5c3182f4170a9f51b7 100644 (file)
 #include "iom.h"
 #include "salloc.h"
 
+#if ENABLE_FRILLS
+# define ENABLE_XEMBED 1
+#endif
+
 /*
  *****************************************************************************
  * SYSTEM HACKS
@@ -179,6 +183,29 @@ typedef struct _mwmhints {
 } MWMHints;
 #endif
 
+#if ENABLE_XEMBED
+// XEMBED messages
+# define XEMBED_EMBEDDED_NOTIFY          0 
+# define XEMBED_WINDOW_ACTIVATE          1 
+# define XEMBED_WINDOW_DEACTIVATE        2 
+# define XEMBED_REQUEST_FOCUS            3 
+# define XEMBED_FOCUS_IN                 4 
+# define XEMBED_FOCUS_OUT                5 
+# define XEMBED_FOCUS_NEXT               6 
+# define XEMBED_FOCUS_PREV               7
+
+# define XEMBED_MODALITY_ON              10 
+# define XEMBED_MODALITY_OFF             11 
+# define XEMBED_REGISTER_ACCELERATOR     12 
+# define XEMBED_UNREGISTER_ACCELERATOR   13 
+# define XEMBED_ACTIVATE_ACCELERATOR     14
+
+// XEMBED detail code
+# define XEMBED_FOCUS_CURRENT            0 
+# define XEMBED_FOCUS_FIRST              1 
+# define XEMBED_FOCUS_LAST               2
+#endif
+
 /*
  *****************************************************************************
  * NORMAL DEFINES
@@ -610,8 +637,10 @@ enum {
   Rs_int_bwidth,
   Rs_borderLess,
   Rs_lineSpace,
-  Rs_embed,
   Rs_pty_fd,
+#endif
+#if ENABLE_XEMBED
+  Rs_embed,
 #endif
   Rs_cutchars,
   Rs_modifier,
@@ -647,7 +676,8 @@ enum {
   XA_TIMESTAMP,
   XA_VT_SELECTION,
   XA_INCR,
-  XA_WMDELETEWINDOW,
+  XA_WM_PROTOCOLS,
+  XA_WM_DELETE_WINDOW,
   XA_CLIPBOARD,
 #if ENABLE_FRILLS
   XA_NET_WM_PID,
@@ -665,6 +695,9 @@ enum {
 #if OFFIX_DND                /* OffiX Dnd (drag 'n' drop) support */
   XA_DNDPROTOCOL,
   XA_DNDSELECTION,
+#endif
+#if ENABLE_XEMBED
+  XA_XEMBED,
 #endif
   NUM_XA
 };
@@ -1348,6 +1381,8 @@ struct rxvt_term : zero_initialized, rxvt_vars {
   void mouse_report (XButtonEvent &ev);
   void button_press (XButtonEvent &ev);
   void button_release (XButtonEvent &ev);
+  void focus_in ();
+  void focus_out ();
   int check_our_parents ();
 #ifdef PRINTPIPE
   FILE *popen_printer ();
index 8c7d2b992c96a519faf1e2f7b6222a67a0278208..3853489d1180edca0dec0337651445d9959be9b0 100644 (file)
@@ -218,8 +218,10 @@ optList[] = {
               STRG (Rs_title, NULL, "T", NULL, NULL),  /* short form */
               STRG (Rs_iconName, "iconName", "n", "string", "icon name for window"),
               STRG (Rs_saveLines, "saveLines", "sl", "number", "number of scrolled lines to save"),
-#if ENABLE_FRILLS
+#if ENABLE_XEMBED
               STRG (Rs_embed, NULL, "embed", "windowid", "window id to embed terminal in"),
+#endif
+#if ENABLE_FRILLS
               STRG (Rs_pty_fd, NULL, "pty-fd", "fileno", "file descriptor of pty to use"),
               STRG (Rs_ext_bwidth, "externalBorder", "w", "number", "external border in pixels"),
               STRG (Rs_ext_bwidth, NULL, "bw", NULL, NULL),