📄 qwindowsystem_qws.cpp
字号:
/******************************************************************************** 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 "qwindowsystem_qws.h"#include "qwsevent_qws.h"#include "qwscommand_qws_p.h"#include "qtransportauth_qws_p.h"#include "qwsutils_qws.h"#include "qwscursor_qws.h"#include "qwsdisplay_qws.h"#include "qmouse_qws.h"#include "qcopchannel_qws.h"#include "qwssocket_qws.h"#include "qapplication.h"#include "private/qapplication_p.h"#include "qsocketnotifier.h"#include "qpolygon.h"#include "qimage.h"#include "qcursor.h"#include <private/qpaintengine_raster_p.h>#include "qscreen_qws.h"#include "qwindowdefs.h"#include "private/qlock_p.h"#include "qwslock_p.h"#include "qfile.h"#include "qtimer.h"#include "qpen.h"#include "qdesktopwidget.h"#include "qevent.h"#include "qinputcontext.h"#include "qpainter.h"#include <qdebug.h>#include <unistd.h>#include <stdlib.h>#include <stdio.h>#include <errno.h>#ifndef QT_NO_QWS_MULTIPROCESS#include <sys/types.h>#include <sys/socket.h>#include <sys/ipc.h>#include <sys/shm.h>#ifndef Q_OS_DARWIN# include <sys/sem.h>#endif#include <sys/param.h>#include <sys/mount.h>#endif#include <signal.h>#include <fcntl.h>#if !defined(QT_NO_SOUND) && !defined(Q_OS_DARWIN)#ifdef QT_USE_OLD_QWS_SOUND#include <sys/types.h>#include <sys/stat.h>#include <sys/ioctl.h>#include <sys/soundcard.h>#else#include "qsoundqss_qws.h"#endif#endif#include "qkbddriverfactory_qws.h"#include "qmousedriverfactory_qws.h"#include <qbuffer.h>#include <qdir.h>#include <private/qwindowsurface_qws_p.h>#include <private/qfontengine_qpf_p.h>#include "qwindowsystem_p.h"//#define QWS_DEBUG_FONTCLEANUPQWSServer Q_GUI_EXPORT *qwsServer=0;static QWSServerPrivate *qwsServerPrivate=0;#define MOUSE 0#define KEY 1//#define EVENT_BLOCK_DEBUGQWSScreenSaver::~QWSScreenSaver(){}extern QByteArray qws_display_spec;extern void qt_init_display(); //qapplication_qws.cppextern QString qws_qtePipeFilename();extern void qt_client_enqueue(const QWSEvent *); //qapplication_qws.cppextern QList<QWSCommand*> *qt_get_server_queue();Q_GLOBAL_STATIC_WITH_ARGS(QString, defaultMouse, (QLatin1String("Auto")))Q_GLOBAL_STATIC_WITH_ARGS(QString, defaultKeyboard, (QLatin1String("TTY")))static const int FontCleanupInterval = 60 * 1000;static int qws_keyModifiers = 0;static QWSWindow *keyboardGrabber;static bool keyboardGrabbing;static int get_object_id(int count = 1){ static int next=1000; int n = next; next += count; return n;}#ifndef QT_NO_QWS_INPUTMETHODSstatic QWSInputMethod *current_IM = 0;static QWSWindow *current_IM_composing_win = 0;static int current_IM_winId = -1;static bool force_reject_strokeIM = false;#endifstatic void cleanupFontsDir();//#define QWS_REGION_DEBUG/*! \class QWSScreenSaver \ingroup qws \brief The QWSScreenSaver class is a base class for screensavers in Qtopia Core. When running \l {Qtopia Core} applications, it is the server application that installs and controls the screensaver. \l {Qtopia Core} supports multilevel screen saving, i.e., it is possible to specify several different levels of screen responsiveness. For example, you can choose to first turn off the light before you fully activate the screensaver. Note that there exists no default screensaver implementation. To create a custom screensaver, derive from this class and reimplement the restore() and save() functions. These functions are called whenever the screensaver is activated or deactivated, respectively. Once an instance of your custom screensaver is created, you can use the QWSServer::setScreenSaver() function to install it. \sa QWSServer, QScreen, {Qtopia Core}*//*! \fn QWSScreenSaver::~QWSScreenSaver() Reimplement this function to destroy the screensaver.*//*! \fn QWSScreenSaver::restore() Implement this function to deactivate the screensaver, restoring the previously saved screen. \sa save(), QWSServer::screenSaverActivate()*//*! \fn QWSScreenSaver::save(int level) Implement this function to activate the screensaver, saving the current screen. \l {Qtopia Core} supports multilevel screen saving, i.e., it is possible to specify several different levels of screen responsiveness. For example, you can choose to first turn off the light before you fully activate the screensaver. Use the QWSServer::setScreenSaverIntervals() to specify the time intervals between the different levels. This function should return true if the screensaver successfully enters the given \a level; otherwise it should return false. \sa restore(), QWSServer::screenSaverActivate()*/class QWSWindowPrivate{public: QWSWindowPrivate(); QRegion allocatedRegion;#ifndef QT_NO_QWSEMBEDWIDGET QList<QWSWindow*> embedded; QWSWindow *embedder;#endif QWSWindow::State state; Qt::WindowFlags windowFlags; QRegion dirtyOnScreen; bool painted;};QWSWindowPrivate::QWSWindowPrivate() :#ifndef QT_NO_QWSEMBEDWIDGET embedder(0), state(QWSWindow::NoState),#endif painted(false){}/*! \class QWSWindow \ingroup qws \brief The QWSWindow class encapsulates a top-level window in Qtopia Core. When you run a \l {Qtopia Core} application, it either runs as a server or connects to an existing server. As applications add and remove windows, the server process maintains information about each window. In \l {Qtopia Core}, top-level windows are encapsulated as QWSWindow objects. Note that you should never construct the QWSWindow class yourself; the current top-level windows can be retrieved using the QWSServer::clientWindows() function. With a window at hand, you can retrieve its caption, name, opacity and ID using the caption(), name(), opacity() and winId() functions, respectively. Use the client() function to retrieve a pointer to the client that owns the window. Use the isVisible() function to find out if the window is visible. You can find out if the window is completely obscured by another window or by the bounds of the screen, using the isFullyObscured() function. The isOpaque() function returns true if the window has an alpha channel equal to 255. Finally, the requestedRegion() function returns the region of the display the window wants to draw on. \sa QWSServer, QWSClient, {Qtopia Core Architecture}*//*! \fn int QWSWindow::winId() const Returns the window's ID. \sa name(), caption()*//*! \fn const QString &QWSWindow::name() const Returns the window's name. \sa caption(), winId()*//*! \fn const QString &QWSWindow::caption() const Returns the window's caption. \sa name(), winId()*//*! \fn QWSClient* QWSWindow::client() const Returns a reference to the QWSClient object that owns this window. \sa requestedRegion()*//*! \fn QRegion QWSWindow::requestedRegion() const Returns the region that the window has requested to draw onto, including any window decorations. \sa client()*//*! \fn bool QWSWindow::isVisible() const Returns true if the window is visible; otherwise returns false. \sa isFullyObscured()*//*! \fn bool QWSWindow::isOpaque() const Returns true if the window is opaque, i.e., if its alpha channel equals 255; otherwise returns false. \sa opacity()*//*! \fn uint QWSWindow::opacity () const Returns the window's alpha channel value. \sa isOpaque()*//*! \fn bool QWSWindow::isPartiallyObscured() const \internal Returns true if the window is partially obsured by another window or by the bounds of the screen; otherwise returns false.*//*! \fn bool QWSWindow::isFullyObscured() const Returns true if the window is completely obsured by another window or by the bounds of the screen; otherwise returns false. \sa isVisible()*//*! \fn QWSWindowSurface* QWSWindow::windowSurface() const \internal*/QWSWindow::QWSWindow(int i, QWSClient* client) : id(i), modified(false), onTop(false), c(client), last_focus_time(0), _opacity(255), opaque(true), d(new QWSWindowPrivate){ surface = 0;}/*! \enum QWSWindow::State This enum describes the state of a window. Most of the transitional states are set just before a call to QScreen::exposeRegion() and reset immediately afterwards. \value NoState Initial state before the window is properly initialized. \value Hidden The window is not visible. \value Showing The window is being shown. \value Visible The window is visible, and not in a transition. \value Hiding The window is being hidden. \value Raising The windoe is being raised. \value Lowering The window is being raised. \value Moving The window is being moved. \value ChangingGeometry The window's geometry is being changed. \value Destroyed The window is destroyed. \sa state(), QScreen::exposeRegion()*//*! Returns the current state of the window. \since 4.3*/QWSWindow::State QWSWindow::state() const{ return d->state;}/*! Returns the window flags of the window. This value is only available after the first paint event. \since 4.3*/Qt::WindowFlags QWSWindow::windowFlags() const{ return d->windowFlags;}/*! Returns the region that has been repainted since the previous QScreen::exposeRegion(), and needs to be copied to the screen. \since 4.3*/QRegion QWSWindow::dirtyOnScreen() const{ return d->dirtyOnScreen;}void QWSWindow::createSurface(const QString &key, const QByteArray &data){#ifndef QT_NO_QWS_MULTIPROCESS if (surface && !surface->isBuffered()) c->removeUnbufferedSurface();#endif delete surface; surface = qt_screen->createSurface(key); surface->setPermanentState(data);#ifndef QT_NO_QWS_MULTIPROCESS if (!surface->isBuffered()) c->addUnbufferedSurface();#endif}/*! \internal Raises the window above all other windows except "Stay on top" windows.*/void QWSWindow::raise(){ qwsServerPrivate->raiseWindow(this);#ifndef QT_NO_QWSEMBEDWIDGET const int n = d->embedded.size(); for (int i = 0; i < n; ++i) d->embedded.at(i)->raise();#endif}/*! \internal Lowers the window below other windows.*/void QWSWindow::lower(){ qwsServerPrivate->lowerWindow(this);#ifndef QT_NO_QWSEMBEDWIDGET const int n = d->embedded.size();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -