diff --git a/src/autotype/xcb/AutoTypeXCB.cpp b/src/autotype/xcb/AutoTypeXCB.cpp index 40127c9a7..21a1a993c 100644 --- a/src/autotype/xcb/AutoTypeXCB.cpp +++ b/src/autotype/xcb/AutoTypeXCB.cpp @@ -30,6 +30,8 @@ AutoTypePlatformX11::AutoTypePlatformX11() m_atomString = XInternAtom(m_dpy, "STRING", True); m_atomUtf8String = XInternAtom(m_dpy, "UTF8_STRING", True); m_atomNetActiveWindow = XInternAtom(m_dpy, "_NET_ACTIVE_WINDOW", True); + m_atomTransientFor = XInternAtom(m_dpy, "WM_TRANSIENT_FOR", True); + m_atomWindow = XInternAtom(m_dpy, "WINDOW", True); m_classBlacklist << "desktop_window" << "gnome-panel"; // Gnome @@ -262,23 +264,31 @@ QStringList AutoTypePlatformX11::windowTitlesRecursive(Window window) bool AutoTypePlatformX11::isTopLevelWindow(Window window) { + bool result = false; + Atom type = None; int format; unsigned long nitems; unsigned long after; - unsigned char* data = Q_NULLPTR; + unsigned char* data = nullptr; + + // Check if the window has WM_STATE atom and it is not Withdrawn int retVal = XGetWindowProperty( m_dpy, window, m_atomWmState, 0, 2, False, m_atomWmState, &type, &format, &nitems, &after, &data); - bool result = false; - if (retVal == 0 && data) { if (type == m_atomWmState && format == 32 && nitems > 0) { - qint32 state = static_cast(*data); - result = (state != WithdrawnState); + result = (static_cast(*data) != WithdrawnState); } - XFree(data); + } else { + // See if this is a transient window without WM_STATE + retVal = XGetWindowProperty( + m_dpy, window, m_atomTransientFor, 0, 1, False, m_atomWindow, &type, &format, &nitems, &after, &data); + if (retVal == 0 && data) { + result = true; + XFree(data); + } } return result; diff --git a/src/autotype/xcb/AutoTypeXCB.h b/src/autotype/xcb/AutoTypeXCB.h index 5f4795552..4e22d417a 100644 --- a/src/autotype/xcb/AutoTypeXCB.h +++ b/src/autotype/xcb/AutoTypeXCB.h @@ -68,7 +68,6 @@ private: void updateKeymap(); bool isRemapKeycodeValid(); int AddKeysym(KeySym keysym); - void AddModifier(KeySym keysym); void SendKeyEvent(unsigned keycode, bool press); void SendModifiers(unsigned int mask, bool press); int GetKeycode(KeySym keysym, unsigned int* mask); @@ -84,6 +83,8 @@ private: Atom m_atomString; Atom m_atomUtf8String; Atom m_atomNetActiveWindow; + Atom m_atomTransientFor; + Atom m_atomWindow; QSet m_classBlacklist; XkbDescPtr m_xkb;