Qt 4.8
qwidget_x11.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qevent.h"
43 #include "qwidget.h"
44 #include "qdesktopwidget.h"
45 #include "qapplication.h"
46 #include "qapplication_p.h"
48 #include "qnamespace.h"
49 #include "qpainter.h"
50 #include "qbitmap.h"
51 #include "qlayout.h"
52 #include "qtextcodec.h"
53 #include "qelapsedtimer.h"
54 #include "qcursor.h"
55 #include "qstack.h"
56 #include "qcolormap.h"
57 #include "qdebug.h"
58 #include "qmenu.h"
59 #include "private/qmenu_p.h"
60 #include "private/qbackingstore_p.h"
61 #include "private/qwindowsurface_x11_p.h"
62 
63 //extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); //qapplication_x11.cpp
64 
65 #include <private/qpixmap_x11_p.h>
66 #include <private/qpaintengine_x11_p.h>
67 #include "qt_x11_p.h"
68 #include "qx11info_x11.h"
69 
70 #include <stdlib.h>
71 
72 //#define ALIEN_DEBUG
73 
74 // defined in qapplication_x11.cpp
75 //bool qt_wstate_iconified(WId);
76 //void qt_updated_rootinfo();
77 
78 
79 #if !defined(QT_NO_IM)
80 #include "qinputcontext.h"
81 #include "qinputcontextfactory.h"
82 #endif
83 
84 #include "qwidget_p.h"
85 
86 #define XCOORD_MAX 16383
87 #define WRECT_MAX 8191
88 
90 
91 extern bool qt_nograb();
92 
95 
97 void qt_net_update_user_time(QWidget *tlw, unsigned long timestamp);
98 
100 
101 extern void qt_net_update_user_time(QWidget *tlw, unsigned long timestamp);
102 
103 // MWM support
104 struct QtMWMHints {
108 };
109 
110 enum {
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 
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 
135 };
136 
137 
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 }
166 
167 static void SetMWMHints(Display *display, Window window, const QtMWMHints &mwmhints)
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 }
176 
177 // Returns true if we should set WM_TRANSIENT_FOR on \a w
178 static inline bool isTransient(const QWidget *w)
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 }
189 
190 static void do_size_hints(QWidget* widget, QWExtra *x);
191 
192 /*****************************************************************************
193  QWidget member functions
194  *****************************************************************************/
195 
196 const uint stdWidgetEventMask = // X event mask
197  (uint)(
198  KeyPressMask | KeyReleaseMask |
199  ButtonPressMask | ButtonReleaseMask |
200  KeymapStateMask |
201  ButtonMotionMask | PointerMotionMask |
202  EnterWindowMask | LeaveWindowMask |
203  FocusChangeMask |
204  ExposureMask |
205  PropertyChangeMask |
206  StructureNotifyMask
207  );
208 
209 const uint stdDesktopEventMask = // X event mask
210  (uint)(
211  KeymapStateMask |
212  EnterWindowMask | LeaveWindowMask |
213  PropertyChangeMask
214  );
215 
216 
217 /*
218  The qt_ functions below are implemented in qwidgetcreate_x11.cpp.
219 */
220 
221 Window qt_XCreateWindow(const QWidget *creator,
222  Display *display, Window parent,
223  int x, int y, uint w, uint h,
224  int borderwidth, int depth,
225  uint windowclass, Visual *visual,
226  ulong valuemask, XSetWindowAttributes *attributes);
227 Window qt_XCreateSimpleWindow(const QWidget *creator,
228  Display *display, Window parent,
229  int x, int y, uint w, uint h, int borderwidth,
230  ulong border, ulong background);
231 void qt_XDestroyWindow(const QWidget *destroyer,
233 
234 
235 static void qt_insert_sip(QWidget* scrolled_widget, int dx, int dy)
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 }
252 
253 static int qt_sip_count(QWidget* scrolled_widget)
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 }
265 
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 }
292 
302 void qt_x11_enforce_cursor(QWidget * w, bool force)
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 }
347 
349 {
350  qt_x11_enforce_cursor(w, false);
351 }
352 
353 void qt_x11_wait_for_window_manager(QWidget *w, bool sendPostedEvents)
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 }
407 
409 {
411 }
412 
413 void qt_change_net_wm_state(const QWidget* w, bool set, Atom one, Atom two = 0)
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 }
432 
434  const XWindowAttributes *att;
435 };
436 
437 void qt_x11_getX11InfoForWindow(QX11Info * xinfo, const XWindowAttributes &a)
438 {
440  att.att = &a;
441  qt_x11_getX11InfoForWindow(xinfo,att);
442 }
443 
444 
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 }
482 
483 void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
484 {
485  Q_Q(QWidget);
486  Qt::WindowType type = q->windowType();
487  Qt::WindowFlags &flags = data.window_flags;
489 
490  if (type == Qt::ToolTip)
492  if (type == Qt::Popup)
494 
495  bool topLevel = (flags & Qt::Window);
496  bool popup = (type == Qt::Popup);
497  bool desktop = (type == Qt::Desktop);
498  bool tool = (type == Qt::Tool || type == Qt::SplashScreen
499  || type == Qt::ToolTip || type == Qt::Drawer);
500 
501 #ifdef ALIEN_DEBUG
502  qDebug() << "QWidgetPrivate::create_sys START:" << q << "topLevel?" << topLevel << "WId:"
503  << window << "initializeWindow:" << initializeWindow << "destroyOldWindow" << destroyOldWindow;
504 #endif
505  if (topLevel) {
506  if (parentWidget) { // if our parent stays on top, so must we
507  QWidget *ptl = parentWidget->window();
508  if(ptl && (ptl->windowFlags() & Qt::WindowStaysOnTopHint))
509  flags |= Qt::WindowStaysOnTopHint;
510  }
511 
512  if (type == Qt::SplashScreen) {
513  if (X11->isSupportedByWM(ATOM(_NET_WM_WINDOW_TYPE_SPLASH))) {
515  } else {
517  }
518  }
519  // All these buttons depend on the system menu, so we enable it
520  if (flags & (Qt::WindowMinimizeButtonHint
523  flags |= Qt::WindowSystemMenuHint;
524  }
525 
526 
527  Window parentw, destroyw = 0;
528  WId id = 0;
529 
530  // always initialize
531  if (!window)
532  initializeWindow = true;
533 
534  QX11Info *parentXinfo = parentWidget ? &parentWidget->d_func()->xinfo : 0;
535 
536  if (desktop &&
538  qt_x11_create_desktop_on_screen != xinfo.screen()) {
539  // desktop on a certain screen other than the default requested
541  xinfo.setX11Data(xd);
542  } else if (parentXinfo && (parentXinfo->screen() != xinfo.screen()
543  || (parentXinfo->visual() != xinfo.visual()
544  && !q->inherits("QGLWidget"))))
545  {
546  // QGLWidgets have to be excluded here as they have a
547  // specially crafted QX11Info structure which can't be swapped
548  // out with the parent widgets QX11Info. The parent visual,
549  // for instance, might not even be GL capable.
550  xinfo = *parentXinfo;
551  }
552 
553  //get display, screen number, root window and desktop geometry for
554  //the current screen
555  Display *dpy = X11->display;
556  int scr = xinfo.screen();
557  Window root_win = RootWindow(dpy, scr);
558  int sw = DisplayWidth(dpy,scr);
559  int sh = DisplayHeight(dpy,scr);
560 
561  if (desktop) { // desktop widget
562  popup = false; // force these flags off
563  data.crect.setRect(0, 0, sw, sh);
564  } else if (topLevel && !q->testAttribute(Qt::WA_Resized)) {
565  QDesktopWidget *desktopWidget = qApp->desktop();
566  if (desktopWidget->isVirtualDesktop()) {
567  QRect r = desktopWidget->screenGeometry();
568  sw = r.width();
569  sh = r.height();
570  }
571 
572  int width = sw / 2;
573  int height = 4 * sh / 10;
574  if (extra) {
575  width = qMax(qMin(width, extra->maxw), extra->minw);
576  height = qMax(qMin(height, extra->maxh), extra->minh);
577  }
578  data.crect.setSize(QSize(width, height));
579  }
580 
581  parentw = topLevel ? root_win : parentWidget->effectiveWinId();
582 
583  XSetWindowAttributes wsa;
584 
585  if (window) { // override the old window
586  if (destroyOldWindow) {
587  if (topLevel)
588  X11->dndEnable(q, false);
589  destroyw = data.winid;
590  }
591  id = window;
592  setWinId(window);
593  XWindowAttributes a;
594  XGetWindowAttributes(dpy, window, &a);
595  data.crect.setRect(a.x, a.y, a.width, a.height);
596 
597  if (a.map_state == IsUnmapped)
598  q->setAttribute(Qt::WA_WState_Visible, false);
599  else
600  q->setAttribute(Qt::WA_WState_Visible);
601 
602  qt_x11_getX11InfoForWindow(&xinfo,a);
603 
604  } else if (desktop) { // desktop widget
605 #ifdef QWIDGET_EXTRA_DEBUG
606  qDebug() << "create desktop";
607 #endif
608  id = (WId)parentw; // id = root window
609 // QWidget *otherDesktop = find(id); // is there another desktop?
610 // if (otherDesktop && otherDesktop->testWFlags(Qt::WPaintDesktop)) {
611 // otherDesktop->d->setWinId(0); // remove id from widget mapper
612 // d->setWinId(id); // make sure otherDesktop is
613 // otherDesktop->d->setWinId(id); // found first
614 // } else {
615  setWinId(id);
616 // }
617  } else if (topLevel || q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) {
618 #ifdef QWIDGET_EXTRA_DEBUG
619  static int topLevels = 0;
620  static int children = 0;
621  if (parentw == root_win)
622  qDebug() << "create toplevel" << ++topLevels;
623  else
624  qDebug() << "create child" << ++children;
625 #endif
626  QRect safeRect = data.crect; //##### must handle huge sizes as well.... i.e. wrect
627  if (safeRect.width() < 1|| safeRect.height() < 1) {
628  if (topLevel) {
629  // top-levels must be at least 1x1
630  safeRect.setSize(safeRect.size().expandedTo(QSize(1, 1)));
631  } else {
632  // create it way off screen, and rely on
633  // setWSGeometry() to do the right thing with it later
634  safeRect = QRect(-1000,-1000,1,1);
635  }
636  }
637 #ifndef QT_NO_XRENDER
638  int screen = xinfo.screen();
639  if (topLevel && X11->use_xrender
640  && xinfo.depth() != 32 && X11->argbVisuals[screen]
641  && q->testAttribute(Qt::WA_TranslucentBackground))
642  {
643  QX11InfoData *xd = xinfo.getX11Data(true);
644 
645  xd->screen = screen;
646  xd->visual = X11->argbVisuals[screen];
647  xd->colormap = X11->argbColormaps[screen];
648  xd->depth = 32;
649  xd->defaultVisual = false;
650  xd->defaultColormap = false;
651  xd->cells = xd->visual->map_entries;
652  xinfo.setX11Data(xd);
653  }
654 #endif
655  if (xinfo.defaultVisual() && xinfo.defaultColormap()) {
656  id = (WId)qt_XCreateSimpleWindow(q, dpy, parentw,
657  safeRect.left(), safeRect.top(),
658  safeRect.width(), safeRect.height(),
659  0,
660  BlackPixel(dpy, xinfo.screen()),
661  WhitePixel(dpy, xinfo.screen()));
662  } else {
663  wsa.background_pixel = WhitePixel(dpy, xinfo.screen());
664  wsa.border_pixel = BlackPixel(dpy, xinfo.screen());
665  wsa.colormap = xinfo.colormap();
666  id = (WId)qt_XCreateWindow(q, dpy, parentw,
667  safeRect.left(), safeRect.top(),
668  safeRect.width(), safeRect.height(),
669  0, xinfo.depth(), InputOutput,
670  (Visual *) xinfo.visual(),
671  CWBackPixel|CWBorderPixel|CWColormap,
672  &wsa);
673  }
674 
675  setWinId(id); // set widget id/handle + hd
676  }
677 
678 #ifndef QT_NO_XRENDER
679  if (picture) {
680  XRenderFreePicture(X11->display, picture);
681  picture = 0;
682  }
683 
684  if (X11->use_xrender && !desktop && q->internalWinId()) {
685  XRenderPictFormat *format = XRenderFindVisualFormat(dpy, (Visual *) xinfo.visual());
686  if (format)
687  picture = XRenderCreatePicture(dpy, id, format, 0, 0);
688  }
689 #endif // QT_NO_XRENDER
690 
691  QtMWMHints mwmhints;
692  mwmhints.flags = 0L;
693  mwmhints.functions = 0L;
694  mwmhints.decorations = 0;
695  mwmhints.input_mode = 0L;
696  mwmhints.status = 0L;
697 
698  if (topLevel) {
699  ulong wsa_mask = 0;
700  if (type != Qt::SplashScreen) { // && customize) {
701  mwmhints.flags |= MWM_HINTS_DECORATIONS;
702 
703  bool customize = flags & Qt::CustomizeWindowHint;
704  if (!(flags & Qt::FramelessWindowHint) && !(customize && !(flags & Qt::WindowTitleHint))) {
705  mwmhints.decorations |= MWM_DECOR_BORDER;
706  mwmhints.decorations |= MWM_DECOR_RESIZEH;
707 
708  if (flags & Qt::WindowTitleHint)
709  mwmhints.decorations |= MWM_DECOR_TITLE;
710 
711  if (flags & Qt::WindowSystemMenuHint)
712  mwmhints.decorations |= MWM_DECOR_MENU;
713 
714  if (flags & Qt::WindowMinimizeButtonHint) {
715  mwmhints.decorations |= MWM_DECOR_MINIMIZE;
716  mwmhints.functions |= MWM_FUNC_MINIMIZE;
717  }
718 
719  if (flags & Qt::WindowMaximizeButtonHint) {
720  mwmhints.decorations |= MWM_DECOR_MAXIMIZE;
721  mwmhints.functions |= MWM_FUNC_MAXIMIZE;
722  }
723 
724  if (flags & Qt::WindowCloseButtonHint)
725  mwmhints.functions |= MWM_FUNC_CLOSE;
726  }
727  } else {
728  // if type == Qt::SplashScreen
729  mwmhints.decorations = MWM_DECOR_ALL;
730  }
731 
732  if (tool) {
733  wsa.save_under = True;
734  wsa_mask |= CWSaveUnder;
735  }
736 
737  if (flags & Qt::X11BypassWindowManagerHint) {
738  wsa.override_redirect = True;
739  wsa_mask |= CWOverrideRedirect;
740  }
741 
742  if (wsa_mask && initializeWindow) {
743  Q_ASSERT(id);
744  XChangeWindowAttributes(dpy, id, wsa_mask, &wsa);
745  }
746 
747  if (mwmhints.functions != 0) {
748  mwmhints.flags |= MWM_HINTS_FUNCTIONS;
750  } else {
751  mwmhints.functions = MWM_FUNC_ALL;
752  }
753 
754  if (!(flags & Qt::FramelessWindowHint)
755  && flags & Qt::CustomizeWindowHint
756  && flags & Qt::WindowTitleHint
757  && !(flags &
761  // a special case - only the titlebar without any button
762  mwmhints.flags = MWM_HINTS_FUNCTIONS;
764  mwmhints.decorations = 0;
765  }
766  }
767 
768  if (!initializeWindow) {
769  // do no initialization
770  } else if (popup) { // popup widget
771  // set EWMH window types
772  setNetWmWindowTypes();
773 
774  wsa.override_redirect = True;
775  wsa.save_under = True;
776  Q_ASSERT(id);
777  XChangeWindowAttributes(dpy, id, CWOverrideRedirect | CWSaveUnder,
778  &wsa);
779  } else if (topLevel && !desktop) { // top-level widget
780  if (!X11->wm_client_leader)
782 
783  // note: WM_TRANSIENT_FOR is set in QWidgetPrivate::show_sys()
784 
785  XSizeHints size_hints;
786  memset(&size_hints, 0, sizeof(size_hints));
787  size_hints.flags = USSize | PSize | PWinGravity;
788  size_hints.x = data.crect.left();
789  size_hints.y = data.crect.top();
790  size_hints.width = data.crect.width();
791  size_hints.height = data.crect.height();
792  size_hints.win_gravity =
793  QApplication::isRightToLeft() ? NorthEastGravity : NorthWestGravity;
794 
795  XWMHints wm_hints; // window manager hints
796  memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy
797  wm_hints.flags = InputHint | StateHint | WindowGroupHint;
798  wm_hints.input = q->testAttribute(Qt::WA_X11DoNotAcceptFocus) ? False : True;
799  wm_hints.initial_state = NormalState;
800  wm_hints.window_group = X11->wm_client_leader;
801 
802  XClassHint class_hint;
804  class_hint.res_name = appName.data(); // application name
805  class_hint.res_class = const_cast<char *>(QX11Info::appClass()); // application class
806 
807  XSetWMProperties(dpy, id, 0, 0,
808  qApp->d_func()->argv, qApp->d_func()->argc,
809  &size_hints, &wm_hints, &class_hint);
810 
811  XResizeWindow(dpy, id,
812  qBound(1, data.crect.width(), XCOORD_MAX),
813  qBound(1, data.crect.height(), XCOORD_MAX));
814  XStoreName(dpy, id, appName.data());
815  Atom protocols[5];
816  int n = 0;
817  protocols[n++] = ATOM(WM_DELETE_WINDOW); // support del window protocol
818  protocols[n++] = ATOM(WM_TAKE_FOCUS); // support take focus window protocol
819  protocols[n++] = ATOM(_NET_WM_PING); // support _NET_WM_PING protocol
820 #ifndef QT_NO_XSYNC
821  protocols[n++] = ATOM(_NET_WM_SYNC_REQUEST); // support _NET_WM_SYNC_REQUEST protocol
822 #endif // QT_NO_XSYNC
824  protocols[n++] = ATOM(_NET_WM_CONTEXT_HELP);
825  XSetWMProtocols(dpy, id, protocols, n);
826 
827  // set mwm hints
828  SetMWMHints(dpy, id, mwmhints);
829 
830  // set EWMH window types
831  setNetWmWindowTypes();
832 
833  // set _NET_WM_PID
834  long curr_pid = getpid();
835  XChangeProperty(dpy, id, ATOM(_NET_WM_PID), XA_CARDINAL, 32, PropModeReplace,
836  (unsigned char *) &curr_pid, 1);
837 
838  // when we create a toplevel widget, the frame strut should be dirty
839  data.fstrut_dirty = 1;
840 
841  // declare the widget's window role
842  if (QTLWExtra *topData = maybeTopData()) {
843  if (!topData->role.isEmpty()) {
844  QByteArray windowRole = topData->role.toUtf8();
845  XChangeProperty(dpy, id,
846  ATOM(WM_WINDOW_ROLE), XA_STRING, 8, PropModeReplace,
847  (unsigned char *)windowRole.constData(), windowRole.length());
848  }
849  }
850 
851  // set client leader property
852  XChangeProperty(dpy, id, ATOM(WM_CLIENT_LEADER),
853  XA_WINDOW, 32, PropModeReplace,
854  (unsigned char *)&X11->wm_client_leader, 1);
855  } else {
856  // non-toplevel widgets don't have a frame, so no need to
857  // update the strut
858  data.fstrut_dirty = 0;
859  }
860 
861  if (initializeWindow && q->internalWinId()) {
862  // don't erase when resizing
863  wsa.bit_gravity = QApplication::isRightToLeft() ? NorthEastGravity : NorthWestGravity;
864  Q_ASSERT(id);
865  XChangeWindowAttributes(dpy, id, CWBitGravity, &wsa);
866  }
867 
868  // set X11 event mask
869  if (desktop) {
870 // QWidget* main_desktop = find(id);
871 // if (main_desktop->testWFlags(Qt::WPaintDesktop))
872 // XSelectInput(dpy, id, stdDesktopEventMask | ExposureMask);
873 // else
874  XSelectInput(dpy, id, stdDesktopEventMask);
875  } else if (q->internalWinId()) {
876  XSelectInput(dpy, id, stdWidgetEventMask);
877 #if !defined (QT_NO_TABLET)
878  QTabletDeviceDataList *tablet_list = qt_tablet_devices();
879  if (X11->ptrXSelectExtensionEvent) {
880  for (int i = 0; i < tablet_list->size(); ++i) {
881  QTabletDeviceData tablet = tablet_list->at(i);
882  X11->ptrXSelectExtensionEvent(dpy, id, reinterpret_cast<XEventClass*>(tablet.eventList),
883  tablet.eventCount);
884  }
885  }
886 #endif
887  }
888 
889  if (desktop) {
890  q->setAttribute(Qt::WA_WState_Visible);
891  } else if (topLevel) { // set X cursor
892  if (initializeWindow) {
894 
895  if (QTLWExtra *topData = maybeTopData())
896  if (!topData->caption.isEmpty())
897  setWindowTitle_helper(topData->caption);
898 
899  //always enable dnd: it's not worth the effort to maintain the state
900  // NOTE: this always creates topData()
901  X11->dndEnable(q, true);
902 
903  if (maybeTopData() && maybeTopData()->opacity != 255)
904  q->setWindowOpacity(maybeTopData()->opacity/255.);
905 
906  }
907  } else if (q->internalWinId()) {
909  if (QWidget *p = q->parentWidget()) // reset the cursor on the native parent
911  }
912 
913  if (extra && !extra->mask.isEmpty() && q->internalWinId())
914  XShapeCombineRegion(X11->display, q->internalWinId(), ShapeBounding, 0, 0,
915  extra->mask.handle(), ShapeSet);
916 #ifndef QT_NO_IM
917  if (q->hasFocus() && q->testAttribute(Qt::WA_InputMethodEnabled)) {
918  QInputContext *inputContext = q->inputContext();
919  if (inputContext)
920  inputContext->setFocusWidget(q);
921  }
922 #endif
923  if (destroyw) {
924  qt_XDestroyWindow(q, dpy, destroyw);
925  if (QTLWExtra *topData = maybeTopData()) {
926 #ifndef QT_NO_XSYNC
927  if (topData->syncUpdateCounter)
928  XSyncDestroyCounter(dpy, topData->syncUpdateCounter);
929 #endif
930  // we destroyed our old window - reset the top-level state
931  createTLSysExtra();
932  }
933  }
934 
935  // newly created windows are positioned at the window system's
936  // (0,0) position. If the parent uses wrect mapping to expand the
937  // coordinate system, we must also adjust this widget's window
938  // system position
939  if (!topLevel && !parentWidget->data->wrect.topLeft().isNull())
940  setWSGeometry();
941  else if (topLevel && (data.crect.width() == 0 || data.crect.height() == 0))
942  q->setAttribute(Qt::WA_OutsideWSRange, true);
943 
944  if (!topLevel && q->testAttribute(Qt::WA_NativeWindow) && q->testAttribute(Qt::WA_Mapped)) {
945  Q_ASSERT(q->internalWinId());
946  XMapWindow(X11->display, q->internalWinId());
947  // Ensure that mapped alien widgets are flushed immediately when re-created as native widgets.
948  if (QWindowSurface *surface = q->windowSurface())
949  surface->flush(q, q->rect(), q->mapTo(surface->window(), QPoint()));
950  }
951 
952 #ifdef ALIEN_DEBUG
953  qDebug() << "QWidgetPrivate::create_sys END:" << q;
954 #endif
955 }
956 
957 static void qt_x11_recreateWidget(QWidget *widget)
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 }
985 
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 }
998 
1000 {
1001 #ifndef QT_NO_XRENDER
1002  Q_Q(QWidget);
1003  if (!q->testAttribute(Qt::WA_WState_Created) || !q->testAttribute(Qt::WA_TranslucentBackground))
1004  return;
1005 
1006  bool topLevel = (data.window_flags & Qt::Window);
1007  int screen = xinfo.screen();
1008  if (topLevel && X11->use_xrender
1009  && X11->argbVisuals[screen] && xinfo.depth() != 32)
1010  {
1012  }
1013 #endif
1014 }
1015 
1016 /*
1017  Returns true if the background is inherited; otherwise returns
1018  false.
1019 
1020  Mainly used in the paintOnScreen case.
1021 */
1023 {
1024  Q_Q(const QWidget);
1025 
1026  // windows do not inherit their background
1027  if (q->isWindow() || q->windowType() == Qt::SubWindow)
1028  return false;
1029 
1030  if (q->testAttribute(Qt::WA_NoSystemBackground) || q->testAttribute(Qt::WA_OpaquePaintEvent))
1031  return false;
1032 
1033  const QPalette &pal = q->palette();
1034  QPalette::ColorRole bg = q->backgroundRole();
1035  QBrush brush = pal.brush(bg);
1036 
1037  // non opaque brushes leaves us no choice, we must inherit
1038  if (!q->autoFillBackground() || !brush.isOpaque())
1039  return true;
1040 
1041  if (brush.style() == Qt::SolidPattern) {
1042  // the background is just a solid color. If there is no
1043  // propagated contents, then we claim as performance
1044  // optimization that it was not inheritet. This is the normal
1045  // case in standard Windows or Motif style.
1046  const QWidget *w = q->parentWidget();
1047  if (!w->d_func()->isBackgroundInherited())
1048  return false;
1049  }
1050 
1051  return true;
1052 }
1053 
1054 void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
1055 {
1056  Q_D(QWidget);
1057  d->aboutToDestroy();
1058  if (!isWindow() && parentWidget())
1059  parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));
1060  d->deactivateWidgetCleanup();
1061  if (testAttribute(Qt::WA_WState_Created)) {
1062  setAttribute(Qt::WA_WState_Created, false);
1063  QObjectList childList = children();
1064  for (int i = 0; i < childList.size(); ++i) { // destroy all widget children
1065  register QObject *obj = childList.at(i);
1066  if (obj->isWidgetType())
1067  static_cast<QWidget*>(obj)->destroy(destroySubWindows,
1068  destroySubWindows);
1069  }
1070  if (QWidgetPrivate::mouseGrabber == this)
1071  releaseMouse();
1072  if (QWidgetPrivate::keyboardGrabber == this)
1073  releaseKeyboard();
1074  if (isWindow())
1075  X11->deferred_map.removeAll(this);
1076  if (isModal()) {
1077  // just be sure we leave modal
1079  }
1080  else if ((windowType() == Qt::Popup))
1081  qApp->d_func()->closePopup(this);
1082 
1083 #ifndef QT_NO_XRENDER
1084  if (d->picture) {
1085  if (destroyWindow)
1086  XRenderFreePicture(X11->display, d->picture);
1087  d->picture = 0;
1088  }
1089 #endif // QT_NO_XRENDER
1090 
1091  // delete the _NET_WM_USER_TIME_WINDOW
1093 
1094  if ((windowType() == Qt::Desktop)) {
1095  if (acceptDrops())
1096  X11->dndEnable(this, false);
1097  } else {
1098  if (isWindow())
1099  X11->dndEnable(this, false);
1100  if (destroyWindow)
1101  qt_XDestroyWindow(this, X11->display, data->winid);
1102  }
1103  QT_TRY {
1104  d->setWinId(0);
1105  } QT_CATCH (const std::bad_alloc &) {
1106  // swallow - destructors must not throw
1107  }
1108 
1109  extern void qPRCleanup(QWidget *widget); // from qapplication_x11.cpp
1110  if (testAttribute(Qt::WA_WState_Reparented))
1111  qPRCleanup(this);
1112 #ifndef QT_NO_IM
1113  if(d->ic) {
1114  delete d->ic;
1115  } else {
1116  // release previous focus information participating with
1117  // preedit preservation of qic
1119  if (qic)
1120  qic->widgetDestroyed(this);
1121  }
1122 #endif
1123  }
1124 }
1125 
1126 void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
1127 {
1128  Q_Q(QWidget);
1129 #ifdef ALIEN_DEBUG
1130  qDebug() << "QWidgetPrivate::setParent_sys START" << q << "parent:" << parent;
1131 #endif
1132  QX11Info old_xinfo = xinfo;
1133  if (parent && parent->windowType() == Qt::Desktop) {
1134  // make sure the widget is created on the same screen as the
1135  // programmer specified desktop widget
1136  xinfo = parent->d_func()->xinfo;
1137  parent = 0;
1138  }
1139 
1140  QTLWExtra *topData = maybeTopData();
1141  bool wasCreated = q->testAttribute(Qt::WA_WState_Created);
1142  if (q->isVisible() && q->parentWidget() && parent != q->parentWidget())
1143  q->parentWidget()->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
1144  extern void qPRCreate(const QWidget *, Window);
1145 #ifndef QT_NO_CURSOR
1146  QCursor oldcurs;
1147 #endif
1148 
1149  // dnd unregister (we will register again below)
1150  if (q->testAttribute(Qt::WA_DropSiteRegistered))
1151  q->setAttribute(Qt::WA_DropSiteRegistered, false);
1152 
1153  // if we are a top then remove our dnd prop for now
1154  // it will get rest later
1155  if (q->isWindow() && wasCreated)
1156  X11->dndEnable(q, false);
1157 
1158  if (topData)
1160 
1161 // QWidget *oldparent = q->parentWidget();
1162  WId old_winid = wasCreated ? data.winid : 0;
1163  if ((q->windowType() == Qt::Desktop))
1164  old_winid = 0;
1165  setWinId(0);
1166 
1167 #ifndef QT_NO_XRENDER
1168  if (picture) {
1169  XRenderFreePicture(X11->display, picture);
1170  picture = 0;
1171  }
1172 #endif
1173 
1174  // hide and reparent our own window away. Otherwise we might get
1175  // destroyed when emitting the child remove event below. See QWorkspace.
1176  if (wasCreated && old_winid) {
1177  XUnmapWindow(X11->display, old_winid);
1178  if (!old_xinfo.screen() != xinfo.screen())
1179  XReparentWindow(X11->display, old_winid, RootWindow(X11->display, xinfo.screen()), 0, 0);
1180  }
1181  if (topData) {
1182  topData->parentWinId = 0;
1183  // zero the frame strut and mark it dirty
1184  topData->frameStrut.setCoords(0, 0, 0, 0);
1185 
1186  // reparenting from top-level, make sure show() works again
1187  topData->waitingForMapNotify = 0;
1188  topData->validWMState = 0;
1189  }
1190  data.fstrut_dirty = (!parent || (f & Qt::Window)); // toplevels get a dirty framestrut
1191 
1193  bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide);
1194 
1195  data.window_flags = f;
1196  q->setAttribute(Qt::WA_WState_Created, false);
1197  q->setAttribute(Qt::WA_WState_Visible, false);
1198  q->setAttribute(Qt::WA_WState_Hidden, false);
1199  adjustFlags(data.window_flags, q);
1200  // keep compatibility with previous versions, we need to preserve the created state
1201  // (but we recreate the winId for the widget being reparented, again for compatibility)
1202  if (wasCreated)
1203  createWinId();
1204  if (q->isWindow() || (!parent || parent->isVisible()) || explicitlyHidden)
1205  q->setAttribute(Qt::WA_WState_Hidden);
1206  q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden);
1207 
1208  if (wasCreated) {
1209  QObjectList chlist = q->children();
1210  for (int i = 0; i < chlist.size(); ++i) { // reparent children
1211  QObject *obj = chlist.at(i);
1212  if (obj->isWidgetType()) {
1213  QWidget *w = (QWidget *)obj;
1215  continue;
1216  if (xinfo.screen() != w->d_func()->xinfo.screen()) {
1217  // ### force setParent() to not shortcut out (because
1218  // ### we're setting the parent to the current parent)
1219  // ### setParent will add child back to the list
1220  // ### of children so we need to make sure the
1221  // ### widget won't be added twice.
1222  w->d_func()->parent = 0;
1223  this->children.removeOne(w);
1224  w->setParent(q);
1225  } else if (!w->isWindow()) {
1226  w->d_func()->invalidateBuffer(w->rect());
1227  if (w->internalWinId()) {
1229  QWidget *nativeParentWidget = w->nativeParentWidget();
1230  // Qt::WA_NativeWindow ensures that we always have a nativeParentWidget
1231  Q_ASSERT(nativeParentWidget != 0);
1232  QPoint p = w->mapTo(nativeParentWidget, QPoint());
1233  XReparentWindow(X11->display,
1234  w->internalWinId(),
1235  nativeParentWidget->internalWinId(),
1236  p.x(), p.y());
1237  } else {
1238  w->d_func()->setParent_sys(q, w->data->window_flags);
1239  }
1240  }
1241  } else if (isTransient(w)) {
1242  /*
1243  when reparenting toplevel windows with toplevel-transient children,
1244  we need to make sure that the window manager gets the updated
1245  WM_TRANSIENT_FOR information... unfortunately, some window managers
1246  don't handle changing WM_TRANSIENT_FOR before the toplevel window is
1247  visible, so we unmap and remap all toplevel-transient children *after*
1248  the toplevel parent has been mapped. thankfully, this is easy in Qt :)
1249 
1250  note that the WM_TRANSIENT_FOR hint is actually updated in
1251  QWidgetPrivate::show_sys()
1252  */
1253  if (w->internalWinId())
1254  XUnmapWindow(X11->display, w->internalWinId());
1256  }
1257  }
1258  }
1259  qPRCreate(q, old_winid);
1260  updateSystemBackground();
1261 
1262  if (old_winid) {
1263  Window *cmwret;
1264  int count;
1265  if (XGetWMColormapWindows(X11->display, old_winid, &cmwret, &count)) {
1266  Window *cmw;
1267  int cmw_size = sizeof(Window)*count;
1268  cmw = new Window[count];
1269  memcpy((char *)cmw, (char *)cmwret, cmw_size);
1270  XFree((char *)cmwret);
1271  int i;
1272  for (i=0; i<count; i++) {
1273  if (cmw[i] == old_winid) {
1274  cmw[i] = q->internalWinId();
1275  break;
1276  }
1277  }
1278  int top_count;
1279  if (XGetWMColormapWindows(X11->display, q->window()->internalWinId(),
1280  &cmwret, &top_count))
1281  {
1282  Window *merged_cmw = new Window[count + top_count];
1283  memcpy((char *)merged_cmw, (char *)cmw, cmw_size);
1284  memcpy((char *)merged_cmw + cmw_size, (char *)cmwret, sizeof(Window)*top_count);
1285  delete [] cmw;
1286  XFree((char *)cmwret);
1287  cmw = merged_cmw;
1288  count += top_count;
1289  }
1290 
1291  XSetWMColormapWindows(X11->display, q->window()->internalWinId(), cmw, count);
1292  delete [] cmw;
1293  }
1294 
1295  qt_XDestroyWindow(q, X11->display, old_winid);
1296  }
1297  }
1298 
1299  // check if we need to register our dropsite
1300  if (q->testAttribute(Qt::WA_AcceptDrops)
1301  || (!q->isWindow() && q->parentWidget() && q->parentWidget()->testAttribute(Qt::WA_DropSiteRegistered))) {
1302  q->setAttribute(Qt::WA_DropSiteRegistered, true);
1303  }
1304 #if !defined(QT_NO_IM)
1305  ic = 0;
1306 #endif
1307  invalidateBuffer(q->rect());
1308 #ifdef ALIEN_DEBUG
1309  qDebug() << "QWidgetPrivate::setParent_sys END" << q;
1310 #endif
1311 }
1312 
1314 {
1315  Q_Q(const QWidget);
1316  if (!q->testAttribute(Qt::WA_WState_Created) || !q->internalWinId()) {
1317  QPoint p = pos + q->data->crect.topLeft();
1318  //cannot trust that !isWindow() implies parentWidget() before create
1319  return (q->isWindow() || !q->parentWidget()) ? p : q->parentWidget()->d_func()->mapToGlobal(p);
1320  }
1321  int x, y;
1322  Window child;
1323  QPoint p = mapToWS(pos);
1324  XTranslateCoordinates(X11->display, q->internalWinId(),
1325  QApplication::desktop()->screen(xinfo.screen())->internalWinId(),
1326  p.x(), p.y(), &x, &y, &child);
1327  return QPoint(x, y);
1328 }
1329 
1331 {
1332  Q_Q(const QWidget);
1333  if (!q->testAttribute(Qt::WA_WState_Created) || !q->internalWinId()) {
1334  //cannot trust that !isWindow() implies parentWidget() before create
1335  QPoint p = (q->isWindow() || !q->parentWidget()) ? pos : q->parentWidget()->d_func()->mapFromGlobal(pos);
1336  return p - q->data->crect.topLeft();
1337  }
1338  int x, y;
1339  Window child;
1340  XTranslateCoordinates(X11->display,
1341  QApplication::desktop()->screen(xinfo.screen())->internalWinId(),
1342  q->internalWinId(), pos.x(), pos.y(), &x, &y, &child);
1343  return mapFromWS(QPoint(x, y));
1344 }
1345 
1346 QPoint QWidget::mapToGlobal(const QPoint &pos) const
1347 {
1348  Q_D(const QWidget);
1349  return d->mapToGlobal(pos);
1350 }
1351 
1352 QPoint QWidget::mapFromGlobal(const QPoint &pos) const
1353 {
1354  Q_D(const QWidget);
1355  return d->mapFromGlobal(pos);
1356 }
1357 
1359 {
1360  Q_Q(QWidget);
1361  if (!q->testAttribute(Qt::WA_WState_Created) || !q->internalWinId())
1362  return;
1363  QBrush brush = q->palette().brush(QPalette::Active, q->backgroundRole());
1364  Qt::WindowType type = q->windowType();
1365  if (brush.style() == Qt::NoBrush
1366  || q->testAttribute(Qt::WA_NoSystemBackground)
1367  || q->testAttribute(Qt::WA_UpdatesDisabled)
1368  || type == Qt::Popup || type == Qt::ToolTip) {
1370  && q->testAttribute(Qt::WA_TranslucentBackground)
1371  && !(q->parent()))
1372  XSetWindowBackground(X11->display, q->internalWinId(),
1373  QColormap::instance(xinfo.screen()).pixel(Qt::transparent));
1374  else
1375  XSetWindowBackgroundPixmap(X11->display, q->internalWinId(), XNone);
1376  }
1377  else if (brush.style() == Qt::SolidPattern && brush.isOpaque())
1378  XSetWindowBackground(X11->display, q->internalWinId(),
1379  QColormap::instance(xinfo.screen()).pixel(brush.color()));
1380  else if (isBackgroundInherited())
1381  XSetWindowBackgroundPixmap(X11->display, q->internalWinId(), ParentRelative);
1382  else if (brush.style() == Qt::TexturePattern) {
1383  extern QPixmap qt_toX11Pixmap(const QPixmap &pixmap); // qpixmap_x11.cpp
1384  XSetWindowBackgroundPixmap(X11->display, q->internalWinId(),
1385  static_cast<QX11PixmapData*>(qt_toX11Pixmap(brush.texture()).data.data())->x11ConvertToDefaultDepth());
1386  } else
1387  XSetWindowBackground(X11->display, q->internalWinId(),
1388  QColormap::instance(xinfo.screen()).pixel(brush.color()));
1389 }
1390 
1391 #ifndef QT_NO_CURSOR
1393 {
1394  Q_Q(QWidget);
1396  XFlush(X11->display);
1397 }
1398 
1400 {
1401  Q_Q(QWidget);
1403  XFlush(X11->display);
1404 }
1405 #endif
1406 
1407 static XTextProperty*
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 }
1454 
1455 void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
1456 {
1457  Q_Q(QWidget);
1458  Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
1459  if (!q->internalWinId())
1460  return;
1461  XSetWMName(X11->display, q->internalWinId(), qstring_to_xtp(caption));
1462 
1463  QByteArray net_wm_name = caption.toUtf8();
1464  XChangeProperty(X11->display, q->internalWinId(), ATOM(_NET_WM_NAME), ATOM(UTF8_STRING), 8,
1465  PropModeReplace, (unsigned char *)net_wm_name.data(), net_wm_name.size());
1466 }
1467 
1468 void QWidgetPrivate::setWindowIcon_sys(bool forceReset)
1469 {
1470  Q_Q(QWidget);
1471  if (!q->testAttribute(Qt::WA_WState_Created))
1472  return;
1473  QTLWExtra *topData = this->topData();
1474  if (topData->iconPixmap && !forceReset)
1475  // already been set
1476  return;
1477 
1478  // preparing images to set the _NET_WM_ICON property
1479  QIcon icon = q->windowIcon();
1480  QVector<long> icon_data;
1481  Qt::HANDLE pixmap_handle = 0;
1482  if (!icon.isNull()) {
1483  QList<QSize> availableSizes = icon.availableSizes();
1484  if(availableSizes.isEmpty()) {
1485  // try to use default sizes since the icon can be a scalable image like svg.
1486  availableSizes.push_back(QSize(16,16));
1487  availableSizes.push_back(QSize(32,32));
1488  availableSizes.push_back(QSize(64,64));
1489  availableSizes.push_back(QSize(128,128));
1490  }
1491  for(int i = 0; i < availableSizes.size(); ++i) {
1492  QSize size = availableSizes.at(i);
1493  QPixmap pixmap = icon.pixmap(size);
1494  if (!pixmap.isNull()) {
1496  int pos = icon_data.size();
1497  icon_data.resize(pos + 2 + image.width()*image.height());
1498  icon_data[pos++] = image.width();
1499  icon_data[pos++] = image.height();
1500  if (sizeof(long) == sizeof(quint32)) {
1501  memcpy(icon_data.data() + pos, image.scanLine(0), image.byteCount());
1502  } else {
1503  for (int y = 0; y < image.height(); ++y) {
1504  uint *scanLine = reinterpret_cast<uint *>(image.scanLine(y));
1505  for (int x = 0; x < image.width(); ++x)
1506  icon_data[pos + y*image.width() + x] = scanLine[x];
1507  }
1508  }
1509  }
1510  }
1511  if (!icon_data.isEmpty()) {
1512  extern QPixmap qt_toX11Pixmap(const QPixmap &pixmap);
1513  /*
1514  if the app is running on an unknown desktop, or it is not
1515  using the default visual, convert the icon to 1bpp as stated
1516  in the ICCCM section 4.1.2.4; otherwise, create the icon pixmap
1517  in the default depth (even though this violates the ICCCM)
1518  */
1519  if (X11->desktopEnvironment == DE_UNKNOWN
1520  || !QX11Info::appDefaultVisual(xinfo.screen())
1521  || !QX11Info::appDefaultColormap(xinfo.screen())) {
1522  // unknown DE or non-default visual/colormap, use 1bpp bitmap
1523  if (!forceReset || !topData->iconPixmap)
1524  topData->iconPixmap = new QPixmap(qt_toX11Pixmap(QBitmap(icon.pixmap(QSize(64,64)))));
1525  pixmap_handle = topData->iconPixmap->handle();
1526  } else {
1527  // default depth, use a normal pixmap (even though this
1528  // violates the ICCCM), since this works on all DEs known to Qt
1529  if (!forceReset || !topData->iconPixmap)
1530  topData->iconPixmap = new QPixmap(qt_toX11Pixmap(icon.pixmap(QSize(64,64))));
1531  pixmap_handle = static_cast<QX11PixmapData*>(topData->iconPixmap->data.data())->x11ConvertToDefaultDepth();
1532  }
1533  }
1534  }
1535 
1536  if (!q->internalWinId())
1537  return;
1538 
1539  if (!icon_data.isEmpty()) {
1540  XChangeProperty(X11->display, q->internalWinId(), ATOM(_NET_WM_ICON), XA_CARDINAL, 32,
1541  PropModeReplace, (unsigned char *) icon_data.data(),
1542  icon_data.size());
1543  } else {
1544  XDeleteProperty(X11->display, q->internalWinId(), ATOM(_NET_WM_ICON));
1545  }
1546 
1547  XWMHints *h = XGetWMHints(X11->display, q->internalWinId());
1548  XWMHints wm_hints;
1549  if (!h) {
1550  memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy
1551  h = &wm_hints;
1552  }
1553 
1554  if (pixmap_handle) {
1555  h->icon_pixmap = pixmap_handle;
1556  h->flags |= IconPixmapHint;
1557  } else {
1558  h->icon_pixmap = 0;
1559  h->flags &= ~(IconPixmapHint | IconMaskHint);
1560  }
1561 
1562  XSetWMHints(X11->display, q->internalWinId(), h);
1563  if (h != &wm_hints)
1564  XFree((char *)h);
1565 }
1566 
1567 void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
1568 {
1569  Q_Q(QWidget);
1570  if (!q->internalWinId())
1571  return;
1572  Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
1573  XSetWMIconName(X11->display, q->internalWinId(), qstring_to_xtp(iconText));
1574 
1575  QByteArray icon_name = iconText.toUtf8();
1576  XChangeProperty(X11->display, q->internalWinId(), ATOM(_NET_WM_ICON_NAME), ATOM(UTF8_STRING), 8,
1577  PropModeReplace, (unsigned char *) icon_name.constData(), icon_name.size());
1578 }
1579 
1580 
1581 void QWidget::grabMouse()
1582 {
1583  if (isVisible() && !qt_nograb()) {
1584  if (QWidgetPrivate::mouseGrabber && QWidgetPrivate::mouseGrabber != this)
1585  QWidgetPrivate::mouseGrabber->releaseMouse();
1586  Q_ASSERT(testAttribute(Qt::WA_WState_Created));
1587 #ifndef QT_NO_DEBUG
1588  int status =
1589 #endif
1590  XGrabPointer(X11->display, effectiveWinId(), False,
1591  (uint)(ButtonPressMask | ButtonReleaseMask |
1592  PointerMotionMask | EnterWindowMask |
1593  LeaveWindowMask),
1594  GrabModeAsync, GrabModeAsync,
1595  XNone, XNone, X11->time);
1596 #ifndef QT_NO_DEBUG
1597  if (status) {
1598  const char *s =
1599  status == GrabNotViewable ? "\"GrabNotViewable\"" :
1600  status == AlreadyGrabbed ? "\"AlreadyGrabbed\"" :
1601  status == GrabFrozen ? "\"GrabFrozen\"" :
1602  status == GrabInvalidTime ? "\"GrabInvalidTime\"" :
1603  "<?>";
1604  qWarning("QWidget::grabMouse: Failed with %s", s);
1605  }
1606 #endif
1607  QWidgetPrivate::mouseGrabber = this;
1608  }
1609 }
1610 
1611 
1612 #ifndef QT_NO_CURSOR
1613 void QWidget::grabMouse(const QCursor &cursor)
1614 {
1615  if (!qt_nograb()) {
1616  if (QWidgetPrivate::mouseGrabber && QWidgetPrivate::mouseGrabber != this)
1617  QWidgetPrivate::mouseGrabber->releaseMouse();
1618  Q_ASSERT(testAttribute(Qt::WA_WState_Created));
1619 #ifndef QT_NO_DEBUG
1620  int status =
1621 #endif
1622  XGrabPointer(X11->display, effectiveWinId(), False,
1623  (uint)(ButtonPressMask | ButtonReleaseMask |
1624  PointerMotionMask | EnterWindowMask | LeaveWindowMask),
1625  GrabModeAsync, GrabModeAsync,
1626  XNone, cursor.handle(), X11->time);
1627 #ifndef QT_NO_DEBUG
1628  if (status) {
1629  const char *s =
1630  status == GrabNotViewable ? "\"GrabNotViewable\"" :
1631  status == AlreadyGrabbed ? "\"AlreadyGrabbed\"" :
1632  status == GrabFrozen ? "\"GrabFrozen\"" :
1633  status == GrabInvalidTime ? "\"GrabInvalidTime\"" :
1634  "<?>";
1635  qWarning("QWidget::grabMouse: Failed with %s", s);
1636  }
1637 #endif
1638  QWidgetPrivate::mouseGrabber = this;
1639  }
1640 }
1641 #endif
1642 
1643 
1644 void QWidget::releaseMouse()
1645 {
1646  if (!qt_nograb() && QWidgetPrivate::mouseGrabber == this) {
1647  XUngrabPointer(X11->display, X11->time);
1648  XFlush(X11->display);
1649  QWidgetPrivate::mouseGrabber = 0;
1650  }
1651 }
1652 
1653 
1654 void QWidget::grabKeyboard()
1655 {
1656  if (!qt_nograb()) {
1657  if (QWidgetPrivate::keyboardGrabber && QWidgetPrivate::keyboardGrabber != this)
1658  QWidgetPrivate::keyboardGrabber->releaseKeyboard();
1659  XGrabKeyboard(X11->display, effectiveWinId(), False, GrabModeAsync, GrabModeAsync,
1660  X11->time);
1661  QWidgetPrivate::keyboardGrabber = this;
1662  }
1663 }
1664 
1665 
1667 {
1668  if (!qt_nograb() && QWidgetPrivate::keyboardGrabber == this) {
1669  XUngrabKeyboard(X11->display, X11->time);
1670  QWidgetPrivate::keyboardGrabber = 0;
1671  }
1672 }
1673 
1674 
1676 {
1678 }
1679 
1680 
1682 {
1684 }
1685 
1687 {
1688  QWidget *tlw = window();
1689  if (tlw->isVisible() && !tlw->d_func()->topData()->embedded && !X11->deferred_map.contains(tlw)) {
1690  if (X11->userTime == 0)
1691  X11->userTime = X11->time;
1692  qt_net_update_user_time(tlw, X11->userTime);
1693 
1694  if (X11->isSupportedByWM(ATOM(_NET_ACTIVE_WINDOW))
1696  XEvent e;
1697  e.xclient.type = ClientMessage;
1698  e.xclient.message_type = ATOM(_NET_ACTIVE_WINDOW);
1699  e.xclient.display = X11->display;
1700  e.xclient.window = tlw->internalWinId();
1701  e.xclient.format = 32;
1702  e.xclient.data.l[0] = 1; // 1 == application
1703  e.xclient.data.l[1] = X11->userTime;
1704  if (QWidget *aw = QApplication::activeWindow())
1705  e.xclient.data.l[2] = aw->internalWinId();
1706  else
1707  e.xclient.data.l[2] = XNone;
1708  e.xclient.data.l[3] = 0;
1709  e.xclient.data.l[4] = 0;
1710  XSendEvent(X11->display, RootWindow(X11->display, tlw->x11Info().screen()),
1711  false, SubstructureNotifyMask | SubstructureRedirectMask, &e);
1712  } else {
1713  if (!qt_widget_private(tlw)->topData()->waitingForMapNotify)
1714  XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time);
1715  }
1716  }
1717 }
1718 
1719 void QWidget::setWindowState(Qt::WindowStates newstate)
1720 {
1721  Q_D(QWidget);
1722  bool needShow = false;
1723  Qt::WindowStates oldstate = windowState();
1724  if (oldstate == newstate)
1725  return;
1726  if (isWindow()) {
1727  // Ensure the initial size is valid, since we store it as normalGeometry below.
1728  if (!testAttribute(Qt::WA_Resized) && !isVisible())
1729  adjustSize();
1730 
1731  QTLWExtra *top = d->topData();
1732 
1733  if ((oldstate & Qt::WindowMaximized) != (newstate & Qt::WindowMaximized)) {
1734  if (X11->isSupportedByWM(ATOM(_NET_WM_STATE_MAXIMIZED_HORZ))
1735  && X11->isSupportedByWM(ATOM(_NET_WM_STATE_MAXIMIZED_VERT))) {
1736  if ((newstate & Qt::WindowMaximized) && !(oldstate & Qt::WindowFullScreen))
1737  top->normalGeometry = geometry();
1738  qt_change_net_wm_state(this, (newstate & Qt::WindowMaximized),
1741  } else if (! (newstate & Qt::WindowFullScreen)) {
1742  if (newstate & Qt::WindowMaximized) {
1743  // save original geometry
1744  const QRect normalGeometry = geometry();
1745 
1746  if (isVisible()) {
1747  data->fstrut_dirty = true;
1748  const QRect maxRect = QApplication::desktop()->availableGeometry(this);
1749  const QRect r = top->normalGeometry;
1750  const QRect fs = d->frameStrut();
1751  setGeometry(maxRect.x() + fs.left(),
1752  maxRect.y() + fs.top(),
1753  maxRect.width() - fs.left() - fs.right(),
1754  maxRect.height() - fs.top() - fs.bottom());
1755  top->normalGeometry = r;
1756  }
1757 
1758  if (top->normalGeometry.width() < 0)
1759  top->normalGeometry = normalGeometry;
1760  } else {
1761  // restore original geometry
1762  setGeometry(top->normalGeometry);
1763  }
1764  }
1765  }
1766 
1767  if ((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen)) {
1768  if (X11->isSupportedByWM(ATOM(_NET_WM_STATE_FULLSCREEN))) {
1769  if (newstate & Qt::WindowFullScreen) {
1770  top->normalGeometry = geometry();
1771  top->fullScreenOffset = d->frameStrut().topLeft();
1772  }
1773  qt_change_net_wm_state(this, (newstate & Qt::WindowFullScreen),
1775  } else {
1776  needShow = isVisible();
1777 
1778  if (newstate & Qt::WindowFullScreen) {
1779  data->fstrut_dirty = true;
1780  const QRect normalGeometry = geometry();
1781  const QPoint fullScreenOffset = d->frameStrut().topLeft();
1782 
1783  top->savedFlags = windowFlags();
1784  setParent(0, Qt::Window | Qt::FramelessWindowHint);
1785  const QRect r = top->normalGeometry;
1786  setGeometry(qApp->desktop()->screenGeometry(this));
1787  top->normalGeometry = r;
1788 
1789  if (top->normalGeometry.width() < 0) {
1790  top->normalGeometry = normalGeometry;
1791  top->fullScreenOffset = fullScreenOffset;
1792  }
1793  } else {
1794  setParent(0, top->savedFlags);
1795 
1796  if (newstate & Qt::WindowMaximized) {
1797  // from fullscreen to maximized
1798  data->fstrut_dirty = true;
1799  const QRect maxRect = QApplication::desktop()->availableGeometry(this);
1800  const QRect r = top->normalGeometry;
1801  const QRect fs = d->frameStrut();
1802  setGeometry(maxRect.x() + fs.left(),
1803  maxRect.y() + fs.top(),
1804  maxRect.width() - fs.left() - fs.right(),
1805  maxRect.height() - fs.top() - fs.bottom());
1806  top->normalGeometry = r;
1807  } else {
1808  // restore original geometry
1809  setGeometry(top->normalGeometry.adjusted(-top->fullScreenOffset.x(),
1810  -top->fullScreenOffset.y(),
1811  -top->fullScreenOffset.x(),
1812  -top->fullScreenOffset.y()));
1813  }
1814  }
1815  }
1816  }
1817 
1818  createWinId();
1819  Q_ASSERT(testAttribute(Qt::WA_WState_Created));
1820  if ((oldstate & Qt::WindowMinimized) != (newstate & Qt::WindowMinimized)) {
1821  if (isVisible()) {
1822  if (newstate & Qt::WindowMinimized) {
1823  XEvent e;
1824  e.xclient.type = ClientMessage;
1825  e.xclient.message_type = ATOM(WM_CHANGE_STATE);
1826  e.xclient.display = X11->display;
1827  e.xclient.window = data->winid;
1828  e.xclient.format = 32;
1829  e.xclient.data.l[0] = IconicState;
1830  e.xclient.data.l[1] = 0;
1831  e.xclient.data.l[2] = 0;
1832  e.xclient.data.l[3] = 0;
1833  e.xclient.data.l[4] = 0;
1834  XSendEvent(X11->display,
1835  RootWindow(X11->display,d->xinfo.screen()),
1836  False, (SubstructureNotifyMask|SubstructureRedirectMask), &e);
1837  } else {
1838  setAttribute(Qt::WA_Mapped);
1839  XMapWindow(X11->display, effectiveWinId());
1840  }
1841  }
1842 
1843  needShow = false;
1844  }
1845  }
1846 
1847  data->window_state = newstate;
1848 
1849  if (needShow)
1850  show();
1851 
1852  if (newstate & Qt::WindowActive)
1853  activateWindow();
1854 
1855  QWindowStateChangeEvent e(oldstate);
1856  QApplication::sendEvent(this, &e);
1857 }
1858 
1868 {
1869  Q_Q(QWidget);
1870  Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
1871 
1872  if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
1873  invalidateBuffer(q->rect());
1874  q->setAttribute(Qt::WA_Mapped);
1875  if (QTLWExtra *tlwExtra = maybeTopData())
1876  tlwExtra->waitingForMapNotify = 0;
1877  return;
1878  }
1879 
1880  if (q->isWindow()) {
1881  XWMHints *h = XGetWMHints(X11->display, q->internalWinId());
1882  XWMHints wm_hints;
1883  bool got_hints = h != 0;
1884  if (!got_hints) {
1885  memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy
1886  h = &wm_hints;
1887  }
1888  h->initial_state = q->isMinimized() ? IconicState : NormalState;
1889  h->flags |= StateHint;
1890  XSetWMHints(X11->display, q->internalWinId(), h);
1891  if (got_hints)
1892  XFree((char *)h);
1893 
1894  // update WM_NORMAL_HINTS
1895  do_size_hints(q, extra);
1896 
1897  // udpate WM_TRANSIENT_FOR
1898  if (isTransient(q)) {
1899  QWidget *p = q->parentWidget();
1900 
1901 #ifndef QT_NO_MENU
1902  // hackish ... try to find the main window related to this QMenu
1903  if (qobject_cast<QMenu *>(q)) {
1904  p = static_cast<QMenuPrivate*>(this)->causedPopup.widget;
1905  if (!p)
1906  p = q->parentWidget();
1907  if (!p)
1908  p = QApplication::widgetAt(q->pos());
1909  if (!p)
1910  p = qApp->activeWindow();
1911  }
1912 #endif
1913  if (p)
1914  p = p->window();
1915  if (p) {
1916  // transient for window
1917  XSetTransientForHint(X11->display, q->internalWinId(), p->internalWinId());
1918  } else {
1919  // transient for group
1920  XSetTransientForHint(X11->display, q->internalWinId(), X11->wm_client_leader);
1921  }
1922  }
1923 
1924  // update _MOTIF_WM_HINTS
1925  QtMWMHints mwmhints = GetMWMHints(X11->display, q->internalWinId());
1926 
1927  if (data.window_modality != Qt::NonModal) {
1928  switch (data.window_modality) {
1929  case Qt::WindowModal:
1930  mwmhints.input_mode = MWM_INPUT_PRIMARY_APPLICATION_MODAL;
1931  break;
1932  case Qt::ApplicationModal:
1933  default:
1934  mwmhints.input_mode = MWM_INPUT_FULL_APPLICATION_MODAL;
1935  break;
1936  }
1937  mwmhints.flags |= MWM_HINTS_INPUT_MODE;
1938  } else {
1939  mwmhints.input_mode = MWM_INPUT_MODELESS;
1940  mwmhints.flags &= ~MWM_HINTS_INPUT_MODE;
1941  }
1942 
1943  if (q->minimumSize() == q->maximumSize()) {
1944  // fixed size, remove the resize handle (since mwm/dtwm
1945  // isn't smart enough to do it itself)
1946  mwmhints.flags |= MWM_HINTS_FUNCTIONS;
1947  if (mwmhints.functions == MWM_FUNC_ALL) {
1948  mwmhints.functions = MWM_FUNC_MOVE;
1949  } else {
1950  mwmhints.functions &= ~MWM_FUNC_RESIZE;
1951  }
1952 
1953  if (mwmhints.decorations == MWM_DECOR_ALL) {
1954  mwmhints.flags |= MWM_HINTS_DECORATIONS;
1955  mwmhints.decorations = (MWM_DECOR_BORDER
1956  | MWM_DECOR_TITLE
1957  | MWM_DECOR_MENU);
1958  } else {
1959  mwmhints.decorations &= ~MWM_DECOR_RESIZEH;
1960  }
1961 
1962  if (q->windowFlags() & Qt::WindowMinimizeButtonHint) {
1963  mwmhints.flags |= MWM_HINTS_DECORATIONS;
1964  mwmhints.decorations |= MWM_DECOR_MINIMIZE;
1965  mwmhints.functions |= MWM_FUNC_MINIMIZE;
1966  }
1967  if (q->windowFlags() & Qt::WindowMaximizeButtonHint) {
1968  mwmhints.flags |= MWM_HINTS_DECORATIONS;
1969  mwmhints.decorations |= MWM_DECOR_MAXIMIZE;
1970  mwmhints.functions |= MWM_FUNC_MAXIMIZE;
1971  }
1972  if (q->windowFlags() & Qt::WindowCloseButtonHint)
1973  mwmhints.functions |= MWM_FUNC_CLOSE;
1974  }
1975 
1976  SetMWMHints(X11->display, q->internalWinId(), mwmhints);
1977 
1978  // update _NET_WM_STATE
1979  QVector<Atom> netWmState = getNetWmState(q);
1980 
1981  Qt::WindowFlags flags = q->windowFlags();
1982  if (flags & Qt::WindowStaysOnTopHint) {
1983  if (flags & Qt::WindowStaysOnBottomHint)
1984  qWarning() << "QWidget: Incompatible window flags: the window can't be on top and on bottom at the same time";
1985  if (!netWmState.contains(ATOM(_NET_WM_STATE_ABOVE)))
1986  netWmState.append(ATOM(_NET_WM_STATE_ABOVE));
1987  if (!netWmState.contains(ATOM(_NET_WM_STATE_STAYS_ON_TOP)))
1988  netWmState.append(ATOM(_NET_WM_STATE_STAYS_ON_TOP));
1989  } else if (flags & Qt::WindowStaysOnBottomHint) {
1990  if (!netWmState.contains(ATOM(_NET_WM_STATE_BELOW)))
1991  netWmState.append(ATOM(_NET_WM_STATE_BELOW));
1992  }
1993  if (q->isFullScreen()) {
1994  if (!netWmState.contains(ATOM(_NET_WM_STATE_FULLSCREEN)))
1995  netWmState.append(ATOM(_NET_WM_STATE_FULLSCREEN));
1996  }
1997  if (q->isMaximized()) {
1998  if (!netWmState.contains(ATOM(_NET_WM_STATE_MAXIMIZED_HORZ)))
1999  netWmState.append(ATOM(_NET_WM_STATE_MAXIMIZED_HORZ));
2000  if (!netWmState.contains(ATOM(_NET_WM_STATE_MAXIMIZED_VERT)))
2001  netWmState.append(ATOM(_NET_WM_STATE_MAXIMIZED_VERT));
2002  }
2003  if (data.window_modality != Qt::NonModal) {
2004  if (!netWmState.contains(ATOM(_NET_WM_STATE_MODAL)))
2005  netWmState.append(ATOM(_NET_WM_STATE_MODAL));
2006  }
2007 
2008  if (!netWmState.isEmpty()) {
2009  XChangeProperty(X11->display, q->internalWinId(),
2010  ATOM(_NET_WM_STATE), XA_ATOM, 32, PropModeReplace,
2011  (unsigned char *) netWmState.data(), netWmState.size());
2012  } else {
2013  XDeleteProperty(X11->display, q->internalWinId(), ATOM(_NET_WM_STATE));
2014  }
2015 
2016  // set _NET_WM_USER_TIME
2017  Time userTime = X11->userTime;
2018  bool setUserTime = false;
2019  if (q->testAttribute(Qt::WA_ShowWithoutActivating)) {
2020  userTime = 0;
2021  setUserTime = true;
2022  } else if (userTime != CurrentTime) {
2023  setUserTime = true;
2024  }
2025  if (setUserTime)
2026  qt_net_update_user_time(q, userTime);
2027 
2028 #ifndef QT_NO_XSYNC
2029  if (!topData()->syncUpdateCounter) {
2030  XSyncValue value;
2031  XSyncIntToValue(&value, 0);
2032  topData()->syncUpdateCounter = XSyncCreateCounter(X11->display, value);
2033 
2034  XChangeProperty(X11->display, q->internalWinId(),
2036  XA_CARDINAL,
2037  32, PropModeReplace,
2038  (uchar *) &topData()->syncUpdateCounter, 1);
2039 
2040  topData()->newCounterValueHi = 0;
2041  topData()->newCounterValueLo = 0;
2042  }
2043 #endif
2044 
2045  if (!topData()->embedded
2046  && (topData()->validWMState || topData()->waitingForMapNotify)
2047  && !q->isMinimized()) {
2048  X11->deferred_map.append(q);
2049  return;
2050  }
2051 
2052  if (q->isMaximized() && !q->isFullScreen()
2053  && !(X11->isSupportedByWM(ATOM(_NET_WM_STATE_MAXIMIZED_HORZ))
2054  && X11->isSupportedByWM(ATOM(_NET_WM_STATE_MAXIMIZED_VERT)))) {
2055  XMapWindow(X11->display, q->internalWinId());
2056  data.fstrut_dirty = true;
2058 
2059  // if the wm was not smart enough to adjust our size, do that manually
2061 
2062  QTLWExtra *top = topData();
2063  QRect normalRect = top->normalGeometry;
2064  const QRect fs = frameStrut();
2065 
2066  q->setGeometry(maxRect.x() + fs.left(),
2067  maxRect.y() + fs.top(),
2068  maxRect.width() - fs.left() - fs.right(),
2069  maxRect.height() - fs.top() - fs.bottom());
2070 
2071  // restore the original normalGeometry
2072  top->normalGeometry = normalRect;
2073  // internalSetGeometry() clears the maximized flag... make sure we set it back
2074  data.window_state = data.window_state | Qt::WindowMaximized;
2075  q->setAttribute(Qt::WA_Mapped);
2076  return;
2077  }
2078 
2079  if (q->isFullScreen() && !X11->isSupportedByWM(ATOM(_NET_WM_STATE_FULLSCREEN))) {
2080  XMapWindow(X11->display, q->internalWinId());
2082  q->setAttribute(Qt::WA_Mapped);
2083  return;
2084  }
2085  }
2086 
2087  invalidateBuffer(q->rect());
2088 
2089  if (q->testAttribute(Qt::WA_OutsideWSRange))
2090  return;
2091  q->setAttribute(Qt::WA_Mapped);
2092  if (q->isWindow())
2093  topData()->waitingForMapNotify = 1;
2094 
2095  if (!q->isWindow()
2096  && (!q->autoFillBackground()
2097  || q->palette().brush(q->backgroundRole()).style() == Qt::LinearGradientPattern)) {
2098  if (q->internalWinId()) {
2099  XSetWindowBackgroundPixmap(X11->display, q->internalWinId(), XNone);
2100  XMapWindow(X11->display, q->internalWinId());
2101  updateSystemBackground();
2102  }
2103  return;
2104  }
2105 
2106  if (q->internalWinId())
2107  XMapWindow(X11->display, q->internalWinId());
2108 
2109  // Freedesktop.org Startup Notification
2110  if (X11->startupId && q->isWindow()) {
2111  QByteArray message("remove: ID=");
2112  message.append(X11->startupId);
2113  sendStartupMessage(message.constData());
2114  X11->startupId = 0;
2115  }
2116 }
2117 
2126 void QWidgetPrivate::sendStartupMessage(const char *message) const
2127 {
2128  Q_Q(const QWidget);
2129 
2130  if (!message)
2131  return;
2132 
2133  XEvent xevent;
2134  xevent.xclient.type = ClientMessage;
2135  xevent.xclient.message_type = ATOM(_NET_STARTUP_INFO_BEGIN);
2136  xevent.xclient.display = X11->display;
2137  xevent.xclient.window = q->internalWinId();
2138  xevent.xclient.format = 8;
2139 
2140  Window rootWindow = RootWindow(X11->display, DefaultScreen(X11->display));
2141  uint sent = 0;
2142  uint length = strlen(message) + 1;
2143  do {
2144  if (sent == 20)
2145  xevent.xclient.message_type = ATOM(_NET_STARTUP_INFO);
2146 
2147  for (uint i = 0; i < 20 && i + sent <= length; i++)
2148  xevent.xclient.data.b[i] = message[i + sent++];
2149 
2150  XSendEvent(X11->display, rootWindow, false, PropertyChangeMask, &xevent);
2151  } while (sent <= length);
2152 }
2153 
2155 {
2156  Q_Q(QWidget);
2157  Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
2158 
2159  if (!q->isWindow()) {
2160  if (q->internalWinId())
2161  XDeleteProperty(X11->display, q->internalWinId(), ATOM(_NET_WM_WINDOW_TYPE));
2162  return;
2163  }
2164 
2165  QVector<long> windowTypes;
2166 
2167  // manual selection 1 (these are never set by Qt and take precedence)
2168  if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDesktop))
2169  windowTypes.append(ATOM(_NET_WM_WINDOW_TYPE_DESKTOP));
2170  if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDock))
2171  windowTypes.append(ATOM(_NET_WM_WINDOW_TYPE_DOCK));
2172  if (q->testAttribute(Qt::WA_X11NetWmWindowTypeNotification))
2174 
2175  // manual selection 2 (Qt uses these during auto selection);
2176  if (q->testAttribute(Qt::WA_X11NetWmWindowTypeUtility))
2177  windowTypes.append(ATOM(_NET_WM_WINDOW_TYPE_UTILITY));
2178  if (q->testAttribute(Qt::WA_X11NetWmWindowTypeSplash))
2179  windowTypes.append(ATOM(_NET_WM_WINDOW_TYPE_SPLASH));
2180  if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDialog))
2181  windowTypes.append(ATOM(_NET_WM_WINDOW_TYPE_DIALOG));
2182  if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolTip))
2183  windowTypes.append(ATOM(_NET_WM_WINDOW_TYPE_TOOLTIP));
2184 
2185  // manual selection 3 (these can be set by Qt, but don't have a
2186  // corresponding Qt::WindowType). note that order of the *MENU
2187  // atoms is important
2188  if (q->testAttribute(Qt::WA_X11NetWmWindowTypeMenu))
2189  windowTypes.append(ATOM(_NET_WM_WINDOW_TYPE_MENU));
2190  if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu))
2192  if (q->testAttribute(Qt::WA_X11NetWmWindowTypePopupMenu))
2194  if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolBar))
2195  windowTypes.append(ATOM(_NET_WM_WINDOW_TYPE_TOOLBAR));
2196  if (q->testAttribute(Qt::WA_X11NetWmWindowTypeCombo))
2197  windowTypes.append(ATOM(_NET_WM_WINDOW_TYPE_COMBO));
2198  if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDND))
2199  windowTypes.append(ATOM(_NET_WM_WINDOW_TYPE_DND));
2200 
2201  // automatic selection
2202  switch (q->windowType()) {
2203  case Qt::Dialog:
2204  case Qt::Sheet:
2205  // dialog netwm type
2206  windowTypes.append(ATOM(_NET_WM_WINDOW_TYPE_DIALOG));
2207  break;
2208 
2209  case Qt::Tool:
2210  case Qt::Drawer:
2211  // utility netwm type
2212  windowTypes.append(ATOM(_NET_WM_WINDOW_TYPE_UTILITY));
2213  break;
2214 
2215  case Qt::ToolTip:
2216  // tooltip netwm type
2217  windowTypes.append(ATOM(_NET_WM_WINDOW_TYPE_TOOLTIP));
2218  break;
2219 
2220  case Qt::SplashScreen:
2221  // splash netwm type
2222  windowTypes.append(ATOM(_NET_WM_WINDOW_TYPE_SPLASH));
2223  break;
2224 
2225  default:
2226  break;
2227  }
2228 
2229  if (q->windowFlags() & Qt::FramelessWindowHint) {
2230  // override netwm type - quick and easy for KDE noborder
2232  }
2233 
2234  // normal netwm type - default
2235  windowTypes.append(ATOM(_NET_WM_WINDOW_TYPE_NORMAL));
2236 
2237  if (!windowTypes.isEmpty()) {
2238  XChangeProperty(X11->display, q->winId(), ATOM(_NET_WM_WINDOW_TYPE), XA_ATOM, 32,
2239  PropModeReplace, (unsigned char *) windowTypes.constData(),
2240  windowTypes.count());
2241  } else {
2242  XDeleteProperty(X11->display, q->winId(), ATOM(_NET_WM_WINDOW_TYPE));
2243  }
2244 }
2245 
2255 {
2256  Q_Q(QWidget);
2257  Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
2258  deactivateWidgetCleanup();
2259  if (q->isWindow()) {
2260  X11->deferred_map.removeAll(q);
2261  if (q->internalWinId()) // in nsplugin, may be 0
2262  XWithdrawWindow(X11->display, q->internalWinId(), xinfo.screen());
2263  XFlush(X11->display);
2264  } else {
2265  invalidateBuffer(q->rect());
2266  if (q->internalWinId()) // in nsplugin, may be 0
2267  XUnmapWindow(X11->display, q->internalWinId());
2268  }
2269  q->setAttribute(Qt::WA_Mapped, false);
2270 }
2271 
2273 {
2274 
2275 }
2276 
2277 
2279 {
2280  Q_Q(QWidget);
2281  Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
2282  if (q->internalWinId())
2283  XRaiseWindow(X11->display, q->internalWinId());
2284 }
2285 
2287 {
2288  Q_Q(QWidget);
2289  Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
2290  if (q->internalWinId())
2291  XLowerWindow(X11->display, q->internalWinId());
2292  if(!q->isWindow())
2293  invalidateBuffer(q->rect());
2294 }
2295 
2297 {
2298  Q_Q(QWidget);
2299  Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
2300  if (q->internalWinId() && w->internalWinId()) {
2301  Window stack[2];
2302  stack[0] = w->internalWinId();;
2303  stack[1] = q->internalWinId();
2304  XRestackWindows(X11->display, stack, 2);
2305  }
2306  if(!q->isWindow() || !w->internalWinId())
2307  invalidateBuffer(q->rect());
2308 }
2309 
2310 
2311 static void do_size_hints(QWidget* widget, QWExtra *x)
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 }
2368 
2369 
2370 /*
2371  Helper function for non-toplevel widgets. Helps to map Qt's 32bit
2372  coordinate system to X11's 16bit coordinate system.
2373 
2374  Sets the geometry of the widget to data.crect, but clipped to sizes
2375  that X can handle. Unmaps widgets that are completely outside the
2376  valid range.
2377 
2378  Maintains data.wrect, which is the geometry of the X widget,
2379  measured in this widget's coordinate system.
2380 
2381  if the parent is not clipped, parentWRect is empty, otherwise
2382  parentWRect is the geometry of the parent's X rect, measured in
2383  parent's coord sys
2384  */
2385 void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &)
2386 {
2387  Q_Q(QWidget);
2388  Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
2389 
2390  /*
2391  There are up to four different coordinate systems here:
2392  Qt coordinate system for this widget.
2393  X coordinate system for this widget (relative to wrect).
2394  Qt coordinate system for parent
2395  X coordinate system for parent (relative to parent's wrect).
2396  */
2397  Display *dpy = xinfo.display();
2398  QRect validRange(-XCOORD_MAX,-XCOORD_MAX, 2*XCOORD_MAX, 2*XCOORD_MAX);
2399  QRect wrectRange(-WRECT_MAX,-WRECT_MAX, 2*WRECT_MAX, 2*WRECT_MAX);
2400  QRect wrect;
2401  //xrect is the X geometry of my X widget. (starts out in parent's Qt coord sys, and ends up in parent's X coord sys)
2402  QRect xrect = data.crect;
2403 
2404  const QWidget *const parent = q->parentWidget();
2405  QRect parentWRect = parent->data->wrect;
2406 
2407  if (parentWRect.isValid()) {
2408  // parent is clipped, and we have to clip to the same limit as parent
2409  if (!parentWRect.contains(xrect)) {
2410  xrect &= parentWRect;
2411  wrect = xrect;
2412  //translate from parent's to my Qt coord sys
2413  wrect.translate(-data.crect.topLeft());
2414  }
2415  //translate from parent's Qt coords to parent's X coords
2416  xrect.translate(-parentWRect.topLeft());
2417 
2418  } else {
2419  // parent is not clipped, we may or may not have to clip
2420 
2421  if (data.wrect.isValid() && QRect(QPoint(),data.crect.size()).contains(data.wrect)) {
2422  // This is where the main optimization is: we are already
2423  // clipped, and if our clip is still valid, we can just
2424  // move our window, and do not need to move or clip
2425  // children
2426 
2427  QRect vrect = xrect & parent->rect();
2428  vrect.translate(-data.crect.topLeft()); //the part of me that's visible through parent, in my Qt coords
2429  if (data.wrect.contains(vrect)) {
2430  xrect = data.wrect;
2431  xrect.translate(data.crect.topLeft());
2432  if (data.winid)
2433  XMoveWindow(dpy, data.winid, xrect.x(), xrect.y());
2434  return;
2435  }
2436  }
2437 
2438  if (!validRange.contains(xrect)) {
2439  // we are too big, and must clip
2440  xrect &=wrectRange;
2441  wrect = xrect;
2442  wrect.translate(-data.crect.topLeft());
2443  //parent's X coord system is equal to parent's Qt coord
2444  //sys, so we don't need to map xrect.
2445  }
2446 
2447  }
2448 
2449  // unmap if we are outside the valid window system coord system
2450  bool outsideRange = !xrect.isValid();
2451  bool mapWindow = false;
2452  if (q->testAttribute(Qt::WA_OutsideWSRange) != outsideRange) {
2453  q->setAttribute(Qt::WA_OutsideWSRange, outsideRange);
2454  if (outsideRange) {
2455  if (data.winid)
2456  XUnmapWindow(dpy, data.winid);
2457  q->setAttribute(Qt::WA_Mapped, false);
2458  } else if (!q->isHidden()) {
2459  mapWindow = true;
2460  }
2461  }
2462 
2463  if (outsideRange)
2464  return;
2465 
2466  bool jump = (data.wrect != wrect);
2467  data.wrect = wrect;
2468 
2469 
2470  // and now recursively for all children...
2471  // ### can be optimized
2472  for (int i = 0; i < children.size(); ++i) {
2473  QObject *object = children.at(i);
2474  if (object->isWidgetType()) {
2475  QWidget *w = static_cast<QWidget *>(object);
2476  if (!w->isWindow() && w->testAttribute(Qt::WA_WState_Created))
2477  w->d_func()->setWSGeometry(jump);
2478  }
2479  }
2480 
2481  if (data.winid) {
2482  // move ourselves to the new position and map (if necessary) after
2483  // the movement. Rationale: moving unmapped windows is much faster
2484  // than moving mapped windows
2485  if (jump) //avoid flicker when jumping
2486  XSetWindowBackgroundPixmap(dpy, data.winid, XNone);
2487  if (!parent->internalWinId())
2488  xrect.translate(parent->mapTo(q->nativeParentWidget(), QPoint(0, 0)));
2489  XMoveResizeWindow(dpy, data.winid, xrect.x(), xrect.y(), xrect.width(), xrect.height());
2490  }
2491 
2492  //to avoid flicker, we have to show children after the helper widget has moved
2493  if (jump) {
2494  for (int i = 0; i < children.size(); ++i) {
2495  QObject *object = children.at(i);
2496  if (object->isWidgetType()) {
2497  QWidget *w = static_cast<QWidget *>(object);
2500  if (w->internalWinId())
2501  XMapWindow(dpy, w->data->winid);
2502  }
2503  }
2504  }
2505  }
2506 
2507 
2508  if (jump && data.winid)
2509  XClearArea(dpy, data.winid, 0, 0, wrect.width(), wrect.height(), True);
2510 
2511  if (mapWindow && !dontShow) {
2512  q->setAttribute(Qt::WA_Mapped);
2513  if (data.winid)
2514  XMapWindow(dpy, data.winid);
2515  }
2516 }
2517 
2518 void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
2519 {
2520  Q_Q(QWidget);
2521  Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
2522  Display *dpy = X11->display;
2523 
2524  if ((q->windowType() == Qt::Desktop))
2525  return;
2526  if (q->isWindow()) {
2527  if (!X11->isSupportedByWM(ATOM(_NET_WM_STATE_MAXIMIZED_VERT))
2528  && !X11->isSupportedByWM(ATOM(_NET_WM_STATE_MAXIMIZED_HORZ)))
2529  data.window_state &= ~Qt::WindowMaximized;
2530  if (!X11->isSupportedByWM(ATOM(_NET_WM_STATE_FULLSCREEN)))
2531  data.window_state &= ~Qt::WindowFullScreen;
2532  if (QTLWExtra *topData = maybeTopData())
2533  topData->normalGeometry = QRect(0,0,-1,-1);
2534  } else {
2535  uint s = data.window_state;
2537  data.window_state = s;
2538  }
2539  if (extra) { // any size restrictions?
2540  w = qMin(w,extra->maxw);
2541  h = qMin(h,extra->maxh);
2542  w = qMax(w,extra->minw);
2543  h = qMax(h,extra->minh);
2544  }
2545  QPoint oldPos(q->pos());
2546  QSize oldSize(q->size());
2547  QRect oldGeom(data.crect);
2548  QRect r(x, y, w, h);
2549 
2550  // We only care about stuff that changes the geometry, or may
2551  // cause the window manager to change its state
2552  if (!q->isWindow() && oldGeom == r)
2553  return;
2554 
2555  data.crect = r;
2556  bool isResize = q->size() != oldSize;
2557 
2558  if (q->isWindow()) {
2559  if (w == 0 || h == 0) {
2560  q->setAttribute(Qt::WA_OutsideWSRange, true);
2561  if (q->isVisible() && q->testAttribute(Qt::WA_Mapped))
2562  hide_sys();
2563  } else if (q->isVisible() && q->testAttribute(Qt::WA_OutsideWSRange)) {
2564  q->setAttribute(Qt::WA_OutsideWSRange, false);
2565 
2566  // put the window in its place and show it
2567  if (data.winid)
2568  XMoveResizeWindow(dpy, data.winid, x, y, w, h);
2569  topData()->posFromMove = false; // force StaticGravity
2570  do_size_hints(q, extra);
2571  show_sys();
2572  } else {
2573  q->setAttribute(Qt::WA_OutsideWSRange, false);
2574  if (!q->isVisible())
2575  do_size_hints(q, extra);
2576  if (isMove) {
2578  // work around 4Dwm's incompliance with ICCCM 4.1.5
2579  || X11->desktopEnvironment == DE_4DWM) {
2580  if (data.winid)
2581  XMoveResizeWindow(dpy, data.winid, x, y, w, h);
2582  } else if (q->isVisible()
2583  && topData()->validWMState
2584  && X11->isSupportedByWM(ATOM(_NET_MOVERESIZE_WINDOW))) {
2585  XEvent e;
2586  e.xclient.type = ClientMessage;
2587  e.xclient.message_type = ATOM(_NET_MOVERESIZE_WINDOW);
2588  e.xclient.display = X11->display;
2589  e.xclient.window = q->internalWinId();
2590  e.xclient.format = 32;
2591  e.xclient.data.l[0] = StaticGravity | 1<<8 | 1<<9 | 1<<10 | 1<<11 | 1<<12;
2592  e.xclient.data.l[1] = x;
2593  e.xclient.data.l[2] = y;
2594  e.xclient.data.l[3] = w;
2595  e.xclient.data.l[4] = h;
2596  XSendEvent(X11->display, RootWindow(X11->display, q->x11Info().screen()),
2597  false, (SubstructureNotifyMask | SubstructureRedirectMask), &e);
2598  } else if (data.winid) {
2599  // pos() is right according to ICCCM 4.1.5
2600  XMoveResizeWindow(dpy, data.winid, q->pos().x(), q->pos().y(), w, h);
2601  }
2602  } else if (isResize && data.winid) {
2603  if (!q->isVisible()
2604  && topData()->validWMState
2605  && !q->testAttribute(Qt::WA_PendingMoveEvent)) {
2606  /*
2607  even though we've not visible, we could be in a
2608  race w/ the window manager, and it may ignore
2609  our ConfigureRequest. setting posFromMove to
2610  false makes sure that doDeferredMap() in
2611  qapplication_x11.cpp keeps the window in the
2612  right place
2613  */
2614  topData()->posFromMove = false;
2615  }
2616  XResizeWindow(dpy, data.winid, w, h);
2617  }
2618  }
2619  if (isResize && !q->testAttribute(Qt::WA_DontShowOnScreen)) // set config pending only on resize, see qapplication_x11.cpp, translateConfigEvent()
2620  q->setAttribute(Qt::WA_WState_ConfigPending);
2621 
2622  } else {
2623  QTLWExtra *tlwExtra = q->window()->d_func()->maybeTopData();
2624  const bool inTopLevelResize = tlwExtra ? tlwExtra->inTopLevelResize : false;
2625  const bool disableInTopLevelResize = inTopLevelResize && q->internalWinId();
2626  if (disableInTopLevelResize) {
2627  // Top-level resize optimization does not work for native child widgets;
2628  // disable it for this particular widget.
2629  tlwExtra->inTopLevelResize = false;
2630  }
2631 
2632  if (!isResize && (!inTopLevelResize || disableInTopLevelResize) && q->isVisible()) {
2633  moveRect(QRect(oldPos, oldSize), x - oldPos.x(), y - oldPos.y());
2634  }
2635  if (q->testAttribute(Qt::WA_WState_Created))
2636  setWSGeometry();
2637 
2638  if (isResize && (!inTopLevelResize || disableInTopLevelResize) && q->isVisible())
2639  invalidateBuffer_resizeHelper(oldPos, oldSize);
2640 
2641  if (disableInTopLevelResize)
2642  tlwExtra->inTopLevelResize = true;
2643  }
2644 
2645  if (q->isVisible()) {
2646  if (isMove && q->pos() != oldPos) {
2647  if (X11->desktopEnvironment != DE_4DWM) {
2648  // pos() is right according to ICCCM 4.1.5
2649  QMoveEvent e(q->pos(), oldPos);
2650  QApplication::sendEvent(q, &e);
2651  } else {
2652  // work around 4Dwm's incompliance with ICCCM 4.1.5
2653  QMoveEvent e(data.crect.topLeft(), oldGeom.topLeft());
2654  QApplication::sendEvent(q, &e);
2655  }
2656  }
2657  if (isResize) {
2658  static bool slowResize = qgetenv("QT_SLOW_TOPLEVEL_RESIZE").toInt();
2659  // If we have a backing store with static contents, we have to disable the top-level
2660  // resize optimization in order to get invalidated regions for resized widgets.
2661  // The optimization discards all invalidateBuffer() calls since we're going to
2662  // repaint everything anyways, but that's not the case with static contents.
2663  const bool setTopLevelResize = !slowResize && q->isWindow() && extra && extra->topextra
2664  && !extra->topextra->inTopLevelResize
2665  && (!extra->topextra->backingStore
2666  || !extra->topextra->backingStore->hasStaticContents());
2667  if (setTopLevelResize)
2668  extra->topextra->inTopLevelResize = true;
2669  QResizeEvent e(q->size(), oldSize);
2670  QApplication::sendEvent(q, &e);
2671  if (setTopLevelResize)
2672  extra->topextra->inTopLevelResize = false;
2673  }
2674  } else {
2675  if (isMove && q->pos() != oldPos)
2676  q->setAttribute(Qt::WA_PendingMoveEvent, true);
2677  if (isResize)
2678  q->setAttribute(Qt::WA_PendingResizeEvent, true);
2679  }
2680 }
2681 
2683 {
2684  Q_Q(QWidget);
2685 #ifdef ALIEN_DEBUG
2686  qDebug() << "QWidgetPrivate::setConstraints_sys START" << q;
2687 #endif
2688  if (q->testAttribute(Qt::WA_WState_Created)) {
2689  do_size_hints(q, extra);
2690  QtMWMHints mwmHints = GetMWMHints(X11->display, q->internalWinId());
2691  const bool wasFuncResize = mwmHints.functions & MWM_FUNC_RESIZE;
2692  if (q->minimumSize() == q->maximumSize())
2693  mwmHints.functions &= ~MWM_FUNC_RESIZE;
2694  else
2695  mwmHints.functions |= MWM_FUNC_RESIZE;
2696  if (wasFuncResize != (mwmHints.functions & MWM_FUNC_RESIZE))
2697  SetMWMHints(X11->display, q->internalWinId(), mwmHints);
2698  }
2699 #ifdef ALIEN_DEBUG
2700  qDebug() << "QWidgetPrivate::setConstraints_sys END" << q;
2701 #endif
2702 }
2703 
2704 void QWidgetPrivate::scroll_sys(int dx, int dy)
2705 {
2706  Q_Q(QWidget);
2707 
2708  scrollChildren(dx, dy);
2709  if (!paintOnScreen()) {
2710  scrollRect(q->rect(), dx, dy);
2711  } else {
2712  scroll_sys(dx, dy, QRect());
2713  }
2714 }
2715 
2716 void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
2717 {
2718  Q_Q(QWidget);
2719 
2720  if (!paintOnScreen()) {
2721  scrollRect(r, dx, dy);
2722  return;
2723  }
2724  bool valid_rect = r.isValid();
2725  bool just_update = qAbs(dx) > q->width() || qAbs(dy) > q->height();
2726  QRect sr = valid_rect ? r : clipRect();
2727  if (just_update)
2728  q->update();
2729  else if (!valid_rect)
2730  dirty.translate(dx, dy);
2731 
2732  int x1, y1, x2, y2, w = sr.width(), h = sr.height();
2733  if (dx > 0) {
2734  x1 = sr.x();
2735  x2 = x1+dx;
2736  w -= dx;
2737  } else {
2738  x2 = sr.x();
2739  x1 = x2-dx;
2740  w += dx;
2741  }
2742  if (dy > 0) {
2743  y1 = sr.y();
2744  y2 = y1+dy;
2745  h -= dy;
2746  } else {
2747  y2 = sr.y();
2748  y1 = y2-dy;
2749  h += dy;
2750  }
2751 
2752  if (dx == 0 && dy == 0)
2753  return;
2754 
2755  Display *dpy = X11->display;
2756  // Want expose events
2757  if (w > 0 && h > 0 && !just_update && q->internalWinId()) {
2758  GC gc = XCreateGC(dpy, q->internalWinId(), 0, 0);
2759  XSetGraphicsExposures(dpy, gc, True);
2760  XCopyArea(dpy, q->internalWinId(), q->internalWinId(), gc, x1, y1, w, h, x2, y2);
2761  XFreeGC(dpy, gc);
2762  }
2763 
2764  if (!valid_rect && !children.isEmpty()) { // scroll children
2765  QPoint pd(dx, dy);
2766  for (int i = 0; i < children.size(); ++i) { // move all children
2767  register QObject *object = children.at(i);
2768  if (object->isWidgetType()) {
2769  QWidget *w = static_cast<QWidget *>(object);
2770  if (!w->isWindow())
2771  w->move(w->pos() + pd);
2772  }
2773  }
2774  }
2775 
2776  if (just_update)
2777  return;
2778 
2779  // Don't let the server be bogged-down with repaint events
2780  bool repaint_immediately = (qt_sip_count(q) < 3 && !q->testAttribute(Qt::WA_WState_InPaintEvent));
2781 
2782  if (dx) {
2783  int x = x2 == sr.x() ? sr.x()+w : sr.x();
2784  if (repaint_immediately)
2785  q->repaint(x, sr.y(), qAbs(dx), sr.height());
2786  else if (q->internalWinId())
2787  XClearArea(dpy, data.winid, x, sr.y(), qAbs(dx), sr.height(), True);
2788  }
2789  if (dy) {
2790  int y = y2 == sr.y() ? sr.y()+h : sr.y();
2791  if (repaint_immediately)
2792  q->repaint(sr.x(), y, sr.width(), qAbs(dy));
2793  else if (q->internalWinId())
2794  XClearArea(dpy, data.winid, sr.x(), y, sr.width(), qAbs(dy), True);
2795  }
2796 
2797  qt_insert_sip(q, dx, dy); // #### ignores r
2798 }
2799 
2800 int QWidget::metric(PaintDeviceMetric m) const
2801 {
2802  Q_D(const QWidget);
2803  int val;
2804  if (m == PdmWidth) {
2805  val = data->crect.width();
2806  } else if (m == PdmHeight) {
2807  val = data->crect.height();
2808  } else {
2809  Display *dpy = X11->display;
2810  int scr = d->xinfo.screen();
2811  switch (m) {
2812  case PdmDpiX:
2813  case PdmPhysicalDpiX:
2814  if (d->extra && d->extra->customDpiX)
2815  val = d->extra->customDpiX;
2816  else if (d->parent)
2817  val = static_cast<QWidget *>(d->parent)->metric(m);
2818  else
2819  val = QX11Info::appDpiX(scr);
2820  break;
2821  case PdmDpiY:
2822  case PdmPhysicalDpiY:
2823  if (d->extra && d->extra->customDpiY)
2824  val = d->extra->customDpiY;
2825  else if (d->parent)
2826  val = static_cast<QWidget *>(d->parent)->metric(m);
2827  else
2828  val = QX11Info::appDpiY(scr);
2829  break;
2830  case PdmWidthMM:
2831  val = (DisplayWidthMM(dpy,scr)*data->crect.width())/
2832  DisplayWidth(dpy,scr);
2833  break;
2834  case PdmHeightMM:
2835  val = (DisplayHeightMM(dpy,scr)*data->crect.height())/
2836  DisplayHeight(dpy,scr);
2837  break;
2838  case PdmNumColors:
2839  val = d->xinfo.cells();
2840  break;
2841  case PdmDepth:
2842  val = d->xinfo.depth();
2843  break;
2844  default:
2845  val = 0;
2846  qWarning("QWidget::metric: Invalid metric command");
2847  }
2848  }
2849  return val;
2850 }
2851 
2853 {
2854  extra->compress_events = true;
2855  extra->xDndProxy = 0;
2856 }
2857 
2859 {
2860 }
2861 
2863 {
2864  extra->topextra->spont_unmapped = 0;
2865  extra->topextra->dnd = 0;
2866  extra->topextra->validWMState = 0;
2867  extra->topextra->waitingForMapNotify = 0;
2868  extra->topextra->parentWinId = 0;
2869  extra->topextra->userTimeWindow = 0;
2870 #ifndef QT_NO_XSYNC
2871  extra->topextra->syncUpdateCounter = 0;
2872  extra->topextra->syncRequestTimestamp = 0;
2873  extra->topextra->newCounterValueHi = 0;
2874  extra->topextra->newCounterValueLo = 0;
2875 #endif
2876 }
2877 
2879 {
2880  // don't destroy input context here. it will be destroyed in
2881  // QWidget::destroy() destroyInputContext();
2882 #ifndef QT_NO_XSYNC
2883  if (extra && extra->topextra && extra->topextra->syncUpdateCounter) {
2884  XSyncDestroyCounter(X11->display, extra->topextra->syncUpdateCounter);
2885  extra->topextra->syncUpdateCounter = 0;
2886  }
2887 #endif
2888 }
2889 
2891 {
2892  Q_UNUSED(on);
2893 }
2894 
2895 void QWidgetPrivate::setMask_sys(const QRegion &region)
2896 {
2897  Q_Q(QWidget);
2898  if (!q->internalWinId())
2899  return;
2900 
2901  if (region.isEmpty()) {
2902  XShapeCombineMask(X11->display, q->internalWinId(), ShapeBounding, 0, 0,
2903  XNone, ShapeSet);
2904  } else {
2905  XShapeCombineRegion(X11->display, q->internalWinId(), ShapeBounding, 0, 0,
2906  region.handle(), ShapeSet);
2907  }
2908 }
2909 
2921 {
2922  Q_Q(QWidget);
2923 
2924  QTLWExtra *top = topData();
2925  if (!top->validWMState) {
2926  return;
2927  }
2928  if (!q->isWindow() && !q->internalWinId()) {
2929  data.fstrut_dirty = false;
2930  return;
2931  }
2932 
2933  Atom type_ret;
2934  Window l = q->effectiveWinId(), w = l, p, r; // target window, its parent, root
2935  Window *c;
2936  int i_unused;
2937  unsigned int nc;
2938  unsigned char *data_ret;
2939  unsigned long l_unused;
2940 
2941  while (XQueryTree(X11->display, w, &r, &p, &c, &nc)) {
2942  if (c && nc > 0)
2943  XFree(c);
2944 
2945  if (! p) {
2946  qWarning("QWidget::updateFrameStrut: No parent");
2947  return;
2948  }
2949 
2950  // if the parent window is the root window, an Enlightenment virtual root or
2951  // a NET WM virtual root window, stop here
2952  data_ret = 0;
2953  if (p == r ||
2954  (XGetWindowProperty(X11->display, p,
2955  ATOM(ENLIGHTENMENT_DESKTOP), 0, 1, False, XA_CARDINAL,
2956  &type_ret, &i_unused, &l_unused, &l_unused,
2957  &data_ret) == Success &&
2958  type_ret == XA_CARDINAL)) {
2959  if (data_ret)
2960  XFree(data_ret);
2961 
2962  break;
2963  } else if (X11->isSupportedByWM(ATOM(_NET_VIRTUAL_ROOTS)) && X11->net_virtual_root_list) {
2964  int i = 0;
2965  while (X11->net_virtual_root_list[i] != 0) {
2966  if (X11->net_virtual_root_list[i++] == p)
2967  break;
2968  }
2969  }
2970 
2971  l = w;
2972  w = p;
2973  }
2974 
2975  // we have our window
2976  int transx, transy;
2977  XWindowAttributes wattr;
2978  if (XTranslateCoordinates(X11->display, l, w,
2979  0, 0, &transx, &transy, &p) &&
2980  XGetWindowAttributes(X11->display, w, &wattr)) {
2981  top->frameStrut.setCoords(transx,
2982  transy,
2983  wattr.width - data.crect.width() - transx,
2984  wattr.height - data.crect.height() - transy);
2985 
2986  // add the border_width for the window managers frame... some window managers
2987  // do not use a border_width of zero for their frames, and if we the left and
2988  // top strut, we ensure that pos() is absolutely correct. frameGeometry()
2989  // will still be incorrect though... perhaps i should have foffset as well, to
2990  // indicate the frame offset (equal to the border_width on X).
2991  // - Brad
2992  top->frameStrut.adjust(wattr.border_width,
2993  wattr.border_width,
2994  wattr.border_width,
2995  wattr.border_width);
2996  }
2997 
2998  data.fstrut_dirty = false;
2999 }
3000 
3002 {
3003  Q_Q(QWidget);
3004  ulong value = ulong(opacity * 0xffffffff);
3005  XChangeProperty(QX11Info::display(), q->internalWinId(), ATOM(_NET_WM_WINDOW_OPACITY), XA_CARDINAL,
3006  32, PropModeReplace, (uchar*)&value, 1);
3007 }
3008 
3010 {
3011  Q_D(const QWidget);
3012  return d->xinfo;
3013 }
3014 
3016 {
3017  Q_Q(QWidget);
3018  if (!q->internalWinId())
3019  return;
3020  QByteArray windowRole = topData()->role.toUtf8();
3021  XChangeProperty(X11->display, q->internalWinId(),
3022  ATOM(WM_WINDOW_ROLE), XA_STRING, 8, PropModeReplace,
3023  (unsigned char *)windowRole.constData(), windowRole.length());
3024 }
3025 
3026 Q_GLOBAL_STATIC(QX11PaintEngine, qt_widget_paintengine)
3028 {
3029  Q_D(const QWidget);
3030  if (qt_widget_paintengine()->isActive()) {
3031  if (d->extraPaintEngine)
3032  return d->extraPaintEngine;
3033  QWidget *self = const_cast<QWidget *>(this);
3034  self->d_func()->extraPaintEngine = new QX11PaintEngine();
3035  return d->extraPaintEngine;
3036  }
3037  return qt_widget_paintengine();
3038 }
3039 
3041 {
3042  return new QX11WindowSurface(q_func());
3043 }
3044 
3046 {
3047 #ifndef QT_NO_XRENDER
3048  Q_D(const QWidget);
3049  if (!internalWinId() && testAttribute(Qt::WA_WState_Created))
3050  (void)winId(); // enforce native window
3051  return d->picture;
3052 #else
3053  return 0;
3054 #endif // QT_NO_XRENDER
3055 }
3056 
3057 #ifndef QT_NO_XRENDER
3058 XRenderColor QX11Data::preMultiply(const QColor &c)
3059 {
3060  XRenderColor color;
3061  const uint A = c.alpha(),
3062  R = c.red(),
3063  G = c.green(),
3064  B = c.blue();
3065  color.alpha = (A | A << 8);
3066  color.red = (R | R << 8) * color.alpha / 0x10000;
3067  color.green = (G | G << 8) * color.alpha / 0x10000;
3068  color.blue = (B | B << 8) * color.alpha / 0x10000;
3069  return color;
3070 }
3072 {
3073  if (!X11->use_xrender)
3074  return XNone;
3075 
3076  XRenderColor color = preMultiply(c);
3077  for (int i = 0; i < X11->solid_fill_count; ++i) {
3078  if (X11->solid_fills[i].screen == screen
3079  && X11->solid_fills[i].color.alpha == color.alpha
3080  && X11->solid_fills[i].color.red == color.red
3081  && X11->solid_fills[i].color.green == color.green
3082  && X11->solid_fills[i].color.blue == color.blue)
3083  return X11->solid_fills[i].picture;
3084  }
3085  // none found, replace one
3086  int i = qrand() % 16;
3087 
3088  if (X11->solid_fills[i].screen != screen && X11->solid_fills[i].picture) {
3089  XRenderFreePicture (X11->display, X11->solid_fills[i].picture);
3090  X11->solid_fills[i].picture = 0;
3091  }
3092 
3093  if (!X11->solid_fills[i].picture) {
3094  Pixmap pixmap = XCreatePixmap (X11->display, RootWindow (X11->display, screen), 1, 1, 32);
3095  XRenderPictureAttributes attrs;
3096  attrs.repeat = True;
3097  X11->solid_fills[i].picture = XRenderCreatePicture (X11->display, pixmap,
3098  XRenderFindStandardFormat(X11->display, PictStandardARGB32),
3099  CPRepeat, &attrs);
3100  XFreePixmap (X11->display, pixmap);
3101  }
3102 
3103  X11->solid_fills[i].color = color;
3104  X11->solid_fills[i].screen = screen;
3105  XRenderFillRectangle (X11->display, PictOpSrc, X11->solid_fills[i].picture, &color, 0, 0, 1, 1);
3106  return X11->solid_fills[i].picture;
3107 }
3108 #endif
3109 
3111 {
3112 }
3113 
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 }
3137 
3139 {
3140  Q_Q(QWidget);
3141  if (!q->isWindow() || !q->internalWinId())
3142  return;
3143 
3144  XWMHints *h = XGetWMHints(X11->display, q->internalWinId());
3145  XWMHints wm_hints;
3146  if (!h) {
3147  memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy
3148  h = &wm_hints;
3149  }
3150  h->flags |= InputHint;
3151  h->input = q->testAttribute(Qt::WA_X11DoNotAcceptFocus) ? False : True;
3152 
3153  XSetWMHints(X11->display, q->internalWinId(), h);
3154  if (h != &wm_hints)
3155  XFree((char *)h);
3156 }
3157 
static QTextCodec * codecForLocale()
Returns a pointer to the codec most suitable for this locale.
T qobject_cast(QObject *object)
Definition: qobject.h:375
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
HCURSOR_or_HANDLE handle() const
Returns a platform-specific cursor handle.
Definition: qcursor_mac.mm:301
double d
Definition: qnumeric_p.h:62
QPoint mapToGlobal(const QPoint &pos) const
static void jump(QtMsgType t, const char *m)
QImage toImage() const
Converts the pixmap to a QImage.
Definition: qpixmap.cpp:542
void setParent_sys(QWidget *parent, Qt::WindowFlags)
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
static QColormap instance(int screen=-1)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
unsigned long WId
Definition: qwindowdefs.h:119
QRect adjusted(int x1, int y1, int x2, int y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:431
void grabMouse()
Grabs the mouse input.
void setWindowIcon_sys(bool forceReset=false)
void push_back(const T &t)
This function is provided for STL compatibility.
Definition: qlist.h:296
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193
QList< QSize > availableSizes(Mode mode=Normal, State state=Off) const
Returns a list of available icon sizes for the specified mode and state.
Definition: qicon.cpp:900
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
unsigned char c[8]
Definition: qnumeric_p.h:62
ulong decorations
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
int metric(PaintDeviceMetric) const
Internal implementation of the virtual QPaintDevice::metric() function.
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
void setNetWmWindowTypes()
static const char * appClass()
Returns the X11 application class.
QPointer< QWidget > widget
QRect frameStrut
Definition: qwidget_p.h:180
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
static int appScreen()
Returns the number of the screen where the application is being displayed.
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
void qPRCleanup(QWidget *widget)
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QByteArray & append(char c)
Appends the character ch to this byte array.
WId effectiveWinId() const
Returns the effective window system identifier of the widget, i.
Definition: qwidget.cpp:2654
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
QPixmap qt_toX11Pixmap(const QImage &image)
Definition: qpixmap_x11.cpp:81
bool isVisible() const
Definition: qwidget.h:1005
static QAbstractEventDispatcher * instance(QThread *thread=0)
Returns a pointer to the event dispatcher object for the specified thread.
QExplicitlySharedDataPointer< QPixmapData > data
Definition: qpixmap.h:252
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
static bool appDefaultVisual(int screen=-1)
Returns true if the application has a default visual on the given screen; otherwise returns false...
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
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.
static QWidget * keyboardGrabber
Definition: qwidget_p.h:787
static QWidget * activeWindow()
Returns the application top-level window that has the keyboard input focus, or 0 if no application wi...
static QVector< Atom > getNetWmState(QWidget *w)
void setWindowTitle_sys(const QString &cap)
static void qt_x11_recreateWidget(QWidget *widget)
#define QWIDGETSIZE_MAX
Defines the maximum size for a QWidget object.
Definition: qwidget.h:1087
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
const QX11Info & x11Info() const
Returns information about the configuration of the X display used to display the widget.
static void do_size_hints(QWidget *widget, QWExtra *x)
#define XCOORD_MAX
Definition: qwidget_x11.cpp:86
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
const uint stdDesktopEventMask
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int byteCount() const
Returns the number of bytes occupied by the image data.
Definition: qimage.cpp:1800
uint inTopLevelResize
Definition: qwidget_p.h:188
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void deleteTLSysExtra()
Qt::HANDLE handle() const
Returns the pixmap&#39;s handle to the device context.
Definition: qpixmap.cpp:1299
long ASN1_INTEGER_get ASN1_INTEGER * a
short baseh
Definition: qwidget_p.h:178
const XWindowAttributes * att
void show_sys()
Platform-specific part of QWidget::show().
ushort red
Returns the red color component of this color.
Definition: qcolor.h:243
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define A(arg)
Q_CORE_EXPORT int qrand()
int qt_x11_create_desktop_on_screen
Definition: qwidget_x11.cpp:99
WindowType
Definition: qnamespace.h:270
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
const uint stdWidgetEventMask
#define X11
Definition: qt_x11_p.h:724
static void SetMWMHints(Display *display, Window window, const QtMWMHints &mwmhints)
#define Q_D(Class)
Definition: qglobal.h:2482
int x
the x coordinate of the widget relative to its parent including any window frame
Definition: qwidget.h:161
void qt_x11_enforce_cursor(QWidget *w, bool force)
Update the X11 cursor of the widget w.
The QElapsedTimer class provides a fast way to calculate elapsed times.
Definition: qelapsedtimer.h:53
void setCursor_sys(const QCursor &cursor)
qint32 minw
Definition: qwidget_p.h:264
qint64 elapsed() const
Returns the number of milliseconds since this QElapsedTimer was last started.
QString qAppName()
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
static bool isCompositingManagerRunning()
Returns true if there is a compositing manager running.
void registerDropSite(bool)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
#define Q_Q(Class)
Definition: qglobal.h:2483
union _XEvent XEvent
Definition: qwindowdefs.h:116
QFuture< T > mapped(const Sequence &sequence, MapFunction function)
bool isHidden() const
Returns true if the widget is hidden, otherwise returns false.
Definition: qwidget.h:1008
#define ATOM(x)
Definition: qt_x11_p.h:723
Q_CORE_EXPORT void qDebug(const char *,...)
static QWidget * widgetAt(const QPoint &p)
Returns the widget at global screen position point, or 0 if there is no Qt widget there...
QX11InfoData * getX11Data(bool def=false) const
#define WRECT_MAX
Definition: qwidget_x11.cpp:87
unsigned char uchar
Definition: qglobal.h:994
void setParent_helper(QObject *)
Definition: qobject.cpp:1974
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:55
NSWindow * window
T * data() const
Returns a pointer to the shared data object.
Definition: qshareddata.h:145
void create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
static void qt_insert_sip(QWidget *scrolled_widget, int dx, int dy)
void unsetCursor_sys()
static QCursor * overrideCursor()
Strips out vertical alignment flags and transforms an alignment align of Qt::AlignLeft into Qt::Align...
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QRect normalGeometry
Definition: qwidget_p.h:181
QWidget * nativeParentWidget() const
Returns the native parent for this widget, i.
Definition: qwidget.cpp:4514
The QMoveEvent class contains event parameters for move events.
Definition: qevent.h:334
QByteArray fromUnicode(const QString &uc) const
Converts str from Unicode to the encoding of this codec, and returns the result in a QByteArray...
void sendStartupMessage(const char *message) const
Platform-specific part of QWidget::show().
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
short inch
Definition: qwidget_p.h:177
virtual void widgetDestroyed(QWidget *w)
This virtual function is called when the specified widget is destroyed.
void destroy(bool destroyWindow=true, bool destroySubWindows=true)
Frees up window system resources.
void releaseMouse()
Releases the mouse grab.
static QWidget * mouseGrabber()
Returns the widget that is currently grabbing the mouse input.
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
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
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
#define qApp
Qt::WindowFlags window_flags
Definition: qwidget.h:119
static int appDpiX(int screen=-1)
Returns the horizontal resolution of the given screen in terms of the number of dots per inch...
qint32 maxh
Definition: qwidget_p.h:267
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
Definition: qglobal.h:1968
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
void hide_sys()
Platform-specific part of QWidget::hide().
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void setConstraints_sys()
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
bool isVirtualDesktop() const
QWidgetData * data
Definition: qwidget.h:815
bool qt_nograb()
bool isNull() const
Returns true if both the x and y coordinates are set to 0, otherwise returns false.
Definition: qpoint.h:125
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
void updateFrameStrut()
Computes the frame rectangle when needed.
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
Q_CORE_EXPORT void qWarning(const char *,...)
void setSize(const QSize &s)
Sets the size of the rectangle to the given size.
Definition: qrect.h:448
void qt_XDestroyWindow(const QWidget *destroyer, Display *display, Window window)
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
static bool appDefaultColormap(int screen=-1)
Returns true if the application has a default color map on the given screen; otherwise returns false...
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
void x11UpdateIsOpaque()
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
Picture getSolidFill(int screen, const QColor &c)
static void sendPostedEvents()
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QCursor cursor
the cursor shape for this widget
Definition: qwidget.h:183
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
Qt::WindowFlags savedFlags
Definition: qwidget_p.h:182
QRect wrect
Definition: qwidget.h:145
void * HANDLE
Definition: qnamespace.h:1671
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
The State element defines configurations of objects and properties.
void setCoords(int x1, int y1, int x2, int y2)
Sets the coordinates of the rectangle&#39;s top-left corner to (x1, y1), and the coordinates of its botto...
Definition: qrect.h:416
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)
unsigned long ulong
Definition: qglobal.h:997
void * visual() const
Returns the current visual.
QPixmap texture() const
Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set...
Definition: qbrush.cpp:785
static Qt::HANDLE appColormap(int screen=-1)
Returns a handle for the application&#39;s color map on the given screen.
void show()
Shows the widget and its child widgets.
bool isOpaque() const
Returns true if the brush is fully opaque otherwise false.
Definition: qbrush.cpp:910
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
void deleteSysExtra()
#define QT_CATCH(A)
Definition: qglobal.h:1537
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
Visual * visual
Definition: qt_x11_p.h:318
short incw
Definition: qwidget_p.h:177
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
The QWindowSurface class provides the drawing area for top-level windows.
bool isEnabled() const
Definition: qwidget.h:948
void hide()
Hides the widget.
Definition: qwidget.h:501
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition: qpalette.cpp:874
static QWidget * parentWidget(const QWidget *w)
WId parentWinId
Definition: qwidget_p.h:198
QWidget * screen(int screen=-1)
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
int length() const
Same as size().
Definition: qbytearray.h:356
void updateX11AcceptFocus()
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
unsigned long Picture
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
void grabKeyboard()
Grabs the keyboard input.
struct _XDisplay Display
Definition: qwindowdefs.h:115
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
static QWidget * mouseGrabber
Definition: qwidget_p.h:786
The QX11Info class provides information about the X display configuration.
Definition: qx11info_x11.h:63
const QRect screenGeometry(int screen=-1) const
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
Definition: qimage.cpp:3966
ushort blue
Returns the blue color component of this color.
Definition: qcolor.h:245
The QWindowStateChangeEvent class provides the window state before a window state change...
Definition: qevent.h:705
void qt_change_net_wm_state(const QWidget *w, bool set, Atom one, Atom two=0)
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
QTLWExtra * topextra
Definition: qwidget_p.h:249
QWindowSurface * createDefaultWindowSurface_sys()
QPoint pos
the position of the widget within its parent widget
Definition: qwidget.h:163
static QInputContext * inputContext
ushort alpha
Returns the alpha color component of this color.
Definition: qcolor.h:242
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
ulong functions
static XTextProperty * qstring_to_xtp(const QString &s)
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
static void * appVisual(int screen=-1)
Returns the current visual used by the application on the given screen.
QPaintEngine * paintEngine() const
Returns the widget&#39;s paint engine.
void setMask_sys(const QRegion &)
QPoint fullScreenOffset
Definition: qwidget_p.h:200
void qt_x11_getX11InfoForWindow(QX11Info *xinfo, const XWindowAttributes &a)
int y
the y coordinate of the widget relative to its parent and including any window frame ...
Definition: qwidget.h:162
Colormap colormap
Definition: qt_x11_p.h:317
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
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...
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
long unsigned int eventList[TOTAL_XINPUT_EVENTS]
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
Definition: qglobal.h:1219
unsigned int quint32
Definition: qglobal.h:938
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
static QWidget * keyboardGrabber()
Returns the widget that is currently grabbing the keyboard input.
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4014
void scroll_sys(int dx, int dy)
void setWindowOpacity_sys(qreal opacity)
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
static bool isTransient(const QWidget *w)
void qt_x11_wait_for_window_manager(QWidget *w, bool sendPostedEvents)
Definition: qnamespace.h:54
QFactoryLoader * l
QPixmap * iconPixmap
Definition: qwidget_p.h:165
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
void releaseKeyboard()
Releases the keyboard grab.
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 size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
void activateWindow()
Sets the top-level widget containing this widget to be the active window.
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
Window qt_XCreateSimpleWindow(const QWidget *creator, Display *display, Window parent, int x, int y, uint w, uint h, int borderwidth, ulong border, ulong background)
static int qt_sip_count(QWidget *scrolled_widget)
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
static QString appName
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
Definition: qicon.cpp:693
struct _XGC * GC
Definition: qwindowdefs.h:117
qint32 minh
Definition: qwidget_p.h:265
static void create_wm_client_leader()
short basew
Definition: qwidget_p.h:178
uint posFromMove
Definition: qwidget_p.h:186
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
void createSysExtra()
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154
void setX11Data(const QX11InfoData *)
Makes a shallow copy of the X11-specific data d and assigns it to this class.
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
const QRect availableGeometry(int screen=-1) const
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
void createTLSysExtra()
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83
bool defaultColormap
Definition: qt_x11_p.h:319
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
The QTextCodec class provides conversions between text encodings.
Definition: qtextcodec.h:62
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
void qt_net_remove_user_time(QWidget *tlw)
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
static void qt_x11_recreateNativeWidgetsRecursive(QWidget *widget)
void updateSystemBackground()
virtual void setFocusWidget(QWidget *w)
Sets the widget that has an input focus for this input context.
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
static bool isRightToLeft()
Returns true if the application&#39;s layout direction is Qt::RightToLeft; otherwise returns false...
Definition: qapplication.h:233
static void leaveModal(QWidget *)
#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
ushort green
Returns the green color component of this color.
Definition: qcolor.h:244
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
void setGeometry_sys(int, int, int, int, bool)
XRenderColor preMultiply(const QColor &c)
void stackUnder_sys(QWidget *)
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
static QtMWMHints GetMWMHints(Display *display, Window window)
void start()
Starts this timer.
#define QT_TRY
Definition: qglobal.h:1536
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
QTabletDeviceDataList * qt_tablet_devices()
uint validWMState
Definition: qwidget_p.h:196
Qt::HANDLE x11PictureHandle() const
Returns the X11 Picture handle of the widget for XRender support.
uint waitingForMapNotify
Definition: qwidget_p.h:197
WId winid
Definition: qwidget.h:117
static Display * display()
Returns the default display for the application.
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
Definition: qimage.cpp:1886
bool isBackgroundInherited() const
static void flush()
Flushes the platform specific event queues.
Handle handle() const
Returns a platform-specific region handle.
void move(int x, int y)
This corresponds to move(QPoint(x, y)).
Definition: qwidget.h:1011
QPoint mapFromGlobal(const QPoint &pos) const
int screen() const
Returns the number of the screen currently in use.
bool defaultVisual
Definition: qt_x11_p.h:320
void qt_net_update_user_time(QWidget *tlw, unsigned long timestamp)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
static Qt::KeyboardModifiers oldstate
Definition: qdnd_qws.cpp:87
void qPRCreate(const QWidget *widget, Window oldwin)
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
void setWindowIconText_sys(const QString &cap)
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60
static int appDpiY(int screen=-1)
Returns the vertical resolution of the given screen in terms of the number of dots per inch...