Qt 4.8
qwindowsystem_qws.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QWINDOWSYSTEM_QWS_H
43 #define QWINDOWSYSTEM_QWS_H
44 
45 #include <QtCore/qbytearray.h>
46 #include <QtCore/qmap.h>
47 #include <QtCore/qdatetime.h>
48 #include <QtCore/qlist.h>
49 
50 #include <QtGui/qwsevent_qws.h>
51 #include <QtGui/qkbd_qws.h>
52 #include <QtGui/qregion.h>
53 
55 
57 
58 QT_MODULE(Gui)
59 
60 struct QWSWindowPrivate;
61 class QWSCursor;
62 class QWSClient;
63 class QWSRegionManager;
64 class QBrush;
65 class QVariant;
66 class QInputMethodEvent;
67 class QWSInputMethod;
68 class QWSBackingStore;
69 class QWSWindowSurface;
70 
71 #ifdef QT3_SUPPORT
72 class QImage;
73 class QColor;
74 #endif
75 
77 {
78 public:
79  int winid;
80  unsigned int clientid;
81  QString name; // Corresponds to QObject name of top-level widget
82 };
83 
84 
86 {
87 public:
88  virtual ~QWSScreenSaver();
89  virtual void restore()=0;
90  virtual bool save(int level)=0;
91 };
92 
93 
95 {
96  friend class QWSServer;
97  friend class QWSServerPrivate;
98 
99 public:
100  QWSWindow(int i, QWSClient* client);
101  ~QWSWindow();
102 
103  int winId() const { return id; }
104  const QString &name() const { return rgnName; }
105  const QString &caption() const { return rgnCaption; }
106  QWSClient* client() const { return c; }
107  const QRegion &requestedRegion() const { return requested_region; }
108  QRegion allocatedRegion() const;
109  QRegion paintedRegion() const;
110  bool isVisible() const { return !requested_region.isEmpty(); }
111  bool isPartiallyObscured() const { return requested_region != allocatedRegion(); }
112  bool isFullyObscured() const { return allocatedRegion().isEmpty(); }
113 
114  enum State { NoState, Hidden, Showing, Visible, Hiding, Raising, Lowering, Moving, ChangingGeometry, Destroyed };
115  State state() const;
116  Qt::WindowFlags windowFlags() const;
117  QRegion dirtyOnScreen() const;
118 
119  void raise();
120  void lower();
121  void show();
122  void hide();
123  void setActiveWindow();
124 
125  bool isOpaque() const {return opaque && _opacity == 255;}
126  uint opacity() const { return _opacity; }
127 
128  QWSWindowSurface* windowSurface() const { return surface; }
129 
130 private:
131  bool hidden() const { return requested_region.isEmpty(); }
132  bool forClient(const QWSClient* cl) const { return cl==c; }
133 
134  void setName(const QString &n);
135  void setCaption(const QString &c);
136 
137  void focus(bool get);
138  int focusPriority() const { return last_focus_time; }
139  void operation(QWSWindowOperationEvent::Operation o);
140  void shuttingDown() { last_focus_time=0; }
141 
142 #ifdef QT_QWS_CLIENTBLIT
143  QRegion directPaintRegion() const;
144  inline void setDirectPaintRegion(const QRegion &topmost);
145 #endif
146  inline void setAllocatedRegion(const QRegion &region);
147 
148  void createSurface(const QString &key, const QByteArray &data);
149 
150 #ifndef QT_NO_QWSEMBEDWIDGET
151  void startEmbed(QWSWindow *window);
152  void stopEmbed(QWSWindow *window);
153 #endif
154 
155 private:
156  int id;
159  bool modified;
160  bool onTop;
167  bool opaque;
169 #ifdef QT3_SUPPORT
170  inline QT3_SUPPORT QRegion requested() const { return requested_region; }
171 // inline QT3_SUPPORT QRegion allocation() const { return allocated_region; }
172 #endif
173 };
174 
175 
176 #ifndef QT_NO_SOUND
177 class QWSSoundServer;
178 #ifdef QT_USE_OLD_QWS_SOUND
179 class QWSSoundServerData;
180 
181 class Q_GUI_EXPORT QWSSoundServer : public QObject {
182  Q_OBJECT
183 public:
184  QWSSoundServer(QObject* parent);
185  ~QWSSoundServer();
186  void playFile(const QString& filename);
187 private Q_SLOTS:
188  void feedDevice(int fd);
189 private:
190  QWSSoundServerData* d;
191 };
192 #endif
193 #endif
194 
195 
196 /*********************************************************************
197  *
198  * Class: QWSServer
199  *
200  *********************************************************************/
201 
202 class QWSMouseHandler;
203 struct QWSCommandStruct;
204 class QWSServerPrivate;
205 class QWSServer;
206 
208 
210 {
211  friend class QCopChannel;
212  friend class QWSMouseHandler;
213  friend class QWSWindow;
214  friend class QWSDisplay;
215  friend class QWSInputMethod;
216  Q_OBJECT
218 public:
219  explicit QWSServer(int flags = 0, QObject *parent=0);
220 #ifdef QT3_SUPPORT
221  QT3_SUPPORT_CONSTRUCTOR QWSServer(int flags, QObject *parent, const char *name);
222 #endif
223  ~QWSServer();
224  enum ServerFlags { DisableKeyboard = 0x01,
225  DisableMouse = 0x02 };
226 
227  static void sendKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
228  bool isPress, bool autoRepeat);
229 #ifndef QT_NO_QWS_KEYBOARD
230  static void processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
231  bool isPress, bool autoRepeat);
232 #endif
233 
234  static QWSServer* instance() { return qwsServer; }
235 
236 #ifndef QT_NO_QWS_INPUTMETHODS
237 #ifdef QT3_SUPPORT
238  enum IMState { IMCompose, IMEnd, IMStart = IMCompose };
239 #endif
240  enum IMMouse { MousePress, MouseRelease, MouseMove, MouseOutside }; //MouseMove reserved but not used
241  void sendIMEvent(const QInputMethodEvent*);
242  void sendIMQuery(int property);
243 #endif
244 
245 #ifndef QT_NO_QWS_KEYBOARD
247  {
248  public:
249  virtual ~KeyboardFilter() {}
250  virtual bool filter(int unicode, int keycode, int modifiers,
251  bool isPress, bool autoRepeat)=0;
252  };
253  static void addKeyboardFilter(KeyboardFilter *f);
254  static void removeKeyboardFilter();
255 #endif
256 
257 #ifndef QT_NO_QWS_INPUTMETHODS
258  static void setCurrentInputMethod(QWSInputMethod *im);
259  static void resetInputMethod();
260 #endif
261 
262  static void setDefaultMouse(const char *);
263  static void setDefaultKeyboard(const char *);
264  static void setMaxWindowRect(const QRect&);
265  static void sendMouseEvent(const QPoint& pos, int state, int wheel = 0);
266 
267  static void setBackground(const QBrush &);
268 #ifdef QT3_SUPPORT
269  static QT3_SUPPORT void setDesktopBackground(const QImage &img);
270  static QT3_SUPPORT void setDesktopBackground(const QColor &);
271 #endif
272  static QWSMouseHandler *mouseHandler();
273  static const QList<QWSMouseHandler*>& mouseHandlers();
274  static void setMouseHandler(QWSMouseHandler*);
275 #ifndef QT_NO_QWS_KEYBOARD
276  static QWSKeyboardHandler* keyboardHandler();
277  static void setKeyboardHandler(QWSKeyboardHandler* kh);
278 #endif
279  QWSWindow *windowAt(const QPoint& pos);
280 
281  const QList<QWSWindow*> &clientWindows();
282 
283  void openMouse();
284  void closeMouse();
285  void suspendMouse();
286  void resumeMouse();
287 #ifndef QT_NO_QWS_KEYBOARD
288  void openKeyboard();
289  void closeKeyboard();
290 #endif
291 
292  static void setScreenSaver(QWSScreenSaver*);
293  static void setScreenSaverIntervals(int* ms);
294  static void setScreenSaverInterval(int);
295  static void setScreenSaverBlockLevel(int);
296  static bool screenSaverActive();
297  static void screenSaverActivate(bool);
298 
299  // the following are internal.
300  void refresh();
301  void refresh(QRegion &);
302 
303  void enablePainting(bool);
304  static void processEventQueue();
305  static QList<QWSInternalWindowInfo*> * windowList();
306 
307  void sendPropertyNotifyEvent(int property, int state);
308 
310 
311  static void startup(int flags);
312  static void closedown();
313 
314  static void beginDisplayReconfigure();
315  static void endDisplayReconfigure();
316 
317 #ifndef QT_NO_QWS_CURSOR
318  static void setCursorVisible(bool);
319  static bool isCursorVisible();
320 #endif
321 
322  const QBrush &backgroundBrush() const;
323 
324  enum WindowEvent { Create=0x0001, Destroy=0x0002, Hide=0x0004, Show=0x0008,
325  Raise=0x0010, Lower=0x0020, Geometry=0x0040, Active = 0x0080,
326  Name=0x0100 };
327 
328 Q_SIGNALS:
329  void windowEvent(QWSWindow *w, QWSServer::WindowEvent e);
330 
331 #ifndef QT_NO_COP
332  void newChannel(const QString& channel);
333  void removedChannel(const QString& channel);
334 
335 #endif
336 #ifndef QT_NO_QWS_INPUTMETHODS
337  void markedText(const QString &);
338 #endif
339 
340 protected:
341  void timerEvent(QTimerEvent *e);
342 
343 private:
344  friend class QApplicationPrivate;
345  void updateWindowRegions() const;
346 
347 #ifdef QT3_SUPPORT
348 #ifndef QT_NO_QWS_KEYBOARD
349  static inline QT3_SUPPORT void setKeyboardFilter(QWSServer::KeyboardFilter *f)
350  { if (f) addKeyboardFilter(f); else removeKeyboardFilter(); }
351 #endif
352 #endif
353 
354 private:
355 #ifndef QT_NO_QWS_MULTIPROCESS
356  Q_PRIVATE_SLOT(d_func(), void _q_clientClosed())
357  Q_PRIVATE_SLOT(d_func(), void _q_doClient())
358  Q_PRIVATE_SLOT(d_func(), void _q_deleteWindowsLater())
359 #endif
360 
361  Q_PRIVATE_SLOT(d_func(), void _q_screenSaverWake())
362  Q_PRIVATE_SLOT(d_func(), void _q_screenSaverSleep())
363  Q_PRIVATE_SLOT(d_func(), void _q_screenSaverTimeout())
364 
365 #ifndef QT_NO_QWS_MULTIPROCESS
366  Q_PRIVATE_SLOT(d_func(), void _q_newConnection())
367 #endif
368 };
369 
370 #ifndef QT_NO_QWS_INPUTMETHODS
372 {
373  Q_OBJECT
374 public:
375  QWSInputMethod();
376  virtual ~QWSInputMethod();
377 
378  enum UpdateType {Update, FocusIn, FocusOut, Reset, Destroyed};
379 
380  virtual bool filter(int unicode, int keycode, int modifiers,
381  bool isPress, bool autoRepeat);
382 
383  virtual bool filter(const QPoint &, int state, int wheel);
384 
385  virtual void reset();
386  virtual void updateHandler(int type);
387  virtual void mouseHandler(int pos, int state);
388  virtual void queryResponse(int property, const QVariant&);
389 
390 protected:
391  uint setInputResolution(bool isHigh);
392  uint inputResolutionShift() const;
393  // needed for required transform
394  void sendMouseEvent(const QPoint &pos, int state, int wheel);
395 
396  void sendEvent(const QInputMethodEvent*);
397  void sendPreeditString(const QString &preeditString, int cursorPosition, int selectionLength = 0);
398  void sendCommitString(const QString &commitString, int replaceFrom = 0, int replaceLength = 0);
399  void sendQuery(int property);
400 
401 #ifdef QT3_SUPPORT
402  inline void sendIMEvent(QWSServer::IMState, const QString& txt, int cpos, int selLen = 0);
403 #endif
404 private:
406 };
407 
409 {
410  qwsServer->sendIMEvent(ime);
411 }
412 #ifdef QT3_SUPPORT
413 inline void QWSInputMethod::sendIMEvent(QWSServer::IMState state, const QString& txt, int cpos, int selLen)
414 {
415  if (state == QWSServer::IMCompose) sendPreeditString(txt, cpos, selLen); else sendCommitString(txt);
416 }
417 #endif
418 
419 inline void QWSInputMethod::sendQuery(int property)
420 {
421  qwsServer->sendIMQuery(property);
422 }
423 
424 // mouse events not inline as involve transformations.
425 #endif // QT_NO_QWS_INPUTMETHODS
426 
427 
428 
429 /*********************************************************************
430  *
431  * Class: QWSClient
432  *
433  *********************************************************************/
434 
436 
438 
439 class QWSClientPrivate;
440 class QWSCommand;
442 
444 {
445  Q_OBJECT
447 public:
448  QWSClient(QObject* parent, QWS_SOCK_BASE *, int id);
449  ~QWSClient();
450 
451  int socket() const;
452 
453  void setIdentity(const QString&);
454  QString identity() const { return id; }
455 
456  void sendEvent(QWSEvent* event);
457  void sendConnectedEvent(const char *display_spec);
458  void sendMaxWindowRectEvent(const QRect &rect);
459  void sendPropertyNotifyEvent(int property, int state);
460  void sendPropertyReplyEvent(int property, int len, const char *data);
461  void sendSelectionClearEvent(int windowid);
462  void sendSelectionRequestEvent(QWSConvertSelectionCommand *cmd, int windowid);
463 #ifndef QT_QWS_CLIENTBLIT
464  void sendRegionEvent(int winid, QRegion rgn, int type);
465 #else
466  void sendRegionEvent(int winid, QRegion rgn, int type, int id = 0);
467 #endif
468 #ifndef QT_NO_QWSEMBEDWIDGET
469  void sendEmbedEvent(int winid, QWSEmbedEvent::Type type,
470  const QRegion &region = QRegion());
471 #endif
472  QWSCommand* readMoreCommand();
473 
474  int clientId() const { return cid; }
475 
476  QWSCursorMap cursors; // cursors defined by this client
477 Q_SIGNALS:
478  void connectionClosed();
479  void readyRead();
480 private Q_SLOTS:
481  void closeHandler();
482  void errorHandler();
483 
484 private:
485 #ifndef QT_NO_QWS_MULTIPROCESS
486  friend class QWSWindow;
487  void removeUnbufferedSurface();
488  void addUnbufferedSurface();
489 #endif
490 
491 private:
493 #ifndef QT_NO_QWS_MULTIPROCESS
495 #endif
499  int cid;
500 
501  friend class QWSServerPrivate;
502 };
503 
505 
507 
508 #endif // QWINDOWSYSTEM_QWS_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
The QWSWindowSurface class provides the drawing area for top-level windows in Qt for Embedded Linux...
The QWSDisplay class provides a display for QWS; it is an internal class.
void sendEvent(const QInputMethodEvent *)
Sends the given event to the focus widget.
The QWSKeyboardHandler class is a base class for keyboard drivers in Qt for Embedded Linux...
Definition: qkbd_qws.h:57
int type
Definition: qmetatype.cpp:239
The KeyboardFilter class is a base class for global keyboard event filters in Qt for Embedded Linux...
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
EventRef event
#define QT_MODULE(x)
Definition: qglobal.h:2783
QWSWindowSurface * surface
int keycode
static QWSServer * instance()
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
Q_CORE_EXPORT QTextStream & reset(QTextStream &s)
The QWSMouseHandler class is a base class for mouse drivers in Qt for Embedded Linux.
Definition: qmouse_qws.h:66
bool isPartiallyObscured() const
Returns true if the window is partially obsured by another window or by the bounds of the screen; oth...
QWSClient * client() const
Returns a reference to the QWSClient object that owns this window.
void sendQuery(int property)
Sends an input method query (internally encapsulated by a QWSEvent of the QWSEvent::IMQuery{IMQuery} ...
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
The QWSScreenSaver class is a base class for screensavers in Qt for Embedded Linux.
friend class QWSWindow
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QString class provides a Unicode character string.
Definition: qstring.h:83
QRegion requested_region
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
bool hidden() const
QString rgnCaption
The QWSEvent class encapsulates an event in Qt for Embedded Linux.
Definition: qwsevent_qws.h:59
The QWSWindow class encapsulates a top-level window in Qt for Embedded Linux.
NSWindow * window
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
UpdateType
This enum describes the various types of update events recognized by the input method.
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
virtual ~KeyboardFilter()
Destroys the keyboard filter.
QWSSocket * csocket
QWSCursorMap cursors
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
void sendIMQuery(int property)
Sends an input method query for the given property.
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
static void sendKeyEvent(KeyAction action, QWidget *widget, Qt::Key code, QString text, Qt::KeyboardModifiers modifier, int delay=-1)
Definition: qtestkeyboard.h:87
QWSCommand * command
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
The State element defines configurations of objects and properties.
int focusPriority() const
ServerFlags
This enum is used to pass various options to the window system server.
bool isFullyObscured() const
Returns true if the window is completely obsured by another window or by the bounds of the screen; ot...
QWSWindowPrivate * d
#define Q_OBJECT
Definition: qobjectdefs.h:157
uint opacity() const
Returns the window&#39;s alpha channel value.
void sendIMEvent(const QInputMethodEvent *)
Sends the given input method event.
bool isVisible() const
Returns true if the window is visible; otherwise returns false.
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
QString identity() const
Returns the name of this client&#39;s running application.
int winId() const
Returns the window&#39;s ID.
WindowEvent
This enum specifies the various events that can occur in a top-level window.
Q_GUI_EXPORT EGLSurface createSurface(QPaintDevice *device, EGLConfig cfg, const QEglProperties *surfaceAttribs=0)
Definition: qegl_x11.cpp:333
The QWSServer class encapsulates a server process in Qt for Embedded Linux.
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
#define QWS_SOCK_BASE
Definition: qwsutils_qws.h:54
const QRegion & requestedRegion() const
Returns the region that the window has requested to draw onto, including any window decorations...
int clientId() const
Returns an integer uniquely identfying this client.
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
QWSClient * c
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void shuttingDown()
const char * property
Definition: qwizard.cpp:138
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QFuture< void > filter(Sequence &sequence, FilterFunction filterFunction)
QWSWindowSurface * windowSurface() const
static void setMaxWindowRect(const QRect &rect)
The QCopChannel class provides communication capabilities between clients in Qt for Embedded Linux...
static QPoint mousePosition
const QString & caption() const
Returns the window&#39;s caption.
Q_GUI_EXPORT QWSServer * qwsServer
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
const QString & name() const
Returns the window&#39;s name, which is taken from the QWidget::objectName() at the time of QWidget::show...
bool isOpaque() const
Returns true if the window is opaque, i.
bool forClient(const QWSClient *cl) const
#define QT_END_HEADER
Definition: qglobal.h:137
The QWSClient class encapsulates a client process in Qt for Embedded Linux.
IMMouse
This enum describes the various types of mouse events recognized by the QWSInputMethod::mouseHandler(...
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
QMap< int, QWSCursor * > QWSCursorMap
The QWSInputMethod class provides international input methods in Qt for Embedded Linux.