Changeset 561 for trunk/src/gui/kernel/qdesktopwidget_mac.mm
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/kernel/qdesktopwidget_mac.mm
r2 r561 2 2 ** 3 3 ** 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) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** 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. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 98 98 99 99 QDesktopWidgetImplementation::QDesktopWidgetImplementation() 100 : appScreen(0) , displays(0)100 : appScreen(0) 101 101 { 102 102 onResize(); … … 105 105 QDesktopWidgetImplementation::~QDesktopWidgetImplementation() 106 106 { 107 if (displays)108 [displays release];109 107 } 110 108 … … 119 117 screenIndex = appScreen; 120 118 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(); 128 120 } 129 121 … … 133 125 screenIndex = appScreen; 134 126 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(); 142 128 } 143 129 144 130 void QDesktopWidgetImplementation::onResize() 145 131 { 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 } 151 152 } 152 153 … … 196 197 int QDesktopWidget::screenNumber(const QWidget *widget) const 197 198 { 198 QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();199 QDesktopWidgetImplementation *d = qdesktopWidgetImplementation(); 199 200 if (!widget) 200 201 return d->appScreen; … … 217 218 int QDesktopWidget::screenNumber(const QPoint &point) const 218 219 { 219 QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();220 QDesktopWidgetImplementation *d = qdesktopWidgetImplementation(); 220 221 int closestScreen = -1; 221 222 int shortestDistance = INT_MAX; … … 233 234 void QDesktopWidget::resizeEvent(QResizeEvent *) 234 235 { 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); 236 241 237 242 d->onResize(); 238 243 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); 242 255 } 243 256
Note:
See TracChangeset
for help on using the changeset viewer.