repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 3754240bd38fde61ace082b9ef064ae83325c1da: path_to: revision_to:
commit 3754240bd38fde61ace082b9ef064ae83325c1da Author: Marc LehmannDate: Sat Feb 19 01:07:58 2005 +0000 *** empty log message *** diff --git a/Changes b/Changes
--- 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).
diff --git a/doc/embed b/doc/embed
--- 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; diff --git a/doc/rxvt.1.pod b/doc/rxvt.1.pod
--- a/doc/rxvt.1.pod +++ b/doc/rxvt.1.pod @@ -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): - 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 diff --git a/src/command.C b/src/command.C
--- a/src/command.C
+++ b/src/command.C
@@ -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)
diff --git a/src/init.C b/src/init.C
--- a/src/init.C
+++ b/src/init.C
@@ -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
diff --git a/src/main.C b/src/main.C
--- a/src/main.C
+++ b/src/main.C
@@ -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
)
diff --git a/src/rxvt.h b/src/rxvt.h
--- a/src/rxvt.h
+++ b/src/rxvt.h
@@ -21,6 +21,10 @@
#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 ();
diff --git a/src/xdefaults.C b/src/xdefaults.C
--- a/src/xdefaults.C
+++ b/src/xdefaults.C
@@ -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),
-----END OF PAGE-----