| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | - | |||||||||||||||||||
| 15 | - | |||||||||||||||||||
| 16 | - | |||||||||||||||||||
| 17 | - | |||||||||||||||||||
| 18 | - | |||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | - | |||||||||||||||||||
| 21 | - | |||||||||||||||||||
| 22 | - | |||||||||||||||||||
| 23 | enum { | - | ||||||||||||||||||
| 24 | defaultWindowWidth = 160, | - | ||||||||||||||||||
| 25 | defaultWindowHeight = 160 | - | ||||||||||||||||||
| 26 | }; | - | ||||||||||||||||||
| 27 | - | |||||||||||||||||||
| 28 | - | |||||||||||||||||||
| 29 | - | |||||||||||||||||||
| 30 | - | |||||||||||||||||||
| 31 | - | |||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | enum QX11EmbedFocusInDetail { | - | ||||||||||||||||||
| 35 | XEMBED_FOCUS_CURRENT = 0, | - | ||||||||||||||||||
| 36 | XEMBED_FOCUS_FIRST = 1, | - | ||||||||||||||||||
| 37 | XEMBED_FOCUS_LAST = 2 | - | ||||||||||||||||||
| 38 | }; | - | ||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | enum QX11EmbedInfoFlags { | - | ||||||||||||||||||
| 41 | XEMBED_MAPPED = (1 << 0), | - | ||||||||||||||||||
| 42 | }; | - | ||||||||||||||||||
| 43 | - | |||||||||||||||||||
| 44 | enum QX11EmbedMessageType { | - | ||||||||||||||||||
| 45 | XEMBED_EMBEDDED_NOTIFY = 0, | - | ||||||||||||||||||
| 46 | XEMBED_WINDOW_ACTIVATE = 1, | - | ||||||||||||||||||
| 47 | XEMBED_WINDOW_DEACTIVATE = 2, | - | ||||||||||||||||||
| 48 | XEMBED_REQUEST_FOCUS = 3, | - | ||||||||||||||||||
| 49 | XEMBED_FOCUS_IN = 4, | - | ||||||||||||||||||
| 50 | XEMBED_FOCUS_OUT = 5, | - | ||||||||||||||||||
| 51 | XEMBED_FOCUS_NEXT = 6, | - | ||||||||||||||||||
| 52 | XEMBED_FOCUS_PREV = 7, | - | ||||||||||||||||||
| 53 | XEMBED_MODALITY_ON = 10, | - | ||||||||||||||||||
| 54 | XEMBED_MODALITY_OFF = 11, | - | ||||||||||||||||||
| 55 | XEMBED_REGISTER_ACCELERATOR = 12, | - | ||||||||||||||||||
| 56 | XEMBED_UNREGISTER_ACCELERATOR = 13, | - | ||||||||||||||||||
| 57 | XEMBED_ACTIVATE_ACCELERATOR = 14 | - | ||||||||||||||||||
| 58 | }; | - | ||||||||||||||||||
| 59 | - | |||||||||||||||||||
| 60 | const quint32 XEMBED_VERSION = 0; | - | ||||||||||||||||||
| 61 | - | |||||||||||||||||||
| 62 | QXcbScreen *QXcbWindow::parentScreen() | - | ||||||||||||||||||
| 63 | { | - | ||||||||||||||||||
| 64 | return parent() ? static_cast<QXcbWindow*>(parent())->parentScreen() : xcbScreen(); | - | ||||||||||||||||||
| 65 | } | - | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | - | |||||||||||||||||||
| 68 | static inline bool isTransient(const QWindow *w) | - | ||||||||||||||||||
| 69 | { | - | ||||||||||||||||||
| 70 | return w->type() == Qt::Dialog | - | ||||||||||||||||||
| 71 | || w->type() == Qt::Sheet | - | ||||||||||||||||||
| 72 | || w->type() == Qt::Tool | - | ||||||||||||||||||
| 73 | || w->type() == Qt::SplashScreen | - | ||||||||||||||||||
| 74 | || w->type() == Qt::ToolTip | - | ||||||||||||||||||
| 75 | || w->type() == Qt::Drawer | - | ||||||||||||||||||
| 76 | || w->type() == Qt::Popup; | - | ||||||||||||||||||
| 77 | } | - | ||||||||||||||||||
| 78 | - | |||||||||||||||||||
| 79 | static inline QImage::Format imageFormatForVisual(int depth, quint32 red_mask, quint32 blue_mask, bool *rgbSwap) | - | ||||||||||||||||||
| 80 | { | - | ||||||||||||||||||
| 81 |     if (rgbSwap
  | 0-4405 | ||||||||||||||||||
| 82 |         * executed 4405 times by 128 tests:  rgbSwap = false;*rgbSwap = false;Executed by: 
 executed 4405 times by 128 tests:  *rgbSwap = false;Executed by: 
  | 4405 | ||||||||||||||||||
| 83 | switch (depth) { | - | ||||||||||||||||||
| 84 |     case executed 4 times by 2 tests:   32:case 32:Executed by: 
 executed 4 times by 2 tests:  case 32:Executed by: 
  | 4 | ||||||||||||||||||
| 85 |         if (blue_mask == 0xff
  | 0-4 | ||||||||||||||||||
| 86 |             return executed 4 times by 2 tests:   QImage::Format_ARGB32_Premultiplied;return QImage::Format_ARGB32_Premultiplied;Executed by: 
 executed 4 times by 2 tests:  return QImage::Format_ARGB32_Premultiplied;Executed by: 
  | 4 | ||||||||||||||||||
| 87 |         if (red_mask == 0x3ff
  | 0 | ||||||||||||||||||
| 88 |             return never executed:   QImage::Format_A2BGR30_Premultiplied;return QImage::Format_A2BGR30_Premultiplied;never executed:  return QImage::Format_A2BGR30_Premultiplied; | 0 | ||||||||||||||||||
| 89 |         if (blue_mask == 0x3ff
  | 0 | ||||||||||||||||||
| 90 |             return never executed:   QImage::Format_A2RGB30_Premultiplied;return QImage::Format_A2RGB30_Premultiplied;never executed:  return QImage::Format_A2RGB30_Premultiplied; | 0 | ||||||||||||||||||
| 91 |         if (red_mask == 0xff
  | 0 | ||||||||||||||||||
| 92 |             if (rgbSwap
  | 0 | ||||||||||||||||||
| 93 |                 * never executed:  rgbSwap = true;*rgbSwap = true;never executed:  *rgbSwap = true; | 0 | ||||||||||||||||||
| 94 |             return never executed:   QImage::Format_ARGB32_Premultiplied;return QImage::Format_ARGB32_Premultiplied;never executed:  return QImage::Format_ARGB32_Premultiplied; | 0 | ||||||||||||||||||
| 95 | } | - | ||||||||||||||||||
| 96 |         break; never executed:  break; | 0 | ||||||||||||||||||
| 97 |     case never executed:   30:case 30:never executed:  case 30: | 0 | ||||||||||||||||||
| 98 |         if (red_mask == 0x3ff
  | 0 | ||||||||||||||||||
| 99 |             return never executed:   QImage::Format_BGR30;return QImage::Format_BGR30;never executed:  return QImage::Format_BGR30; | 0 | ||||||||||||||||||
| 100 |         if (blue_mask == 0x3ff
  | 0 | ||||||||||||||||||
| 101 |             return never executed:   QImage::Format_RGB30;return QImage::Format_RGB30;never executed:  return QImage::Format_RGB30; | 0 | ||||||||||||||||||
| 102 |         break; never executed:  break; | 0 | ||||||||||||||||||
| 103 |     case executed 4401 times by 128 tests:   24:case 24:Executed by: 
 executed 4401 times by 128 tests:  case 24:Executed by: 
  | 4401 | ||||||||||||||||||
| 104 |         if (blue_mask == 0xff
  | 0-4401 | ||||||||||||||||||
| 105 |             return executed 4401 times by 128 tests:   QImage::Format_RGB32;return QImage::Format_RGB32;Executed by: 
 executed 4401 times by 128 tests:  return QImage::Format_RGB32;Executed by: 
  | 4401 | ||||||||||||||||||
| 106 |         if (red_mask == 0xff
  | 0 | ||||||||||||||||||
| 107 |             if (rgbSwap
  | 0 | ||||||||||||||||||
| 108 |                 * never executed:  rgbSwap = true;*rgbSwap = true;never executed:  *rgbSwap = true; | 0 | ||||||||||||||||||
| 109 |             return never executed:   QImage::Format_RGB32;return QImage::Format_RGB32;never executed:  return QImage::Format_RGB32; | 0 | ||||||||||||||||||
| 110 | } | - | ||||||||||||||||||
| 111 |         break; never executed:  break; | 0 | ||||||||||||||||||
| 112 |     case never executed:   16:case 16:never executed:  case 16: | 0 | ||||||||||||||||||
| 113 |         if (blue_mask == 0x1f
  | 0 | ||||||||||||||||||
| 114 |             return never executed:   QImage::Format_RGB16;return QImage::Format_RGB16;never executed:  return QImage::Format_RGB16; | 0 | ||||||||||||||||||
| 115 |         if (red_mask == 0x1f
  | 0 | ||||||||||||||||||
| 116 |             if (rgbSwap
  | 0 | ||||||||||||||||||
| 117 |                 * never executed:  rgbSwap = true;*rgbSwap = true;never executed:  *rgbSwap = true; | 0 | ||||||||||||||||||
| 118 |             return never executed:   QImage::Format_RGB16;return QImage::Format_RGB16;never executed:  return QImage::Format_RGB16; | 0 | ||||||||||||||||||
| 119 | } | - | ||||||||||||||||||
| 120 |         break; never executed:  break; | 0 | ||||||||||||||||||
| 121 |     case never executed:   15:case 15:never executed:  case 15: | 0 | ||||||||||||||||||
| 122 |         if (blue_mask == 0x1f
  | 0 | ||||||||||||||||||
| 123 |             return never executed:   QImage::Format_RGB555;return QImage::Format_RGB555;never executed:  return QImage::Format_RGB555; | 0 | ||||||||||||||||||
| 124 |         if (red_mask == 0x1f
  | 0 | ||||||||||||||||||
| 125 |             if (rgbSwap
  | 0 | ||||||||||||||||||
| 126 |                 * never executed:  rgbSwap = true;*rgbSwap = true;never executed:  *rgbSwap = true; | 0 | ||||||||||||||||||
| 127 |             return never executed:   QImage::Format_RGB555;return QImage::Format_RGB555;never executed:  return QImage::Format_RGB555; | 0 | ||||||||||||||||||
| 128 | } | - | ||||||||||||||||||
| 129 |         break; never executed:  break; | 0 | ||||||||||||||||||
| 130 |     default never executed:  :default:never executed:  default: | 0 | ||||||||||||||||||
| 131 |         break; never executed:  break; | 0 | ||||||||||||||||||
| 132 | } | - | ||||||||||||||||||
| 133 | QMessageLogger(__FILE__, 203223, __PRETTY_FUNCTION__).warning("Unsupported screen format: depth: %d, red_mask: %x, blue_mask: %x", depth, red_mask, blue_mask); | - | ||||||||||||||||||
| 134 | - | |||||||||||||||||||
| 135 | switch (depth) { | - | ||||||||||||||||||
| 136 |     case never executed:   24:case 24:never executed:  case 24: | 0 | ||||||||||||||||||
| 137 | QMessageLogger(__FILE__, 207227, __PRETTY_FUNCTION__).warning("Using RGB32 fallback, if this works your X11 server is reporting a bad screen format."); | - | ||||||||||||||||||
| 138 |         return never executed:   QImage::Format_RGB32;return QImage::Format_RGB32;never executed:  return QImage::Format_RGB32; | 0 | ||||||||||||||||||
| 139 |     case never executed:   16:case 16:never executed:  case 16: | 0 | ||||||||||||||||||
| 140 | QMessageLogger(__FILE__, 210230, __PRETTY_FUNCTION__).warning("Using RGB16 fallback, if this works your X11 server is reporting a bad screen format."); | - | ||||||||||||||||||
| 141 |         return never executed:   QImage::Format_RGB16;return QImage::Format_RGB16;never executed:  return QImage::Format_RGB16; | 0 | ||||||||||||||||||
| 142 |     default never executed:  :default:never executed:  default: | 0 | ||||||||||||||||||
| 143 |         break; never executed:  break; | 0 | ||||||||||||||||||
| 144 | } | - | ||||||||||||||||||
| 145 | - | |||||||||||||||||||
| 146 |     return never executed:   QImage::Format_Invalid;return QImage::Format_Invalid;never executed:  return QImage::Format_Invalid; | 0 | ||||||||||||||||||
| 147 | } | - | ||||||||||||||||||
| 148 | - | |||||||||||||||||||
| 149 | static inline bool positionIncludesFrame(QWindow *w) | - | ||||||||||||||||||
| 150 | { | - | ||||||||||||||||||
| 151 | return qt_window_private(w)->positionPolicy == QWindowPrivate::WindowFrameInclusive; | - | ||||||||||||||||||
| 152 | } | - | ||||||||||||||||||
| 153 | - | |||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 | static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s) | - | ||||||||||||||||||
| 156 | { | - | ||||||||||||||||||
| 157 | - | |||||||||||||||||||
| 158 | static XTextProperty tp = { 0, 0, 0, 0 }; | - | ||||||||||||||||||
| 159 | static bool free_prop = true; | - | ||||||||||||||||||
| 160 | - | |||||||||||||||||||
| 161 | if (tp.value) { | - | ||||||||||||||||||
| 162 | if (free_prop) | - | ||||||||||||||||||
| 163 | XFree(tp.value); | - | ||||||||||||||||||
| 164 | tp.value = 0; | - | ||||||||||||||||||
| 165 | free_prop = true; | - | ||||||||||||||||||
| 166 | } | - | ||||||||||||||||||
| 167 | - | |||||||||||||||||||
| 168 | static const QTextCodec* mapper = QTextCodec::codecForLocale(); | - | ||||||||||||||||||
| 169 | int errCode = 0; | - | ||||||||||||||||||
| 170 | if (mapper) { | - | ||||||||||||||||||
| 171 | QByteArray mapped = mapper->fromUnicode(s); | - | ||||||||||||||||||
| 172 | char* tl[2]; | - | ||||||||||||||||||
| 173 | tl[0] = mapped.data(); | - | ||||||||||||||||||
| 174 | tl[1] = 0; | - | ||||||||||||||||||
| 175 | errCode = XmbTextListToTextProperty(dpy, tl, 1, XStdICCTextStyle, &tp); | - | ||||||||||||||||||
| 176 | if (errCode < 0) | - | ||||||||||||||||||
| 177 | QMessageLogger(__FILE__, 248268, __PRETTY_FUNCTION__).debug("XmbTextListToTextProperty result code %d", errCode); | - | ||||||||||||||||||
| 178 | } | - | ||||||||||||||||||
| 179 | if (!mapper || errCode < 0) { | - | ||||||||||||||||||
| 180 | mapper = QTextCodec::codecForName("latin1"); | - | ||||||||||||||||||
| 181 | if (!mapper || !mapper->canEncode(s)) | - | ||||||||||||||||||
| 182 | return nullptr; | - | ||||||||||||||||||
| 183 | static QByteArray qcs; | - | ||||||||||||||||||
| 184 | qcs = s.toLatin1(); | - | ||||||||||||||||||
| 185 | tp.value = (uchar*)qcs.data(); | - | ||||||||||||||||||
| 186 | tp.encoding = ((Atom) 31); | - | ||||||||||||||||||
| 187 | tp.format = 8; | - | ||||||||||||||||||
| 188 | tp.nitems = qcs.length(); | - | ||||||||||||||||||
| 189 | free_prop = false; | - | ||||||||||||||||||
| 190 | } | - | ||||||||||||||||||
| 191 | return &tp; | - | ||||||||||||||||||
| 192 | } | - | ||||||||||||||||||
| 193 | - | |||||||||||||||||||
| 194 | - | |||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | static QWindow *childWindowAt(QWindow *win, const QPoint &p) | - | ||||||||||||||||||
| 197 | { | - | ||||||||||||||||||
| 198 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(win->children())>::type> _container_((win->children())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QObject *obj = *_container_.i; _container_.control; _container_.control = 0): win->children()) { | - | ||||||||||||||||||
| 199 |         if (obj->isWindowType()
  | 0-3 | ||||||||||||||||||
| 200 | QWindow *childWin = static_cast<QWindow *>(obj); | - | ||||||||||||||||||
| 201 |             if (childWin->isVisible()
  | 1-2 | ||||||||||||||||||
| 202 |                 if (QWindow *recurse = childWindowAt(childWin, p)
  | 0-2 | ||||||||||||||||||
| 203 |                     return executed 2 times by 1 test:   recurse;return recurse;Executed by: 
 executed 2 times by 1 test:  return recurse;Executed by: 
  | 2 | ||||||||||||||||||
| 204 |             } never executed:  end of block | 0 | ||||||||||||||||||
| 205 |         } executed 1 time by 1 test:  end of blockExecuted by: 
  | 1 | ||||||||||||||||||
| 206 |     } executed 1 time by 1 test:  end of blockExecuted by: 
  | 1 | ||||||||||||||||||
| 207 |     if (!win->isTopLevel()
  | 1-5 | ||||||||||||||||||
| 208 |             && !(win->flags() & Qt::WindowTransparentForInput)
  | 0-1 | ||||||||||||||||||
| 209 |             && win->geometry().contains(win->parent()->mapFromGlobal(p))
  | 0-1 | ||||||||||||||||||
| 210 |         return executed 1 time by 1 test:   win;return win;Executed by: 
 executed 1 time by 1 test:  return win;Executed by: 
  | 1 | ||||||||||||||||||
| 211 | } | - | ||||||||||||||||||
| 212 |     return executed 5 times by 3 tests:   nullptr;return nullptr;Executed by: 
 executed 5 times by 3 tests:  return nullptr;Executed by: 
  | 5 | ||||||||||||||||||
| 213 | } | - | ||||||||||||||||||
| 214 | - | |||||||||||||||||||
| 215 | static const char *wm_window_type_property_id = "_q_xcb_wm_window_type"; | - | ||||||||||||||||||
| 216 | static const char *wm_window_role_property_id = "_q_xcb_wm_window_role"; | - | ||||||||||||||||||
| 217 | - | |||||||||||||||||||
| 218 | QXcbWindow::QXcbWindow(QWindow *window) | - | ||||||||||||||||||
| 219 | : QPlatformWindow(window) | - | ||||||||||||||||||
| 220 | , m_window(0) | - | ||||||||||||||||||
| 221 | , m_syncCounter(0) | - | ||||||||||||||||||
| 222 | , m_gravity(XCB_GRAVITY_STATIC) | - | ||||||||||||||||||
| 223 | , m_mapped(false) | - | ||||||||||||||||||
| 224 | , m_transparent(false) | - | ||||||||||||||||||
| 225 | , m_usingSyncProtocol(false) | - | ||||||||||||||||||
| 226 | , m_deferredActivation(false) | - | ||||||||||||||||||
| 227 | , m_embedded(false) | - | ||||||||||||||||||
| 228 | , m_alertState(false) | - | ||||||||||||||||||
| 229 | , m_netWmUserTimeWindow(0L) | - | ||||||||||||||||||
| 230 | , m_dirtyFrameMargins(false) | - | ||||||||||||||||||
| 231 | , m_lastWindowStateEvent(-1) | - | ||||||||||||||||||
| 232 | , m_syncState(NoSyncNeeded) | - | ||||||||||||||||||
| 233 | , m_pendingSyncRequest(0) | - | ||||||||||||||||||
| 234 | , m_currentBitmapCursor(XCB_CURSOR_NONE) | - | ||||||||||||||||||
| 235 | { | - | ||||||||||||||||||
| 236 | setConnection(xcbScreen()->connection()); | - | ||||||||||||||||||
| 237 | } | - | ||||||||||||||||||
| 238 | - | |||||||||||||||||||
| 239 | - | |||||||||||||||||||
| 240 | enum : quint32 { | - | ||||||||||||||||||
| 241 | - | |||||||||||||||||||
| 242 | - | |||||||||||||||||||
| 243 | - | |||||||||||||||||||
| 244 | baseEventMask | - | ||||||||||||||||||
| 245 | = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | - | ||||||||||||||||||
| 246 | | XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_FOCUS_CHANGE, | - | ||||||||||||||||||
| 247 | - | |||||||||||||||||||
| 248 | defaultEventMask = baseEventMask | - | ||||||||||||||||||
| 249 | | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE | - | ||||||||||||||||||
| 250 | | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | - | ||||||||||||||||||
| 251 | | XCB_EVENT_MASK_BUTTON_MOTION | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | - | ||||||||||||||||||
| 252 | | XCB_EVENT_MASK_POINTER_MOTION, | - | ||||||||||||||||||
| 253 | - | |||||||||||||||||||
| 254 | transparentForInputEventMask = baseEventMask | - | ||||||||||||||||||
| 255 | | XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_RESIZE_REDIRECT | - | ||||||||||||||||||
| 256 | | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | - | ||||||||||||||||||
| 257 | | XCB_EVENT_MASK_COLOR_MAP_CHANGE | XCB_EVENT_MASK_OWNER_GRAB_BUTTON | - | ||||||||||||||||||
| 258 | }; | - | ||||||||||||||||||
| 259 | - | |||||||||||||||||||
| 260 | void QXcbWindow::create() | - | ||||||||||||||||||
| 261 | { | - | ||||||||||||||||||
| 262 |     if (window()->type() == Qt::ForeignWindow
  | 0-4405 | ||||||||||||||||||
| 263 | m_window = window()->winId(); | - | ||||||||||||||||||
| 264 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 265 | } | - | ||||||||||||||||||
| 266 | - | |||||||||||||||||||
| 267 | destroy(); | - | ||||||||||||||||||
| 268 | - | |||||||||||||||||||
| 269 | m_windowState = Qt::WindowNoState; | - | ||||||||||||||||||
| 270 | - | |||||||||||||||||||
| 271 | Qt::WindowType type = window()->type(); | - | ||||||||||||||||||
| 272 | - | |||||||||||||||||||
| 273 | QXcbScreen *currentScreen = xcbScreen(); | - | ||||||||||||||||||
| 274 | QRect rect = windowGeometry(); | - | ||||||||||||||||||
| 275 |     QXcbScreen *platformScreen = parent()
  | 97-4308 | ||||||||||||||||||
| 276 | - | |||||||||||||||||||
| 277 |     if (type == Qt::Desktop
  | 298-4107 | ||||||||||||||||||
| 278 | m_window = platformScreen->root(); | - | ||||||||||||||||||
| 279 | m_depth = platformScreen->screen()->root_depth; | - | ||||||||||||||||||
| 280 | m_visualId = platformScreen->screen()->root_visual; | - | ||||||||||||||||||
| 281 | const xcb_visualtype_t *visual = 0; | - | ||||||||||||||||||
| 282 |         if (connection()->hasDefaultVisualId()
  | 0-298 | ||||||||||||||||||
| 283 | visual = platformScreen->visualForId(connection()->defaultVisualId()); | - | ||||||||||||||||||
| 284 |             if (visual
  | 0 | ||||||||||||||||||
| 285 |                 m_visualId = connection()->defaultVisualId(); never executed:  m_visualId = connection()->defaultVisualId(); | 0 | ||||||||||||||||||
| 286 |             if (!visual
  | 0 | ||||||||||||||||||
| 287 |                 QMessageLogger(__FILE__, 358378, __PRETTY_FUNCTION__).warning() << ("Could not use default visual id. Falling back to root_visual for screen.";); never executed:  QMessageLogger(__FILE__, 378, __PRETTY_FUNCTION__).warning("Could not use default visual id. Falling back to root_visual for screen."); | 0 | ||||||||||||||||||
| 288 |         } never executed:  end of block | 0 | ||||||||||||||||||
| 289 |         if (!visual
  | 0-298 | ||||||||||||||||||
| 290 |             visual = platformScreen->visualForId(m_visualId); executed 298 times by 117 tests:  visual = platformScreen->visualForId(m_visualId);Executed by: 
  | 298 | ||||||||||||||||||
| 291 | m_imageFormat = imageFormatForVisual(m_depth, visual->red_mask, visual->blue_mask, &m_imageRgbSwap); | - | ||||||||||||||||||
| 292 | connection()->addWindowEventListener(m_window, this); | - | ||||||||||||||||||
| 293 |         return; executed 298 times by 117 tests:  return;Executed by: 
  | 298 | ||||||||||||||||||
| 294 | } | - | ||||||||||||||||||
| 295 | - | |||||||||||||||||||
| 296 | - | |||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | - | |||||||||||||||||||
| 299 | const quint32 mask = XCB_CW_BACK_PIXMAP | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK; | - | ||||||||||||||||||
| const quint32 values[] = { | ||||||||||||||||||||
| 0L, | ||||||||||||||||||||
| type == Qt::Popup || type == Qt::ToolTip || (window()->flags() & Qt::BypassWindowManagerHint), | ||||||||||||||||||||
| type == Qt::Popup || type == Qt::Tool || type == Qt::SplashScreen || type == Qt::ToolTip || type == Qt::Drawer, | ||||||||||||||||||||
| defaultEventMask | ||||||||||||||||||||
| };QPlatformWindow::setGeometry(rect); | ||||||||||||||||||||
| 300 | - | |||||||||||||||||||
| 301 |     if (platformScreen != currentScreen
  | 0-4107 | ||||||||||||||||||
| 302 |         QWindowSystemInterface::handleWindowScreenChanged(window(), platformScreen->QPlatformScreen::screen()); never executed:  QWindowSystemInterface::handleWindowScreenChanged(window(), platformScreen->QPlatformScreen::screen()); | 0 | ||||||||||||||||||
| 303 | - | |||||||||||||||||||
| 304 | const QSize minimumSize = windowMinimumSize(); | - | ||||||||||||||||||
| 305 |     if (rect.width() > 0
 
  | 0-4034 | ||||||||||||||||||
| 306 | rect.setWidth(qBound(1, rect.width(), 16383)); | - | ||||||||||||||||||
| 307 | rect.setHeight(qBound(1, rect.height(), 16383)); | - | ||||||||||||||||||
| 308 |     } executed 4034 times by 119 tests:   else if (minimumSize.width() > 0end of blockExecuted by: 
 
 
  | 0-4034 | ||||||||||||||||||
| 309 | rect.setSize(minimumSize); | - | ||||||||||||||||||
| 310 |     } never executed:   else {end of block | 0 | ||||||||||||||||||
| 311 | rect.setWidth(QHighDpi::toNativePixels(int(defaultWindowWidth), platformScreen->QPlatformScreen::screen())); | - | ||||||||||||||||||
| 312 | rect.setHeight(QHighDpi::toNativePixels(int(defaultWindowHeight), platformScreen->QPlatformScreen::screen())); | - | ||||||||||||||||||
| 313 |     } executed 73 times by 13 tests:  end of blockExecuted by: 
  | 73 | ||||||||||||||||||
| 314 | - | |||||||||||||||||||
| 315 | xcb_window_t xcb_parent_id = platformScreen->root(); | - | ||||||||||||||||||
| 316 |     if (parent()
  | 97-4010 | ||||||||||||||||||
| 317 | xcb_parent_id = static_cast<QXcbWindow *>(parent())->xcb_window(); | - | ||||||||||||||||||
| 318 | m_embedded = parent()->window()->type() == Qt::ForeignWindow; | - | ||||||||||||||||||
| 319 | - | |||||||||||||||||||
| 320 | QSurfaceFormat parentFormat = parent()->window()->requestedFormat(); | - | ||||||||||||||||||
| 321 |         if (window()->surfaceType() != QSurface::OpenGLSurface
 
  | 0-97 | ||||||||||||||||||
| 322 | window()->setFormat(parentFormat); | - | ||||||||||||||||||
| 323 |         } never executed:  end of block | 0 | ||||||||||||||||||
| 324 |     } executed 97 times by 6 tests:  end of blockExecuted by: 
  | 97 | ||||||||||||||||||
| 325 | - | |||||||||||||||||||
| 326 | resolveFormat(); | - | ||||||||||||||||||
| if(platformScreen->surfaceFormatFor(window()->surfaceType() != QSurface::RasterSurface | ||||||||||||||||||||
| && QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) { | ||||||||||||||||||||
| XVisualInforequestedFormat())); | ||||||||||||||||||||
| 327 | - | |||||||||||||||||||
| 328 | const xcb_visualtype_t *visualInfovisual = nullptr; | - | ||||||||||||||||||
| 329 | - | |||||||||||||||||||
| 330 |     if (connection()->hasDefaultVisualId()
  | 0-4107 | ||||||||||||||||||
| 331 | visual = ((XVisualInfo *)(thisplatformScreen->visualForId(connection()->createVisualInfoForDefaultVisualId())); | - | ||||||||||||||||||
| if (!visualInfo) | ||||||||||||||||||||
| visualInfo = static_cast<XVisualInfo *>(createVisualdefaultVisualId()); | ||||||||||||||||||||
| 332 | if (!visualInfo && window()->surfaceType() == QSurface::OpenGLSurface) | 0 | ||||||||||||||||||
            QMessageLogger(__FILE__, 421, __PRETTY_FUNCTION__).fatal("Could not initialize OpenGL");if (!visualInfo && window()->surfaceType() == QSurface::RasterGLSurfacevisual
  | ||||||||||||||||||||
| 333 |             {QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__).warning("Could not initialize() << OpenGL"Failed forto RasterGLSurface,use revertingrequested tovisual RasterSurfaceid."); never executed:  QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__).warning() << "Failed to use requested visual id."; | 0 | ||||||||||||||||||
|             window()->setSurfaceType(QSurface::RasterSurface); never executed:  QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__).warning() << "Failed to use requested visual id."; | ||||||||||||||||||||
|         } never executed:  QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__).warning() << "Failed to use requested visual id."; | ||||||||||||||||||||
|         if (visualInfo) { never executed:  QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__).warning() << "Failed to use requested visual id."; | ||||||||||||||||||||
|             m_depth = visualInfo->depth; never executed:  QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__).warning() << "Failed to use requested visual id."; | ||||||||||||||||||||
|             m_imageFormat = imageFormatForVisual(visualInfo->depth, visualInfo->red_mask, visualInfo->blue_mask, &m_imageRgbSwap); never executed:  QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__).warning() << "Failed to use requested visual id."; | ||||||||||||||||||||
|             Colormap cmap = XCreateColormap(((Display *)(this->connection()->xlib_display())), xcb_parent_id, visualInfo->visual, 0); never executed:  QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__).warning() << "Failed to use requested visual id."; | ||||||||||||||||||||
|             XSetWindowAttributes a; never executed:  QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__).warning() << "Failed to use requested visual id."; | ||||||||||||||||||||
|             a.background_pixel = ((&((_XPrivDisplay)((Display *)(this->connection()->xlib_display())))->screens[platformScreen->screenNumber()])->white_pixel); never executed:  QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__).warning() << "Failed to use requested visual id."; | ||||||||||||||||||||
|             a.border_pixel = ((&((_XPrivDisplay)((Display *)(this->connection()->xlib_display())))->screens[platformScreen->screenNumber()])->black_pixel); never executed:  QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__).warning() << "Failed to use requested visual id."; | ||||||||||||||||||||
|             a.colormap = cmap; never executed:  QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__).warning() << "Failed to use requested visual id."; | ||||||||||||||||||||
|             m_visualId = visualInfo->visualid never executed:  QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__).warning() << "Failed to use requested visual id.";never executed:  ;QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__).warning() << "Failed to use requested visual id.";never executed:  QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__).warning() << "Failed to use requested visual id."; | ||||||||||||||||||||
| 334 | m_window = XCreateWindow(((Display *)(this->connection()->xlib_display())), xcb_parent_id, rect.x(), rect.y(), rect.width(), rect.height(), | 0 | ||||||||||||||||||
| 0, visualInfo->depth, 1, visualInfo->visual, | ||||||||||||||||||||
| (1L<<1)|(1L<<3)|(1L<<13), &a); | ||||||||||||||||||||
| XFree(visualInfo); | ||||||||||||||||||||
|         }} never executed:  end of block | ||||||||||||||||||||
| 335 | - | |||||||||||||||||||
| 336 |     if (!m_windowvisual
  | 0-4107 | ||||||||||||||||||
| 337 | { | 4107 | ||||||||||||||||||
| m_window = xcb_generate_id(xcb_connection()); | ||||||||||||||||||||
| m_visualId = (2147483647 * 2U + 1U); | ||||||||||||||||||||
|         const xcb_visualtype_t *visual = nullptr; executed 4107 times by 125 tests:  visual = createVisual();Executed by: 
  | ||||||||||||||||||||
|         m_depth = platformScreen->screen()->root_depth; executed 4107 times by 125 tests:  visual = createVisual();Executed by: 
  | ||||||||||||||||||||
|         uint32_t mask = 0; executed 4107 times by 125 tests:  visual = createVisual();Executed by: 
  | ||||||||||||||||||||
|         uint32_t values[3]; executed 4107 times by 125 tests:  visual = createVisual();Executed by: 
  | ||||||||||||||||||||
|         if (connection()->hasDefaultVisualId()) { executed 4107 times by 125 tests:  visual = createVisual();Executed by: 
  | ||||||||||||||||||||
|             m_visualId executed 4107 times by 125 tests:  visual = createVisual();Executed by: 
 executed 4107 times by 125 tests:  = connection()->defaultVisualIdcreateVisual();visual = createVisual();Executed by: 
 executed 4107 times by 125 tests:  visual = createVisual();Executed by: 
  | ||||||||||||||||||||
| 338 | - | |||||||||||||||||||
| 339 | visual = platformScreen->visualForId(m_visualId); | 0-4107 | ||||||||||||||||||
        }if (!visual
  | ||||||||||||||||||||
| 340 | if (connection()->hasDefaultVisualId())QMessageLogger(__FILE__, 466431, __PRETTY_FUNCTION__).warning("Failed to use default visual id.() << Falling"Falling back to using screens root_visual"); | - | ||||||||||||||||||
| m_visualIdroot_visual."; | ||||||||||||||||||||
| 341 | visual = platformScreen->visualForId(platformScreen->screen()->root_visual; | - | ||||||||||||||||||
| if); | ||||||||||||||||||||
| 342 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 343 | - | |||||||||||||||||||
| 344 | ((!(visual)) ? qt_assert(m_format.alphaBufferSize() == 8"visual",__FILE__,435) { | - | ||||||||||||||||||
| xcb_depth_iterator_t depthIter: qt_noop()); | ||||||||||||||||||||
| 345 | - | |||||||||||||||||||
| 346 | m_visualId = xcb_screen_allowed_depths_iterator(visual->visual_id; | - | ||||||||||||||||||
| 347 | m_depth = platformScreen->screen()); | - | ||||||||||||||||||
| whiledepthOfVisual(depthIter.rem) { | ||||||||||||||||||||
| ifm_visualId); | ||||||||||||||||||||
| 348 | m_imageFormat = imageFormatForVisual(depthIter.datam_depth, visual->depth == 32) { | - | ||||||||||||||||||
| xcb_visualtype_iterator_t visualIterred_mask, visual->blue_mask, &m_imageRgbSwap); | ||||||||||||||||||||
| 349 | xcb_colormap_t colormap = xcb_depth_visuals_iterator0; | - | ||||||||||||||||||
| 350 | - | |||||||||||||||||||
| 351 | quint32 mask = XCB_CW_BACK_PIXMAP | - | ||||||||||||||||||
| 352 | | XCB_CW_BORDER_PIXEL | - | ||||||||||||||||||
| 353 | | XCB_CW_BIT_GRAVITY | - | ||||||||||||||||||
| 354 | | XCB_CW_OVERRIDE_REDIRECT | - | ||||||||||||||||||
| 355 | | XCB_CW_SAVE_UNDER | - | ||||||||||||||||||
| 356 | | XCB_CW_EVENT_MASK; | - | ||||||||||||||||||
| 357 | - | |||||||||||||||||||
| 358 | static const bool haveOpenGL = QGuiApplicationPrivate::platformIntegration()->hasCapability(depthIter.dataQPlatformIntegration::OpenGL); | - | ||||||||||||||||||
| 359 | - | |||||||||||||||||||
| 360 |     if (visualIter.rem((window()->supportsOpenGL()
 
  | 0-3974 | ||||||||||||||||||
                            m_visualId = visualIter|| m_format
 
  | ||||||||||||||||||||
                            m_depth = 32;
  | ||||||||||||||||||||
                            uint32_t
 
 
  | ||||||||||||||||||||
| 361 | colormap = xcb_generate_id(xcb_connection()); | - | ||||||||||||||||||
| 362 | xcb_create_colormap(xcb_connection(), XCB_COLORMAP_ALLOC_NONE, colormap, xcb_parent_id, m_visualId);) | - | ||||||||||||||||||
| 363 | - | |||||||||||||||||||
| 364 | - | |||||||||||||||||||
| 365 | - | |||||||||||||||||||
| 366 | ; | - | ||||||||||||||||||
| 367 | - | |||||||||||||||||||
| 368 | mask |= XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL |XCB_CW_COLORMAP; | - | ||||||||||||||||||
| values[0] = platformScreen->screen()->white_pixel; | ||||||||||||||||||||
| 369 |     } executed 3974 times by 118 tests:  end of blockExecuted by: 
  | 3974 | ||||||||||||||||||
| 370 | - | |||||||||||||||||||
| 371 | quint32 values[1][] = { | - | ||||||||||||||||||
| 372 | XCB_BACK_PIXMAP_NONE, | - | ||||||||||||||||||
| 373 | platformScreen->screen()->black_pixel; | - | ||||||||||||||||||
| values[2] = colormap; | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| xcb_depth_next(&depthIter); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| visual = platformScreen->visualForId(m_visualId); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| m_imageFormat = imageFormatForVisual(m_depth, | ||||||||||||||||||||
| 374 | visual->red_maskXCB_GRAVITY_NORTH_WEST, | - | ||||||||||||||||||
| 375 | visual->blue_masktype == Qt::Popup || type == Qt::ToolTip || (window()->flags() & Qt::BypassWindowManagerHint), | - | ||||||||||||||||||
| 376 | type == Qt::Popup || type == Qt::Tool || type == Qt::SplashScreen || type == Qt::ToolTip || type == Qt::Drawer, | - | ||||||||||||||||||
| 377 | &m_imageRgbSwap);defaultEventMask, | - | ||||||||||||||||||
| 378 | colormap | - | ||||||||||||||||||
| 379 | }; | - | ||||||||||||||||||
| 380 | - | |||||||||||||||||||
| 381 | m_window = xcb_generate_id(xcb_connection()); | - | ||||||||||||||||||
| 382 | xcb_create_window(xcb_connection(), m_depth, m_window, xcb_parent_id, rect.x(), rect.y(), rect.width(), rect.height(), 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, m_visualId, mask, values) | - | ||||||||||||||||||
| 383 | ; | - | ||||||||||||||||||
| 384 | - | |||||||||||||||||||
| 385 | }connection()->addWindowEventListener(m_window, this); | - | ||||||||||||||||||
| 386 | - | |||||||||||||||||||
| 387 | xcb_change_window_attributes(xcb_connection(), m_window, mask, values); | - | ||||||||||||||||||
| 388 | - | |||||||||||||||||||
| 389 | propagateSizeHints(); | - | ||||||||||||||||||
| 390 | - | |||||||||||||||||||
| 391 | xcb_atom_t properties[5]; | - | ||||||||||||||||||
| 392 | int propertyCount = 0; | - | ||||||||||||||||||
| 393 | properties[propertyCount++] = atom(QXcbAtom::WM_DELETE_WINDOW); | - | ||||||||||||||||||
| 394 | properties[propertyCount++] = atom(QXcbAtom::WM_TAKE_FOCUS); | - | ||||||||||||||||||
| 395 | properties[propertyCount++] = atom(QXcbAtom::_NET_WM_PING); | - | ||||||||||||||||||
| 396 | - | |||||||||||||||||||
| 397 | m_usingSyncProtocol = platformScreen->syncRequestSupported(); | - | ||||||||||||||||||
| 398 | - | |||||||||||||||||||
| 399 |     if (m_usingSyncProtocol
  | 0-4107 | ||||||||||||||||||
| 400 |         properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST); executed 4107 times by 125 tests:  properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST);Executed by: 
  | 4107 | ||||||||||||||||||
| 401 | - | |||||||||||||||||||
| 402 |     if (window()->flags() & Qt::WindowContextHelpButtonHint
  | 223-3884 | ||||||||||||||||||
| 403 |         properties[propertyCount++] = atom(QXcbAtom::_NET_WM_CONTEXT_HELP); executed 223 times by 25 tests:  properties[propertyCount++] = atom(QXcbAtom::_NET_WM_CONTEXT_HELP);Executed by: 
  | 223 | ||||||||||||||||||
| 404 | - | |||||||||||||||||||
| 405 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::WM_PROTOCOLS), XCB_ATOM_ATOM, 32, propertyCount, properties) | - | ||||||||||||||||||
| 406 | - | |||||||||||||||||||
| 407 | - | |||||||||||||||||||
| 408 | - | |||||||||||||||||||
| 409 | - | |||||||||||||||||||
| 410 | - | |||||||||||||||||||
| 411 | - | |||||||||||||||||||
| 412 | ; | - | ||||||||||||||||||
| 413 | m_syncValue.hi = 0; | - | ||||||||||||||||||
| 414 | m_syncValue.lo = 0; | - | ||||||||||||||||||
| 415 | - | |||||||||||||||||||
| 416 | const QByteArray wmClass = QXcbIntegration::instance()->wmClass(); | - | ||||||||||||||||||
| 417 |     if (!wmClass.isEmpty()
  | 51-4056 | ||||||||||||||||||
| 418 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::WM_CLASS), XCB_ATOM_STRING, 8, wmClass.size(), wmClass.constData()) | - | ||||||||||||||||||
| 419 | - | |||||||||||||||||||
| 420 | ; | - | ||||||||||||||||||
| 421 |     } executed 4056 times by 125 tests:  end of blockExecuted by: 
  | 4056 | ||||||||||||||||||
| 422 | - | |||||||||||||||||||
| 423 |     if (m_usingSyncProtocol
  | 0-4107 | ||||||||||||||||||
| 424 | m_syncCounter = xcb_generate_id(xcb_connection()); | - | ||||||||||||||||||
| 425 | xcb_sync_create_counter(xcb_connection(), m_syncCounter, m_syncValue); | - | ||||||||||||||||||
| 426 | - | |||||||||||||||||||
| 427 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_SYNC_REQUEST_COUNTER), XCB_ATOM_CARDINAL, 32, 1, &m_syncCounter) | - | ||||||||||||||||||
| 428 | - | |||||||||||||||||||
| 429 | - | |||||||||||||||||||
| 430 | - | |||||||||||||||||||
| 431 | - | |||||||||||||||||||
| 432 | - | |||||||||||||||||||
| 433 | - | |||||||||||||||||||
| 434 | ; | - | ||||||||||||||||||
| 435 |     } executed 4107 times by 125 tests:  end of blockExecuted by: 
  | 4107 | ||||||||||||||||||
| 436 | - | |||||||||||||||||||
| 437 | - | |||||||||||||||||||
| 438 | quint32 pid = getpid(); | - | ||||||||||||||||||
| 439 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_PID), XCB_ATOM_CARDINAL, 32, 1, &pid) | - | ||||||||||||||||||
| 440 | - | |||||||||||||||||||
| 441 | ; | - | ||||||||||||||||||
| 442 | - | |||||||||||||||||||
| 443 | xcb_icccm_wm_hints_t hints; | - | ||||||||||||||||||
| 444 | memset(&hints, 0, sizeof(hints)); | - | ||||||||||||||||||
| 445 | xcb_icccm_wm_hints_set_normal(&hints); | - | ||||||||||||||||||
| 446 | - | |||||||||||||||||||
| 447 | xcb_icccm_wm_hints_set_input(&hints, !(window()->flags() & Qt::WindowDoesNotAcceptFocus)); | - | ||||||||||||||||||
| 448 | - | |||||||||||||||||||
| 449 | xcb_icccm_set_wm_hints(xcb_connection(), m_window, &hints); | - | ||||||||||||||||||
| 450 | - | |||||||||||||||||||
| 451 | xcb_window_t leader = connection()->clientLeader(); | - | ||||||||||||||||||
| 452 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::WM_CLIENT_LEADER), XCB_ATOM_WINDOW, 32, 1, &leader) | - | ||||||||||||||||||
| 453 | - | |||||||||||||||||||
| 454 | ; | - | ||||||||||||||||||
| 455 | - | |||||||||||||||||||
| 456 | - | |||||||||||||||||||
| 457 | quint32 data[] = { XEMBED_VERSION, XEMBED_MAPPED }; | - | ||||||||||||||||||
| 458 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_XEMBED_INFO), atom(QXcbAtom::_XEMBED_INFO), 32, 2, (void *)data) | - | ||||||||||||||||||
| 459 | - | |||||||||||||||||||
| 460 | - | |||||||||||||||||||
| 461 | ; | - | ||||||||||||||||||
| 462 | - | |||||||||||||||||||
| 463 | - | |||||||||||||||||||
| 464 | - | |||||||||||||||||||
| 465 | connection()->xi2Select(m_window); | - | ||||||||||||||||||
| 466 | - | |||||||||||||||||||
| 467 | - | |||||||||||||||||||
| 468 | setWindowState(window()->windowState()); | - | ||||||||||||||||||
| 469 | setWindowFlags(window()->flags()); | - | ||||||||||||||||||
| 470 | setWindowTitle(window()->title()); | - | ||||||||||||||||||
| 471 | - | |||||||||||||||||||
| 472 |     if (window()->flags() & Qt::WindowTransparentForInput
  | 1-4106 | ||||||||||||||||||
| 473 |         setTransparentForMouseEvents(true); executed 1 time by 1 test:  setTransparentForMouseEvents(true);Executed by: 
  | 1 | ||||||||||||||||||
| 474 | - | |||||||||||||||||||
| 475 | - | |||||||||||||||||||
| 476 | - | |||||||||||||||||||
| 477 | XSync(((Display *)(platformScreen->connection()->xlib_display())), false); | - | ||||||||||||||||||
| 478 | - | |||||||||||||||||||
| 479 | - | |||||||||||||||||||
| 480 | - | |||||||||||||||||||
| 481 | connection()->drag()->dndEnable(this, true); | - | ||||||||||||||||||
| 482 | - | |||||||||||||||||||
| 483 | - | |||||||||||||||||||
| 484 | const qreal opacity = qt_window_private(window())->opacity; | - | ||||||||||||||||||
| 485 |     if (!qFuzzyCompare(opacity, qreal(1.0))
  | 0-4107 | ||||||||||||||||||
| 486 |         setOpacity(opacity); never executed:  setOpacity(opacity); | 0 | ||||||||||||||||||
| 487 |     if (window()->isTopLevel()
  | 97-4010 | ||||||||||||||||||
| 488 |         setWindowIcon(window()->icon()); executed 4010 times by 125 tests:  setWindowIcon(window()->icon());Executed by: 
  | 4010 | ||||||||||||||||||
| 489 | - | |||||||||||||||||||
| 490 |     if (window()->dynamicPropertyNames().contains(wm_window_role_property_id)
  | 0-4107 | ||||||||||||||||||
| 491 | QByteArray wmWindowRole = window()->property(wm_window_role_property_id).toByteArray(); | - | ||||||||||||||||||
| 492 | setWmWindowRole(wmWindowRole); | - | ||||||||||||||||||
| 493 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 494 | } executed 4107 times by 125 tests:  end of blockExecuted by: 
  | 4107 | ||||||||||||||||||
| 495 | - | |||||||||||||||||||
| 496 | QXcbWindow::~QXcbWindow() | - | ||||||||||||||||||
| 497 | { | - | ||||||||||||||||||
| 498 | if (m_currentBitmapCursor != XCB_CURSOR_NONE) { | - | ||||||||||||||||||
| 499 | xcb_free_cursor(xcb_connection(), m_currentBitmapCursor); | - | ||||||||||||||||||
| 500 | } | - | ||||||||||||||||||
| 501 | if (window()->type() != Qt::ForeignWindow) | - | ||||||||||||||||||
| 502 | destroy(); | - | ||||||||||||||||||
| 503 | else { | - | ||||||||||||||||||
| 504 | if (connection()->mouseGrabber() == this) | - | ||||||||||||||||||
| 505 | connection()->setMouseGrabber(nullptr); | - | ||||||||||||||||||
| 506 | if (connection()->mousePressWindow() == this) | - | ||||||||||||||||||
| 507 | connection()->setMousePressWindow(nullptr); | - | ||||||||||||||||||
| 508 | } | - | ||||||||||||||||||
| 509 | } | - | ||||||||||||||||||
| 510 | - | |||||||||||||||||||
| 511 | void QXcbWindow::destroy() | - | ||||||||||||||||||
| 512 | { | - | ||||||||||||||||||
| 513 | if (connection()->focusWindow() == this) | - | ||||||||||||||||||
| 514 | doFocusOut(); | - | ||||||||||||||||||
| 515 | if (connection()->mouseGrabber() == this) | - | ||||||||||||||||||
| 516 | connection()->setMouseGrabber(nullptr); | - | ||||||||||||||||||
| 517 | - | |||||||||||||||||||
| 518 | if (m_syncCounter && m_usingSyncProtocol) | - | ||||||||||||||||||
| 519 | xcb_sync_destroy_counter(xcb_connection(), m_syncCounter); | - | ||||||||||||||||||
| 520 | if (m_window) { | - | ||||||||||||||||||
| 521 | if (m_netWmUserTimeWindow) { | - | ||||||||||||||||||
| 522 | xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW)); | - | ||||||||||||||||||
| 523 | - | |||||||||||||||||||
| 524 | - | |||||||||||||||||||
| 525 | connection()->sync(); | - | ||||||||||||||||||
| 526 | xcb_destroy_window(xcb_connection(), m_netWmUserTimeWindow); | - | ||||||||||||||||||
| 527 | m_netWmUserTimeWindow = 0L; | - | ||||||||||||||||||
| 528 | } | - | ||||||||||||||||||
| 529 | connection()->removeWindowEventListener(m_window); | - | ||||||||||||||||||
| 530 | xcb_destroy_window(xcb_connection(), m_window); | - | ||||||||||||||||||
| 531 | m_window = 0; | - | ||||||||||||||||||
| 532 | } | - | ||||||||||||||||||
| 533 | m_mapped = false; | - | ||||||||||||||||||
| 534 | - | |||||||||||||||||||
| 535 | if (m_pendingSyncRequest) | - | ||||||||||||||||||
| 536 | m_pendingSyncRequest->invalidate(); | - | ||||||||||||||||||
| 537 | } | - | ||||||||||||||||||
| 538 | - | |||||||||||||||||||
| 539 | void QXcbWindow::setGeometry(const QRect &rect) | - | ||||||||||||||||||
| 540 | { | - | ||||||||||||||||||
| 541 | QPlatformWindow::setGeometry(rect); | - | ||||||||||||||||||
| 542 | - | |||||||||||||||||||
| 543 | propagateSizeHints(); | - | ||||||||||||||||||
| 544 | - | |||||||||||||||||||
| 545 | QXcbScreen *currentScreen = xcbScreen(); | - | ||||||||||||||||||
| 546 |     QXcbScreen *newScreen = parent()
  | 43-2810 | ||||||||||||||||||
| 547 | - | |||||||||||||||||||
| 548 |     if (!newScreen
  | 0-2853 | ||||||||||||||||||
| 549 |         newScreen = xcbScreen(); never executed:  newScreen = xcbScreen(); | 0 | ||||||||||||||||||
| 550 | - | |||||||||||||||||||
| 551 | const QRect wmGeometry = windowToWmGeometry(rect); | - | ||||||||||||||||||
| 552 | - | |||||||||||||||||||
| 553 |     if (newScreen &&newScreen != currentScreen
  | 0-2853 | ||||||||||||||||||
| 554 |         QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen()); never executed:  QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen()); | 0 | ||||||||||||||||||
| 555 | - | |||||||||||||||||||
| 556 |     if (qt_window_private(window())->positionAutomatic
  | 1074-1779 | ||||||||||||||||||
| 557 | const quint32 mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; | - | ||||||||||||||||||
| 558 | const qint32 values[] = { | - | ||||||||||||||||||
| 559 | qBound<qint32>(1, wmGeometry.width(), 16383), | - | ||||||||||||||||||
| 560 | qBound<qint32>(1, wmGeometry.height(), 16383), | - | ||||||||||||||||||
| 561 | }; | - | ||||||||||||||||||
| 562 | xcb_configure_window(xcb_connection(), m_window, mask, reinterpret_cast<const quint32*>(values)); | - | ||||||||||||||||||
| 563 |     } executed 1779 times by 86 tests:   else {end of blockExecuted by: 
  | 1779 | ||||||||||||||||||
| 564 | const quint32 mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; | - | ||||||||||||||||||
| 565 | const qint32 values[] = { | - | ||||||||||||||||||
| 566 | qBound<qint32>(-16383, wmGeometry.x(), 16383), | - | ||||||||||||||||||
| 567 | qBound<qint32>(-16383, wmGeometry.y(), 16383), | - | ||||||||||||||||||
| 568 | qBound<qint32>(1, wmGeometry.width(), 16383), | - | ||||||||||||||||||
| 569 | qBound<qint32>(1, wmGeometry.height(), 16383), | - | ||||||||||||||||||
| 570 | }; | - | ||||||||||||||||||
| 571 | xcb_configure_window(xcb_connection(), m_window, mask, reinterpret_cast<const quint32*>(values)); | - | ||||||||||||||||||
| 572 |     } executed 1074 times by 69 tests:  end of blockExecuted by: 
  | 1074 | ||||||||||||||||||
| 573 | - | |||||||||||||||||||
| 574 | xcb_flush(xcb_connection()); | - | ||||||||||||||||||
| 575 | } executed 2853 times by 106 tests:  end of blockExecuted by: 
  | 2853 | ||||||||||||||||||
| 576 | - | |||||||||||||||||||
| 577 | QMargins QXcbWindow::frameMargins() const | - | ||||||||||||||||||
| 578 | { | - | ||||||||||||||||||
| 579 | if (m_dirtyFrameMargins) { | - | ||||||||||||||||||
| 580 | if (connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::_NET_FRAME_EXTENTS))) { | - | ||||||||||||||||||
| 581 | xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, m_window, | - | ||||||||||||||||||
| 582 | atom(QXcbAtom::_NET_FRAME_EXTENTS), XCB_ATOM_CARDINAL, 0, 4); | - | ||||||||||||||||||
| 583 | QScopedPointer<xcb_get_property_reply_t, QScopedPointerPodDeleter> reply( | - | ||||||||||||||||||
| 584 | xcb_get_property_reply(xcb_connection(), cookie, __null)); | - | ||||||||||||||||||
| 585 | if (reply && reply->type == XCB_ATOM_CARDINAL && reply->format == 32 && reply->value_len == 4) { | - | ||||||||||||||||||
| 586 | quint32 *data = (quint32 *)xcb_get_property_value(reply.data()); | - | ||||||||||||||||||
| 587 | - | |||||||||||||||||||
| 588 | m_frameMargins = QMargins(data[0], data[2], data[1], data[3]); | - | ||||||||||||||||||
| 589 | m_dirtyFrameMargins = false; | - | ||||||||||||||||||
| 590 | return m_frameMargins; | - | ||||||||||||||||||
| 591 | } | - | ||||||||||||||||||
| 592 | } | - | ||||||||||||||||||
| 593 | - | |||||||||||||||||||
| 594 | - | |||||||||||||||||||
| 595 | - | |||||||||||||||||||
| 596 | xcb_window_t window = m_window; | - | ||||||||||||||||||
| 597 | xcb_window_t parent = m_window; | - | ||||||||||||||||||
| 598 | - | |||||||||||||||||||
| 599 | bool foundRoot = false; | - | ||||||||||||||||||
| 600 | - | |||||||||||||||||||
| 601 | const QVector<xcb_window_t> &virtualRoots = | - | ||||||||||||||||||
| 602 | connection()->wmSupport()->virtualRoots(); | - | ||||||||||||||||||
| 603 | - | |||||||||||||||||||
| 604 | while (!foundRoot) { | - | ||||||||||||||||||
| 605 | xcb_query_tree_cookie_t cookie = xcb_query_tree_unchecked(xcb_connection(), parent); | - | ||||||||||||||||||
| 606 | - | |||||||||||||||||||
| 607 | xcb_query_tree_reply_t *reply = xcb_query_tree_reply(xcb_connection(), cookie, __null); | - | ||||||||||||||||||
| 608 | if (reply) { | - | ||||||||||||||||||
| 609 | if (reply->root == reply->parent || virtualRoots.indexOf(reply->parent) != -1 || reply->parent == XCB_WINDOW_NONE) { | - | ||||||||||||||||||
| 610 | foundRoot = true; | - | ||||||||||||||||||
| 611 | } else { | - | ||||||||||||||||||
| 612 | window = parent; | - | ||||||||||||||||||
| 613 | parent = reply->parent; | - | ||||||||||||||||||
| 614 | } | - | ||||||||||||||||||
| 615 | - | |||||||||||||||||||
| 616 | free(reply); | - | ||||||||||||||||||
| 617 | } else { | - | ||||||||||||||||||
| 618 | m_dirtyFrameMargins = false; | - | ||||||||||||||||||
| 619 | m_frameMargins = QMargins(); | - | ||||||||||||||||||
| 620 | return m_frameMargins; | - | ||||||||||||||||||
| 621 | } | - | ||||||||||||||||||
| 622 | } | - | ||||||||||||||||||
| 623 | - | |||||||||||||||||||
| 624 | QPoint offset; | - | ||||||||||||||||||
| 625 | - | |||||||||||||||||||
| 626 | xcb_translate_coordinates_reply_t *reply = | - | ||||||||||||||||||
| 627 | xcb_translate_coordinates_reply( | - | ||||||||||||||||||
| 628 | xcb_connection(), | - | ||||||||||||||||||
| 629 | xcb_translate_coordinates(xcb_connection(), window, parent, 0, 0), | - | ||||||||||||||||||
| 630 | __null); | - | ||||||||||||||||||
| 631 | - | |||||||||||||||||||
| 632 | if (reply) { | - | ||||||||||||||||||
| 633 | offset = QPoint(reply->dst_x, reply->dst_y); | - | ||||||||||||||||||
| 634 | free(reply); | - | ||||||||||||||||||
| 635 | } | - | ||||||||||||||||||
| 636 | - | |||||||||||||||||||
| 637 | xcb_get_geometry_reply_t *geom = | - | ||||||||||||||||||
| 638 | xcb_get_geometry_reply( | - | ||||||||||||||||||
| 639 | xcb_connection(), | - | ||||||||||||||||||
| 640 | xcb_get_geometry(xcb_connection(), parent), | - | ||||||||||||||||||
| 641 | __null); | - | ||||||||||||||||||
| 642 | - | |||||||||||||||||||
| 643 | if (geom) { | - | ||||||||||||||||||
| 644 | int left = offset.x() + geom->border_width; | - | ||||||||||||||||||
| 645 | int top = offset.y() + geom->border_width; | - | ||||||||||||||||||
| 646 | int right = geom->width + geom->border_width - geometry().width() - offset.x(); | - | ||||||||||||||||||
| 647 | int bottom = geom->height + geom->border_width - geometry().height() - offset.y(); | - | ||||||||||||||||||
| 648 | - | |||||||||||||||||||
| 649 | m_frameMargins = QMargins(left, top, right, bottom); | - | ||||||||||||||||||
| 650 | - | |||||||||||||||||||
| 651 | free(geom); | - | ||||||||||||||||||
| 652 | } | - | ||||||||||||||||||
| 653 | - | |||||||||||||||||||
| 654 | m_dirtyFrameMargins = false; | - | ||||||||||||||||||
| 655 | } | - | ||||||||||||||||||
| 656 | - | |||||||||||||||||||
| 657 | return m_frameMargins; | - | ||||||||||||||||||
| 658 | } | - | ||||||||||||||||||
| 659 | - | |||||||||||||||||||
| 660 | void QXcbWindow::setVisible(bool visible) | - | ||||||||||||||||||
| 661 | { | - | ||||||||||||||||||
| 662 | if (visible) | - | ||||||||||||||||||
| 663 | show(); | - | ||||||||||||||||||
| 664 | else | - | ||||||||||||||||||
| 665 | hide(); | - | ||||||||||||||||||
| 666 | } | - | ||||||||||||||||||
| 667 | - | |||||||||||||||||||
| 668 | static inline bool testShowWithoutActivating(const QWindow *window) | - | ||||||||||||||||||
| 669 | { | - | ||||||||||||||||||
| 670 | - | |||||||||||||||||||
| 671 | const QVariant showWithoutActivating = window->property("_q_showWithoutActivating"); | - | ||||||||||||||||||
| 672 | return showWithoutActivating.isValid() && showWithoutActivating.toBool(); | - | ||||||||||||||||||
| 673 | } | - | ||||||||||||||||||
| 674 | - | |||||||||||||||||||
| 675 | void QXcbWindow::show() | - | ||||||||||||||||||
| 676 | { | - | ||||||||||||||||||
| 677 | if (window()->isTopLevel()) { | - | ||||||||||||||||||
| 678 | xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_hints_unchecked(xcb_connection(), m_window); | - | ||||||||||||||||||
| 679 | - | |||||||||||||||||||
| 680 | xcb_icccm_wm_hints_t hints; | - | ||||||||||||||||||
| 681 | xcb_icccm_get_wm_hints_reply(xcb_connection(), cookie, &hints, __null); | - | ||||||||||||||||||
| 682 | - | |||||||||||||||||||
| 683 | if (window()->windowState() & Qt::WindowMinimized) | - | ||||||||||||||||||
| 684 | xcb_icccm_wm_hints_set_iconic(&hints); | - | ||||||||||||||||||
| 685 | else | - | ||||||||||||||||||
| 686 | xcb_icccm_wm_hints_set_normal(&hints); | - | ||||||||||||||||||
| 687 | - | |||||||||||||||||||
| 688 | xcb_icccm_wm_hints_set_input(&hints, !(window()->flags() & Qt::WindowDoesNotAcceptFocus)); | - | ||||||||||||||||||
| 689 | - | |||||||||||||||||||
| 690 | xcb_icccm_set_wm_hints(xcb_connection(), m_window, &hints); | - | ||||||||||||||||||
| 691 | - | |||||||||||||||||||
| 692 | m_gravity = positionIncludesFrame(window()) ? | - | ||||||||||||||||||
| 693 | XCB_GRAVITY_NORTH_WEST : XCB_GRAVITY_STATIC; | - | ||||||||||||||||||
| 694 | - | |||||||||||||||||||
| 695 | - | |||||||||||||||||||
| 696 | propagateSizeHints(); | - | ||||||||||||||||||
| 697 | - | |||||||||||||||||||
| 698 | - | |||||||||||||||||||
| 699 | xcb_window_t transientXcbParent = 0; | - | ||||||||||||||||||
| 700 | if (isTransient(window())) { | - | ||||||||||||||||||
| 701 | const QWindow *tp = window()->transientParent(); | - | ||||||||||||||||||
| 702 | if (tp && tp->handle()) | - | ||||||||||||||||||
| 703 | transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId(); | - | ||||||||||||||||||
| 704 | - | |||||||||||||||||||
| 705 | - | |||||||||||||||||||
| 706 | if (!transientXcbParent) | - | ||||||||||||||||||
| 707 | transientXcbParent = connection()->clientLeader(); | - | ||||||||||||||||||
| 708 | if (transientXcbParent) { | - | ||||||||||||||||||
| 709 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32, 1, &transientXcbParent) | - | ||||||||||||||||||
| 710 | - | |||||||||||||||||||
| 711 | ; | - | ||||||||||||||||||
| 712 | } | - | ||||||||||||||||||
| 713 | } | - | ||||||||||||||||||
| 714 | if (!transientXcbParent) | - | ||||||||||||||||||
| 715 | xcb_delete_property(xcb_connection(), m_window, XCB_ATOM_WM_TRANSIENT_FOR); | - | ||||||||||||||||||
| 716 | - | |||||||||||||||||||
| 717 | - | |||||||||||||||||||
| 718 | updateMotifWmHintsBeforeMap(); | - | ||||||||||||||||||
| 719 | - | |||||||||||||||||||
| 720 | - | |||||||||||||||||||
| 721 | updateNetWmStateBeforeMap(); | - | ||||||||||||||||||
| 722 | } | - | ||||||||||||||||||
| 723 | - | |||||||||||||||||||
| 724 | if (testShowWithoutActivating(window())) | - | ||||||||||||||||||
| 725 | updateNetWmUserTime(0); | - | ||||||||||||||||||
| 726 | else if (connection()->time() != XCB_TIME_CURRENT_TIME) | - | ||||||||||||||||||
| 727 | updateNetWmUserTime(connection()->time()); | - | ||||||||||||||||||
| 728 | - | |||||||||||||||||||
| 729 | if (window()->objectName() == QLatin1String("QSystemTrayIconSysWindow")) | - | ||||||||||||||||||
| 730 | return; | - | ||||||||||||||||||
| 731 | - | |||||||||||||||||||
| 732 | xcb_map_window(xcb_connection(), m_window); | - | ||||||||||||||||||
| 733 | - | |||||||||||||||||||
| 734 | if (QGuiApplication::modalWindow() == window()) | - | ||||||||||||||||||
| 735 | requestActivateWindow(); | - | ||||||||||||||||||
| 736 | - | |||||||||||||||||||
| 737 | xcbScreen()->windowShown(this); | - | ||||||||||||||||||
| 738 | - | |||||||||||||||||||
| 739 | connection()->sync(); | - | ||||||||||||||||||
| 740 | } | - | ||||||||||||||||||
| 741 | - | |||||||||||||||||||
| 742 | void QXcbWindow::hide() | - | ||||||||||||||||||
| 743 | { | - | ||||||||||||||||||
| 744 | xcb_unmap_window(xcb_connection(), m_window); | - | ||||||||||||||||||
| 745 | - | |||||||||||||||||||
| 746 | - | |||||||||||||||||||
| 747 | q_padded_xcb_event<xcb_unmap_notify_event_t> store = q_padded_xcb_event<xcb_unmap_notify_event_t >(); auto &event = store.event;;; | - | ||||||||||||||||||
| 748 | event.response_type = 18; | - | ||||||||||||||||||
| 749 | event.event = xcbScreen()->root(); | - | ||||||||||||||||||
| 750 | event.window = m_window; | - | ||||||||||||||||||
| 751 | event.from_configure = false; | - | ||||||||||||||||||
| 752 | xcb_send_event(xcb_connection(), false, xcbScreen()->root(), XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event) | - | ||||||||||||||||||
| 753 | ; | - | ||||||||||||||||||
| 754 | - | |||||||||||||||||||
| 755 | xcb_flush(xcb_connection()); | - | ||||||||||||||||||
| 756 | - | |||||||||||||||||||
| 757 |     if (connection()->mouseGrabber() == this
  | 3-3982 | ||||||||||||||||||
| 758 |         connection()->setMouseGrabber(nullptr); executed 3 times by 1 test:  connection()->setMouseGrabber(nullptr);Executed by: 
  | 3 | ||||||||||||||||||
| 759 |     if (QPlatformWindow *w = connection()->mousePressWindow()
  | 0-3985 | ||||||||||||||||||
| 760 | - | |||||||||||||||||||
| 761 |         while (w
  | 0 | ||||||||||||||||||
| 762 |             if (w == this
  | 0 | ||||||||||||||||||
| 763 | connection()->setMousePressWindow(nullptr); | - | ||||||||||||||||||
| 764 |                 break; never executed:  break; | 0 | ||||||||||||||||||
| 765 | } | - | ||||||||||||||||||
| 766 | w = w->parent(); | - | ||||||||||||||||||
| 767 |         } never executed:  end of block | 0 | ||||||||||||||||||
| 768 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 769 | - | |||||||||||||||||||
| 770 | m_mapped = false; | - | ||||||||||||||||||
| 771 | - | |||||||||||||||||||
| 772 | - | |||||||||||||||||||
| 773 | - | |||||||||||||||||||
| 774 |     if (window()->isModal()
  | 132-3853 | ||||||||||||||||||
| 775 | - | |||||||||||||||||||
| 776 | const QPoint nativePos = xcbScreen()->cursor()->pos(); | - | ||||||||||||||||||
| 777 | const QPoint cursorPos = QHighDpi::fromNativePixels(nativePos, xcbScreen()->screenForPosition(nativePos)->screen()); | - | ||||||||||||||||||
| 778 | - | |||||||||||||||||||
| 779 | - | |||||||||||||||||||
| 780 | - | |||||||||||||||||||
| 781 | QWindow *enterWindow = nullptr; | - | ||||||||||||||||||
| 782 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(xcbScreen()->virtualSiblings())>::type> _container_((const auto screens = xcbScreen()->virtualSiblings())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)(); | - | ||||||||||||||||||
| 783 | for (QPlatformScreen *screen = *_container_.i; _container_.control; _container_.control = 0: screens) { | - | ||||||||||||||||||
| 784 |             if (screen->geometry().contains(cursorPos)
  | 0-132 | ||||||||||||||||||
| 785 | const QPoint devicePosition = QHighDpi::toNativePixels(cursorPos, screen->screen()); | - | ||||||||||||||||||
| 786 | enterWindow = screen->topLevelAt(devicePosition); | - | ||||||||||||||||||
| 787 |                 break; executed 132 times by 16 tests:  break;Executed by: 
  | 132 | ||||||||||||||||||
| 788 | } | - | ||||||||||||||||||
| 789 |         } never executed:  end of block | 0 | ||||||||||||||||||
| 790 | - | |||||||||||||||||||
| 791 |         if (enterWindow
 
  | 0-126 | ||||||||||||||||||
| 792 | - | |||||||||||||||||||
| 793 |             if (QWindow *childWindow = childWindowAt(enterWindow, cursorPos)
  | 1-5 | ||||||||||||||||||
| 794 |                 enterWindow = childWindow; executed 1 time by 1 test:  enterWindow = childWindow;Executed by: 
  | 1 | ||||||||||||||||||
| 795 | const QPoint localPos = enterWindow->mapFromGlobal(cursorPos); | - | ||||||||||||||||||
| 796 | QWindowSystemInterface::handleEnterEvent(enterWindow, localPos, cursorPos); | - | ||||||||||||||||||
| 797 |         } executed 6 times by 3 tests:  end of blockExecuted by: 
  | 6 | ||||||||||||||||||
| 798 |     } executed 132 times by 16 tests:  end of blockExecuted by: 
  | 132 | ||||||||||||||||||
| 799 | } executed 3985 times by 130 tests:  end of blockExecuted by: 
  | 3985 | ||||||||||||||||||
| 800 | - | |||||||||||||||||||
| 801 | static QWindow *tlWindow(QWindow *window) | - | ||||||||||||||||||
| 802 | { | - | ||||||||||||||||||
| 803 | if (window && window->parent()) | - | ||||||||||||||||||
| 804 | return tlWindow(window->parent()); | - | ||||||||||||||||||
| 805 | return window; | - | ||||||||||||||||||
| 806 | } | - | ||||||||||||||||||
| 807 | - | |||||||||||||||||||
| 808 | bool QXcbWindow::relayFocusToModalWindow() const | - | ||||||||||||||||||
| 809 | { | - | ||||||||||||||||||
| 810 | QWindow *w = tlWindow(static_cast<QWindowPrivate *>(QObjectPrivate::get(window()))->eventReceiver()); | - | ||||||||||||||||||
| 811 | QWindow *modal_window = 0; | - | ||||||||||||||||||
| 812 | if (QGuiApplicationPrivate::instance()->isWindowBlocked(w,&modal_window) && modal_window != w) { | - | ||||||||||||||||||
| 813 | modal_window->requestActivate(); | - | ||||||||||||||||||
| 814 | connection()->flush(); | - | ||||||||||||||||||
| 815 | return true; | - | ||||||||||||||||||
| 816 | } | - | ||||||||||||||||||
| 817 | - | |||||||||||||||||||
| 818 | return false; | - | ||||||||||||||||||
| 819 | } | - | ||||||||||||||||||
| 820 | - | |||||||||||||||||||
| 821 | void QXcbWindow::doFocusIn() | - | ||||||||||||||||||
| 822 | { | - | ||||||||||||||||||
| 823 | if (relayFocusToModalWindow()) | - | ||||||||||||||||||
| 824 | return; | - | ||||||||||||||||||
| 825 | QWindow *w = static_cast<QWindowPrivate *>(QObjectPrivate::get(window()))->eventReceiver(); | - | ||||||||||||||||||
| 826 | connection()->setFocusWindow(static_cast<QXcbWindow *>(w->handle())); | - | ||||||||||||||||||
| 827 | QWindowSystemInterface::handleWindowActivated(w, Qt::ActiveWindowFocusReason); | - | ||||||||||||||||||
| 828 | } | - | ||||||||||||||||||
| 829 | - | |||||||||||||||||||
| 830 | static bool focusInPeeker(QXcbConnection *connection, xcb_generic_event_t *event) | - | ||||||||||||||||||
| 831 | { | - | ||||||||||||||||||
| 832 | if (!event) { | - | ||||||||||||||||||
| 833 | - | |||||||||||||||||||
| 834 | QWindowSystemInterface::handleWindowActivated(0, Qt::ActiveWindowFocusReason); | - | ||||||||||||||||||
| 835 | return true; | - | ||||||||||||||||||
| 836 | } | - | ||||||||||||||||||
| 837 | uint response_type = event->response_type & ~0x80; | - | ||||||||||||||||||
| 838 | if (response_type == 9) { | - | ||||||||||||||||||
| 839 | - | |||||||||||||||||||
| 840 | - | |||||||||||||||||||
| 841 | xcb_focus_in_event_t *e = (xcb_focus_in_event_t *) event; | - | ||||||||||||||||||
| 842 | if (e->detail != XCB_NOTIFY_DETAIL_POINTER) | - | ||||||||||||||||||
| 843 | return true; | - | ||||||||||||||||||
| 844 | } | - | ||||||||||||||||||
| 845 | - | |||||||||||||||||||
| 846 | - | |||||||||||||||||||
| 847 | if (response_type == 33) { | - | ||||||||||||||||||
| 848 | xcb_client_message_event_t *cme = (xcb_client_message_event_t *)event; | - | ||||||||||||||||||
| 849 | if (cme->type == connection->atom(QXcbAtom::_XEMBED) | - | ||||||||||||||||||
| 850 | && cme->data.data32[1] == XEMBED_FOCUS_IN) | - | ||||||||||||||||||
| 851 | return true; | - | ||||||||||||||||||
| 852 | } | - | ||||||||||||||||||
| 853 | - | |||||||||||||||||||
| 854 | return false; | - | ||||||||||||||||||
| 855 | } | - | ||||||||||||||||||
| 856 | - | |||||||||||||||||||
| 857 | void QXcbWindow::doFocusOut() | - | ||||||||||||||||||
| 858 | { | - | ||||||||||||||||||
| 859 | if (relayFocusToModalWindow()) | - | ||||||||||||||||||
| 860 | return; | - | ||||||||||||||||||
| 861 | connection()->setFocusWindow(0); | - | ||||||||||||||||||
| 862 | - | |||||||||||||||||||
| 863 | - | |||||||||||||||||||
| 864 | - | |||||||||||||||||||
| 865 | connection()->addPeekFunc(focusInPeeker); | - | ||||||||||||||||||
| 866 | } | - | ||||||||||||||||||
| 867 | - | |||||||||||||||||||
| 868 | struct QtMotifWmHints { | - | ||||||||||||||||||
| 869 | quint32 flags, functions, decorations; | - | ||||||||||||||||||
| 870 | qint32 input_mode; | - | ||||||||||||||||||
| 871 | quint32 status; | - | ||||||||||||||||||
| 872 | }; | - | ||||||||||||||||||
| 873 | - | |||||||||||||||||||
| 874 | enum { | - | ||||||||||||||||||
| 875 | MWM_HINTS_FUNCTIONS = (1L << 0), | - | ||||||||||||||||||
| 876 | - | |||||||||||||||||||
| 877 | MWM_FUNC_ALL = (1L << 0), | - | ||||||||||||||||||
| 878 | MWM_FUNC_RESIZE = (1L << 1), | - | ||||||||||||||||||
| 879 | MWM_FUNC_MOVE = (1L << 2), | - | ||||||||||||||||||
| 880 | MWM_FUNC_MINIMIZE = (1L << 3), | - | ||||||||||||||||||
| 881 | MWM_FUNC_MAXIMIZE = (1L << 4), | - | ||||||||||||||||||
| 882 | MWM_FUNC_CLOSE = (1L << 5), | - | ||||||||||||||||||
| 883 | - | |||||||||||||||||||
| 884 | MWM_HINTS_DECORATIONS = (1L << 1), | - | ||||||||||||||||||
| 885 | - | |||||||||||||||||||
| 886 | MWM_DECOR_ALL = (1L << 0), | - | ||||||||||||||||||
| 887 | MWM_DECOR_BORDER = (1L << 1), | - | ||||||||||||||||||
| 888 | MWM_DECOR_RESIZEH = (1L << 2), | - | ||||||||||||||||||
| 889 | MWM_DECOR_TITLE = (1L << 3), | - | ||||||||||||||||||
| 890 | MWM_DECOR_MENU = (1L << 4), | - | ||||||||||||||||||
| 891 | MWM_DECOR_MINIMIZE = (1L << 5), | - | ||||||||||||||||||
| 892 | MWM_DECOR_MAXIMIZE = (1L << 6), | - | ||||||||||||||||||
| 893 | - | |||||||||||||||||||
| 894 | MWM_HINTS_INPUT_MODE = (1L << 2), | - | ||||||||||||||||||
| 895 | - | |||||||||||||||||||
| 896 | MWM_INPUT_MODELESS = 0L, | - | ||||||||||||||||||
| 897 | MWM_INPUT_PRIMARY_APPLICATION_MODAL = 1L, | - | ||||||||||||||||||
| 898 | MWM_INPUT_FULL_APPLICATION_MODAL = 3L | - | ||||||||||||||||||
| 899 | }; | - | ||||||||||||||||||
| 900 | - | |||||||||||||||||||
| 901 | static QtMotifWmHints getMotifWmHints(QXcbConnection *c, xcb_window_t window) | - | ||||||||||||||||||
| 902 | { | - | ||||||||||||||||||
| 903 | QtMotifWmHints hints; | - | ||||||||||||||||||
| 904 | - | |||||||||||||||||||
| 905 | xcb_get_property_cookie_t get_cookie = | - | ||||||||||||||||||
| 906 | xcb_get_property_unchecked(c->xcb_connection(), 0, window, c->atom(QXcbAtom::_MOTIF_WM_HINTS), | - | ||||||||||||||||||
| 907 | c->atom(QXcbAtom::_MOTIF_WM_HINTS), 0, 20); | - | ||||||||||||||||||
| 908 | - | |||||||||||||||||||
| 909 | xcb_get_property_reply_t *reply = | - | ||||||||||||||||||
| 910 | xcb_get_property_reply(c->xcb_connection(), get_cookie, __null); | - | ||||||||||||||||||
| 911 | - | |||||||||||||||||||
| 912 | if (reply && reply->format == 32 && reply->type == c->atom(QXcbAtom::_MOTIF_WM_HINTS)) { | - | ||||||||||||||||||
| 913 | hints = *((QtMotifWmHints *)xcb_get_property_value(reply)); | - | ||||||||||||||||||
| 914 | } else { | - | ||||||||||||||||||
| 915 | hints.flags = 0L; | - | ||||||||||||||||||
| 916 | hints.functions = MWM_FUNC_ALL; | - | ||||||||||||||||||
| 917 | hints.decorations = MWM_DECOR_ALL; | - | ||||||||||||||||||
| 918 | hints.input_mode = 0L; | - | ||||||||||||||||||
| 919 | hints.status = 0L; | - | ||||||||||||||||||
| 920 | } | - | ||||||||||||||||||
| 921 | - | |||||||||||||||||||
| 922 | free(reply); | - | ||||||||||||||||||
| 923 | - | |||||||||||||||||||
| 924 | return hints; | - | ||||||||||||||||||
| 925 | } | - | ||||||||||||||||||
| 926 | - | |||||||||||||||||||
| 927 | static void setMotifWmHints(QXcbConnection *c, xcb_window_t window, const QtMotifWmHints &hints) | - | ||||||||||||||||||
| 928 | { | - | ||||||||||||||||||
| 929 | if (hints.flags != 0l) { | - | ||||||||||||||||||
| 930 | xcb_change_property(c->xcb_connection(), XCB_PROP_MODE_REPLACE, window, c->atom(QXcbAtom::_MOTIF_WM_HINTS), c->atom(QXcbAtom::_MOTIF_WM_HINTS), 32, 5, &hints) | - | ||||||||||||||||||
| 931 | - | |||||||||||||||||||
| 932 | - | |||||||||||||||||||
| 933 | - | |||||||||||||||||||
| 934 | - | |||||||||||||||||||
| 935 | - | |||||||||||||||||||
| 936 | - | |||||||||||||||||||
| 937 | ; | - | ||||||||||||||||||
| 938 | } else { | - | ||||||||||||||||||
| 939 | xcb_delete_property(c->xcb_connection(), window, c->atom(QXcbAtom::_MOTIF_WM_HINTS)); | - | ||||||||||||||||||
| 940 | } | - | ||||||||||||||||||
| 941 | } | - | ||||||||||||||||||
| 942 | - | |||||||||||||||||||
| 943 | QXcbWindow::NetWmStates QXcbWindow::netWmStates() | - | ||||||||||||||||||
| 944 | { | - | ||||||||||||||||||
| 945 | NetWmStates result(0); | - | ||||||||||||||||||
| 946 | - | |||||||||||||||||||
| 947 | xcb_get_property_cookie_t get_cookie = | - | ||||||||||||||||||
| 948 | xcb_get_property_unchecked(xcb_connection(), 0, m_window, atom(QXcbAtom::_NET_WM_STATE), | - | ||||||||||||||||||
| 949 | XCB_ATOM_ATOM, 0, 1024); | - | ||||||||||||||||||
| 950 | - | |||||||||||||||||||
| 951 | xcb_get_property_reply_t *reply = | - | ||||||||||||||||||
| 952 | xcb_get_property_reply(xcb_connection(), get_cookie, __null); | - | ||||||||||||||||||
| 953 | - | |||||||||||||||||||
| 954 | if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM) { | - | ||||||||||||||||||
| 955 | const xcb_atom_t *states = static_cast<const xcb_atom_t *>(xcb_get_property_value(reply)); | - | ||||||||||||||||||
| 956 | const xcb_atom_t *statesEnd = states + reply->length; | - | ||||||||||||||||||
| 957 | if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_ABOVE))) | - | ||||||||||||||||||
| 958 | result |= NetWmStateAbove; | - | ||||||||||||||||||
| 959 | if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_BELOW))) | - | ||||||||||||||||||
| 960 | result |= NetWmStateBelow; | - | ||||||||||||||||||
| 961 | if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN))) | - | ||||||||||||||||||
| 962 | result |= NetWmStateFullScreen; | - | ||||||||||||||||||
| 963 | if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ))) | - | ||||||||||||||||||
| 964 | result |= NetWmStateMaximizedHorz; | - | ||||||||||||||||||
| 965 | if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT))) | - | ||||||||||||||||||
| 966 | result |= NetWmStateMaximizedVert; | - | ||||||||||||||||||
| 967 | if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_MODAL))) | - | ||||||||||||||||||
| 968 | result |= NetWmStateModal; | - | ||||||||||||||||||
| 969 | if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP))) | - | ||||||||||||||||||
| 970 | result |= NetWmStateStaysOnTop; | - | ||||||||||||||||||
| 971 | if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_DEMANDS_ATTENTION))) | - | ||||||||||||||||||
| 972 | result |= NetWmStateDemandsAttention; | - | ||||||||||||||||||
| 973 | free(reply); | - | ||||||||||||||||||
| 974 | } else { | - | ||||||||||||||||||
| 975 | - | |||||||||||||||||||
| 976 | - | |||||||||||||||||||
| 977 | - | |||||||||||||||||||
| 978 | } | - | ||||||||||||||||||
| 979 | - | |||||||||||||||||||
| 980 | return result; | - | ||||||||||||||||||
| 981 | } | - | ||||||||||||||||||
| 982 | - | |||||||||||||||||||
| 983 | void QXcbWindow::setNetWmStates(NetWmStates states) | - | ||||||||||||||||||
| 984 | { | - | ||||||||||||||||||
| 985 | QVector<xcb_atom_t> atoms; | - | ||||||||||||||||||
| 986 | - | |||||||||||||||||||
| 987 | xcb_get_property_cookie_t get_cookie = | - | ||||||||||||||||||
| 988 | xcb_get_property_unchecked(xcb_connection(), 0, m_window, atom(QXcbAtom::_NET_WM_STATE), | - | ||||||||||||||||||
| 989 | XCB_ATOM_ATOM, 0, 1024); | - | ||||||||||||||||||
| 990 | - | |||||||||||||||||||
| 991 | xcb_get_property_reply_t *reply = | - | ||||||||||||||||||
| 992 | xcb_get_property_reply(xcb_connection(), get_cookie, __null); | - | ||||||||||||||||||
| 993 | - | |||||||||||||||||||
| 994 | if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM && reply->value_len > 0) { | - | ||||||||||||||||||
| 995 | const xcb_atom_t *data = static_cast<const xcb_atom_t *>(xcb_get_property_value(reply)); | - | ||||||||||||||||||
| 996 | atoms.resize(reply->value_len); | - | ||||||||||||||||||
| 997 | memcpy((void *)&atoms.first(), (void *)data, reply->value_len * sizeof(xcb_atom_t)); | - | ||||||||||||||||||
| 998 | } | - | ||||||||||||||||||
| 999 | - | |||||||||||||||||||
| 1000 | free(reply); | - | ||||||||||||||||||
| 1001 | - | |||||||||||||||||||
| 1002 | if (states & NetWmStateAbove && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_ABOVE))) | - | ||||||||||||||||||
| 1003 | atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_ABOVE)); | - | ||||||||||||||||||
| 1004 | if (states & NetWmStateBelow && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_BELOW))) | - | ||||||||||||||||||
| 1005 | atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_BELOW)); | - | ||||||||||||||||||
| 1006 | if (states & NetWmStateFullScreen && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN))) | - | ||||||||||||||||||
| 1007 | atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN)); | - | ||||||||||||||||||
| 1008 | if (states & NetWmStateMaximizedHorz && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ))) | - | ||||||||||||||||||
| 1009 | atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ)); | - | ||||||||||||||||||
| 1010 | if (states & NetWmStateMaximizedVert && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT))) | - | ||||||||||||||||||
| 1011 | atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT)); | - | ||||||||||||||||||
| 1012 | if (states & NetWmStateModal && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_MODAL))) | - | ||||||||||||||||||
| 1013 | atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_MODAL)); | - | ||||||||||||||||||
| 1014 | if (states & NetWmStateStaysOnTop && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP))) | - | ||||||||||||||||||
| 1015 | atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP)); | - | ||||||||||||||||||
| 1016 | if (states & NetWmStateDemandsAttention && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_DEMANDS_ATTENTION))) | - | ||||||||||||||||||
| 1017 | atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_DEMANDS_ATTENTION)); | - | ||||||||||||||||||
| 1018 | - | |||||||||||||||||||
| 1019 | if (atoms.isEmpty()) { | - | ||||||||||||||||||
| 1020 | xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_STATE)); | - | ||||||||||||||||||
| 1021 | } else { | - | ||||||||||||||||||
| 1022 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_STATE), XCB_ATOM_ATOM, 32, atoms.count(), atoms.constData()) | - | ||||||||||||||||||
| 1023 | - | |||||||||||||||||||
| 1024 | ; | - | ||||||||||||||||||
| 1025 | } | - | ||||||||||||||||||
| 1026 | xcb_flush(xcb_connection()); | - | ||||||||||||||||||
| 1027 | } | - | ||||||||||||||||||
| 1028 | - | |||||||||||||||||||
| 1029 | void QXcbWindow::setWindowFlags(Qt::WindowFlags flags) | - | ||||||||||||||||||
| 1030 | { | - | ||||||||||||||||||
| 1031 | Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask)); | - | ||||||||||||||||||
| 1032 | - | |||||||||||||||||||
| 1033 |     if (type == Qt::ToolTip
  | 16-4142 | ||||||||||||||||||
| 1034 |         flags |= Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint; executed 16 times by 6 tests:  flags |= Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint;Executed by: 
  | 16 | ||||||||||||||||||
| 1035 |     if (type == Qt::Popup
  | 147-4011 | ||||||||||||||||||
| 1036 |         flags |= Qt::X11BypassWindowManagerHint; executed 147 times by 23 tests:  flags |= Qt::X11BypassWindowManagerHint;Executed by: 
  | 147 | ||||||||||||||||||
| 1037 | - | |||||||||||||||||||
| 1038 | const quint32 mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK; | - | ||||||||||||||||||
| 1039 | const quint32 values[] = { | - | ||||||||||||||||||
| 1040 | - | |||||||||||||||||||
| 1041 | (flags & Qt::BypassWindowManagerHint) ? 1u : 0, | - | ||||||||||||||||||
| 1042 | - | |||||||||||||||||||
| 1043 | (flags & Qt::WindowTransparentForInput) ? transparentForInputEventMask : defaultEventMask | - | ||||||||||||||||||
| 1044 | }; | - | ||||||||||||||||||
| 1045 | - | |||||||||||||||||||
| 1046 | xcb_change_window_attributes(xcb_connection(), xcb_window(), mask, values); | - | ||||||||||||||||||
| 1047 | - | |||||||||||||||||||
| 1048 | QXcbWindowFunctions::WmWindowTypes wmWindowTypes = 0; | - | ||||||||||||||||||
| 1049 |     if (window()->dynamicPropertyNames().contains(wm_window_type_property_id)
  | 154-4004 | ||||||||||||||||||
| 1050 | wmWindowTypes = static_cast<QXcbWindowFunctions::WmWindowTypes>( | - | ||||||||||||||||||
| 1051 | window()->property(wm_window_type_property_id).value<int>()); | - | ||||||||||||||||||
| 1052 |     } executed 154 times by 23 tests:  end of blockExecuted by: 
  | 154 | ||||||||||||||||||
| 1053 | - | |||||||||||||||||||
| 1054 | setWmWindowType(wmWindowTypes, flags); | - | ||||||||||||||||||
| 1055 | setNetWmStateWindowFlags(flags); | - | ||||||||||||||||||
| 1056 | setMotifWindowFlags(flags); | - | ||||||||||||||||||
| 1057 | - | |||||||||||||||||||
| 1058 | setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput); | - | ||||||||||||||||||
| 1059 | updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus); | - | ||||||||||||||||||
| 1060 | } executed 4158 times by 125 tests:  end of blockExecuted by: 
  | 4158 | ||||||||||||||||||
| 1061 | - | |||||||||||||||||||
| 1062 | void QXcbWindow::setMotifWindowFlags(Qt::WindowFlags flags) | - | ||||||||||||||||||
| 1063 | { | - | ||||||||||||||||||
| 1064 | Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask)); | - | ||||||||||||||||||
| 1065 | - | |||||||||||||||||||
| 1066 | QtMotifWmHints mwmhints; | - | ||||||||||||||||||
| 1067 | mwmhints.flags = 0L; | - | ||||||||||||||||||
| 1068 | mwmhints.functions = 0L; | - | ||||||||||||||||||
| 1069 | mwmhints.decorations = 0; | - | ||||||||||||||||||
| 1070 | mwmhints.input_mode = 0L; | - | ||||||||||||||||||
| 1071 | mwmhints.status = 0L; | - | ||||||||||||||||||
| 1072 | - | |||||||||||||||||||
| 1073 | if (type != Qt::SplashScreen) { | - | ||||||||||||||||||
| 1074 | mwmhints.flags |= MWM_HINTS_DECORATIONS; | - | ||||||||||||||||||
| 1075 | - | |||||||||||||||||||
| 1076 | bool customize = flags & Qt::CustomizeWindowHint; | - | ||||||||||||||||||
| 1077 | if (type == Qt::Window && !customize) { | - | ||||||||||||||||||
| 1078 | const Qt::WindowFlags defaultFlags = Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint; | - | ||||||||||||||||||
| 1079 | if (!(flags & defaultFlags)) | - | ||||||||||||||||||
| 1080 | flags |= defaultFlags; | - | ||||||||||||||||||
| 1081 | } | - | ||||||||||||||||||
| 1082 | if (!(flags & Qt::FramelessWindowHint) && !(customize && !(flags & Qt::WindowTitleHint))) { | - | ||||||||||||||||||
| 1083 | mwmhints.decorations |= MWM_DECOR_BORDER; | - | ||||||||||||||||||
| 1084 | mwmhints.decorations |= MWM_DECOR_RESIZEH; | - | ||||||||||||||||||
| 1085 | mwmhints.decorations |= MWM_DECOR_TITLE; | - | ||||||||||||||||||
| 1086 | - | |||||||||||||||||||
| 1087 | if (flags & Qt::WindowSystemMenuHint) | - | ||||||||||||||||||
| 1088 | mwmhints.decorations |= MWM_DECOR_MENU; | - | ||||||||||||||||||
| 1089 | - | |||||||||||||||||||
| 1090 | if (flags & Qt::WindowMinimizeButtonHint) { | - | ||||||||||||||||||
| 1091 | mwmhints.decorations |= MWM_DECOR_MINIMIZE; | - | ||||||||||||||||||
| 1092 | mwmhints.functions |= MWM_FUNC_MINIMIZE; | - | ||||||||||||||||||
| 1093 | } | - | ||||||||||||||||||
| 1094 | - | |||||||||||||||||||
| 1095 | if (flags & Qt::WindowMaximizeButtonHint) { | - | ||||||||||||||||||
| 1096 | mwmhints.decorations |= MWM_DECOR_MAXIMIZE; | - | ||||||||||||||||||
| 1097 | mwmhints.functions |= MWM_FUNC_MAXIMIZE; | - | ||||||||||||||||||
| 1098 | } | - | ||||||||||||||||||
| 1099 | - | |||||||||||||||||||
| 1100 | if (flags & Qt::WindowCloseButtonHint) | - | ||||||||||||||||||
| 1101 | mwmhints.functions |= MWM_FUNC_CLOSE; | - | ||||||||||||||||||
| 1102 | } | - | ||||||||||||||||||
| 1103 | } else { | - | ||||||||||||||||||
| 1104 | - | |||||||||||||||||||
| 1105 | mwmhints.decorations = MWM_DECOR_ALL; | - | ||||||||||||||||||
| 1106 | } | - | ||||||||||||||||||
| 1107 | - | |||||||||||||||||||
| 1108 | if (mwmhints.functions != 0) { | - | ||||||||||||||||||
| 1109 | mwmhints.flags |= MWM_HINTS_FUNCTIONS; | - | ||||||||||||||||||
| 1110 | mwmhints.functions |= MWM_FUNC_MOVE | MWM_FUNC_RESIZE; | - | ||||||||||||||||||
| 1111 | } else { | - | ||||||||||||||||||
| 1112 | mwmhints.functions = MWM_FUNC_ALL; | - | ||||||||||||||||||
| 1113 | } | - | ||||||||||||||||||
| 1114 | - | |||||||||||||||||||
| 1115 | if (!(flags & Qt::FramelessWindowHint) | - | ||||||||||||||||||
| 1116 | && flags & Qt::CustomizeWindowHint | - | ||||||||||||||||||
| 1117 | && flags & Qt::WindowTitleHint | - | ||||||||||||||||||
| 1118 | && !(flags & | - | ||||||||||||||||||
| 1119 | (Qt::WindowMinimizeButtonHint | - | ||||||||||||||||||
| 1120 | | Qt::WindowMaximizeButtonHint | - | ||||||||||||||||||
| 1121 | | Qt::WindowCloseButtonHint))) | - | ||||||||||||||||||
| 1122 | { | - | ||||||||||||||||||
| 1123 | - | |||||||||||||||||||
| 1124 | mwmhints.flags = MWM_HINTS_FUNCTIONS; | - | ||||||||||||||||||
| 1125 | mwmhints.functions = MWM_FUNC_MOVE | MWM_FUNC_RESIZE; | - | ||||||||||||||||||
| 1126 | mwmhints.decorations = 0; | - | ||||||||||||||||||
| 1127 | } | - | ||||||||||||||||||
| 1128 | - | |||||||||||||||||||
| 1129 | setMotifWmHints(connection(), m_window, mwmhints); | - | ||||||||||||||||||
| 1130 | } | - | ||||||||||||||||||
| 1131 | - | |||||||||||||||||||
| 1132 | void QXcbWindow::changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two) | - | ||||||||||||||||||
| 1133 | { | - | ||||||||||||||||||
| 1134 | xcb_client_message_event_t event; | - | ||||||||||||||||||
| 1135 | - | |||||||||||||||||||
| 1136 | event.response_type = 33; | - | ||||||||||||||||||
| 1137 | event.format = 32; | - | ||||||||||||||||||
| 1138 | event.sequence = 0; | - | ||||||||||||||||||
| 1139 | event.window = m_window; | - | ||||||||||||||||||
| 1140 | event.type = atom(QXcbAtom::_NET_WM_STATE); | - | ||||||||||||||||||
| 1141 | event.data.data32[0] = set ? 1 : 0; | - | ||||||||||||||||||
| 1142 | event.data.data32[1] = one; | - | ||||||||||||||||||
| 1143 | event.data.data32[2] = two; | - | ||||||||||||||||||
| 1144 | event.data.data32[3] = 0; | - | ||||||||||||||||||
| 1145 | event.data.data32[4] = 0; | - | ||||||||||||||||||
| 1146 | - | |||||||||||||||||||
| 1147 | xcb_send_event(xcb_connection(), 0, xcbScreen()->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event); | - | ||||||||||||||||||
| 1148 | } | - | ||||||||||||||||||
| 1149 | - | |||||||||||||||||||
| 1150 | void QXcbWindow::setWindowState(Qt::WindowState state) | - | ||||||||||||||||||
| 1151 | { | - | ||||||||||||||||||
| 1152 | if (state == m_windowState) | - | ||||||||||||||||||
| 1153 | return; | - | ||||||||||||||||||
| 1154 | - | |||||||||||||||||||
| 1155 | - | |||||||||||||||||||
| 1156 | switch (m_windowState) { | - | ||||||||||||||||||
| 1157 | case Qt::WindowMinimized: | - | ||||||||||||||||||
| 1158 | xcb_map_window(xcb_connection(), m_window); | - | ||||||||||||||||||
| 1159 | break; | - | ||||||||||||||||||
| 1160 | case Qt::WindowMaximized: | - | ||||||||||||||||||
| 1161 | changeNetWmState(false, | - | ||||||||||||||||||
| 1162 | atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ), | - | ||||||||||||||||||
| 1163 | atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT)); | - | ||||||||||||||||||
| 1164 | break; | - | ||||||||||||||||||
| 1165 | case Qt::WindowFullScreen: | - | ||||||||||||||||||
| 1166 | changeNetWmState(false, atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN)); | - | ||||||||||||||||||
| 1167 | break; | - | ||||||||||||||||||
| 1168 | default: | - | ||||||||||||||||||
| 1169 | break; | - | ||||||||||||||||||
| 1170 | } | - | ||||||||||||||||||
| 1171 | - | |||||||||||||||||||
| 1172 | - | |||||||||||||||||||
| 1173 | switch (state) { | - | ||||||||||||||||||
| 1174 | case Qt::WindowMinimized: | - | ||||||||||||||||||
| 1175 | { | - | ||||||||||||||||||
| 1176 | xcb_client_message_event_t event; | - | ||||||||||||||||||
| 1177 | - | |||||||||||||||||||
| 1178 | event.response_type = 33; | - | ||||||||||||||||||
| 1179 | event.format = 32; | - | ||||||||||||||||||
| 1180 | event.sequence = 0; | - | ||||||||||||||||||
| 1181 | event.window = m_window; | - | ||||||||||||||||||
| 1182 | event.type = atom(QXcbAtom::WM_CHANGE_STATE); | - | ||||||||||||||||||
| 1183 | event.data.data32[0] = XCB_ICCCM_WM_STATE_ICONIC; | - | ||||||||||||||||||
| 1184 | event.data.data32[1] = 0; | - | ||||||||||||||||||
| 1185 | event.data.data32[2] = 0; | - | ||||||||||||||||||
| 1186 | event.data.data32[3] = 0; | - | ||||||||||||||||||
| 1187 | event.data.data32[4] = 0; | - | ||||||||||||||||||
| 1188 | - | |||||||||||||||||||
| 1189 | xcb_send_event(xcb_connection(), 0, xcbScreen()->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event); | - | ||||||||||||||||||
| 1190 | } | - | ||||||||||||||||||
| 1191 | break; | - | ||||||||||||||||||
| 1192 | case Qt::WindowMaximized: | - | ||||||||||||||||||
| 1193 | changeNetWmState(true, | - | ||||||||||||||||||
| 1194 | atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ), | - | ||||||||||||||||||
| 1195 | atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT)); | - | ||||||||||||||||||
| 1196 | break; | - | ||||||||||||||||||
| 1197 | case Qt::WindowFullScreen: | - | ||||||||||||||||||
| 1198 | changeNetWmState(true, atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN)); | - | ||||||||||||||||||
| 1199 | break; | - | ||||||||||||||||||
| 1200 | case Qt::WindowNoState: | - | ||||||||||||||||||
| 1201 | break; | - | ||||||||||||||||||
| 1202 | default: | - | ||||||||||||||||||
| 1203 | break; | - | ||||||||||||||||||
| 1204 | } | - | ||||||||||||||||||
| 1205 | - | |||||||||||||||||||
| 1206 | connection()->sync(); | - | ||||||||||||||||||
| 1207 | - | |||||||||||||||||||
| 1208 | m_windowState = state; | - | ||||||||||||||||||
| 1209 | } | - | ||||||||||||||||||
| 1210 | - | |||||||||||||||||||
| 1211 | void QXcbWindow::updateMotifWmHintsBeforeMap() | - | ||||||||||||||||||
| 1212 | { | - | ||||||||||||||||||
| 1213 | QtMotifWmHints mwmhints = getMotifWmHints(connection(), m_window); | - | ||||||||||||||||||
| 1214 | - | |||||||||||||||||||
| 1215 | if (window()->modality() != Qt::NonModal) { | - | ||||||||||||||||||
| 1216 | switch (window()->modality()) { | - | ||||||||||||||||||
| 1217 | case Qt::WindowModal: | - | ||||||||||||||||||
| 1218 | mwmhints.input_mode = MWM_INPUT_PRIMARY_APPLICATION_MODAL; | - | ||||||||||||||||||
| 1219 | break; | - | ||||||||||||||||||
| 1220 | case Qt::ApplicationModal: | - | ||||||||||||||||||
| 1221 | default: | - | ||||||||||||||||||
| 1222 | mwmhints.input_mode = MWM_INPUT_FULL_APPLICATION_MODAL; | - | ||||||||||||||||||
| 1223 | break; | - | ||||||||||||||||||
| 1224 | } | - | ||||||||||||||||||
| 1225 | mwmhints.flags |= MWM_HINTS_INPUT_MODE; | - | ||||||||||||||||||
| 1226 | } else { | - | ||||||||||||||||||
| 1227 | mwmhints.input_mode = MWM_INPUT_MODELESS; | - | ||||||||||||||||||
| 1228 | mwmhints.flags &= ~MWM_HINTS_INPUT_MODE; | - | ||||||||||||||||||
| 1229 | } | - | ||||||||||||||||||
| 1230 | - | |||||||||||||||||||
| 1231 | if (windowMinimumSize() == windowMaximumSize()) { | - | ||||||||||||||||||
| 1232 | - | |||||||||||||||||||
| 1233 | - | |||||||||||||||||||
| 1234 | mwmhints.flags |= MWM_HINTS_FUNCTIONS; | - | ||||||||||||||||||
| 1235 | if (mwmhints.functions == MWM_FUNC_ALL) { | - | ||||||||||||||||||
| 1236 | mwmhints.functions = MWM_FUNC_MOVE; | - | ||||||||||||||||||
| 1237 | } else { | - | ||||||||||||||||||
| 1238 | mwmhints.functions &= ~MWM_FUNC_RESIZE; | - | ||||||||||||||||||
| 1239 | } | - | ||||||||||||||||||
| 1240 | - | |||||||||||||||||||
| 1241 | if (mwmhints.decorations == MWM_DECOR_ALL) { | - | ||||||||||||||||||
| 1242 | mwmhints.flags |= MWM_HINTS_DECORATIONS; | - | ||||||||||||||||||
| 1243 | mwmhints.decorations = (MWM_DECOR_BORDER | - | ||||||||||||||||||
| 1244 | | MWM_DECOR_TITLE | - | ||||||||||||||||||
| 1245 | | MWM_DECOR_MENU); | - | ||||||||||||||||||
| 1246 | } else { | - | ||||||||||||||||||
| 1247 | mwmhints.decorations &= ~MWM_DECOR_RESIZEH; | - | ||||||||||||||||||
| 1248 | } | - | ||||||||||||||||||
| 1249 | } | - | ||||||||||||||||||
| 1250 | - | |||||||||||||||||||
| 1251 | if (window()->flags() & Qt::WindowMinimizeButtonHint) { | - | ||||||||||||||||||
| 1252 | mwmhints.flags |= MWM_HINTS_DECORATIONS; | - | ||||||||||||||||||
| 1253 | mwmhints.decorations |= MWM_DECOR_MINIMIZE; | - | ||||||||||||||||||
| 1254 | mwmhints.functions |= MWM_FUNC_MINIMIZE; | - | ||||||||||||||||||
| 1255 | } | - | ||||||||||||||||||
| 1256 | if (window()->flags() & Qt::WindowMaximizeButtonHint) { | - | ||||||||||||||||||
| 1257 | mwmhints.flags |= MWM_HINTS_DECORATIONS; | - | ||||||||||||||||||
| 1258 | mwmhints.decorations |= MWM_DECOR_MAXIMIZE; | - | ||||||||||||||||||
| 1259 | mwmhints.functions |= MWM_FUNC_MAXIMIZE; | - | ||||||||||||||||||
| 1260 | } | - | ||||||||||||||||||
| 1261 | if (window()->flags() & Qt::WindowCloseButtonHint) | - | ||||||||||||||||||
| 1262 | mwmhints.functions |= MWM_FUNC_CLOSE; | - | ||||||||||||||||||
| 1263 | - | |||||||||||||||||||
| 1264 | setMotifWmHints(connection(), m_window, mwmhints); | - | ||||||||||||||||||
| 1265 | } | - | ||||||||||||||||||
| 1266 | - | |||||||||||||||||||
| 1267 | void QXcbWindow::updateNetWmStateBeforeMap() | - | ||||||||||||||||||
| 1268 | { | - | ||||||||||||||||||
| 1269 | NetWmStates states(0); | - | ||||||||||||||||||
| 1270 | - | |||||||||||||||||||
| 1271 | const Qt::WindowFlags flags = window()->flags(); | - | ||||||||||||||||||
| 1272 | if (flags & Qt::WindowStaysOnTopHint) { | - | ||||||||||||||||||
| 1273 | states |= NetWmStateAbove; | - | ||||||||||||||||||
| 1274 | states |= NetWmStateStaysOnTop; | - | ||||||||||||||||||
| 1275 | } else if (flags & Qt::WindowStaysOnBottomHint) { | - | ||||||||||||||||||
| 1276 | states |= NetWmStateBelow; | - | ||||||||||||||||||
| 1277 | } | - | ||||||||||||||||||
| 1278 | - | |||||||||||||||||||
| 1279 | if (window()->windowState() & Qt::WindowFullScreen) | - | ||||||||||||||||||
| 1280 | states |= NetWmStateFullScreen; | - | ||||||||||||||||||
| 1281 | - | |||||||||||||||||||
| 1282 | if (window()->windowState() & Qt::WindowMaximized) { | - | ||||||||||||||||||
| 1283 | states |= NetWmStateMaximizedHorz; | - | ||||||||||||||||||
| 1284 | states |= NetWmStateMaximizedVert; | - | ||||||||||||||||||
| 1285 | } | - | ||||||||||||||||||
| 1286 | - | |||||||||||||||||||
| 1287 | if (window()->modality() != Qt::NonModal) | - | ||||||||||||||||||
| 1288 | states |= NetWmStateModal; | - | ||||||||||||||||||
| 1289 | - | |||||||||||||||||||
| 1290 | setNetWmStates(states); | - | ||||||||||||||||||
| 1291 | } | - | ||||||||||||||||||
| 1292 | - | |||||||||||||||||||
| 1293 | void QXcbWindow::setNetWmStateWindowFlags(Qt::WindowFlags flags) | - | ||||||||||||||||||
| 1294 | { | - | ||||||||||||||||||
| 1295 | changeNetWmState(flags & Qt::WindowStaysOnTopHint, | - | ||||||||||||||||||
| 1296 | atom(QXcbAtom::_NET_WM_STATE_ABOVE), | - | ||||||||||||||||||
| 1297 | atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP)); | - | ||||||||||||||||||
| 1298 | changeNetWmState(flags & Qt::WindowStaysOnBottomHint, | - | ||||||||||||||||||
| 1299 | atom(QXcbAtom::_NET_WM_STATE_BELOW)); | - | ||||||||||||||||||
| 1300 | } executed 4158 times by 125 tests:  end of blockExecuted by: 
  | 4158 | ||||||||||||||||||
| 1301 | - | |||||||||||||||||||
| 1302 | void QXcbWindow::updateNetWmUserTime(xcb_timestamp_t timestamp) | - | ||||||||||||||||||
| 1303 | { | - | ||||||||||||||||||
| 1304 | xcb_window_t wid = m_window; | - | ||||||||||||||||||
| 1305 | - | |||||||||||||||||||
| 1306 | - | |||||||||||||||||||
| 1307 | - | |||||||||||||||||||
| 1308 | if (timestamp != 0) | - | ||||||||||||||||||
| 1309 | connection()->setNetWmUserTime(timestamp); | - | ||||||||||||||||||
| 1310 | - | |||||||||||||||||||
| 1311 | const bool isSupportedByWM = connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW)); | - | ||||||||||||||||||
| 1312 | if (m_netWmUserTimeWindow || isSupportedByWM) { | - | ||||||||||||||||||
| 1313 | if (!m_netWmUserTimeWindow) { | - | ||||||||||||||||||
| 1314 | m_netWmUserTimeWindow = xcb_generate_id(xcb_connection()); | - | ||||||||||||||||||
| 1315 | xcb_create_window(xcb_connection(), 0L, m_netWmUserTimeWindow, m_window, -1, -1, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, m_visualId, 0, 0) | - | ||||||||||||||||||
| 1316 | ; | - | ||||||||||||||||||
| 1317 | wid = m_netWmUserTimeWindow; | - | ||||||||||||||||||
| 1318 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW), | - | ||||||||||||||||||
| 1319 | XCB_ATOM_WINDOW, 32, 1, &m_netWmUserTimeWindow); | - | ||||||||||||||||||
| 1320 | xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_USER_TIME)); | - | ||||||||||||||||||
| 1321 | - | |||||||||||||||||||
| 1322 | QByteArray ba("Qt NET_WM user time window"); | - | ||||||||||||||||||
| 1323 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_netWmUserTimeWindow, atom(QXcbAtom::_NET_WM_NAME), atom(QXcbAtom::UTF8_STRING), 8, ba.length(), ba.constData()) | - | ||||||||||||||||||
| 1324 | - | |||||||||||||||||||
| 1325 | - | |||||||||||||||||||
| 1326 | - | |||||||||||||||||||
| 1327 | - | |||||||||||||||||||
| 1328 | - | |||||||||||||||||||
| 1329 | - | |||||||||||||||||||
| 1330 | ; | - | ||||||||||||||||||
| 1331 | - | |||||||||||||||||||
| 1332 | } else if (!isSupportedByWM) { | - | ||||||||||||||||||
| 1333 | - | |||||||||||||||||||
| 1334 | - | |||||||||||||||||||
| 1335 | xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW)); | - | ||||||||||||||||||
| 1336 | xcb_destroy_window(xcb_connection(), m_netWmUserTimeWindow); | - | ||||||||||||||||||
| 1337 | m_netWmUserTimeWindow = 0L; | - | ||||||||||||||||||
| 1338 | } else { | - | ||||||||||||||||||
| 1339 | wid = m_netWmUserTimeWindow; | - | ||||||||||||||||||
| 1340 | } | - | ||||||||||||||||||
| 1341 | } | - | ||||||||||||||||||
| 1342 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, wid, atom(QXcbAtom::_NET_WM_USER_TIME), | - | ||||||||||||||||||
| 1343 | XCB_ATOM_CARDINAL, 32, 1, ×tamp); | - | ||||||||||||||||||
| 1344 | } | - | ||||||||||||||||||
| 1345 | - | |||||||||||||||||||
| 1346 | void QXcbWindow::setTransparentForMouseEvents(bool transparent) | - | ||||||||||||||||||
| 1347 | { | - | ||||||||||||||||||
| 1348 | if (!connection()->hasXFixes() || transparent == m_transparent) | - | ||||||||||||||||||
| 1349 | return; | - | ||||||||||||||||||
| 1350 | - | |||||||||||||||||||
| 1351 | xcb_rectangle_t rectangle; | - | ||||||||||||||||||
| 1352 | - | |||||||||||||||||||
| 1353 | xcb_rectangle_t *rect = 0; | - | ||||||||||||||||||
| 1354 | int nrect = 0; | - | ||||||||||||||||||
| 1355 | - | |||||||||||||||||||
| 1356 | if (!transparent) { | - | ||||||||||||||||||
| 1357 | rectangle.x = 0; | - | ||||||||||||||||||
| 1358 | rectangle.y = 0; | - | ||||||||||||||||||
| 1359 | rectangle.width = geometry().width(); | - | ||||||||||||||||||
| 1360 | rectangle.height = geometry().height(); | - | ||||||||||||||||||
| 1361 | rect = &rectangle; | - | ||||||||||||||||||
| 1362 | nrect = 1; | - | ||||||||||||||||||
| 1363 | } | - | ||||||||||||||||||
| 1364 | - | |||||||||||||||||||
| 1365 | xcb_xfixes_region_t region = xcb_generate_id(xcb_connection()); | - | ||||||||||||||||||
| 1366 | xcb_xfixes_create_region(xcb_connection(), region, nrect, rect); | - | ||||||||||||||||||
| 1367 | xcb_xfixes_set_window_shape_region_checked(xcb_connection(), m_window, XCB_SHAPE_SK_INPUT, 0, 0, region); | - | ||||||||||||||||||
| 1368 | xcb_xfixes_destroy_region(xcb_connection(), region); | - | ||||||||||||||||||
| 1369 | - | |||||||||||||||||||
| 1370 | m_transparent = transparent; | - | ||||||||||||||||||
| 1371 | } | - | ||||||||||||||||||
| 1372 | - | |||||||||||||||||||
| 1373 | void QXcbWindow::updateDoesNotAcceptFocus(bool doesNotAcceptFocus) | - | ||||||||||||||||||
| 1374 | { | - | ||||||||||||||||||
| 1375 | xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_hints_unchecked(xcb_connection(), m_window); | - | ||||||||||||||||||
| 1376 | - | |||||||||||||||||||
| 1377 | xcb_icccm_wm_hints_t hints; | - | ||||||||||||||||||
| 1378 | if (!xcb_icccm_get_wm_hints_reply(xcb_connection(), cookie, &hints, __null)) { | - | ||||||||||||||||||
| 1379 | return; | - | ||||||||||||||||||
| 1380 | } | - | ||||||||||||||||||
| 1381 | - | |||||||||||||||||||
| 1382 | xcb_icccm_wm_hints_set_input(&hints, !doesNotAcceptFocus); | - | ||||||||||||||||||
| 1383 | xcb_icccm_set_wm_hints(xcb_connection(), m_window, &hints); | - | ||||||||||||||||||
| 1384 | } | - | ||||||||||||||||||
| 1385 | - | |||||||||||||||||||
| 1386 | WId QXcbWindow::winId() const | - | ||||||||||||||||||
| 1387 | { | - | ||||||||||||||||||
| 1388 | return m_window; | - | ||||||||||||||||||
| 1389 | } | - | ||||||||||||||||||
| 1390 | - | |||||||||||||||||||
| 1391 | void QXcbWindow::setParent(const QPlatformWindow *parent) | - | ||||||||||||||||||
| 1392 | { | - | ||||||||||||||||||
| 1393 | QPoint topLeft = geometry().topLeft(); | - | ||||||||||||||||||
| 1394 | - | |||||||||||||||||||
| 1395 | xcb_window_t xcb_parent_id; | - | ||||||||||||||||||
| 1396 | if (parent) { | - | ||||||||||||||||||
| 1397 | const QXcbWindow *qXcbParent = static_cast<const QXcbWindow *>(parent); | - | ||||||||||||||||||
| 1398 | xcb_parent_id = qXcbParent->xcb_window(); | - | ||||||||||||||||||
| 1399 | m_embedded = qXcbParent->window()->type() == Qt::ForeignWindow; | - | ||||||||||||||||||
| 1400 | } else { | - | ||||||||||||||||||
| 1401 | xcb_parent_id = xcbScreen()->root(); | - | ||||||||||||||||||
| 1402 | m_embedded = false; | - | ||||||||||||||||||
| 1403 | } | - | ||||||||||||||||||
| 1404 | xcb_reparent_window(xcb_connection(), xcb_window(), xcb_parent_id, topLeft.x(), topLeft.y()); | - | ||||||||||||||||||
| 1405 | } | - | ||||||||||||||||||
| 1406 | - | |||||||||||||||||||
| 1407 | void QXcbWindow::setWindowTitle(const QString &title) | - | ||||||||||||||||||
| 1408 | { | - | ||||||||||||||||||
| 1409 | const QString fullTitle = formatWindowTitle(title, QString::fromUtf8(" \xe2\x80\x94 ")); | - | ||||||||||||||||||
| 1410 | const QByteArray ba = fullTitle.toUtf8(); | - | ||||||||||||||||||
| 1411 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_NAME), atom(QXcbAtom::UTF8_STRING), 8, ba.length(), ba.constData()) | - | ||||||||||||||||||
| 1412 | - | |||||||||||||||||||
| 1413 | - | |||||||||||||||||||
| 1414 | - | |||||||||||||||||||
| 1415 | - | |||||||||||||||||||
| 1416 | - | |||||||||||||||||||
| 1417 | - | |||||||||||||||||||
| 1418 | ; | - | ||||||||||||||||||
| 1419 | - | |||||||||||||||||||
| 1420 | - | |||||||||||||||||||
| 1421 | XTextProperty *text = qstringToXTP(((Display *)(this->connection()->xlib_display())), title); | - | ||||||||||||||||||
| 1422 | if (text) | - | ||||||||||||||||||
| 1423 | XSetWMName(((Display *)(this->connection()->xlib_display())), m_window, text); | - | ||||||||||||||||||
| 1424 | - | |||||||||||||||||||
| 1425 | xcb_flush(xcb_connection()); | - | ||||||||||||||||||
| 1426 | } | - | ||||||||||||||||||
| 1427 | - | |||||||||||||||||||
| 1428 | void QXcbWindow::setWindowIconText(const QString &title) | - | ||||||||||||||||||
| 1429 | { | - | ||||||||||||||||||
| 1430 | const QByteArray ba = title.toUtf8(); | - | ||||||||||||||||||
| 1431 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_ICON_NAME), atom(QXcbAtom::UTF8_STRING), 8, ba.length(), ba.constData()) | - | ||||||||||||||||||
| 1432 | - | |||||||||||||||||||
| 1433 | - | |||||||||||||||||||
| 1434 | - | |||||||||||||||||||
| 1435 | - | |||||||||||||||||||
| 1436 | - | |||||||||||||||||||
| 1437 | - | |||||||||||||||||||
| 1438 | ; | - | ||||||||||||||||||
| 1439 | } | - | ||||||||||||||||||
| 1440 | - | |||||||||||||||||||
| 1441 | void QXcbWindow::setWindowIcon(const QIcon &icon) | - | ||||||||||||||||||
| 1442 | { | - | ||||||||||||||||||
| 1443 | QVector<quint32> icon_data; | - | ||||||||||||||||||
| 1444 | if (!icon.isNull()) { | - | ||||||||||||||||||
| 1445 | QList<QSize> availableSizes = icon.availableSizes(); | - | ||||||||||||||||||
| 1446 | if (availableSizes.isEmpty()) { | - | ||||||||||||||||||
| 1447 | - | |||||||||||||||||||
| 1448 | availableSizes.push_back(QSize(16,16)); | - | ||||||||||||||||||
| 1449 | availableSizes.push_back(QSize(32,32)); | - | ||||||||||||||||||
| 1450 | availableSizes.push_back(QSize(64,64)); | - | ||||||||||||||||||
| 1451 | availableSizes.push_back(QSize(128,128)); | - | ||||||||||||||||||
| 1452 | } | - | ||||||||||||||||||
| 1453 | for (int i = 0; i < availableSizes.size(); ++i) { | - | ||||||||||||||||||
| 1454 | QSize size = availableSizes.at(i); | - | ||||||||||||||||||
| 1455 | QPixmap pixmap = icon.pixmap(size); | - | ||||||||||||||||||
| 1456 | if (!pixmap.isNull()) { | - | ||||||||||||||||||
| 1457 | QImage image = pixmap.toImage().convertToFormat(QImage::Format_ARGB32); | - | ||||||||||||||||||
| 1458 | int pos = icon_data.size(); | - | ||||||||||||||||||
| 1459 | icon_data.resize(pos + 2 + image.width()*image.height()); | - | ||||||||||||||||||
| 1460 | icon_data[pos++] = image.width(); | - | ||||||||||||||||||
| 1461 | icon_data[pos++] = image.height(); | - | ||||||||||||||||||
| 1462 | memcpy(icon_data.data() + pos, image.bits(), image.width()*image.height()*4); | - | ||||||||||||||||||
| 1463 | } | - | ||||||||||||||||||
| 1464 | } | - | ||||||||||||||||||
| 1465 | } | - | ||||||||||||||||||
| 1466 | - | |||||||||||||||||||
| 1467 | if (!icon_data.isEmpty()) { | - | ||||||||||||||||||
| 1468 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_ICON), atom(QXcbAtom::CARDINAL), 32, icon_data.size(), (unsigned char *) icon_data.data()) | - | ||||||||||||||||||
| 1469 | - | |||||||||||||||||||
| 1470 | - | |||||||||||||||||||
| 1471 | - | |||||||||||||||||||
| 1472 | - | |||||||||||||||||||
| 1473 | - | |||||||||||||||||||
| 1474 | - | |||||||||||||||||||
| 1475 | ; | - | ||||||||||||||||||
| 1476 | } else { | - | ||||||||||||||||||
| 1477 | xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_ICON)) | - | ||||||||||||||||||
| 1478 | - | |||||||||||||||||||
| 1479 | ; | - | ||||||||||||||||||
| 1480 | } | - | ||||||||||||||||||
| 1481 | } | - | ||||||||||||||||||
| 1482 | - | |||||||||||||||||||
| 1483 | void QXcbWindow::raise() | - | ||||||||||||||||||
| 1484 | { | - | ||||||||||||||||||
| 1485 | const quint32 mask = XCB_CONFIG_WINDOW_STACK_MODE; | - | ||||||||||||||||||
| 1486 | const quint32 values[] = { XCB_STACK_MODE_ABOVE }; | - | ||||||||||||||||||
| 1487 | xcb_configure_window(xcb_connection(), m_window, mask, values); | - | ||||||||||||||||||
| 1488 | } | - | ||||||||||||||||||
| 1489 | - | |||||||||||||||||||
| 1490 | void QXcbWindow::lower() | - | ||||||||||||||||||
| 1491 | { | - | ||||||||||||||||||
| 1492 | const quint32 mask = XCB_CONFIG_WINDOW_STACK_MODE; | - | ||||||||||||||||||
| 1493 | const quint32 values[] = { XCB_STACK_MODE_BELOW }; | - | ||||||||||||||||||
| 1494 | xcb_configure_window(xcb_connection(), m_window, mask, values); | - | ||||||||||||||||||
| 1495 | } | - | ||||||||||||||||||
| 1496 | - | |||||||||||||||||||
| 1497 | - | |||||||||||||||||||
| 1498 | - | |||||||||||||||||||
| 1499 | QRect QXcbWindow::windowToWmGeometry(QRect r) const | - | ||||||||||||||||||
| 1500 | { | - | ||||||||||||||||||
| 1501 | if (m_dirtyFrameMargins || m_frameMargins.isNull()) | - | ||||||||||||||||||
| 1502 | return r; | - | ||||||||||||||||||
| 1503 | const bool frameInclusive = positionIncludesFrame(window()); | - | ||||||||||||||||||
| 1504 | - | |||||||||||||||||||
| 1505 | - | |||||||||||||||||||
| 1506 | if (frameInclusive && m_gravity == XCB_GRAVITY_STATIC) { | - | ||||||||||||||||||
| 1507 | r.translate(m_frameMargins.left(), m_frameMargins.top()); | - | ||||||||||||||||||
| 1508 | } else if (!frameInclusive && m_gravity == XCB_GRAVITY_NORTH_WEST) { | - | ||||||||||||||||||
| 1509 | r.translate(-m_frameMargins.left(), -m_frameMargins.top()); | - | ||||||||||||||||||
| 1510 | } | - | ||||||||||||||||||
| 1511 | return r; | - | ||||||||||||||||||
| 1512 | } | - | ||||||||||||||||||
| 1513 | - | |||||||||||||||||||
| 1514 | void QXcbWindow::propagateSizeHints() | - | ||||||||||||||||||
| 1515 | { | - | ||||||||||||||||||
| 1516 | - | |||||||||||||||||||
| 1517 | xcb_size_hints_t hints; | - | ||||||||||||||||||
| 1518 | memset(&hints, 0, sizeof(hints)); | - | ||||||||||||||||||
| 1519 | - | |||||||||||||||||||
| 1520 | const QRect xRect = windowToWmGeometry(geometry()); | - | ||||||||||||||||||
| 1521 | - | |||||||||||||||||||
| 1522 | QWindow *win = window(); | - | ||||||||||||||||||
| 1523 | - | |||||||||||||||||||
| 1524 | if (!qt_window_private(win)->positionAutomatic) | - | ||||||||||||||||||
| 1525 | xcb_icccm_size_hints_set_position(&hints, true, xRect.x(), xRect.y()); | - | ||||||||||||||||||
| 1526 | if (xRect.width() < ((1<<24)-1) || xRect.height() < ((1<<24)-1)) | - | ||||||||||||||||||
| 1527 | xcb_icccm_size_hints_set_size(&hints, true, xRect.width(), xRect.height()); | - | ||||||||||||||||||
| 1528 | xcb_icccm_size_hints_set_win_gravity(&hints, m_gravity); | - | ||||||||||||||||||
| 1529 | - | |||||||||||||||||||
| 1530 | QSize minimumSize = windowMinimumSize(); | - | ||||||||||||||||||
| 1531 | QSize maximumSize = windowMaximumSize(); | - | ||||||||||||||||||
| 1532 | QSize baseSize = windowBaseSize(); | - | ||||||||||||||||||
| 1533 | QSize sizeIncrement = windowSizeIncrement(); | - | ||||||||||||||||||
| 1534 | - | |||||||||||||||||||
| 1535 | if (minimumSize.width() > 0 || minimumSize.height() > 0) | - | ||||||||||||||||||
| 1536 | xcb_icccm_size_hints_set_min_size(&hints, | - | ||||||||||||||||||
| 1537 | qMin(16383,minimumSize.width()), | - | ||||||||||||||||||
| 1538 | qMin(16383,minimumSize.height())); | - | ||||||||||||||||||
| 1539 | - | |||||||||||||||||||
| 1540 | if (maximumSize.width() < ((1<<24)-1) || maximumSize.height() < ((1<<24)-1)) | - | ||||||||||||||||||
| 1541 | xcb_icccm_size_hints_set_max_size(&hints, | - | ||||||||||||||||||
| 1542 | qMin(16383, maximumSize.width()), | - | ||||||||||||||||||
| 1543 | qMin(16383, maximumSize.height())); | - | ||||||||||||||||||
| 1544 | - | |||||||||||||||||||
| 1545 | if (sizeIncrement.width() > 0 || sizeIncrement.height() > 0) { | - | ||||||||||||||||||
| 1546 | xcb_icccm_size_hints_set_base_size(&hints, baseSize.width(), baseSize.height()); | - | ||||||||||||||||||
| 1547 | xcb_icccm_size_hints_set_resize_inc(&hints, sizeIncrement.width(), sizeIncrement.height()); | - | ||||||||||||||||||
| 1548 | } | - | ||||||||||||||||||
| 1549 | - | |||||||||||||||||||
| 1550 | xcb_icccm_set_wm_normal_hints(xcb_connection(), m_window, &hints); | - | ||||||||||||||||||
| 1551 | } | - | ||||||||||||||||||
| 1552 | - | |||||||||||||||||||
| 1553 | void QXcbWindow::requestActivateWindow() | - | ||||||||||||||||||
| 1554 | { | - | ||||||||||||||||||
| 1555 | - | |||||||||||||||||||
| 1556 | - | |||||||||||||||||||
| 1557 |     if (m_embedded
  | 0-1383 | ||||||||||||||||||
| 1558 | QPlatformWindow::requestActivateWindow(); | - | ||||||||||||||||||
| 1559 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 1560 | } | - | ||||||||||||||||||
| 1561 | - | |||||||||||||||||||
| 1562 |     if (!m_mapped|| !xcbScreen())
  | 650-733 | ||||||||||||||||||
| 1563 | m_deferredActivation = true; | - | ||||||||||||||||||
| 1564 |         return; executed 733 times by 58 tests:  return;Executed by: 
  | 733 | ||||||||||||||||||
| 1565 | } | - | ||||||||||||||||||
| 1566 | m_deferredActivation = false; | - | ||||||||||||||||||
| 1567 | - | |||||||||||||||||||
| 1568 | updateNetWmUserTime(connection()->time()); | - | ||||||||||||||||||
| 1569 | QWindow *focusWindow = QGuiApplication::focusWindow(); | - | ||||||||||||||||||
| 1570 | - | |||||||||||||||||||
| 1571 |     if (window()->isTopLevel()
  | 4-646 | ||||||||||||||||||
| 1572 |         && !(window()->flags() & Qt::X11BypassWindowManagerHint)
  | 15-631 | ||||||||||||||||||
| 1573 |         && (!focusWindow
 
  | 11-363 | ||||||||||||||||||
| 1574 |         && connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::_NET_ACTIVE_WINDOW))
  | 0-620 | ||||||||||||||||||
| 1575 | xcb_client_message_event_t event; | - | ||||||||||||||||||
| 1576 | - | |||||||||||||||||||
| 1577 | event.response_type = 33; | - | ||||||||||||||||||
| 1578 | event.format = 32; | - | ||||||||||||||||||
| 1579 | event.sequence = 0; | - | ||||||||||||||||||
| 1580 | event.window = m_window; | - | ||||||||||||||||||
| 1581 | event.type = atom(QXcbAtom::_NET_ACTIVE_WINDOW); | - | ||||||||||||||||||
| 1582 | event.data.data32[0] = 1; | - | ||||||||||||||||||
| 1583 | event.data.data32[1] = connection()->time(); | - | ||||||||||||||||||
| 1584 |         event.data.data32[2] = focusWindow
  | 257-363 | ||||||||||||||||||
| 1585 | event.data.data32[3] = 0; | - | ||||||||||||||||||
| 1586 | event.data.data32[4] = 0; | - | ||||||||||||||||||
| 1587 | - | |||||||||||||||||||
| 1588 | xcb_send_event(xcb_connection(), 0, xcbScreen()->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event); | - | ||||||||||||||||||
| 1589 |     } executed 620 times by 59 tests:   else {end of blockExecuted by: 
  | 620 | ||||||||||||||||||
| 1590 | xcb_set_input_focus(xcb_connection(), XCB_INPUT_FOCUS_PARENT, m_window, connection()->time()); | - | ||||||||||||||||||
| 1591 |     } executed 30 times by 11 tests:  end of blockExecuted by: 
  | 30 | ||||||||||||||||||
| 1592 | - | |||||||||||||||||||
| 1593 | connection()->sync(); | - | ||||||||||||||||||
| 1594 | } executed 650 times by 59 tests:  end of blockExecuted by: 
  | 650 | ||||||||||||||||||
| 1595 | - | |||||||||||||||||||
| 1596 | QSurfaceFormat QXcbWindow::format() const | - | ||||||||||||||||||
| 1597 | { | - | ||||||||||||||||||
| 1598 | return m_format; | - | ||||||||||||||||||
| 1599 | } | - | ||||||||||||||||||
| 1600 | - | |||||||||||||||||||
| 1601 | void QXcbWindow::setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes) | - | ||||||||||||||||||
| 1602 | { | - | ||||||||||||||||||
| 1603 | window->setProperty(wm_window_type_property_id, QVariant::fromValue(static_cast<int>(windowTypes))); | - | ||||||||||||||||||
| 1604 | - | |||||||||||||||||||
| 1605 | if (window->handle()) | - | ||||||||||||||||||
| 1606 | static_cast<QXcbWindow *>(window->handle())->setWmWindowType(windowTypes, window->flags()); | - | ||||||||||||||||||
| 1607 | } | - | ||||||||||||||||||
| 1608 | - | |||||||||||||||||||
| 1609 | void QXcbWindow::setWindowIconTextStatic(QWindow *window, const QString &text) | - | ||||||||||||||||||
| 1610 | { | - | ||||||||||||||||||
| 1611 | if (window->handle()) | - | ||||||||||||||||||
| 1612 | static_cast<QXcbWindow *>(window->handle())->setWindowIconText(text); | - | ||||||||||||||||||
| 1613 | } | - | ||||||||||||||||||
| 1614 | - | |||||||||||||||||||
| 1615 | void QXcbWindow::setWmWindowRoleStatic(QWindow *window, const QByteArray &role) | - | ||||||||||||||||||
| 1616 | { | - | ||||||||||||||||||
| 1617 | if (window->handle()) | - | ||||||||||||||||||
| 1618 | static_cast<QXcbWindow *>(window->handle())->setWmWindowRole(role); | - | ||||||||||||||||||
| 1619 | else | - | ||||||||||||||||||
| 1620 | window->setProperty(wm_window_role_property_id, role); | - | ||||||||||||||||||
| 1621 | } | - | ||||||||||||||||||
| 1622 | - | |||||||||||||||||||
| 1623 | uint QXcbWindow::visualIdStatic(QWindow *window) | - | ||||||||||||||||||
| 1624 | { | - | ||||||||||||||||||
| 1625 | if (window && window->handle()) | - | ||||||||||||||||||
| 1626 | return static_cast<QXcbWindow *>(window->handle())->visualId(); | - | ||||||||||||||||||
| 1627 | return (2147483647 * 2U + 1U); | - | ||||||||||||||||||
| 1628 | } | - | ||||||||||||||||||
| 1629 | - | |||||||||||||||||||
| 1630 | QXcbWindowFunctions::WmWindowTypes QXcbWindow::wmWindowTypes() const | - | ||||||||||||||||||
| 1631 | { | - | ||||||||||||||||||
| 1632 | QXcbWindowFunctions::WmWindowTypes result(0); | - | ||||||||||||||||||
| 1633 | - | |||||||||||||||||||
| 1634 | xcb_get_property_cookie_t get_cookie = | - | ||||||||||||||||||
| 1635 | xcb_get_property_unchecked(xcb_connection(), 0, m_window, atom(QXcbAtom::_NET_WM_WINDOW_TYPE), | - | ||||||||||||||||||
| 1636 | XCB_ATOM_ATOM, 0, 1024); | - | ||||||||||||||||||
| 1637 | - | |||||||||||||||||||
| 1638 | xcb_get_property_reply_t *reply = | - | ||||||||||||||||||
| 1639 | xcb_get_property_reply(xcb_connection(), get_cookie, __null); | - | ||||||||||||||||||
| 1640 | - | |||||||||||||||||||
| 1641 | if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM) { | - | ||||||||||||||||||
| 1642 | const xcb_atom_t *types = static_cast<const xcb_atom_t *>(xcb_get_property_value(reply)); | - | ||||||||||||||||||
| 1643 | const xcb_atom_t *types_end = types + reply->length; | - | ||||||||||||||||||
| 1644 | for (; types != types_end; types++) { | - | ||||||||||||||||||
| 1645 | QXcbAtom::Atom type = connection()->qatom(*types); | - | ||||||||||||||||||
| 1646 | switch (type) { | - | ||||||||||||||||||
| 1647 | case QXcbAtom::_NET_WM_WINDOW_TYPE_NORMAL: | - | ||||||||||||||||||
| 1648 | result |= QXcbWindowFunctions::Normal; | - | ||||||||||||||||||
| 1649 | break; | - | ||||||||||||||||||
| 1650 | case QXcbAtom::_NET_WM_WINDOW_TYPE_DESKTOP: | - | ||||||||||||||||||
| 1651 | result |= QXcbWindowFunctions::Desktop; | - | ||||||||||||||||||
| 1652 | break; | - | ||||||||||||||||||
| 1653 | case QXcbAtom::_NET_WM_WINDOW_TYPE_DOCK: | - | ||||||||||||||||||
| 1654 | result |= QXcbWindowFunctions::Dock; | - | ||||||||||||||||||
| 1655 | break; | - | ||||||||||||||||||
| 1656 | case QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLBAR: | - | ||||||||||||||||||
| 1657 | result |= QXcbWindowFunctions::Toolbar; | - | ||||||||||||||||||
| 1658 | break; | - | ||||||||||||||||||
| 1659 | case QXcbAtom::_NET_WM_WINDOW_TYPE_MENU: | - | ||||||||||||||||||
| 1660 | result |= QXcbWindowFunctions::Menu; | - | ||||||||||||||||||
| 1661 | break; | - | ||||||||||||||||||
| 1662 | case QXcbAtom::_NET_WM_WINDOW_TYPE_UTILITY: | - | ||||||||||||||||||
| 1663 | result |= QXcbWindowFunctions::Utility; | - | ||||||||||||||||||
| 1664 | break; | - | ||||||||||||||||||
| 1665 | case QXcbAtom::_NET_WM_WINDOW_TYPE_SPLASH: | - | ||||||||||||||||||
| 1666 | result |= QXcbWindowFunctions::Splash; | - | ||||||||||||||||||
| 1667 | break; | - | ||||||||||||||||||
| 1668 | case QXcbAtom::_NET_WM_WINDOW_TYPE_DIALOG: | - | ||||||||||||||||||
| 1669 | result |= QXcbWindowFunctions::Dialog; | - | ||||||||||||||||||
| 1670 | break; | - | ||||||||||||||||||
| 1671 | case QXcbAtom::_NET_WM_WINDOW_TYPE_DROPDOWN_MENU: | - | ||||||||||||||||||
| 1672 | result |= QXcbWindowFunctions::DropDownMenu; | - | ||||||||||||||||||
| 1673 | break; | - | ||||||||||||||||||
| 1674 | case QXcbAtom::_NET_WM_WINDOW_TYPE_POPUP_MENU: | - | ||||||||||||||||||
| 1675 | result |= QXcbWindowFunctions::PopupMenu; | - | ||||||||||||||||||
| 1676 | break; | - | ||||||||||||||||||
| 1677 | case QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLTIP: | - | ||||||||||||||||||
| 1678 | result |= QXcbWindowFunctions::Tooltip; | - | ||||||||||||||||||
| 1679 | break; | - | ||||||||||||||||||
| 1680 | case QXcbAtom::_NET_WM_WINDOW_TYPE_NOTIFICATION: | - | ||||||||||||||||||
| 1681 | result |= QXcbWindowFunctions::Notification; | - | ||||||||||||||||||
| 1682 | break; | - | ||||||||||||||||||
| 1683 | case QXcbAtom::_NET_WM_WINDOW_TYPE_COMBO: | - | ||||||||||||||||||
| 1684 | result |= QXcbWindowFunctions::Combo; | - | ||||||||||||||||||
| 1685 | break; | - | ||||||||||||||||||
| 1686 | case QXcbAtom::_NET_WM_WINDOW_TYPE_DND: | - | ||||||||||||||||||
| 1687 | result |= QXcbWindowFunctions::Dnd; | - | ||||||||||||||||||
| 1688 | break; | - | ||||||||||||||||||
| 1689 | case QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE: | - | ||||||||||||||||||
| 1690 | result |= QXcbWindowFunctions::KdeOverride; | - | ||||||||||||||||||
| 1691 | break; | - | ||||||||||||||||||
| 1692 | default: | - | ||||||||||||||||||
| 1693 | break; | - | ||||||||||||||||||
| 1694 | } | - | ||||||||||||||||||
| 1695 | } | - | ||||||||||||||||||
| 1696 | free(reply); | - | ||||||||||||||||||
| 1697 | } | - | ||||||||||||||||||
| 1698 | return result; | - | ||||||||||||||||||
| 1699 | } | - | ||||||||||||||||||
| 1700 | - | |||||||||||||||||||
| 1701 | void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::WindowFlags flags) | - | ||||||||||||||||||
| 1702 | { | - | ||||||||||||||||||
| 1703 | QVector<xcb_atom_t> atoms; | - | ||||||||||||||||||
| 1704 | - | |||||||||||||||||||
| 1705 | - | |||||||||||||||||||
| 1706 | if (types & QXcbWindowFunctions::Normal) | - | ||||||||||||||||||
| 1707 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_NORMAL)); | - | ||||||||||||||||||
| 1708 | if (types & QXcbWindowFunctions::Desktop) | - | ||||||||||||||||||
| 1709 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DESKTOP)); | - | ||||||||||||||||||
| 1710 | if (types & QXcbWindowFunctions::Dock) | - | ||||||||||||||||||
| 1711 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DOCK)); | - | ||||||||||||||||||
| 1712 | if (types & QXcbWindowFunctions::Notification) | - | ||||||||||||||||||
| 1713 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_NOTIFICATION)); | - | ||||||||||||||||||
| 1714 | - | |||||||||||||||||||
| 1715 | - | |||||||||||||||||||
| 1716 | if (types & QXcbWindowFunctions::Utility) | - | ||||||||||||||||||
| 1717 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_UTILITY)); | - | ||||||||||||||||||
| 1718 | if (types & QXcbWindowFunctions::Splash) | - | ||||||||||||||||||
| 1719 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_SPLASH)); | - | ||||||||||||||||||
| 1720 | if (types & QXcbWindowFunctions::Dialog) | - | ||||||||||||||||||
| 1721 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DIALOG)); | - | ||||||||||||||||||
| 1722 | if (types & QXcbWindowFunctions::Tooltip) | - | ||||||||||||||||||
| 1723 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLTIP)); | - | ||||||||||||||||||
| 1724 | if (types & QXcbWindowFunctions::KdeOverride) | - | ||||||||||||||||||
| 1725 | atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE)); | - | ||||||||||||||||||
| 1726 | - | |||||||||||||||||||
| 1727 | - | |||||||||||||||||||
| 1728 | - | |||||||||||||||||||
| 1729 | - | |||||||||||||||||||
| 1730 | if (types & QXcbWindowFunctions::Menu) | - | ||||||||||||||||||
| 1731 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_MENU)); | - | ||||||||||||||||||
| 1732 | if (types & QXcbWindowFunctions::DropDownMenu) | - | ||||||||||||||||||
| 1733 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DROPDOWN_MENU)); | - | ||||||||||||||||||
| 1734 | if (types & QXcbWindowFunctions::PopupMenu) | - | ||||||||||||||||||
| 1735 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_POPUP_MENU)); | - | ||||||||||||||||||
| 1736 | if (types & QXcbWindowFunctions::Toolbar) | - | ||||||||||||||||||
| 1737 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLBAR)); | - | ||||||||||||||||||
| 1738 | if (types & QXcbWindowFunctions::Combo) | - | ||||||||||||||||||
| 1739 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_COMBO)); | - | ||||||||||||||||||
| 1740 | if (types & QXcbWindowFunctions::Dnd) | - | ||||||||||||||||||
| 1741 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DND)); | - | ||||||||||||||||||
| 1742 | - | |||||||||||||||||||
| 1743 | - | |||||||||||||||||||
| 1744 | Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask)); | - | ||||||||||||||||||
| 1745 | switch (type) { | - | ||||||||||||||||||
| 1746 | case Qt::Dialog: | - | ||||||||||||||||||
| 1747 | case Qt::Sheet: | - | ||||||||||||||||||
| 1748 | if (!(types & QXcbWindowFunctions::Dialog)) | - | ||||||||||||||||||
| 1749 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DIALOG)); | - | ||||||||||||||||||
| 1750 | break; | - | ||||||||||||||||||
| 1751 | case Qt::Tool: | - | ||||||||||||||||||
| 1752 | case Qt::Drawer: | - | ||||||||||||||||||
| 1753 | if (!(types & QXcbWindowFunctions::Utility)) | - | ||||||||||||||||||
| 1754 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_UTILITY)); | - | ||||||||||||||||||
| 1755 | break; | - | ||||||||||||||||||
| 1756 | case Qt::ToolTip: | - | ||||||||||||||||||
| 1757 | if (!(types & QXcbWindowFunctions::Tooltip)) | - | ||||||||||||||||||
| 1758 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLTIP)); | - | ||||||||||||||||||
| 1759 | break; | - | ||||||||||||||||||
| 1760 | case Qt::SplashScreen: | - | ||||||||||||||||||
| 1761 | if (!(types & QXcbWindowFunctions::Splash)) | - | ||||||||||||||||||
| 1762 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_SPLASH)); | - | ||||||||||||||||||
| 1763 | break; | - | ||||||||||||||||||
| 1764 | default: | - | ||||||||||||||||||
| 1765 | break; | - | ||||||||||||||||||
| 1766 | } | - | ||||||||||||||||||
| 1767 | - | |||||||||||||||||||
| 1768 | if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) { | - | ||||||||||||||||||
| 1769 | - | |||||||||||||||||||
| 1770 | atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE)); | - | ||||||||||||||||||
| 1771 | } | - | ||||||||||||||||||
| 1772 | - | |||||||||||||||||||
| 1773 | if (atoms.size() == 1 && atoms.first() == atom(QXcbAtom::_NET_WM_WINDOW_TYPE_NORMAL)) | - | ||||||||||||||||||
| 1774 | atoms.clear(); | - | ||||||||||||||||||
| 1775 | else | - | ||||||||||||||||||
| 1776 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_NORMAL)); | - | ||||||||||||||||||
| 1777 | - | |||||||||||||||||||
| 1778 | if (atoms.isEmpty()) { | - | ||||||||||||||||||
| 1779 | xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_WINDOW_TYPE)); | - | ||||||||||||||||||
| 1780 | } else { | - | ||||||||||||||||||
| 1781 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_WINDOW_TYPE), XCB_ATOM_ATOM, 32, atoms.count(), atoms.constData()) | - | ||||||||||||||||||
| 1782 | - | |||||||||||||||||||
| 1783 | ; | - | ||||||||||||||||||
| 1784 | } | - | ||||||||||||||||||
| 1785 | xcb_flush(xcb_connection()); | - | ||||||||||||||||||
| 1786 | } | - | ||||||||||||||||||
| 1787 | - | |||||||||||||||||||
| 1788 | void QXcbWindow::setWmWindowRole(const QByteArray &role) | - | ||||||||||||||||||
| 1789 | { | - | ||||||||||||||||||
| 1790 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::WM_WINDOW_ROLE), XCB_ATOM_STRING, 8, role.size(), role.constData()) | - | ||||||||||||||||||
| 1791 | - | |||||||||||||||||||
| 1792 | ; | - | ||||||||||||||||||
| 1793 | } | - | ||||||||||||||||||
| 1794 | - | |||||||||||||||||||
| 1795 | void QXcbWindow::setParentRelativeBackPixmapStatic(QWindow *window) | - | ||||||||||||||||||
| 1796 | { | - | ||||||||||||||||||
| 1797 | if (window->handle()) | - | ||||||||||||||||||
| 1798 | static_cast<QXcbWindow *>(window->handle())->setParentRelativeBackPixmap(); | - | ||||||||||||||||||
| 1799 | } | - | ||||||||||||||||||
| 1800 | - | |||||||||||||||||||
| 1801 | void QXcbWindow::setParentRelativeBackPixmap() | - | ||||||||||||||||||
| 1802 | { | - | ||||||||||||||||||
| 1803 | const quint32 mask = XCB_CW_BACK_PIXMAP; | - | ||||||||||||||||||
| 1804 | const quint32 values[] = { XCB_BACK_PIXMAP_PARENT_RELATIVE }; | - | ||||||||||||||||||
| 1805 | xcb_change_window_attributes(xcb_connection(), m_window, mask, values); | - | ||||||||||||||||||
| 1806 | } | - | ||||||||||||||||||
| 1807 | - | |||||||||||||||||||
| 1808 | bool QXcbWindow::requestSystemTrayWindowDockStatic(const QWindow *window) | - | ||||||||||||||||||
| 1809 | { | - | ||||||||||||||||||
| 1810 | if (window->handle()) | - | ||||||||||||||||||
| 1811 | return static_cast<QXcbWindow *>(window->handle())->requestSystemTrayWindowDock(); | - | ||||||||||||||||||
| 1812 | return false; | - | ||||||||||||||||||
| 1813 | } | - | ||||||||||||||||||
| 1814 | - | |||||||||||||||||||
| 1815 | bool QXcbWindow::requestSystemTrayWindowDock() const | - | ||||||||||||||||||
| 1816 | { | - | ||||||||||||||||||
| 1817 | if (!connection()->systemTrayTracker()) | - | ||||||||||||||||||
| 1818 | return false; | - | ||||||||||||||||||
| 1819 | connection()->systemTrayTracker()->requestSystemTrayWindowDock(m_window); | - | ||||||||||||||||||
| 1820 | return true; | - | ||||||||||||||||||
| 1821 | } | - | ||||||||||||||||||
| 1822 | - | |||||||||||||||||||
| 1823 | QRect QXcbWindow::systemTrayWindowGlobalGeometryStatic(const QWindow *window) | - | ||||||||||||||||||
| 1824 | { | - | ||||||||||||||||||
| 1825 | if (window->handle()) | - | ||||||||||||||||||
| 1826 | return static_cast<QXcbWindow *>(window->handle())->systemTrayWindowGlobalGeometry(); | - | ||||||||||||||||||
| 1827 | return QRect(); | - | ||||||||||||||||||
| 1828 | } | - | ||||||||||||||||||
| 1829 | - | |||||||||||||||||||
| 1830 | QRect QXcbWindow::systemTrayWindowGlobalGeometry() const | - | ||||||||||||||||||
| 1831 | { | - | ||||||||||||||||||
| 1832 | if (!connection()->systemTrayTracker()) | - | ||||||||||||||||||
| 1833 | return QRect(); | - | ||||||||||||||||||
| 1834 | return connection()->systemTrayTracker()->systemTrayWindowGlobalGeometry(m_window); | - | ||||||||||||||||||
| 1835 | } | - | ||||||||||||||||||
| 1836 | - | |||||||||||||||||||
| 1837 | class ExposeCompressor | - | ||||||||||||||||||
| 1838 | { | - | ||||||||||||||||||
| 1839 | public: | - | ||||||||||||||||||
| 1840 | ExposeCompressor(xcb_window_t window, QRegion *region) | - | ||||||||||||||||||
| 1841 | : m_window(window) | - | ||||||||||||||||||
| 1842 | , m_region(region) | - | ||||||||||||||||||
| 1843 | , m_pending(true) | - | ||||||||||||||||||
| 1844 | { | - | ||||||||||||||||||
| 1845 | } | - | ||||||||||||||||||
| 1846 | - | |||||||||||||||||||
| 1847 | bool checkEvent(xcb_generic_event_t *event) | - | ||||||||||||||||||
| 1848 | { | - | ||||||||||||||||||
| 1849 | if (!event) | - | ||||||||||||||||||
| 1850 | return false; | - | ||||||||||||||||||
| 1851 | if ((event->response_type & ~0x80) != 12) | - | ||||||||||||||||||
| 1852 | return false; | - | ||||||||||||||||||
| 1853 | xcb_expose_event_t *expose = (xcb_expose_event_t *)event; | - | ||||||||||||||||||
| 1854 | if (expose->window != m_window) | - | ||||||||||||||||||
| 1855 | return false; | - | ||||||||||||||||||
| 1856 | if (expose->count == 0) | - | ||||||||||||||||||
| 1857 | m_pending = false; | - | ||||||||||||||||||
| 1858 | *m_region |= QRect(expose->x, expose->y, expose->width, expose->height); | - | ||||||||||||||||||
| 1859 | return true; | - | ||||||||||||||||||
| 1860 | } | - | ||||||||||||||||||
| 1861 | - | |||||||||||||||||||
| 1862 | bool pending() const | - | ||||||||||||||||||
| 1863 | { | - | ||||||||||||||||||
| 1864 | return m_pending; | - | ||||||||||||||||||
| 1865 | } | - | ||||||||||||||||||
| 1866 | - | |||||||||||||||||||
| 1867 | private: | - | ||||||||||||||||||
| 1868 | xcb_window_t m_window; | - | ||||||||||||||||||
| 1869 | QRegion *m_region; | - | ||||||||||||||||||
| 1870 | bool m_pending; | - | ||||||||||||||||||
| 1871 | }; | - | ||||||||||||||||||
| 1872 | - | |||||||||||||||||||
| 1873 | bool QXcbWindow::compressExposeEvent(QRegion &exposeRegion) | - | ||||||||||||||||||
| 1874 | { | - | ||||||||||||||||||
| 1875 | ExposeCompressor compressor(m_window, &exposeRegion); | - | ||||||||||||||||||
| 1876 | xcb_generic_event_t *filter = 0; | - | ||||||||||||||||||
| 1877 | do { | - | ||||||||||||||||||
| 1878 | filter = connection()->checkEvent(compressor); | - | ||||||||||||||||||
| 1879 | free(filter); | - | ||||||||||||||||||
| 1880 | } while (filter); | - | ||||||||||||||||||
| 1881 | return compressor.pending(); | - | ||||||||||||||||||
| 1882 | } | - | ||||||||||||||||||
| 1883 | - | |||||||||||||||||||
| 1884 | bool QXcbWindow::handleGenericEvent(xcb_generic_event_t *event, long *result) | - | ||||||||||||||||||
| 1885 | { | - | ||||||||||||||||||
| 1886 | return QWindowSystemInterface::handleNativeEvent(window(), | - | ||||||||||||||||||
| 1887 | connection()->nativeInterface()->genericEventFilterType(), | - | ||||||||||||||||||
| 1888 | event, | - | ||||||||||||||||||
| 1889 | result); | - | ||||||||||||||||||
| 1890 | } | - | ||||||||||||||||||
| 1891 | - | |||||||||||||||||||
| 1892 | void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event) | - | ||||||||||||||||||
| 1893 | { | - | ||||||||||||||||||
| 1894 | QRect rect(event->x, event->y, event->width, event->height); | - | ||||||||||||||||||
| 1895 | - | |||||||||||||||||||
| 1896 | if (m_exposeRegion.isEmpty()) | - | ||||||||||||||||||
| 1897 | m_exposeRegion = rect; | - | ||||||||||||||||||
| 1898 | else | - | ||||||||||||||||||
| 1899 | m_exposeRegion |= rect; | - | ||||||||||||||||||
| 1900 | - | |||||||||||||||||||
| 1901 | bool pending = compressExposeEvent(m_exposeRegion); | - | ||||||||||||||||||
| 1902 | - | |||||||||||||||||||
| 1903 | - | |||||||||||||||||||
| 1904 | if (event->count == 0 || !pending) { | - | ||||||||||||||||||
| 1905 | QWindowSystemInterface::handleExposeEvent(window(), m_exposeRegion); | - | ||||||||||||||||||
| 1906 | m_exposeRegion = QRegion(); | - | ||||||||||||||||||
| 1907 | } | - | ||||||||||||||||||
| 1908 | } | - | ||||||||||||||||||
| 1909 | - | |||||||||||||||||||
| 1910 | void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *event) | - | ||||||||||||||||||
| 1911 | { | - | ||||||||||||||||||
| 1912 | if (event->format != 32) | - | ||||||||||||||||||
| 1913 | return; | - | ||||||||||||||||||
| 1914 | - | |||||||||||||||||||
| 1915 | if (event->type == atom(QXcbAtom::WM_PROTOCOLS)) { | - | ||||||||||||||||||
| 1916 | if (event->data.data32[0] == atom(QXcbAtom::WM_DELETE_WINDOW)) { | - | ||||||||||||||||||
| 1917 | QWindowSystemInterface::handleCloseEvent(window()); | - | ||||||||||||||||||
| 1918 | } else if (event->data.data32[0] == atom(QXcbAtom::WM_TAKE_FOCUS)) { | - | ||||||||||||||||||
| 1919 | connection()->setTime(event->data.data32[1]); | - | ||||||||||||||||||
| 1920 | relayFocusToModalWindow(); | - | ||||||||||||||||||
| 1921 | return; | - | ||||||||||||||||||
| 1922 | } else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_PING)) { | - | ||||||||||||||||||
| 1923 | if (event->window == xcbScreen()->root()) | - | ||||||||||||||||||
| 1924 | return; | - | ||||||||||||||||||
| 1925 | - | |||||||||||||||||||
| 1926 | xcb_client_message_event_t reply = *event; | - | ||||||||||||||||||
| 1927 | - | |||||||||||||||||||
| 1928 | reply.response_type = 33; | - | ||||||||||||||||||
| 1929 | reply.window = xcbScreen()->root(); | - | ||||||||||||||||||
| 1930 | - | |||||||||||||||||||
| 1931 | xcb_send_event(xcb_connection(), 0, xcbScreen()->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&reply); | - | ||||||||||||||||||
| 1932 | xcb_flush(xcb_connection()); | - | ||||||||||||||||||
| 1933 | } else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_SYNC_REQUEST)) { | - | ||||||||||||||||||
| 1934 | connection()->setTime(event->data.data32[1]); | - | ||||||||||||||||||
| 1935 | m_syncValue.lo = event->data.data32[2]; | - | ||||||||||||||||||
| 1936 | m_syncValue.hi = event->data.data32[3]; | - | ||||||||||||||||||
| 1937 | if (m_usingSyncProtocol) | - | ||||||||||||||||||
| 1938 | m_syncState = SyncReceived; | - | ||||||||||||||||||
| 1939 | - | |||||||||||||||||||
| 1940 | } else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_CONTEXT_HELP)) { | - | ||||||||||||||||||
| 1941 | QWindowSystemInterface::handleEnterWhatsThisEvent(); | - | ||||||||||||||||||
| 1942 | - | |||||||||||||||||||
| 1943 | } else { | - | ||||||||||||||||||
| 1944 | QMessageLogger(__FILE__, 20762063, __PRETTY_FUNCTION__).warning() << "QXcbWindow: Unhandled WM_PROTOCOLS message:" << connection()->atomName(event->data.data32[0]); | - | ||||||||||||||||||
| 1945 | } | - | ||||||||||||||||||
| 1946 | - | |||||||||||||||||||
| 1947 | } else if (event->type == atom(QXcbAtom::XdndEnter)) { | - | ||||||||||||||||||
| 1948 | connection()->drag()->handleEnter(this, event); | - | ||||||||||||||||||
| 1949 | } else if (event->type == atom(QXcbAtom::XdndPosition)) { | - | ||||||||||||||||||
| 1950 | connection()->drag()->handlePosition(this, event); | - | ||||||||||||||||||
| 1951 | } else if (event->type == atom(QXcbAtom::XdndLeave)) { | - | ||||||||||||||||||
| 1952 | connection()->drag()->handleLeave(this, event); | - | ||||||||||||||||||
| 1953 | } else if (event->type == atom(QXcbAtom::XdndDrop)) { | - | ||||||||||||||||||
| 1954 | connection()->drag()->handleDrop(this, event); | - | ||||||||||||||||||
| 1955 | - | |||||||||||||||||||
| 1956 | } else if (event->type == atom(QXcbAtom::_XEMBED)) { | - | ||||||||||||||||||
| 1957 | handleXEmbedMessage(event); | - | ||||||||||||||||||
| 1958 | } else if (event->type == atom(QXcbAtom::_NET_ACTIVE_WINDOW)) { | - | ||||||||||||||||||
| 1959 | doFocusIn(); | - | ||||||||||||||||||
| 1960 | } else if (event->type == atom(QXcbAtom::MANAGER) | - | ||||||||||||||||||
| 1961 | || event->type == atom(QXcbAtom::_NET_WM_STATE) | - | ||||||||||||||||||
| 1962 | || event->type == atom(QXcbAtom::WM_CHANGE_STATE)) { | - | ||||||||||||||||||
| 1963 | - | |||||||||||||||||||
| 1964 | - | |||||||||||||||||||
| 1965 | } else if (event->type == atom(QXcbAtom::_COMPIZ_DECOR_PENDING) | - | ||||||||||||||||||
| 1966 | || event->type == atom(QXcbAtom::_COMPIZ_DECOR_REQUEST) | - | ||||||||||||||||||
| 1967 | || event->type == atom(QXcbAtom::_COMPIZ_DECOR_DELETE_PIXMAP) | - | ||||||||||||||||||
| 1968 | || event->type == atom(QXcbAtom::_COMPIZ_TOOLKIT_ACTION) | - | ||||||||||||||||||
| 1969 | || event->type == atom(QXcbAtom::_GTK_LOAD_ICONTHEMES)) { | - | ||||||||||||||||||
| 1970 | - | |||||||||||||||||||
| 1971 | } else { | - | ||||||||||||||||||
| 1972 | QMessageLogger(__FILE__, 21042091, __PRETTY_FUNCTION__).warning() << "QXcbWindow: Unhandled client message:" << connection()->atomName(event->type); | - | ||||||||||||||||||
| 1973 | } | - | ||||||||||||||||||
| 1974 | } | - | ||||||||||||||||||
| 1975 | - | |||||||||||||||||||
| 1976 | void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event) | - | ||||||||||||||||||
| 1977 | { | - | ||||||||||||||||||
| 1978 | bool fromSendEvent = (event->response_type & 0x80); | - | ||||||||||||||||||
| 1979 | QPoint pos(event->x, event->y); | - | ||||||||||||||||||
| 1980 |     if (!parent()
 
  | 23-5733 | ||||||||||||||||||
| 1981 | - | |||||||||||||||||||
| 1982 | xcb_translate_coordinates_cookie_t cookie = xcb_translate_coordinates(xcb_connection(), xcb_window(), | - | ||||||||||||||||||
| 1983 | xcbScreen()->root(), 0, 0); | - | ||||||||||||||||||
| 1984 | xcb_translate_coordinates_reply_t *reply = xcb_translate_coordinates_reply(xcb_connection(), cookie, __null); | - | ||||||||||||||||||
| 1985 |         if (reply
  | 0-3467 | ||||||||||||||||||
| 1986 | pos.setX(reply->dst_x); | - | ||||||||||||||||||
| 1987 | pos.setY(reply->dst_y); | - | ||||||||||||||||||
| 1988 | free(reply); | - | ||||||||||||||||||
| 1989 |         } executed 3467 times by 109 tests:  end of blockExecuted by: 
  | 3467 | ||||||||||||||||||
| 1990 |     } executed 3467 times by 109 tests:  end of blockExecuted by: 
  | 3467 | ||||||||||||||||||
| 1991 | - | |||||||||||||||||||
| 1992 | const QRect actualGeometry = QRect(pos, QSize(event->width, event->height)); | - | ||||||||||||||||||
| 1993 |     QPlatformScreen *newScreen = parent()
  | 23-5733 | ||||||||||||||||||
| 1994 |     if (!newScreen
  | 0-5756 | ||||||||||||||||||
| 1995 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 1996 | - | |||||||||||||||||||
| 1997 | - | |||||||||||||||||||
| 1998 | - | |||||||||||||||||||
| 1999 | QPlatformWindow::setGeometry(actualGeometry); | - | ||||||||||||||||||
| 2000 | - | |||||||||||||||||||
| 2001 | - | |||||||||||||||||||
| 2002 | - | |||||||||||||||||||
| 2003 | - | |||||||||||||||||||
| 2004 | - | |||||||||||||||||||
| 2005 | QWindowSystemInterface::handleGeometryChange(window(), actualGeometry); | - | ||||||||||||||||||
| 2006 | - | |||||||||||||||||||
| 2007 | - | |||||||||||||||||||
| 2008 | - | |||||||||||||||||||
| 2009 | - | |||||||||||||||||||
| 2010 | QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen()); | - | ||||||||||||||||||
| 2011 | - | |||||||||||||||||||
| 2012 | - | |||||||||||||||||||
| 2013 | - | |||||||||||||||||||
| 2014 |     if (!m_oldWindowSize.isEmpty()
  | 2394-3362 | ||||||||||||||||||
| 2015 |             && (actualGeometry.width() < m_oldWindowSize.width()
  | 97-3265 | ||||||||||||||||||
| 2016 |                 || actualGeometry.height() < m_oldWindowSize.height()
  | 12-3253 | ||||||||||||||||||
| 2017 | QWindowSystemInterface::handleExposeEvent(window(), QRegion(0, 0, actualGeometry.width(), actualGeometry.height())); | - | ||||||||||||||||||
| 2018 |     } executed 109 times by 11 tests:  end of blockExecuted by: 
  | 109 | ||||||||||||||||||
| 2019 | m_oldWindowSize = actualGeometry.size(); | - | ||||||||||||||||||
| 2020 | - | |||||||||||||||||||
| 2021 |     if (m_usingSyncProtocol
 
  | 0-5756 | ||||||||||||||||||
| 2022 |         m_syncState = SyncAndConfigureReceived; never executed:  m_syncState = SyncAndConfigureReceived; | 0 | ||||||||||||||||||
| 2023 | - | |||||||||||||||||||
| 2024 | m_dirtyFrameMargins = true; | - | ||||||||||||||||||
| 2025 | } executed 5756 times by 109 tests:  end of blockExecuted by: 
  | 5756 | ||||||||||||||||||
| 2026 | - | |||||||||||||||||||
| 2027 | bool QXcbWindow::isExposed() const | - | ||||||||||||||||||
| 2028 | { | - | ||||||||||||||||||
| 2029 | return m_mapped; | - | ||||||||||||||||||
| 2030 | } | - | ||||||||||||||||||
| 2031 | - | |||||||||||||||||||
| 2032 | bool QXcbWindow::isEmbedded(const QPlatformWindow *parentWindow) const | - | ||||||||||||||||||
| 2033 | { | - | ||||||||||||||||||
| 2034 | if (!m_embedded) | - | ||||||||||||||||||
| 2035 | return false; | - | ||||||||||||||||||
| 2036 | - | |||||||||||||||||||
| 2037 | return parentWindow ? (parentWindow == parent()) : true; | - | ||||||||||||||||||
| 2038 | } | - | ||||||||||||||||||
| 2039 | - | |||||||||||||||||||
| 2040 | QPoint QXcbWindow::mapToGlobal(const QPoint &pos) const | - | ||||||||||||||||||
| 2041 | { | - | ||||||||||||||||||
| 2042 | if (!m_embedded) | - | ||||||||||||||||||
| 2043 | return pos; | - | ||||||||||||||||||
| 2044 | - | |||||||||||||||||||
| 2045 | QPoint ret; | - | ||||||||||||||||||
| 2046 | xcb_translate_coordinates_cookie_t cookie = | - | ||||||||||||||||||
| 2047 | xcb_translate_coordinates(xcb_connection(), xcb_window(), xcbScreen()->root(), | - | ||||||||||||||||||
| 2048 | pos.x(), pos.y()); | - | ||||||||||||||||||
| 2049 | xcb_translate_coordinates_reply_t *reply = | - | ||||||||||||||||||
| 2050 | xcb_translate_coordinates_reply(xcb_connection(), cookie, __null); | - | ||||||||||||||||||
| 2051 | if (reply) { | - | ||||||||||||||||||
| 2052 | ret.setX(reply->dst_x); | - | ||||||||||||||||||
| 2053 | ret.setY(reply->dst_y); | - | ||||||||||||||||||
| 2054 | free(reply); | - | ||||||||||||||||||
| 2055 | } | - | ||||||||||||||||||
| 2056 | - | |||||||||||||||||||
| 2057 | return ret; | - | ||||||||||||||||||
| 2058 | } | - | ||||||||||||||||||
| 2059 | - | |||||||||||||||||||
| 2060 | QPoint QXcbWindow::mapFromGlobal(const QPoint &pos) const | - | ||||||||||||||||||
| 2061 | { | - | ||||||||||||||||||
| 2062 | if (!m_embedded) | - | ||||||||||||||||||
| 2063 | return pos; | - | ||||||||||||||||||
| 2064 | - | |||||||||||||||||||
| 2065 | QPoint ret; | - | ||||||||||||||||||
| 2066 | xcb_translate_coordinates_cookie_t cookie = | - | ||||||||||||||||||
| 2067 | xcb_translate_coordinates(xcb_connection(), xcbScreen()->root(), xcb_window(), | - | ||||||||||||||||||
| 2068 | pos.x(), pos.y()); | - | ||||||||||||||||||
| 2069 | xcb_translate_coordinates_reply_t *reply = | - | ||||||||||||||||||
| 2070 | xcb_translate_coordinates_reply(xcb_connection(), cookie, __null); | - | ||||||||||||||||||
| 2071 | if (reply) { | - | ||||||||||||||||||
| 2072 | ret.setX(reply->dst_x); | - | ||||||||||||||||||
| 2073 | ret.setY(reply->dst_y); | - | ||||||||||||||||||
| 2074 | free(reply); | - | ||||||||||||||||||
| 2075 | } | - | ||||||||||||||||||
| 2076 | - | |||||||||||||||||||
| 2077 | return ret; | - | ||||||||||||||||||
| 2078 | } | - | ||||||||||||||||||
| 2079 | - | |||||||||||||||||||
| 2080 | void QXcbWindow::handleMapNotifyEvent(const xcb_map_notify_event_t *event) | - | ||||||||||||||||||
| 2081 | { | - | ||||||||||||||||||
| 2082 |     if (event->window == m_window
  | 0-2478 | ||||||||||||||||||
| 2083 | m_mapped = true; | - | ||||||||||||||||||
| 2084 |         if (m_deferredActivation
  | 388-2090 | ||||||||||||||||||
| 2085 |             requestActivateWindow(); executed 388 times by 53 tests:  requestActivateWindow();Executed by: 
  | 388 | ||||||||||||||||||
| 2086 | - | |||||||||||||||||||
| 2087 | QRegion exposeRegion =QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size()); | - | ||||||||||||||||||
| compressExposeEvent(exposeRegion); | ||||||||||||||||||||
| QWindowSystemInterface::handleExposeEvent(window(), exposeRegion);())); | ||||||||||||||||||||
| 2088 |     } executed 2478 times by 104 tests:  end of blockExecuted by: 
  | 2478 | ||||||||||||||||||
| 2089 | } executed 2478 times by 104 tests:  end of blockExecuted by: 
  | 2478 | ||||||||||||||||||
| 2090 | - | |||||||||||||||||||
| 2091 | void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event) | - | ||||||||||||||||||
| 2092 | { | - | ||||||||||||||||||
| 2093 | if (event->window == m_window) { | - | ||||||||||||||||||
| 2094 | m_mapped = false; | - | ||||||||||||||||||
| 2095 | QWindowSystemInterface::handleExposeEvent(window(), QRegion()); | - | ||||||||||||||||||
| 2096 | } | - | ||||||||||||||||||
| 2097 | } | - | ||||||||||||||||||
| 2098 | - | |||||||||||||||||||
| 2099 | void QXcbWindow::handleButtonPressEvent(int event_x, int event_y, int root_x, int root_y, | - | ||||||||||||||||||
| 2100 | int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source) | - | ||||||||||||||||||
| 2101 | { | - | ||||||||||||||||||
| 2102 | const bool isWheel = detail >= 4 && detail <= 7; | - | ||||||||||||||||||
| 2103 | if (!isWheel && window() != QGuiApplication::focusWindow()) { | - | ||||||||||||||||||
| 2104 | QWindow *w = static_cast<QWindowPrivate *>(QObjectPrivate::get(window()))->eventReceiver(); | - | ||||||||||||||||||
| 2105 | if (!(w->flags() & (Qt::WindowDoesNotAcceptFocus | Qt::BypassWindowManagerHint)) | - | ||||||||||||||||||
| 2106 | && w->type() != Qt::ToolTip | - | ||||||||||||||||||
| 2107 | && w->type() != Qt::Popup) { | - | ||||||||||||||||||
| 2108 | w->requestActivate(); | - | ||||||||||||||||||
| 2109 | } | - | ||||||||||||||||||
| 2110 | } | - | ||||||||||||||||||
| 2111 | - | |||||||||||||||||||
| 2112 | updateNetWmUserTime(timestamp); | - | ||||||||||||||||||
| 2113 | - | |||||||||||||||||||
| 2114 | if (m_embedded) { | - | ||||||||||||||||||
| 2115 | if (window() != QGuiApplication::focusWindow()) { | - | ||||||||||||||||||
| 2116 | const QXcbWindow *container = static_cast<const QXcbWindow *>(parent()); | - | ||||||||||||||||||
| 2117 | ((!(container != 0)) ? qt_assert("container != 0",__FILE__,22422236) : qt_noop()); | - | ||||||||||||||||||
| 2118 | - | |||||||||||||||||||
| 2119 | sendXEmbedMessage(container->xcb_window(), XEMBED_REQUEST_FOCUS); | - | ||||||||||||||||||
| 2120 | } | - | ||||||||||||||||||
| 2121 | } | - | ||||||||||||||||||
| 2122 | QPoint local(event_x, event_y); | - | ||||||||||||||||||
| 2123 | QPoint global(root_x, root_y); | - | ||||||||||||||||||
| 2124 | - | |||||||||||||||||||
| 2125 | if (isWheel) { | - | ||||||||||||||||||
| 2126 | if (!connection()->isAtLeastXI21()) { | - | ||||||||||||||||||
| 2127 | - | |||||||||||||||||||
| 2128 | int delta = 120 * ((detail == 4 || detail == 6) ? 1 : -1); | - | ||||||||||||||||||
| 2129 | bool hor = (((detail == 4 || detail == 5) | - | ||||||||||||||||||
| 2130 | && (modifiers & Qt::AltModifier)) | - | ||||||||||||||||||
| 2131 | || (detail == 6 || detail == 7)); | - | ||||||||||||||||||
| 2132 | - | |||||||||||||||||||
| 2133 | QWindowSystemInterface::handleWheelEvent(window(), timestamp, | - | ||||||||||||||||||
| 2134 | local, global, delta, hor ? Qt::Horizontal : Qt::Vertical, modifiers); | - | ||||||||||||||||||
| 2135 | } | - | ||||||||||||||||||
| 2136 | return; | - | ||||||||||||||||||
| 2137 | } | - | ||||||||||||||||||
| 2138 | - | |||||||||||||||||||
| 2139 | connection()->setMousePressWindow(this); | - | ||||||||||||||||||
| 2140 | - | |||||||||||||||||||
| 2141 | handleMouseEvent(timestamp, local, global, modifiers, source); | - | ||||||||||||||||||
| 2142 | } | - | ||||||||||||||||||
| 2143 | - | |||||||||||||||||||
| 2144 | void QXcbWindow::handleButtonReleaseEvent(int event_x, int event_y, int root_x, int root_y, | - | ||||||||||||||||||
| 2145 | int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source) | - | ||||||||||||||||||
| 2146 | { | - | ||||||||||||||||||
| 2147 | QPoint local(event_x, event_y); | - | ||||||||||||||||||
| 2148 | QPoint global(root_x, root_y); | - | ||||||||||||||||||
| 2149 | - | |||||||||||||||||||
| 2150 | if (detail >= 4 && detail <= 7) { | - | ||||||||||||||||||
| 2151 | - | |||||||||||||||||||
| 2152 | return; | - | ||||||||||||||||||
| 2153 | } | - | ||||||||||||||||||
| 2154 | - | |||||||||||||||||||
| 2155 | if (connection()->buttons() == Qt::NoButton) | - | ||||||||||||||||||
| 2156 | connection()->setMousePressWindow(nullptr); | - | ||||||||||||||||||
| 2157 | - | |||||||||||||||||||
| 2158 | handleMouseEvent(timestamp, local, global, modifiers, source); | - | ||||||||||||||||||
| 2159 | } | - | ||||||||||||||||||
| 2160 | - | |||||||||||||||||||
| 2161 | static inline bool doCheckUnGrabAncestor(QXcbConnection *conn) | - | ||||||||||||||||||
| 2162 | { | - | ||||||||||||||||||
| 2163 | - | |||||||||||||||||||
| 2164 | - | |||||||||||||||||||
| 2165 | - | |||||||||||||||||||
| 2166 | - | |||||||||||||||||||
| 2167 | - | |||||||||||||||||||
| 2168 | - | |||||||||||||||||||
| 2169 | if (conn) { | - | ||||||||||||||||||
| 2170 | const bool mouseButtonsPressed = (conn->buttons() != Qt::NoButton); | - | ||||||||||||||||||
| 2171 | - | |||||||||||||||||||
| 2172 | return mouseButtonsPressed || (conn->isAtLeastXI22() && conn->xi2MouseEvents()); | - | ||||||||||||||||||
| 2173 | - | |||||||||||||||||||
| 2174 | - | |||||||||||||||||||
| 2175 | - | |||||||||||||||||||
| 2176 | } | - | ||||||||||||||||||
| 2177 | return true; | - | ||||||||||||||||||
| 2178 | } | - | ||||||||||||||||||
| 2179 | - | |||||||||||||||||||
| 2180 | static bool ignoreLeaveEvent(quint8 mode, quint8 detail, QXcbConnection *conn = nullptr) | - | ||||||||||||||||||
| 2181 | { | - | ||||||||||||||||||
| 2182 | return ((doCheckUnGrabAncestor(conn) | - | ||||||||||||||||||
| 2183 | && mode == XCB_NOTIFY_MODE_GRAB && detail == XCB_NOTIFY_DETAIL_ANCESTOR) | - | ||||||||||||||||||
| 2184 | || (mode == XCB_NOTIFY_MODE_UNGRAB && detail == XCB_NOTIFY_DETAIL_INFERIOR) | - | ||||||||||||||||||
| 2185 | || detail == XCB_NOTIFY_DETAIL_VIRTUAL | - | ||||||||||||||||||
| 2186 | || detail == XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL); | - | ||||||||||||||||||
| 2187 | } | - | ||||||||||||||||||
| 2188 | - | |||||||||||||||||||
| 2189 | static bool ignoreEnterEvent(quint8 mode, quint8 detail, QXcbConnection *conn = nullptr) | - | ||||||||||||||||||
| 2190 | { | - | ||||||||||||||||||
| 2191 | return ((doCheckUnGrabAncestor(conn) | - | ||||||||||||||||||
| 2192 | && mode == XCB_NOTIFY_MODE_UNGRAB && detail == XCB_NOTIFY_DETAIL_ANCESTOR) | - | ||||||||||||||||||
| 2193 | || (mode != XCB_NOTIFY_MODE_NORMAL && mode != XCB_NOTIFY_MODE_UNGRAB) | - | ||||||||||||||||||
| 2194 | || detail == XCB_NOTIFY_DETAIL_VIRTUAL | - | ||||||||||||||||||
| 2195 | || detail == XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL); | - | ||||||||||||||||||
| 2196 | } | - | ||||||||||||||||||
| 2197 | - | |||||||||||||||||||
| 2198 | class EnterEventChecker | - | ||||||||||||||||||
| 2199 | { | - | ||||||||||||||||||
| 2200 | public: | - | ||||||||||||||||||
| 2201 | bool checkEvent(xcb_generic_event_t *event) | - | ||||||||||||||||||
| 2202 | { | - | ||||||||||||||||||
| 2203 | if (!event) | - | ||||||||||||||||||
| 2204 | return false; | - | ||||||||||||||||||
| 2205 | if ((event->response_type & ~0x80) != 7) | - | ||||||||||||||||||
| 2206 | return false; | - | ||||||||||||||||||
| 2207 | - | |||||||||||||||||||
| 2208 | xcb_enter_notify_event_t *enter = (xcb_enter_notify_event_t *)event; | - | ||||||||||||||||||
| 2209 | if (ignoreEnterEvent(enter->mode, enter->detail)) | - | ||||||||||||||||||
| 2210 | return false; | - | ||||||||||||||||||
| 2211 | - | |||||||||||||||||||
| 2212 | return true; | - | ||||||||||||||||||
| 2213 | } | - | ||||||||||||||||||
| 2214 | }; | - | ||||||||||||||||||
| 2215 | - | |||||||||||||||||||
| 2216 | void QXcbWindow::handleEnterNotifyEvent(int event_x, int event_y, int root_x, int root_y, | - | ||||||||||||||||||
| 2217 | quint8 mode, quint8 detail, xcb_timestamp_t timestamp) | - | ||||||||||||||||||
| 2218 | { | - | ||||||||||||||||||
| 2219 | connection()->setTime(timestamp); | - | ||||||||||||||||||
| 2220 | - | |||||||||||||||||||
| 2221 | connection()->handleEnterEvent(); | - | ||||||||||||||||||
| 2222 | - | |||||||||||||||||||
| 2223 | - | |||||||||||||||||||
| 2224 | const QPoint global = QPoint(root_x, root_y); | - | ||||||||||||||||||
| 2225 | - | |||||||||||||||||||
| 2226 | if (ignoreEnterEvent(mode, detail, connection()) || connection()->mousePressWindow()) | - | ||||||||||||||||||
| 2227 | return; | - | ||||||||||||||||||
| 2228 | - | |||||||||||||||||||
| 2229 | const QPoint local(event_x, event_y); | - | ||||||||||||||||||
| 2230 | QWindowSystemInterface::handleEnterEvent(window(), local, global); | - | ||||||||||||||||||
| 2231 | } | - | ||||||||||||||||||
| 2232 | - | |||||||||||||||||||
| 2233 | void QXcbWindow::handleLeaveNotifyEvent(int root_x, int root_y, | - | ||||||||||||||||||
| 2234 | quint8 mode, quint8 detail, xcb_timestamp_t timestamp) | - | ||||||||||||||||||
| 2235 | { | - | ||||||||||||||||||
| 2236 | connection()->setTime(timestamp); | - | ||||||||||||||||||
| 2237 | - | |||||||||||||||||||
| 2238 | if (ignoreLeaveEvent(mode, detail, connection()) || connection()->mousePressWindow()) | - | ||||||||||||||||||
| 2239 | return; | - | ||||||||||||||||||
| 2240 | - | |||||||||||||||||||
| 2241 | EnterEventChecker checker; | - | ||||||||||||||||||
| 2242 | xcb_enter_notify_event_t *enter = (xcb_enter_notify_event_t *)connection()->checkEvent(checker); | - | ||||||||||||||||||
| 2243 | QXcbWindow *enterWindow = enter ? connection()->platformWindowFromId(enter->event) : 0; | - | ||||||||||||||||||
| 2244 | - | |||||||||||||||||||
| 2245 | if (enterWindow) { | - | ||||||||||||||||||
| 2246 | QPoint local(enter->event_x, enter->event_y); | - | ||||||||||||||||||
| 2247 | QPoint global = QPoint(root_x, root_y); | - | ||||||||||||||||||
| 2248 | QWindowSystemInterface::handleEnterLeaveEvent(enterWindow->window(), window(), local, global); | - | ||||||||||||||||||
| 2249 | } else { | - | ||||||||||||||||||
| 2250 | QWindowSystemInterface::handleLeaveEvent(window()); | - | ||||||||||||||||||
| 2251 | } | - | ||||||||||||||||||
| 2252 | - | |||||||||||||||||||
| 2253 | free(enter); | - | ||||||||||||||||||
| 2254 | } | - | ||||||||||||||||||
| 2255 | - | |||||||||||||||||||
| 2256 | void QXcbWindow::handleMotionNotifyEvent(int event_x, int event_y, int root_x, int root_y, | - | ||||||||||||||||||
| 2257 | Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source) | - | ||||||||||||||||||
| 2258 | { | - | ||||||||||||||||||
| 2259 | QPoint local(event_x, event_y); | - | ||||||||||||||||||
| 2260 | QPoint global(root_x, root_y); | - | ||||||||||||||||||
| 2261 | - | |||||||||||||||||||
| 2262 | - | |||||||||||||||||||
| 2263 | - | |||||||||||||||||||
| 2264 | const bool isMouseButtonPressed = (connection()->buttons() != Qt::NoButton); | - | ||||||||||||||||||
| 2265 | const bool hasMousePressWindow = (connection()->mousePressWindow() != nullptr); | - | ||||||||||||||||||
| 2266 | if (isMouseButtonPressed && !hasMousePressWindow) | - | ||||||||||||||||||
| 2267 | connection()->setMousePressWindow(this); | - | ||||||||||||||||||
| 2268 | else if (hasMousePressWindow && !isMouseButtonPressed) | - | ||||||||||||||||||
| 2269 | connection()->setMousePressWindow(nullptr); | - | ||||||||||||||||||
| 2270 | - | |||||||||||||||||||
| 2271 | handleMouseEvent(timestamp, local, global, modifiers, source); | - | ||||||||||||||||||
| 2272 | } | - | ||||||||||||||||||
| 2273 | - | |||||||||||||||||||
| 2274 | - | |||||||||||||||||||
| 2275 | void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event) | - | ||||||||||||||||||
| 2276 | { | - | ||||||||||||||||||
| 2277 | Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state); | - | ||||||||||||||||||
| 2278 | handleButtonPressEvent(event->event_x, event->event_y, event->root_x, event->root_y, event->detail, | - | ||||||||||||||||||
| 2279 | modifiers, event->time); | - | ||||||||||||||||||
| 2280 | } | - | ||||||||||||||||||
| 2281 | - | |||||||||||||||||||
| 2282 | void QXcbWindow::handleButtonReleaseEvent(const xcb_button_release_event_t *event) | - | ||||||||||||||||||
| 2283 | { | - | ||||||||||||||||||
| 2284 | Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state); | - | ||||||||||||||||||
| 2285 | handleButtonReleaseEvent(event->event_x, event->event_y, event->root_x, event->root_y, event->detail, | - | ||||||||||||||||||
| 2286 | modifiers, event->time); | - | ||||||||||||||||||
| 2287 | } | - | ||||||||||||||||||
| 2288 | - | |||||||||||||||||||
| 2289 | void QXcbWindow::handleMotionNotifyEvent(const xcb_motion_notify_event_t *event) | - | ||||||||||||||||||
| 2290 | { | - | ||||||||||||||||||
| 2291 | Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state); | - | ||||||||||||||||||
| 2292 | handleMotionNotifyEvent(event->event_x, event->event_y, event->root_x, event->root_y, modifiers, event->time); | - | ||||||||||||||||||
| 2293 | } | - | ||||||||||||||||||
| 2294 | - | |||||||||||||||||||
| 2295 | - | |||||||||||||||||||
| 2296 | static inline int fixed1616ToInt(FP1616 val) | - | ||||||||||||||||||
| 2297 | { | - | ||||||||||||||||||
| 2298 | return int((qreal(val >> 16)) + (val & 0xFFFF) / (qreal)0xFFFF); | - | ||||||||||||||||||
| 2299 | } | - | ||||||||||||||||||
| 2300 | - | |||||||||||||||||||
| 2301 | - | |||||||||||||||||||
| 2302 | void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource source) | - | ||||||||||||||||||
| 2303 | { | - | ||||||||||||||||||
| 2304 | QXcbConnection *conn = connection(); | - | ||||||||||||||||||
| 2305 | xXIDeviceEvent *ev = reinterpret_cast<xXIDeviceEvent *>(event); | - | ||||||||||||||||||
| 2306 | const Qt::KeyboardModifiers modifiers = conn->keyboard()->translateModifiers(ev->mods.effective_mods); | - | ||||||||||||||||||
| 2307 | const int event_x = fixed1616ToInt(ev->event_x); | - | ||||||||||||||||||
| 2308 | const int event_y = fixed1616ToInt(ev->event_y); | - | ||||||||||||||||||
| 2309 | const int root_x = fixed1616ToInt(ev->root_x); | - | ||||||||||||||||||
| 2310 | const int root_y = fixed1616ToInt(ev->root_y); | - | ||||||||||||||||||
| 2311 | - | |||||||||||||||||||
| 2312 | conn->keyboard()->updateXKBStateFromXI(&ev->mods, &ev->group); | - | ||||||||||||||||||
| 2313 | - | |||||||||||||||||||
| 2314 | const Qt::MouseButton button = conn->xiToQtMouseButton(ev->detail); | - | ||||||||||||||||||
| 2315 | - | |||||||||||||||||||
| 2316 | if (ev->buttons_len > 0) { | - | ||||||||||||||||||
| 2317 | unsigned char *buttonMask = (unsigned char *) &ev[1]; | - | ||||||||||||||||||
| 2318 | for (int i = 1; i <= 15; ++i) | - | ||||||||||||||||||
| 2319 | conn->setButton(conn->translateMouseButton(i), (((unsigned char*)(buttonMask))[(i)>>3] & (1 << ((i) & 7)))); | - | ||||||||||||||||||
| 2320 | } | - | ||||||||||||||||||
| 2321 | - | |||||||||||||||||||
| 2322 | const char *sourceName = 0; | - | ||||||||||||||||||
| 2323 | if (__builtin_expect(!!(lcQpaXInputEvents().isDebugEnabled()), false)) { | - | ||||||||||||||||||
| 2324 | const QMetaObject *metaObject = qt_getEnumMetaObject(source); | - | ||||||||||||||||||
| 2325 | const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(source))); | - | ||||||||||||||||||
| 2326 | sourceName = me.valueToKey(source); | - | ||||||||||||||||||
| 2327 | } | - | ||||||||||||||||||
| 2328 | - | |||||||||||||||||||
| 2329 | switch (ev->evtype) { | - | ||||||||||||||||||
| 2330 | case 4: | - | ||||||||||||||||||
| 2331 | if (__builtin_expect(!!(lcQpaXInputEvents().isDebugEnabled()), false)) | - | ||||||||||||||||||
| 2332 | for (bool qt_category_enabled = lcQpaXInputEvents().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 24572451, __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 mouse press, button %d, time %d, source %s", button, ev->time, sourceName); | - | ||||||||||||||||||
| 2333 | conn->setButton(button, true); | - | ||||||||||||||||||
| 2334 | handleButtonPressEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source); | - | ||||||||||||||||||
| 2335 | break; | - | ||||||||||||||||||
| 2336 | case 5: | - | ||||||||||||||||||
| 2337 | if (__builtin_expect(!!(lcQpaXInputEvents().isDebugEnabled()), false)) | - | ||||||||||||||||||
| 2338 | for (bool qt_category_enabled = lcQpaXInputEvents().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 24632457, __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 mouse release, button %d, time %d, source %s", button, ev->time, sourceName); | - | ||||||||||||||||||
| 2339 | conn->setButton(button, false); | - | ||||||||||||||||||
| 2340 | handleButtonReleaseEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source); | - | ||||||||||||||||||
| 2341 | break; | - | ||||||||||||||||||
| 2342 | case 6: | - | ||||||||||||||||||
| 2343 | if (__builtin_expect(!!(lcQpaXInputEvents().isDebugEnabled()), false)) | - | ||||||||||||||||||
| 2344 | for (bool qt_category_enabled = lcQpaXInputEvents().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 24692463, __PRETTY_FUNCTION__, lcQpaXInputEvents().categoryName()).debug("XI2 mouse motion %d,%d, time %d, source %s", event_x, event_y, ev->time, sourceName); | - | ||||||||||||||||||
| 2345 | handleMotionNotifyEvent(event_x, event_y, root_x, root_y, modifiers, ev->time, source); | - | ||||||||||||||||||
| 2346 | break; | - | ||||||||||||||||||
| 2347 | default: | - | ||||||||||||||||||
| 2348 | QMessageLogger(__FILE__, 24732467, __PRETTY_FUNCTION__).warning() << "Unrecognized XI2 mouse event" << ev->evtype; | - | ||||||||||||||||||
| 2349 | break; | - | ||||||||||||||||||
| 2350 | } | - | ||||||||||||||||||
| 2351 | } | - | ||||||||||||||||||
| 2352 | - | |||||||||||||||||||
| 2353 | - | |||||||||||||||||||
| 2354 | void QXcbWindow::handleXIEnterLeave(xcb_ge_event_t *event) | - | ||||||||||||||||||
| 2355 | { | - | ||||||||||||||||||
| 2356 | xXIEnterEvent *ev = reinterpret_cast<xXIEnterEvent *>(event); | - | ||||||||||||||||||
| 2357 | - | |||||||||||||||||||
| 2358 | - | |||||||||||||||||||
| 2359 | - | |||||||||||||||||||
| 2360 | QXcbWindow *mouseGrabber = connection()->mouseGrabber(); | - | ||||||||||||||||||
| 2361 | if (mouseGrabber && mouseGrabber != this | - | ||||||||||||||||||
| 2362 | && (ev->evtype != 8 || QGuiApplicationPrivate::currentMouseWindow != window())) { | - | ||||||||||||||||||
| 2363 | return; | - | ||||||||||||||||||
| 2364 | } | - | ||||||||||||||||||
| 2365 | - | |||||||||||||||||||
| 2366 | const int root_x = fixed1616ToInt(ev->root_x); | - | ||||||||||||||||||
| 2367 | const int root_y = fixed1616ToInt(ev->root_y); | - | ||||||||||||||||||
| 2368 | - | |||||||||||||||||||
| 2369 | switch (ev->evtype) { | - | ||||||||||||||||||
| 2370 | case 7: { | - | ||||||||||||||||||
| 2371 | const int event_x = fixed1616ToInt(ev->event_x); | - | ||||||||||||||||||
| 2372 | const int event_y = fixed1616ToInt(ev->event_y); | - | ||||||||||||||||||
| 2373 | for (bool qt_category_enabled = lcQpaXInput().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 24982492, __PRETTY_FUNCTION__, lcQpaXInput().categoryName()).debug("XI2 mouse enter %d,%d, mode %d, detail %d, time %d", event_x, event_y, ev->mode, ev->detail, ev->time); | - | ||||||||||||||||||
| 2374 | handleEnterNotifyEvent(event_x, event_y, root_x, root_y, ev->mode, ev->detail, ev->time); | - | ||||||||||||||||||
| 2375 | break; | - | ||||||||||||||||||
| 2376 | } | - | ||||||||||||||||||
| 2377 | case 8: | - | ||||||||||||||||||
| 2378 | for (bool qt_category_enabled = lcQpaXInput().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) QMessageLogger(__FILE__, 25032497, __PRETTY_FUNCTION__, lcQpaXInput().categoryName()).debug("XI2 mouse leave, mode %d, detail %d, time %d", ev->mode, ev->detail, ev->time); | - | ||||||||||||||||||
| 2379 | connection()->keyboard()->updateXKBStateFromXI(&ev->mods, &ev->group); | - | ||||||||||||||||||
| 2380 | handleLeaveNotifyEvent(root_x, root_y, ev->mode, ev->detail, ev->time); | - | ||||||||||||||||||
| 2381 | break; | - | ||||||||||||||||||
| 2382 | } | - | ||||||||||||||||||
| 2383 | } | - | ||||||||||||||||||
| 2384 | - | |||||||||||||||||||
| 2385 | - | |||||||||||||||||||
| 2386 | QXcbWindow *QXcbWindow::toWindow() { return this; } | - | ||||||||||||||||||
| 2387 | - | |||||||||||||||||||
| 2388 | void QXcbWindow::handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global, | - | ||||||||||||||||||
| 2389 | Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source) | - | ||||||||||||||||||
| 2390 | { | - | ||||||||||||||||||
| 2391 | connection()->setTime(time); | - | ||||||||||||||||||
| 2392 | QWindowSystemInterface::handleMouseEvent(window(), time, local, global, connection()->buttons(), modifiers, source); | - | ||||||||||||||||||
| 2393 | } | - | ||||||||||||||||||
| 2394 | - | |||||||||||||||||||
| 2395 | void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *event) | - | ||||||||||||||||||
| 2396 | { | - | ||||||||||||||||||
| 2397 | handleEnterNotifyEvent(event->event_x, event->event_y, event->root_x, event->root_y, event->mode, event->detail, event->time); | - | ||||||||||||||||||
| 2398 | } | - | ||||||||||||||||||
| 2399 | - | |||||||||||||||||||
| 2400 | void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event) | - | ||||||||||||||||||
| 2401 | { | - | ||||||||||||||||||
| 2402 | handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time); | - | ||||||||||||||||||
| 2403 | } | - | ||||||||||||||||||
| 2404 | - | |||||||||||||||||||
| 2405 | void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) | - | ||||||||||||||||||
| 2406 | { | - | ||||||||||||||||||
| 2407 | connection()->setTime(event->time); | - | ||||||||||||||||||
| 2408 | - | |||||||||||||||||||
| 2409 | const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE; | - | ||||||||||||||||||
| 2410 | - | |||||||||||||||||||
| 2411 | if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) { | - | ||||||||||||||||||
| 2412 | if (propertyDeleted) | - | ||||||||||||||||||
| 2413 | return; | - | ||||||||||||||||||
| 2414 | - | |||||||||||||||||||
| 2415 | Qt::WindowState newState = Qt::WindowNoState; | - | ||||||||||||||||||
| 2416 | if (event->atom == atom(QXcbAtom::WM_STATE)) { | - | ||||||||||||||||||
| 2417 | const xcb_get_property_cookie_t get_cookie = | - | ||||||||||||||||||
| 2418 | xcb_get_property(xcb_connection(), 0, m_window, atom(QXcbAtom::WM_STATE), | - | ||||||||||||||||||
| 2419 | XCB_ATOM_ANY, 0, 1024); | - | ||||||||||||||||||
| 2420 | - | |||||||||||||||||||
| 2421 | xcb_get_property_reply_t *reply = | - | ||||||||||||||||||
| 2422 | xcb_get_property_reply(xcb_connection(), get_cookie, __null); | - | ||||||||||||||||||
| 2423 | - | |||||||||||||||||||
| 2424 | if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) { | - | ||||||||||||||||||
| 2425 | const quint32 *data = (const quint32 *)xcb_get_property_value(reply); | - | ||||||||||||||||||
| 2426 | if (reply->length != 0) { | - | ||||||||||||||||||
| 2427 | if (data[0] == XCB_ICCCM_WM_STATE_ICONIC | - | ||||||||||||||||||
| 2428 | || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN | - | ||||||||||||||||||
| 2429 | && m_lastWindowStateEvent == Qt::WindowMinimized)) { | - | ||||||||||||||||||
| 2430 | newState = Qt::WindowMinimized; | - | ||||||||||||||||||
| 2431 | } | - | ||||||||||||||||||
| 2432 | } | - | ||||||||||||||||||
| 2433 | } | - | ||||||||||||||||||
| 2434 | free(reply); | - | ||||||||||||||||||
| 2435 | } else { | - | ||||||||||||||||||
| 2436 | if (m_lastWindowStateEvent == Qt::WindowMinimized) | - | ||||||||||||||||||
| 2437 | newState = Qt::WindowMinimized; | - | ||||||||||||||||||
| 2438 | } | - | ||||||||||||||||||
| 2439 | - | |||||||||||||||||||
| 2440 | if (newState != Qt::WindowMinimized) { | - | ||||||||||||||||||
| 2441 | const NetWmStates states = netWmStates(); | - | ||||||||||||||||||
| 2442 | if (states & NetWmStateFullScreen) | - | ||||||||||||||||||
| 2443 | newState = Qt::WindowFullScreen; | - | ||||||||||||||||||
| 2444 | else if ((states & NetWmStateMaximizedHorz) && (states & NetWmStateMaximizedVert)) | - | ||||||||||||||||||
| 2445 | newState = Qt::WindowMaximized; | - | ||||||||||||||||||
| 2446 | } | - | ||||||||||||||||||
| 2447 | - | |||||||||||||||||||
| 2448 | if (m_lastWindowStateEvent != newState) { | - | ||||||||||||||||||
| 2449 | QWindowSystemInterface::handleWindowStateChanged(window(), newState); | - | ||||||||||||||||||
| 2450 | m_lastWindowStateEvent = newState; | - | ||||||||||||||||||
| 2451 | m_windowState = newState; | - | ||||||||||||||||||
| 2452 | if (m_windowState == Qt::WindowMinimized && connection()->mouseGrabber() == this) | - | ||||||||||||||||||
| 2453 | connection()->setMouseGrabber(nullptr); | - | ||||||||||||||||||
| 2454 | } | - | ||||||||||||||||||
| 2455 | return; | - | ||||||||||||||||||
| 2456 | } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) { | - | ||||||||||||||||||
| 2457 | m_dirtyFrameMargins = true; | - | ||||||||||||||||||
| 2458 | } | - | ||||||||||||||||||
| 2459 | } | - | ||||||||||||||||||
| 2460 | - | |||||||||||||||||||
| 2461 | void QXcbWindow::handleFocusInEvent(const xcb_focus_in_event_t *event) | - | ||||||||||||||||||
| 2462 | { | - | ||||||||||||||||||
| 2463 | - | |||||||||||||||||||
| 2464 | - | |||||||||||||||||||
| 2465 | if (event->detail == XCB_NOTIFY_DETAIL_POINTER) | - | ||||||||||||||||||
| 2466 | return; | - | ||||||||||||||||||
| 2467 | doFocusIn(); | - | ||||||||||||||||||
| 2468 | } | - | ||||||||||||||||||
| 2469 | - | |||||||||||||||||||
| 2470 | - | |||||||||||||||||||
| 2471 | void QXcbWindow::handleFocusOutEvent(const xcb_focus_out_event_t *event) | - | ||||||||||||||||||
| 2472 | { | - | ||||||||||||||||||
| 2473 | - | |||||||||||||||||||
| 2474 | - | |||||||||||||||||||
| 2475 | if (event->detail == XCB_NOTIFY_DETAIL_POINTER) | - | ||||||||||||||||||
| 2476 | return; | - | ||||||||||||||||||
| 2477 | doFocusOut(); | - | ||||||||||||||||||
| 2478 | } | - | ||||||||||||||||||
| 2479 | - | |||||||||||||||||||
| 2480 | void QXcbWindow::updateSyncRequestCounter() | - | ||||||||||||||||||
| 2481 | { | - | ||||||||||||||||||
| 2482 | if (m_syncState != SyncAndConfigureReceived) { | - | ||||||||||||||||||
| 2483 | - | |||||||||||||||||||
| 2484 | return; | - | ||||||||||||||||||
| 2485 | } | - | ||||||||||||||||||
| 2486 | if (m_usingSyncProtocol && (m_syncValue.lo != 0 || m_syncValue.hi != 0)) { | - | ||||||||||||||||||
| 2487 | xcb_sync_set_counter(xcb_connection(), m_syncCounter, m_syncValue); | - | ||||||||||||||||||
| 2488 | xcb_flush(xcb_connection()); | - | ||||||||||||||||||
| 2489 | - | |||||||||||||||||||
| 2490 | m_syncValue.lo = 0; | - | ||||||||||||||||||
| 2491 | m_syncValue.hi = 0; | - | ||||||||||||||||||
| 2492 | m_syncState = NoSyncNeeded; | - | ||||||||||||||||||
| 2493 | } | - | ||||||||||||||||||
| 2494 | } | - | ||||||||||||||||||
| 2495 | - | |||||||||||||||||||
| 2496 | const xcb_visualtype_t *QXcbWindow::createVisual() | - | ||||||||||||||||||
| 2497 | { | - | ||||||||||||||||||
| 2498 |     return executed 133 times by 12 tests:   xcbScreen() ? xcbScreen()->visualForFormat(m_format)return xcbScreen() ? xcbScreen()->visualForFormat(m_format) : nullptr;Executed by: 
 executed 133 times by 12 tests:  return xcbScreen() ? xcbScreen()->visualForFormat(m_format) : nullptr;Executed by: 
  | 133 | ||||||||||||||||||
| 2499 |                        : nullptr; executed 133 times by 12 tests:  return xcbScreen() ? xcbScreen()->visualForFormat(m_format) : nullptr;Executed by: 
  | 133 | ||||||||||||||||||
| 2500 | } | - | ||||||||||||||||||
| 2501 | - | |||||||||||||||||||
| 2502 | bool QXcbWindow::setKeyboardGrabEnabled(bool grab) | - | ||||||||||||||||||
| 2503 | { | - | ||||||||||||||||||
| 2504 | if (grab && !connection()->canGrab()) | - | ||||||||||||||||||
| 2505 | return false; | - | ||||||||||||||||||
| 2506 | - | |||||||||||||||||||
| 2507 | if (!grab) { | - | ||||||||||||||||||
| 2508 | xcb_ungrab_keyboard(xcb_connection(), XCB_TIME_CURRENT_TIME); | - | ||||||||||||||||||
| 2509 | return true; | - | ||||||||||||||||||
| 2510 | } | - | ||||||||||||||||||
| 2511 | xcb_grab_keyboard_cookie_t cookie = xcb_grab_keyboard(xcb_connection(), false, | - | ||||||||||||||||||
| 2512 | m_window, XCB_TIME_CURRENT_TIME, | - | ||||||||||||||||||
| 2513 | XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC); | - | ||||||||||||||||||
| 2514 | xcb_grab_keyboard_reply_t *reply = xcb_grab_keyboard_reply(xcb_connection(), cookie, __null); | - | ||||||||||||||||||
| 2515 | bool result = !(!reply || reply->status != XCB_GRAB_STATUS_SUCCESS); | - | ||||||||||||||||||
| 2516 | free(reply); | - | ||||||||||||||||||
| 2517 | return result; | - | ||||||||||||||||||
| 2518 | } | - | ||||||||||||||||||
| 2519 | - | |||||||||||||||||||
| 2520 | bool QXcbWindow::setMouseGrabEnabled(bool grab) | - | ||||||||||||||||||
| 2521 | { | - | ||||||||||||||||||
| 2522 | if (!grab && connection()->mouseGrabber() == this) | - | ||||||||||||||||||
| 2523 | connection()->setMouseGrabber(nullptr); | - | ||||||||||||||||||
| 2524 | - | |||||||||||||||||||
| 2525 | if (connection()->isAtLeastXI22() && connection()->xi2MouseEvents()) { | - | ||||||||||||||||||
| 2526 | bool result = connection()->xi2SetMouseGrabEnabled(m_window, grab); | - | ||||||||||||||||||
| 2527 | if (grab && result) | - | ||||||||||||||||||
| 2528 | connection()->setMouseGrabber(this); | - | ||||||||||||||||||
| 2529 | return result; | - | ||||||||||||||||||
| 2530 | } | - | ||||||||||||||||||
| 2531 | - | |||||||||||||||||||
| 2532 | if (grab && !connection()->canGrab()) | - | ||||||||||||||||||
| 2533 | return false; | - | ||||||||||||||||||
| 2534 | - | |||||||||||||||||||
| 2535 | if (!grab) { | - | ||||||||||||||||||
| 2536 | xcb_ungrab_pointer(xcb_connection(), XCB_TIME_CURRENT_TIME); | - | ||||||||||||||||||
| 2537 | return true; | - | ||||||||||||||||||
| 2538 | } | - | ||||||||||||||||||
| 2539 | xcb_grab_pointer_cookie_t cookie = xcb_grab_pointer(xcb_connection(), false, m_window, | - | ||||||||||||||||||
| 2540 | (XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | - | ||||||||||||||||||
| 2541 | | XCB_EVENT_MASK_BUTTON_MOTION | XCB_EVENT_MASK_ENTER_WINDOW | - | ||||||||||||||||||
| 2542 | | XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_POINTER_MOTION), | - | ||||||||||||||||||
| 2543 | XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, | - | ||||||||||||||||||
| 2544 | XCB_WINDOW_NONE, XCB_CURSOR_NONE, | - | ||||||||||||||||||
| 2545 | XCB_TIME_CURRENT_TIME); | - | ||||||||||||||||||
| 2546 | xcb_grab_pointer_reply_t *reply = xcb_grab_pointer_reply(xcb_connection(), cookie, __null); | - | ||||||||||||||||||
| 2547 | bool result = !(!reply || reply->status != XCB_GRAB_STATUS_SUCCESS); | - | ||||||||||||||||||
| 2548 | free(reply); | - | ||||||||||||||||||
| 2549 | if (result) | - | ||||||||||||||||||
| 2550 | connection()->setMouseGrabber(this); | - | ||||||||||||||||||
| 2551 | return result; | - | ||||||||||||||||||
| 2552 | } | - | ||||||||||||||||||
| 2553 | - | |||||||||||||||||||
| 2554 | void QXcbWindow::setCursor(xcb_cursor_t cursor, bool isBitmapCursor) | - | ||||||||||||||||||
| 2555 | { | - | ||||||||||||||||||
| 2556 | xcb_connection_t *conn = xcb_connection(); | - | ||||||||||||||||||
| 2557 | - | |||||||||||||||||||
| 2558 | xcb_change_window_attributes(conn, m_window, XCB_CW_CURSOR, &cursor); | - | ||||||||||||||||||
| 2559 | xcb_flush(conn); | - | ||||||||||||||||||
| 2560 | - | |||||||||||||||||||
| 2561 | if (m_currentBitmapCursor != XCB_CURSOR_NONE) { | - | ||||||||||||||||||
| 2562 | xcb_free_cursor(conn, m_currentBitmapCursor); | - | ||||||||||||||||||
| 2563 | } | - | ||||||||||||||||||
| 2564 | - | |||||||||||||||||||
| 2565 | if (isBitmapCursor) { | - | ||||||||||||||||||
| 2566 | m_currentBitmapCursor = cursor; | - | ||||||||||||||||||
| 2567 | } else { | - | ||||||||||||||||||
| 2568 | m_currentBitmapCursor = XCB_CURSOR_NONE; | - | ||||||||||||||||||
| 2569 | } | - | ||||||||||||||||||
| 2570 | } | - | ||||||||||||||||||
| 2571 | - | |||||||||||||||||||
| 2572 | void QXcbWindow::windowEvent(QEvent *event) | - | ||||||||||||||||||
| 2573 | { | - | ||||||||||||||||||
| 2574 | switch (event->type()) { | - | ||||||||||||||||||
| 2575 | case QEvent::FocusIn: | - | ||||||||||||||||||
| 2576 | if (m_embedded && !event->spontaneous()) { | - | ||||||||||||||||||
| 2577 | QFocusEvent *focusEvent = static_cast<QFocusEvent *>(event); | - | ||||||||||||||||||
| 2578 | switch (focusEvent->reason()) { | - | ||||||||||||||||||
| 2579 | case Qt::TabFocusReason: | - | ||||||||||||||||||
| 2580 | case Qt::BacktabFocusReason: | - | ||||||||||||||||||
| 2581 | { | - | ||||||||||||||||||
| 2582 | const QXcbWindow *container = | - | ||||||||||||||||||
| 2583 | static_cast<const QXcbWindow *>(parent()); | - | ||||||||||||||||||
| 2584 | sendXEmbedMessage(container->xcb_window(), | - | ||||||||||||||||||
| 2585 | focusEvent->reason() == Qt::TabFocusReason ? | - | ||||||||||||||||||
| 2586 | XEMBED_FOCUS_NEXT : XEMBED_FOCUS_PREV); | - | ||||||||||||||||||
| 2587 | event->accept(); | - | ||||||||||||||||||
| 2588 | } | - | ||||||||||||||||||
| 2589 | break; | - | ||||||||||||||||||
| 2590 | default: | - | ||||||||||||||||||
| 2591 | break; | - | ||||||||||||||||||
| 2592 | } | - | ||||||||||||||||||
| 2593 | } | - | ||||||||||||||||||
| 2594 | break; | - | ||||||||||||||||||
| 2595 | default: | - | ||||||||||||||||||
| 2596 | break; | - | ||||||||||||||||||
| 2597 | } | - | ||||||||||||||||||
| 2598 | QPlatformWindow::windowEvent(event); | - | ||||||||||||||||||
| 2599 | } | - | ||||||||||||||||||
| 2600 | - | |||||||||||||||||||
| 2601 | bool QXcbWindow::startSystemResize(const QPoint &pos, Qt::Corner corner) | - | ||||||||||||||||||
| 2602 | { | - | ||||||||||||||||||
| 2603 | const xcb_atom_t moveResize = connection()->atom(QXcbAtom::_NET_WM_MOVERESIZE); | - | ||||||||||||||||||
| 2604 | if (!connection()->wmSupport()->isSupportedByWM(moveResize)) | - | ||||||||||||||||||
| 2605 | return false; | - | ||||||||||||||||||
| 2606 | xcb_client_message_event_t xev; | - | ||||||||||||||||||
| 2607 | xev.response_type = 33; | - | ||||||||||||||||||
| 2608 | xev.type = moveResize; | - | ||||||||||||||||||
| 2609 | xev.sequence = 0; | - | ||||||||||||||||||
| 2610 | xev.window = xcb_window(); | - | ||||||||||||||||||
| 2611 | xev.format = 32; | - | ||||||||||||||||||
| 2612 | const QPoint globalPos = window()->mapToGlobal(pos); | - | ||||||||||||||||||
| 2613 | xev.data.data32[0] = globalPos.x(); | - | ||||||||||||||||||
| 2614 | xev.data.data32[1] = globalPos.y(); | - | ||||||||||||||||||
| 2615 | const bool bottom = corner == Qt::BottomRightCorner || corner == Qt::BottomLeftCorner; | - | ||||||||||||||||||
| 2616 | const bool left = corner == Qt::BottomLeftCorner || corner == Qt::TopLeftCorner; | - | ||||||||||||||||||
| 2617 | if (bottom) | - | ||||||||||||||||||
| 2618 | xev.data.data32[2] = left ? 6 : 4; | - | ||||||||||||||||||
| 2619 | else | - | ||||||||||||||||||
| 2620 | xev.data.data32[2] = left ? 0 : 2; | - | ||||||||||||||||||
| 2621 | xev.data.data32[3] = XCB_BUTTON_INDEX_1; | - | ||||||||||||||||||
| 2622 | xev.data.data32[4] = 0; | - | ||||||||||||||||||
| 2623 | xcb_ungrab_pointer(connection()->xcb_connection(), 0L); | - | ||||||||||||||||||
| 2624 | xcb_send_event(connection()->xcb_connection(), false, xcbScreen()->root(), | - | ||||||||||||||||||
| 2625 | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY, | - | ||||||||||||||||||
| 2626 | (const char *)&xev); | - | ||||||||||||||||||
| 2627 | return true; | - | ||||||||||||||||||
| 2628 | } | - | ||||||||||||||||||
| 2629 | - | |||||||||||||||||||
| 2630 | - | |||||||||||||||||||
| 2631 | void QXcbWindow::sendXEmbedMessage(xcb_window_t window, quint32 message, | - | ||||||||||||||||||
| 2632 | quint32 detail, quint32 data1, quint32 data2) | - | ||||||||||||||||||
| 2633 | { | - | ||||||||||||||||||
| 2634 | xcb_client_message_event_t event; | - | ||||||||||||||||||
| 2635 | - | |||||||||||||||||||
| 2636 | event.response_type = 33; | - | ||||||||||||||||||
| 2637 | event.format = 32; | - | ||||||||||||||||||
| 2638 | event.sequence = 0; | - | ||||||||||||||||||
| 2639 | event.window = window; | - | ||||||||||||||||||
| 2640 | event.type = atom(QXcbAtom::_XEMBED); | - | ||||||||||||||||||
| 2641 | event.data.data32[0] = connection()->time(); | - | ||||||||||||||||||
| 2642 | event.data.data32[1] = message; | - | ||||||||||||||||||
| 2643 | event.data.data32[2] = detail; | - | ||||||||||||||||||
| 2644 | event.data.data32[3] = data1; | - | ||||||||||||||||||
| 2645 | event.data.data32[4] = data2; | - | ||||||||||||||||||
| 2646 | xcb_send_event(xcb_connection(), false, window, XCB_EVENT_MASK_NO_EVENT, (const char *)&event) | - | ||||||||||||||||||
| 2647 | ; | - | ||||||||||||||||||
| 2648 | } | - | ||||||||||||||||||
| 2649 | - | |||||||||||||||||||
| 2650 | static bool activeWindowChangeQueued(const QWindow *window) | - | ||||||||||||||||||
| 2651 | { | - | ||||||||||||||||||
| 2652 | - | |||||||||||||||||||
| 2653 | - | |||||||||||||||||||
| 2654 | - | |||||||||||||||||||
| 2655 | QWindowSystemInterfacePrivate::ActivatedWindowEvent *systemEvent = | - | ||||||||||||||||||
| 2656 | static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *> | - | ||||||||||||||||||
| 2657 | (QWindowSystemInterfacePrivate::peekWindowSystemEvent(QWindowSystemInterfacePrivate::ActivatedWindow)); | - | ||||||||||||||||||
| 2658 | return systemEvent && systemEvent->activated != window; | - | ||||||||||||||||||
| 2659 | } | - | ||||||||||||||||||
| 2660 | - | |||||||||||||||||||
| 2661 | void QXcbWindow::handleXEmbedMessage(const xcb_client_message_event_t *event) | - | ||||||||||||||||||
| 2662 | { | - | ||||||||||||||||||
| 2663 | connection()->setTime(event->data.data32[0]); | - | ||||||||||||||||||
| 2664 | switch (event->data.data32[1]) { | - | ||||||||||||||||||
| 2665 | case XEMBED_WINDOW_ACTIVATE: | - | ||||||||||||||||||
| 2666 | case XEMBED_WINDOW_DEACTIVATE: | - | ||||||||||||||||||
| 2667 | break; | - | ||||||||||||||||||
| 2668 | case XEMBED_EMBEDDED_NOTIFY: | - | ||||||||||||||||||
| 2669 | xcb_map_window(xcb_connection(), m_window); | - | ||||||||||||||||||
| 2670 | xcbScreen()->windowShown(this); | - | ||||||||||||||||||
| 2671 | - | |||||||||||||||||||
| 2672 | - | |||||||||||||||||||
| 2673 | - | |||||||||||||||||||
| 2674 | xcb_clear_area(xcb_connection(), false, m_window, 0, 0, geometry().width(), geometry().height()); | - | ||||||||||||||||||
| 2675 | xcb_flush(xcb_connection()); | - | ||||||||||||||||||
| 2676 | break; | - | ||||||||||||||||||
| 2677 | case XEMBED_FOCUS_IN: | - | ||||||||||||||||||
| 2678 | Qt::FocusReason reason; | - | ||||||||||||||||||
| 2679 | switch (event->data.data32[2]) { | - | ||||||||||||||||||
| 2680 | case XEMBED_FOCUS_FIRST: | - | ||||||||||||||||||
| 2681 | reason = Qt::TabFocusReason; | - | ||||||||||||||||||
| 2682 | break; | - | ||||||||||||||||||
| 2683 | case XEMBED_FOCUS_LAST: | - | ||||||||||||||||||
| 2684 | reason = Qt::BacktabFocusReason; | - | ||||||||||||||||||
| 2685 | break; | - | ||||||||||||||||||
| 2686 | case XEMBED_FOCUS_CURRENT: | - | ||||||||||||||||||
| 2687 | default: | - | ||||||||||||||||||
| 2688 | reason = Qt::OtherFocusReason; | - | ||||||||||||||||||
| 2689 | break; | - | ||||||||||||||||||
| 2690 | } | - | ||||||||||||||||||
| 2691 | connection()->setFocusWindow(static_cast<QXcbWindow*>(window()->handle())); | - | ||||||||||||||||||
| 2692 | QWindowSystemInterface::handleWindowActivated(window(), reason); | - | ||||||||||||||||||
| 2693 | break; | - | ||||||||||||||||||
| 2694 | case XEMBED_FOCUS_OUT: | - | ||||||||||||||||||
| 2695 | if (window() == QGuiApplication::focusWindow() | - | ||||||||||||||||||
| 2696 | && !activeWindowChangeQueued(window())) { | - | ||||||||||||||||||
| 2697 | connection()->setFocusWindow(0); | - | ||||||||||||||||||
| 2698 | QWindowSystemInterface::handleWindowActivated(0); | - | ||||||||||||||||||
| 2699 | } | - | ||||||||||||||||||
| 2700 | break; | - | ||||||||||||||||||
| 2701 | } | - | ||||||||||||||||||
| 2702 | } | - | ||||||||||||||||||
| 2703 | - | |||||||||||||||||||
| 2704 | static inline xcb_rectangle_t qRectToXCBRectangle(const QRect &r) | - | ||||||||||||||||||
| 2705 | { | - | ||||||||||||||||||
| 2706 | xcb_rectangle_t result; | - | ||||||||||||||||||
| 2707 | result.x = qMax((-32767 - 1), r.x()); | - | ||||||||||||||||||
| 2708 | result.y = qMax((-32767 - 1), r.y()); | - | ||||||||||||||||||
| 2709 | result.width = qMin((int)(32767 * 2 + 1), r.width()); | - | ||||||||||||||||||
| 2710 | result.height = qMin((int)(32767 * 2 + 1), r.height()); | - | ||||||||||||||||||
| 2711 | return result; | - | ||||||||||||||||||
| 2712 | } | - | ||||||||||||||||||
| 2713 | - | |||||||||||||||||||
| 2714 | void QXcbWindow::setOpacity(qreal level) | - | ||||||||||||||||||
| 2715 | { | - | ||||||||||||||||||
| 2716 | if (!m_window) | - | ||||||||||||||||||
| 2717 | return; | - | ||||||||||||||||||
| 2718 | - | |||||||||||||||||||
| 2719 | quint32 value = qRound64(qBound(qreal(0), level, qreal(1)) * 0xffffffff); | - | ||||||||||||||||||
| 2720 | - | |||||||||||||||||||
| 2721 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_WINDOW_OPACITY), XCB_ATOM_CARDINAL, 32, 1, (uchar *)&value) | - | ||||||||||||||||||
| 2722 | - | |||||||||||||||||||
| 2723 | - | |||||||||||||||||||
| 2724 | - | |||||||||||||||||||
| 2725 | - | |||||||||||||||||||
| 2726 | - | |||||||||||||||||||
| 2727 | - | |||||||||||||||||||
| 2728 | ; | - | ||||||||||||||||||
| 2729 | } | - | ||||||||||||||||||
| 2730 | - | |||||||||||||||||||
| 2731 | void QXcbWindow::setMask(const QRegion ®ion) | - | ||||||||||||||||||
| 2732 | { | - | ||||||||||||||||||
| 2733 | if (!connection()->hasXShape()) | - | ||||||||||||||||||
| 2734 | return; | - | ||||||||||||||||||
| 2735 | if (region.isEmpty()) { | - | ||||||||||||||||||
| 2736 | xcb_shape_mask(connection()->xcb_connection(), XCB_SHAPE_SO_SET, | - | ||||||||||||||||||
| 2737 | XCB_SHAPE_SK_BOUNDING, xcb_window(), 0, 0, 0L); | - | ||||||||||||||||||
| 2738 | } else { | - | ||||||||||||||||||
| 2739 | QVector<xcb_rectangle_t> rects; | - | ||||||||||||||||||
| 2740 | const QVector<QRect> regionRects = region.rects(); | - | ||||||||||||||||||
| 2741 | rects.reserve(regionRects.count()); | - | ||||||||||||||||||
| 2742 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(regionRects)>::type> _container_((regionRects)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QRect &r = *_container_.i; _container_.control; _container_.control = 0) | - | ||||||||||||||||||
| 2743 | rects.push_back(qRectToXCBRectangle(r)); | - | ||||||||||||||||||
| 2744 | xcb_shape_rectangles(connection()->xcb_connection(), XCB_SHAPE_SO_SET, | - | ||||||||||||||||||
| 2745 | XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED, | - | ||||||||||||||||||
| 2746 | xcb_window(), 0, 0, rects.size(), &rects[0]); | - | ||||||||||||||||||
| 2747 | } | - | ||||||||||||||||||
| 2748 | } | - | ||||||||||||||||||
| 2749 | - | |||||||||||||||||||
| 2750 | void QXcbWindow::setAlertState(bool enabled) | - | ||||||||||||||||||
| 2751 | { | - | ||||||||||||||||||
| 2752 | if (m_alertState == enabled) | - | ||||||||||||||||||
| 2753 | return; | - | ||||||||||||||||||
| 2754 | - | |||||||||||||||||||
| 2755 | m_alertState = enabled; | - | ||||||||||||||||||
| 2756 | - | |||||||||||||||||||
| 2757 | changeNetWmState(enabled, atom(QXcbAtom::_NET_WM_STATE_DEMANDS_ATTENTION)); | - | ||||||||||||||||||
| 2758 | } | - | ||||||||||||||||||
| 2759 | - | |||||||||||||||||||
| 2760 | uint QXcbWindow::visualId() const | - | ||||||||||||||||||
| 2761 | { | - | ||||||||||||||||||
| 2762 | return m_visualId; | - | ||||||||||||||||||
| 2763 | } | - | ||||||||||||||||||
| 2764 | - | |||||||||||||||||||
| 2765 | bool QXcbWindow::needsSync() const | - | ||||||||||||||||||
| 2766 | { | - | ||||||||||||||||||
| 2767 | return m_syncState == SyncAndConfigureReceived; | - | ||||||||||||||||||
| 2768 | } | - | ||||||||||||||||||
| 2769 | - | |||||||||||||||||||
| 2770 | void QXcbWindow::postSyncWindowRequest() | - | ||||||||||||||||||
| 2771 | { | - | ||||||||||||||||||
| 2772 | if (!m_pendingSyncRequest) { | - | ||||||||||||||||||
| 2773 | QXcbSyncWindowRequest *e = new QXcbSyncWindowRequest(this); | - | ||||||||||||||||||
| 2774 | m_pendingSyncRequest = e; | - | ||||||||||||||||||
| 2775 | QCoreApplication::postEvent(xcbScreen()->connection(), e); | - | ||||||||||||||||||
| 2776 | } | - | ||||||||||||||||||
| 2777 | } | - | ||||||||||||||||||
| 2778 | - | |||||||||||||||||||
| 2779 | QXcbScreen *QXcbWindow::xcbScreen() const | - | ||||||||||||||||||
| 2780 | { | - | ||||||||||||||||||
| 2781 | return static_cast<QXcbScreen *>(screen()); | - | ||||||||||||||||||
| 2782 | } | - | ||||||||||||||||||
| 2783 | - | |||||||||||||||||||
| 2784 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |