1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2015 The Qt Company Ltd. 4 ** Contact: http://www.qt.io/licensing/ 5 ** 6 ** This file is part of the QtGui module of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see http://www.qt.io/terms-conditions. For further 15 ** information use the contact form at http://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 2.1 or version 3 as published by the Free 20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and 21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the 22 ** following information to ensure the GNU Lesser General Public License 23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and 24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 25 ** 26 ** As a special exception, The Qt Company gives you certain additional 27 ** rights. These rights are described in The Qt Company LGPL Exception 28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 29 ** 30 ** GNU General Public License Usage 31 ** Alternatively, this file may be used under the terms of the GNU 32 ** General Public License version 3.0 as published by the Free Software 33 ** Foundation and appearing in the file LICENSE.GPL included in the 34 ** packaging of this file. Please review the following information to 35 ** ensure the GNU General Public License version 3.0 requirements will be 36 ** met: http://www.gnu.org/copyleft/gpl.html. 37 ** 38 ** $QT_END_LICENSE$ 39 ** 40 ****************************************************************************/ 41 42 #ifndef QWINDOWSYSTEM_QWS_P_H 43 #define QWINDOWSYSTEM_QWS_P_H 44 45 46 // 47 // W A R N I N G 48 // ------------- 49 // 50 // This file is not part of the Qt API. It exists for the convenience 51 // of the QWSServer class. This header file may change from 52 // version to version without notice, or even be removed. 53 // 54 // We mean it. 55 // 56 57 #include "private/qobject_p.h" 58 #include "qwindowsystem_qws.h" 59 #include "qbrush.h" 60 #include "qwsproperty_qws.h" 61 #include "qwscommand_qws_p.h" 62 #include "QtCore/qbasictimer.h" 63 64 QT_BEGIN_NAMESPACE 65 66 class QWSServerPrivate : public QObjectPrivate { 67 friend class QCopChannel; 68 friend class QWSMouseHandler; 69 friend class QWSWindow; 70 friend class QWSDisplay; 71 friend class QWSInputMethod; Q_DECLARE_PUBLIC(QWSServer)72 Q_DECLARE_PUBLIC(QWSServer) 73 74 public: 75 QWSServerPrivate() 76 : screensaverintervals(0) 77 , screensavereventblocklevel(-1), screensaverblockevents(false) 78 , saver(0), cursorClient(0), mouseState(0), nReserved(0) 79 , doClientIsActive(false) 80 { 81 } ~QWSServerPrivate()82 ~QWSServerPrivate() 83 { 84 closeDisplay(); 85 86 qDeleteAll(deletedWindows); 87 delete [] screensaverintervals; 88 delete saver; 89 90 qDeleteAll(windows); 91 windows.clear(); 92 93 delete bgBrush; 94 bgBrush = 0; 95 } 96 QTime screensavertime; 97 QTimer* screensavertimer; 98 int* screensaverintervals; 99 int screensavereventblocklevel; 100 bool screensaverblockevents; 101 bool screensaverblockevent( int index, int *screensaverinterval, bool isDown ); 102 QWSScreenSaver* saver; 103 QWSClient *cursorClient; 104 int mouseState; 105 // bool prevWin; 106 QList<QWSWindow*> deletedWindows; 107 QList<int> crashedClientIds; 108 109 void update_regions(); 110 //private functions moved from class 111 112 private: 113 void initServer(int flags); 114 #ifndef QT_NO_COP 115 static void sendQCopEvent(QWSClient *c, const QString &ch, 116 const QString &msg, const QByteArray &data, 117 bool response = false); 118 #endif 119 void move_region(const QWSRegionMoveCommand *); 120 void set_altitude(const QWSChangeAltitudeCommand *); 121 void set_opacity(const QWSSetOpacityCommand *); 122 void request_focus(const QWSRequestFocusCommand *); 123 QRegion reserve_region(QWSWindow *window, const QRegion ®ion); 124 void request_region(int winId, const QString &surfaceKey, 125 const QByteArray &surfaceData, 126 const QRegion ®ion); 127 void repaint_region(int winId, int windowFlags, bool opaque, const QRegion &); 128 void destroy_region(const QWSRegionDestroyCommand *); 129 void name_region(const QWSRegionNameCommand *); 130 void set_identity(const QWSIdentifyCommand *); 131 #ifndef QT_NO_QWS_PROPERTIES 132 bool get_property(int winId, int property, const char *&data, int &len); 133 #endif 134 #ifndef QT_NO_QWS_INPUTMETHODS 135 void im_response(const QWSIMResponseCommand *); 136 137 void im_update(const QWSIMUpdateCommand *); 138 139 void send_im_mouse(const QWSIMMouseCommand *); 140 #endif 141 // not in ifndef as this results in more readable functions. 142 static void sendKeyEventUnfiltered(int unicode, int keycode, Qt::KeyboardModifiers modifiers, 143 bool isPress, bool autoRepeat); 144 static void sendMouseEventUnfiltered(const QPoint &pos, int state, int wheel = 0); 145 static void emergency_cleanup(); 146 147 static QBrush *bgBrush; 148 149 void sendMaxWindowRectEvents(const QRect &rect); 150 151 void invokeIdentify(const QWSIdentifyCommand *cmd, QWSClient *client); 152 void invokeCreate(QWSCreateCommand *cmd, QWSClient *client); 153 void invokeRegionName(const QWSRegionNameCommand *cmd, QWSClient *client); 154 void invokeRegion(QWSRegionCommand *cmd, QWSClient *client); 155 void invokeRegionMove(const QWSRegionMoveCommand *cmd, QWSClient *client); 156 void invokeRegionDestroy(const QWSRegionDestroyCommand *cmd, QWSClient *client); 157 void invokeSetAltitude(const QWSChangeAltitudeCommand *cmd, QWSClient *client); 158 void invokeSetOpacity(const QWSSetOpacityCommand *cmd, QWSClient *client); 159 #ifndef QT_NO_QWS_PROPERTIES 160 void invokeAddProperty(QWSAddPropertyCommand *cmd); 161 void invokeSetProperty(QWSSetPropertyCommand *cmd); 162 void invokeRemoveProperty(QWSRemovePropertyCommand *cmd); 163 void invokeGetProperty(QWSGetPropertyCommand *cmd, QWSClient *client); 164 #endif //QT_NO_QWS_PROPERTIES 165 void invokeSetSelectionOwner(QWSSetSelectionOwnerCommand *cmd); 166 void invokeConvertSelection(QWSConvertSelectionCommand *cmd); 167 void invokeSetFocus(const QWSRequestFocusCommand *cmd, QWSClient *client); 168 169 void initIO(); 170 void setFocus(QWSWindow*, bool gain); 171 #ifndef QT_NO_QWS_CURSOR 172 void invokeDefineCursor(QWSDefineCursorCommand *cmd, QWSClient *client); 173 void invokeSelectCursor(QWSSelectCursorCommand *cmd, QWSClient *client); 174 void invokePositionCursor(QWSPositionCursorCommand *cmd, QWSClient *client); 175 #endif 176 void invokeGrabMouse(QWSGrabMouseCommand *cmd, QWSClient *client); 177 void invokeGrabKeyboard(QWSGrabKeyboardCommand *cmd, QWSClient *client); 178 #ifndef QT_NO_SOUND 179 void invokePlaySound(QWSPlaySoundCommand *cmd, QWSClient *client); 180 #endif 181 #ifndef QT_NO_COP 182 void invokeRegisterChannel(QWSQCopRegisterChannelCommand *cmd, 183 QWSClient *client); 184 void invokeQCopSend(QWSQCopSendCommand *cmd, QWSClient *client); 185 #endif 186 void invokeRepaintRegion(QWSRepaintRegionCommand *cmd, 187 QWSClient *client); 188 #ifndef QT_NO_QWSEMBEDWIDGET 189 void invokeEmbed(QWSEmbedCommand *cmd, QWSClient *client); 190 #endif 191 #ifndef QT_NO_QWS_INPUTMETHODS 192 void invokeIMResponse(const QWSIMResponseCommand *cmd, 193 QWSClient *client); 194 void invokeIMUpdate(const QWSIMUpdateCommand *cmd, 195 QWSClient *client); 196 #endif 197 void invokeFont(const QWSFontCommand *cmd, QWSClient *client); 198 void invokeScreenTransform(const QWSScreenTransformCommand *cmd, 199 QWSClient *client); 200 201 QWSMouseHandler* newMouseHandler(const QString& spec); 202 void openDisplay(); 203 void closeDisplay(); 204 205 void showCursor(); 206 void hideCursor(); 207 void initializeCursor(); 208 209 void resetEngine(); 210 211 //private Q_SLOTS: 212 213 #ifndef QT_NO_QWS_MULTIPROCESS 214 void _q_clientClosed(); 215 void _q_doClient(); 216 void _q_deleteWindowsLater(); 217 #endif 218 219 void _q_screenSaverWake(); 220 void _q_screenSaverSleep(); 221 void _q_screenSaverTimeout(); 222 #ifndef QT_NO_QWS_MULTIPROCESS 223 void _q_newConnection(); 224 #endif 225 226 //other private moved from class 227 228 void disconnectClient(QWSClient *); 229 void screenSave(int level); 230 void doClient(QWSClient *); 231 typedef QMap<int,QWSClient*>::Iterator ClientIterator; 232 typedef QMap<int,QWSClient*> ClientMap; 233 void handleWindowClose(QWSWindow *w); 234 void releaseMouse(QWSWindow* w); 235 void releaseKeyboard(QWSWindow* w); 236 void updateClientCursorPos(); 237 238 uchar* sharedram; 239 int ramlen; 240 241 ClientMap clientMap; 242 #ifndef QT_NO_QWS_PROPERTIES 243 QWSPropertyManager propertyManager; 244 #endif 245 struct SelectionOwner { 246 int windowid; 247 struct Time { setSelectionOwner::Time248 void set(int h, int m, int s, int s2) { 249 hour = h; minute = m; sec = s; ms = s2; 250 } 251 int hour, minute, sec, ms; 252 } time; 253 } selectionOwner; 254 QTime timer; 255 int* screensaverinterval; 256 257 QWSWindow *focusw; 258 QWSWindow *mouseGrabber; 259 bool mouseGrabbing; 260 bool inputMethodMouseGrabbed; 261 int swidth, sheight, sdepth; 262 #ifndef QT_NO_QWS_CURSOR 263 bool haveviscurs; 264 QWSCursor *cursor; // cursor currently shown 265 QWSCursor *nextCursor; // cursor to show once grabbing is off 266 #endif 267 268 bool disablePainting; 269 QList<QWSMouseHandler*> mousehandlers; 270 #ifndef QT_NO_QWS_KEYBOARD 271 QList<QWSKeyboardHandler*> keyboardhandlers; 272 #endif 273 274 QList<QWSCommandStruct*> commandQueue; 275 276 // Window management 277 QList<QWSWindow*> windows; // first=topmost 278 int nReserved; 279 QWSWindow* newWindow(int id, QWSClient* client); 280 QWSWindow* findWindow(int windowid, QWSClient* client = 0); 281 void moveWindowRegion(QWSWindow*, int dx, int dy); 282 void setWindowRegion(QWSWindow*, const QRegion &r); 283 void raiseWindow(QWSWindow *, int = 0); 284 void lowerWindow(QWSWindow *, int = -1); 285 void exposeRegion(const QRegion &, int index = 0); 286 287 void setCursor(QWSCursor *curs); 288 289 // multimedia 290 #ifndef QT_NO_SOUND 291 QWSSoundServer *soundserver; 292 #endif 293 #ifndef QT_NO_COP 294 QMap<QString, QList<QWSClient*> > channels; 295 #endif 296 297 #ifndef QT_NO_QWS_MULTIPROCESS 298 QWSServerSocket *ssocket; 299 #endif 300 301 // filename -> refcount 302 QMap<QByteArray, int> fontReferenceCount; 303 QBasicTimer fontCleanupTimer; 304 void referenceFont(QWSClientPrivate *client, const QByteArray &font); 305 void dereferenceFont(QWSClientPrivate *client, const QByteArray &font); 306 void cleanupFonts(bool force = false); 307 void sendFontRemovedEvent(const QByteArray &font); 308 309 bool doClientIsActive; 310 QList<QWSClient*> pendingDoClients; 311 }; 312 313 QT_END_NAMESPACE 314 315 #endif 316