Ted Zlatanov <[EMAIL PROTECTED]> writes:

> On Mon, 07 Jan 2008 16:12:19 -0500 Mark Eichin <[EMAIL PROTECTED]> wrote: 
>
>>> Also, the X and Y dimensions are set to 1920x1200 in the script, but can
>>> be overridden with -x and -y respectively.  I don't know how to grab
>>> those automatically.
>
> ME> If you're into running commands instead of doing Xlib from perl
> ME> directly, just run "xwininfo -root" and parse out the Width: and
> ME> Height: fields.  (For multi-monitor setups, just run one on each
> ME> screen, or maybe look at xdpyinfo and parse "screen #" and
> ME> "dimensions:" instead.)
>
> I'd do Xlib directly to get the mouse position and the screen
> dimensions, but I just don't have the time to play with it.  I know
> Inline::C will do almost all the glue work, but the remaining 10% of
> work will take me a long time...  If you or someone else can tell me the
> Xlib calls to do those two things, I'll rewrite my script.  I did some
> googling but didn't hit useful information.

I was mostly being sarcastic :-) I did an article on X11 in pure perl
(the protocol is simpler than you'd expect) about 10 years ago in The
Perl Journal, and it would *do* this, but shelling out to xwininfo is
Just Fine, especially given that you're already calling xmousepos...

> There's a Perl X11::Protocol module but I'd rather not make the end user
> install a huge CPAN module just for a few lines of C.  Similarly, I'd
> rather not set up the X event loop if I can help it.  So the simpler the
> better...  Thanks for any ideas.

If you do care about the C version - you get the window geometry for
free from XOpenDisplay (most of what xdpyinfo prints is the stuff in a
the Display* it gets back.)  You can look at xmousepos to see what
it's doing for the pointer-location checking.

(Given the overhead of Inline::C [hint, it uses a C compiler] the
xwininfo version is likely to be faster, at least on startup, anyway :-)

Reply via email to