LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Linux - enumerate X window system - window id (https://www.linuxquestions.org/questions/programming-9/linux-enumerate-x-window-system-window-id-670009/)

234107 09-15-2008 06:29 AM

Linux - enumerate X window system - window id
 
Hello,

I have some problems how to find id of some window in X. I'm lost :\

Can you pick me some books, functions, API's or else how to find window id? The only thing that i want to do is to send a message to some window, but i need to know the id(windows terminology - handle).

Thanks in advance...

EDIT: To describe best the problem, in MS windows for example there are several ways to get window handle... like FindWindow(...). Wait, wait, wait... yea it's MS, don't blame me. Thats why i want to start exploring Linux dev with few simple tasks so any info is most appreciated.

matthewg42 09-15-2008 06:53 AM

How do you wish to specify the window to identify? To click on it?

If so you can use the xwininfo command. This changes the cursor to a cross hairs, and when you click on a window, the program output something like this:
Code:

xwininfo: Window id: 0x4000007 "matthew@chubby: ~/bin - Shell - Konsole"

  Absolute upper-left X:  0
  Absolute upper-left Y:  23
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 1680
  Height: 978
  Depth: 24
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x20 (installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +0+23  -0+23  -0-49  +0-49
  -geometry 1680x978+0+0

You could post-process this and extract the window id:
Code:

xwininfo |grep 'Window id:' |cut -d" " -f4

234107 09-15-2008 07:09 AM

Really thanks, but is there a way to do it in C/C++ ? Currently im trying to debug panels like XFCE panel and etc. to find out how is it implented there... u know when u click on the title of some window and the window is popping up. So that means it should send to the window id _NET_ACTIVE_WINDOW...

234107 09-15-2008 09:28 AM

I think i found the answer and it is XQueryTree. Thanks again matthewg42. I saw the source of xwininfo and it helped me quite much. Also with this tool you can check if you are on the right way ;)


All times are GMT -5. The time now is 09:44 AM.