Qt 4.8
qapplication_qws.cpp
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 #include "qglobal.h"
43 #include "qlibrary.h"
44 #include "qcursor.h"
45 #include "qapplication.h"
46 #include "private/qapplication_p.h"
47 #include "qwidget.h"
48 #include "qbitarray.h"
49 #include "qpainter.h"
50 #include "qpixmapcache.h"
51 #include "qdatetime.h"
52 #include "qtextcodec.h"
53 #include "qdatastream.h"
54 #include "qbuffer.h"
55 #include "qsocketnotifier.h"
56 #include "qsessionmanager.h"
57 #include "qclipboard.h"
58 #include "qbitmap.h"
59 #include "qwssocket_qws.h"
60 #include "qtransportauth_qws.h"
61 #include "private/qtransportauth_qws_p.h"
62 #include "qwsevent_qws.h"
63 #include "private/qwscommand_qws_p.h"
64 #include "qwsproperty_qws.h"
65 #include "qscreen_qws.h"
66 #include "qscreenproxy_qws.h"
67 #include "qcopchannel_qws.h"
68 #include "private/qlock_p.h"
69 #include "private/qwslock_p.h"
70 //#include "qmemorymanager_qws.h"
71 #include "qwsmanager_qws.h"
72 //#include "qwsregionmanager_qws.h"
73 #include "qwindowsystem_qws.h"
74 #include "private/qwindowsystem_p.h"
75 #include "qdecorationfactory_qws.h"
76 
77 #include "qwsdisplay_qws.h"
78 #include "private/qwsdisplay_qws_p.h"
79 #include "private/qwsinputcontext_p.h"
80 #include "qfile.h"
81 #include "qhash.h"
82 #include "qdesktopwidget.h"
83 #include "qcolormap.h"
84 #include "private/qcursor_p.h"
85 #include "qsettings.h"
86 #include "qdebug.h"
87 #include "qeventdispatcher_qws_p.h"
88 #if !defined(QT_NO_GLIB)
90 #endif
91 
92 
93 #include "private/qwidget_p.h"
94 #include "private/qbackingstore_p.h"
95 #include "private/qwindowsurface_qws_p.h"
96 #include "private/qfont_p.h"
97 
98 #include <unistd.h>
99 #include <stdio.h>
100 #include <stdlib.h>
101 #include <string.h>
102 #include <locale.h>
103 #include <errno.h>
104 #include <fcntl.h>
105 #include <sys/stat.h>
106 #include <sys/types.h>
107 
108 #include <qvfbhdr.h>
109 
111 
112 #ifndef QT_NO_DIRECTPAINTER
113 class QDirectPainter;
114 extern void qt_directpainter_region(QDirectPainter *dp, const QRegion &alloc, int type);
115 #ifndef QT_NO_QWSEMBEDWIDGET
117  const QWSEmbedEvent *e);
118 #endif
119 #endif // QT_NO_DIRECTPAINTER
120 
121 const int qwsSharedRamSize = 1 * 1024; // misc data, written by server, read by clients
122 
125 
126 //these used to be environment variables, they are initialized from
127 //environment variables in
128 
129 bool qws_savefonts = false;
130 bool qws_screen_is_interlaced=false; //### should be detected
131 bool qws_shared_memory = false;
132 bool qws_sw_cursor = true;
133 bool qws_accel = true; // ### never set
139 int *qt_last_x = 0;
140 int *qt_last_y = 0;
141 
142 static int mouse_x_root = -1;
143 static int mouse_y_root = -1;
144 static int mouse_state = 0;
146 
147 int qt_servershmid = -1;
148 
149 bool qws_overrideCursor = false;
150 #ifndef QT_NO_QWS_MANAGER
151 
153 
154 static QDecoration *qws_decoration = 0;
155 #endif
156 
157 #if defined(QT_DEBUG)
158 /*
159 extern "C" void dumpmem(const char* m)
160 {
161  static int init=0;
162  static int prev=0;
163  FILE* f = fopen("/proc/meminfo","r");
164  // char line[100];
165  int total=0,used=0,free=0,shared=0,buffers=0,cached=0;
166  fscanf(f,"%*[^M]Mem: %d %d %d %d %d %d",&total,&used,&free,&shared,&buffers,&cached);
167  used -= buffers + cached;
168  if (!init) {
169  init=used;
170  } else {
171  printf("%40s: %+8d = %8d\n",m,used-init-prev,used-init);
172  prev = used-init;
173  }
174  fclose(f);
175 }
176 */
177 #endif
178 
179 // Get the name of the directory where Qt for Embedded Linux temporary data should
180 // live.
182 {
183  static QString result;
184  if (!result.isEmpty())
185  return result;
186  result = QT_VFB_DATADIR(qws_display_id);
187  QByteArray dataDir = result.toLocal8Bit();
188 
189 #if defined(Q_OS_INTEGRITY)
190  /* ensure filesystem is ready before starting requests */
191  WaitForFileSystemInitialization();
192 #endif
193 
194  if (QT_MKDIR(dataDir, 0700)) {
195  if (errno != EEXIST) {
196  qFatal("Cannot create Qt for Embedded Linux data directory: %s", dataDir.constData());
197  }
198  }
199 
200  QT_STATBUF buf;
201  if (QT_LSTAT(dataDir, &buf))
202  qFatal("stat failed for Qt for Embedded Linux data directory: %s", dataDir.constData());
203 
204  if (!S_ISDIR(buf.st_mode))
205  qFatal("%s is not a directory", dataDir.constData());
206 
207 #if !defined(Q_OS_INTEGRITY) && !defined(Q_OS_VXWORKS) && !defined(Q_OS_QNX)
208  if (buf.st_uid != getuid())
209  qFatal("Qt for Embedded Linux data directory is not owned by user %d: %s", getuid(), dataDir.constData());
210 
211  if ((buf.st_mode & 0677) != 0600)
212  qFatal("Qt for Embedded Linux data directory has incorrect permissions: %s", dataDir.constData());
213 #endif
214 
215  result.append(QLatin1Char('/'));
216  return result;
217 }
218 
219 // Get the filename of the pipe Qt for Embedded Linux uses for server/client comms
221 {
222  qws_dataDir();
223  return QTE_PIPE(qws_display_id);
224 }
225 
226 static void setMaxWindowRect(const QRect &rect)
227 {
228  const QList<QScreen*> subScreens = qt_screen->subScreens();
229  QScreen *screen = qt_screen;
230  int screenNo = 0;
231  for (int i = 0; i < subScreens.size(); ++i) {
232  if (subScreens.at(i)->region().contains(rect)) {
233  screen = subScreens.at(i);
234  screenNo = i;
235  break;
236  }
237  }
238 
240  ap->setMaxWindowRect(screen, screenNo, rect);
241 }
242 
243 void QApplicationPrivate::setMaxWindowRect(const QScreen *screen, int screenNo,
244  const QRect &rect)
245 {
246  if (maxWindowRects.value(screen) == rect)
247  return;
248 
249  maxWindowRects[screen] = rect;
250 
251  // Re-resize any maximized windows
253  for (int i = 0; i < l.size(); ++i) {
254  QWidget *w = l.at(i);
255  QScreen *s = w->d_func()->getScreen();
256  if (s == screen) {
257  if (w->isMaximized())
258  w->d_func()->setMaxWindowState_helper();
259  else if (w->isFullScreen())
260  w->d_func()->setFullScreenSize_helper();
261  }
262  }
263 
264  if ( qt_desktopWidget ) // XXX workaround crash
266 }
267 
268 #ifndef QT_NO_QWS_DYNAMICSCREENTRANSFORMATION
269 
270 typedef void (*TransformFunc)(QScreen *, int);
271 #ifndef QT_NO_QWS_TRANSFORMED
272 extern "C" void qws_setScreenTransformation(QScreen *, int);
273 #endif
275 {
276  static TransformFunc func = 0;
277 
278  if (!func) {
279 #ifdef QT_NO_QWS_TRANSFORMED
280 # ifndef QT_NO_LIBRARY
281  // symbol is not built into the library, search for the plugin
282  const QStringList paths = QApplication::libraryPaths();
283  foreach (const QString &path, paths) {
284  const QString file = path + QLatin1String("/gfxdrivers/libqgfxtransformed");
285  func = (TransformFunc)QLibrary::resolve(file,
286  "qws_setScreenTransformation");
287  if (func)
288  break;
289  }
290 # endif
291 #else
293 #endif
294  if (!func)
295  func = (TransformFunc)-1;
296  }
297 
298  if (func == (TransformFunc)-1)
299  return 0;
300 
301  return func;
302 }
303 
304 static void setScreenTransformation(int screenNo, int transformation)
305 {
306  QScreen *screen = QScreen::instance();
307  const QList<QScreen*> subScreens = screen->subScreens();
308 
309  if (screenNo == -1)
310  screenNo = 0;
311 
312  if (screenNo == -1 && !subScreens.isEmpty())
313  screenNo = 0;
314 
315  if (subScreens.isEmpty() && screenNo == 0) {
316  // nothing
317  } else if (screenNo < 0 || screenNo >= subScreens.size()) {
318  qWarning("setScreenTransformation: invalid screen %i", screenNo);
319  return;
320  }
321 
322  if (screenNo < subScreens.size())
323  screen = subScreens.at(screenNo);
324 
326  ap->setScreenTransformation(screen, screenNo, transformation);
327 }
328 
330  int screenNo,
331  int transformation)
332 {
333  QScreen *transformed = screen;
334 
335  while (transformed->classId() == QScreen::ProxyClass)
336  transformed = static_cast<QProxyScreen*>(transformed)->screen();
337 
338  if (transformed->classId() != QScreen::TransformedClass)
339  return;
340 
342  if (!setScreenTransformation)
343  return;
344 
345  setScreenTransformation(transformed, transformation);
346 
347  // need to re-configure() proxies bottom-up
348  if (screen->classId() == QScreen::ProxyClass) {
349  QList<QProxyScreen*> proxies;
350  QScreen *s = screen;
351 
352  do {
353  QProxyScreen *proxy = static_cast<QProxyScreen*>(s);
354  proxies.append(proxy);
355  s = proxy->screen();
356  } while (s->classId() == QScreen::ProxyClass);
357 
358  do {
359  QProxyScreen *proxy = proxies.takeLast();
360  proxy->setScreen(proxy->screen()); // triggers configure()
361  } while (!proxies.isEmpty());
362  }
363 
364  if (qt_desktopWidget) { // XXX workaround crash for early screen transform events
366 
367  emit desktop->resized(screenNo);
368  if (maxWindowRect(screen).isEmpty()) // not explicitly set
369  emit desktop->workAreaResized(screenNo);
370  }
371 
373  if (server) {
374  server->updateWindowRegions();
375  QRegion r = screen->region();
376  server->refresh(r);
377  }
378 
379  // make sure maximized and fullscreen windows are updated
381  for (int i = list.size() - 1; i >= 0; --i) {
382  QWidget *w = list.at(i);
383  if (w->isFullScreen())
384  w->d_func()->setFullScreenSize_helper();
385  else if (w->isMaximized())
386  w->d_func()->setMaxWindowState_helper();
387  }
388 }
389 
390 #endif // QT_NO_QWS_DYNAMICSCREENTRANSFORMATION
391 
392 /*****************************************************************************
393  Internal variables and functions
394  *****************************************************************************/
395 
396 
397 static QString appName; // application name
398 static const char *appFont = 0; // application font
399 static const char *appBGCol = 0; // application bg color
400 static const char *appFGCol = 0; // application fg color
401 static const char *appBTNCol = 0; // application btn color
402 static const char *mwGeometry = 0; // main widget geometry
403 static const char *mwTitle = 0; // main widget title
404 //static bool mwIconic = false; // main widget iconified
405 
406 static bool app_do_modal = false; // modal mode
407 Q_GUI_EXPORT QWSDisplay *qt_fbdpy = 0; // QWS `display'
409 
410 static int mouseButtonPressed = 0; // last mouse button pressed
411 static int mouseButtonPressTime = 0; // when was a button pressed
412 static short mouseXPos, mouseYPos; // mouse position in act window
413 
414 extern QWidgetList *qt_modal_stack; // stack of modal widgets
415 
418 static bool popupCloseDownMode = false;
419 static bool popupGrabOk;
422 
423 static bool sm_blockUserInput = false; // session management
424 
425 QWidget *qt_button_down = 0; // widget got last button-down
426 WId qt_last_cursor = 0xffffffff; // Was -1, but WIds are unsigned
427 
428 class QWSMouseEvent;
429 class QWSKeyEvent;
430 
431 class QETWidget : public QWidget // event translator widget
432 {
433 public:
434  bool translateMouseEvent(const QWSMouseEvent *, int oldstate);
435  bool translateKeyEvent(const QWSKeyEvent *, bool grab);
436  bool translateRegionEvent(const QWSRegionEvent *);
437 #ifndef QT_NO_QWSEMBEDWIDGET
438  void translateEmbedEvent(const QWSEmbedEvent *event);
439 #endif
440  bool translateWheelEvent(const QWSMouseEvent *me);
441  void repaintDecoration(QRegion r, bool post);
442  void updateRegion();
443 
445  {
446  // With limited windowmanagement/taskbar/etc., raising big windows
447  // (eg. spreadsheet) over the top of everything else (eg. calculator)
448  // is just annoying.
449  return !isMaximized() && !isFullScreen();
450  }
451 };
452 
454 {
455  Q_Q(QApplication);
456 #if !defined(QT_NO_GLIB)
457  if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported())
458  eventDispatcher = (q->type() != QApplication::Tty
459  ? new QWSEventDispatcherGlib(q)
460  : new QEventDispatcherGlib(q));
461  else
462 #endif
463  eventDispatcher = (q->type() != QApplication::Tty
464  ? new QEventDispatcherQWS(q)
465  : new QEventDispatcherUNIX(q));
466 }
467 
468 // Single-process stuff. This should maybe move into qwindowsystem_qws.cpp
469 
470 static bool qws_single_process;
473 
475 {
476  QWSEvent *copy = QWSEvent::factory(event->type);
477  copy->copyFrom(event);
478  incoming.append(copy);
479 }
480 
482 {
483  return &outgoing;
484 }
485 
486 void qt_server_enqueue(const QWSCommand *command)
487 {
488  QWSCommand *copy = QWSCommand::factory(command->type);
489  QT_TRY {
490  copy->copyFrom(command);
491  outgoing.append(copy);
492  } QT_CATCH(...) {
493  delete copy;
494  QT_RETHROW;
495  }
496 }
497 
498 QWSDisplay::Data::Data(QObject* parent, bool singleProcess)
499 {
500 #ifdef QT_NO_QWS_MULTIPROCESS
501  Q_UNUSED(parent);
502  Q_UNUSED(singleProcess);
503 #else
504  if (singleProcess)
505  csocket = 0;
506  else {
507  csocket = new QWSSocket(parent);
508  QObject::connect(csocket, SIGNAL(disconnected()),
509  qApp, SLOT(quit()));
510  }
511  clientLock = 0;
512 #endif
513  init();
514 }
515 
517 {
518 // delete rgnMan; rgnMan = 0;
519 // delete memorymanager; memorymanager = 0;
521  delete qt_screen; qt_screen = 0;
522 #ifndef QT_NO_QWS_CURSOR
523  delete qt_screencursor; qt_screencursor = 0;
524 #endif
525 #ifndef QT_NO_QWS_MULTIPROCESS
526  shm.detach();
527  if (csocket) {
528  QWSCommand shutdownCmd(QWSCommand::Shutdown, 0, 0);
529  shutdownCmd.write(csocket);
530  csocket->flush(); // may be pending QCop message, eg.
531  delete csocket;
532  }
533  delete clientLock;
534  clientLock = 0;
535 #endif
536  delete connected_event;
537  delete mouse_event;
538  delete current_event;
539  qDeleteAll(queue);
540 #ifndef QT_NO_COP
541  delete qcop_response;
542 #endif
543 }
544 
545 #ifndef QT_NO_QWS_MULTIPROCESS
547 {
548  return !clientLock || clientLock->lock(type, timeout);
549 }
550 
552 {
553  if (clientLock) clientLock->unlock(type);
554 }
555 
557 {
558  return !clientLock || clientLock->wait(type, timeout);
559 }
560 
562 {
563  return clientLock;
564 }
565 #endif // QT_NO_QWS_MULTIPROCESS
566 
568 {
569 #ifndef QT_NO_QWS_MULTIPROCESS
570  if (csocket) {
571  csocket->waitForReadyRead(0);
572  csocket->flush();
573  }
574 #endif
575 }
576 
577 #if 0
578 void QWSDisplay::Data::debugQueue() {
579  for (int i = 0; i < queue.size(); ++i) {
580  QWSEvent *e = queue.at(i);
581  qDebug( " ev %d type %d sl %d rl %d", i, e->type, e->simpleLen, e->rawLen);
582  }
583 }
584 #endif
585 
587 {
588  return mouse_event/*||region_event*/||queue.count() > 0;
589 }
591 {
592  QWSEvent *r=0;
593  if (queue.count()) {
594  r = queue.first();
595  queue.removeFirst();
596  if (r->type == QWSEvent::Region)
597  region_events_count--;
598  } else if (mouse_event) {
599  r = mouse_event;
600  mouse_event = 0;
601 #ifdef QAPPLICATION_EXTRA_DEBUG
602  mouse_event_count = 0;
603 #endif
604  }
605  return r;
606 }
607 
609 {
610  return queue.first();
611 }
612 
614 {
615 #ifndef QT_NO_QWS_MULTIPROCESS
616  return csocket == 0;
617 #else
618  return true;
619 #endif
620 }
621 
623 {
624  QWSCreateCommand cmd(n);
625  sendCommand(cmd);
626 }
627 
629 {
630 #ifndef QT_NO_QWS_MULTIPROCESS
631  if (csocket)
632  csocket->flush();
633 #endif
634 }
635 
637 {
638 #ifndef QT_NO_QWS_MULTIPROCESS
639  if (csocket)
640  cmd.write(csocket);
641  else
642 #endif
643  qt_server_enqueue(&cmd);
644 }
645 
647 {
648 #ifndef QT_NO_QWS_MULTIPROCESS
649  if (csocket) {
650  lockClient(QWSLock::Communication);
651  cmd.write(csocket);
652  bool ok = true;
653  while (csocket->bytesToWrite() > 0) {
654  if (!csocket->waitForBytesWritten(-1)) {
655  qCritical("QWSDisplay::Data::sendSynchronousCommand: %s",
656  qPrintable(csocket->errorString()));
657  ok = false;
658  break;
659  }
660  }
661  if (ok)
662  waitClient(QWSLock::Communication);
663  } else
664 #endif
665  qt_server_enqueue(&cmd);
666 }
667 
669 {
670  int unusedIdCount = unused_identifiers.count();
671  if (unusedIdCount <= 10)
672  create(15);
673  if (unusedIdCount == 0) {
674  create(1); // Make sure we have an incoming id to wait for, just in case we're recursive
675  waitForCreation();
676  }
677 
678  return unused_identifiers.takeFirst();
679 }
680 
682 {
683  mouseFilter = filter;
684 }
685 
686 #ifndef QT_NO_QWS_MULTIPROCESS
687 
689 
690 void Q_GUI_EXPORT qt_app_reinit( const QString& newAppName )
691 {
692  qt_fbdpy->d->reinit( newAppName );
693 }
694 
695 #endif // QT_NO_QWS_MULTIPROCESS
696 
697 class QDesktopWidget;
698 
699 #ifndef QT_NO_QWS_MULTIPROCESS
700 void QWSDisplay::Data::reinit( const QString& newAppName )
701 {
702  Q_ASSERT(csocket);
703 
704  delete connected_event;
705  connected_event = 0;
706  region_events_count = 0;
707 // region_ack = 0;
708  delete mouse_event;
709  mouse_event = 0;
710 // region_event = 0;
711  region_offset_window = 0;
712 #ifndef QT_NO_COP
713  delete qcop_response;
714  qcop_response = 0;
715 #endif
716  delete current_event;
717  current_event = 0;
718 #ifdef QAPPLICATION_EXTRA_DEBUG
719  mouse_event_count = 0;
720 #endif
721  mouseFilter = 0;
722 
723  qt_desktopWidget = 0;
725  QWSDisplay::Data::clientLock = 0;
726 
727  QString pipe = qws_qtePipeFilename();
728 
729  // QWS client
730  // Cleanup all cached ids
731  unused_identifiers.clear();
732  delete csocket;
733 
734  appName = newAppName;
735  qApp->setObjectName( appName );
736 
737  csocket = new QWSSocket();
738  QObject::connect(csocket, SIGNAL(disconnected()),
739  qApp, SLOT(quit()));
740  csocket->connectToLocalFile(pipe);
741 
742  QWSDisplay::Data::clientLock = new QWSLock();
743 
744  QWSIdentifyCommand cmd;
745  cmd.setId(appName, QWSDisplay::Data::clientLock->id());
746 
747 #ifndef QT_NO_SXE
752  csocket->socketDescriptor());
753  QAuthDevice *ad = a->authBuf( d, csocket );
754  ad->setClient( csocket );
755 
756  cmd.write(ad);
757 #else
758  cmd.write(csocket);
759 #endif
760 
761  // wait for connect confirmation
762  waitForConnection();
763 
764  qws_client_id = connected_event->simpleData.clientId;
765 
766  if (!QWSDisplay::initLock(pipe, false))
767  qFatal("Cannot get display lock");
768 
769  if (shm.attach(connected_event->simpleData.servershmid)) {
770  sharedRam = static_cast<uchar *>(shm.address());
772  if (s)
773  sharedRamSize += s->memoryNeeded(QLatin1String(qws_display_spec.constData()));
774  } else {
775  perror("QWSDisplay::Data::init");
776  qFatal("Client can't attach to main ram memory.");
777  }
778 
779  qApp->desktop();
780 
781  // We wait for creation mainly so that we can process important
782  // initialization events such as MaxWindowRect that are sent
783  // before object id creation. Waiting here avoids later window
784  // resizing since we have the MWR before windows are displayed.
785  waitForCreation();
786 
787  sharedRamSize -= sizeof(int);
788  qt_last_x = reinterpret_cast<int *>(sharedRam + sharedRamSize);
789  sharedRamSize -= sizeof(int);
790  qt_last_y = reinterpret_cast<int *>(sharedRam + sharedRamSize);
791 
792 #ifndef QT_NO_COP
794 #endif
795  csocket->flush();
796 }
797 #endif
798 
800 {
801  connected_event = 0;
802  region_events_count = 0;
803 // region_ack = 0;
804  mouse_event = 0;
805  mouse_state = -1;
806  mouse_winid = 0;
807 // region_event = 0;
808  region_offset_window = 0;
809 #ifndef QT_NO_COP
810  qcop_response = 0;
811 #endif
812  current_event = 0;
813 #ifdef QAPPLICATION_EXTRA_DEBUG
814  mouse_event_count = 0;
815 #endif
816  mouseFilter = 0;
817 
818  QString pipe = qws_qtePipeFilename();
819 
820  sharedRamSize = qwsSharedRamSize;
821 
822 #ifndef QT_NO_QWS_MULTIPROCESS
823  if (csocket) {
824  // QWS client
825 
826  connectToPipe();
827 
828  QWSDisplay::Data::clientLock = new QWSLock();
829 
830  QWSIdentifyCommand cmd;
831  cmd.setId(appName, QWSDisplay::Data::clientLock->id());
832 #ifndef QT_NO_SXE
837  csocket->socketDescriptor());
838  QAuthDevice *ad = a->authBuf( d, csocket );
839  ad->setClient( csocket );
840  cmd.write(ad);
841 #else
842  cmd.write(csocket);
843 #endif
844 
845  // create(30); // not necessary, server will send ids anyway
846  waitForConnection();
847 
848  qws_client_id = connected_event->simpleData.clientId;
849 
850  // now we want to get the exact display spec to use if we haven't
851  // specified anything.
852  if (qws_display_spec.at(0) == ':')
853  qws_display_spec = connected_event->display;
854 
855  if (!QWSDisplay::initLock(pipe, false))
856  qFatal("Cannot get display lock");
857 
858  if (shm.attach(connected_event->simpleData.servershmid)) {
859  sharedRam = static_cast<uchar *>(shm.address());
861  if (s)
862  sharedRamSize += s->memoryNeeded(QLatin1String(qws_display_spec.constData()));
863  } else {
864  perror("QWSDisplay::Data::init");
865  qFatal("Client can't attach to main ram memory.");
866  }
867 
868  // We wait for creation mainly so that we can process important
869  // initialization events such as MaxWindowRect that are sent
870  // before object id creation. Waiting here avoids later window
871  // resizing since we have the MWR before windows are displayed.
872  waitForCreation();
873  } else
874 #endif
875  {
876  create(30);
877 
878  // QWS server
879  if (!QWSDisplay::initLock(pipe, true))
880  qFatal("Cannot get display lock");
881 
883  if (s)
884  sharedRamSize += s->memoryNeeded(QLatin1String(qws_display_spec.constData()));
885 
886 #ifndef QT_NO_QWS_MULTIPROCESS
887 
888  if (!shm.create(sharedRamSize)) {
889  perror("Cannot create main ram shared memory\n");
890  qFatal("Unable to allocate %d bytes of shared memory", sharedRamSize);
891  }
892  qt_servershmid = shm.id();
893  sharedRam = static_cast<uchar *>(shm.address());
894 #else
895  sharedRam=static_cast<uchar *>(malloc(sharedRamSize));
896 #endif
897  // Need to zero index count at end of block, might as well zero
898  // the rest too
899  memset(sharedRam,0,sharedRamSize);
900 
901  QWSIdentifyCommand cmd;
902  cmd.setId(appName, -1);
903  qt_server_enqueue(&cmd);
904  }
905 
906  // Allow some memory for the graphics driver too
907  //### Note that sharedRamSize() has side effects; it must be called
908  //### once, and only once, and before initDevice()
909  sharedRamSize -= qt_screen->sharedRamSize(sharedRam+sharedRamSize);
910 
911 #ifndef QT_NO_QWS_MULTIPROCESS
912  if(!csocket)
913 #endif
914  {
915  //QWS server process
916  if (!qt_screen->initDevice())
917  qFatal("Unable to initialize screen driver!");
918  }
919 
920  sharedRamSize -= sizeof(int);
921  qt_last_x = reinterpret_cast<int *>(sharedRam + sharedRamSize);
922  sharedRamSize -= sizeof(int);
923  qt_last_y = reinterpret_cast<int *>(sharedRam + sharedRamSize);
924 
925  /* Initialise framebuffer memory manager */
926  /* Add 4k for luck and to avoid clobbering hardware cursor */
927 // int screensize=qt_screen->screenSize();
928 // memorymanager=new QMemoryManager(qt_screen->base()+screensize+4096,
929 // qt_screen->totalSize()-(screensize+4096),0);
930 
931 // #ifndef QT_NO_QWS_MULTIPROCESS
932 // rgnMan = new QWSRegionManager(pipe, csocket);
933 // #else
934 // rgnMan = new QWSRegionManager(pipe, 0); //####### not necessary
935 // #endif
936 #ifndef QT_NO_QWS_MULTIPROCESS
937  if (csocket)
938  csocket->flush();
939 #endif
940 }
941 
942 
944 {
945 #ifdef QT_NO_QWS_MULTIPROCESS
946  return incoming.isEmpty() ? 0 : incoming.takeFirst();
947 #else
948  if (!csocket)
949  return incoming.isEmpty() ? 0 : incoming.takeFirst();
950  // read next event
951  if (!current_event) {
952  int event_type = qws_read_uint(csocket);
953 
954  if (event_type >= 0) {
955  current_event = QWSEvent::factory(event_type);
956  }
957  }
958 
959  if (current_event) {
960  if (current_event->read(csocket)) {
961  // Finished reading a whole event.
962  QWSEvent* result = current_event;
963  current_event = 0;
964  return result;
965  }
966  }
967 
968  // Not finished reading a whole event.
969  return 0;
970 #endif
971 }
972 
974 {
976  QWSEvent *e = readMore();
977 #ifndef QT_NO_QWS_MULTIPROCESS
978  int bytesAvailable = csocket ? csocket->bytesAvailable() : 0;
979  int bytesRead = 0;
980 #endif
981  while (e) {
982 #ifndef QT_NO_QWS_MULTIPROCESS
983  bytesRead += QWS_PROTOCOL_ITEM_SIZE((*e));
984 #endif
985  if (e->type == QWSEvent::Connected) {
986  connected_event = static_cast<QWSConnectedEvent *>(e);
987  return;
988  } else if (e->type == QWSEvent::Creation) {
989  QWSCreationEvent *ce = static_cast<QWSCreationEvent*>(e);
990  int id = ce->simpleData.objectid;
991  int count = ce->simpleData.count;
992  for (int i = 0; i < count; ++i)
993  unused_identifiers.append(id++);
994  delete e;
995  } else if (e->type == QWSEvent::Mouse) {
996  if (!qt_screen) {
997  delete e;
998  } else {
999  QWSMouseEvent *me = static_cast<QWSMouseEvent*>(e);
1000  if (mouseFilter)
1001  mouseFilter(me);
1002 #ifdef QAPPLICATION_EXTRA_DEBUG
1003  static const char *defaultAction= "INITIAL";
1004  const char * action = defaultAction;
1005 #endif
1006  delete mouse_event;
1007  if (mouse_winid != me->window ()
1008  || mouse_state != me->simpleData.state) {
1009  queue.append(me);
1010  mouse_winid = me->window();
1012  mouse_event = 0;
1013 #ifdef QAPPLICATION_EXTRA_DEBUG
1014  mouse_event_count = 0;
1015  action = "ENQUEUE";
1016 #endif
1017  } else {
1018 #ifdef QAPPLICATION_EXTRA_DEBUG
1019  if (mouse_event)
1020  action = "COMPRESS";
1021  mouse_event_count++;
1022 #endif
1023  mouse_event = me;
1024  }
1025 #ifdef QAPPLICATION_EXTRA_DEBUG
1026  if (me->simpleData.state !=0 || action != defaultAction || mouse_event_count != 0)
1027  qDebug("fillQueue %s (%d,%d), state %x win %d count %d", action,
1029  me->window(), mouse_event_count);
1030 #endif
1031  }
1032 #ifndef QT_NO_QWS_MULTIPROCESS
1033  } else if (e->type == QWSEvent::Region && clientLock) {
1034  // not really an unlock, decrements the semaphore
1035  region_events_count++;
1036  clientLock->unlock(QWSLock::RegionEvent);
1037  queue.append(e);
1038 #endif
1039 #ifndef QT_NO_QWS_PROPERTIES
1040  } else if (e->type == QWSEvent::PropertyReply) {
1041  QWSPropertyReplyEvent *pe = static_cast<QWSPropertyReplyEvent*>(e);
1042  int len = pe->simpleData.len;
1043  char *data;
1044  if (len <= 0) {
1045  data = 0;
1046  } else {
1047  data = new char[len];
1048  memcpy(data, pe->data, len) ;
1049  }
1052  delete e;
1053 #endif // QT_NO_QWS_PROPERTIES
1054  } else if (e->type==QWSEvent::MaxWindowRect && qt_screen) {
1055  // Process this ASAP, in case new widgets are created (startup)
1056  setMaxWindowRect((static_cast<QWSMaxWindowRectEvent*>(e))->simpleData.rect);
1057  delete e;
1058 #ifndef QT_NO_QWS_DYNAMICSCREENTRANSFORMATION
1059  } else if (e->type == QWSEvent::ScreenTransformation) {
1063  delete e;
1064 #endif
1065 #ifndef QT_NO_COP
1066  } else if (e->type == QWSEvent::QCopMessage) {
1067  QWSQCopMessageEvent *pe = static_cast<QWSQCopMessageEvent*>(e);
1068  if (pe->simpleData.is_response) {
1069  qcop_response = pe;
1070  } else {
1071  queue.append(e);
1072  }
1073 #endif
1074  } else {
1075  queue.append(e);
1076  }
1077  //debugQueue();
1078 #ifndef QT_NO_QWS_MULTIPROCESS
1079  if (csocket && bytesRead >= bytesAvailable)
1080  break;
1081 #endif
1082  e = readMore();
1083  }
1084 }
1085 
1086 #ifndef QT_NO_QWS_MULTIPROCESS
1087 
1088 static int qws_connection_timeout = 5;
1089 
1091 {
1092  Q_ASSERT(csocket);
1093 
1094  int timeout = qgetenv("QWS_CONNECTION_TIMEOUT").toInt();
1095  if (timeout)
1096  qws_connection_timeout = timeout;
1097 
1098  const QString pipe = qws_qtePipeFilename();
1099  int i = 0;
1100  while (!csocket->connectToLocalFile(pipe)) {
1101  if (++i > qws_connection_timeout) {
1102  qWarning("No Qt for Embedded Linux server appears to be running.");
1103  qWarning("If you want to run this program as a server,");
1104  qWarning("add the \"-qws\" command-line option.");
1105  exit(1);
1106  }
1107  sleep(1);
1108  }
1109 }
1110 
1112 {
1113  connected_event = 0;
1114 
1115  for (int i = 0; i < qws_connection_timeout; i++) {
1116  fillQueue();
1117  if (connected_event)
1118  return;
1119  csocket->flush();
1120  csocket->waitForReadyRead(1000);
1121  }
1122 
1123  csocket->flush();
1124  if (!connected_event)
1125  qFatal("Did not receive a connection event from the qws server");
1126 }
1127 
1129 {
1130  QWSEvent *ack = 0;
1131 
1132  if (csocket) { // GuiClient
1133  int i = 0;
1134  while (!ack) {
1135  fillQueue();
1136 
1137  while (i < queue.size()) {
1138  QWSEvent *e = queue.at(i);
1139  if (e->type == QWSEvent::Region && e->window() == winId) {
1140  ack = e;
1141  queue.removeAt(i);
1142  break;
1143  }
1144  ++i;
1145  }
1146 
1147  if (!ack) {
1148  csocket->flush();
1149  csocket->waitForReadyRead(1000);
1150  }
1151  }
1152  } else { // GuiServer
1153  fillQueue();
1154  for (int i = 0; i < queue.size(); /* nothing */) {
1155  QWSEvent *e = queue.at(i);
1156  if (e->type == QWSEvent::Region && e->window() == winId) {
1157  ack = e;
1158  queue.removeAt(i);
1159  break;
1160  }
1161  ++i;
1162  }
1163  if (!ack) // already processed
1164  return;
1165  }
1166 
1167  Q_ASSERT(ack);
1168 
1169  qApp->qwsProcessEvent(ack);
1170  delete ack;
1171  region_events_count--;
1172 }
1173 
1174 void QWSDisplay::Data::waitForRegionEvents(int winId, bool ungrabDisplay)
1175 {
1176  if (!clientLock)
1177  return;
1178 
1179  int removedEventsCount = 0;
1180 
1181  // fill queue with unreceived region events
1182  if (!clientLock->hasLock(QWSLock::RegionEvent)) {
1183  bool ungrabbed = false;
1184  if (ungrabDisplay && QWSDisplay::grabbed()) {
1186  ungrabbed = true;
1187  }
1188 
1189  for (;;) {
1190  fillQueue();
1191  if (clientLock->hasLock(QWSLock::RegionEvent))
1192  break;
1193  csocket->flush();
1194  csocket->waitForReadyRead(1000);
1195  }
1196 
1197  if (ungrabbed)
1198  QWSDisplay::grab(true);
1199  }
1200 
1201  // check the queue for pending region events
1202  QWSEvent *regionEvent = 0;
1203  for (int i = 0; i < queue.size(); /* nothing */) {
1204  QWSEvent *e = queue.at(i);
1205  if (e->type == QWSEvent::Region && e->window() == winId) {
1206  QWSRegionEvent *re = static_cast<QWSRegionEvent*>(e);
1208  delete regionEvent;
1209  regionEvent = re;
1210  }
1211  queue.removeAt(i);
1212  removedEventsCount++;
1213  } else {
1214  ++i;
1215  }
1216  }
1217 
1218  if (regionEvent) {
1219  qApp->qwsProcessEvent(regionEvent);
1220  delete regionEvent;
1221  }
1222  region_events_count -= removedEventsCount;
1223 }
1224 
1226 {
1227  if (clientLock && !clientLock->hasLock(QWSLock::RegionEvent))
1228  return true;
1229 
1230  return region_events_count > 0;
1231 }
1232 
1233 #endif // QT_NO_QWS_MULTIPROCESS
1234 
1236 {
1237  fillQueue();
1238 #ifndef QT_NO_QWS_MULTIPROCESS
1239  while (unused_identifiers.count() == 0) {
1240  if (csocket) {
1241  csocket->flush();
1242  csocket->waitForReadyRead(1000);
1243  }
1244  fillQueue();
1245  }
1246 #endif
1247 }
1248 
1249 
1250 #ifndef QT_NO_QWS_MULTIPROCESS
1252 {
1253  if (!csocket)
1254  return;
1255  fillQueue();
1256  while (qt_fbdpy->getPropertyLen == -2) {
1257  csocket->flush();
1258  csocket->waitForReadyRead(1000);
1259  fillQueue();
1260  }
1261 }
1262 #endif
1263 
1264 #ifndef QT_NO_COP
1266 {
1267  for (;;) {
1268  fillQueue();
1269  if (qcop_response)
1270  break;
1271 #ifndef QT_NO_QWS_MULTIPROCESS
1272  if (csocket) {
1273  csocket->flush();
1274  csocket->waitForReadyRead(1000);
1275  }
1276 #endif
1277  }
1278  queue.prepend(qcop_response);
1279  qcop_response = 0;
1280 }
1281 #endif
1282 
1296 {
1297  d = new Data(0, qws_single_process);
1298 }
1299 
1301 {
1302  delete d;
1303  delete lock;
1304  lock = 0;
1305 }
1306 
1308 {
1309  return lock->locked();
1310 }
1311 
1313 {
1314  lock->lock(QLock::Read);
1315 }
1316 
1317 void QWSDisplay::grab(bool write)
1318 {
1319  lock->lock(write ? QLock::Write : QLock::Read);
1320 
1321 }
1323 {
1324  lock->unlock();
1325 }
1326 
1327 #if 0
1328 QWSRegionManager *QWSDisplay::regionManager() const
1329 {
1330  return d->rgnMan;
1331 }
1332 #endif
1333 
1335 {
1336 #ifndef QT_NO_QWS_MULTIPROCESS
1337  d->flush();
1338 #endif
1339  d->fillQueue();
1340  return d->queueNotEmpty();
1341 }
1342 
1343 
1344 /*
1345  Caller must delete return value!
1346  */
1348 {
1349  d->fillQueue();
1350  Q_ASSERT(d->queueNotEmpty());
1351  QWSEvent* e = d->dequeue();
1352 
1353  return e;
1354 }
1355 
1357 int QWSDisplay::width() const { return qt_screen->width(); }
1358 int QWSDisplay::height() const { return qt_screen->height(); }
1359 int QWSDisplay::depth() const { return qt_screen->depth(); }
1361 bool QWSDisplay::supportsDepth(int depth) const { return qt_screen->supportsDepth(depth); }
1362 uchar *QWSDisplay::sharedRam() const { return d->sharedRam; }
1363 int QWSDisplay::sharedRamSize() const { return d->sharedRamSize; }
1364 
1365 #ifndef QT_NO_QWS_PROPERTIES
1366 
1368 {
1370  cmd.simpleData.windowid = winId;
1372  d->sendCommand(cmd);
1373 }
1374 
1375 void QWSDisplay::setProperty(int winId, int property, int mode, const QByteArray &data)
1376 {
1378  cmd.simpleData.windowid = winId;
1380  cmd.simpleData.mode = mode;
1381  cmd.setData(data.constData(), data.size());
1382  d->sendCommand(cmd);
1383 }
1384 
1385 void QWSDisplay::setProperty(int winId, int property, int mode,
1386  const char * data)
1387 {
1389  cmd.simpleData.windowid = winId;
1391  cmd.simpleData.mode = mode;
1392  cmd.setData(data, strlen(data));
1393  d->sendCommand(cmd);
1394 }
1395 
1397 {
1399  cmd.simpleData.windowid = winId;
1401  d->sendCommand(cmd);
1402 }
1403 
1404 /*
1405  It is the caller's responsibility to delete[] \a data.
1406  */
1407 bool QWSDisplay::getProperty(int winId, int property, char *&data, int &len)
1408 {
1409  if (d->directServerConnection()) {
1410  const char *propertyData;
1411  bool retval = qwsServer->d_func()->get_property(winId, property, propertyData, len);
1412  if (len <= 0) {
1413  data = 0;
1414  } else {
1415  data = new char[len];
1416  memcpy(data, propertyData, len) ;
1417  }
1418  return retval;
1419  }
1421  cmd.simpleData.windowid = winId;
1423  d->sendCommand(cmd);
1424 
1425  getPropertyLen = -2;
1426  getPropertyData = 0;
1427 
1428 #ifndef QT_NO_QWS_MULTIPROCESS
1429  d->waitForPropertyReply();
1430 #endif
1431 
1432  len = getPropertyLen;
1433  data = getPropertyData;
1434 
1435  getPropertyLen = -2;
1436  getPropertyData = 0;
1437 
1438  return len != -1;
1439 }
1440 
1441 #endif // QT_NO_QWS_PROPERTIES
1442 
1443 void QWSDisplay::setAltitude(int winId, int alt, bool fixed)
1444 {
1446 #ifdef QT_DEBUG
1447  memset(cmd.simpleDataPtr, 0, sizeof(cmd.simpleData)); //shut up Valgrind
1448 #endif
1449  cmd.simpleData.windowid = winId;
1451  cmd.simpleData.fixed = fixed;
1452  if (d->directServerConnection()) {
1453  qwsServer->d_func()->set_altitude(&cmd);
1454  } else {
1455  d->sendSynchronousCommand(cmd);
1456  }
1457 }
1458 
1459 void QWSDisplay::setOpacity(int winId, int opacity)
1460 {
1462  cmd.simpleData.windowid = winId;
1463  cmd.simpleData.opacity = opacity;
1464  if (d->directServerConnection()) {
1465  qwsServer->d_func()->set_opacity(&cmd);
1466  } else {
1467  d->sendCommand(cmd);
1468  }
1469 }
1470 
1471 
1472 
1473 void QWSDisplay::requestFocus(int winId, bool get)
1474 {
1476  cmd.simpleData.windowid = winId;
1477  cmd.simpleData.flag = get;
1478  if (d->directServerConnection())
1479  qwsServer->d_func()->request_focus(&cmd);
1480  else
1481  d->sendCommand(cmd);
1482 }
1483 
1484 void QWSDisplay::setIdentity(const QString &appName)
1485 {
1486  QWSIdentifyCommand cmd;
1487 #ifdef QT_NO_QWS_MULTIPROCESS
1488  const int id = -1;
1489 #else
1490  const int id = QWSDisplay::Data::clientLock ? QWSDisplay::Data::clientLock->id() : -1;
1491 #endif
1492  cmd.setId(appName, id);
1493  if (d->directServerConnection())
1494  qwsServer->d_func()->set_identity(&cmd);
1495  else
1496  d->sendCommand(cmd);
1497 }
1498 
1499 void QWSDisplay::nameRegion(int winId, const QString& n, const QString &c)
1500 {
1502  cmd.simpleData.windowid = winId;
1503  cmd.setName(n, c);
1504  if (d->directServerConnection())
1505  qwsServer->d_func()->name_region(&cmd);
1506  else
1507  d->sendCommand(cmd);
1508 }
1509 
1510 void QWSDisplay::requestRegion(int winId, const QString &surfaceKey,
1511  const QByteArray &surfaceData,
1512  const QRegion &region)
1513 {
1514  if (d->directServerConnection()) {
1515  qwsServer->d_func()->request_region(winId, surfaceKey,
1516  surfaceData, region);
1517  } else {
1518  QWSRegionCommand cmd;
1519  cmd.setData(winId, surfaceKey, surfaceData, region);
1520  d->sendSynchronousCommand(cmd);
1521  }
1522 }
1523 
1524 void QWSDisplay::repaintRegion(int winId, int windowFlags, bool opaque, QRegion r)
1525 {
1526  if (d->directServerConnection()) {
1527  qwsServer->d_func()->repaint_region(winId, windowFlags, opaque, r);
1528  } else {
1529  QVector<QRect> ra = r.rects();
1530 
1531  /*
1532  for (int i = 0; i < ra.size(); i++) {
1533  QRect r(ra[i]);
1534  qDebug("rect: %d %d %d %d", r.x(), r.y(), r.right(), r.bottom());
1535  }
1536  */
1537 
1539  /* XXX QWSRegionCommand is padded out in a compiler dependent way.
1540  Zeroed out to avoid valgrind reporting uninitialized memory usage.
1541  */
1542 #ifdef QT_DEBUG
1543  memset(cmd.simpleDataPtr, 0, sizeof(cmd.simpleData)); //shut up Valgrind
1544 #endif
1545  cmd.simpleData.windowid = winId;
1547  cmd.simpleData.opaque = opaque;
1548  cmd.simpleData.nrectangles = ra.count();
1549  cmd.setData(reinterpret_cast<const char *>(ra.constData()),
1550  ra.count() * sizeof(QRect), false);
1551 
1552  d->sendSynchronousCommand(cmd);
1553  }
1554 }
1555 
1556 
1557 void QWSDisplay::moveRegion(int winId, int dx, int dy)
1558 {
1560  cmd.simpleData.windowid = winId;
1561  cmd.simpleData.dx = dx;
1562  cmd.simpleData.dy = dy;
1563 
1564  if (d->directServerConnection()) {
1565  qwsServer->d_func()->move_region(&cmd);
1566  } else {
1567  d->sendSynchronousCommand(cmd);
1568  }
1569 // d->offsetPendingExpose(winId, QPoint(cmd.simpleData.dx, cmd.simpleData.dy));
1570 }
1571 
1573 {
1575  cmd.simpleData.windowid = winId;
1576  if (d->directServerConnection()) {
1577  qwsServer->d_func()->destroy_region(&cmd);
1578  } else {
1579  d->sendCommand(cmd);
1580  }
1581 }
1582 
1583 #ifndef QT_NO_QWS_INPUTMETHODS
1584 
1585 void QWSDisplay::sendIMUpdate(int type, int winId, int widgetid)
1586 {
1587  QWSIMUpdateCommand cmd;
1588  cmd.simpleData.windowid = winId;
1589  cmd.simpleData.widgetid = widgetid;
1590 
1591  cmd.simpleData.type = type;
1592 
1593  if (d->directServerConnection()) {
1594  qwsServer->d_func()->im_update(&cmd);
1595  } else {
1596  d->sendCommand(cmd);
1597  }
1598 }
1599 
1600 void QWSDisplay::sendIMResponse(int winId, int property, const QVariant &result)
1601 {
1603  cmd.simpleData.windowid = winId;
1605 
1606  cmd.setResult(result);
1607 
1608  if (d->directServerConnection()) {
1609  qwsServer->d_func()->im_response(&cmd);
1610  } else {
1611  d->sendCommand(cmd);
1612  }
1613 }
1614 
1616 {
1617  sendIMUpdate(QWSInputMethod::Reset, -1, -1);
1618 }
1619 
1620 void QWSDisplay::sendIMMouseEvent(int index, bool isPress)
1621 {
1622  QWSIMMouseCommand cmd;
1623  cmd.simpleData.index = index;
1625  if (d->directServerConnection()) {
1626  qwsServer->d_func()->send_im_mouse(&cmd);
1627  } else {
1628  d->sendCommand(cmd);
1629  }
1630 }
1631 
1632 #endif
1633 
1635 {
1636  return d->takeId();
1637 }
1638 
1639 bool QWSDisplay::initLock(const QString &filename, bool create)
1640 {
1641  if (!lock) {
1642  lock = new QLock(filename, 'd', create);
1643 
1644  if (!lock->isValid()) {
1645  delete lock;
1646  lock = 0;
1647  return false;
1648  }
1649  }
1650 
1651  return true;
1652 }
1653 
1655 {
1657  cmd.simpleData.windowid = winId;
1658  cmd.simpleData.hour = time.hour();
1659  cmd.simpleData.minute = time.minute();
1660  cmd.simpleData.sec = time.second();
1661  cmd.simpleData.ms = time.msec();
1662  d->sendCommand(cmd);
1663 }
1664 
1665 void QWSDisplay::convertSelection(int winId, int selectionProperty, const QString &mimeTypes)
1666 {
1667 #ifdef QT_NO_QWS_PROPERTIES
1668  Q_UNUSED(mimeTypes);
1669 #else
1670  // ### we need the atom/property thingy like in X here
1671  addProperty(winId, QT_QWS_PROPERTY_CONVERTSELECTION);
1673  int(QWSPropertyManager::PropReplace), mimeTypes.toLatin1());
1674 #endif
1676  cmd.simpleData.requestor = winId;
1677  cmd.simpleData.selection = selectionProperty;
1678  cmd.simpleData.mimeTypes = QT_QWS_PROPERTY_CONVERTSELECTION;
1679  d->sendCommand(cmd);
1680 }
1681 
1682 void QWSDisplay::defineCursor(int id, const QBitmap &curs, const QBitmap &mask,
1683  int hotX, int hotY)
1684 {
1685  const QImage cursImg = curs.toImage().convertToFormat(QImage::Format_MonoLSB);
1686  const QImage maskImg = mask.toImage().convertToFormat(QImage::Format_MonoLSB);
1687 
1689  cmd.simpleData.width = curs.width();
1690  cmd.simpleData.height = curs.height();
1691  cmd.simpleData.hotX = hotX;
1692  cmd.simpleData.hotY = hotY;
1693  cmd.simpleData.id = id;
1694 
1695 
1696  // must copy each scanline since there might be gaps between them
1697  const int height = curs.height();
1698  const int width = curs.width();
1699  const int dst_bpl = (width + 7) / 8;
1700 
1701  int dataLen = dst_bpl * height;
1702  uchar *data = new uchar[dataLen*2];
1703  uchar *dst = data;
1704 
1705  int src_bpl = cursImg.bytesPerLine();
1706  const uchar *cursSrc = cursImg.bits();
1707  for (int i = 0; i < height; ++i) {
1708  memcpy(dst, cursSrc + i*src_bpl, dst_bpl);
1709  dst += dst_bpl;
1710  }
1711 
1712  src_bpl = maskImg.bytesPerLine();
1713  const uchar *maskSrc = maskImg.bits();
1714  for (int i = 0; i < height; ++i) {
1715  memcpy(dst, maskSrc + i*src_bpl, dst_bpl);
1716  dst += dst_bpl;
1717  }
1718 
1719  cmd.setData(reinterpret_cast<char*>(data), dataLen*2);
1720  delete [] data;
1721  d->sendCommand(cmd);
1722 }
1723 
1725 {
1727  cmd.simpleData.width = 0;
1728  cmd.simpleData.height = 0;
1729  cmd.simpleData.hotX = 0;
1730  cmd.simpleData.hotY = 0;
1731  cmd.simpleData.id = id;
1732  cmd.setData(0, 0);
1733 
1734  d->sendCommand(cmd);
1735 }
1736 
1737 #ifndef QT_NO_SOUND
1739 {
1740  QWSPlaySoundCommand cmd;
1741  cmd.setFileName(f);
1742  d->sendCommand(cmd);
1743 }
1744 #endif
1745 
1746 #ifndef QT_NO_COP
1748 {
1750  reg.setChannel(channel);
1751  qt_fbdpy->d->sendCommand(reg);
1752 }
1753 
1754 void QWSDisplay::sendMessage(const QString &channel, const QString &msg,
1755  const QByteArray &data)
1756 {
1757  QWSQCopSendCommand com;
1758  com.setMessage(channel, msg, data);
1759  qt_fbdpy->d->sendCommand(com);
1760 }
1761 
1763 {
1764  qt_fbdpy->d->flushCommands();
1765 }
1766 
1767 /*
1768  caller deletes result
1769 */
1771 {
1773  QWSQCopMessageEvent *e = static_cast<QWSQCopMessageEvent*>(qt_fbdpy->d->dequeue());
1775  return e;
1776 }
1777 #endif
1778 
1779 void QWSDisplay::sendFontCommand(int type, const QByteArray &fontName)
1780 {
1781  QWSFontCommand cmd;
1782  cmd.simpleData.type = type;
1783  cmd.setFontName(fontName);
1784  d->sendCommand(cmd);
1785 }
1786 
1788 {
1789  if (w->isWindow()) {
1790  nameRegion(w->internalWinId(), w->objectName(), c);
1791  static_cast<QETWidget *>(w)->repaintDecoration(qApp->desktop()->rect(), true);
1792  }
1793 }
1794 
1795 void QWSDisplay::selectCursor(QWidget *w, unsigned int cursId)
1796 {
1797  if (cursId != qt_last_cursor)
1798  {
1799  QWidget *top = w->window();
1800  qt_last_cursor = cursId;
1802  cmd.simpleData.windowid = top->internalWinId();
1803  cmd.simpleData.id = cursId;
1804  d->sendCommand(cmd);
1805  d->flush();
1806  }
1807 }
1808 
1810 {
1812  cmd.simpleData.newX = x;
1813  cmd.simpleData.newY = y;
1814  d->sendCommand(cmd);
1815  d->flush();
1816 }
1817 
1818 void QWSDisplay::grabMouse(QWidget *w, bool grab)
1819 {
1820  QWidget *top = w->window();
1821  QWSGrabMouseCommand cmd;
1822 #ifdef QT_DEBUG
1823  memset(cmd.simpleDataPtr, 0, sizeof(cmd.simpleData)); //shut up Valgrind
1824 #endif
1825  cmd.simpleData.windowid = top->winId();
1826  cmd.simpleData.grab = grab;
1827  d->sendCommand(cmd);
1828  d->flush();
1829 }
1830 
1832 {
1833  QWidget *top = w->window();
1835 #ifdef QT_DEBUG
1836  memset(cmd.simpleDataPtr, 0, sizeof(cmd.simpleData)); //shut up Valgrind
1837 #endif
1838  cmd.simpleData.windowid = top->winId();
1839  cmd.simpleData.grab = grab;
1840  d->sendCommand(cmd);
1841  d->flush();
1842 }
1843 
1845 {
1847  if(d->directServerConnection()) {
1849  for (int i = 0; i < qin->count(); ++i) {
1850  QWSInternalWindowInfo * qwi = qin->at(i);
1851  QWSWindowInfo tmp;
1852  tmp.winid = qwi->winid;
1853  tmp.clientid = qwi->clientid;
1854  tmp.name = QString(qwi->name);
1855  ret.append(tmp);
1856  }
1857  qDeleteAll(*qin);
1858  delete qin;
1859  }
1860  return ret;
1861 }
1862 
1864 {
1865  //### currently only implemented for the server process
1866  int ret = 0;
1867  if(d->directServerConnection()) {
1868  QWSWindow *win = qwsServer->windowAt(p);
1869  if (win)
1870  return win->winId();
1871  }
1872  return ret;
1873 }
1874 
1876 {
1877  if (qt_fbdpy)
1879 }
1880 
1889 void QWSDisplay::setTransformation(int transformation, int screenNo)
1890 {
1892  cmd.setTransformation(screenNo, transformation);
1894 }
1895 
1896 static bool qt_try_modal(QWidget *, QWSEvent *);
1897 
1898 /*****************************************************************************
1899  qt_init() - initializes Qt/FB
1900  *****************************************************************************/
1901 
1903 
1904 {
1906  QApplicationPrivate::qws_apply_settings();
1907 
1908  if (appFont)
1910 
1911  if (appBGCol || appBTNCol || appFGCol) {
1912  (void) QApplication::style(); // trigger creation of application style and system palettes
1913  QColor btn;
1914  QColor bg;
1915  QColor fg;
1916  if (appBGCol)
1917  bg = QColor(appBGCol);
1918  else
1920  if (appFGCol)
1921  fg = QColor(appFGCol);
1922  else
1924  if (appBTNCol)
1925  btn = QColor(appBTNCol);
1926  else
1928 
1929  int h,s,v;
1930  fg.getHsv(&h,&s,&v);
1931  QColor base = Qt::white;
1932  bool bright_mode = false;
1933  if (v >= 255 - 50) {
1934  base = btn.darker(150);
1935  bright_mode = true;
1936  }
1937 
1938  QPalette pal(fg, btn, btn.lighter(), btn.darker(), btn.darker(150), fg, Qt::white, base, bg);
1939  if (bright_mode) {
1941  pal.setColor(QPalette::Highlight, Qt::white);
1942  } else {
1943  pal.setColor(QPalette::HighlightedText, Qt::white);
1944  pal.setColor(QPalette::Highlight, Qt::darkBlue);
1945  }
1946  QColor disabled((fg.red() + btn.red()) / 2,
1947  (fg.green() + btn.green())/ 2,
1948  (fg.blue() + btn.blue()) / 2);
1949  pal.setColorGroup(QPalette::Disabled, disabled, btn, btn.lighter(125),
1950  btn.darker(), btn.darker(150), disabled, Qt::white, Qt::white, bg);
1951  if (bright_mode) {
1952  pal.setColor(QPalette::Disabled, QPalette::HighlightedText, base);
1953  pal.setColor(QPalette::Disabled, QPalette::Highlight, Qt::white);
1954  } else {
1955  pal.setColor(QPalette::Disabled, QPalette::HighlightedText, Qt::white);
1957  }
1959 
1960  }
1961 }
1962 
1964 {
1965 }
1966 
1970 bool QApplicationPrivate::qws_apply_settings()
1971 {
1972 #ifndef QT_NO_SETTINGS
1973  QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
1974  settings.beginGroup(QLatin1String("Qt"));
1975 
1976  QStringList strlist;
1977  int i;
1978  QPalette pal(Qt::black);
1979  int groupCount = 0;
1980  strlist = settings.value(QLatin1String("Palette/active")).toStringList();
1981  if (strlist.count() == QPalette::NColorRoles) {
1982  ++groupCount;
1983  for (i = 0; i < QPalette::NColorRoles; i++)
1985  QColor(strlist[i]));
1986  }
1987  strlist = settings.value(QLatin1String("Palette/inactive")).toStringList();
1988  if (strlist.count() == QPalette::NColorRoles) {
1989  ++groupCount;
1990  for (i = 0; i < QPalette::NColorRoles; i++)
1992  QColor(strlist[i]));
1993  }
1994  strlist = settings.value(QLatin1String("Palette/disabled")).toStringList();
1995  if (strlist.count() == QPalette::NColorRoles) {
1996  ++groupCount;
1997  for (i = 0; i < QPalette::NColorRoles; i++)
1999  QColor(strlist[i]));
2000  }
2001 
2002 
2003  if (groupCount == QPalette::NColorGroups)
2005 
2006  QString str = settings.value(QLatin1String("font")).toString();
2007  if (!str.isEmpty()) {
2009  font.fromString(str);
2011  }
2012 
2013  // read library (ie. plugin) path list
2014  QString libpathkey =
2015  QString::fromLatin1("%1.%2/libraryPath")
2016  .arg(QT_VERSION >> 16)
2017  .arg((QT_VERSION & 0xff00) >> 8);
2018  QStringList pathlist = settings.value(libpathkey).toString().split(QLatin1Char(':'));
2019 #ifndef QT_NO_LIBRARY
2020  if (! pathlist.isEmpty()) {
2022  while (it != pathlist.constEnd())
2024  }
2025 #endif
2026 
2027  // read new QStyle
2028  QString stylename = settings.value(QLatin1String("style")).toString();
2030  if (!stylename.isEmpty() && QApplicationPrivate::styleOverride.isNull())
2032  } else {
2033  QApplication::setStyle(stylename);
2034  }
2035 
2036  int num =
2037  settings.value(QLatin1String("doubleClickInterval"),
2040 
2041  num =
2042  settings.value(QLatin1String("cursorFlashTime"),
2045 
2046 #ifndef QT_NO_WHEELEVENT
2047  num =
2048  settings.value(QLatin1String("wheelScrollLines"),
2051 #endif
2052 
2053  QString colorspec = settings.value(QLatin1String("colorSpec"),
2054  QVariant(QLatin1String("default"))).toString();
2055  if (colorspec == QLatin1String("normal"))
2057  else if (colorspec == QLatin1String("custom"))
2059  else if (colorspec == QLatin1String("many"))
2061  else if (colorspec != QLatin1String("default"))
2062  colorspec = QLatin1String("default");
2063 
2064 #ifndef QT_NO_TEXTCODEC
2065  QString defaultcodec = settings.value(QLatin1String("defaultCodec"),
2066  QVariant(QLatin1String("none"))).toString();
2067  if (defaultcodec != QLatin1String("none")) {
2069  if (codec)
2071  }
2072 #endif
2073 
2074  int w = settings.value(QLatin1String("globalStrut/width")).toInt();
2075  int h = settings.value(QLatin1String("globalStrut/height")).toInt();
2076  QSize strut(w, h);
2077  if (strut.isValid())
2079 
2080  QStringList effects = settings.value(QLatin1String("GUIEffects")).toStringList();
2082  effects.contains(QLatin1String("general")));
2084  effects.contains(QLatin1String("animatemenu")));
2086  effects.contains(QLatin1String("fademenu")));
2088  effects.contains(QLatin1String("animatecombo")));
2090  effects.contains(QLatin1String("animatetooltip")));
2092  effects.contains(QLatin1String("fadetooltip")));
2094  effects.contains(QLatin1String("animatetoolbox")));
2095 
2096  settings.beginGroup(QLatin1String("Font Substitutions"));
2097  QStringList fontsubs = settings.childKeys();
2098  if (!fontsubs.isEmpty()) {
2099  QStringList::Iterator it = fontsubs.begin();
2100  for (; it != fontsubs.end(); ++it) {
2101  QString fam = *it;
2102  QStringList subs = settings.value(fam).toStringList();
2103  QFont::insertSubstitutions(fam, subs);
2104  }
2105  }
2106  settings.endGroup();
2107 
2108  settings.endGroup(); // Qt
2109 
2110  settings.beginGroup(QLatin1String("QWS Font Fallbacks"));
2111  if (!settings.childKeys().isEmpty()) {
2112  // from qfontdatabase_qws.cpp
2113  extern void qt_applyFontDatabaseSettings(const QSettings &);
2114  qt_applyFontDatabaseSettings(settings);
2115  }
2116  settings.endGroup();
2117 
2118  return true;
2119 #else
2120  return false;
2121 #endif // QT_NO_SETTINGS
2122 }
2123 
2124 
2125 
2126 static void init_display()
2127 {
2128  if (qt_fbdpy) return; // workaround server==client case
2129 
2130  // Connect to FB server
2131  qt_fbdpy = new QWSDisplay();
2132 
2133  // Get display parameters
2134  // Set paintdevice parameters
2135  // XXX initial info sent from server
2136  // Misc. initialization
2137 
2140 #ifndef QT_NO_CURSOR
2142 #endif
2143 
2144  qApp->setObjectName(appName);
2145 
2147 #ifdef QT_NO_FREETYPE
2148  QFont f = QFont(QLatin1String("helvetica"), 10);
2149 #else
2150  QFont f = QFont(QLatin1String("DejaVu Sans"), 12);
2151 #endif
2153  }
2155 }
2156 
2158 {
2159  qt_is_gui_used = true;
2160  qws_single_process = true;
2161  init_display();
2162 }
2163 
2164 static bool read_bool_env_var(const char *var, bool defaultvalue)
2165 {
2166  // returns true if env variable is set to non-zero
2167  // returns false if env var is set to zero
2168  // returns defaultvalue if env var not set
2169  char *x = ::getenv(var);
2170  return (x && *x) ? (strcmp(x,"0") != 0) : defaultvalue;
2171 }
2172 
2173 static int read_int_env_var(const char *var, int defaultvalue)
2174 {
2175  bool ok;
2176  int r = qgetenv(var).toInt(&ok);
2177  return ok ? r : defaultvalue;
2178 }
2179 
2181 {
2182 #ifdef QT_NO_QWS_MULTIPROCESS
2183  if (type == QApplication::GuiClient)
2184  type = QApplication::GuiServer;
2185 #endif
2186  if (type == QApplication::GuiServer)
2187  qt_is_gui_used = false; //we'll turn it on in a second
2188  qws_sw_cursor = read_bool_env_var("QWS_SW_CURSOR",qws_sw_cursor);
2189  qws_screen_is_interlaced = read_bool_env_var("QWS_INTERLACE",false);
2190 
2191  const char *display = ::getenv("QWS_DISPLAY");
2192 
2193 #ifdef QT_QWS_DEFAULT_DRIVER_NAME
2194  if (!display) display = QT_QWS_DEFAULT_DRIVER_NAME;
2195 #endif
2196 
2197  if (display)
2198  qws_display_spec = display; // since we setenv later!
2199 
2200  //qws_savefonts = qgetenv("QWS_SAVEFONTS") != 0;
2201  //qws_shared_memory = qgetenv("QWS_NOSHARED") == 0;
2202 
2203  mouse_double_click_distance = read_int_env_var("QWS_DBLCLICK_DISTANCE", 5);
2204 
2205  priv->inputContext = 0;
2206 
2207  int flags = 0;
2208  char *p;
2209  int argc = priv->argc;
2210  char **argv = priv->argv;
2211  int j;
2212 
2213  // Set application name
2214 
2215  if (argv && *argv) { //apparently, we allow people to pass 0 on the other platforms
2216  p = strrchr(argv[0], '/');
2217  appName = QString::fromLocal8Bit(p ? p + 1 : argv[0]);
2218  }
2219 
2220  // Get command line params
2221 
2222  j = argc ? 1 : 0;
2223  QString decoration;
2224  for (int i=1; i<argc; i++) {
2225  if (argv[i] && *argv[i] != '-') {
2226  argv[j++] = argv[i];
2227  continue;
2228  }
2229  QByteArray arg = argv[i];
2230  if (arg == "-fn" || arg == "-font") {
2231  if (++i < argc)
2232  appFont = argv[i];
2233  } else if (arg == "-bg" || arg == "-background") {
2234  if (++i < argc)
2235  appBGCol = argv[i];
2236  } else if (arg == "-btn" || arg == "-button") {
2237  if (++i < argc)
2238  appBTNCol = argv[i];
2239  } else if (arg == "-fg" || arg == "-foreground") {
2240  if (++i < argc)
2241  appFGCol = argv[i];
2242  } else if (arg == "-name") {
2243  if (++i < argc)
2244  appName = QString::fromLocal8Bit(argv[i]);
2245  } else if (arg == "-title") {
2246  if (++i < argc)
2247  mwTitle = argv[i];
2248  } else if (arg == "-geometry") {
2249  if (++i < argc)
2250  mwGeometry = argv[i];
2251  } else if (arg == "-shared") {
2252  qws_shared_memory = true;
2253  } else if (arg == "-noshared") {
2254  qws_shared_memory = false;
2255  } else if (arg == "-savefonts") {
2256  qws_savefonts = true;
2257  } else if (arg == "-nosavefonts") {
2258  qws_savefonts = false;
2259  } else if (arg == "-swcursor") {
2260  qws_sw_cursor = true;
2261  } else if (arg == "-noswcursor") {
2262  qws_sw_cursor = false;
2263  } else if (arg == "-keyboard") {
2264  flags &= ~QWSServer::DisableKeyboard;
2265  } else if (arg == "-nokeyboard") {
2266  flags |= QWSServer::DisableKeyboard;
2267  } else if (arg == "-mouse") {
2268  flags &= ~QWSServer::DisableMouse;
2269  } else if (arg == "-nomouse") {
2270  flags |= QWSServer::DisableMouse;
2271  } else if (arg == "-qws") {
2272  type = QApplication::GuiServer;
2273  } else if (arg == "-interlaced") {
2274  qws_screen_is_interlaced = true;
2275  } else if (arg == "-display") {
2276  if (++i < argc)
2277  qws_display_spec = argv[i];
2278  } else if (arg == "-decoration") {
2279  if (++i < argc)
2280  decoration = QString::fromLocal8Bit(argv[i]);
2281  } else {
2282  argv[j++] = argv[i];
2283  }
2284  }
2285  if(j < priv->argc) {
2286  priv->argv[j] = 0;
2287  priv->argc = j;
2288  }
2289 
2290  mouseInWidget = new QPointer<QWidget>;
2291 
2293  QRegExp regexp(QLatin1String(":(\\d+)$"));
2294  if (regexp.lastIndexIn(disp) != -1) {
2295  const QString capture = regexp.cap(1);
2296  bool ok = false;
2297  int id = capture.toInt(&ok);
2298  if (ok)
2299  qws_display_id = id;
2300  }
2301 
2302  if (type == QApplication::GuiServer) {
2304  qws_single_process = true;
2305  QWSServer::startup(flags);
2306  if (!display) // if not already set
2307  qputenv("QWS_DISPLAY", qws_display_spec);
2308  }
2309 
2310  if(qt_is_gui_used) {
2311  init_display();
2312 #ifndef QT_NO_QWS_MANAGER
2313  if (decoration.isEmpty() && !qws_decoration) {
2315  if (!keys.isEmpty())
2316  decoration = keys.first();
2317  }
2318  if (!decoration.isEmpty())
2319  qws_decoration = QApplication::qwsSetDecoration(decoration);
2320 #endif // QT_NO_QWS_MANAGER
2321 #ifndef QT_NO_QWS_INPUTMETHODS
2322  qApp->setInputContext(new QWSInputContext(qApp));
2323 #endif
2324  }
2325 
2326 /*### convert interlace style
2327  if (qws_screen_is_interlaced)
2328  QApplication::setStyle(new QInterlaceStyle);
2329 */
2330 }
2331 
2332 /*****************************************************************************
2333  qt_cleanup() - cleans up when the application is finished
2334  *****************************************************************************/
2335 
2337 {
2339 #ifndef QT_NO_CURSOR
2341 #endif
2342  QFont::cleanup();
2344 
2345  if (qws_single_process) {
2347  }
2348 
2349  qDeleteAll(outgoing);
2350  outgoing.clear();
2351  qDeleteAll(incoming);
2352  incoming.clear();
2353 
2354  if (qt_is_gui_used) {
2355  delete qt_fbdpy;
2356  }
2357  qt_fbdpy = 0;
2358 
2359 #ifndef QT_NO_QWS_MANAGER
2360  delete qws_decoration;
2361  qws_decoration = 0;
2362 #endif
2363 
2364  delete mouseInWidget;
2365  mouseInWidget = 0;
2366 
2367 #if !defined(QT_NO_IM)
2370 #endif
2371 }
2372 
2373 
2374 /*****************************************************************************
2375  Platform specific global and internal functions
2376  *****************************************************************************/
2377 
2378 QString QApplicationPrivate::appName() const // get application name
2379 {
2380  return QT_PREPEND_NAMESPACE(appName);
2381 }
2382 
2383 /*****************************************************************************
2384  Platform specific QApplication members
2385  *****************************************************************************/
2386 
2387 #define NoValue 0x0000
2388 #define XValue 0x0001
2389 #define YValue 0x0002
2390 #define WidthValue 0x0004
2391 #define HeightValue 0x0008
2392 #define AllValues 0x000F
2393 #define XNegative 0x0010
2394 #define YNegative 0x0020
2395 
2396 /* Copyright notice for ReadInteger and parseGeometry
2397 
2398 Copyright (c) 1985, 1986, 1987 X Consortium
2399 
2400 Permission is hereby granted, free of charge, to any person obtaining
2401 a copy of this software and associated documentation files (the
2402 "Software"), to deal in the Software without restriction, including
2403 without limitation the rights to use, copy, modify, merge, publish,
2404 distribute, sublicense, and/or sell copies of the Software, and to
2405 permit persons to whom the Software is furnished to do so, subject to
2406 the following conditions:
2407 
2408 The above copyright notice and this permission notice shall be included
2409 in all copies or substantial portions of the Software.
2410 
2411 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2412 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2413 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2414 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
2415 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2416 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2417 OTHER DEALINGS IN THE SOFTWARE.
2418 
2419 Except as contained in this notice, the name of the X Consortium shall
2420 not be used in advertising or otherwise to promote the sale, use or
2421 other dealings in this Software without prior written authorization
2422 from the X Consortium.
2423 
2424 */
2425 /*
2426  * XParseGeometry parses strings of the form
2427  * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
2428  * width, height, xoffset, and yoffset are unsigned integers.
2429  * Example: "=80x24+300-49"
2430  * The equal sign is optional.
2431  * It returns a bitmask that indicates which of the four values
2432  * were actually found in the string. For each value found,
2433  * the corresponding argument is updated; for each value
2434  * not found, the corresponding argument is left unchanged.
2435  */
2436 
2437 static int
2438 ReadInteger(char *string, char **NextString)
2439 {
2440  register int Result = 0;
2441  int Sign = 1;
2442 
2443  if (*string == '+')
2444  string++;
2445  else if (*string == '-')
2446  {
2447  string++;
2448  Sign = -1;
2449  }
2450  for (; (*string >= '0') && (*string <= '9'); string++)
2451  {
2452  Result = (Result * 10) + (*string - '0');
2453  }
2454  *NextString = string;
2455  if (Sign >= 0)
2456  return Result;
2457  else
2458  return -Result;
2459 }
2460 
2461 static int parseGeometry(const char* string,
2462  int* x, int* y, int* width, int* height)
2463 {
2464  int mask = NoValue;
2465  register char *strind;
2466  unsigned int tempWidth=0, tempHeight=0;
2467  int tempX=0, tempY=0;
2468  char *nextCharacter;
2469 
2470  if (!string || (*string == '\0')) return mask;
2471  if (*string == '=')
2472  string++; /* ignore possible '=' at beg of geometry spec */
2473 
2474  strind = const_cast<char *>(string);
2475  if (*strind != '+' && *strind != '-' && *strind != 'x') {
2476  tempWidth = ReadInteger(strind, &nextCharacter);
2477  if (strind == nextCharacter)
2478  return 0;
2479  strind = nextCharacter;
2480  mask |= WidthValue;
2481  }
2482 
2483  if (*strind == 'x' || *strind == 'X') {
2484  strind++;
2485  tempHeight = ReadInteger(strind, &nextCharacter);
2486  if (strind == nextCharacter)
2487  return 0;
2488  strind = nextCharacter;
2489  mask |= HeightValue;
2490  }
2491 
2492  if ((*strind == '+') || (*strind == '-')) {
2493  if (*strind == '-') {
2494  strind++;
2495  tempX = -ReadInteger(strind, &nextCharacter);
2496  if (strind == nextCharacter)
2497  return 0;
2498  strind = nextCharacter;
2499  mask |= XNegative;
2500 
2501  }
2502  else
2503  { strind++;
2504  tempX = ReadInteger(strind, &nextCharacter);
2505  if (strind == nextCharacter)
2506  return 0;
2507  strind = nextCharacter;
2508  }
2509  mask |= XValue;
2510  if ((*strind == '+') || (*strind == '-')) {
2511  if (*strind == '-') {
2512  strind++;
2513  tempY = -ReadInteger(strind, &nextCharacter);
2514  if (strind == nextCharacter)
2515  return 0;
2516  strind = nextCharacter;
2517  mask |= YNegative;
2518 
2519  }
2520  else
2521  {
2522  strind++;
2523  tempY = ReadInteger(strind, &nextCharacter);
2524  if (strind == nextCharacter)
2525  return 0;
2526  strind = nextCharacter;
2527  }
2528  mask |= YValue;
2529  }
2530  }
2531 
2532  /* If strind isn't at the end of the string then it's an invalid
2533  geometry specification. */
2534 
2535  if (*strind != '\0') return 0;
2536 
2537  if (mask & XValue)
2538  *x = tempX;
2539  if (mask & YValue)
2540  *y = tempY;
2541  if (mask & WidthValue)
2542  *width = tempWidth;
2543  if (mask & HeightValue)
2544  *height = tempHeight;
2545  return mask;
2546 }
2547 
2548 #ifdef QT3_SUPPORT
2549 void QApplication::setMainWidget(QWidget *mainWidget)
2550 {
2551  QApplicationPrivate::main_widget = mainWidget;
2552  if (QApplicationPrivate::main_widget) // give WM command line
2553  QApplicationPrivate::applyQWSSpecificCommandLineArguments(QApplicationPrivate::main_widget);
2554 }
2555 #endif
2556 
2557 void QApplicationPrivate::applyQWSSpecificCommandLineArguments(QWidget *main_widget)
2558 {
2559  static bool beenHereDoneThat = false;
2560  if (beenHereDoneThat)
2561  return;
2562  beenHereDoneThat = true;
2563  if (qApp->windowIcon().isNull() && main_widget->testAttribute(Qt::WA_SetWindowIcon))
2564  qApp->setWindowIcon(main_widget->windowIcon());
2565  if (mwTitle) // && main_widget->windowTitle().isEmpty())
2567  if (mwGeometry) { // parse geometry
2568  int x = 0;
2569  int y = 0;
2570  int w = 0;
2571  int h = 0;
2572  int m = parseGeometry(mwGeometry, &x, &y, &w, &h);
2573  QSize minSize = main_widget->minimumSize();
2574  QSize maxSize = main_widget->maximumSize();
2575  if ((m & XValue) == 0)
2576  x = main_widget->geometry().x();
2577  if ((m & YValue) == 0)
2578  y = main_widget->geometry().y();
2579  if ((m & WidthValue) == 0)
2580  w = main_widget->width();
2581  if ((m & HeightValue) == 0)
2582  h = main_widget->height();
2583  w = qMin(w,maxSize.width());
2584  h = qMin(h,maxSize.height());
2585  w = qMax(w,minSize.width());
2586  h = qMax(h,minSize.height());
2587  if ((m & XNegative)) {
2588  x = qApp->desktop()->width() + x - w;
2589  x -= (main_widget->frameGeometry().width() - main_widget->width()) / 2;
2590  } else {
2591  x += (main_widget->geometry().x() - main_widget->x());
2592  }
2593  if ((m & YNegative)) {
2594  y = qApp->desktop()->height() + y - h;
2595  } else {
2596  y += (main_widget->geometry().y() - main_widget->y());
2597  }
2598 
2599  main_widget->setGeometry(x, y, w, h);
2600  }
2601 }
2602 
2603 /*****************************************************************************
2604  QApplication cursor stack
2605  *****************************************************************************/
2606 #ifndef QT_NO_CURSOR
2608 {
2609  qApp->d_func()->cursor_list.prepend(cursor);
2610 
2612  if (!w && qt_last_x)
2613  w = topLevelAt(*qt_last_x, *qt_last_y);
2614  if (!w)
2615  w = desktop();
2616  QPaintDevice::qwsDisplay()->selectCursor(w, qApp->d_func()->cursor_list.first().handle());
2617 }
2618 
2620 {
2621  if (qApp->d_func()->cursor_list.isEmpty())
2622  return;
2623  qApp->d_func()->cursor_list.removeFirst();
2624 
2626  if (!w && qt_last_x)
2627  w = topLevelAt(*qt_last_x, *qt_last_y);
2628  if (!w)
2629  w = desktop();
2630 
2631  int cursor_handle = Qt::ArrowCursor;
2632  if (qApp->d_func()->cursor_list.isEmpty()) {
2633  qws_overrideCursor = false;
2635  if (upw)
2636  cursor_handle = upw->cursor().handle();
2637  } else {
2638  cursor_handle = qApp->d_func()->cursor_list.first().handle();
2639  }
2640  QPaintDevice::qwsDisplay()->selectCursor(w, cursor_handle);
2641 }
2642 #endif// QT_NO_CURSOR
2643 
2644 
2645 
2646 /*****************************************************************************
2647  Routines to find a Qt widget from a screen position
2648  *****************************************************************************/
2649 
2653 QWidget *QApplicationPrivate::findWidget(const QObjectList& list,
2654  const QPoint &pos, bool rec)
2655 {
2656  QWidget *w;
2657 
2658  for (int i = list.size()-1; i >= 0; --i) {
2659  if (list.at(i)->isWidgetType()) {
2660  w = static_cast<QWidget*>(list.at(i));
2662  && (!w->d_func()->extra || w->d_func()->extra->mask.isEmpty() || w->d_func()->extra->mask.contains(pos - w->geometry().topLeft()) )) {
2663  if (!rec)
2664  return w;
2665  QWidget *c = w->childAt(w->mapFromParent(pos));
2666  return c ? c : w;
2667  }
2668  }
2669  }
2670  return 0;
2671 }
2672 
2673 
2675 {
2676  //### QWSDisplay::windowAt() is currently only implemented in the server process
2677  int winId = QPaintDevice::qwsDisplay()->windowAt(pos);
2678  if (winId !=0)
2679  return QWidget::find(winId);
2680 
2681 #if 1
2682  // fallback implementation for client processes
2683 //### This is slightly wrong: we have no guarantee that the list is in
2684 //### stacking order, so if the topmost window is transparent, we may
2685 //### return the wrong widget
2686 
2687  QWidgetList list = topLevelWidgets();
2688  for (int i = list.size()-1; i >= 0; --i) {
2689  QWidget *w = list[i];
2690  if (w != QApplication::desktop() &&
2691  w->isVisible() && w->d_func()->localAllocatedRegion().contains(w->mapFromParent(pos))
2692  )
2693  return w;
2694  }
2695 #endif
2696  return 0;
2697 }
2698 
2699 void QApplication::beep()
2700 {
2701 }
2702 
2703 void QApplication::alert(QWidget *, int)
2704 {
2705 }
2706 
2707 Qt::KeyboardModifiers QApplication::queryKeyboardModifiers()
2708 {
2709  return keyboardModifiers(); // TODO proper implementation
2710 }
2711 
2713 {
2714  Q_D(QApplication);
2715  QScopedLoopLevelCounter loopLevelCounter(d->threadData);
2716  int oldstate = -1;
2717  bool isMove = false;
2718  if (event->type == QWSEvent::Mouse) {
2719  QWSMouseEvent::SimpleData &mouse = event->asMouse()->simpleData;
2720  isMove = mouse_x_root != mouse.x_root || mouse_y_root != mouse.y_root;
2721  oldstate = mouse_state;
2722  mouse_x_root = mouse.x_root;
2723  mouse_y_root = mouse.y_root;
2724  mouse_state = mouse.state;
2725  }
2726 
2727  long unused;
2728  if (filterEvent(event, &unused)) // send through app filter
2729  return 1;
2730 
2731  if (qwsEventFilter(event)) // send through app filter
2732  return 1;
2733 
2734 
2735 #ifndef QT_NO_QWS_PROPERTIES
2736  if (event->type == QWSEvent::PropertyNotify) {
2738  if (e->simpleData.property == 424242) { // Clipboard
2739 #ifndef QT_NO_CLIPBOARD
2740  if (qt_clipboard) {
2741  QClipboardEvent e(reinterpret_cast<QEventPrivate*>(event));
2743  }
2744 #endif
2745  }
2746  }
2747 #endif //QT_NO_QWS_PROPERTIES
2748 #ifndef QT_NO_COP
2749  else if (event->type == QWSEvent::QCopMessage) {
2750  QWSQCopMessageEvent *e = static_cast<QWSQCopMessageEvent*>(event);
2752  return 0;
2753  }
2754 #endif
2755 #if !defined(QT_NO_QWS_QPF2)
2756  else if (event->type == QWSEvent::Font) {
2757  QWSFontEvent *e = static_cast<QWSFontEvent *>(event);
2760  }
2761  }
2762 #endif
2763 
2764  QPointer<QETWidget> widget = static_cast<QETWidget*>(QWidget::find(WId(event->window())));
2765 #ifdef Q_BACKINGSTORE_SUBSURFACES
2766  if (!widget) { // XXX: hw: hack for accessing subsurfaces
2767  extern QWSWindowSurface* qt_findWindowSurface(int);
2768  QWSWindowSurface *s = qt_findWindowSurface(event->window());
2769  if (s)
2770  widget = static_cast<QETWidget*>(s->window());
2771  }
2772 #endif
2773 
2774 #ifndef QT_NO_DIRECTPAINTER
2775  if (!widget && d->directPainters) {
2776  QDirectPainter *dp = d->directPainters->value(WId(event->window()));
2777  if (dp == 0) {
2778  } else if (event->type == QWSEvent::Region) {
2779  QWSRegionEvent *e = static_cast<QWSRegionEvent*>(event);
2780  QRegion reg;
2783  return 1;
2784 #ifndef QT_NO_QWSEMBEDWIDGET
2785  } else if (event->type == QWSEvent::Embed) {
2786  QWSEmbedEvent *e = static_cast<QWSEmbedEvent*>(event);
2788  return 1;
2789  #endif // QT_NO_QWSEMBEDWIDGET
2790  }
2791  }
2792 #endif // QT_NO_DIRECTPAINTER
2793 
2794 #ifndef QT_NO_QWS_MANAGER
2795  if (d->last_manager && event->type == QWSEvent::Mouse) {
2796  QPoint pos(event->asMouse()->simpleData.x_root, event->asMouse()->simpleData.y_root);
2797  if (!d->last_manager->cachedRegion().contains(pos)) {
2798  // MouseEvent not yet delivered, so QCursor::pos() is not yet updated, sending 2 x pos
2799  QMouseEvent outside(QEvent::MouseMove, pos, pos, Qt::NoButton, 0, 0);
2800  QApplication::sendSpontaneousEvent(d->last_manager, &outside);
2801  d->last_manager = 0;
2802  qt_last_cursor = 0xffffffff; //decoration is like another window; must redo cursor
2803  }
2804  }
2805 #endif // QT_NO_QWS_MANAGER
2806 
2807  QETWidget *keywidget=0;
2808  bool grabbed=false;
2809  if (event->type==QWSEvent::Key || event->type == QWSEvent::IMEvent || event->type == QWSEvent::IMQuery) {
2810  keywidget = static_cast<QETWidget*>(QWidget::keyboardGrabber());
2811  if (keywidget) {
2812  grabbed = true;
2813  } else {
2814  if (QWidget *popup = QApplication::activePopupWidget()) {
2815  if (popup->focusWidget())
2816  keywidget = static_cast<QETWidget*>(popup->focusWidget());
2817  else
2818  keywidget = static_cast<QETWidget*>(popup);
2820  keywidget = static_cast<QETWidget*>(QApplicationPrivate::focus_widget);
2821  else if (widget)
2822  keywidget = static_cast<QETWidget*>(widget->window());
2823  }
2824  } else if (event->type==QWSEvent::MaxWindowRect) {
2825  QRect r = static_cast<QWSMaxWindowRectEvent*>(event)->simpleData.rect;
2826  setMaxWindowRect(r);
2827  return 0;
2828 #ifndef QT_NO_QWS_DYNAMICSCREENTRANSFORMATION
2829  } else if (event->type == QWSEvent::ScreenTransformation) {
2833  return 0;
2834 #endif
2835  } else if (widget && event->type==QWSEvent::Mouse) {
2836  // The mouse event is to one of my top-level widgets
2837  // which one?
2838  const int btnMask = Qt::LeftButton | Qt::RightButton | Qt::MidButton;
2839  QPoint p(event->asMouse()->simpleData.x_root,
2840  event->asMouse()->simpleData.y_root);
2841  int mouseButtonState = event->asMouse()->simpleData.state & btnMask;
2842  static int btnstate = 0;
2843 
2844  QETWidget *w = static_cast<QETWidget*>(QWidget::mouseGrabber());
2845  if (w && !mouseButtonState && qt_pressGrab == w)
2846  qt_pressGrab = 0;
2847 #ifndef QT_NO_QWS_MANAGER
2848  if (!w)
2849  w = static_cast<QETWidget*>(QWSManager::grabbedMouse());
2850 #endif
2851  if (w) {
2852  // Our mouse is grabbed - send it.
2853  widget = w;
2854  btnstate = mouseButtonState;
2855  } else {
2856  static QWidget *gw = 0;
2857  // Three jobs to do here:
2858  // 1. find the child widget this event belongs to.
2859  // 2. make sure the cursor is correct.
2860  // 3. handle implicit mouse grab due to button press.
2861  w = widget; // w is the widget the cursor is in.
2862 
2863  //### ??? alloc_region
2864  //#### why should we get events outside alloc_region ????
2865  if (1 /*widget->data->alloc_region.contains(dp) */) {
2866  // Find the child widget that the cursor is in.
2867  w = static_cast<QETWidget*>(widget->childAt(widget->mapFromParent(p)));
2868  if (!w)
2869  w = widget;
2870 #ifndef QT_NO_CURSOR
2871  // Update Cursor.
2872  if (!gw || gw != w || qt_last_cursor == 0xffffffff) {
2873  QCursor *curs = 0;
2874  if (!qApp->d_func()->cursor_list.isEmpty())
2875  curs = &qApp->d_func()->cursor_list.first();
2876  else if (w->d_func()->extraData())
2877  curs = w->d_func()->extraData()->curs;
2878  QWidget *pw = w;
2879  // If this widget has no cursor set, try parent.
2880  while (!curs) {
2881  pw = pw->parentWidget();
2882  if (!pw)
2883  break;
2884  if (pw->d_func()->extraData())
2885  curs = pw->d_func()->extraData()->curs;
2886  }
2887  if (!qws_overrideCursor) {
2888  if (curs)
2889  QPaintDevice::qwsDisplay()->selectCursor(widget, curs->handle());
2890  else
2892  }
2893  }
2894 #endif
2895  gw = w;
2896  } else {
2897  // This event is not for any of our widgets
2898  gw = 0;
2899  }
2900  if (mouseButtonState && !btnstate) {
2901  // The server has grabbed the mouse for us.
2902  // Remember which of my widgets has it.
2903  qt_pressGrab = w;
2904  if (!widget->isActiveWindow() &&
2906  !((widget->windowFlags() & Qt::FramelessWindowHint) || (widget->windowType() == Qt::Tool))) {
2907  widget->activateWindow();
2908  if (widget->raiseOnClick())
2909  widget->raise();
2910  }
2911  }
2912  btnstate = mouseButtonState;
2913  widget = w;
2914  }
2915  }
2916 
2917  if (!widget) { // don't know this window
2918  if (!QWidget::mouseGrabber()
2919 #ifndef QT_NO_QWS_MANAGER
2920  && !QWSManager::grabbedMouse()
2921 #endif
2922  ) {
2923  qt_last_cursor = 0xffffffff; // cursor can be changed by another application
2924  }
2925 
2927  if (popup) {
2928 
2929  /*
2930  That is more than suboptimal. The real solution should
2931  do some keyevent and buttonevent translation, so that
2932  the popup still continues to work as the user expects.
2933  Unfortunately this translation is currently only
2934  possible with a known widget. I'll change that soon
2935  (Matthias).
2936  */
2937 
2938  // Danger - make sure we don't lock the server
2939  switch (event->type) {
2940  case QWSEvent::Mouse:
2941  case QWSEvent::Key:
2942  do {
2943  popup->close();
2944  } while ((popup = qApp->activePopupWidget()));
2945  return 1;
2946  }
2947  }
2948  if (event->type == QWSEvent::Mouse && *mouseInWidget) {
2949  QApplicationPrivate::dispatchEnterLeave(0, *mouseInWidget);
2950  (*mouseInWidget) = 0;
2951  }
2952  return -1;
2953  }
2954 
2955  if (app_do_modal) // modal event handling
2956  if (!qt_try_modal(widget, event)) {
2957  return 1;
2958  }
2959 
2960  if (widget->qwsEvent(event)) // send through widget filter
2961  return 1;
2962  switch (event->type) {
2963 
2964  case QWSEvent::Mouse: { // mouse event
2965  QWSMouseEvent *me = event->asMouse();
2967 
2968  // Translate a QWS event into separate move
2969  // and press/release events
2970  // Beware of reentrancy: we can enter a modal state
2971  // inside translateMouseEvent
2972 
2973  if (isMove) {
2974  QWSMouseEvent move = *me;
2975  move.simpleData.state = oldstate;
2976  widget->translateMouseEvent(&move, oldstate);
2977  }
2978  if ((mouse.state&Qt::MouseButtonMask) != (oldstate&Qt::MouseButtonMask)) {
2979  widget->translateMouseEvent(me, oldstate);
2980  }
2981 
2982  if (mouse.delta != 0)
2983  widget->translateWheelEvent(me);
2984 
2985  if (qt_button_down && (mouse_state & Qt::MouseButtonMask) == 0)
2986  qt_button_down = 0;
2987 
2988  break;
2989  }
2990  case QWSEvent::Key: // keyboard event
2991  if (keywidget) // should always exist
2992  keywidget->translateKeyEvent(static_cast<QWSKeyEvent*>(event), grabbed);
2993  break;
2994 
2995 #ifndef QT_NO_QWS_INPUTMETHODS
2996  case QWSEvent::IMEvent:
2997  if (keywidget) // should always exist
2998  QWSInputContext::translateIMEvent(keywidget, static_cast<QWSIMEvent*>(event));
2999  break;
3000 
3001  case QWSEvent::IMQuery:
3002  if (keywidget) // should always exist
3003  QWSInputContext::translateIMQueryEvent(keywidget, static_cast<QWSIMQueryEvent*>(event));
3004  break;
3005 
3006  case QWSEvent::IMInit:
3007  QWSInputContext::translateIMInitEvent(static_cast<QWSIMInitEvent*>(event));
3008  break;
3009 #endif
3010  case QWSEvent::Region:
3011  widget->translateRegionEvent(static_cast<QWSRegionEvent*>(event));
3012  break;
3013  case QWSEvent::Focus:
3014  if ((static_cast<QWSFocusEvent*>(event))->simpleData.get_focus) {
3015  if (widget == static_cast<QWidget *>(desktop()))
3016  return true; // not interesting
3017  if (activeWindow() != widget) {
3018  setActiveWindow(widget);
3020  static_cast<QETWidget *>(QApplicationPrivate::active_window)->repaintDecoration(desktop()->rect(), false);
3021  if (widget && !d->inPopupMode()) {
3022  QWidget *w = widget->focusWidget();
3023  while (w && w->focusProxy())
3024  w = w->focusProxy();
3025  if (w && (w->focusPolicy() != Qt::NoFocus))
3026  w->setFocus();
3027  else
3028  widget->QWidget::focusNextPrevChild(true);
3030  if (widget->focusWidget())
3031  widget->focusWidget()->setFocus();
3032  else
3033  widget->window()->setFocus();
3034  }
3035  }
3036  }
3037  } else { // lost focus
3038  if (widget == static_cast<QWidget *>(desktop()))
3039  return true; // not interesting
3042  setActiveWindow(0);
3043  qt_last_cursor = 0xffffffff;
3044  //QApplicationPrivate::active_window = 0;
3045  if (old)
3046  old->repaintDecoration(desktop()->rect(), false);
3047  /* activateWindow() sends focus events
3048  QApplication::setFocusWidget(0);
3049  */
3050  }
3051  }
3052  break;
3053 
3055  if (static_cast<QWidget *>(widget) == desktop())
3056  return true;
3057  switch ((static_cast<QWSWindowOperationEvent *>(event))->simpleData.op) {
3059  widget->show();
3060  break;
3062  widget->hide();
3063  break;
3065  widget->showMaximized();
3066  break;
3068  widget->showMinimized();
3069  break;
3071  widget->showNormal();
3072  break;
3075  break;
3076  }
3077  break;
3078 #ifndef QT_NO_QWSEMBEDWIDGET
3079  case QWSEvent::Embed:
3080  widget->translateEmbedEvent(static_cast<QWSEmbedEvent*>(event));
3081  break;
3082 #endif
3083  default:
3084  break;
3085  }
3086 
3087  return 0;
3088 }
3089 
3091 {
3092  return false;
3093 }
3094 
3095 void QApplication::qwsSetCustomColors(QRgb *colorTable, int start, int numColors)
3096 {
3097  if (start < 0 || start > 39) {
3098  qWarning("QApplication::qwsSetCustomColors: start < 0 || start > 39");
3099  return;
3100  }
3101  if (start + numColors > 40) {
3102  numColors = 40 - start;
3103  qWarning("QApplication::qwsSetCustomColors: Too many colors");
3104  }
3105  start += 216;
3106  for (int i = 0; i < numColors; i++) {
3107  qt_screen->set(start + i, qRed(colorTable[i]), qGreen(colorTable[i]),
3108  qBlue(colorTable[i]));
3109  }
3110 }
3111 
3112 #ifndef QT_NO_QWS_MANAGER
3113 QDecoration &QApplication::qwsDecoration()
3114 {
3115  return *qws_decoration;
3116 }
3117 
3118 void QApplication::qwsSetDecoration(QDecoration *dec)
3119 {
3120  if (dec) {
3121  delete qws_decoration;
3122  qws_decoration = dec;
3123  QWidgetList widgets = topLevelWidgets();
3124  for (int i = 0; i < widgets.size(); ++i) {
3125  QWidget *w = widgets[i];
3126  if (w->isVisible() && w != desktop()) {
3127  static_cast<QETWidget *>(w)->updateRegion();
3128  static_cast<QETWidget *>(w)->repaintDecoration(desktop()->rect(), false);
3129  if (w->isMaximized())
3130  w->showMaximized();
3131  }
3132  }
3133  }
3134 }
3135 
3136 QDecoration* QApplication::qwsSetDecoration(const QString &decoration)
3137 {
3138  QDecoration *decore = QDecorationFactory::create(decoration);
3139  if (!decore)
3140  return 0;
3141 
3142  qwsSetDecoration(decore);
3143  return decore;
3144 }
3145 
3146 #endif
3147 
3149 {
3150  return app_do_modal;
3151 }
3152 
3154 {
3155  if (!qt_modal_stack)
3156  qt_modal_stack = new QWidgetList;
3157  qt_modal_stack->insert(0, widget);
3158  app_do_modal = true;
3159 }
3160 
3162 {
3163  if (qt_modal_stack && qt_modal_stack->removeAll(widget)) {
3164  if (qt_modal_stack->isEmpty()) {
3165  delete qt_modal_stack;
3166  qt_modal_stack = 0;
3167  }
3168  }
3169  app_do_modal = qt_modal_stack != 0;
3170 }
3171 
3172 static bool qt_try_modal(QWidget *widget, QWSEvent *event)
3173 {
3174  QWidget * top = 0;
3175 
3176  if (QApplicationPrivate::tryModalHelper(widget, &top))
3177  return true;
3178 
3179  bool block_event = false;
3180  bool paint_event = false;
3181 
3182  switch (event->type) {
3183  case QWSEvent::Focus:
3184  if (!static_cast<QWSFocusEvent*>(event)->simpleData.get_focus)
3185  break;
3186  // drop through
3187  case QWSEvent::Mouse: // disallow mouse/key events
3188  case QWSEvent::Key:
3189  block_event = true;
3190  break;
3191  }
3192 
3193  if (top->parentWidget() == 0 && (block_event || paint_event))
3194  top->raise();
3195 
3196  return !block_event;
3197 }
3198 
3199 static int openPopupCount = 0;
3201 {
3202  openPopupCount++;
3203  if (!popupWidgets) { // create list
3204  popupWidgets = new QWidgetList;
3205 
3206  /* only grab if you are the first/parent popup */
3207  QPaintDevice::qwsDisplay()->grabMouse(popup,true);
3208  QPaintDevice::qwsDisplay()->grabKeyboard(popup,true);
3209  popupGrabOk = true;
3210  }
3211  popupWidgets->append(popup); // add to end of list
3212 
3213  // popups are not focus-handled by the window system (the first
3214  // popup grabbed the keyboard), so we have to do that manually: A
3215  // new popup gets the focus
3216  if (popup->focusWidget()) {
3218  } else if (popupWidgets->count() == 1) { // this was the first popup
3219  if (QWidget *fw = QApplication::focusWidget()) {
3221  QApplication::sendEvent(fw, &e);
3222  }
3223  }
3224 }
3225 
3227 {
3228  if (!popupWidgets)
3229  return;
3230 
3231  popupWidgets->removeAll(popup);
3232  if (popup == popupOfPopupButtonFocus) {
3233  popupButtonFocus = 0;
3234  popupOfPopupButtonFocus = 0;
3235  }
3236  if (popupWidgets->count() == 0) { // this was the last popup
3237  popupCloseDownMode = true; // control mouse events
3238  delete popupWidgets;
3239  popupWidgets = 0;
3240  if (popupGrabOk) { // grabbing not disabled
3241  QPaintDevice::qwsDisplay()->grabMouse(popup,false);
3242  QPaintDevice::qwsDisplay()->grabKeyboard(popup,false);
3243  popupGrabOk = false;
3244  // XXX ungrab keyboard
3245  }
3246  if (active_window) {
3247  if (QWidget *fw = active_window->focusWidget()) {
3248  if (fw != QApplication::focusWidget()) {
3249  fw->setFocus(Qt::PopupFocusReason);
3250  } else {
3252  QApplication::sendEvent(fw, &e);
3253  }
3254  }
3255  }
3256  } else {
3257  // popups are not focus-handled by the window system (the
3258  // first popup grabbed the keyboard), so we have to do that
3259  // manually: A popup was closed, so the previous popup gets
3260  // the focus.
3261  QWidget* aw = popupWidgets->last();
3262  if (QWidget *fw = aw->focusWidget())
3263  fw->setFocus(Qt::PopupFocusReason);
3264  }
3265 }
3266 
3267 /*****************************************************************************
3268  Event translation; translates FB events to Qt events
3269  *****************************************************************************/
3270 
3271 //
3272 // Mouse event translation
3273 //
3274 // FB doesn't give mouse double click events, so we generate them by
3275 // comparing window, time and position between two mouse press events.
3276 //
3277 
3278 
3279 // Needed for QCursor::pos
3280 
3282 
3283 
3284 
3285 //
3286 // Wheel event translation
3287 //
3289 {
3290 #ifdef QT_NO_WHEELEVENT
3291  Q_UNUSED(me);
3292  return false;
3293 #else
3294  const QWSMouseEvent::SimpleData &mouse = me->simpleData;
3295 
3296  // Figure out wheeling direction:
3297  // Horizontal wheel w/o Alt
3298  // OR Vertical wheel w/ Alt ==> Horizontal wheeling
3299  // ..all other permutations ==> Vertical wheeling
3300  int axis = mouse.delta / 120; // WHEEL_DELTA?
3301  Qt::Orientation orient = ((axis == 2 || axis == -2) && ((mouse.state & Qt::AltModifier) == 0))
3302  ||((axis == 1 || axis == -1) && mouse.state & Qt::AltModifier)
3304 
3305  QPoint mousePoint = QPoint(mouse.x_root, mouse.y_root);
3306 
3307  // send the event to the widget or its ancestors
3308  QWidget* popup = qApp->activePopupWidget();
3309  if (popup && window() != popup)
3310  popup->close();
3311  QWheelEvent we(mapFromGlobal(mousePoint), mousePoint, mouse.delta,
3312  Qt::MouseButtons(mouse.state & Qt::MouseButtonMask),
3313  Qt::KeyboardModifiers(mouse.state & Qt::KeyboardModifierMask), orient);
3314  if (QApplication::sendSpontaneousEvent(this, &we))
3315  return true;
3316 
3317  // send the event to the widget that has the focus or its ancestors, if different
3318  QWidget *w = this;
3319  if (w != qApp->focusWidget() && (w = qApp->focusWidget())) {
3320  QWidget* popup = qApp->activePopupWidget();
3321  if (popup && w != popup)
3322  popup->hide();
3324  return true;
3325  }
3326  return false;
3327 #endif
3328 }
3329 
3331 {
3332  static bool manualGrab = false;
3333  QPoint pos;
3334  QPoint globalPos;
3335  int button = 0;
3336 
3337  if (sm_blockUserInput) // block user interaction during session management
3338  return true;
3339  const QWSMouseEvent::SimpleData &mouse = event->simpleData;
3340  pos = mapFromGlobal(QPoint(mouse.x_root, mouse.y_root));
3341 // if (qt_last_x) {
3342 // *qt_last_x=mouse.x_root;
3343 // *qt_last_y=mouse.y_root;
3344 // }
3345  globalPos.rx() = mouse.x_root;
3346  globalPos.ry() = mouse.y_root;
3347 
3349 
3350  Qt::MouseButtons buttonstate = Qt::MouseButtons(mouse.state & Qt::MouseButtonMask);
3351  Qt::KeyboardModifiers keystate = Qt::KeyboardModifiers(mouse.state & Qt::KeyboardModifierMask);
3352 
3353  if (mouse.state == prevstate) {
3354  // mouse move
3355  type = QEvent::MouseMove;
3356  } else if ((mouse.state&AnyButton) != (prevstate&AnyButton)) {
3357  Qt::MouseButtons current_buttons = Qt::MouseButtons(prevstate&Qt::MouseButtonMask);
3358  for (button = Qt::LeftButton; !type && button <= Qt::MidButton; button<<=1) {
3359  if ((mouse.state&button) != (current_buttons&button)) {
3360  // button press or release
3361  current_buttons = Qt::MouseButtons(current_buttons ^ button);
3362 
3363 #ifndef QT_NO_QWS_INPUTMETHODS
3364  //############ We used to do a QInputContext::reset(oldFocus);
3365  // when we changed the focus widget. See change 93389 for where the
3366  // focus code went. The IM code was (after testing for ClickToFocus):
3367  //if (mouse.state&button && w != QInputContext::microFocusWidget()) //button press
3368  // QInputContext::reset(oldFocus);
3369 
3370 #endif
3371  if (mouse.state&button) { //button press
3372  qt_button_down = childAt(pos);
3373  if (!qt_button_down)
3374  qt_button_down = this;
3375  if (/*XXX mouseActWindow == this &&*/
3376  mouseButtonPressed == button &&
3377  long(mouse.time) -long(mouseButtonPressTime)
3382  mouseButtonPressTime -= 2000; // no double-click next time
3383  } else {
3384  type = QEvent::MouseButtonPress;
3385  mouseButtonPressTime = mouse.time;
3386  }
3387  mouseButtonPressed = button; // save event params for
3388  mouseXPos = globalPos.x(); // future double click tests
3389  mouseYPos = globalPos.y();
3390  } else { // mouse button released
3391  if (manualGrab) { // release manual grab
3392  manualGrab = false;
3393  // XXX XUngrabPointer(x11Display(), CurrentTime);
3394  }
3395 
3397  }
3398  }
3399  }
3400  button >>= 1;
3401  }
3402  //XXX mouseActWindow = winId(); // save some event params
3403 
3404  if (type == 0) { // event consumed
3405  return false; //EXIT in the normal case
3406  }
3407 
3408  if (qApp->d_func()->inPopupMode()) { // in popup mode
3409  QWidget *popup = qApp->activePopupWidget();
3410  // in X11, this would be the window we are over.
3411  // in QWS this is the top level popup. to allow mouse
3412  // events to other widgets, need to go through qApp->QApplicationPrivate::popupWidgets.
3413  QSize s(qt_screen->width(), qt_screen->height());
3414  for (int i = 0; i < QApplicationPrivate::popupWidgets->size(); ++i) {
3416 
3417  if ((w->windowType() == Qt::Popup) && w->d_func()->localAllocatedRegion().contains(globalPos - w->geometry().topLeft()))
3418  {
3419  popup = w;
3420  break;
3421  }
3422  }
3423  pos = popup->mapFromGlobal(globalPos);
3424  bool releaseAfter = false;
3425  QWidget *popupChild = popup->childAt(pos);
3426  QWidget *popupTarget = popupChild ? popupChild : popup;
3427 
3428  if (popup != popupOfPopupButtonFocus){
3429  popupButtonFocus = 0;
3430  popupOfPopupButtonFocus = 0;
3431  }
3432 
3433  if (!popupTarget->isEnabled()) {
3434  return false; //EXIT special case
3435  }
3436 
3437  switch (type) {
3440  popupButtonFocus = popupChild;
3441  popupOfPopupButtonFocus = popup;
3442  break;
3444  releaseAfter = true;
3445  break;
3446  default:
3447  break; // nothing for mouse move
3448  }
3449 
3450  int oldOpenPopupCount = openPopupCount;
3451 
3452  if (popupButtonFocus) {
3453  QMouseEvent e(type, popupButtonFocus->mapFromGlobal(globalPos),
3454  globalPos, Qt::MouseButton(button), buttonstate, keystate);
3455  QApplication::sendSpontaneousEvent(popupButtonFocus, & e);
3456  if (releaseAfter) {
3457  popupButtonFocus = 0;
3458  popupOfPopupButtonFocus = 0;
3459  }
3460  } else if (popupChild) {
3461  QMouseEvent e(type, popupChild->mapFromGlobal(globalPos),
3462  globalPos, Qt::MouseButton(button), buttonstate, keystate);
3463  QApplication::sendSpontaneousEvent(popupChild, & e);
3464  } else {
3465  QMouseEvent e(type, pos, globalPos, Qt::MouseButton(button), buttonstate, keystate);
3466  QApplication::sendSpontaneousEvent(popupChild ? popupChild : popup, & e);
3467  }
3468 #ifndef QT_NO_CONTEXTMENU
3469  if (type == QEvent::MouseButtonPress && button == Qt::RightButton && (openPopupCount == oldOpenPopupCount)) {
3470  QWidget *popupEvent = popup;
3471  if(popupButtonFocus)
3472  popupEvent = popupButtonFocus;
3473  else if(popupChild)
3474  popupEvent = popupChild;
3475  QContextMenuEvent e(QContextMenuEvent::Mouse, pos, globalPos, keystate);
3476  QApplication::sendSpontaneousEvent(popupEvent, &e);
3477  }
3478 #endif // QT_NO_CONTEXTMENU
3479 
3480  if (releaseAfter)
3481  qt_button_down = 0;
3482 
3483  } else { //qApp not in popup mode
3484  QWidget *widget = this;
3486  if (!w && qt_button_down)
3487  w = qt_button_down;
3488  if (w && w != this) {
3489  widget = w;
3490  pos = mapToGlobal(pos);
3491  pos = w->mapFromGlobal(pos);
3492  }
3493 
3494  if (popupCloseDownMode) {
3495  popupCloseDownMode = false;
3496  if ((windowType() == Qt::Popup)) // ignore replayed event
3497  return true; //EXIT
3498  }
3499 
3501  if (type == QEvent::MouseButtonRelease &&
3502  (mouse.state & (~button) & (Qt::LeftButton |
3503  Qt::MidButton |
3504  Qt::RightButton)) == 0) {
3505  // Button released outside the widget -> leave the widget after the
3506  // release event has been delivered.
3507  if (widget == qt_button_down && (pos.x() < 0 || pos.y() < 0))
3508  leaveAfterRelease = qt_button_down;
3509  qt_button_down = 0;
3510  }
3511 
3512  int oldOpenPopupCount = openPopupCount;
3513 
3514  QMouseEvent e(type, pos, globalPos, Qt::MouseButton(button), buttonstate, keystate);
3515 #ifndef QT_NO_QWS_MANAGER
3516  if (widget->isWindow() && widget->d_func()->topData()->qwsManager
3517  && (widget->d_func()->topData()->qwsManager->region().contains(globalPos)
3518  || QWSManager::grabbedMouse() )) {
3519  if ((*mouseInWidget)) {
3520  QApplicationPrivate::dispatchEnterLeave(0, *mouseInWidget);
3521  (*mouseInWidget) = 0;
3522  }
3523  QApplication::sendSpontaneousEvent(widget->d_func()->topData()->qwsManager, &e);
3524  qApp->d_func()->last_manager = widget->d_func()->topData()->qwsManager;
3525  } else
3526 #endif
3527  {
3528  if (widget != (*mouseInWidget)) {
3529  QApplicationPrivate::dispatchEnterLeave(widget, *mouseInWidget);
3530  (*mouseInWidget) = widget;
3531  qt_last_mouse_receiver = widget;
3532  }
3534  if (leaveAfterRelease && !QWidget::mouseGrabber()) {
3535  *mouseInWidget = QApplication::widgetAt(globalPos);
3536  qt_last_mouse_receiver = *mouseInWidget;
3537  QApplicationPrivate::dispatchEnterLeave(*mouseInWidget, leaveAfterRelease);
3538  leaveAfterRelease = 0;
3539  }
3540  }
3541 #ifndef QT_NO_CONTEXTMENU
3542  if (type == QEvent::MouseButtonPress && button == Qt::RightButton && (openPopupCount == oldOpenPopupCount)) {
3543  QContextMenuEvent e(QContextMenuEvent::Mouse, pos, globalPos, keystate);
3545  }
3546 #endif // QT_NO_CONTEXTMENU
3547  }
3548  return true;
3549 }
3550 
3551 
3552 bool QETWidget::translateKeyEvent(const QWSKeyEvent *event, bool grab) /* grab is used in the #ifdef */
3553 {
3554  int code = -1;
3555  //### Qt assumes keyboard state is state *before*, while QWS uses state after the event
3556  static Qt::KeyboardModifiers oldstate;
3557  Qt::KeyboardModifiers state = oldstate;
3558  oldstate = event->simpleData.modifiers;
3559 
3560  if (sm_blockUserInput) // block user interaction during session management
3561  return true;
3562 
3563  if (!isEnabled())
3564  return true;
3565 
3566  QEvent::Type type = event->simpleData.is_press ?
3568  bool autor = event->simpleData.is_auto_repeat;
3569  QString text;
3570  if (event->simpleData.unicode && event->simpleData.unicode != 0xffff)
3571  text += QChar(event->simpleData.unicode);
3572  code = event->simpleData.keycode;
3573 
3574 #if defined QT3_SUPPORT && !defined(QT_NO_SHORTCUT)
3575  if (type == QEvent::KeyPress && !grab
3576  && static_cast<QApplicationPrivate*>(qApp->d_ptr.data())->use_compat()) {
3577  // send accel events if the keyboard is not grabbed
3578  QKeyEvent a(type, code, state, text, autor, int(text.length()));
3579  if (static_cast<QApplicationPrivate*>(qApp->d_ptr.data())->qt_tryAccelEvent(this, &a))
3580  return true;
3581  }
3582 #else
3583  Q_UNUSED(grab);
3584 #endif
3585  if (!text.isEmpty() && testAttribute(Qt::WA_KeyCompression)) {
3586  // the widget wants key compression so it gets it
3587 
3588  // XXX not implemented
3589  }
3590 
3591  QKeyEvent e(type, code, state, text, autor, int(text.length()));
3592  return QApplication::sendSpontaneousEvent(this, &e);
3593 }
3594 
3596 {
3597  QWSWindowSurface *surface = static_cast<QWSWindowSurface*>(windowSurface());
3598  Q_ASSERT(surface);
3599 
3600  QRegion region;
3601  region.setRects(event->rectangles, event->simpleData.nrectangles);
3602 
3603  switch (event->simpleData.type) {
3605  region.translate(-mapToGlobal(QPoint()));
3606  surface->setClipRegion(region);
3607  break;
3608 #ifdef QT_QWS_CLIENTBLIT
3609  case QWSRegionEvent::DirectPaint:
3610  surface->setDirectRegion(region, event->simpleData.id);
3611  break;
3612 #endif
3613  default:
3614  break;
3615  }
3616 
3617  return true;
3618 }
3619 
3620 #ifndef QT_NO_QWSEMBEDWIDGET
3622 {
3623  if (event->simpleData.type | QWSEmbedEvent::Region) {
3624  const QRegion region = event->region;
3625  setGeometry(region.boundingRect());
3626  setVisible(!region.isEmpty());
3627  }
3628 }
3629 #endif // QT_NO_QWSEMBEDWIDGET
3630 
3632 {
3633  Q_UNUSED(post);
3634 #ifdef QT_NO_QWS_MANAGER
3635  Q_UNUSED(r);
3636 #else
3637  //please note that qwsManager is a QObject, not a QWidget.
3638  //therefore, normal ways of painting do not work.
3639  // However, it does listen to paint events.
3640 
3641  Q_D(QWidget);
3642  if (isWindow() && d->topData()->qwsManager && isVisible()) {
3643  QWSManager *manager = d->topData()->qwsManager;
3644  r &= manager->region();
3645  if (!r.isEmpty())
3646  manager->repaintRegion(QDecoration::All, QDecoration::Normal);
3647  }
3648 #endif
3649 }
3650 
3652 {
3653  Q_D(QWidget);
3654 
3655  QTLWExtra *topextra = d->maybeTopData();
3656  if (!topextra)
3657  return;
3658 
3659  QRegion myregion = d->localRequestedRegion();
3660  myregion.translate(geometry().topLeft());
3661 
3662 #ifndef QT_NO_QWS_MANAGER
3663  QWSManager *manager = topextra->qwsManager;
3664  if (manager)
3665  myregion += manager->region();
3666 #endif
3667 
3668  QRect br(myregion.boundingRect());
3669  topextra->frameStrut.setCoords(d->data.crect.x() - br.x(),
3670  d->data.crect.y() - br.y(),
3671  br.right() - d->data.crect.right(),
3672  br.bottom() - d->data.crect.bottom());
3673 }
3674 
3675 void QApplication::setCursorFlashTime(int msecs)
3676 {
3678 }
3679 
3680 
3682 {
3684 }
3685 
3687 {
3689 }
3690 
3692 {
3694 }
3695 
3697 {
3699 }
3700 
3702 {
3704 }
3705 
3706 #ifndef QT_NO_WHEELEVENT
3707 void QApplication::setWheelScrollLines(int lines)
3708 {
3710 }
3711 
3713 {
3715 }
3716 #endif
3717 
3718 void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
3719 {
3720  switch (effect) {
3721  case Qt::UI_AnimateMenu:
3723  break;
3724  case Qt::UI_FadeMenu:
3725  if (enable)
3728  break;
3729  case Qt::UI_AnimateCombo:
3731  break;
3732  case Qt::UI_AnimateTooltip:
3734  break;
3735  case Qt::UI_FadeTooltip:
3736  if (enable)
3739  break;
3740  case Qt::UI_AnimateToolBox:
3742  break;
3743  default:
3745  break;
3746  }
3747 }
3748 
3750 {
3752  return false;
3753 
3754  switch(effect) {
3755  case Qt::UI_AnimateMenu:
3757  case Qt::UI_FadeMenu:
3759  case Qt::UI_AnimateCombo:
3761  case Qt::UI_AnimateTooltip:
3763  case Qt::UI_FadeTooltip:
3765  case Qt::UI_AnimateToolBox:
3767  default:
3769  }
3770 }
3771 
3772 void QApplication::setArgs(int c, char **v)
3773 {
3774  Q_D(QApplication);
3775  d->argc = c;
3776  d->argv = v;
3777 }
3778 
3780 { }
3782 { }
3783 
3784 /* \internal
3785  This is used to clean up the qws server
3786  in case the QApplication constructor threw an exception
3787 */
3789 {
3792 }
3793 
QWidget * qt_mouseGrb
#define YValue
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
struct QWSPropertyReplyEvent::SimpleData simpleData
QPoint pos() const
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
static int keyboardInputInterval()
static QPointer< QWidget > leaveAfterRelease
void moveRegion(int winId, int dx, int dy)
void showMaximized()
Shows the widget maximized.
Definition: qwidget.cpp:3218
struct QWSAddPropertyCommand::SimpleData simpleData
struct QWSRepaintRegionCommand::SimpleData simpleData
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
HCURSOR_or_HANDLE handle() const
Returns a platform-specific cursor handle.
Definition: qcursor_mac.mm:301
double d
Definition: qnumeric_p.h:62
void nameRegion(int winId, const QString &n, const QString &c)
struct QWSIMResponseCommand::SimpleData simpleData
QSize maximumSize
the widget&#39;s maximum size in pixels
Definition: qwidget.h:173
void sendFontCommand(int type, const QByteArray &fontName)
static QWidget * main_widget
QSize minimumSize
the widget&#39;s minimum size
Definition: qwidget.h:172
static int openPopupCount
QImage toImage() const
Converts the pixmap to a QImage.
Definition: qpixmap.cpp:542
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.
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QApplication class manages the GUI application&#39;s control flow and main settings.
Definition: qapplication.h:99
bool qws_screen_is_interlaced
void reinit(const QString &newAppName)
int pixmapDepth() const
#define QT_QWS_PROPERTY_CONVERTSELECTION
void setMaxWindowRect(const QScreen *screen, int screenNo, const QRect &rect)
static QColormap instance(int screen=-1)
QRect maxWindowRect(const QScreen *screen) const
QByteArray fontName
Definition: qwsevent_qws.h:441
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
unsigned int QRgb
Definition: qrgb.h:53
static QWidgetList topLevelWidgets()
The QKeyEvent class describes a key event.
Definition: qevent.h:224
QWidget * focusWidget() const
Returns the last child of this widget that setFocus had been called on.
Definition: qwidget.cpp:6863
unsigned long WId
Definition: qwindowdefs.h:119
static const char * appBGCol
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
The QProxyScreen class provides a generic interface to QScreen implementations.
int type
Definition: qmetatype.cpp:239
static void beep()
Sounds the bell, using the default volume and sound.
static bool popupGrabOk
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Returns the value for setting key.
Definition: qsettings.cpp:3460
int height() const
Returns the logical height of the framebuffer in pixels.
Definition: qscreen_qws.h:228
#define disabled
void setArgs(int, char **)
int y() const
static bool translateIMQueryEvent(QWidget *w, const QWSIMQueryEvent *e)
QApplication::Type qt_appType
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
void registerChannel(const QString &channel)
unsigned char c[8]
Definition: qnumeric_p.h:62
struct QWSRegionMoveCommand::SimpleData simpleData
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
QString cap(int nth=0) const
Returns the text captured by the nth subexpression.
Definition: qregexp.cpp:4310
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void setScreen(QScreen *screen)
Sets the real screen to be used by the proxy screen.
void removeProperty(int winId, int property)
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
void setData(const char *d, int len, bool allocateMem=true)
EventRef event
int lastIndexIn(const QString &str, int offset=-1, CaretMode caretMode=CaretAtZero) const
Attempts to find a match backwards in str from position offset.
Definition: qregexp.cpp:4167
QPointer< QWidget > widget
virtual int sharedRamSize(void *)
Definition: qscreen_qws.h:215
void setOpacity(int winId, int opacity)
void qws_setScreenTransformation(QScreen *, int)
QRect frameStrut
Definition: qwidget_p.h:180
void selectCursor(QWidget *w, unsigned int id)
static void setTransformation(int transformation, int screenNo=-1)
QCursor cursor() const
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
static void setStyle(QStyle *)
Sets the application&#39;s GUI style to style.
void setAltitude(int winId, int altitude, bool fixed=false)
static QWSServer * instance()
QAuthDevice * authBuf(QTransportAuth::Data *, QIODevice *)
Return a QIODevice pointer (to an internal QBuffer) which can be used to write data onto...
void setCursorPosition(int x, int y)
static void qt_set_qws_resources()
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
static bool fade_tooltip
static QLock * lock
static QWSDisplay * qwsDisplay()
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition: qstring.cpp:6090
void unlock()
Unlocks the lock.
void refresh()
Refreshes the display by making the screen driver update the entire display.
static QWSCommand * factory(int type)
const int qwsSharedRamSize
#define it(className, varName)
void setChannel(const QString &n)
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
void repaintRegion(int winId, int windowFlags, bool opaque, QRegion)
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
bool fromString(const QString &)
Sets this font to match the description descrip.
Definition: qfont.cpp:2367
QList< QWidget * > QWidgetList
Definition: qwindowdefs.h:89
The QWheelEvent class contains parameters that describe a wheel event.
Definition: qevent.h:139
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition: qevent.h:396
The QSettings class provides persistent platform-independent application settings.
Definition: qsettings.h:73
void sendIMResponse(int winId, int property, const QVariant &result)
void endGroup()
Resets the group to what it was before the corresponding beginGroup() call.
Definition: qsettings.cpp:3089
bool isVisible() const
Definition: qwidget.h:1005
static void initializeWidgetPaletteHash()
QTransportAuth::Data * connectTransport(unsigned char, int)
Record a new transport connection with properties and descriptor.
struct QWSPositionCursorCommand::SimpleData simpleData
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
static bool read_bool_env_var(const char *var, bool defaultvalue)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
bool qws_shared_memory
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
bool hasPendingRegionEvents() const
QWSMouseEvent * asMouse()
Definition: qwsevent_qws.h:90
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
void setData(const char *d, int len, bool allocateMem=true)
#define SLOT(a)
Definition: qobjectdefs.h:226
QCursor * curs
Definition: qwidget_p.h:254
void setFileName(const QString &n)
void copyFrom(const QWSProtocolItem *item)
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition: qwidget.h:187
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static void addLibraryPath(const QString &)
Prepends path to the beginning of the library path list, ensuring that it is searched for libraries f...
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object&#39;s name property to value.
Definition: qobject.cpp:3755
void qt_init_display()
void beginGroup(const QString &prefix)
Appends prefix to the current group.
Definition: qsettings.cpp:3073
void sendIMUpdate(int type, int winId, int widgetid)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
QRect frameGeometry
geometry of the widget relative to its parent including any window frame
Definition: qwidget.h:159
static int wheel_scroll_lines
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
Pass-through QIODevice sub-class for authentication.
void workAreaResized(int)
void qt_directpainter_region(QDirectPainter *dp, const QRegion &alloc, int type)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
void write(QIODevice *s)
int qws_read_uint(QIODevice *socket)
Definition: qwsutils_qws.h:73
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
#define XValue
static bool testAttribute(uint flag)
static TransformFunc getTransformationFunction()
int & ry()
Returns a reference to the y coordinate of this point.
Definition: qpoint.h:143
void insert(int i, const T &t)
Inserts value at index position i in the list.
Definition: qlist.h:575
int window()
Definition: qwsevent_qws.h:92
static QWidget * active_window
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
struct QWSRequestFocusCommand::SimpleData simpleData
Q_GUI_EXPORT QScreen * qt_get_screen(int display_id, const char *spec)
static void cleanup()
Internal function that cleans up the font system.
Definition: qfont_mac.cpp:93
static QApplicationPrivate * instance()
int msec() const
Returns the millisecond part (0 to 999) of the time.
Definition: qdatetime.cpp:1611
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
static bool qws_single_process
static QStyle * style()
Returns the application&#39;s style object.
bool qws_accel
static short mouseXPos
void closePopup(QWidget *popup)
void * resolve(const char *symbol)
Returns the address of the exported symbol symbol.
Definition: qlibrary.cpp:1155
static int cursorFlashTime()
QString appName() const
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
void Q_GUI_EXPORT qt_app_reinit(const QString &newAppName)
ushort red
Returns the red color component of this color.
Definition: qcolor.h:243
static const char * mwTitle
bool isActiveWindow() const
static QWidget * popupOfPopupButtonFocus
bool eventPending() const
The QDirectPainter class provides direct access to the underlying hardware in Qt for Embedded Linux...
The QString class provides a Unicode character string.
Definition: qstring.h:83
QClipboard * qt_clipboard
static bool animate_ui
struct QWSIMMouseCommand::SimpleData simpleData
void updateWindowRegions() const
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
struct QWSSetPropertyCommand::SimpleData simpleData
#define Q_D(Class)
Definition: qglobal.h:2482
int x
the x coordinate of the widget relative to its parent including any window frame
Definition: qwidget.h:161
struct QWSMouseEvent::SimpleData simpleData
void(* TransformFunc)(QScreen *, int)
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
int qwsProcessEvent(QWSEvent *)
int height() const
static int wheelScrollLines()
static const uint base
Definition: qurl.cpp:268
static QWSLock * clientLock
struct QWSSetSelectionOwnerCommand::SimpleData simpleData
struct QWSEmbedEvent::SimpleData simpleData
static bool waitClient(QWSLock::LockType, int timeout=-1)
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QWidget * focusProxy() const
Returns the focus proxy, or 0 if there is no focus proxy.
Definition: qwidget.cpp:6561
static QFont * sys_font
QStringList keys
static int qws_connection_timeout
QIcon windowIcon
the widget&#39;s icon
Definition: qwidget.h:199
QWSQCopMessageEvent * waitForQCopResponse()
void destroyRegion(int winId)
void showNormal()
Restores the widget after it has been maximized or minimized.
Definition: qwidget.cpp:3250
void setId(const QString &i, int lock)
static void closedown()
Q_CORE_EXPORT QTextStream & dec(QTextStream &s)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
iterator Iterator
Qt-style synonym for QList::iterator.
Definition: qlist.h:278
bool translateKeyEvent(const QWSKeyEvent *, bool grab)
static const char * appFGCol
void getHsv(int *h, int *s, int *v, int *a=0) const
Sets the contents pointed to by h, s, v, and a, to the hue, saturation, value, and alpha-channel (tra...
Definition: qcolor.cpp:679
static void processEventQueue()
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
Q_GUI_EXPORT_INLINE int qRed(QRgb rgb)
Definition: qrgb.h:57
static QWidget * focus_widget
static QFontCache * instance()
Definition: qfont.cpp:2919
#define Q_Q(Class)
Definition: qglobal.h:2483
static int mouseButtonPressTime
QList< QWSCommand * > * qt_get_server_queue()
static bool initLock(const QString &filename, bool create=false)
static QFont font()
Returns the default application font.
static void sendLocally(const QString &ch, const QString &msg, const QByteArray &data)
Client side: distribute received event to the QCop instance managing the channel. ...
The QDecoration class is a base class for window decorations in Qt for Embedded Linux.
Q_CORE_EXPORT QTextStream & fixed(QTextStream &s)
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
static int mouse_y_root
The QWSEvent class encapsulates an event in Qt for Embedded Linux.
Definition: qwsevent_qws.h:59
struct QWSRegionDestroyCommand::SimpleData simpleData
struct QWSSetOpacityCommand::SimpleData simpleData
void setData(const char *d, int len, bool allocateMem=true)
static QStringList keys()
Returns the list of valid keys, i.e., the available decorations.
QWidgetList * qt_modal_stack
int * qt_last_y
void setFontName(const QByteArray &name)
void waitForRegionAck(int winId)
void sendCommand(QWSCommand &cmd)
#define QT_VFB_DATADIR(DISPLAY)
Definition: qvfbhdr.h:74
bool qws_sw_cursor
static int keyboard_input_time
Q_CORE_EXPORT void qDebug(const char *,...)
The QWSWindow class encapsulates a top-level window in Qt for Embedded Linux.
static QWidget * widgetAt(const QPoint &p)
Returns the widget at global screen position point, or 0 if there is no Qt widget there...
static void setRawMouseEventFilter(void(*filter)(QWSMouseEvent *))
struct QWSQCopMessageEvent::SimpleData simpleData
virtual void disconnect()=0
This function is called by every Qt for Embedded Linux application before exiting, and must be implemented to unmap the framebuffer.
struct QWSChangeAltitudeCommand::SimpleData simpleData
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
#define SIGNAL(a)
Definition: qobjectdefs.h:227
virtual QRegion region() const
Returns the region covered by this screen driver.
Definition: qscreen_qws.h:284
#define QT_RETHROW
Definition: qglobal.h:1539
unsigned char uchar
Definition: qglobal.h:994
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:55
int width() const
Returns the logical width of the framebuffer in pixels.
Definition: qscreen_qws.h:227
void setWindowTitle(const QString &)
Definition: qwidget.cpp:6312
NSWindow * window
int width() const
Returns the width.
Definition: qsize.h:126
void sendIMMouseEvent(int index, bool isPress)
static QWidget * activeModalWidget()
Returns the active modal widget.
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
Definition: qvariant.cpp:2259
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static int parseGeometry(const char *string, int *x, int *y, int *width, int *height)
static void setSystemFont(const QFont &font)
void setName(const QString &n, const QString &c)
void requestRegion(int winId, const QString &surfacekey, const QByteArray &surfaceData, const QRegion &region)
The QTime class provides clock time functions.
Definition: qdatetime.h:148
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void removeEngineForFont(const QByteArray &fontName)
Definition: qfont.cpp:3025
QWidgetPrivate * d_func()
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
static void init_display()
static bool isEmpty(const char *str)
void setMessage(const QString &c, const QString &m, const QByteArray &data)
struct QWSKeyEvent::SimpleData simpleData
static QWidget * mouseGrabber()
Returns the widget that is currently grabbing the mouse input.
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void raise()
Raises this widget to the top of the parent widget&#39;s stack.
Definition: qwidget.cpp:11901
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
static void initialize()
Internal function that initializes the font system.
Definition: qfont_mac.cpp:131
#define qApp
static bool init
int width() const
void repaintDecoration(QRegion r, bool post)
bool translateWheelEvent(const QWSMouseEvent *me)
struct QWSPropertyNotifyEvent::SimpleData simpleData
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
virtual bool initDevice()=0
This function is called by the Qt for Embedded Linux server to initialize the framebuffer.
static int mouse_x_root
QWidget * childAt(int x, int y) const
Returns the visible child widget at the position ({x}, {y}) in the widget&#39;s coordinate system...
Definition: qwidget.h:934
static QWidgetList * popupWidgets
static const char * mwGeometry
const T value(const Key &key) const
Returns the value associated with the key key.
Definition: qmap.h:499
struct QWSFontEvent::SimpleData simpleData
static void insertSubstitutions(const QString &, const QStringList &)
Inserts the list of families substituteNames into the substitution list for familyName.
Definition: qfont.cpp:2175
void destroyCursor(int id)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
void translateEmbedEvent(const QWSEmbedEvent *event)
void setTransformation(int screen, int transformation)
static int ReadInteger(char *string, char **NextString)
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
The QLock class is a wrapper for a system shared semaphore.
Definition: qlock_p.h:62
static QWidget * find(WId)
Returns a pointer to the widget with window identifer/handle id.
Definition: qwidget.cpp:2517
void grabMouse(QWidget *w, bool grab)
static void clear()
Removes all pixmaps from the cache.
#define QT_PREPEND_NAMESPACE(name)
This macro qualifies identifier with the full namespace.
Definition: qglobal.h:87
void * unused
Definition: qobject_p.h:208
QWidget * qt_button_down
static bool sendSpontaneousEvent(QObject *receiver, QEvent *event)
static int mouse_double_click_time
void waitForRegionEvents(int winId, bool ungrabDisplay)
WId qt_last_cursor
Q_CORE_EXPORT void qWarning(const char *,...)
int & rx()
Returns a reference to the x coordinate of this point.
Definition: qpoint.h:140
int second() const
Returns the second part (0 to 59) of the time.
Definition: qdatetime.cpp:1600
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
void setResult(const QVariant &v)
bool contains(const QPoint &p) const
Returns true if the region contains the point p; otherwise returns false.
Definition: qregion.cpp:4104
static const char * data(const QByteArray &arr)
QByteArray qws_display_spec(":0")
static void setKeyboardInputInterval(int)
struct QWSSelectCursorCommand::SimpleData simpleData
#define YNegative
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
void convertSelection(int winId, int selectionProperty, const QString &mimeTypes)
static QTextCodec * codec(MYSQL *mysql)
Definition: qsql_mysql.cpp:220
static QScreen * instance()
Returns a pointer to the application&#39;s QScreen instance.
Definition: qscreen_qws.h:201
static bool animate_combo
static void alert(QWidget *widget, int duration=0)
QWindowSurface * windowSurface() const
Returns the QWindowSurface this widget will be drawn into.
Definition: qwidget.cpp:12819
bool qws_savefonts
static bool lockClient(QWSLock::LockType, int timeout=-1)
int width() const
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
static int mouse_state
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
static QPalette * sys_pal
void resized(int)
QCursor cursor
the cursor shape for this widget
Definition: qwidget.h:183
Data(QObject *parent, bool singleProcess=false)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
bool close_helper(CloseMode mode)
Definition: qwidget.cpp:8218
void clear()
Removes all items from the list.
Definition: qlist.h:764
struct QWSRegionNameCommand::SimpleData simpleData
UIEffect
Definition: qnamespace.h:1252
int minute() const
Returns the minute part (0 to 59) of the time.
Definition: qdatetime.cpp:1589
QStringList childKeys() const
Returns a list of all top-level keys that can be read using the QSettings object. ...
Definition: qsettings.cpp:3264
static void grab()
void setCoords(int x1, int y1, int x2, int y2)
Sets the coordinates of the rectangle&#39;s top-left corner to (x1, y1), and the coordinates of its botto...
Definition: qrect.h:416
int height() const
void qt_applyFontDatabaseSettings(const QSettings &settings)
void show()
Shows the widget and its child widgets.
static void startup(int flags)
static QWSLock * getClientLock()
void qt_cleanup()
QRect * rectangles
Definition: qwsevent_qws.h:265
void setIdentity(const QString &appName)
#define QT_CATCH(A)
Definition: qglobal.h:1537
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
struct QWSScreenTransformationEvent::SimpleData simpleData
QWSWindow * windowAt(const QPoint &pos)
Returns the window containing the given position.
Q_GUI_EXPORT_INLINE int qBlue(QRgb rgb)
Definition: qrgb.h:63
static QWidgetList topLevelWidgets()
Returns a list of the top-level widgets (windows) in the application.
static QWidget * topLevelAt(const QPoint &p)
Returns the top-level widget at the given point; returns 0 if there is no such widget.
static QWidget * popupButtonFocus
QRect rect() const
QRegion mask() const
Returns the mask currently set on a widget.
Definition: qwidget.cpp:10058
void showMinimized()
Shows the widget minimized, as an icon.
Definition: qwidget.cpp:3038
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
Q_GUI_EXPORT QWSDisplay * qt_fbdpy
QList< QWSWindowInfo > windowList()
bool isEnabled() const
Definition: qwidget.h:948
virtual void setVisible(bool visible)
Definition: qwidget.cpp:7991
void qt_init(QApplicationPrivate *priv, int type)
void hide()
Hides the widget.
Definition: qwidget.h:501
QT_DEPRECATED int numColors() const
Definition: qpaintdevice.h:100
static short mouseYPos
bool isMaximized() const
Definition: qwidget.cpp:3074
static bool startingUp()
Returns true if an application object has not been created yet; otherwise returns false...
static void enterModal_sys(QWidget *)
static bool translateIMEvent(QWidget *w, const QWSIMEvent *e)
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
#define QTE_PIPE(DISPLAY)
Definition: qvfbhdr.h:84
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
static QList< QWSEvent * > incoming
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
static QDecoration * create(const QString &)
static bool animate_tooltip
QWSEvent * getEvent()
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
void qt_server_enqueue(const QWSCommand *command)
static void setColorSpec(int)
Sets the color specification for the application to spec.
uchar * base() const
Returns a pointer to the beginning of the framebuffer.
Definition: qscreen_qws.h:235
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
static bool tryModalHelper(QWidget *widget, QWidget **rettop=0)
int depth() const
static QAuServer & server()
Definition: qsound.cpp:79
void setData(const char *d, int len, bool allocateMem=true)
Q_CORE_EXPORT void qFatal(const char *,...)
static int read_int_env_var(const char *var, int defaultvalue)
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
static Qt::KeyboardModifiers queryKeyboardModifiers()
Queries and returns the state of the modifier keys on the keyboard.
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static void setCursorFlashTime(int)
static bool isEffectEnabled(Qt::UIEffect)
Returns true if effect is enabled; otherwise returns false.
int winId() const
Returns the window&#39;s ID.
static Qt::MouseButtons mouseButtonState
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
Definition: qimage.cpp:3966
QPoint mapFromParent(const QPoint &) const
Translates the parent widget coordinate pos to widget coordinates.
Definition: qwidget.cpp:4473
uchar * sharedRam() const
static QWidget * activePopupWidget()
Returns the active popup widget.
void setRects(const QRect *rect, int num)
Sets the region using the array of rectangles specified by rects and number.
Definition: qregion.cpp:4424
QString & append(QChar c)
Definition: qstring.cpp:1777
ushort blue
Returns the blue color component of this color.
Definition: qcolor.h:245
void qt_directpainter_embedevent(QDirectPainter *dp, const QWSEmbedEvent *e)
char * getPropertyData
int x() const
bool qws_overrideCursor
The QWSServer class encapsulates a server process in Qt for Embedded Linux.
virtual int memoryNeeded(const QString &)
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
static bool sm_blockUserInput
static QAbstractEventDispatcher * eventDispatcher
static QInputContext * inputContext
void setSelectionOwner(int winId, const QTime &time)
#define S_ISDIR(x)
Definition: qzip.cpp:63
#define QWS_PROTOCOL_ITEM_SIZE(item)
void setClipRegion(const QRegion &)
Sets the region currently visible on the screen to be the given clip region.
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
static QWSEvent * factory(int type)
static QList< QWSCommand * > outgoing
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
virtual bool qwsEventFilter(QWSEvent *)
This virtual function is only implemented under Qt for Embedded Linux.
Q_GUI_EXPORT int qws_display_id
int y
the y coordinate of the widget relative to its parent and including any window frame ...
Definition: qwidget.h:162
struct QWSRegionEvent::SimpleData simpleData
static const int AnyButton
static void unlockClient(QWSLock::LockType)
static QStringList libraryPaths()
Returns a list of paths that the application will search when dynamically loading libraries...
void addProperty(int winId, int property)
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
static bool animate_toolbox
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...
static void initialize()
virtual QList< QScreen * > subScreens() const
Definition: qscreen_qws.h:283
QString qws_dataDir()
struct QWSDefineCursorCommand::SimpleData simpleData
const_iterator ConstIterator
Qt-style synonym for QList::const_iterator.
Definition: qlist.h:279
int sharedRamSize() const
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
static void setWheelScrollLines(int)
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
#define WidthValue
bool isFullScreen() const
Definition: qwidget.cpp:3153
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
#define NoValue
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
static QList< QWSInternalWindowInfo * > * windowList()
static QWidget * keyboardGrabber()
Returns the widget that is currently grabbing the keyboard input.
static bool grabbed()
static bool desktopSettingsAware()
Returns true if Qt is set to use the system&#39;s standard colors, fonts, etc.
int qt_servershmid
static const QMetaObjectPrivate * priv(const uint *data)
bool translateRegionEvent(const QWSRegionEvent *)
static int mouse_double_click_distance
QString objectName() const
const char * property
Definition: qwizard.cpp:138
static QReadWriteLock lock
Definition: proxyconf.cpp:399
void defineCursor(int id, const QBitmap &curs, const QBitmap &mask, int hotX, int hotY)
int height() const
Returns the height.
Definition: qsize.h:129
QMap< const QScreen *, QRect > maxWindowRects
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
Definition: qsize.h:123
void setClient(QObject *)
QFuture< void > filter(Sequence &sequence, FilterFunction filterFunction)
QFactoryLoader * l
void create(int n=1)
static QTextCodec * codecForName(const QByteArray &name)
Searches all installed QTextCodec objects and returns the one which best matches name; the match is c...
virtual bool qwsEvent(QWSEvent *)
This special event handler can be reimplemented in a subclass to receive native Qt for Embedded Linux...
Definition: qwidget.cpp:9993
struct QWSGrabMouseCommand::SimpleData simpleData
The QScreen class is a base class for screen drivers in Qt for Embedded Linux.
Definition: qscreen_qws.h:191
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
void sendSynchronousCommand(QWSCommand &cmd)
static void dispatchEnterLeave(QWidget *enter, QWidget *leave)
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
static void setSystemPalette(const QPalette &pal)
void activateWindow()
Sets the top-level widget containing this widget to be the active window.
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
static void setMaxWindowRect(const QRect &rect)
quint16 index
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
QObject * parent
Definition: qobject.h:92
int depth() const
Definition: qpaintdevice.h:103
Q_GUI_EXPORT_INLINE int qGreen(QRgb rgb)
Definition: qrgb.h:60
static QString styleOverride
Q_CORE_EXPORT bool qputenv(const char *varName, const QByteArray &value)
static const char * appBTNCol
static void setOverrideCursor(const QCursor &)
Use changeOverrideCursor(cursor) (if replace is true) or setOverrideCursor(cursor) (if replace is fal...
T takeLast()
Removes the last item in the list and returns it.
Definition: qlist.h:492
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
static void cleanup()
Definition: qcursor.cpp:402
QWidget * qt_pressGrab
bool getProperty(int winId, int property, char *&data, int &len)
QPointer< QWidget > qt_last_mouse_receiver
void translate(int dx, int dy)
Translates (moves) the region dx along the X axis and dy along the Y axis.
Definition: qregion.cpp:4116
static void initialize()
Definition: qcursor.cpp:417
ClassId classId() const
Returns the class identifier for the screen object.
bool translateMouseEvent(const QWSMouseEvent *, int oldstate)
struct QWSConvertSelectionCommand::SimpleData simpleData
void grabKeyboard(QWidget *w, bool grab)
const QFont & font() const
The QClipboardEvent class provides the parameters used in a clipboard event.
Definition: qevent.h:695
static const char * appFont
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
uchar * frameBuffer() const
int * qt_last_x
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
Authenticate a message transport.
bool qt_is_gui_used
QWExtra * extraData() const
Definition: qwidget_p.h:999
static void setDoubleClickInterval(int)
bool close()
Closes this widget.
Definition: qwidget.cpp:8305
static QWSDisplay * instance()
void playSoundFile(const QString &)
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
Q_GUI_EXPORT QString qws_qtePipeFilename()
static bool popupCloseDownMode
bool supportsDepth(int) const
struct QWSFontCommand::SimpleData simpleData
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
#define HeightValue
int id() const
Definition: qwslock_p.h:78
virtual void set(unsigned int, unsigned int, unsigned int, unsigned int)
QScreen * screen() const
Returns the real screen used by the proxy screen.
void qwsSetCustomColors(QRgb *colortable, int start, int numColors)
Set Qt for Embedded Linux custom color table.
Q_GUI_EXPORT QScreenCursor * qt_screencursor
Definition: qscreen_qws.cpp:67
static int mouseButtonPressed
void setProperty(int winId, int property, int mode, const QByteArray &data)
static void restoreOverrideCursor()
Undoes the last setOverrideCursor().
struct QWSGrabKeyboardCommand::SimpleData simpleData
static void ungrab()
Q_GUI_EXPORT int qws_client_id
virtual bool supportsDepth(int) const
Returns true if the screen supports the specified color depth; otherwise returns false.
The QTextCodec class provides conversions between text encodings.
Definition: qtextcodec.h:62
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
Definition: qcolor.h:298
const QRect & geometry() const
char at(int i) const
Returns the character at index position i in the byte array.
Definition: qbytearray.h:413
unsigned int clientid
static bool app_do_modal
static void leaveModal_sys(QWidget *)
static void setFont(const QFont &, const char *className=0)
Changes the default application font to font.
struct QWSRemovePropertyCommand::SimpleData simpleData
static QPointer< QWidget > * mouseInWidget
Orientation
Definition: qnamespace.h:174
void requestFocus(int winId, bool get)
static bool qt_try_modal(QWidget *, QWSEvent *)
static bool translateIMInitEvent(const QWSIMInitEvent *e)
#define qPrintable(string)
Definition: qglobal.h:1750
static int doubleClickInterval()
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
ushort green
Returns the green color component of this color.
Definition: qcolor.h:244
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319
void qt_client_enqueue(const QWSEvent *event)
virtual int pixmapDepth() const
Returns the preferred depth for pixmaps, in bits per pixel.
void setScreenTransformation(QScreen *screen, int screenNo, int transformation)
struct QWSCreationEvent::SimpleData simpleData
#define QT_TRY
Definition: qglobal.h:1536
int windowAt(const QPoint &)
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
struct QWSGetPropertyCommand::SimpleData simpleData
QWidget * window() const
Returns a pointer to the top-level window associated with this surface.
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275
struct QWSIMUpdateCommand::SimpleData simpleData
static void setGlobalStrut(const QSize &)
static void setCodecForTr(QTextCodec *c)
Definition: qtextcodec.h:156
friend class QWSManager
Definition: qwidget.h:786
static void setEffectEnabled(Qt::UIEffect, bool enable=true)
Enables the UI effect effect if enable is true, otherwise the effect will not be used.
static void cleanup()
void openPopup(QWidget *popup)
static bool animate_menu
Q_CORE_EXPORT void qCritical(const char *,...)
void move(int x, int y)
This corresponds to move(QPoint(x, y)).
Definition: qwidget.h:1011
QWSServer Q_GUI_EXPORT * qwsServer
#define text
Definition: qobjectdefs.h:80
void sendMessage(const QString &channel, const QString &msg, const QByteArray &data)
int depth() const
Returns the depth of the framebuffer, in bits per pixel.
Definition: qscreen_qws.h:229
static QTransportAuth * getInstance()
Return a pointer to the instance of this process&#39;s QTransportAuth object.
void setWindowCaption(QWidget *w, const QString &)
int hour() const
Returns the hour part (0 to 23) of the time.
Definition: qdatetime.cpp:1578
int errno
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
static Qt::KeyboardModifiers oldstate
Definition: qdnd_qws.cpp:87
void setMouseFilter(void(*filter)(QWSMouseEvent *))
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272
static int cursor_flash_time
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
#define XNegative
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770
#define QT_VERSION
This macro expands a numeric value of the form 0xMMNNPP (MM = major, NN = minor, PP = patch) that spe...
Definition: qglobal.h:51
MouseButton
Definition: qnamespace.h:150
static void reregisterAll()
QDesktopWidget * qt_desktopWidget
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61