From: Valeriy E. Ushakov
Subject: CLX: getting a WINDOW object for the gived window id?
Date: 
Message-ID: <90gbmu$80d$1@news.spbu.ru>
I have searched CLX manual, but cannot find how a window id (an
integer) can be converted/mapped to a WINDOW object.

I probably miss something obvious here...

Thanks in advance.

SY, Uwe
-- 
···@ptc.spbu.ru                         |       Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/            |       Ist zu Grunde gehen

From: Janis Dzerins
Subject: Re: CLX: getting a WINDOW object for the gived window id?
Date: 
Message-ID: <87ofysunkt.fsf@asaka.latnet.lv>
"Valeriy E. Ushakov" <···@ptc.spbu.ru> writes:

> I have searched CLX manual, but cannot find how a window id (an
> integer) can be converted/mapped to a WINDOW object.

You can query root window for its children and find the one you're
interested in:

(defun find-window (id &optional (display *display*))
  (dolist (window (query-tree (screen-root (display-default-screen display))))
    (when (= id (window-id window))
      (return window))))

There may be other way to do it but I could not find it in 2 minutes.

BTW, window-id is card29 not integer!

Janis Dzerins
-- 
  If million people say a stupid thing it's still a stupid thing.
From: Valeriy E. Ushakov
Subject: Re: CLX: getting a WINDOW object for the gived window id?
Date: 
Message-ID: <90gu5f$fqo$1@news.spbu.ru>
Janis Dzerins <·····@latnet.lv> wrote:

> > I have searched CLX manual, but cannot find how a window id (an
> > integer) can be converted/mapped to a WINDOW object.
> 
> You can query root window for its children and find the one you're
> interested in:

Sure, QUERY-TREE will do (and in my particular case I'm looking for a
toplevel, so I won't need to recurse).  But that's not sportsmanlike ;)

> BTW, window-id is card29 not integer!

Sure.

I've been looking through protocol macrology that extracts window ids
from the stream (lookup-window &c), but haven't completely unwound it
yet.

PS: I'm prototyping some code (that gonna be in C) that will talk to
WM using new wm-spec jointly developed by Gnome, KDE and others and
CLX was *very* helpful in hunting and debugging WM bugs ;-), not to
mention that programming CLX is *refreshing* after C/Xlib.

SY, Uwe
-- 
···@ptc.spbu.ru                         |       Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/            |       Ist zu Grunde gehen
From: Janis Dzerins
Subject: Re: CLX: getting a WINDOW object for the gived window id?
Date: 
Message-ID: <87elznutvk.fsf@asaka.latnet.lv>
"Valeriy E. Ushakov" <···@ptc.spbu.ru> writes:

> Sure, QUERY-TREE will do (and in my particular case I'm looking for a
> toplevel, so I won't need to recurse).  But that's not sportsmanlike ;)

QUERY-TREE returns plain list (list by default) so you could not
recurse even if you wanted :)

> PS: I'm prototyping some code (that gonna be in C) that will talk to
> WM using new wm-spec jointly developed by Gnome, KDE and others and
> CLX was *very* helpful in hunting and debugging WM bugs ;-), not to
> mention that programming CLX is *refreshing* after C/Xlib.

From what C sources of X programs I have seen I do not want to program
X in C. But when I saw CLX it really made me feel good (the best thing
being that CLX "talks" X by itself not through FFI to Xlib).

And, while we're at it -- what's wrong with X protocol? I have seen
people complaining about it being stupid or inefficient or what else
not. But I like it. And with CLX X gets very simple to use (after seen
the thread about sketching program in MCL I wrote one in CLX -- my
first CLX program -- well that was easy).

Janis Dzerins
-- 
  If million people say a stupid thing it's still a stupid thing.
From: Lieven Marchand
Subject: Re: CLX: getting a WINDOW object for the gived window id?
Date: 
Message-ID: <m34s0i95ay.fsf@localhost.localdomain>
Janis Dzerins <·····@latnet.lv> writes:

> And, while we're at it -- what's wrong with X protocol? I have seen
> people complaining about it being stupid or inefficient or what else
> not. But I like it. And with CLX X gets very simple to use (after seen
> the thread about sketching program in MCL I wrote one in CLX -- my
> first CLX program -- well that was easy).

Some people get nostalgic about Sun NeWs. It was basically a
PostScript interpreter running on your display, and applications could
download PostScript code to run in the display. The design was by
Gosling of Java fame, and you can trace its intellectual lineage in
AWT. It didn't take off because Sun was too proprietary about it so
the competition rallied around the X implementation and started the X
consortium. I wonder if they've learned that lesson with Java.

-- 
Lieven Marchand <···@bewoner.dma.be>
Lambda calculus - Call us a mad club
From: Valeriy E. Ushakov
Subject: Re: CLX: getting a WINDOW object for the gived window id?
Date: 
Message-ID: <90il3c$165r$1@news.spbu.ru>
Janis Dzerins <·····@latnet.lv> wrote:

>> Sure, QUERY-TREE will do (and in my particular case I'm looking for a
>> toplevel, so I won't need to recurse).  But that's not sportsmanlike ;)
> 
> QUERY-TREE returns plain list (list by default) so you could not
> recurse even if you wanted :)

I mean by recursively calling QUERY-TREE on each window in a list.

Anyway I have come up with something like:

(defun window-for-id (id display)
  (declare (type xlib:display display)
	   (type xlib:resource-id id))
  (let ((object (xlib::lookup-resource-id display id)))
    (cond (object
	   (check-type object xlib:window)
	   object)
	  (t
	   (let ((w (xlib::make-window :id id :display display)))
	     (xlib::save-id display id w))))))

that makes shure that the widnow object is cached properly and you can
use EQ safely.

SY, Uwe
-- 
···@ptc.spbu.ru                         |       Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/            |       Ist zu Grunde gehen