From 9f26c7d725610079bab0b3ffbbf2d08a2d945d15 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 20 Feb 2005 00:09:25 +0000 Subject: [PATCH] *** empty log message *** --- Changes | 3 ++ MANIFEST | 2 ++ doc/embed-tk | 16 +++++++++++ doc/rxvt-tabbed | 2 ++ src/init.C | 73 ++++++++++++++++++++++--------------------------- src/main.C | 6 +--- src/rxvt.h | 3 ++ 7 files changed, 59 insertions(+), 46 deletions(-) create mode 100755 doc/embed-tk diff --git a/Changes b/Changes index a2e95e73..1168ac57 100644 --- a/Changes +++ b/Changes @@ -17,6 +17,9 @@ WISH: just for fun, do shade and tint with XRender. that uses an existing pty for I/O instead of starting a command. - implement enough of XEMBED to allow for correct focus. + - added doc/embed-tk, an embedding example in Perl/Tk, + and doc/rxvt-tabbed, a primitive tabbed shell implemented + in Perl/Gtk2. - fix assertioan failure ("crash") on mousewheel-scrolling when the terminal height is small, by removing the assert. (reported by Mikael Magnusson). diff --git a/MANIFEST b/MANIFEST index 17cd0d13..cee6a531 100644 --- a/MANIFEST +++ b/MANIFEST @@ -11,6 +11,8 @@ reconf genac doc/embed +doc/embed-tk +doc/rxvt-tabbed doc/pty-fd doc/etc/rxvt-unicode.terminfo doc/etc/rxvt-unicode.termcap diff --git a/doc/embed-tk b/doc/embed-tk new file mode 100755 index 00000000..e502314a --- /dev/null +++ b/doc/embed-tk @@ -0,0 +1,16 @@ +#!/usr/bin/perl + +# sample script to illustrate the -embed option +# using Tk +# resizes do not work yet. + +use Tk; + +my $mw = new MainWindow; + +my $frame = $mw->Frame (width => 700, height => 400, container => 1) + ->pack (fill => "both", expand => 1); + +system "rxvt -embed " . ($frame->id) . " &"; + +MainLoop; diff --git a/doc/rxvt-tabbed b/doc/rxvt-tabbed index 64247ba4..dabd965b 100755 --- a/doc/rxvt-tabbed +++ b/doc/rxvt-tabbed @@ -11,6 +11,8 @@ my $RXVT_BASENAME = "rxvt"; use Gtk2; use Encode; +$SIG{CHLD} = 'IGNORE'; + my $event_cb; # $wid => $cb init Gtk2; diff --git a/src/init.C b/src/init.C index 74a17d8b..bf9aa873 100644 --- a/src/init.C +++ b/src/init.C @@ -205,6 +205,7 @@ const char *const xa_names[] = #endif #if ENABLE_XEMBED "_XEMBED", + "_XEMBED_INFO", #endif }; @@ -931,7 +932,7 @@ rxvt_term::create_windows (int argc, const char *const *argv) long vt_emask; XSetWindowAttributes attributes; XWindowAttributes gattr; - Window top; + Window top, parent; dDisp; #ifdef USING_W11LIB @@ -979,59 +980,44 @@ 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"); + parent = DefaultRootWindow (disp); + #if ENABLE_XEMBED if (rs[Rs_embed]) { XWindowAttributes wattr; - top = strtol (rs[Rs_embed], 0, 0); + parent = strtol (rs[Rs_embed], 0, 0); - if (!XGetWindowAttributes (disp, top, &wattr)) + if (!XGetWindowAttributes (disp, parent, &wattr)) rxvt_fatal ("invalid window-id specified with -embed, aborting.\n"); window_calc (wattr.width, wattr.height); - -#if 0 - if (wattr.map_state == IsViewable) - { - TermWin.mapped = 1; - refresh_type = FAST_REFRESH; - XClearWindow (disp, top); - // TODO: make XMapNotify-event-code a function and call it - // TODO: how can I detect visibility without unmap/map? - // TODO: focusin etc. - } -#else - // it's easiest just to unmap/map to get all state correctly set-up - XUnmapWindow (disp, top); -#endif } - else + #endif - { - window_calc (0, 0); + window_calc (0, 0); - /* sub-window placement & size in rxvt_resize_subwindows () */ + /* sub-window placement & size in rxvt_resize_subwindows () */ #ifdef PREFER_24BIT - attributes.background_pixel = pix_colors_focused[Color_border]; - 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); + attributes.background_pixel = pix_colors_focused[Color_border]; + attributes.border_pixel = pix_colors_focused[Color_border]; + attributes.colormap = display->cmap; + top = XCreateWindow (disp, parent, + 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]); + top = XCreateSimpleWindow (disp, parent, + szHint.x, szHint.y, + szHint.width, szHint.height, + TermWin.ext_bwidth, + pix_colors_focused[Color_border], + pix_colors_focused[Color_border]); #endif - } TermWin.parent[0] = top; @@ -1187,8 +1173,13 @@ rxvt_term::create_windows (int argc, const char *const *argv) scr_recolour (); #if ENABLE_XEMBED - // why this is necessary, I don't know, race condition?? - XMoveWindow (disp, TermWin.vt, window_vt_x, window_vt_y); + if (rs[Rs_embed]) + { + long info[2] = { 0, XEMBED_MAPPED }; + + XChangeProperty (disp, parent, xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO], + 32, PropModeReplace, (unsigned char *)&info, 2); + } #endif } diff --git a/src/main.C b/src/main.C index 775cc8a5..70dfcec6 100644 --- a/src/main.C +++ b/src/main.C @@ -254,11 +254,7 @@ rxvt_term::~rxvt_term () #endif delete TermWin.drawable; // destroy all windows - if (TermWin.parent[0] -#if ENABLE_XEMBED - && !rs[Rs_embed] -#endif - ) + if (TermWin.parent[0]) XDestroyWindow (disp, TermWin.parent[0]); } diff --git a/src/rxvt.h b/src/rxvt.h index 4c23ea6f..2d67fa85 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -204,6 +204,8 @@ typedef struct _mwmhints { # define XEMBED_FOCUS_CURRENT 0 # define XEMBED_FOCUS_FIRST 1 # define XEMBED_FOCUS_LAST 2 + +# define XEMBED_MAPPED (1 << 0) #endif /* @@ -698,6 +700,7 @@ enum { #endif #if ENABLE_XEMBED XA_XEMBED, + XA_XEMBED_INFO, #endif NUM_XA }; -- 2.34.1