Qt 4.8
Classes | Functions | Variables
qguieventdispatcher_glib.cpp File Reference
#include "qguieventdispatcher_glib_p.h"
#include "qapplication.h"
#include "qx11info_x11.h"
#include "qt_x11_p.h"
#include <glib.h>

Go to the source code of this file.

Classes

struct  GX11EventSource
 
class  QGuiEventDispatcherGlibPrivate
 

Functions

static gboolean x11EventSourceCheck (GSource *s)
 
static gboolean x11EventSourceDispatch (GSource *s, GSourceFunc callback, gpointer user_data)
 
static gboolean x11EventSourcePrepare (GSource *s, gint *timeout)
 

Variables

static GSourceFuncs x11EventSourceFuncs
 

Function Documentation

◆ x11EventSourceCheck()

static gboolean x11EventSourceCheck ( GSource *  s)
static

Definition at line 82 of file qguieventdispatcher_glib.cpp.

83 {
84  GX11EventSource *source = reinterpret_cast<GX11EventSource *>(s);
85  return (XEventsQueued(X11->display, QueuedAfterFlush)
87  && !source->d->queuedUserInputEvents.isEmpty()));
88 }
QGuiEventDispatcherGlibPrivate * d
QEventLoop::ProcessEventsFlags flags
#define X11
Definition: qt_x11_p.h:724
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152

◆ x11EventSourceDispatch()

static gboolean x11EventSourceDispatch ( GSource *  s,
GSourceFunc  callback,
gpointer  user_data 
)
static

Definition at line 90 of file qguieventdispatcher_glib.cpp.

91 {
92  GX11EventSource *source = reinterpret_cast<GX11EventSource *>(s);
93 
94  ulong marker = XNextRequest(X11->display);
95  do {
96  XEvent event;
98  && !source->d->queuedUserInputEvents.isEmpty()) {
99  // process a pending user input event
100  event = source->d->queuedUserInputEvents.takeFirst();
101  } else if (XEventsQueued(X11->display, QueuedAlready)) {
102  // process events from the X server
103  XNextEvent(X11->display, &event);
104 
106  // queue user input events
107  switch (event.type) {
108  case ButtonPress:
109  case ButtonRelease:
110  case MotionNotify:
111  case XKeyPress:
112  case XKeyRelease:
113  case EnterNotify:
114  case LeaveNotify:
115  source->d->queuedUserInputEvents.append(event);
116  continue;
117 
118  case ClientMessage:
119  // only keep the wm_take_focus and
120  // _qt_scrolldone protocols, queue all other
121  // client messages
122  if (event.xclient.format == 32) {
123  if (event.xclient.message_type == ATOM(WM_PROTOCOLS) &&
124  (Atom) event.xclient.data.l[0] == ATOM(WM_TAKE_FOCUS)) {
125  break;
126  } else if (event.xclient.message_type == ATOM(_QT_SCROLL_DONE)) {
127  break;
128  }
129  }
130  source->d->queuedUserInputEvents.append(event);
131  continue;
132 
133  default:
134  break;
135  }
136  }
137  } else {
138  // no event to process
139  break;
140  }
141 
142  // send through event filter
143  if (source->q->filterEvent(&event))
144  continue;
145 
146  if (qApp->x11ProcessEvent(&event) == 1)
147  return true;
148 
149  if (event.xany.serial >= marker)
150  goto out;
151  } while (XEventsQueued(X11->display, QueuedAfterFlush));
152 
153  out:
154 
156 
157  if (callback)
158  callback(user_data);
159  return true;
160 }
static void callback(AuServer *, AuEventHandlerRec *, AuEvent *e, AuPointer p)
Definition: qsound_x11.cpp:170
bool filterEvent(void *message)
Sends message through the event filter that was set by setEventFilter().
EventRef event
QGuiEventDispatcherGlibPrivate * d
QGuiEventDispatcherGlib * q
QEventLoop::ProcessEventsFlags flags
#define X11
Definition: qt_x11_p.h:724
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
union _XEvent XEvent
Definition: qwindowdefs.h:116
#define ATOM(x)
Definition: qt_x11_p.h:723
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
#define qApp
unsigned long ulong
Definition: qglobal.h:997

◆ x11EventSourcePrepare()

static gboolean x11EventSourcePrepare ( GSource *  s,
gint *  timeout 
)
static

Definition at line 72 of file qguieventdispatcher_glib.cpp.

73 {
74  if (timeout)
75  *timeout = -1;
76  GX11EventSource *source = reinterpret_cast<GX11EventSource *>(s);
77  return (XEventsQueued(X11->display, QueuedAfterFlush)
79  && !source->d->queuedUserInputEvents.isEmpty()));
80 }
QGuiEventDispatcherGlibPrivate * d
QEventLoop::ProcessEventsFlags flags
#define X11
Definition: qt_x11_p.h:724
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152

Variable Documentation

◆ x11EventSourceFuncs

GSourceFuncs x11EventSourceFuncs
static
Initial value:
= {
NULL,
NULL,
NULL
}
static gboolean x11EventSourceDispatch(GSource *s, GSourceFunc callback, gpointer user_data)
static gboolean x11EventSourcePrepare(GSource *s, gint *timeout)
static gboolean x11EventSourceCheck(GSource *s)

Definition at line 162 of file qguieventdispatcher_glib.cpp.

Referenced by QGuiEventDispatcherGlibPrivate::QGuiEventDispatcherGlibPrivate().