• Uncategorized

About c++ : cant-get-XGetInputFocus-when-started-without-a-window-manager

Question Detail

I am using following code to check if an X11 window is currently focussed, so if it has mouse/keyboard input:

        Display* display = XOpenDisplay(NULL);
        if (display == NULL)  {
            return false;
        }

        XID focused;
        int revert_to;
        XGetInputFocus(display, &focused, &revert_to);
        XCloseDisplay(display);

        return focused == windowIdentifier;

Works on Ubuntu.

However, it doesn’t work when I run it in my other VM:
It’s a debian command line, without any window manager or desktop environment, just a plain command line with xorg installed.

I can run the application successfully with sudo xinit <application> :0, but it constantly says the window is unfocussed. I found out that focused is always 1 instead of a valid window id. Yes, you can’t really talk about focusing because there is only one singular graphics window on top of the command line, but in this case it should always return true, not always false.

How can I detect that?

Question Answer

No answer for now.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.