Changeset 561 for trunk/src/gui/kernel/qdesktopwidget_win.cpp
- 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_win.cpp
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 ** … … 46 46 #include <qvector.h> 47 47 #include <limits.h> 48 #ifdef Q_ OS_WINCE48 #ifdef Q_WS_WINCE 49 49 #include <sipapi.h> 50 50 #endif … … 93 93 static int screen_number = 0; 94 94 int QDesktopWidgetPrivate::refcount = 0; 95 #ifdef Q_ OS_WINCE_WM95 #ifdef Q_WS_WINCE_WM 96 96 // Use SIP information, if available 97 97 // SipGetInfo is not supported by SSDK (no definition!). … … 153 153 rects = new QVector<QRect>(); 154 154 workrects = new QVector<QRect>(); 155 screenCount = 0; 155 156 156 157 #ifndef Q_OS_WINCE 157 if (QSysInfo::WindowsVersion != QSysInfo::WV_95 && QSysInfo::WindowsVersion != QSysInfo::WV_NT) { 158 screenCount = 0; 159 // Trying to get the function pointers to Win98/2000 only functions 160 QLibrary user32Lib(QLatin1String("user32")); 161 if (!user32Lib.load()) 162 return; 158 QLibrary user32Lib(QLatin1String("user32")); 159 if (user32Lib.load()) { 163 160 enumDisplayMonitors = (EnumFunc)user32Lib.resolve("EnumDisplayMonitors"); 164 QT_WA({ 165 getMonitorInfo = (InfoFunc)user32Lib.resolve("GetMonitorInfoW"); 166 } , { 167 getMonitorInfo = (InfoFunc)user32Lib.resolve("GetMonitorInfoA"); 168 }); 169 170 if (!enumDisplayMonitors || !getMonitorInfo) { 171 screenCount = GetSystemMetrics(80); // SM_CMONITORS 172 rects->resize(screenCount); 173 for (int i = 0; i < screenCount; ++i) 174 rects->replace(i, that->rect()); 175 return; 176 } 177 // Calls enumCallback 178 enumDisplayMonitors(0, 0, enumCallback, 0); 179 enumDisplayMonitors = 0; 180 getMonitorInfo = 0; 181 } else { 182 rects->resize(1); 183 rects->replace(0, that->rect()); 184 workrects->resize(1); 185 workrects->replace(0, that->rect()); 186 } 161 getMonitorInfo = (InfoFunc)user32Lib.resolve("GetMonitorInfoW"); 162 } 163 164 if (!enumDisplayMonitors || !getMonitorInfo) { 165 screenCount = GetSystemMetrics(80); // SM_CMONITORS 166 rects->resize(screenCount); 167 for (int i = 0; i < screenCount; ++i) 168 rects->replace(i, that->rect()); 169 return; 170 } 171 // Calls enumCallback 172 enumDisplayMonitors(0, 0, enumCallback, 0); 173 enumDisplayMonitors = 0; 174 getMonitorInfo = 0; 187 175 #else 188 screenCount = 0;189 190 176 QLibrary coreLib(QLatin1String("coredll")); 191 177 if (coreLib.load()) { … … 209 195 QRect qr = QRect(QPoint(r.left, r.top), QPoint(r.right - 1, r.bottom - 1)); 210 196 211 #if defined(Q_ OS_WINCE_WM)197 #if defined(Q_WS_WINCE_WM) 212 198 qt_get_sip_info(qr); 213 199 #endif … … 223 209 enumDisplayMonitors = 0; 224 210 getMonitorInfo = 0; 225 #endif // Q_ OS_WINCE211 #endif // Q_WS_WINCE 226 212 } 227 213 … … 304 290 { 305 291 Q_D(const QDesktopWidget); 306 #ifdef Q_ OS_WINCE_WM292 #ifdef Q_WS_WINCE_WM 307 293 for(int i=0; i < d->workrects->size(); ++i) 308 294 qt_get_sip_info((*d->workrects)[i]); 309 295 #endif 310 if (QSysInfo::WindowsVersion != QSysInfo::WV_95 && QSysInfo::WindowsVersion != QSysInfo::WV_NT) { 311 if (screen < 0 || screen >= d->screenCount) 312 screen = d->primaryScreen; 313 314 return d->workrects->at(screen); 315 } else { 316 return d->workrects->at(d->primaryScreen); 317 } 296 if (screen < 0 || screen >= d->screenCount) 297 screen = d->primaryScreen; 298 299 return d->workrects->at(screen); 318 300 } 319 301 … … 321 303 { 322 304 const QDesktopWidgetPrivate *d = d_func(); 323 if (QSysInfo::WindowsVersion != QSysInfo::WV_95 && QSysInfo::WindowsVersion != QSysInfo::WV_NT) { 324 if (screen < 0 || screen >= d->screenCount) 325 screen = d->primaryScreen; 326 327 return d->rects->at(screen); 328 } else { 329 return d->rects->at(d->primaryScreen); 330 } 305 if (screen < 0 || screen >= d->screenCount) 306 screen = d->primaryScreen; 307 308 return d->rects->at(screen); 331 309 } 332 310 … … 334 312 { 335 313 Q_D(const QDesktopWidget); 336 if (QSysInfo::WindowsVersion != QSysInfo::WV_95 && QSysInfo::WindowsVersion != QSysInfo::WV_NT) { 337 if (!widget) 338 return d->primaryScreen; 339 QRect frame = widget->frameGeometry(); 340 if (!widget->isWindow()) 341 frame.moveTopLeft(widget->mapToGlobal(QPoint(0,0))); 342 343 int maxSize = -1; 344 int maxScreen = -1; 345 346 for (int i = 0; i < d->screenCount; ++i) { 347 QRect sect = d->rects->at(i).intersected(frame); 348 int size = sect.width() * sect.height(); 349 if (size > maxSize && sect.width() > 0 && sect.height() > 0) { 350 maxSize = size; 351 maxScreen = i; 352 } 314 if (!widget) 315 return d->primaryScreen; 316 317 QRect frame = widget->frameGeometry(); 318 if (!widget->isWindow()) 319 frame.moveTopLeft(widget->mapToGlobal(QPoint(0,0))); 320 321 int maxSize = -1; 322 int maxScreen = -1; 323 324 for (int i = 0; i < d->screenCount; ++i) { 325 QRect sect = d->rects->at(i).intersected(frame); 326 int size = sect.width() * sect.height(); 327 if (size > maxSize && sect.width() > 0 && sect.height() > 0) { 328 maxSize = size; 329 maxScreen = i; 353 330 } 354 return maxScreen; 355 } else { 356 return d->primaryScreen; 357 } 331 } 332 333 return maxScreen; 358 334 } 359 335 … … 361 337 { 362 338 Q_D(const QDesktopWidget); 339 363 340 int closestScreen = -1; 364 if (QSysInfo::WindowsVersion != QSysInfo::WV_95 && QSysInfo::WindowsVersion != QSysInfo::WV_NT) { 365 int shortestDistance = INT_MAX; 366 for (int i = 0; i < d->screenCount; ++i) { 367 int thisDistance = d->pointToRect(point, d->rects->at(i)); 368 if (thisDistance < shortestDistance) { 369 shortestDistance = thisDistance; 370 closestScreen = i; 371 } 341 int shortestDistance = INT_MAX; 342 343 for (int i = 0; i < d->screenCount; ++i) { 344 int thisDistance = d->pointToRect(point, d->rects->at(i)); 345 if (thisDistance < shortestDistance) { 346 shortestDistance = thisDistance; 347 closestScreen = i; 372 348 } 373 349 } 350 374 351 return closestScreen; 375 352 } … … 378 355 { 379 356 Q_D(QDesktopWidget); 380 QVector<QRect> oldrects; 381 oldrects = *d->rects; 382 QVector<QRect> oldworkrects; 383 oldworkrects = *d->workrects; 357 const QVector<QRect> oldrects(*d->rects); 358 const QVector<QRect> oldworkrects(*d->workrects); 384 359 int oldscreencount = d->screenCount; 385 360 386 361 QDesktopWidgetPrivate::cleanup(); 387 362 QDesktopWidgetPrivate::init(this); 388 #ifdef Q_ OS_WINCE_WM363 #ifdef Q_WS_WINCE_WM 389 364 for(int i=0; i < d->workrects->size(); ++i) 390 365 qt_get_sip_info((*d->workrects)[i]); … … 392 367 393 368 for (int i = 0; i < qMin(oldscreencount, d->screenCount); ++i) { 394 QRect oldrect = oldrects[i];395 QRect newrect = d->rects->at(i);369 const QRect oldrect = oldrects[i]; 370 const QRect newrect = d->rects->at(i); 396 371 if (oldrect != newrect) 397 372 emit resized(i); … … 399 374 400 375 for (int j = 0; j < qMin(oldscreencount, d->screenCount); ++j) { 401 QRect oldrect = oldworkrects[j];402 QRect newrect = d->workrects->at(j);376 const QRect oldrect = oldworkrects[j]; 377 const QRect newrect = d->workrects->at(j); 403 378 if (oldrect != newrect) 404 379 emit workAreaResized(j); 405 380 } 381 382 if (oldscreencount != d->screenCount) { 383 emit screenCountChanged(d->screenCount); 384 } 406 385 } 407 386
Note:
See TracChangeset
for help on using the changeset viewer.