tags:

views:

144

answers:

2

Is it possible to create a window that acts as an overlay on top of another window, say, an icon that you can display in the window's title bar or status bar?

Assume for the purposes of this question that:

  • The window is a foreign window (not owned by my application)
  • The overlay is 16x16 pixels and has a transparent background
  • The overlay is displayed very close to the top-right of the window, and should stay positioned relative to the window's top-right border.
  • The overlay is interested in processing the left-click on the mouse and no other input.
  • The overlay should never have input focus, it should only know when it has been clicked on.

If it is possible, how can it be done? I have tried to create a window and display it in the correct spot, but I never see it; it is as if it doesn't exist. I do get the Window handle, and can even convert it into a GdkWindow object, but I can't get to the point of seeing it.

ETA: An example of what I want to do can be found online, first without what I'm trying to do, and again with it. In this case, look at the menubar, to the right. I'd like to do that for any arbitrary application and have the user be able to click on that little icon to “dock” the window.

+1  A: 

The way a window manager works is by taking a new window and adding the window's decoration as the window's 'parent' to the new window.

You may be able to insert your window between the window manager's decoration window and the existing window's using the XReparent() window api.

codeDr
I'm trying to avoid reparenting and wrapping. AIUI, that approach means that I have to act as a message proxy of sorts and that's fragile. If I could figure it out anyway, I'd just intercept the WM_DELETE ClientMessage.I'm beginning to think that I'm just not cut out for low-level X11 programming. :)
Michael Trausch
A: 

It should be possible to do that using only GDK commands, because they map more or less into the same calls of Xlib. Maybe you don't take into account that you should somehow handle expose events (those ones sent not to your app, but to foreign one)? BTW, how exactly do you convert the XWindow handle to GtkWindow?

as
I don't at the moment. I'm using libwnck to get window handles from it, which may be doing work behind the scenes for me, but when I have to work with the windows, I get an X window from that.
Michael Trausch