Set/reset position of mouse cursor in EGL window …

Dear openFrameworkers, is there some way to set (or reset) the coordinates of my mouse cursor in an ofAppEGLWindow?

if you wish to reposition the mouse for X11 you can use this:

Display *display;
int newX = 0;
int newY = 0;

if ((display = XOpenDisplay(NULL)) == NULL) 
      ofExit(0);
root = DefaultRootWindow(display);
XWarpPointer(display, None, None, 0, 0, 0, 0,newX,newY);
XCloseDisplay(display);

Hey @kashim, thank you very much. Do I need to include anything or can I just use this code snippet as is? Thank you very much!

PS: I’m using an EGL window, no X11 window … if that matters.

maybe you don’t need include nothing, OF include X11 for linux.
This is actually just a dirty trick, i am no expert OF, but this example work on X11 mouse events
thanks to the function XWarpPointer().

sample:

#include "ofMain.h"

class ofApp : public ofBaseApp{
        public:
                Display *display;
                Window root;

                void setup(){

                }

                void update(){

                }

                void draw(){

                }

                void keyPressed(int key){
                        int newX = 10;
                        int newY = 5;
                        if ((display = XOpenDisplay(NULL)) == NULL)
                              ofExit(0);
                        root = DefaultRootWindow(display);
                        XWarpPointer(display, None, None, 0, 0, 0, 0,newX, newY);
                        XCloseDisplay(display);
                }

};

int main(){
        ofSetupOpenGL(1024,768, OF_WINDOW);
        ofRunApp( new ofApp());
}

@kashim Unfortunately …

Oh, I copied the wrong error messages … I’ll deliver the correct ones in a few moments. … XOpenDisplay cannot be found/done …

test include this:

#include <X11/Xlib.h>

the package is this:
libx11-dev