rittchat
7th April 2011, 10:01
Hi
I want to get system wide mouse release event in Linux. I created a ruApplication class from QApplication.
The header file is
#include <QApplication>
#include <QAbstractEventDispatcher>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
class ruApplication : public QApplication
{
Q_OBJECT
public:
explicit ruApplication(int c, char *v[]);
protected:
bool x11EventFilter(XEvent *);
static bool ruEventFilter(void *message);
public slots:
private:
QAbstractEventDispatcher *evInstance;
};
The cpp file is
ruApplication::ruApplication(int c, char *v[]) :
QApplication(c,v)
{
evInstance = QAbstractEventDispatcher::instance();
evInstance->setEventFilter((QAbstractEventDispatcher::EventFil ter)ruEventFilter);
}
bool ruApplication::x11EventFilter(XEvent *evt)
{
if(evt->type == ButtonRelease)
qDebug("x11Event Filter");
return false;
}
bool ruApplication::ruEventFilter(void *message)
{
XEvent *evt;
evt = (XEvent *) message;
if(evt->type == ButtonRelease)
qDebug("ruEvent Filter");
return false;
}
The main.cpp is
int main(int argc, char *argv[])
{
ruApplication a(argc, argv);
Dialog w();
w.show();
return a.exec();
}
But when I am clicking out side the client area of the dialog, I am not getting any mouse event. What am I doing wrong? If this is not the correct way of doing this, can you suggest me, how to get system wide mouse release event in Linux?
thanks
I want to get system wide mouse release event in Linux. I created a ruApplication class from QApplication.
The header file is
#include <QApplication>
#include <QAbstractEventDispatcher>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
class ruApplication : public QApplication
{
Q_OBJECT
public:
explicit ruApplication(int c, char *v[]);
protected:
bool x11EventFilter(XEvent *);
static bool ruEventFilter(void *message);
public slots:
private:
QAbstractEventDispatcher *evInstance;
};
The cpp file is
ruApplication::ruApplication(int c, char *v[]) :
QApplication(c,v)
{
evInstance = QAbstractEventDispatcher::instance();
evInstance->setEventFilter((QAbstractEventDispatcher::EventFil ter)ruEventFilter);
}
bool ruApplication::x11EventFilter(XEvent *evt)
{
if(evt->type == ButtonRelease)
qDebug("x11Event Filter");
return false;
}
bool ruApplication::ruEventFilter(void *message)
{
XEvent *evt;
evt = (XEvent *) message;
if(evt->type == ButtonRelease)
qDebug("ruEvent Filter");
return false;
}
The main.cpp is
int main(int argc, char *argv[])
{
ruApplication a(argc, argv);
Dialog w();
w.show();
return a.exec();
}
But when I am clicking out side the client area of the dialog, I am not getting any mouse event. What am I doing wrong? If this is not the correct way of doing this, can you suggest me, how to get system wide mouse release event in Linux?
thanks