LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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
  Search this Thread
Old 09-15-2008, 06:29 AM   #1
234107
LQ Newbie
 
Registered: Sep 2008
Posts: 8

Rep: Reputation: 0
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.

Last edited by 234107; 09-15-2008 at 06:34 AM.
 
Old 09-15-2008, 06:53 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
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
 
Old 09-15-2008, 07:09 AM   #3
234107
LQ Newbie
 
Registered: Sep 2008
Posts: 8

Original Poster
Rep: Reputation: 0
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...
 
Old 09-15-2008, 09:28 AM   #4
234107
LQ Newbie
 
Registered: Sep 2008
Posts: 8

Original Poster
Rep: Reputation: 0
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 10:10 PM
x-window-system x-window-system-core gabsik Linux - Software 1 07-04-2006 07:12 AM
why mandriva 10.2 gnome2.8 system freezes upon resizing/opening window/new window skaramanger Mandriva 8 08-30-2005 10:22 AM
why mandriva 10.2 gnome2.8 system freezes upon resizing/opening window/new window skaramanger Mandriva 2 08-15-2005 04:38 PM
creating a window in linux with a 'window' variable??! (openCV) vmok82 Programming 1 02-28-2005 03:38 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
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
Twitter: @linuxquestions
Open Source Consulting | Domain Registration