Skip to content

Instantly share code, notes, and snippets.

@mnogu
Created May 4, 2010 11:48
Show Gist options
  • Select an option

  • Save mnogu/389313 to your computer and use it in GitHub Desktop.

Select an option

Save mnogu/389313 to your computer and use it in GitHub Desktop.
#include <QtGui/QApplication>
#include <QtGui/QWidget>
#include <QtGui/QX11Info>
#include <X11/Xutil.h>
// Qt version of gtk_window_set_accept_focus().
// Qt 4.7 snapshot has Qt::WA_X11DoNotAcceptFocus.
void qt_window_set_accept_focus(QWidget *window, bool setting)
{
XWMHints *wmhints = XGetWMHints(QX11Info::display(), window->winId());
if (!wmhints)
wmhints = XAllocWMHints();
wmhints->flags = InputHint;
wmhints->input = setting ? True : False;
XSetWMHints(QX11Info::display(), window->winId(), wmhints);
XFree(wmhints);
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget widget;
qt_window_set_accept_focus(&widget, false);
widget.show();
return app.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment