⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qapplication_qws.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the QtGui module of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "qglobal.h"#include "qcursor.h"#include "qapplication.h"#include "private/qapplication_p.h"#include "qwidget.h"#include "qbitarray.h"#include "qpainter.h"#include "qpixmapcache.h"#include "qdatetime.h"#include "qtextcodec.h"#include "qdatastream.h"#include "qbuffer.h"#include "qsocketnotifier.h"#include "qsessionmanager.h"#include "qclipboard.h"#include "qbitmap.h"#include "qwssocket_qws.h"#include "qtransportauth_qws.h"#include "private/qtransportauth_qws_p.h"#include "qwsevent_qws.h"#include "private/qwscommand_qws_p.h"#include "qwsproperty_qws.h"#include "qscreen_qws.h"#include "qcopchannel_qws.h"#include "private/qlock_p.h"#include "private/qwslock_p.h"//#include "qmemorymanager_qws.h"#include "qwsmanager_qws.h"//#include "qwsregionmanager_qws.h"#include "qwindowsystem_qws.h"#include "private/qwindowsystem_p.h"#include "qwsdisplay_qws.h"#include "private/qwsdisplay_qws_p.h"#include "private/qwsinputcontext_p.h"#include "qfile.h"#include "qhash.h"#include "qdesktopwidget.h"#include "qcolormap.h"#include "private/qcursor_p.h"#include "qsettings.h"#include "qdebug.h"#include "qeventdispatcher_qws_p.h"#if !defined(QT_NO_GLIB)#  include "qwseventdispatcher_glib_p.h"#endif#include "private/qwidget_p.h"#include "private/qbackingstore_p.h"#include "private/qwindowsurface_qws_p.h"#include "private/qfont_p.h"#include <unistd.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <locale.h>#include <errno.h>#include <fcntl.h>#include <sys/time.h>#include <sys/stat.h>#include <sys/types.h>#ifndef QT_NO_QWS_MULTIPROCESS#ifdef QT_NO_QSHM#include <sys/ipc.h>#include <sys/shm.h>#ifndef Q_OS_DARWIN# include <sys/sem.h>#endif#include <sys/socket.h>#else#include "private/qsharedmemory_p.h"#endif#endif#ifndef QT_NO_DIRECTPAINTERclass QDirectPainter;extern void qt_directpainter_region(QDirectPainter *dp, const QRegion &alloc, int type);#ifndef QT_NO_QWSEMBEDWIDGETextern void qt_directpainter_embedevent(QDirectPainter *dp,                                        const QWSEmbedEvent *e);#endif#endif // QT_NO_DIRECTPAINTERconst int qwsSharedRamSize = 1 * 1024; // misc data, written by server, read by clientsextern QApplication::Type qt_appType;extern QDesktopWidget *qt_desktopWidget;//these used to be environment variables, they are initialized from//environment variables inbool qws_savefonts = false;bool qws_screen_is_interlaced=false; //### should be detectedbool qws_shared_memory = false;bool qws_sw_cursor = true;bool qws_accel = true;            // ### never setQByteArray qws_display_spec(":0");Q_GUI_EXPORT int qws_display_id = 0;int qws_client_id = 0;QWidget *qt_pressGrab = 0;QWidget *qt_mouseGrb = 0;int *qt_last_x = 0;int *qt_last_y = 0;static int mouse_x_root = -1;static int mouse_y_root = -1;static int mouse_state = 0;int qt_servershmid = -1;bool qws_overrideCursor = false;#ifndef QT_NO_QWS_MANAGER#include "qdecorationfactory_qws.h"static QDecoration *qws_decoration = 0;#endif#if defined(QT_DEBUG)/*extern "C" void dumpmem(const char* m){    static int init=0;    static int prev=0;    FILE* f = fopen("/proc/meminfo","r");    //    char line[100];    int total=0,used=0,free=0,shared=0,buffers=0,cached=0;    fscanf(f,"%*[^M]Mem: %d %d %d %d %d %d",&total,&used,&free,&shared,&buffers,&cached);    used -= buffers + cached;    if (!init) {        init=used;    } else {        printf("%40s: %+8d = %8d\n",m,used-init-prev,used-init);        prev = used-init;    }    fclose(f);}*/#endif// Get the name of the directory where Qtopia Core temporary data should// live.QString qws_dataDir(){    static QString result;    if (!result.isEmpty())        return result;    QByteArray dataDir = QString(QLatin1String("/tmp/qtembedded-%1")).arg(qws_display_id).toLocal8Bit();    if (mkdir(dataDir, 0700)) {        if (errno != EEXIST) {            qFatal("Cannot create Qtopia Core data directory: %s", dataDir.constData());        }    }    struct stat buf;    if (lstat(dataDir, &buf))        qFatal("stat failed for Qtopia Core data directory: %s", dataDir.constData());    if (!S_ISDIR(buf.st_mode))        qFatal("%s is not a directory", dataDir.constData());#ifndef Q_OS_INTEGRITY    if (buf.st_uid != getuid())        qFatal("Qtopia Core data directory is not owned by user %d", getuid());    if ((buf.st_mode & 0677) != 0600)        qFatal("Qtopia Core data directory has incorrect permissions: %s", dataDir.constData());#endif    dataDir += "/";    result = QString::fromLocal8Bit(dataDir);    return result;}// Get the filename of the pipe Qtopia Core uses for server/client commsQ_GUI_EXPORT QString qws_qtePipeFilename(){    return (qws_dataDir() + QString(QLatin1String(QTE_PIPE)).arg(qws_display_id));}static void setMaxWindowRect(const QRect &rect){    const QList<QScreen*> subScreens = qt_screen->subScreens();    QScreen *screen = qt_screen;    int screenNo = 0;    for (int i = 0; i < subScreens.size(); ++i) {        if (subScreens.at(i)->region().contains(rect)) {            screen = subScreens.at(i);            screenNo = i;            break;        }    }    QApplicationPrivate *ap = QApplicationPrivate::instance();    ap->setMaxWindowRect(screen, screenNo, rect);}void QApplicationPrivate::setMaxWindowRect(const QScreen *screen, int screenNo,                                           const QRect &rect){    if (maxWindowRects.value(screen) == rect)        return;    maxWindowRects[screen] = rect;    // Re-resize any maximized windows    QWidgetList l = QApplication::topLevelWidgets();    for (int i = 0; i < l.size(); ++i) {        QWidget *w = l.at(i);        QScreen *s = w->d_func()->getScreen();        if (w->isMaximized() && s == screen)            w->d_func()->setMaxWindowState_helper();    }    if ( qt_desktopWidget ) // XXX workaround crash        emit QApplication::desktop()->workAreaResized(screenNo);}/*****************************************************************************  Internal variables and functions *****************************************************************************/static QString appName;                          // application namestatic const char *appFont = 0;                  // application fontstatic const char *appBGCol = 0;                 // application bg colorstatic const char *appFGCol = 0;                 // application fg colorstatic const char *appBTNCol = 0;                // application btn colorstatic const char *mwGeometry = 0;               // main widget geometrystatic const char *mwTitle = 0;                  // main widget title//static bool mwIconic = false;                  // main widget iconifiedstatic bool app_do_modal = false;                // modal modeQ_GUI_EXPORT QWSDisplay *qt_fbdpy = 0;                        // QWS `display'QLock *QWSDisplay::lock = 0;static int mouseButtonPressed = 0;               // last mouse button pressedstatic int mouseButtonPressTime = 0;             // when was a button pressedstatic short mouseXPos, mouseYPos;               // mouse position in act windowextern QWidgetList *qt_modal_stack;              // stack of modal widgetsstatic QWidget *popupButtonFocus = 0;static QWidget *popupOfPopupButtonFocus = 0;static bool popupCloseDownMode = false;static bool popupGrabOk;static QPointer<QWidget> *mouseInWidget = 0;static bool sm_blockUserInput = false;           // session managementQWidget *qt_button_down = 0;                     // widget got last button-downWId qt_last_cursor = 0xffffffff;                 // Was -1, but WIds are unsignedclass QWSMouseEvent;class QWSKeyEvent;class QETWidget : public QWidget                 // event translator widget{public:    bool translateMouseEvent(const QWSMouseEvent *, int oldstate);    bool translateKeyEvent(const QWSKeyEvent *, bool grab);    bool translateRegionEvent(const QWSRegionEvent *);#ifndef QT_NO_QWSEMBEDWIDGET    void translateEmbedEvent(const QWSEmbedEvent *event);#endif    bool translateWheelEvent(const QWSMouseEvent *me);    void repaintDecoration(QRegion r, bool post);    void updateRegion();    bool raiseOnClick()    {        // With limited windowmanagement/taskbar/etc., raising big windows        // (eg. spreadsheet) over the top of everything else (eg. calculator)        // is just annoying.        return !isMaximized() && !isFullScreen();    }};void QApplicationPrivate::createEventDispatcher(){    Q_Q(QApplication);#if !defined(QT_NO_GLIB)    if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported())        eventDispatcher = (q->type() != QApplication::Tty                           ? new QWSEventDispatcherGlib(q)                           : new QEventDispatcherGlib(q));    else#endif    eventDispatcher = (q->type() != QApplication::Tty                       ? new QEventDispatcherQWS(q)                       : new QEventDispatcherUNIX(q));}// Single-process stuff. This should maybe move into qwindowsystem_qws.cppstatic bool qws_single_process;static QList<QWSEvent*> incoming;static QList<QWSCommand*> outgoing;void qt_client_enqueue(const QWSEvent *event){    QWSEvent *copy = QWSEvent::factory(event->type);    copy->copyFrom(event);    incoming.append(copy);}QList<QWSCommand*> *qt_get_server_queue(){    return &outgoing;}void qt_server_enqueue(const QWSCommand *command){    QWSCommand *copy = QWSCommand::factory(command->type);    copy->copyFrom(command);    outgoing.append(copy);}QWSDisplay::Data::Data(QObject* parent, bool singleProcess){#ifdef QT_NO_QWS_MULTIPROCESS    Q_UNUSED(parent);    Q_UNUSED(singleProcess);#else    if (singleProcess)        csocket = 0;    else {        csocket = new QWSSocket(parent);        QObject::connect(csocket, SIGNAL(disconnected()),                         qApp, SLOT(quit()));    }    clientLock = 0;#endif    init();}QWSDisplay::Data::~Data(){//        delete rgnMan; rgnMan = 0;//        delete memorymanager; memorymanager = 0;    qt_screen->disconnect();    delete qt_screen; qt_screen = 0;#ifndef QT_NO_QWS_CURSOR    delete qt_screencursor; qt_screencursor = 0;#endif#ifndef QT_NO_QWS_MULTIPROCESS    shm.detach();    if (csocket) {        QWSCommand shutdownCmd(QWSCommand::Shutdown, 0, 0);        shutdownCmd.write(csocket);        csocket->flush(); // may be pending QCop message, eg.        delete csocket;    }    delete clientLock;    clientLock = 0;#endif    delete connected_event;    delete mouse_event;    delete current_event;    qDeleteAll(queue);#ifndef QT_NO_COP    delete qcop_response;#endif}#ifndef QT_NO_QWS_MULTIPROCESSbool QWSDisplay::Data::lockClient(QWSLock::LockType type, int timeout){    return !clientLock || clientLock->lock(type, timeout);}void QWSDisplay::Data::unlockClient(QWSLock::LockType type){    if (clientLock) clientLock->unlock(type);}bool QWSDisplay::Data::waitClient(QWSLock::LockType type, int timeout){    return !clientLock || clientLock->wait(type, timeout);}QWSLock* QWSDisplay::Data::getClientLock(){    return clientLock;}#endif // QT_NO_QWS_MULTIPROCESSvoid QWSDisplay::Data::flush(){#ifndef QT_NO_QWS_MULTIPROCESS    if (csocket) {        csocket->waitForReadyRead(0);        csocket->flush();   }#endif}#if 0void QWSDisplay::Data::debugQueue() {    for (int i = 0; i < queue.size(); ++i) {        QWSEvent *e = queue.at(i);        qDebug( "   ev %d type %d sl %d rl %d", i, e->type, e->simpleLen, e->rawLen);    }}#endifbool QWSDisplay::Data::queueNotEmpty(){    return mouse_event/*||region_event*/||queue.count() > 0;}QWSEvent* QWSDisplay::Data::dequeue()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -