#include <qeventdispatcher_x11_p.h>
Inheritance diagram for QEventDispatcherX11:


Definition at line 42 of file qeventdispatcher_x11_p.h.
Public Member Functions | |
| QEventDispatcherX11 (QObject *parent=0) | |
| ~QEventDispatcherX11 () | |
| bool | processEvents (QEventLoop::ProcessEventsFlags flags) |
| bool | hasPendingEvents () |
| void | flush () |
| void | startingUp () |
| void | closingDown () |
Protected Member Functions | |
| int | select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, timeval *timeout) |
| QEventDispatcherX11::QEventDispatcherX11 | ( | QObject * | parent = 0 |
) | [explicit] |
Definition at line 43 of file qeventdispatcher_x11.cpp.
00044 : QEventDispatcherUNIX(*new QEventDispatcherX11Private, parent) 00045 { }
| QEventDispatcherX11::~QEventDispatcherX11 | ( | ) |
| bool QEventDispatcherX11::processEvents | ( | QEventLoop::ProcessEventsFlags | flags | ) | [virtual] |
Processes pending events that match flags until there are no more events to process. Returns true if an event was processed; otherwise returns false.
This function is especially useful if you have a long running operation and want to show its progress without allowing user input; i.e. by using the QEventLoop::ExcludeUserInputEvents flag.
If the QEventLoop::WaitForMoreEvents flag is set in flags, the behavior of this function is as follows:
If events are available, this function returns after processing them.
If no events are available, this function will wait until more are available and return after processing newly available events.
If the QEventLoop::WaitForMoreEvents flag is not set in flags, and no events are available, this function will return immediately.
{Note:} This function does not process events continuously; it returns after all available events are processed.
Reimplemented from QEventDispatcherUNIX.
Definition at line 50 of file qeventdispatcher_x11.cpp.
References ATOM, d, QObject::event(), QEventLoop::ExcludeSocketNotifiers, QEventLoop::ExcludeUserInputEvents, QAbstractEventDispatcher::filterEvent(), marker, QEventDispatcherUNIX::processEvents(), qApp, QCoreApplication::sendPostedEvents(), QEventLoop::WaitForMoreEvents, X11, QEventLoop::X11ExcludeTimers, XKeyPress, and XKeyRelease.
00051 { 00052 Q_D(QEventDispatcherX11); 00053 00054 d->interrupt = false; 00055 QApplication::sendPostedEvents(); 00056 00057 ulong marker = XNextRequest(X11->display); 00058 int nevents = 0; 00059 do { 00060 while (!d->interrupt) { 00061 XEvent event; 00062 if (!(flags & QEventLoop::ExcludeUserInputEvents) 00063 && !d->queuedUserInputEvents.isEmpty()) { 00064 // process a pending user input event 00065 event = d->queuedUserInputEvents.takeFirst(); 00066 } else if (XEventsQueued(X11->display, QueuedAlready)) { 00067 // process events from the X server 00068 XNextEvent(X11->display, &event); 00069 00070 if (flags & QEventLoop::ExcludeUserInputEvents) { 00071 // queue user input events 00072 switch (event.type) { 00073 case ButtonPress: 00074 case ButtonRelease: 00075 case MotionNotify: 00076 case XKeyPress: 00077 case XKeyRelease: 00078 case EnterNotify: 00079 case LeaveNotify: 00080 d->queuedUserInputEvents.append(event); 00081 continue; 00082 00083 case ClientMessage: 00084 // only keep the wm_take_focus and 00085 // _qt_scrolldone protocols, queue all other 00086 // client messages 00087 if (event.xclient.format == 32) { 00088 if (event.xclient.message_type == ATOM(WM_PROTOCOLS) || 00089 (Atom) event.xclient.data.l[0] == ATOM(WM_TAKE_FOCUS)) { 00090 break; 00091 } else if (event.xclient.message_type == ATOM(_QT_SCROLL_DONE)) { 00092 break; 00093 } 00094 } 00095 d->queuedUserInputEvents.append(event); 00096 continue; 00097 00098 default: 00099 break; 00100 } 00101 } 00102 } else { 00103 // no event to process 00104 break; 00105 } 00106 00107 // send through event filter 00108 if (filterEvent(&event)) 00109 continue; 00110 00111 nevents++; 00112 if (qApp->x11ProcessEvent(&event) == 1) 00113 return true; 00114 00115 if (event.xany.serial >= marker) { 00116 if (XEventsQueued(X11->display, QueuedAfterFlush)) 00117 flags &= ~QEventLoop::WaitForMoreEvents; 00118 goto out; 00119 } 00120 } 00121 } while (!d->interrupt && XEventsQueued(X11->display, QueuedAfterFlush)); 00122 00123 out: 00124 if (!d->interrupt) { 00125 const uint exclude_all = 00126 QEventLoop::ExcludeSocketNotifiers | QEventLoop::X11ExcludeTimers | QEventLoop::WaitForMoreEvents; 00127 if (nevents > 0 && ((uint)flags & exclude_all) == exclude_all) { 00128 QApplication::sendPostedEvents(); 00129 return nevents > 0; 00130 } 00131 // return true if we handled events, false otherwise 00132 return QEventDispatcherUNIX::processEvents(flags) || (nevents > 0); 00133 } 00134 return nevents > 0; 00135 }
Here is the call graph for this function:

| bool QEventDispatcherX11::hasPendingEvents | ( | ) | [virtual] |
Returns true if there is an event waiting; otherwise returns false.
Reimplemented from QEventDispatcherUNIX.
Definition at line 137 of file qeventdispatcher_x11.cpp.
References qGlobalPostedEventsCount(), and X11.
00138 { 00139 extern uint qGlobalPostedEventsCount(); // from qapplication.cpp 00140 return (qGlobalPostedEventsCount() || XPending(X11->display)); 00141 }
Here is the call graph for this function:

| void QEventDispatcherX11::flush | ( | ) | [virtual] |
Flushes the event queue. This normally returns almost immediately. Does nothing on platforms other than X11.
Reimplemented from QEventDispatcherUNIX.
Definition at line 143 of file qeventdispatcher_x11.cpp.
References X11.
00144 { 00145 XFlush(X11->display); 00146 }
| void QEventDispatcherX11::startingUp | ( | ) | [virtual] |
Reimplemented from QAbstractEventDispatcher.
Definition at line 148 of file qeventdispatcher_x11.cpp.
00149 { 00150 Q_D(QEventDispatcherX11); 00151 d->xfd = XConnectionNumber(X11->display); 00152 }
| void QEventDispatcherX11::closingDown | ( | ) | [virtual] |
Reimplemented from QAbstractEventDispatcher.
Definition at line 154 of file qeventdispatcher_x11.cpp.
References d.
00155 { 00156 Q_D(QEventDispatcherX11); 00157 d->xfd = -1; 00158 }
| int QEventDispatcherX11::select | ( | int | nfds, | |
| fd_set * | readfds, | |||
| fd_set * | writefds, | |||
| fd_set * | exceptfds, | |||
| timeval * | timeout | |||
| ) | [protected, virtual] |
Reimplemented from QEventDispatcherUNIX.
Definition at line 160 of file qeventdispatcher_x11.cpp.
References d, qMax(), and QEventDispatcherUNIX::select().
00162 { 00163 Q_D(QEventDispatcherX11); 00164 if (d->xfd > 0) { 00165 nfds = qMax(nfds - 1, d->xfd) + 1; 00166 FD_SET(d->xfd, readfds); 00167 } 00168 return QEventDispatcherUNIX::select(nfds, readfds, writefds, exceptfds, timeout); 00169 }
Here is the call graph for this function:

1.5.1