VirtualBox

Ignore:
Timestamp:
Sep 1, 2008 3:23:56 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
35802
Message:

FE/Qt4-OSX: Try to fix annoying mouse cursor problems on the mac. Switch to Qt4 cursor handling for the mac.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleView.cpp

    r11882 r11926  
    3939#include <QStatusBar>
    4040#include <QPainter>
     41#include <QBitmap>
    4142
    4243#ifdef Q_WS_WIN
     
    827828
    828829#ifdef Q_WS_MAC
    829     DarwinCursorClearHandle (&mDarwinCursor);
     830//    DarwinCursorClearHandle (&mDarwinCursor);
    830831#endif
    831832}
     
    28162817#ifdef Q_WS_MAC /** @todo Christian, can you look at this. It causes flickering and IIRC is really a Qt3 workaround which probably isn't needed. If it is needed it needs to be redone. */
    28172818        /* Update the mouse cursor; this is a bit excessive really... */
    2818         if (!DarwinCursorIsNull (&mDarwinCursor))
    2819             DarwinCursorSet (&mDarwinCursor);
     2819//        if (!DarwinCursorIsNull (&mDarwinCursor))
     2820//            DarwinCursorSet (&mDarwinCursor);
    28202821#endif
    28212822        if (mMainWnd->isTrueFullscreen())
     
    35053506#elif defined(Q_WS_MAC)
    35063507
     3508        /* Create a ARGB image out of the shape data. */
     3509        QImage image  (me->width(), me->height(), QImage::Format_ARGB32);
     3510        unsigned char alpha;
     3511        for (unsigned int y = 0; y < me->height(); ++y)
     3512            for (unsigned int x = 0; x < me->width(); ++x)
     3513            {
     3514               unsigned int color = ((unsigned int*)srcShapePtr)[y*me->width()+x];
     3515               if (me->hasAlpha())
     3516                   alpha = qAlpha (color);
     3517               else
     3518                   alpha = 0xff;
     3519               image.setPixel (x, y, qRgba (qRed (color), qGreen (color), qBlue (color), alpha));
     3520            }
     3521        /* Invert the mask channel if there is one */
     3522        QPixmap pixmap (QPixmap::fromImage (image));
     3523        if (!me->hasAlpha())
     3524        {
     3525            uchar* pu8DstData = (uchar*)alloca(me->width() * me->height());
     3526            unsigned int i = 0;
     3527            while (i < me->width() * me->height())
     3528            {
     3529                pu8DstData[i] = 0xff-srcAndMaskPtr[i];
     3530                ++i;
     3531            }
     3532            QBitmap bitmap = QBitmap::fromData (QSize (me->width(), me->height()),
     3533                                                pu8DstData, QImage::Format_Mono);
     3534            /* Set the mask to the pixmap */
     3535            pixmap.setMask (bitmap);
     3536        }
     3537//        printf ("has alpha %d- %d %d\n", me->hasAlpha(), me->width(), me->height());
     3538        /* Set the new cursor */
     3539        QCursor cursor (pixmap,
     3540                        me->xHot(), me->yHot());
     3541        viewport()->setCursor (cursor);
     3542        ok = true;
    35073543        /*
    35083544         * Qt3/Mac only supports black/white cursors and it offers no way
     
    35103546         * Which means we're pretty much forced to do it our own way.
    35113547         */
    3512         int rc;
    3513 
    3514         /* dispose of the old cursor. */
    3515         if (!DarwinCursorIsNull (&mDarwinCursor))
    3516         {
    3517             rc = DarwinCursorDestroy (&mDarwinCursor);
    3518             AssertRC (rc);
    3519         }
    3520 
    3521         /* create the new cursor */
    3522         rc = DarwinCursorCreate (me->width(), me->height(), me->xHot(), me->yHot(), me->hasAlpha(),
    3523                                  srcAndMaskPtr, srcShapePtr, &mDarwinCursor);
    3524         AssertRC (rc);
    3525         if (VBOX_SUCCESS (rc))
    3526         {
    3527             /** @todo check current mouse coordinates. */
    3528             rc = DarwinCursorSet (&mDarwinCursor);
    3529             AssertRC (rc);
    3530         }
    3531         ok = VBOX_SUCCESS (rc);
     3548//        int rc;
     3549//
     3550//        /* dispose of the old cursor. */
     3551//        if (!DarwinCursorIsNull (&mDarwinCursor))
     3552//        {
     3553//            rc = DarwinCursorDestroy (&mDarwinCursor);
     3554//            AssertRC (rc);
     3555//        }
     3556//
     3557//        /* create the new cursor */
     3558//        rc = DarwinCursorCreate (me->width(), me->height(), me->xHot(), me->yHot(), me->hasAlpha(),
     3559//                                 srcAndMaskPtr, srcShapePtr, &mDarwinCursor);
     3560//        AssertRC (rc);
     3561//        if (VBOX_SUCCESS (rc))
     3562//        {
     3563//            /** @todo check current mouse coordinates. */
     3564//            rc = DarwinCursorSet (&mDarwinCursor);
     3565//            AssertRC (rc);
     3566//        }
     3567//        ok = VBOX_SUCCESS (rc);
    35323568        NOREF (srcShapePtrScan);
    35333569
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette