Skip to content

Commit

Permalink
Canvas: Cleanup; fixed move event tracking
Browse files Browse the repository at this point in the history
Mouse_Poll() must do nothing when using Qt mouse events for
tracking cursor position.
  • Loading branch information
skyjake committed May 3, 2012
1 parent fbf866a commit 2baf82a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 40 deletions.
4 changes: 1 addition & 3 deletions doomsday/engine/portable/include/canvas.h
Expand Up @@ -135,9 +135,7 @@ class Canvas : public QGLWidget

protected slots:
void notifyInit();
#ifndef LIBDENG_CANVAS_TRACK_WITH_MOUSE_MOVE_EVENTS
//void trackMousePosition(bool keepTracking = true);
#else
#ifdef LIBDENG_CANVAS_TRACK_WITH_MOUSE_MOVE_EVENTS
void recenterMouse();
#endif

Expand Down
39 changes: 2 additions & 37 deletions doomsday/engine/portable/src/canvas.cpp
Expand Up @@ -117,7 +117,7 @@ struct Canvas::Instance
#endif

#ifdef MACOSX
//CGAssociateMouseAndMouseCursorPosition(false);
//CGAssociateMouseAndMouseCursorPosition(false);
#endif
}

Expand All @@ -133,7 +133,7 @@ struct Canvas::Instance
self->setCursor(QCursor(Qt::ArrowCursor)); // Default cursor.
#endif
#ifdef MACOSX
//CGAssociateMouseAndMouseCursorPosition(true);
//CGAssociateMouseAndMouseCursorPosition(true);
#endif
// Tell the mouse driver that the mouse is untrapped.
mouseGrabbed = false;
Expand Down Expand Up @@ -284,41 +284,6 @@ void Canvas::notifyInit()
}
}

/*
#ifndef LIBDENG_CANVAS_TRACK_WITH_MOUSE_MOVE_EVENTS
void Canvas::trackMousePosition(bool keepTracking)
{
if(d->mouseGrabbed)
{
QPoint curPos = mapFromGlobal(QCursor::pos());
if(!d->prevMousePos.isNull())
{
QPoint delta = curPos - d->prevMousePos;
if(!delta.isNull())
{
Mouse_Qt_SubmitMotion(IMA_POINTER, delta.x(), delta.y());
// Keep the cursor centered.
QPoint mid = rect().center();
QCursor::setPos(mapToGlobal(mid));
d->prevMousePos = mid;
}
}
else
{
d->prevMousePos = curPos;
}
if(keepTracking) QTimer::singleShot(1, this, SLOT(trackMousePosition()));
}
else
{
// Mouse was ungrabbed; reset the tracking.
d->prevMousePos = QPoint();
}
}
#endif
*/

void Canvas::paintGL()
{
if(d->drawCallback)
Expand Down
3 changes: 3 additions & 0 deletions doomsday/engine/portable/src/mouse_qt.cpp
Expand Up @@ -26,6 +26,7 @@
#include "sys_input.h"
#include "window.h"
#include "mouse_qt.h"
#include "canvas.h"
#include <string.h>

#include <QWidget>
Expand Down Expand Up @@ -61,6 +62,7 @@ static void Mouse_Qt_Poll(void)
{
if(!mouseTrapped) return;

#ifndef LIBDENG_CANVAS_TRACK_WITH_MOUSE_MOVE_EVENTS
QWidget* widget = Window_Widget(Window_Main());
if(!widget) return; // Hmm?

Expand All @@ -83,6 +85,7 @@ static void Mouse_Qt_Poll(void)
{
prevMousePos = curPos;
}
#endif
}

static void Mouse_Qt_GetState(mousestate_t *state)
Expand Down

0 comments on commit 2baf82a

Please sign in to comment.