简体   繁体   中英

How to disable the automatic middle-click mouse events in X (Xlib)?

I am currently implementing a program in X11 using C. I got the program to handle right- and left-click events, however middle-clicking poses a problem. It seems my window manager (Gnome on Ubuntu 9.10) thinks it's better if, instead of having a single middle-click, I should have a series of other clicks instead. I assume it's got something to do with the middle-click being used for copying-pasting. I really don't want this, though, as I'm making a full-screen application with OpenGL, and such things aren't appropriate. Is there any way to have the middle mouse button just working like any other button?

My current code goes something like this:

switch(currentXEvent.type) {
    case ButtonPress:
        switch(currentXEvent.xbutton.button) {
            case 1:
                leftMouseButton(currentXEvent.xbutton.x, currentXEvent.xbutton.y);
                break;
            case 2:
                middleMouseButton(currentXEvent.xbutton.x, currentXEvent.xbutton.y);
                break;
        }
}

My difficulty is that it behaves like leftMouseButton() has been pressed. Any ideas?

To do this, you have to grab controls from the server. Then the window manager is left out of the processing chain. The most comfortable way is to use libSDL . It creates the appropriate context for a fullscreen OpenGL application and is easier to handle than Xlib+GLX.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM