Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Moving and resizing application in X Window Manager

by jettero (Monsignor)
on Oct 28, 2009 at 22:58 UTC ( [id://803825]=note: print w/replies, xml ) Need Help??


in reply to Moving and resizing application in X Window Manager

I use X11::GUITest for this stuff. I used to like the KGS Go server, but I hated the way the client interacted with my linux desktop. WMS made several terrible design decisions that made it somewhat less portable than Java programmers pretend their programs should be... ... so I wrote a program to find KGS windows and move them back onto my desktop (from off the screen) and/or put them where I want them to go (instead of whatever random position WMS calculated). I won't cut and paste the whole thing, but here's basically how it worked:
use strict; use warnings; use X11::GUITest ':ALL'; my $cur = GetInputFocus; sub onscreen { my ($x, $y) = @_; return 0 if $x > 1280 or $x < 0; return 0 if $y > 1024 or $y < 0; return 1; } for(;;) { my $root = GetRootWindow; for my $window (grep {defined $_->{n}} map {{id=>$_, n=>GetWindowN +ame($_)}} GetChildWindows($root)) { if( $window->{n} =~ m/Room List/ ) { my ($x, $y, $w, $h) = GetWindowPos($window->{id}); # warn +"\$x=$x, \$y=$y, \$w=$w, \$h=$h"; my ($ex, $ey, $ew, $eh) = (1, 19, 1076, 879); if( onscreen($x, $y) ) { unless( $x == $ex and $y == $ey ) { print "Moving room list to ${ex}x$ey\n"; MoveWindow($window->{id}, $ex, $ey); } unless( $w == $ew and $h == $eh ) { print "Resizing room list to ${ew}x$eh\n"; ResizeWindow($window->{id}, $ew, $eh); } } } } sleep $d; }

Also, I may not understand Gnome/kde vs Metacity/sawfish/openbox -- but I don't think Gnome moves windows around, that's metacity. Metacity doesn't handle the panels, that's gnome... maybe I'm way off.

-Paul

Replies are listed 'Best First'.
Re^2: Moving and resizing application in X Window Manager
by LanX (Saint) on Oct 28, 2009 at 23:24 UTC
    Thanx Paul, I really appreciate your help + code samples!

    I already got wmctrl installed and running it does everything I need so far! 8)

    ... and yes the WM is indeed metacity, the default installed with gnome. (Actually I really do not care much, as long as I have the least possible administration tasks setting up my ubuntu box, which may distract me from hacking ... )

    Anyway X11::GUITest does muuuuch more than wmctrl, e.g sending keystrokes to the app, simulating a typing user - excellent!

    That's something I have on my todo list for a long time now, so muchas gracias again!!! 8)

    Cheers Rolf

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://803825]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-26 05:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found