X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Fglwidget.cpp;h=ead7268ccd45f9615daedb2324270b72c68a5e7c;hb=94d59c2c8c14b9ac51dffd117ec507418b4d0881;hp=058f9e0f150b5b07977f338a9d9449a2b11fe7de;hpb=5d76d651dfc3aa0a2e810e6b6db2ae8a2e34c53e;p=virtualjaguar diff --git a/src/gui/glwidget.cpp b/src/gui/glwidget.cpp index 058f9e0..ead7268 100644 --- a/src/gui/glwidget.cpp +++ b/src/gui/glwidget.cpp @@ -26,10 +26,11 @@ GLWidget::GLWidget(QWidget * parent/*= 0*/): QGLWidget(parent), texture(0), textureWidth(0), textureHeight(0), buffer(0), rasterWidth(326), rasterHeight(240), - offset(0) + offset(0), hideMouseTimeout(60) { // Screen pitch has to be the texture width (in 32-bit pixels)... JaguarSetScreenPitch(1024); + setMouseTracking(true); } @@ -113,7 +114,7 @@ void GLWidget::paintGL() } -void GLWidget::resizeGL(int width, int height) +void GLWidget::resizeGL(int /*width*/, int /*height*/) { //kludge [No, this is where it belongs!] rasterHeight = (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL); @@ -143,6 +144,42 @@ void GLWidget::CreateTextures(void) } +void GLWidget::HandleMouseHiding(void) +{ + // Mouse watchdog timer handling. Basically, if the timeout value is + // greater than zero, decrement it. Otherwise, check for zero, if so, then + // hide the mouse and set the hideMouseTimeout value to -1 to signal that + // the mouse has been hidden. + if (hideMouseTimeout > 0) + hideMouseTimeout--; + else if (hideMouseTimeout == 0) + { + hideMouseTimeout--; + qApp->setOverrideCursor(Qt::BlankCursor); + } +} + + +// We use this as part of a watchdog system for hiding/unhiding the mouse. This +// part shows the mouse (if hidden) and resets the watchdog timer. +void GLWidget::CheckAndRestoreMouseCursor(void) +{ + // Has the mouse been hidden? (-1 means mouse was hidden) + if (hideMouseTimeout == -1) + qApp->restoreOverrideCursor(); + + hideMouseTimeout = 60; +} + + +// We check here for mouse movement; if there is any, show the mouse and reset +// the watchdog timer. +void GLWidget::mouseMoveEvent(QMouseEvent * /*event*/) +{ + CheckAndRestoreMouseCursor(); +} + + #if 0 class RubyGLWidget: public QGLWidget {