bgiii has asked for the wisdom of the Perl Monks concerning the following question:

I have what I hope is a simple question. I have an old, crusty X11 application which I want to "extend" with Perl/Tk.

For my purposes, a simple X11 ClientMessage will do to facilitate communication between the X11 app and the Perl/Tk app. I can send a ClientMessage from Perl/Tk to my X11 app, but I can't seem to get it to work the other way (X11 app -> Perl/Tk). And this is because I can't seem to figure out how to capture the ClientMessage event in my Perl/Tk app. Google searches (including comp.lang.perl.tk) have been fruitless, unfortunately.

Does anyone have an idea how I might be able to do this?

TIA, my brothers in Perl

Replies are listed 'Best First'.
Re: ClientMessage x11 <=> perl/tk
by zentara (Cardinal) on May 12, 2007 at 11:49 UTC
    Gee, good question. I'm just brainstorming here, but maybe it will lead you onto the right path. I would look at X11::SendEvent and X11::WMCtrl . The following is some code which I tried, but never got to work.
    #!/usr/bin/perl use warnings; use strict; use X11::SendEvent; use X11::WMCtrl; use Data::Dumper; my $wmctrl = X11::WMCtrl->new; my @windows = $wmctrl->get_windows; print Dumper([\@windows]),"\n"; $wmctrl->activate('foo'); $|++; my $win = X11::SendEvent->new( win => [ 'foo' ], debug => 1 ); for(1..100){ $win->SendString( "testing", [ "Return" ] ); $win->SendString( "user", [ "Return" ], "joe", [ "9/1" ] ); $win->SendKeycode( 119 ); $win->SendString( "zentara", [ "Return" ], [ "Return" ] ); } <>;
    You can get the Tk widget's id with $mw->id. You probably should ask this on the newsgroup comp.lang.perl.tk. If you groups.google.com search for "Perl Tk ClientMessage" you will find this was the source of a critical bug in Tk code built on recent platforms. The patch that fixed it, may also prevent ClientMessaging from working the way you had hoped......but this is way over my head, and Slaven Rezic eserte ( the new Tk guru) is probably the only one who can answer you. Maybe message him here or ask on comp.lang.perl.tk. He is very busy so be patient.

    P.S. "perldoc Tk::send" may also have some clues like the $mw->Receive(string) method.


    I'm not really a human, but I play one on earth. Cogito ergo sum a bum