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_win.cpp

    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**
     
    4646#include <qvector.h>
    4747#include <limits.h>
    48 #ifdef Q_OS_WINCE
     48#ifdef Q_WS_WINCE
    4949#include <sipapi.h>
    5050#endif
     
    9393static int screen_number = 0;
    9494int QDesktopWidgetPrivate::refcount = 0;
    95 #ifdef Q_OS_WINCE_WM
     95#ifdef Q_WS_WINCE_WM
    9696// Use SIP information, if available
    9797// SipGetInfo is not supported by SSDK (no definition!).
     
    153153    rects = new QVector<QRect>();
    154154    workrects = new QVector<QRect>();
     155    screenCount = 0;
    155156
    156157#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()) {
    163160        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;
    187175#else
    188     screenCount = 0;
    189 
    190176    QLibrary coreLib(QLatin1String("coredll"));
    191177    if (coreLib.load()) {
     
    209195        QRect qr = QRect(QPoint(r.left, r.top), QPoint(r.right - 1, r.bottom - 1));
    210196
    211 #if defined(Q_OS_WINCE_WM)
     197#if defined(Q_WS_WINCE_WM)
    212198        qt_get_sip_info(qr);
    213199#endif
     
    223209    enumDisplayMonitors = 0;
    224210    getMonitorInfo = 0;
    225 #endif // Q_OS_WINCE
     211#endif // Q_WS_WINCE
    226212}
    227213
     
    304290{
    305291    Q_D(const QDesktopWidget);
    306 #ifdef Q_OS_WINCE_WM
     292#ifdef Q_WS_WINCE_WM
    307293    for(int i=0; i < d->workrects->size(); ++i)
    308294        qt_get_sip_info((*d->workrects)[i]);
    309295#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);
    318300}
    319301
     
    321303{
    322304    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);
    331309}
    332310
     
    334312{
    335313    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;
    353330        }
    354         return maxScreen;
    355     } else {
    356         return d->primaryScreen;
    357     }
     331    }
     332
     333    return maxScreen;
    358334}
    359335
     
    361337{
    362338    Q_D(const QDesktopWidget);
     339
    363340    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;
    372348        }
    373349    }
     350
    374351    return closestScreen;
    375352}
     
    378355{
    379356    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);
    384359    int oldscreencount = d->screenCount;
    385360
    386361    QDesktopWidgetPrivate::cleanup();
    387362    QDesktopWidgetPrivate::init(this);
    388 #ifdef Q_OS_WINCE_WM
     363#ifdef Q_WS_WINCE_WM
    389364    for(int i=0; i < d->workrects->size(); ++i)
    390365        qt_get_sip_info((*d->workrects)[i]);
     
    392367
    393368    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);
    396371        if (oldrect != newrect)
    397372            emit resized(i);
     
    399374
    400375    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);
    403378        if (oldrect != newrect)
    404379            emit workAreaResized(j);
    405380    }
     381
     382    if (oldscreencount != d->screenCount) {
     383        emit screenCountChanged(d->screenCount);
     384    }
    406385}
    407386
Note: See TracChangeset for help on using the changeset viewer.