How can I prevent Gnome from showing two windows when doing alt-tab? (c++ qt app)
Asked Answered
P

2

7

(see edits)

I'm developing a QT/c++ application under gnome.

The application a main window and QListBox child window.

Both of these windows show up as separate main windows when I alt-tab away from the application.

How can I make it so that only one window is shown when I (or later the user) uses alt-tab?

I am guessing this behavior comes because one main window doesn't clip the subwindow - the subwindow extends the boundary of the main window. Gnome has bad alt-tab behavior for a number of other applications too, showing modal dialog boxes separately from main windows. But in the case of my app, this is really annoying.

I am thinking I could make a giant transparent window that includes both existing windows. But it would be nicer to find a "clean" solution.

(the most logical guess is indeed that it has something to do with window flags. I've tried every reasonable combination of flags I could think of. The window types are described here)

Edit: The app has a QWidget as its main window (Not QMainWindow), QListView is contained in the QWidget object and created by passing a point to the main window. is styled with Qt::Tool | Qt::FramelessWindowHint.

Edit2: The Qt::X11BypassWindowManagerHint style does work to remove the window from the alt-tab list. The problem is that it also makes the window "unmanaged" so it cover the other windows. I could manaully hide whenever I lose focus - prize now for a better solution.

Postmortem answered 24/8, 2010 at 3:42 Comment(2)
I'm guessing it has something to do with the window flags... for instance, if you made it a tool window, would it grab both then? When I use open office, for example, gnome doesn't tab through its floating tool windows, but only the main ones.Bergren
I'm assuming the QListBox has its parent window pointer set to a QMainWindow? Any chance at a skeleton of minimum-required code to generate this issue?Phantasy
W
3

When creating a window for your QListBox window set a Qt::Tool window flag in its constructor or later with setWindowFlags function call. Here is some code snippet(I omitted the headers):

int main(int argc, char** argv)
{
    QApplication app(argc, argv);
    QMainWindow mw;
    mw.show();
    QWidget toolWindow(&mw, Qt::Window|Qt::Tool);
    QHBoxLayout layout(&toolWindow);
    toolWindow.setLayout(&layout);
    QListView lv(&toolWindow);
    layout.addWidget(&lv);
    toolWindow.show();

    return app.exec();
}

I've tested this on my Debian sid box (Gnome 2.30, metacity 2.30.1) with freshly created user: image proof on answer to question #3553428.

If this is not what you wanted, then please name the software which works correctly or you may check it yourself. To do this run xprop in terminal window and click on the window you are interested in. The output will contain window flags. The one you are interested in is _NET_WM_WINDOW_TYPE(ATOM). For the tool window(i.e. not listed in alt-tab) this flag is:

_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_UTILITY, _NET_WM_WINDOW_TYPE_NORMAL

If the window with these flags is not a toolbox window then something is wrong with your window manager or you have personally set such behavior.

Woodyard answered 30/8, 2010 at 20:49 Comment(3)
Well, you've got the only answer - the problem is, you are wrong. I'll just hold off. Maybe award it if you edit to reflect the comments in my question...Postmortem
Well, I think the solution is as in my edits - you need to use the Qt::X11BypassWindowManagerHint style with all it's problems. But hey, if you've gone that much trouble, you're closer than anyone else...Postmortem
But frickin stack overflow might have eaten the bonus since I can't see them appearing. Bad SO. This place ain't what it used to be...Postmortem
A
1

You can try it by hand with the wmctrl tool. With "-r -b SOMETHING" you can modify NET_WM arguments to it. Try these in [1].

If this works, you can add them in with Xlib-Calls (If you get to know X11 Window Number from Qt. I am sure that's possible).

[1] http://standards.freedesktop.org/wm-spec/1.3/ar01s05.html
Adhibit answered 2/9, 2010 at 9:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.