Qt 4.8
Classes | Macros | Enumerations | Functions | Variables
qx11embed_x11.cpp File Reference
#include "qplatformdefs.h"
#include "qx11embed_x11.h"
#include <qapplication.h>
#include <qevent.h>
#include <qpainter.h>
#include <qlayout.h>
#include <qstyle.h>
#include <qstyleoption.h>
#include <qelapsedtimer.h>
#include <qpointer.h>
#include <qdebug.h>
#include <qx11info_x11.h>
#include <private/qt_x11_p.h>
#include <private/qwidget_p.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <X11/keysymdef.h>
#include <X11/X.h>

Go to the source code of this file.

Classes

struct  functorData
 
class  QHackWidget
 
class  QX11EmbedContainerPrivate
 
class  QX11EmbedWidgetPrivate
 

Macros

#define None   0
 
#define XK_ISO_Left_Tab   0xFE20
 
#define XK_LATIN1
 
#define XK_MISCELLANY
 

Enumerations

enum  QX11EmbedAccelFlags { XEMBED_ACCELERATOR_OVERLOADED = (1 << 0) }
 
enum  QX11EmbedAccelModifiers {
  XEMBED_MODIFIER_SHIFT = (1 << 0), XEMBED_MODIFIER_CONTROL = (1 << 1), XEMBED_MODIFIER_ALT = (1 << 2), XEMBED_MODIFIER_SUPER = (1 << 3),
  XEMBED_MODIFIER_HYPER = (1 << 4)
}
 
enum  QX11EmbedFocusInDetail { XEMBED_FOCUS_CURRENT = 0, XEMBED_FOCUS_FIRST = 1, XEMBED_FOCUS_LAST = 2 }
 
enum  QX11EmbedFocusInFlags { XEMBED_FOCUS_OTHER = (0 << 0), XEMBED_FOCUS_WRAPAROUND = (1 << 0) }
 
enum  QX11EmbedInfoFlags { XEMBED_MAPPED = (1 << 0) }
 
enum  QX11EmbedMessageType {
  XEMBED_EMBEDDED_NOTIFY = 0, XEMBED_WINDOW_ACTIVATE = 1, XEMBED_WINDOW_DEACTIVATE = 2, XEMBED_REQUEST_FOCUS = 3,
  XEMBED_FOCUS_IN = 4, XEMBED_FOCUS_OUT = 5, XEMBED_FOCUS_NEXT = 6, XEMBED_FOCUS_PREV = 7,
  XEMBED_MODALITY_ON = 10, XEMBED_MODALITY_OFF = 11, XEMBED_REGISTER_ACCELERATOR = 12, XEMBED_UNREGISTER_ACCELERATOR = 13,
  XEMBED_ACTIVATE_ACCELERATOR = 14
}
 

Functions

static Bool functor (Display *display, XEvent *event, XPointer arg)
 
static void sendXEmbedMessage (WId window, Display *display, long message, long detail=0, long data1=0, long data2=0)
 
static int x11ErrorHandler (Display *, XErrorEvent *)
 
static bool x11EventFilter (void *message, long *result)
 
static Time x11Time ()
 
static unsigned int XEmbedVersion ()
 

Variables

static XKeyEvent lastKeyEvent
 
static QCoreApplication::EventFilter oldX11EventFilter
 
const int XButtonPress = ButtonPress
 
const int XButtonRelease = ButtonRelease
 
static unsigned int XEMBED_VERSION = 0
 

Macro Definition Documentation

◆ None

#define None   0

◆ XK_ISO_Left_Tab

#define XK_ISO_Left_Tab   0xFE20

Definition at line 67 of file qx11embed_x11.cpp.

◆ XK_LATIN1

#define XK_LATIN1

Definition at line 58 of file qx11embed_x11.cpp.

◆ XK_MISCELLANY

#define XK_MISCELLANY

Definition at line 57 of file qx11embed_x11.cpp.

Enumeration Type Documentation

◆ QX11EmbedAccelFlags

Enumerator
XEMBED_ACCELERATOR_OVERLOADED 

Definition at line 346 of file qx11embed_x11.cpp.

◆ QX11EmbedAccelModifiers

Enumerator
XEMBED_MODIFIER_SHIFT 
XEMBED_MODIFIER_CONTROL 
XEMBED_MODIFIER_ALT 
XEMBED_MODIFIER_SUPER 
XEMBED_MODIFIER_HYPER 

Definition at line 338 of file qx11embed_x11.cpp.

◆ QX11EmbedFocusInDetail

Enumerator
XEMBED_FOCUS_CURRENT 
XEMBED_FOCUS_FIRST 
XEMBED_FOCUS_LAST 

Definition at line 323 of file qx11embed_x11.cpp.

◆ QX11EmbedFocusInFlags

Enumerator
XEMBED_FOCUS_OTHER 
XEMBED_FOCUS_WRAPAROUND 

Definition at line 329 of file qx11embed_x11.cpp.

◆ QX11EmbedInfoFlags

Enumerator
XEMBED_MAPPED 

Definition at line 334 of file qx11embed_x11.cpp.

334  {
335  XEMBED_MAPPED = (1 << 0)
336 };

◆ QX11EmbedMessageType

Enumerator
XEMBED_EMBEDDED_NOTIFY 
XEMBED_WINDOW_ACTIVATE 
XEMBED_WINDOW_DEACTIVATE 
XEMBED_REQUEST_FOCUS 
XEMBED_FOCUS_IN 
XEMBED_FOCUS_OUT 
XEMBED_FOCUS_NEXT 
XEMBED_FOCUS_PREV 
XEMBED_MODALITY_ON 
XEMBED_MODALITY_OFF 
XEMBED_REGISTER_ACCELERATOR 
XEMBED_UNREGISTER_ACCELERATOR 
XEMBED_ACTIVATE_ACCELERATOR 

Definition at line 307 of file qx11embed_x11.cpp.

Function Documentation

◆ functor()

static Bool functor ( Display display,
XEvent event,
XPointer  arg 
)
static

Definition at line 418 of file qx11embed_x11.cpp.

Referenced by QX11EmbedContainer::embedClient().

419 {
420  functorData *data = (functorData *) arg;
421 
422  if (!data->reparentedToRoot && event->type == ReparentNotify
423  && event->xreparent.window == data->id
424  && event->xreparent.parent == data->rootWindow) {
425  data->reparentedToRoot = true;
426  return true;
427  }
428 
429  if (!data->clearedWmState
430  && event->type == PropertyNotify
431  && event->xproperty.window == data->id
432  && event->xproperty.atom == ATOM(WM_STATE)) {
433  if (event->xproperty.state == PropertyDelete) {
434  data->clearedWmState = true;
435  return true;
436  }
437 
438  Atom ret;
439  int format, status;
440  unsigned char *retval;
441  unsigned long nitems, after;
442  status = XGetWindowProperty(display, data->id, ATOM(WM_STATE), 0, 2, False, ATOM(WM_STATE),
443  &ret, &format, &nitems, &after, &retval );
444  if (status == Success && ret == ATOM(WM_STATE) && format == 32 && nitems > 0) {
445  long state = *(long *)retval;
446  XFree(retval);
447  if (state == WithdrawnState) {
448  data->clearedWmState = true;
449  return true;
450  }
451  }
452  }
453 
454  return false;
455 }
EventRef event
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
#define ATOM(x)
Definition: qt_x11_p.h:723
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
static const char * data(const QByteArray &arr)

◆ sendXEmbedMessage()

static void sendXEmbedMessage ( WId  window,
Display display,
long  message,
long  detail = 0,
long  data1 = 0,
long  data2 = 0 
)
static

Definition at line 370 of file qx11embed_x11.cpp.

Referenced by QX11EmbedContainerPrivate::acceptClient(), QX11EmbedWidgetPrivate::checkActivateWindow(), QX11EmbedWidget::eventFilter(), QX11EmbedContainer::eventFilter(), and QX11EmbedContainer::x11Event().

372 {
373  XClientMessageEvent c;
374  memset(&c, 0, sizeof(c));
375  c.type = ClientMessage;
376  c.message_type = ATOM(_XEMBED);
377  c.format = 32;
378  c.display = display;
379  c.window = window;
380 
381  c.data.l[0] = x11Time();
382  c.data.l[1] = message;
383  c.data.l[2] = detail;
384  c.data.l[3] = data1;
385  c.data.l[4] = data2;
386 
387  XSendEvent(display, window, false, NoEventMask, (XEvent *) &c);
388 }
unsigned char c[8]
Definition: qnumeric_p.h:62
union _XEvent XEvent
Definition: qwindowdefs.h:116
#define ATOM(x)
Definition: qt_x11_p.h:723
NSWindow * window
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
static Time x11Time()

◆ x11ErrorHandler()

static int x11ErrorHandler ( Display ,
XErrorEvent *   
)
static

Definition at line 351 of file qx11embed_x11.cpp.

Referenced by QX11EmbedContainer::QX11EmbedContainer(), and QX11EmbedWidget::QX11EmbedWidget().

352 {
353  return 0;
354 }

◆ x11EventFilter()

static bool x11EventFilter ( void *  message,
long *  result 
)
static

Definition at line 398 of file qx11embed_x11.cpp.

Referenced by QApplication::isLeftToRight(), and QX11EmbedContainer::QX11EmbedContainer().

399 {
400  XEvent *event = reinterpret_cast<XEvent *>(message);
401  if (event->type == XKeyPress || event->type == XKeyRelease)
402  lastKeyEvent = event->xkey;
403 
405  return oldX11EventFilter(message, result);
406  else
407  return false;
408 }
static XKeyEvent lastKeyEvent
EventRef event
static QCoreApplication::EventFilter oldX11EventFilter
union _XEvent XEvent
Definition: qwindowdefs.h:116
static bool x11EventFilter(void *message, long *result)

◆ x11Time()

static Time x11Time ( )
static

Definition at line 358 of file qx11embed_x11.cpp.

Referenced by QX11EmbedContainerPrivate::acceptClient(), QX11EmbedContainer::eventFilter(), and sendXEmbedMessage().

359 {
360  return qt_x11Data->time;
361 }
Time time
Definition: qt_x11_p.h:476
Q_GUI_EXPORT QX11Data * qt_x11Data

◆ XEmbedVersion()

static unsigned int XEmbedVersion ( )
static

Definition at line 364 of file qx11embed_x11.cpp.

Referenced by QX11EmbedContainerPrivate::acceptClient().

365 {
366  return 0;
367 }

Variable Documentation

◆ lastKeyEvent

XKeyEvent lastKeyEvent
static

Definition at line 391 of file qx11embed_x11.cpp.

◆ oldX11EventFilter

QCoreApplication::EventFilter oldX11EventFilter
static

Definition at line 393 of file qx11embed_x11.cpp.

Referenced by x11EventFilter().

◆ XButtonPress

const int XButtonPress = ButtonPress

Definition at line 291 of file qx11embed_x11.cpp.

Referenced by QX11EmbedContainer::x11Event().

◆ XButtonRelease

const int XButtonRelease = ButtonRelease

Definition at line 292 of file qx11embed_x11.cpp.

Referenced by QX11EmbedContainer::x11Event().

◆ XEMBED_VERSION

unsigned int XEMBED_VERSION = 0
static