rickst29
16th December 2010, 09:11
I'll ask here in the forum, because I keep "crazy" hours in comparison to EU. Thanks in advance for any-all comments and suggestions. This is in preparation for attempting a change in Qt itself, not in "user code".
When I'm done providing background information, the questions are very simple- but I just don't know the answers.
Within /src/kernel/gui/kernel/qevent, QMouseEvent is given multiple declarations, and it's re-cast dynamically. Here's the relevant snippet of the current (4.7.1) declarations in qevent.h, lines 82-105:
public:
QMouseEvent(Type type, const QPoint &pos, Qt::MouseButton button,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
Qt::MouseButton button, Qt::MouseButtons buttons,
Qt::KeyboardModifiers modifiers);
~QMouseEvent();
inline const QPoint &pos() const { return p; }
inline const QPoint &globalPos() const { return g; }
inline int x() const { return p.x(); }
inline int y() const { return p.y(); }
inline int globalX() const { return g.x(); }
inline int globalY() const { return g.y(); }
inline Qt::MouseButton button() const { return b; }
inline Qt::MouseButtons buttons() const { return mouseState; }
static QMouseEvent *createExtendedMouseEvent(Type type, const QPointF &pos,
const QPoint &globalPos, Qt::MouseButton button,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
inline bool hasExtendedInfo() const { return reinterpret_cast<const QMouseEvent *>(d) == this; }
QPointF posF() const;
#ifdef QT3_SUPPORT
// followed by irrelevant QT3 constructors, etc.
The "Extended Info" was introduced with 4.4 (a "minor" Release), and it attempts to provide the new "Global Positioning" as a set of automatically-paired floating point values (rather than the int values in the previous constructor.) This is done dynamically via the "reinterpret_cast" test, SOMEHOW. The same thing is done with QKeyEvent at line 235 of the header file, adding declaration of three quint32 "native" data fields.
- - - -
Ultimately, my objective is the partial support of "gaming mice" buttons in the X11 platform. I can't do this, WITH backward compatibility, by simply using the current "button-causing-the-event" field as the unsigned integer which X11 actually provides to us. (Binary Qt programs created within a "Qt 4.8" environment would have different button numbers for the same bits in "Qt.MouseButton" enum provided by library code in boxes running 4.0 thru 4.7). Maybe I need to create and manipulate an "extended info" data field, of type quint32, to hold a compatible bit-mask enum wide enough to add buttons 10-32.
And if so: Can I add a SECOND *createExtendedMouseEventVersion2 signature, adding this field? And maybe also another boolean test function result, "hasExtendedInfoV2() ? If so, what kind of test can I do for a dynamic test to declare and utilize the field?
Please advise me of your ideas on "smart" ways to create this enhancement, while preserving BC with all previous QT4 Releases. And again, my thanks for your patience and expertise in giving me "a clue". :)
When I'm done providing background information, the questions are very simple- but I just don't know the answers.
Within /src/kernel/gui/kernel/qevent, QMouseEvent is given multiple declarations, and it's re-cast dynamically. Here's the relevant snippet of the current (4.7.1) declarations in qevent.h, lines 82-105:
public:
QMouseEvent(Type type, const QPoint &pos, Qt::MouseButton button,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
Qt::MouseButton button, Qt::MouseButtons buttons,
Qt::KeyboardModifiers modifiers);
~QMouseEvent();
inline const QPoint &pos() const { return p; }
inline const QPoint &globalPos() const { return g; }
inline int x() const { return p.x(); }
inline int y() const { return p.y(); }
inline int globalX() const { return g.x(); }
inline int globalY() const { return g.y(); }
inline Qt::MouseButton button() const { return b; }
inline Qt::MouseButtons buttons() const { return mouseState; }
static QMouseEvent *createExtendedMouseEvent(Type type, const QPointF &pos,
const QPoint &globalPos, Qt::MouseButton button,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
inline bool hasExtendedInfo() const { return reinterpret_cast<const QMouseEvent *>(d) == this; }
QPointF posF() const;
#ifdef QT3_SUPPORT
// followed by irrelevant QT3 constructors, etc.
The "Extended Info" was introduced with 4.4 (a "minor" Release), and it attempts to provide the new "Global Positioning" as a set of automatically-paired floating point values (rather than the int values in the previous constructor.) This is done dynamically via the "reinterpret_cast" test, SOMEHOW. The same thing is done with QKeyEvent at line 235 of the header file, adding declaration of three quint32 "native" data fields.
- - - -
Ultimately, my objective is the partial support of "gaming mice" buttons in the X11 platform. I can't do this, WITH backward compatibility, by simply using the current "button-causing-the-event" field as the unsigned integer which X11 actually provides to us. (Binary Qt programs created within a "Qt 4.8" environment would have different button numbers for the same bits in "Qt.MouseButton" enum provided by library code in boxes running 4.0 thru 4.7). Maybe I need to create and manipulate an "extended info" data field, of type quint32, to hold a compatible bit-mask enum wide enough to add buttons 10-32.
And if so: Can I add a SECOND *createExtendedMouseEventVersion2 signature, adding this field? And maybe also another boolean test function result, "hasExtendedInfoV2() ? If so, what kind of test can I do for a dynamic test to declare and utilize the field?
Please advise me of your ideas on "smart" ways to create this enhancement, while preserving BC with all previous QT4 Releases. And again, my thanks for your patience and expertise in giving me "a clue". :)