From df498e37f30a8c5ee15ffc1912265b85baac841e Mon Sep 17 00:00:00 2001 From: root Date: Sat, 19 Feb 2005 01:07:57 +0000 Subject: [PATCH] *** empty log message *** --- Changes | 3 + doc/embed | 2 +- doc/rxvt.1.html | 13 ++--- doc/rxvt.1.man.in | 17 +++--- doc/rxvt.1.pod | 11 ++-- doc/rxvt.1.txt | 11 ++-- src/command.C | 138 +++++++++++++++++++++++++++------------------- src/init.C | 34 +++++++----- src/main.C | 2 +- src/rxvt.h | 39 ++++++++++++- src/xdefaults.C | 4 +- 11 files changed, 166 insertions(+), 108 deletions(-) diff --git a/Changes b/Changes index 42ca0d94..b1c6519f 100644 --- 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 index ee673738..7566ecc3 100755 --- 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.html b/doc/rxvt.1.html index 415c99b1..9d8a2c75 100644 --- a/doc/rxvt.1.html +++ b/doc/rxvt.1.html @@ -547,14 +547,11 @@ 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
diff --git a/doc/rxvt.1.man.in b/doc/rxvt.1.man.in index 4dbce079..be3e16f9 100644 --- a/doc/rxvt.1.man.in +++ b/doc/rxvt.1.man.in @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .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" diff --git a/doc/rxvt.1.pod b/doc/rxvt.1.pod index 3c4d081e..32f757d4 100644 --- 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/doc/rxvt.1.txt b/doc/rxvt.1.txt index 757f1e72..b301bc75 100644 --- a/doc/rxvt.1.txt +++ b/doc/rxvt.1.txt @@ -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 diff --git a/src/command.C b/src/command.C index 2b71770c..0c150aad 100644 --- 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 index 7b0b6d09..e47996d8 100644 --- 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 index eebe70b3..7828b46d 100644 --- 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 index f68138dc..4c23ea6f 100644 --- 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 index 8c7d2b99..3853489d 100644 --- 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), -- 2.34.1