GNOME Bugzilla – Bug 654688
Gtk does not seem to handle XReparentWindow correctly
Last modified: 2013-02-03 21:36:10 UTC
Raised a bug against xterm not reparenting its window correctly at https://bugs.launchpad.net/bugs/806969 which resulted in the maintainer saying the bug is with Gtk2 Full text of bug report is: === When re-parenting xterm into another window using '-into <id>' the term ignores all input. When using a different terminal such as "urxvt -embed <id>" it works as expected Attached scripts shows the problem when typing into the new window when using xterm and urxvt $ dpkg -l |grep xterm ii xterm 268-1ubuntu1 $ more /etc/debian_version squeeze/sid system is up to date === #!/usr/bin/perl use warnings; use strict; use Gtk2; init Gtk2; my $window = new Gtk2::Window 'toplevel'; $window->signal_connect( 'destroy' => sub { Gtk2->main_quit; return 0; } ); my $frame = new Gtk2::Frame "embedded terminal"; $window->add($frame); my $rxvt = new Gtk2::Socket; $frame->add($rxvt); $frame->set_size_request( 700, 400 ); $window->show_all; my $xid = $rxvt->window->get_xid; # works with rxvt but xterm loses keyboard focus system "xterm -into $xid &"; #system "urxvt -embed $xid &"; $window->show_all; $rxvt->add_events( [qw( all_events_mask key_press_mask )] ); main Gtk2; === Response from xterm admin === Investigated, found that the essential difference between xterm and urxvt in this aspect is that xterm initializes using one of the functions such as XtOpenApplication, which does resource initialization, etc., on a shell widget that it creates. Later, it uses XReparentWindow to handle the "-into" option. urxvt on the other hand, processes its "-embed" option before creating its first window, using the parameter directly as its parent window. While Tcl/Tk handles the XReparentWindow, Gtk does not, it seems. Given the nature of the problem (a bug in Gtk), revising xterm's initialization to work around Gtk's problems would seem to be a wish- list item for xterm rather than a bug in xterm.
If this is a bug, then it's not with the Perl bindings, but with the underlying gtk+ library. Reassigning accordingly.
You can't expect this to work - randomly reparenting a window into another app. The xembed protocol was invented to handle this.