Qt 4.8
Public Functions | Protected Variables | List of all members
QWSMouseHandler Class Referenceabstract

The QWSMouseHandler class is a base class for mouse drivers in Qt for Embedded Linux. More...

#include <qmouse_qws.h>

Inheritance diagram for QWSMouseHandler:
QDirectFBMouseHandler QQnxMouseHandler QVFbMouseHandler QWSCalibratedMouseHandler QWSPcMouseHandler QIntMouseHandler QWSLinuxInputMouseHandler QWSLinuxTPMouseHandler QWSTslibMouseHandler

Public Functions

virtual void calibrate (const QWSPointerCalibrationData *)
 This virtual function allows subclasses of QWSMouseHandler to set the calibration information passed in the given data. More...
 
virtual void clearCalibration ()
 This virtual function allows subclasses of QWSMouseHandler to clear the calibration information. More...
 
virtual void getCalibration (QWSPointerCalibrationData *) const
 This virtual function allows subclasses of QWSMouseHandler to fill in the device coordinates in data with values that correspond to screen coordinates that are already in data. More...
 
void limitToScreen (QPoint &pt)
 Ensures that the given position is within the screen's boundaries, changing the position if necessary. More...
 
void mouseChanged (const QPoint &pos, int bstate, int wheel=0)
 Notifies the system of a new mouse event. More...
 
const QPointpos () const
 Returns the current mouse position. More...
 
 QWSMouseHandler (const QString &driver=QString(), const QString &device=QString())
 Constructs a mouse driver. More...
 
virtual void resume ()=0
 Implement this function to resume reading and handling mouse events, e. More...
 
void setScreen (const QScreen *screen)
 Sets the screen for this mouse driver to be the given screen. More...
 
virtual void suspend ()=0
 Implement this function to suspend reading and handling of mouse events, e. More...
 
virtual ~QWSMouseHandler ()
 Destroys this mouse driver. More...
 

Protected Variables

QWSMouseHandlerPrivated_ptr
 
QPointmousePos
 

Detailed Description

The QWSMouseHandler class is a base class for mouse drivers in Qt for Embedded Linux.

Note that this class is only available in Qt for Embedded Linux.

Qt for Embedded Linux provides ready-made drivers for several mouse protocols, see the Qt for Embedded Linux Pointer Handling{pointer handling} documentation for details. Custom mouse drivers can be implemented by subclassing the QWSMouseHandler class and creating a mouse driver plugin (derived from QMouseDriverPlugin). The default implementation of the QMouseDriverFactory class will automatically detect the plugin, and load the driver into the server application at run-time using Qt's How to Create Qt Plugins.

The mouse driver receives mouse events from the system device and encapsulates each event with an instance of the QWSEvent class which it then passes to the server application (the server is responsible for propagating the event to the appropriate client). To receive mouse events, a QWSMouseHandler object will usually create a QSocketNotifier object for the given device. The QSocketNotifier class provides support for monitoring activity on a file descriptor. When the socket notifier receives data, it will call the mouse driver's mouseChanged() function to send the event to the Qt for Embedded Linux server application for relaying to clients.

If you are creating a driver for a device that needs calibration or noise reduction, such as a touchscreen, use the QWSCalibratedMouseHandler subclass instead to take advantage of the calibrate() and clearCalibration() functions. The Mouse Calibration demonstrates how to write a simple program using the mechanisms provided by the QWSMouseHandler class to calibrate a mouse driver.

Note that when deriving from the QWSMouseHandler class, the resume() and suspend() functions must be reimplemented to control the flow of mouse input, i.e., the default implementation does nothing. Reimplementations of these functions typically call the QSocketNotifier::setEnabled() function to enable or disable the socket notifier, respectively.

In addition, QWSMouseHandler provides the setScreen() function that allows you to specify a screen for your mouse driver and the limitToScreen() function that ensures that a given position is within this screen's boundaries (changing the position if necessary). Finally, QWSMouseHandler provides the pos() function returning the current mouse position.

See also
QMouseDriverPlugin, QMouseDriverFactory, {Qt for Embedded Linux Pointer Handling}

Definition at line 66 of file qmouse_qws.h.

Constructors and Destructors

◆ QWSMouseHandler()

QWSMouseHandler::QWSMouseHandler ( const QString driver = QString(),
const QString device = QString() 
)
explicit

Constructs a mouse driver.

The driver and device arguments are passed by the QWS_MOUSE_PROTO environment variable.

Call the QWSServer::setMouseHandler() function to make the newly created mouse driver, the primary driver. Note that the primary driver is controlled by the system, i.e., the system will delete it upon exit.

Definition at line 223 of file qmouse_qws.cpp.

225 {
226 }
QPoint & mousePos
Definition: qmouse_qws.h:87
QWSMouseHandlerPrivate * d_ptr
Definition: qmouse_qws.h:88
static QPoint mousePosition

◆ ~QWSMouseHandler()

QWSMouseHandler::~QWSMouseHandler ( )
virtual

Destroys this mouse driver.

Do not call this function if this driver is the primary mouse driver, i.e., if QWSServer::setMouseHandler() function has been called passing this driver as argument. The primary mouse driver is deleted by the system.

Definition at line 236 of file qmouse_qws.cpp.

237 {
238  delete d_ptr;
239 }
QWSMouseHandlerPrivate * d_ptr
Definition: qmouse_qws.h:88

Functions

◆ calibrate()

QWSMouseHandler::calibrate ( const QWSPointerCalibrationData data)
inlinevirtual

This virtual function allows subclasses of QWSMouseHandler to set the calibration information passed in the given data.

Note that the default implementation does nothing.

See also
QWSCalibratedMouseHandler::calibrate(), clearCalibration()

Reimplemented in QWSCalibratedMouseHandler, QIntMouseHandler, and QWSTslibMouseHandler.

Definition at line 74 of file qmouse_qws.h.

74 {}

◆ clearCalibration()

QWSMouseHandler::clearCalibration ( )
inlinevirtual

This virtual function allows subclasses of QWSMouseHandler to clear the calibration information.

Note that the default implementation does nothing.

See also
QWSCalibratedMouseHandler::clearCalibration(), calibrate()

Reimplemented in QWSCalibratedMouseHandler, QIntMouseHandler, and QWSTslibMouseHandler.

Definition at line 73 of file qmouse_qws.h.

73 {}

◆ getCalibration()

QWSMouseHandler::getCalibration ( QWSPointerCalibrationData data) const
inlinevirtual

This virtual function allows subclasses of QWSMouseHandler to fill in the device coordinates in data with values that correspond to screen coordinates that are already in data.

Note that the default implementation does nothing.

Reimplemented in QWSCalibratedMouseHandler.

Definition at line 75 of file qmouse_qws.h.

75 {}

◆ limitToScreen()

void QWSMouseHandler::limitToScreen ( QPoint position)

Ensures that the given position is within the screen's boundaries, changing the position if necessary.

See also
pos(), setScreen()

Definition at line 248 of file qmouse_qws.cpp.

Referenced by QWSLinuxInputMousePrivate::readMouseData(), QIntMouseHandler::readMouseData(), QDirectFBMouseHandlerPrivate::readMouseData(), QWSPcMouseHandlerPrivate::sendEvent(), and QQnxMouseHandler::socketActivated().

249 {
250  position.setX(qMin(d_ptr->screen->deviceWidth() - 1, qMax(0, position.x())));
251  position.setY(qMin(d_ptr->screen->deviceHeight() - 1, qMax(0, position.y())));
252 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int deviceWidth() const
Returns the physical width of the framebuffer device in pixels.
Definition: qscreen_qws.h:233
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
const QScreen * screen
Definition: qmouse_qws.cpp:114
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
Definition: qpoint.h:137
int deviceHeight() const
Returns the full height of the framebuffer device in pixels.
Definition: qscreen_qws.h:234
QWSMouseHandlerPrivate * d_ptr
Definition: qmouse_qws.h:88
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
Definition: qpoint.h:134

◆ mouseChanged()

void QWSMouseHandler::mouseChanged ( const QPoint position,
int  state,
int  wheel = 0 
)

Notifies the system of a new mouse event.

This function updates the current mouse position and sends the event to the Qt for Embedded Linux server application for delivery to the correct widget. Note that a custom mouse driver must call this function whenever it wants to deliver a new mouse event.

The given position is the global position of the mouse cursor. The state parameter is a bitmask of the Qt::MouseButton enum's values, indicating which mouse buttons are pressed. The wheel parameter is the delta value of the mouse wheel as returned by QWheelEvent::delta().

See also
pos()

Definition at line 285 of file qmouse_qws.cpp.

Referenced by QWSLinuxInputMousePrivate::readMouseData(), QIntMouseHandler::readMouseData(), QVFbMouseHandler::readMouseData(), QDirectFBMouseHandlerPrivate::readMouseData(), QWSLinuxTPMouseHandlerPrivate::readMouseData(), QWSPcMouseHandlerPrivate::sendEvent(), QWSCalibratedMouseHandler::sendFiltered(), and QQnxMouseHandler::socketActivated().

286 {
287  mousePos = position + d_ptr->screen->offset();
288  QWSServer::sendMouseEvent(mousePos, state, wheel);
289 }
static void sendMouseEvent(const QPoint &pos, int state, int wheel=0)
Send a mouse event.
QPoint & mousePos
Definition: qmouse_qws.h:87
const QScreen * screen
Definition: qmouse_qws.cpp:114
QWSMouseHandlerPrivate * d_ptr
Definition: qmouse_qws.h:88
QPoint offset() const
Returns the logical offset of the screen, i.

◆ pos()

const QPoint & QWSMouseHandler::pos ( ) const
inline

Returns the current mouse position.

See also
mouseChanged(), limitToScreen()

Definition at line 82 of file qmouse_qws.h.

Referenced by QIntMouseHandler::readMouseData(), QWSPcMouseHandlerPrivate::sendEvent(), and QWSCalibratedMouseHandler::sendFiltered().

82 { return mousePos; }
QPoint & mousePos
Definition: qmouse_qws.h:87

◆ resume()

void QWSMouseHandler::resume ( )
pure virtual

Implement this function to resume reading and handling mouse events, e.

g., call the QSocketNotifier::setEnabled() function to enable the socket notifier.

See also
suspend()

Implemented in QWSLinuxTPMouseHandler, QDirectFBMouseHandler, QIntMouseHandler, QWSPcMouseHandler, QWSTslibMouseHandler, QWSLinuxInputMouseHandler, QQnxMouseHandler, and QVFbMouseHandler.

◆ setScreen()

void QWSMouseHandler::setScreen ( const QScreen screen)

Sets the screen for this mouse driver to be the given screen.

Since
4.2
See also
limitToScreen()

Definition at line 264 of file qmouse_qws.cpp.

Referenced by QVFbScreen::initDevice(), and QWSServerPrivate::newMouseHandler().

265 {
266  d_ptr->screen = (screen ? screen : qt_screen);
267 }
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
const QScreen * screen
Definition: qmouse_qws.cpp:114
QWSMouseHandlerPrivate * d_ptr
Definition: qmouse_qws.h:88

◆ suspend()

void QWSMouseHandler::suspend ( )
pure virtual

Implement this function to suspend reading and handling of mouse events, e.

g., call the QSocketNotifier::setEnabled() function to disable the socket notifier.

See also
resume()

Implemented in QIntMouseHandler, QWSLinuxTPMouseHandler, QQnxMouseHandler, QVFbMouseHandler, QDirectFBMouseHandler, QWSPcMouseHandler, QWSTslibMouseHandler, and QWSLinuxInputMouseHandler.

Properties

◆ d_ptr

QWSMouseHandlerPrivate* QWSMouseHandler::d_ptr
protected

Definition at line 88 of file qmouse_qws.h.

Referenced by limitToScreen(), mouseChanged(), setScreen(), and ~QWSMouseHandler().

◆ mousePos

QPoint& QWSMouseHandler::mousePos
protected

The documentation for this class was generated from the following files: