Qt 4.8
Classes | Macros | Enumerations | Functions | Variables
qwidget_x11.cpp File Reference
#include "qevent.h"
#include "qwidget.h"
#include "qdesktopwidget.h"
#include "qapplication.h"
#include "qapplication_p.h"
#include "qabstracteventdispatcher.h"
#include "qnamespace.h"
#include "qpainter.h"
#include "qbitmap.h"
#include "qlayout.h"
#include "qtextcodec.h"
#include "qelapsedtimer.h"
#include "qcursor.h"
#include "qstack.h"
#include "qcolormap.h"
#include "qdebug.h"
#include "qmenu.h"
#include "private/qmenu_p.h"
#include "private/qbackingstore_p.h"
#include "private/qwindowsurface_x11_p.h"
#include <private/qpixmap_x11_p.h>
#include <private/qpaintengine_x11_p.h>
#include "qt_x11_p.h"
#include "qx11info_x11.h"
#include <stdlib.h>
#include "qinputcontext.h"
#include "qinputcontextfactory.h"
#include "qwidget_p.h"

Go to the source code of this file.

Classes

struct  QtMWMHints
 
struct  QX11WindowAttributes
 

Macros

#define WRECT_MAX   8191
 
#define XCOORD_MAX   16383
 

Enumerations

enum  {
  MWM_HINTS_FUNCTIONS = (1L << 0), MWM_FUNC_ALL = (1L << 0), MWM_FUNC_RESIZE = (1L << 1), MWM_FUNC_MOVE = (1L << 2),
  MWM_FUNC_MINIMIZE = (1L << 3), MWM_FUNC_MAXIMIZE = (1L << 4), MWM_FUNC_CLOSE = (1L << 5), MWM_HINTS_DECORATIONS = (1L << 1),
  MWM_DECOR_ALL = (1L << 0), MWM_DECOR_BORDER = (1L << 1), MWM_DECOR_RESIZEH = (1L << 2), MWM_DECOR_TITLE = (1L << 3),
  MWM_DECOR_MENU = (1L << 4), MWM_DECOR_MINIMIZE = (1L << 5), MWM_DECOR_MAXIMIZE = (1L << 6), MWM_HINTS_INPUT_MODE = (1L << 2),
  MWM_INPUT_MODELESS = 0L, MWM_INPUT_PRIMARY_APPLICATION_MODAL = 1L, MWM_INPUT_FULL_APPLICATION_MODAL = 3L
}
 

Functions

static void create_wm_client_leader ()
 
static void do_size_hints (QWidget *widget, QWExtra *x)
 
static QtMWMHints GetMWMHints (Display *display, Window window)
 
static QVector< Atom > getNetWmState (QWidget *w)
 
static bool isTransient (const QWidget *w)
 
static XTextProperty * qstring_to_xtp (const QString &s)
 
void qt_change_net_wm_state (const QWidget *w, bool set, Atom one, Atom two=0)
 
static void qt_insert_sip (QWidget *scrolled_widget, int dx, int dy)
 
void qt_net_remove_user_time (QWidget *tlw)
 
void qt_net_update_user_time (QWidget *tlw, unsigned long timestamp)
 
bool qt_nograb ()
 
static int qt_sip_count (QWidget *scrolled_widget)
 
void qt_x11_enforce_cursor (QWidget *w, bool force)
 Update the X11 cursor of the widget w. More...
 
Q_GUI_EXPORT void qt_x11_enforce_cursor (QWidget *w)
 
void qt_x11_getX11InfoForWindow (QX11Info *xinfo, const XWindowAttributes &a)
 
void qt_x11_getX11InfoForWindow (QX11Info *xinfo, const QX11WindowAttributes &att)
 
static void qt_x11_recreateNativeWidgetsRecursive (QWidget *widget)
 
static void qt_x11_recreateWidget (QWidget *widget)
 
void qt_x11_wait_for_window_manager (QWidget *w, bool sendPostedEvents)
 
Q_GUI_EXPORT void qt_x11_wait_for_window_manager (QWidget *w)
 
Window qt_XCreateSimpleWindow (const QWidget *creator, Display *display, Window parent, int x, int y, uint w, uint h, int borderwidth, ulong border, ulong background)
 
Window qt_XCreateWindow (const QWidget *creator, Display *display, Window parent, int x, int y, uint w, uint h, int borderwidth, int depth, uint windowclass, Visual *visual, ulong valuemask, XSetWindowAttributes *attributes)
 
void qt_XDestroyWindow (const QWidget *destroyer, Display *display, Window window)
 
static void SetMWMHints (Display *display, Window window, const QtMWMHints &mwmhints)
 

Variables

int qt_x11_create_desktop_on_screen = -1
 
const uint stdDesktopEventMask
 
const uint stdWidgetEventMask
 

Macro Definition Documentation

◆ WRECT_MAX

#define WRECT_MAX   8191

Definition at line 87 of file qwidget_x11.cpp.

Referenced by do_size_hints().

◆ XCOORD_MAX

#define XCOORD_MAX   16383

Definition at line 86 of file qwidget_x11.cpp.

Referenced by do_size_hints(), and getNetWmState().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
MWM_HINTS_FUNCTIONS 
MWM_FUNC_ALL 
MWM_FUNC_RESIZE 
MWM_FUNC_MOVE 
MWM_FUNC_MINIMIZE 
MWM_FUNC_MAXIMIZE 
MWM_FUNC_CLOSE 
MWM_HINTS_DECORATIONS 
MWM_DECOR_ALL 
MWM_DECOR_BORDER 
MWM_DECOR_RESIZEH 
MWM_DECOR_TITLE 
MWM_DECOR_MENU 
MWM_DECOR_MINIMIZE 
MWM_DECOR_MAXIMIZE 
MWM_HINTS_INPUT_MODE 
MWM_INPUT_MODELESS 
MWM_INPUT_PRIMARY_APPLICATION_MODAL 
MWM_INPUT_FULL_APPLICATION_MODAL 

Definition at line 110 of file qwidget_x11.cpp.

110  {
111  MWM_HINTS_FUNCTIONS = (1L << 0),
112 
113  MWM_FUNC_ALL = (1L << 0),
114  MWM_FUNC_RESIZE = (1L << 1),
115  MWM_FUNC_MOVE = (1L << 2),
116  MWM_FUNC_MINIMIZE = (1L << 3),
117  MWM_FUNC_MAXIMIZE = (1L << 4),
118  MWM_FUNC_CLOSE = (1L << 5),
119 
120  MWM_HINTS_DECORATIONS = (1L << 1),
121 
122  MWM_DECOR_ALL = (1L << 0),
123  MWM_DECOR_BORDER = (1L << 1),
124  MWM_DECOR_RESIZEH = (1L << 2),
125  MWM_DECOR_TITLE = (1L << 3),
126  MWM_DECOR_MENU = (1L << 4),
127  MWM_DECOR_MINIMIZE = (1L << 5),
128  MWM_DECOR_MAXIMIZE = (1L << 6),
129 
130  MWM_HINTS_INPUT_MODE = (1L << 2),
131 
132  MWM_INPUT_MODELESS = 0L,
135 };

Function Documentation

◆ create_wm_client_leader()

static void create_wm_client_leader ( )
static

Definition at line 266 of file qwidget_x11.cpp.

Referenced by getNetWmState().

267 {
268  if (X11->wm_client_leader) return;
269 
270  X11->wm_client_leader =
271  XCreateSimpleWindow(X11->display,
273  0, 0, 1, 1, 0, 0, 0);
274 
275  // set client leader property to itself
276  XChangeProperty(X11->display,
277  X11->wm_client_leader, ATOM(WM_CLIENT_LEADER),
278  XA_WINDOW, 32, PropModeReplace,
279  (unsigned char *)&X11->wm_client_leader, 1);
280 
281 #ifndef QT_NO_SESSIONMANAGER
282  // If we are session managed, inform the window manager about it
283  QByteArray session = qApp->sessionId().toLatin1();
284  if (!session.isEmpty()) {
285  XChangeProperty(X11->display,
286  X11->wm_client_leader, ATOM(SM_CLIENT_ID),
287  XA_STRING, 8, PropModeReplace,
288  (unsigned char *)session.data(), session.size());
289  }
290 #endif
291 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static Qt::HANDLE appRootWindow(int screen=-1)
Returns a handle for the applications root window on the given screen.
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
#define qApp
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421

◆ do_size_hints()

static void do_size_hints ( QWidget widget,
QWExtra x 
)
static

Definition at line 2311 of file qwidget_x11.cpp.

Referenced by isTransient(), and qstring_to_xtp().

2312 {
2314  XSizeHints s;
2315  memset(&s, 0, sizeof(s));
2316  if (x) {
2317  QRect g = widget->geometry();
2318  s.x = g.x();
2319  s.y = g.y();
2320  s.width = g.width();
2321  s.height = g.height();
2322  if (x->minw > 0 || x->minh > 0) {
2323  // add minimum size hints
2324  s.flags |= PMinSize;
2325  s.min_width = qMin(XCOORD_MAX, x->minw);
2326  s.min_height = qMin(XCOORD_MAX, x->minh);
2327  }
2328  if (x->maxw < QWIDGETSIZE_MAX || x->maxh < QWIDGETSIZE_MAX) {
2329  // add maximum size hints
2330  s.flags |= PMaxSize;
2331  s.max_width = qMin(XCOORD_MAX, x->maxw);
2332  s.max_height = qMin(XCOORD_MAX, x->maxh);
2333  }
2334  if (x->topextra &&
2335  (x->topextra->incw > 0 || x->topextra->inch > 0)) {
2336  // add resize increment hints
2337  s.flags |= PResizeInc | PBaseSize;
2338  s.width_inc = x->topextra->incw;
2339  s.height_inc = x->topextra->inch;
2340  s.base_width = x->topextra->basew;
2341  s.base_height = x->topextra->baseh;
2342  }
2343  }
2344  if (widget->testAttribute(Qt::WA_Moved)) {
2345  // user (i.e. command-line) specified position
2346  s.flags |= USPosition;
2347  s.flags |= PPosition;
2348  }
2349  if (widget->testAttribute(Qt::WA_Resized)) {
2350  // user (i.e. command-line) specified size
2351  s.flags |= USSize;
2352  s.flags |= PSize;
2353  }
2354  s.flags |= PWinGravity;
2355  if (widget->testAttribute(Qt::WA_Moved) && x && x->topextra && !x->topextra->posFromMove) {
2356  // position came from setGeometry(), tell the WM that we don't
2357  // want our window gravity-shifted
2358  s.win_gravity = StaticGravity;
2359  } else {
2360  // position came from move()
2361  s.x = widget->x();
2362  s.y = widget->y();
2363  s.win_gravity = QApplication::isRightToLeft() ? NorthEastGravity : NorthWestGravity;
2364  }
2365  if (widget->internalWinId())
2366  XSetWMNormalHints(X11->display, widget->internalWinId(), &s);
2367 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
#define XCOORD_MAX
Definition: qwidget_x11.cpp:86
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
short baseh
Definition: qwidget_p.h:178
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define X11
Definition: qt_x11_p.h:724
int x
the x coordinate of the widget relative to its parent including any window frame
Definition: qwidget.h:161
qint32 minw
Definition: qwidget_p.h:264
short inch
Definition: qwidget_p.h:177
qint32 maxw
Definition: qwidget_p.h:266
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
qint32 maxh
Definition: qwidget_p.h:267
short incw
Definition: qwidget_p.h:177
QTLWExtra * topextra
Definition: qwidget_p.h:249
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int y
the y coordinate of the widget relative to its parent and including any window frame ...
Definition: qwidget.h:162
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
qint32 minh
Definition: qwidget_p.h:265
short basew
Definition: qwidget_p.h:178
uint posFromMove
Definition: qwidget_p.h:186
static bool isRightToLeft()
Returns true if the application&#39;s layout direction is Qt::RightToLeft; otherwise returns false...
Definition: qapplication.h:233
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158

◆ GetMWMHints()

static QtMWMHints GetMWMHints ( Display display,
Window  window 
)
static

Definition at line 138 of file qwidget_x11.cpp.

Referenced by do_size_hints(), and qstring_to_xtp().

139 {
140  QtMWMHints mwmhints;
141 
142  Atom type;
143  int format;
144  ulong nitems, bytesLeft;
145  uchar *data = 0;
146  if ((XGetWindowProperty(display, window, ATOM(_MOTIF_WM_HINTS), 0, 5, false,
147  ATOM(_MOTIF_WM_HINTS), &type, &format, &nitems, &bytesLeft,
148  &data) == Success)
149  && (type == ATOM(_MOTIF_WM_HINTS)
150  && format == 32
151  && nitems >= 5)) {
152  mwmhints = *(reinterpret_cast<QtMWMHints *>(data));
153  } else {
154  mwmhints.flags = 0L;
155  mwmhints.functions = MWM_FUNC_ALL;
156  mwmhints.decorations = MWM_DECOR_ALL;
157  mwmhints.input_mode = 0L;
158  mwmhints.status = 0L;
159  }
160 
161  if (data)
162  XFree(data);
163 
164  return mwmhints;
165 }
int type
Definition: qmetatype.cpp:239
ulong decorations
#define ATOM(x)
Definition: qt_x11_p.h:723
unsigned char uchar
Definition: qglobal.h:994
NSWindow * window
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
static const char * data(const QByteArray &arr)
unsigned long ulong
Definition: qglobal.h:997
ulong functions

◆ getNetWmState()

static QVector<Atom> getNetWmState ( QWidget w)
static

Definition at line 445 of file qwidget_x11.cpp.

Referenced by qstring_to_xtp(), and QXlibWindow::visual().

446 {
447  QVector<Atom> returnValue;
448 
449  // Don't read anything, just get the size of the property data
450  Atom actualType;
451  int actualFormat;
452  ulong propertyLength;
453  ulong bytesLeft;
454  uchar *propertyData = 0;
455  if (XGetWindowProperty(X11->display, w->internalWinId(), ATOM(_NET_WM_STATE), 0, 0,
456  False, XA_ATOM, &actualType, &actualFormat,
457  &propertyLength, &bytesLeft, &propertyData) == Success
458  && actualType == XA_ATOM && actualFormat == 32) {
459  returnValue.resize(bytesLeft / 4);
460  XFree((char*) propertyData);
461  propertyData = 0;
462 
463  // fetch all data
464  if (XGetWindowProperty(X11->display, w->internalWinId(), ATOM(_NET_WM_STATE), 0,
465  returnValue.size(), False, XA_ATOM, &actualType, &actualFormat,
466  &propertyLength, &bytesLeft, &propertyData) != Success) {
467  returnValue.clear();
468  } else if (propertyLength != (ulong)returnValue.size()) {
469  returnValue.resize(propertyLength);
470  }
471 
472  // put it into netWmState
473  if (!returnValue.isEmpty()) {
474  memcpy(returnValue.data(), propertyData, returnValue.size() * sizeof(Atom));
475  }
476  if (propertyData)
477  XFree((char*) propertyData);
478  }
479 
480  return returnValue;
481 }
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
#define X11
Definition: qt_x11_p.h:724
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
#define ATOM(x)
Definition: qt_x11_p.h:723
unsigned char uchar
Definition: qglobal.h:994
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
unsigned long ulong
Definition: qglobal.h:997
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ isTransient()

static bool isTransient ( const QWidget w)
inlinestatic

Definition at line 178 of file qwidget_x11.cpp.

Referenced by QWidgetPrivate::isBackgroundInherited(), and qstring_to_xtp().

179 {
180  return ((w->windowType() == Qt::Dialog
181  || w->windowType() == Qt::Sheet
182  || w->windowType() == Qt::Tool
183  || w->windowType() == Qt::SplashScreen
184  || w->windowType() == Qt::ToolTip
185  || w->windowType() == Qt::Drawer
186  || w->windowType() == Qt::Popup)
188 }
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937

◆ qstring_to_xtp()

static XTextProperty* qstring_to_xtp ( const QString s)
static

Definition at line 1408 of file qwidget_x11.cpp.

1409 {
1410  static XTextProperty tp = { 0, 0, 0, 0 };
1411  static bool free_prop = true; // we can't free tp.value in case it references
1412  // the data of the static QCString below.
1413  if (tp.value) {
1414  if (free_prop)
1415  XFree(tp.value);
1416  tp.value = 0;
1417  free_prop = true;
1418  }
1419 
1420  static const QTextCodec* mapper = QTextCodec::codecForLocale();
1421  int errCode = 0;
1422  if (mapper) {
1423  QByteArray mapped = mapper->fromUnicode(s);
1424  char* tl[2];
1425  tl[0] = mapped.data();
1426  tl[1] = 0;
1427  errCode = XmbTextListToTextProperty(X11->display, tl, 1, XStdICCTextStyle, &tp);
1428 #if defined(QT_DEBUG)
1429  if (errCode < 0)
1430  qDebug("qstring_to_xtp result code %d", errCode);
1431 #endif
1432  }
1433  if (!mapper || errCode < 0) {
1434  static QByteArray qcs;
1435  qcs = s.toAscii();
1436  tp.value = (uchar*)qcs.data();
1437  tp.encoding = XA_STRING;
1438  tp.format = 8;
1439  tp.nitems = qcs.length();
1440  free_prop = false;
1441  }
1442 
1443  // ### If we knew WM could understand unicode, we could use
1444  // ### a much simpler, cheaper encoding...
1445  /*
1446  tp.value = (XChar2b*)s.unicode();
1447  tp.encoding = XA_UNICODE; // wish
1448  tp.format = 16;
1449  tp.nitems = s.length();
1450  */
1451 
1452  return &tp;
1453 }
static QTextCodec * codecForLocale()
Returns a pointer to the codec most suitable for this locale.
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define X11
Definition: qt_x11_p.h:724
QFuture< T > mapped(const Sequence &sequence, MapFunction function)
Q_CORE_EXPORT void qDebug(const char *,...)
unsigned char uchar
Definition: qglobal.h:994
QByteArray fromUnicode(const QString &uc) const
Converts str from Unicode to the encoding of this codec, and returns the result in a QByteArray...
int length() const
Same as size().
Definition: qbytearray.h:356
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4014
The QTextCodec class provides conversions between text encodings.
Definition: qtextcodec.h:62

◆ qt_change_net_wm_state()

void qt_change_net_wm_state ( const QWidget w,
bool  set,
Atom  one,
Atom  two = 0 
)

Definition at line 413 of file qwidget_x11.cpp.

Referenced by qstring_to_xtp(), and QApplication::syncX().

414 {
415  if (!w->isVisible()) // not managed by the window manager
416  return;
417 
418  XEvent e;
419  e.xclient.type = ClientMessage;
420  e.xclient.message_type = ATOM(_NET_WM_STATE);
421  e.xclient.display = X11->display;
422  e.xclient.window = w->internalWinId();
423  e.xclient.format = 32;
424  e.xclient.data.l[0] = set ? 1 : 0;
425  e.xclient.data.l[1] = one;
426  e.xclient.data.l[2] = two;
427  e.xclient.data.l[3] = 0;
428  e.xclient.data.l[4] = 0;
429  XSendEvent(X11->display, RootWindow(X11->display, w->x11Info().screen()),
430  false, (SubstructureNotifyMask | SubstructureRedirectMask), &e);
431 }
bool isVisible() const
Definition: qwidget.h:1005
const QX11Info & x11Info() const
Returns information about the configuration of the X display used to display the widget.
#define X11
Definition: qt_x11_p.h:724
union _XEvent XEvent
Definition: qwindowdefs.h:116
#define ATOM(x)
Definition: qt_x11_p.h:723
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
int screen() const
Returns the number of the screen currently in use.

◆ qt_insert_sip()

static void qt_insert_sip ( QWidget scrolled_widget,
int  dx,
int  dy 
)
static

Definition at line 235 of file qwidget_x11.cpp.

Referenced by do_size_hints().

236 {
237  if (!scrolled_widget->isWindow() && !scrolled_widget->internalWinId())
238  return;
239  QX11Data::ScrollInProgress sip = { X11->sip_serial++, scrolled_widget, dx, dy };
240  X11->sip_list.append(sip);
241 
242  XClientMessageEvent client_message;
243  client_message.type = ClientMessage;
244  client_message.window = scrolled_widget->internalWinId();
245  client_message.format = 32;
246  client_message.message_type = ATOM(_QT_SCROLL_DONE);
247  client_message.data.l[0] = sip.id;
248 
249  XSendEvent(X11->display, scrolled_widget->internalWinId(), False, NoEventMask,
250  (XEvent*)&client_message);
251 }
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
#define X11
Definition: qt_x11_p.h:724
union _XEvent XEvent
Definition: qwindowdefs.h:116
#define ATOM(x)
Definition: qt_x11_p.h:723
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244

◆ qt_net_remove_user_time()

void qt_net_remove_user_time ( QWidget tlw)

Definition at line 1508 of file qapplication_x11.cpp.

Referenced by QWidgetPrivate::isBackgroundInherited(), and qt_net_update_user_time().

1509 {
1510  Q_ASSERT(tlw);
1511  QTLWExtra *extra = tlw->d_func()->maybeTopData();
1512  if (extra && extra->userTimeWindow) {
1513  Q_ASSERT(tlw->internalWinId());
1514  XDeleteProperty(X11->display, tlw->internalWinId(), ATOM(_NET_WM_USER_TIME_WINDOW));
1515  XDestroyWindow(X11->display, extra->userTimeWindow);
1516  extra->userTimeWindow = 0;
1517  }
1518 }
WId userTimeWindow
Definition: qwidget_p.h:199
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244

◆ qt_net_update_user_time()

void qt_net_update_user_time ( QWidget tlw,
unsigned long  timestamp 
)

Definition at line 1520 of file qapplication_x11.cpp.

Referenced by qstring_to_xtp(), and QApplication::x11ProcessEvent().

1521 {
1522  Q_ASSERT(tlw);
1523  Q_ASSERT(tlw->isWindow());
1525  QTLWExtra *extra = tlw->d_func()->topData();
1526  WId wid = tlw->internalWinId();
1527  const bool isSupportedByWM = X11->isSupportedByWM(ATOM(_NET_WM_USER_TIME_WINDOW));
1528  if (extra->userTimeWindow || isSupportedByWM) {
1529  if (!extra->userTimeWindow) {
1530  extra->userTimeWindow = XCreateSimpleWindow(X11->display,
1531  tlw->internalWinId(),
1532  -1, -1, 1, 1, 0, 0, 0);
1533  wid = extra->userTimeWindow;
1534  XChangeProperty(X11->display, tlw->internalWinId(), ATOM(_NET_WM_USER_TIME_WINDOW),
1535  XA_WINDOW, 32, PropModeReplace,
1536  (unsigned char *)&wid, 1);
1537  XDeleteProperty(X11->display, tlw->internalWinId(), ATOM(_NET_WM_USER_TIME));
1538  } else if (!isSupportedByWM) {
1539  // WM no longer supports it, then we should remove the
1540  // _NET_WM_USER_TIME_WINDOW atom.
1542  } else {
1543  wid = extra->userTimeWindow;
1544  }
1545  }
1546  XChangeProperty(X11->display, wid, ATOM(_NET_WM_USER_TIME),
1547  XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &timestamp, 1);
1548 }
unsigned long WId
Definition: qwindowdefs.h:119
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define X11
Definition: qt_x11_p.h:724
#define ATOM(x)
Definition: qt_x11_p.h:723
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
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 qt_net_remove_user_time(QWidget *tlw)

◆ qt_nograb()

bool qt_nograb ( )

Definition at line 482 of file qapplication_mac.mm.

Referenced by qJournalRecordProc(), qstring_to_xtp(), and qt_try_modal().

483 {
484 #if defined(QT_DEBUG)
485  return appNoGrab;
486 #else
487  return false;
488 #endif
489 }
static bool appNoGrab

◆ qt_sip_count()

static int qt_sip_count ( QWidget scrolled_widget)
static

Definition at line 253 of file qwidget_x11.cpp.

Referenced by do_size_hints().

254 {
255  int sips=0;
256 
257  for (int i = 0; i < X11->sip_list.size(); ++i) {
258  const QX11Data::ScrollInProgress &sip = X11->sip_list.at(i);
259  if (sip.scrolled_widget == scrolled_widget)
260  sips++;
261  }
262 
263  return sips;
264 }
#define X11
Definition: qt_x11_p.h:724

◆ qt_x11_enforce_cursor() [1/2]

void qt_x11_enforce_cursor ( QWidget w,
bool  force 
)

Update the X11 cursor of the widget w.

Warning
This function is not part of the public interface.

force is true if this function is called from dispatchEnterLeave, it means that the mouse is actually directly under this widget.

Definition at line 302 of file qwidget_x11.cpp.

Referenced by QApplicationPrivate::applyX11SpecificCommandLineArguments(), QApplicationPrivate::dispatchEnterLeave(), getNetWmState(), QWidgetPrivate::mapFromGlobal(), qt_x11_enforce_cursor(), and QWidgetPrivate::setEnabled_helper().

303 {
305  return;
306 
307  static QPointer<QWidget> lastUnderMouse = 0;
308  if (force) {
309  lastUnderMouse = w;
310  } else if (lastUnderMouse && lastUnderMouse->effectiveWinId() == w->effectiveWinId()) {
311  w = lastUnderMouse;
312  } else if (!w->internalWinId()) {
313  return; //the mouse is not under this widget, and it's not native, so don't change it
314  }
315 
316  while (!w->internalWinId() && w->parentWidget() && !w->isWindow() && !w->testAttribute(Qt::WA_SetCursor))
317  w = w->parentWidget();
318 
319  QWidget *nativeParent = w;
320  if (!w->internalWinId())
321  nativeParent = w->nativeParentWidget();
322  // This does the same as effectiveWinId(), but since it is possible
323  // to not have a native parent widget due to a special hack in
324  // qwidget for reparenting widgets to a different X11 screen,
325  // added additional check to make sure native parent widget exists.
326  if (!nativeParent || !nativeParent->internalWinId())
327  return;
328  WId winid = nativeParent->internalWinId();
329 
330  if (w->isWindow() || w->testAttribute(Qt::WA_SetCursor)) {
331 #ifndef QT_NO_CURSOR
333  if (oc) {
334  XDefineCursor(X11->display, winid, oc->handle());
335  } else if (w->isEnabled()) {
336  XDefineCursor(X11->display, winid, w->cursor().handle());
337  } else {
338  // enforce the windows behavior of clearing the cursor on
339  // disabled widgets
340  XDefineCursor(X11->display, winid, XNone);
341  }
342 #endif
343  } else {
344  XDefineCursor(X11->display, winid, XNone);
345  }
346 }
HCURSOR_or_HANDLE handle() const
Returns a platform-specific cursor handle.
Definition: qcursor_mac.mm:301
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
unsigned long WId
Definition: qwindowdefs.h:119
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
WId effectiveWinId() const
Returns the effective window system identifier of the widget, i.
Definition: qwidget.cpp:2654
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define X11
Definition: qt_x11_p.h:724
static QCursor * overrideCursor()
Strips out vertical alignment flags and transforms an alignment align of Qt::AlignLeft into Qt::Align...
QWidget * nativeParentWidget() const
Returns the native parent for this widget, i.
Definition: qwidget.cpp:4514
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QCursor cursor
the cursor shape for this widget
Definition: qwidget.h:183
bool isEnabled() const
Definition: qwidget.h:948
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244

◆ qt_x11_enforce_cursor() [2/2]

Q_GUI_EXPORT void qt_x11_enforce_cursor ( QWidget w)

Definition at line 348 of file qwidget_x11.cpp.

349 {
350  qt_x11_enforce_cursor(w, false);
351 }
void qt_x11_enforce_cursor(QWidget *w, bool force)
Update the X11 cursor of the widget w.

◆ qt_x11_getX11InfoForWindow() [1/2]

void qt_x11_getX11InfoForWindow ( QX11Info xinfo,
const XWindowAttributes &  a 
)

Definition at line 437 of file qwidget_x11.cpp.

Referenced by getNetWmState(), and QX11PixmapData::transformed().

438 {
440  att.att = &a;
441  qt_x11_getX11InfoForWindow(xinfo,att);
442 }
long ASN1_INTEGER_get ASN1_INTEGER * a
const XWindowAttributes * att
void qt_x11_getX11InfoForWindow(QX11Info *xinfo, const XWindowAttributes &a)

◆ qt_x11_getX11InfoForWindow() [2/2]

void qt_x11_getX11InfoForWindow ( QX11Info xinfo,
const QX11WindowAttributes att 
)

Definition at line 3114 of file qwidget_x11.cpp.

3115 {
3116  QX11InfoData* xd = xinfo->getX11Data(true);
3117  const XWindowAttributes &a = *(att.att);
3118  // find which screen the window is on...
3119  xd->screen = QX11Info::appScreen(); // by default, use the default :)
3120  int i;
3121  for (i = 0; i < ScreenCount(X11->display); i++) {
3122  if (RootWindow(X11->display, i) == a.root) {
3123  xd->screen = i;
3124  break;
3125  }
3126  }
3127 
3128  xd->depth = a.depth;
3129  xd->cells = DisplayCells(X11->display, xd->screen);
3130  xd->visual = a.visual;
3131  xd->defaultVisual = (XVisualIDFromVisual((Visual *) a.visual) ==
3132  XVisualIDFromVisual((Visual *) QX11Info::appVisual(xinfo->screen())));
3133  xd->colormap = a.colormap;
3134  xd->defaultColormap = (a.colormap == QX11Info::appColormap(xinfo->screen()));
3135  xinfo->setX11Data(xd);
3136 }
static int appScreen()
Returns the number of the screen where the application is being displayed.
long ASN1_INTEGER_get ASN1_INTEGER * a
const XWindowAttributes * att
#define X11
Definition: qt_x11_p.h:724
QX11InfoData * getX11Data(bool def=false) const
static Qt::HANDLE appColormap(int screen=-1)
Returns a handle for the application&#39;s color map on the given screen.
Visual * visual
Definition: qt_x11_p.h:318
static void * appVisual(int screen=-1)
Returns the current visual used by the application on the given screen.
Colormap colormap
Definition: qt_x11_p.h:317
void setX11Data(const QX11InfoData *)
Makes a shallow copy of the X11-specific data d and assigns it to this class.
bool defaultColormap
Definition: qt_x11_p.h:319
int screen() const
Returns the number of the screen currently in use.
bool defaultVisual
Definition: qt_x11_p.h:320

◆ qt_x11_recreateNativeWidgetsRecursive()

static void qt_x11_recreateNativeWidgetsRecursive ( QWidget widget)
static

Definition at line 986 of file qwidget_x11.cpp.

Referenced by QWidgetPrivate::x11UpdateIsOpaque().

987 {
988  if (widget->internalWinId())
989  qt_x11_recreateWidget(widget);
990 
991  const QObjectList &children = widget->children();
992  for (int i = 0; i < children.size(); ++i) {
993  QWidget *child = qobject_cast<QWidget*>(children.at(i));
994  if (child)
996  }
997 }
static void qt_x11_recreateWidget(QWidget *widget)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
T * qobject_cast(QObject *object)
Definition: qobject.h:375
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
static void qt_x11_recreateNativeWidgetsRecursive(QWidget *widget)

◆ qt_x11_recreateWidget()

static void qt_x11_recreateWidget ( QWidget widget)
static

Definition at line 957 of file qwidget_x11.cpp.

Referenced by qt_x11_recreateNativeWidgetsRecursive().

958 {
959  if (widget->inherits("QGLWidget")) {
960  // We send QGLWidgets a ParentChange event which causes them to
961  // recreate their GL context, which in turn causes them to choose
962  // their visual again. Now that WA_TranslucentBackground is set,
963  // QGLContext::chooseVisual will select an ARGB visual.
964 
965  // QGLWidget expects a ParentAboutToChange to be sent first
966  QEvent aboutToChangeEvent(QEvent::ParentAboutToChange);
967  QApplication::sendEvent(widget, &aboutToChangeEvent);
968 
969  QEvent parentChangeEvent(QEvent::ParentChange);
970  QApplication::sendEvent(widget, &parentChangeEvent);
971  } else {
972  // For regular widgets, reparent them with their parent which
973  // also triggers a recreation of the native window
974  QPoint pos = widget->pos();
975  bool visible = widget->isVisible();
976  if (visible)
977  widget->hide();
978 
979  widget->setParent(widget->parentWidget(), widget->windowFlags());
980  widget->move(pos);
981  if (visible)
982  widget->show();
983  }
984 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
bool isVisible() const
Definition: qwidget.h:1005
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void show()
Shows the widget and its child widgets.
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
void hide()
Hides the widget.
Definition: qwidget.h:501
QPoint pos
the position of the widget within its parent widget
Definition: qwidget.h:163
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
void move(int x, int y)
This corresponds to move(QPoint(x, y)).
Definition: qwidget.h:1011

◆ qt_x11_wait_for_window_manager() [1/2]

void qt_x11_wait_for_window_manager ( QWidget w,
bool  sendPostedEvents 
)

Definition at line 353 of file qwidget_x11.cpp.

Referenced by QSplashScreen::finish(), qstring_to_xtp(), and qt_x11_wait_for_window_manager().

354 {
355  if (!w || (!w->isWindow() && !w->internalWinId()))
356  return;
358  XEvent ev;
359  QElapsedTimer t;
360  t.start();
361  static const int maximumWaitTime = 2000;
363  return;
364 
365  WId winid = w->internalWinId();
366 
367  // first deliver events that are already in the local queue
368  if (sendPostedEvents)
370 
371  // the normal sequence is:
372  // ... ConfigureNotify ... ReparentNotify ... MapNotify ... Expose
373  // with X11BypassWindowManagerHint:
374  // ConfigureNotify ... MapNotify ... Expose
375 
376  enum State {
377  Initial, Mapped
378  } state = Initial;
379 
380  do {
381  if (XEventsQueued(X11->display, QueuedAlready)) {
382  XNextEvent(X11->display, &ev);
383  // Pass the event through the event dispatcher filter so that applications
384  // which install an event filter on the dispatcher get to handle it first.
385  if (!QAbstractEventDispatcher::instance()->filterEvent(&ev)) {
386  qApp->x11ProcessEvent(&ev);
387 
388  switch (state) {
389  case Initial:
390  if (ev.type == MapNotify && ev.xany.window == winid)
391  state = Mapped;
392  break;
393  case Mapped:
394  if (ev.type == Expose && ev.xany.window == winid)
395  return;
396  break;
397  }
398  }
399  } else {
400  if (!XEventsQueued(X11->display, QueuedAfterFlush))
401  qApp->syncX(); // non-busy wait
402  }
403  if (t.elapsed() > maximumWaitTime)
404  return;
405  } while(1);
406 }
unsigned long WId
Definition: qwindowdefs.h:119
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
static QAbstractEventDispatcher * instance(QThread *thread=0)
Returns a pointer to the event dispatcher object for the specified thread.
#define X11
Definition: qt_x11_p.h:724
The QElapsedTimer class provides a fast way to calculate elapsed times.
Definition: qelapsedtimer.h:53
qint64 elapsed() const
Returns the number of milliseconds since this QElapsedTimer was last started.
union _XEvent XEvent
Definition: qwindowdefs.h:116
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
#define qApp
static void sendPostedEvents()
The State element defines configurations of objects and properties.
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 start()
Starts this timer.
static void flush()
Flushes the platform specific event queues.

◆ qt_x11_wait_for_window_manager() [2/2]

Q_GUI_EXPORT void qt_x11_wait_for_window_manager ( QWidget w)

Definition at line 408 of file qwidget_x11.cpp.

Referenced by pixmapsAreEqual(), and QTest::qWaitForWindowShown().

409 {
411 }
void qt_x11_wait_for_window_manager(QWidget *w, bool sendPostedEvents)

◆ qt_XCreateSimpleWindow()

Window qt_XCreateSimpleWindow ( const QWidget creator,
Display display,
Window  parent,
int  x,
int  y,
uint  w,
uint  h,
int  borderwidth,
ulong  border,
ulong  background 
)

Definition at line 64 of file qwidgetcreate_x11.cpp.

Referenced by getNetWmState().

67 {
68  return XCreateSimpleWindow(display, parent, x, y, w, h, borderwidth,
69  border, background);
70 }
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589

◆ qt_XCreateWindow()

Window qt_XCreateWindow ( const QWidget creator,
Display display,
Window  parent,
int  x,
int  y,
uint  w,
uint  h,
int  borderwidth,
int  depth,
uint  windowclass,
Visual *  visual,
ulong  valuemask,
XSetWindowAttributes *  attributes 
)

Definition at line 53 of file qwidgetcreate_x11.cpp.

Referenced by getNetWmState().

58 {
59  return XCreateWindow(display, parent, x, y, w, h, borderwidth, depth,
60  windowclass, visual, valuemask, attributes);
61 }
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589

◆ qt_XDestroyWindow()

void qt_XDestroyWindow ( const QWidget destroyer,
Display display,
Window  window 
)

Definition at line 73 of file qwidgetcreate_x11.cpp.

Referenced by getNetWmState(), and QWidgetPrivate::isBackgroundInherited().

74 {
75  if (window)
76  XDestroyWindow(display, window);
77 }
NSWindow * window
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589

◆ SetMWMHints()

static void SetMWMHints ( Display display,
Window  window,
const QtMWMHints mwmhints 
)
static

Definition at line 167 of file qwidget_x11.cpp.

Referenced by do_size_hints(), getNetWmState(), and qstring_to_xtp().

168 {
169  if (mwmhints.flags != 0l) {
170  XChangeProperty(display, window, ATOM(_MOTIF_WM_HINTS), ATOM(_MOTIF_WM_HINTS), 32,
171  PropModeReplace, (unsigned char *) &mwmhints, 5);
172  } else {
173  XDeleteProperty(display, window, ATOM(_MOTIF_WM_HINTS));
174  }
175 }
#define ATOM(x)
Definition: qt_x11_p.h:723
NSWindow * window
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
QFactoryLoader * l

Variable Documentation

◆ qt_x11_create_desktop_on_screen

int qt_x11_create_desktop_on_screen = -1

Definition at line 99 of file qwidget_x11.cpp.

Referenced by getNetWmState(), and QDesktopWidgetPrivate::init().

◆ stdDesktopEventMask

const uint stdDesktopEventMask
Initial value:
=
(uint)(
KeymapStateMask |
EnterWindowMask | LeaveWindowMask |
PropertyChangeMask
)
unsigned int uint
Definition: qglobal.h:996

Definition at line 209 of file qwidget_x11.cpp.

◆ stdWidgetEventMask

const uint stdWidgetEventMask
Initial value:
=
(uint)(
KeyPressMask | KeyReleaseMask |
ButtonPressMask | ButtonReleaseMask |
KeymapStateMask |
ButtonMotionMask | PointerMotionMask |
EnterWindowMask | LeaveWindowMask |
FocusChangeMask |
ExposureMask |
PropertyChangeMask |
StructureNotifyMask
)
unsigned int uint
Definition: qglobal.h:996

Definition at line 196 of file qwidget_x11.cpp.