14.8 Selecting Events

selectEvents selects events for all the windows of the application.

Example 14-11. basecalc — the selectEvents routine

selectEvents ()
{
    int win;

    /* Window behind calculator */
    XSelectInput (display, calcWin, KeyPressMask|KeyReleaseMask);

    /* Where results are drawn */
    XSelectInput (display, dispWin, ExposureMask);

    /* Pad windows */
    for (win = 1; win < NBUTTONS; win++)
        XSelectInput (display, Buttons[win].ID,
            ExposureMask|ButtonPressMask|ButtonReleaseMask|
            EnterWindowMask|LeaveWindowMask);
}

The entire calculator window requires key events, because we want to be able to operate the calculator from the keyboard as well as with the pointer.

The display window (dispWin) requires exposure events, because it must be able to refresh itself for the usual reasons.

All other windows (pads) require exposure events for refresh, button events for selection, and border crossing events so that the button only needs to be released within a pad to activate the pad. This last feature makes it easier to work quickly with the calculator.

Get XLIB Programming Manual, Rel. 5, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.