How to know if a window has a menu , identify by WId ( was `Simple App to get window WId` )

Eirik Byrkjeflot Anonsen eirik at
Mon Aug 23 22:23:49 PDT 2010

Aaron Lewis <aaron.lewis1989 at> writes:

> Hi,
> 	Still for the last plasma-globalmenu , now i've got some ideas , i
> could grab the last focused window by remembering WId , and only if that
> window has a `menu' , that will change the variable `lastWid' ..
> So , something like this ..
> In globalmenu.h
> private:
> 	WId wid;
> In globalmenu.cpp:
> void GlobalMenu::windowChanged ( WId wid ) {
> 	// If Window has a menu , remember lastWid;
> 	if ( X11->hasMenu ( lastWid ) ) {
> 		lastWid = wid;
> 	}
> }
> So is there any API like X11->hasMenu ( WId wid ) ?

Unless I totally misunderstand what you are trying to do, probably not.
There is no way X can know whether some random painting commands is a
"menu" or not.

The X server only deals with "windows" (rectangular, potentially
overlapping areas on the screen), allowing an application to listen for
"events" happening to that window (mouse clicks, key presses,
resizes...) and to paint into that window (lines, circles, rectangles,
pixmaps...).  A "menu" is an abstract concept entirely inside the

Also, "last focused window" may not be quite as easy as you think.  The
X input focus may not be on the top-level window.  The most obvious
example of this is any application implementing the XEmbed protocol

And on the other hand, the "menu" may be painted in a window which is
not a top-level window...

(And note that WId is a Qt term and does not exist in X11.)


More information about the xorg mailing list