Commit a6d34dc0c8715c461fa47da76f5615df60f7b61a
- Diff rendering mode:
- inline
- side by side
src/gui/kernel/qwidget_x11.cpp
(30 / 7)
|   | |||
| 346 | 346 | qt_x11_enforce_cursor(w, false); | |
| 347 | 347 | } | |
| 348 | 348 | ||
| 349 | static Bool checkForConfigureAndExpose(Display *, XEvent *e, XPointer) | ||
| 350 | { | ||
| 351 | return e->type == ConfigureNotify || e->type == Expose; | ||
| 352 | } | ||
| 349 | 353 | ||
| 350 | 354 | Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget* w) | |
| 351 | 355 | { | |
| … | … | ||
| 359 | 359 | XEvent ev; | |
| 360 | 360 | QTime t; | |
| 361 | 361 | t.start(); | |
| 362 | static const int maximumWaitTime = 2000; | ||
| 362 | 363 | if (!w->testAttribute(Qt::WA_WState_Created)) | |
| 363 | 364 | return; | |
| 364 | while (!XCheckTypedWindowEvent(X11->display, w->effectiveWinId(), ReparentNotify, &ev)) { | ||
| 365 | if (t.elapsed() > 2000) | ||
| 366 | return; | ||
| 367 | qApp->syncX(); // non-busy wait | ||
| 365 | |||
| 366 | if (!(w->windowFlags() & Qt::X11BypassWindowManagerHint)) { | ||
| 367 | // if the window is not override-redirect, then the window manager | ||
| 368 | // will reparent us to the frame decoration window. | ||
| 369 | while (!XCheckTypedWindowEvent(X11->display, w->effectiveWinId(), ReparentNotify, &ev)) { | ||
| 370 | if (t.elapsed() > maximumWaitTime) | ||
| 371 | return; | ||
| 372 | qApp->syncX(); // non-busy wait | ||
| 373 | } | ||
| 368 | 374 | } | |
| 369 | 375 | ||
| 370 | 376 | while (!XCheckTypedWindowEvent(X11->display, w->effectiveWinId(), MapNotify, &ev)) { | |
| 371 | if (t.elapsed() > 2000) | ||
| 377 | if (t.elapsed() > maximumWaitTime) | ||
| 372 | 378 | return; | |
| 373 | 379 | qApp->syncX(); // non-busy wait | |
| 374 | 380 | } | |
| 375 | 381 | ||
| 376 | 382 | qApp->x11ProcessEvent(&ev); | |
| 377 | if (XCheckTypedWindowEvent(X11->display, w->effectiveWinId(), ConfigureNotify, &ev)) | ||
| 378 | qApp->x11ProcessEvent(&ev); | ||
| 383 | |||
| 384 | // ok, seems like the window manager successfully reparented us, we'll wait | ||
| 385 | // for the first paint event to arrive, while handling ConfigureNotify in | ||
| 386 | // the arrival order | ||
| 387 | while(1) | ||
| 388 | { | ||
| 389 | if (XCheckIfEvent(X11->display, &ev, checkForConfigureAndExpose, 0)) { | ||
| 390 | qApp->x11ProcessEvent(&ev); | ||
| 391 | if (ev.type == Expose) | ||
| 392 | return; | ||
| 393 | } | ||
| 394 | if (t.elapsed() > maximumWaitTime) | ||
| 395 | return; | ||
| 396 | qApp->syncX(); // non-busy wait | ||
| 397 | } | ||
| 379 | 398 | } | |
| 380 | 399 | ||
| 381 | 400 | void qt_change_net_wm_state(const QWidget* w, bool set, Atom one, Atom two = 0) |

