开发者

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

开发者 https://www.devze.com 2023-01-12 15:48 出处:网络
(see edits) I\'m developing a QT/c++ application under gnome. The application a main window and QListBox child window.

(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.


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:

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

.

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.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消