Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/kernel/qdesktopwidget_mac.mm

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    9898
    9999QDesktopWidgetImplementation::QDesktopWidgetImplementation()
    100     : appScreen(0), displays(0)
     100    : appScreen(0)
    101101{
    102102    onResize();
     
    105105QDesktopWidgetImplementation::~QDesktopWidgetImplementation()
    106106{
    107     if (displays)
    108         [displays release];
    109107}
    110108
     
    119117        screenIndex = appScreen;
    120118
    121     NSRect r = [[displays objectAtIndex:screenIndex] visibleFrame];
    122     NSRect primaryRect = [[displays objectAtIndex:0] frame];
    123 
    124     const int flippedY = - r.origin.y +                // account for position offset and
    125               primaryRect.size.height - r.size.height; // height difference.
    126     return QRectF(r.origin.x, flippedY,
    127             r.size.width, r.size.height).toRect();
     119        return availableRects[screenIndex].toRect();
    128120}
    129121
     
    133125        screenIndex = appScreen;
    134126
    135     NSRect r = [[displays objectAtIndex:screenIndex] frame];
    136     NSRect primaryRect = [[displays objectAtIndex:0] frame];
    137 
    138     const int flippedY = - r.origin.y +                // account for position offset and
    139               primaryRect.size.height - r.size.height; // height difference.
    140     return QRectF(r.origin.x, flippedY,
    141             r.size.width, r.size.height).toRect();
     127    return screenRects[screenIndex].toRect();
    142128}
    143129
    144130void QDesktopWidgetImplementation::onResize()
    145131{
    146     if (displays)
    147         [displays release];
    148 
    149     displays = [[NSScreen screens] retain];
    150     screenCount = [displays count];
     132    QMacCocoaAutoReleasePool pool;
     133    NSArray *displays = [NSScreen screens];
     134    screenCount = [displays count];
     135 
     136    screenRects.clear();
     137    availableRects.clear();
     138    NSRect primaryRect = [[displays objectAtIndex:0] frame];
     139    for (int i = 0; i<screenCount; i++) {
     140        NSRect r = [[displays objectAtIndex:i] frame];
     141        int flippedY = - r.origin.y +                  // account for position offset and
     142              primaryRect.size.height - r.size.height; // height difference.
     143        screenRects.append(QRectF(r.origin.x, flippedY,
     144            r.size.width, r.size.height));
     145
     146        r = [[displays objectAtIndex:i] visibleFrame];
     147        flippedY = - r.origin.y +                      // account for position offset and
     148              primaryRect.size.height - r.size.height; // height difference.
     149        availableRects.append(QRectF(r.origin.x, flippedY,
     150                r.size.width, r.size.height));
     151    }
    151152}
    152153
     
    196197int QDesktopWidget::screenNumber(const QWidget *widget) const
    197198{
    198    QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();
     199    QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();
    199200    if (!widget)
    200201        return d->appScreen;
     
    217218int QDesktopWidget::screenNumber(const QPoint &point) const
    218219{
    219    QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();
     220    QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();
    220221    int closestScreen = -1;
    221222    int shortestDistance = INT_MAX;
     
    233234void QDesktopWidget::resizeEvent(QResizeEvent *)
    234235{
    235    QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();
     236    QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();
     237
     238    const int oldScreenCount = d->screenCount;
     239    const QVector<QRectF> oldRects(d->screenRects);
     240    const QVector<QRectF> oldWorks(d->availableRects);
    236241
    237242    d->onResize();
    238243
    239     for (int i = 0; i < d->screenCount; ++i) {
    240         emit resized(i);
    241     }
     244    for (int i = 0; i < qMin(oldScreenCount, d->screenCount); ++i) {
     245        if (oldRects.at(i) != d->screenRects.at(i))
     246            emit resized(i);
     247    }
     248    for (int i = 0; i < qMin(oldScreenCount, d->screenCount); ++i) {
     249        if (oldWorks.at(i) != d->availableRects.at(i))
     250            emit workAreaResized(i);
     251    }
     252
     253    if (oldScreenCount != d->screenCount)
     254        emit screenCountChanged(d->screenCount);
    242255}
    243256
Note: See TracChangeset for help on using the changeset viewer.