Qt 4.8
Public Functions | Static Public Functions | Public Variables | Static Public Variables | Private Types | Properties | List of all members
QWSDisplay::Data Class Reference

#include <qwsdisplay_qws_p.h>

Public Functions

void connectToPipe ()
 
void create (int n=1)
 
 Data (QObject *parent, bool singleProcess=false)
 
QWSEventdequeue ()
 
bool directServerConnection ()
 
void fillQueue ()
 
void flush ()
 
void flushCommands ()
 
bool hasPendingRegionEvents () const
 
void init ()
 
QWSEventpeek ()
 
bool queueNotEmpty ()
 
QWSEventreadMore ()
 
void reinit (const QString &newAppName)
 
void sendCommand (QWSCommand &cmd)
 
void sendSynchronousCommand (QWSCommand &cmd)
 
void setMouseFilter (void(*filter)(QWSMouseEvent *))
 
int takeId ()
 
void waitForConnection ()
 
void waitForCreation ()
 
void waitForPropertyReply ()
 
void waitForQCopResponse ()
 
void waitForRegionAck (int winId)
 
void waitForRegionEvents (int winId, bool ungrabDisplay)
 
 ~Data ()
 

Static Public Functions

static QWSLockgetClientLock ()
 
static bool lockClient (QWSLock::LockType, int timeout=-1)
 
static void unlockClient (QWSLock::LockType)
 
static bool waitClient (QWSLock::LockType, int timeout=-1)
 

Public Variables

ucharsharedRam
 
int sharedRamSize
 
QWSSharedMemory shm
 

Static Public Variables

static QWSLockclientLock = 0
 

Private Types

enum  { VariableEvent =-1 }
 

Properties

QWSConnectedEventconnected_event
 
QWSSocketcsocket
 
QWSEventcurrent_event
 
QWSMouseEventmouse_event
 
int mouse_state
 
int mouse_winid
 
void(* mouseFilter )(QWSMouseEvent *)
 
QWSQCopMessageEventqcop_response
 
QList< QWSEvent * > queue
 
int region_events_count
 
QPoint region_offset
 
int region_offset_window
 
QList< int > unused_identifiers
 

Detailed Description

Definition at line 65 of file qwsdisplay_qws_p.h.

Enumerations

◆ anonymous enum

anonymous enum
private
Enumerator
VariableEvent 

Definition at line 155 of file qwsdisplay_qws_p.h.

Constructors and Destructors

◆ Data()

QWSDisplay::Data::Data ( QObject parent,
bool  singleProcess = false 
)

Definition at line 498 of file qapplication_qws.cpp.

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 }
#define SLOT(a)
Definition: qobjectdefs.h:226
static QWSLock * clientLock
#define SIGNAL(a)
Definition: qobjectdefs.h:227
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
#define qApp
#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

◆ ~Data()

QWSDisplay::Data::~Data ( )

Definition at line 516 of file qapplication_qws.cpp.

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 }
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
QWSEvent * current_event
static QWSLock * clientLock
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.
QList< QWSEvent * > queue
QWSMouseEvent * mouse_event
QWSQCopMessageEvent * qcop_response
Q_GUI_EXPORT QScreenCursor * qt_screencursor
Definition: qscreen_qws.cpp:67
QWSSharedMemory shm
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319
QWSConnectedEvent * connected_event

Functions

◆ connectToPipe()

void QWSDisplay::Data::connectToPipe ( )

Definition at line 1090 of file qapplication_qws.cpp.

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 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static int qws_connection_timeout
Q_CORE_EXPORT void qWarning(const char *,...)
bool connectToLocalFile(const QString &file)
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...
Q_GUI_EXPORT QString qws_qtePipeFilename()

◆ create()

void QWSDisplay::Data::create ( int  n = 1)

Definition at line 622 of file qapplication_qws.cpp.

623 {
624  QWSCreateCommand cmd(n);
625  sendCommand(cmd);
626 }
void sendCommand(QWSCommand &cmd)

◆ dequeue()

QWSEvent * QWSDisplay::Data::dequeue ( )

Definition at line 590 of file qapplication_qws.cpp.

Referenced by QWSDisplay::waitForQCopResponse().

591 {
592  QWSEvent *r=0;
593  if (queue.count()) {
594  r = queue.first();
595  queue.removeFirst();
596  if (r->type == QWSEvent::Region)
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 }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QWSEvent class encapsulates an event in Qt for Embedded Linux.
Definition: qwsevent_qws.h:59
void removeFirst()
Removes the first item in the list.
Definition: qlist.h:286
QList< QWSEvent * > queue
QWSMouseEvent * mouse_event
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282

◆ directServerConnection()

bool QWSDisplay::Data::directServerConnection ( )

Definition at line 613 of file qapplication_qws.cpp.

614 {
615 #ifndef QT_NO_QWS_MULTIPROCESS
616  return csocket == 0;
617 #else
618  return true;
619 #endif
620 }

◆ fillQueue()

void QWSDisplay::Data::fillQueue ( )

Definition at line 973 of file qapplication_qws.cpp.

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)
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
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 }
struct QWSPropertyReplyEvent::SimpleData simpleData
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
static QWSDisplay * qwsDisplay()
QList< int > unused_identifiers
int window()
Definition: qwsevent_qws.h:92
void(* mouseFilter)(QWSMouseEvent *)
struct QWSMouseEvent::SimpleData simpleData
static QWSLock * clientLock
static void processEventQueue()
void unlock(LockType type)
Definition: qwslock.cpp:250
The QWSEvent class encapsulates an event in Qt for Embedded Linux.
Definition: qwsevent_qws.h:59
Q_CORE_EXPORT void qDebug(const char *,...)
struct QWSQCopMessageEvent::SimpleData simpleData
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static const char * data(const QByteArray &arr)
QList< QWSEvent * > queue
struct QWSScreenTransformationEvent::SimpleData simpleData
QWSMouseEvent * mouse_event
char * getPropertyData
#define QWS_PROTOCOL_ITEM_SIZE(item)
static void setMaxWindowRect(const QRect &rect)
QWSQCopMessageEvent * qcop_response
struct QWSCreationEvent::SimpleData simpleData
QWSConnectedEvent * connected_event
static void setScreenTransformation(int screenNo, int transformation)

◆ flush()

void QWSDisplay::Data::flush ( )

Definition at line 567 of file qapplication_qws.cpp.

568 {
569 #ifndef QT_NO_QWS_MULTIPROCESS
570  if (csocket) {
571  csocket->waitForReadyRead(0);
572  csocket->flush();
573  }
574 #endif
575 }

◆ flushCommands()

void QWSDisplay::Data::flushCommands ( )

Definition at line 628 of file qapplication_qws.cpp.

Referenced by QWSDisplay::flushCommands().

629 {
630 #ifndef QT_NO_QWS_MULTIPROCESS
631  if (csocket)
632  csocket->flush();
633 #endif
634 }

◆ getClientLock()

QWSLock * QWSDisplay::Data::getClientLock ( )
static

Definition at line 561 of file qapplication_qws.cpp.

Referenced by QWSMemorySurface::QWSMemorySurface(), QWSMemorySurface::setLock(), and QWSMemorySurface::~QWSMemorySurface().

562 {
563  return clientLock;
564 }
static QWSLock * clientLock

◆ hasPendingRegionEvents()

bool QWSDisplay::Data::hasPendingRegionEvents ( ) const

Definition at line 1225 of file qapplication_qws.cpp.

Referenced by QWSDirectPainterSurface::hasPendingRegionEvents().

1226 {
1228  return true;
1229 
1230  return region_events_count > 0;
1231 }
static QWSLock * clientLock
bool hasLock(LockType type)
Definition: qwslock.cpp:242

◆ init()

void QWSDisplay::Data::init ( )

Definition at line 799 of file qapplication_qws.cpp.

800 {
801  connected_event = 0;
803 // region_ack = 0;
804  mouse_event = 0;
805  mouse_state = -1;
806  mouse_winid = 0;
807 // region_event = 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 
821 
822 #ifndef QT_NO_QWS_MULTIPROCESS
823  if (csocket) {
824  // QWS client
825 
826  connectToPipe();
827 
829 
830  QWSIdentifyCommand cmd;
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
847 
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) == ':')
854 
855  if (!QWSDisplay::initLock(pipe, false))
856  qFatal("Cannot get display lock");
857 
859  sharedRam = static_cast<uchar *>(shm.address());
861  if (s)
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)
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()
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 }
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
bool create(int size)
virtual int sharedRamSize(void *)
Definition: qscreen_qws.h:215
QAuthDevice * authBuf(QTransportAuth::Data *, QIODevice *)
Return a QIODevice pointer (to an internal QBuffer) which can be used to write data onto...
const int qwsSharedRamSize
QTransportAuth::Data * connectTransport(unsigned char, int)
Record a new transport connection with properties and descriptor.
void * address() const
Pass-through QIODevice sub-class for authentication.
void write(QIODevice *s)
void(* mouseFilter)(QWSMouseEvent *)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
Q_GUI_EXPORT QScreen * qt_get_screen(int display_id, const char *spec)
static QString appName
long ASN1_INTEGER_get ASN1_INTEGER * a
The QString class provides a Unicode character string.
Definition: qstring.h:83
QWSEvent * current_event
static QWSLock * clientLock
void setId(const QString &i, int lock)
static bool initLock(const QString &filename, bool create=false)
int * qt_last_y
unsigned char uchar
Definition: qglobal.h:994
virtual bool initDevice()=0
This function is called by the Qt for Embedded Linux server to initialize the framebuffer.
QByteArray qws_display_spec(":0")
bool attach(int id)
QWSMouseEvent * mouse_event
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
void qt_server_enqueue(const QWSCommand *command)
Q_CORE_EXPORT void qFatal(const char *,...)
virtual int memoryNeeded(const QString &)
Q_GUI_EXPORT int qws_display_id
int qt_servershmid
if(void) toggleToolbarShown
void setClient(QObject *)
void create(int n=1)
The QScreen class is a base class for screen drivers in Qt for Embedded Linux.
Definition: qscreen_qws.h:191
QWSQCopMessageEvent * qcop_response
int * qt_last_x
Authenticate a message transport.
Q_GUI_EXPORT QString qws_qtePipeFilename()
Q_GUI_EXPORT int qws_client_id
char at(int i) const
Returns the character at index position i in the byte array.
Definition: qbytearray.h:413
QWSSharedMemory shm
static QTransportAuth * getInstance()
Return a pointer to the instance of this process&#39;s QTransportAuth object.
QWSConnectedEvent * connected_event
struct QWSConnectedEvent::SimpleData simpleData

◆ lockClient()

bool QWSDisplay::Data::lockClient ( QWSLock::LockType  type,
int  timeout = -1 
)
static

Definition at line 546 of file qapplication_qws.cpp.

547 {
548  return !clientLock || clientLock->lock(type, timeout);
549 }
int type
Definition: qmetatype.cpp:239
static QWSLock * clientLock
bool lock(LockType type, int timeout=-1)
Definition: qwslock.cpp:224

◆ peek()

QWSEvent * QWSDisplay::Data::peek ( )

Definition at line 608 of file qapplication_qws.cpp.

609 {
610  return queue.first();
611 }
QList< QWSEvent * > queue
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282

◆ queueNotEmpty()

bool QWSDisplay::Data::queueNotEmpty ( )

Definition at line 586 of file qapplication_qws.cpp.

587 {
588  return mouse_event/*||region_event*/||queue.count() > 0;
589 }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QList< QWSEvent * > queue
QWSMouseEvent * mouse_event

◆ readMore()

QWSEvent * QWSDisplay::Data::readMore ( )

Definition at line 943 of file qapplication_qws.cpp.

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 }
int qws_read_uint(QIODevice *socket)
Definition: qwsutils_qws.h:73
QWSEvent * current_event
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
The QWSEvent class encapsulates an event in Qt for Embedded Linux.
Definition: qwsevent_qws.h:59
bool read(QIODevice *s)
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
static QList< QWSEvent * > incoming
static QWSEvent * factory(int type)

◆ reinit()

void QWSDisplay::Data::reinit ( const QString newAppName)

Definition at line 700 of file qapplication_qws.cpp.

Referenced by qt_app_reinit().

701 {
702  Q_ASSERT(csocket);
703 
704  delete connected_event;
705  connected_event = 0;
707 // region_ack = 0;
708  delete mouse_event;
709  mouse_event = 0;
710 // region_event = 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;
726 
727  QString pipe = qws_qtePipeFilename();
728 
729  // QWS client
730  // Cleanup all cached ids
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()));
741 
743 
744  QWSIdentifyCommand cmd;
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
763 
765 
766  if (!QWSDisplay::initLock(pipe, false))
767  qFatal("Cannot get display lock");
768 
770  sharedRam = static_cast<uchar *>(shm.address());
772  if (s)
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 }
QAuthDevice * authBuf(QTransportAuth::Data *, QIODevice *)
Return a QIODevice pointer (to an internal QBuffer) which can be used to write data onto...
QTransportAuth::Data * connectTransport(unsigned char, int)
Record a new transport connection with properties and descriptor.
void * address() const
#define SLOT(a)
Definition: qobjectdefs.h:226
QList< int > unused_identifiers
Pass-through QIODevice sub-class for authentication.
void write(QIODevice *s)
void(* mouseFilter)(QWSMouseEvent *)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
Q_GUI_EXPORT QScreen * qt_get_screen(int display_id, const char *spec)
static QString appName
long ASN1_INTEGER_get ASN1_INTEGER * a
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QWSEvent * current_event
static QWSLock * clientLock
void setId(const QString &i, int lock)
static bool initLock(const QString &filename, bool create=false)
int * qt_last_y
#define SIGNAL(a)
Definition: qobjectdefs.h:227
unsigned char uchar
Definition: qglobal.h:994
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
#define qApp
bool connectToLocalFile(const QString &file)
QByteArray qws_display_spec(":0")
void clear()
Removes all items from the list.
Definition: qlist.h:764
bool attach(int id)
QWSMouseEvent * mouse_event
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
Q_CORE_EXPORT void qFatal(const char *,...)
virtual int memoryNeeded(const QString &)
Q_GUI_EXPORT int qws_display_id
void setClient(QObject *)
The QScreen class is a base class for screen drivers in Qt for Embedded Linux.
Definition: qscreen_qws.h:191
QWSQCopMessageEvent * qcop_response
int * qt_last_x
Authenticate a message transport.
Q_GUI_EXPORT QString qws_qtePipeFilename()
Q_GUI_EXPORT int qws_client_id
QWSSharedMemory shm
static QTransportAuth * getInstance()
Return a pointer to the instance of this process&#39;s QTransportAuth object.
QWSConnectedEvent * connected_event
struct QWSConnectedEvent::SimpleData simpleData
static void reregisterAll()
QDesktopWidget * qt_desktopWidget

◆ sendCommand()

void QWSDisplay::Data::sendCommand ( QWSCommand cmd)

Definition at line 636 of file qapplication_qws.cpp.

Referenced by QWSDisplay::registerChannel(), QWSEmbedWidgetPrivate::resize(), QWSDisplay::sendMessage(), QScreen::setTransformation(), QWSEmbedWidgetPrivate::updateWindow(), and QWSEmbedWidget::~QWSEmbedWidget().

637 {
638 #ifndef QT_NO_QWS_MULTIPROCESS
639  if (csocket)
640  cmd.write(csocket);
641  else
642 #endif
643  qt_server_enqueue(&cmd);
644 }
void write(QIODevice *s)
void qt_server_enqueue(const QWSCommand *command)

◆ sendSynchronousCommand()

void QWSDisplay::Data::sendSynchronousCommand ( QWSCommand cmd)

Definition at line 646 of file qapplication_qws.cpp.

647 {
648 #ifndef QT_NO_QWS_MULTIPROCESS
649  if (csocket) {
651  cmd.write(csocket);
652  bool ok = true;
653  while (csocket->bytesToWrite() > 0) {
654  if (!csocket->waitForBytesWritten(-1)) {
655  qCritical("QWSDisplay::Data::sendSynchronousCommand: %s",
657  ok = false;
658  break;
659  }
660  }
661  if (ok)
663  } else
664 #endif
665  qt_server_enqueue(&cmd);
666 }
void write(QIODevice *s)
static bool waitClient(QWSLock::LockType, int timeout=-1)
static bool lockClient(QWSLock::LockType, int timeout=-1)
void qt_server_enqueue(const QWSCommand *command)
QString errorString()
#define qPrintable(string)
Definition: qglobal.h:1750
Q_CORE_EXPORT void qCritical(const char *,...)

◆ setMouseFilter()

void QWSDisplay::Data::setMouseFilter ( void(*)(QWSMouseEvent *)  filter)

Definition at line 681 of file qapplication_qws.cpp.

Referenced by QWSDisplay::setRawMouseEventFilter().

682 {
684 }
void(* mouseFilter)(QWSMouseEvent *)
QFuture< void > filter(Sequence &sequence, FilterFunction filterFunction)

◆ takeId()

int QWSDisplay::Data::takeId ( )

Definition at line 668 of file qapplication_qws.cpp.

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 }
QList< int > unused_identifiers
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
void create(int n=1)

◆ unlockClient()

void QWSDisplay::Data::unlockClient ( QWSLock::LockType  type)
static

Definition at line 551 of file qapplication_qws.cpp.

552 {
554 }
int type
Definition: qmetatype.cpp:239
static QWSLock * clientLock
void unlock(LockType type)
Definition: qwslock.cpp:250

◆ waitClient()

bool QWSDisplay::Data::waitClient ( QWSLock::LockType  type,
int  timeout = -1 
)
static

Definition at line 556 of file qapplication_qws.cpp.

557 {
558  return !clientLock || clientLock->wait(type, timeout);
559 }
int type
Definition: qmetatype.cpp:239
bool wait(LockType type, int timeout=-1)
Definition: qwslock.cpp:266
static QWSLock * clientLock

◆ waitForConnection()

void QWSDisplay::Data::waitForConnection ( )

Definition at line 1111 of file qapplication_qws.cpp.

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 }
static int qws_connection_timeout
Q_CORE_EXPORT void qFatal(const char *,...)
QWSConnectedEvent * connected_event

◆ waitForCreation()

void QWSDisplay::Data::waitForCreation ( )

Definition at line 1235 of file qapplication_qws.cpp.

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 }
QList< int > unused_identifiers
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891

◆ waitForPropertyReply()

void QWSDisplay::Data::waitForPropertyReply ( )

Definition at line 1251 of file qapplication_qws.cpp.

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 }
Q_GUI_EXPORT QWSDisplay * qt_fbdpy

◆ waitForQCopResponse()

void QWSDisplay::Data::waitForQCopResponse ( )

Definition at line 1265 of file qapplication_qws.cpp.

Referenced by QWSDisplay::waitForQCopResponse().

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  }
1279  qcop_response = 0;
1280 }
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
QList< QWSEvent * > queue
QWSQCopMessageEvent * qcop_response

◆ waitForRegionAck()

void QWSDisplay::Data::waitForRegionAck ( int  winId)

Definition at line 1128 of file qapplication_qws.cpp.

Referenced by QWSDirectPainterSurface::setRegion().

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;
1172 }
int window()
Definition: qwsevent_qws.h:92
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QWSEvent class encapsulates an event in Qt for Embedded Linux.
Definition: qwsevent_qws.h:59
#define qApp
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< QWSEvent * > queue
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ waitForRegionEvents()

void QWSDisplay::Data::waitForRegionEvents ( int  winId,
bool  ungrabDisplay 
)

Definition at line 1174 of file qapplication_qws.cpp.

Referenced by QWSDirectPainterSurface::beginPaint().

1175 {
1176  if (!clientLock)
1177  return;
1178 
1179  int removedEventsCount = 0;
1180 
1181  // fill queue with unreceived region events
1183  bool ungrabbed = false;
1184  if (ungrabDisplay && QWSDisplay::grabbed()) {
1186  ungrabbed = true;
1187  }
1188 
1189  for (;;) {
1190  fillQueue();
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 }
int window()
Definition: qwsevent_qws.h:92
static QWSLock * clientLock
The QWSEvent class encapsulates an event in Qt for Embedded Linux.
Definition: qwsevent_qws.h:59
bool hasLock(LockType type)
Definition: qwslock.cpp:242
#define qApp
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static void grab()
QList< QWSEvent * > queue
struct QWSRegionEvent::SimpleData simpleData
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
static bool grabbed()
static void ungrab()
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

Properties

◆ clientLock

QWSLock * QWSDisplay::Data::clientLock = 0
static

Definition at line 115 of file qwsdisplay_qws_p.h.

Referenced by reinit(), and setMouseFilter().

◆ connected_event

QWSConnectedEvent* QWSDisplay::Data::connected_event
private

Definition at line 138 of file qwsdisplay_qws_p.h.

◆ csocket

QWSSocket* QWSDisplay::Data::csocket
private

Definition at line 125 of file qwsdisplay_qws_p.h.

◆ current_event

QWSEvent* QWSDisplay::Data::current_event
private

Definition at line 148 of file qwsdisplay_qws_p.h.

◆ mouse_event

QWSMouseEvent* QWSDisplay::Data::mouse_event
private

Definition at line 139 of file qwsdisplay_qws_p.h.

◆ mouse_state

int QWSDisplay::Data::mouse_state
private

Definition at line 141 of file qwsdisplay_qws_p.h.

◆ mouse_winid

int QWSDisplay::Data::mouse_winid
private

Definition at line 142 of file qwsdisplay_qws_p.h.

◆ mouseFilter

void(* QWSDisplay::Data::mouseFilter) (QWSMouseEvent *)
private

Definition at line 153 of file qwsdisplay_qws_p.h.

◆ qcop_response

QWSQCopMessageEvent* QWSDisplay::Data::qcop_response
private

Definition at line 146 of file qwsdisplay_qws_p.h.

◆ queue

QList<QWSEvent*> QWSDisplay::Data::queue
private

Definition at line 127 of file qwsdisplay_qws_p.h.

◆ region_events_count

int QWSDisplay::Data::region_events_count
private

Definition at line 140 of file qwsdisplay_qws_p.h.

◆ region_offset

QPoint QWSDisplay::Data::region_offset
private

Definition at line 143 of file qwsdisplay_qws_p.h.

◆ region_offset_window

int QWSDisplay::Data::region_offset_window
private

Definition at line 144 of file qwsdisplay_qws_p.h.

◆ sharedRam

uchar* QWSDisplay::Data::sharedRam

Definition at line 108 of file qwsdisplay_qws_p.h.

◆ sharedRamSize

int QWSDisplay::Data::sharedRamSize

Definition at line 112 of file qwsdisplay_qws_p.h.

◆ shm

QWSSharedMemory QWSDisplay::Data::shm

Definition at line 110 of file qwsdisplay_qws_p.h.

◆ unused_identifiers

QList<int> QWSDisplay::Data::unused_identifiers
private

Definition at line 149 of file qwsdisplay_qws_p.h.


The documentation for this class was generated from the following files: