2

Consider the following minimal window manager found online. It compiles and runs fine.

#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
    Display *display;
    Window window;
    XEvent event;
    int s;

    /* open connection with the server */
    display = XOpenDisplay(NULL);
    if (display == NULL)
    {
        fprintf(stderr, "Cannot open display\n");
        exit(1);
    }

    s = DefaultScreen(display);

    /* create window */
    window = XCreateSimpleWindow(display, RootWindow(display, s), 10, 10, 200, 200, 1,
                           BlackPixel(display, s), WhitePixel(display, s));

    /* select kind of events we are interested in */
    XSelectInput(display, window, KeyPressMask | KeyReleaseMask );

    /* map (show) the window */
    XMapWindow(display, window);

    /* event loop */
    while (1)
    {
        XNextEvent(display, &event);

        /* keyboard events */
        if (event.type == KeyPress)
        {
            printf( "KeyPress: %x\n", event.xkey.keycode );

            /* exit on ESC key press */
            if ( event.xkey.keycode == 0x09 )
                break;
        }
        else if (event.type == KeyRelease)
        {
            printf( "KeyRelease: %x\n", event.xkey.keycode );
        }
    }

    /* close connection to server */
    XCloseDisplay(display);

    return 0;
}

In this window manager, I can load a terminal (such as xterm) and the "onboard" on screen keyboard program with ubuntu (server addition, with xinit installed). The onboard on screen keyboard is not sending key input to other windows in this minimal window manager (onboard loads on the bottom region of the screen).

Note that DWM minimalist window manager works as expected (the onboard input gets sent to all other windows). Im unable to find in the DWM source where this kind of thing is considered.

My question is this: How to I make this minialist window manager allow the Onboard on screen keyboard to send input to other windows?

GrahamTheDev
  • 22,724
  • 2
  • 32
  • 64
CygnusVis
  • 31
  • 2
  • Hi Bud, just removed the accessibility tag as that is to do with accessibility in terms of disabled users. Hope you find someone to answer this! – GrahamTheDev Feb 09 '20 at 19:03

1 Answers1

1

Found the solution. I should have been using XSetInputFocus on the terminal, then input goes there correctly.

//e.window is the program window for the program that should get the input.
XSetInputFocus(mDisplay, e.window, RevertToPointerRoot, CurrentTime);
CygnusVis
  • 31
  • 2