LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Thread Tools
Old 09-15-2008, 07:29 AM   #1
234107
LQ Newbie
 
Registered: Sep 2008
Posts: 8
Thanked: 0
Linux - enumerate X window system - window id


[Log in to get rid of this advertisement]
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.

Last edited by 234107; 09-15-2008 at 07:34 AM..
234107 is offline     Reply With Quote
Old 09-15-2008, 07:53 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu (x86), Debian (PPC)
Posts: 3,495
Thanked: 6
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
matthewg42 is offline     Reply With Quote
Old 09-15-2008, 08:09 AM   #3
234107
LQ Newbie
 
Registered: Sep 2008
Posts: 8
Thanked: 0

Original Poster
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 is offline     Reply With Quote
Old 09-15-2008, 10:28 AM   #4
234107
LQ Newbie
 
Registered: Sep 2008
Posts: 8
Thanked: 0

Original Poster
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
234107 is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What's the best X-Window System window manager in your opinion? t3gah Linux - Software 9 12-16-2006 11:10 PM
x-window-system x-window-system-core gabsik Linux - Software 1 07-04-2006 08:12 AM
why mandriva 10.2 gnome2.8 system freezes upon resizing/opening window/new window skaramanger Mandriva 8 08-30-2005 11:22 AM
why mandriva 10.2 gnome2.8 system freezes upon resizing/opening window/new window skaramanger Mandriva 2 08-15-2005 05:38 PM
creating a window in linux with a 'window' variable??! (openCV) vmok82 Programming 1 02-28-2005 04:38 PM


All times are GMT -5. The time now is 07:29 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration