Recent

Author Topic: X11 - IsWindow ?  (Read 7647 times)

Dibo

  • Hero Member
  • *****
  • Posts: 1045
X11 - IsWindow ?
« on: August 26, 2010, 05:39:57 pm »
Hi,

On windows, if I have handle to window (HWND), I can check if it exists calling function:
IsWindow(window: HWND): Boolean

Is there a similar function in X11? I'm looking in xlib, xutil units but I don't see anything interesting. I have some TWindow and I want check if it still exists. Now I'm calling some XEvent and checking for BadWindow X11 error code :P

Regards and sorry for English

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
Re: X11 - IsWindow ?
« Reply #1 on: August 26, 2010, 05:47:06 pm »
I wrote some code to list and activate top-level windows:
http://www.theo.ch/lazarus/winlist.zip
Maybe it helps.

Dibo

  • Hero Member
  • *****
  • Posts: 1045
Re: X11 - IsWindow ?
« Reply #2 on: August 26, 2010, 08:03:26 pm »
I have not found exactly such a function but I use XGetWindowAttributes from your sources instead of checking events. At the end I'm Checking for BadWindow. It's good for me. Thanks

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
Re: X11 - IsWindow ?
« Reply #3 on: August 27, 2010, 12:56:06 am »
It should be easy. You get a list of all toplevel windows.
This should be enough to check if a XID (HWND) exists:

Code: Pascal  [Select]
  1. Function IsWindow(XID:Cardinal):Boolean;
  2. var xwl:TXWindowList;
  3. begin
  4. xwl:=TXWindowList.Create;
  5. xwl.UpdateWindowList;
  6. Result:=xwl.WindowList.IndexOf(XID)>-1;
  7. xwl.free;
  8. end;


You can also check by window name.
« Last Edit: August 27, 2010, 12:58:31 am by theo »

Dibo

  • Hero Member
  • *****
  • Posts: 1045
Re: X11 - IsWindow ?
« Reply #4 on: August 27, 2010, 10:17:41 am »
Thanks!