778 QApplication::isRightToLeft() ? NorthEastGravity : NorthWestGravity; |
778 QApplication::isRightToLeft() ? NorthEastGravity : NorthWestGravity; |
779 |
779 |
780 XWMHints wm_hints; // window manager hints |
780 XWMHints wm_hints; // window manager hints |
781 memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy |
781 memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy |
782 wm_hints.flags = InputHint | StateHint | WindowGroupHint; |
782 wm_hints.flags = InputHint | StateHint | WindowGroupHint; |
783 wm_hints.input = True; |
783 wm_hints.input = q->testAttribute(Qt::WA_X11DoNotAcceptFocus) ? False : True; |
784 wm_hints.initial_state = NormalState; |
784 wm_hints.initial_state = NormalState; |
785 wm_hints.window_group = X11->wm_client_leader; |
785 wm_hints.window_group = X11->wm_client_leader; |
786 |
786 |
787 XClassHint class_hint; |
787 XClassHint class_hint; |
788 QByteArray appName = qAppName().toLatin1(); |
788 QByteArray appName = qAppName().toLatin1(); |
1164 q->setAttribute(Qt::WA_WState_Visible, false); |
1164 q->setAttribute(Qt::WA_WState_Visible, false); |
1165 q->setAttribute(Qt::WA_WState_Hidden, false); |
1165 q->setAttribute(Qt::WA_WState_Hidden, false); |
1166 adjustFlags(data.window_flags, q); |
1166 adjustFlags(data.window_flags, q); |
1167 // keep compatibility with previous versions, we need to preserve the created state |
1167 // keep compatibility with previous versions, we need to preserve the created state |
1168 // (but we recreate the winId for the widget being reparented, again for compatibility) |
1168 // (but we recreate the winId for the widget being reparented, again for compatibility) |
1169 if (wasCreated || (!q->isWindow() && parent->testAttribute(Qt::WA_WState_Created))) |
1169 if (wasCreated) |
1170 createWinId(); |
1170 createWinId(); |
1171 if (q->isWindow() || (!parent || parent->isVisible()) || explicitlyHidden) |
1171 if (q->isWindow() || (!parent || parent->isVisible()) || explicitlyHidden) |
1172 q->setAttribute(Qt::WA_WState_Hidden); |
1172 q->setAttribute(Qt::WA_WState_Hidden); |
1173 q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden); |
1173 q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden); |
1174 |
1174 |
1639 QWidget *tlw = window(); |
1639 QWidget *tlw = window(); |
1640 if (tlw->isVisible() && !tlw->d_func()->topData()->embedded && !X11->deferred_map.contains(tlw)) { |
1640 if (tlw->isVisible() && !tlw->d_func()->topData()->embedded && !X11->deferred_map.contains(tlw)) { |
1641 if (X11->userTime == 0) |
1641 if (X11->userTime == 0) |
1642 X11->userTime = X11->time; |
1642 X11->userTime = X11->time; |
1643 qt_net_update_user_time(tlw, X11->userTime); |
1643 qt_net_update_user_time(tlw, X11->userTime); |
1644 XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time); |
1644 |
|
1645 if (X11->isSupportedByWM(ATOM(_NET_ACTIVE_WINDOW)) |
|
1646 && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)) { |
|
1647 XEvent e; |
|
1648 e.xclient.type = ClientMessage; |
|
1649 e.xclient.message_type = ATOM(_NET_ACTIVE_WINDOW); |
|
1650 e.xclient.display = X11->display; |
|
1651 e.xclient.window = tlw->internalWinId(); |
|
1652 e.xclient.format = 32; |
|
1653 e.xclient.data.l[0] = 1; // 1 == application |
|
1654 e.xclient.data.l[1] = X11->userTime; |
|
1655 if (QWidget *aw = QApplication::activeWindow()) |
|
1656 e.xclient.data.l[2] = aw->internalWinId(); |
|
1657 else |
|
1658 e.xclient.data.l[2] = XNone; |
|
1659 e.xclient.data.l[3] = 0; |
|
1660 e.xclient.data.l[4] = 0; |
|
1661 XSendEvent(X11->display, RootWindow(X11->display, tlw->x11Info().screen()), |
|
1662 false, SubstructureNotifyMask | SubstructureRedirectMask, &e); |
|
1663 } else { |
|
1664 if (!qt_widget_private(tlw)->topData()->waitingForMapNotify) |
|
1665 XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time); |
|
1666 } |
1645 } |
1667 } |
1646 } |
1668 } |
1647 |
1669 |
1648 void QWidget::setWindowState(Qt::WindowStates newstate) |
1670 void QWidget::setWindowState(Qt::WindowStates newstate) |
1649 { |
1671 { |
2976 && X11->solid_fills[i].color.green == color.green |
2998 && X11->solid_fills[i].color.green == color.green |
2977 && X11->solid_fills[i].color.blue == color.blue) |
2999 && X11->solid_fills[i].color.blue == color.blue) |
2978 return X11->solid_fills[i].picture; |
3000 return X11->solid_fills[i].picture; |
2979 } |
3001 } |
2980 // none found, replace one |
3002 // none found, replace one |
2981 int i = rand() % 16; |
3003 int i = qrand() % 16; |
2982 |
3004 |
2983 if (X11->solid_fills[i].screen != screen && X11->solid_fills[i].picture) { |
3005 if (X11->solid_fills[i].screen != screen && X11->solid_fills[i].picture) { |
2984 XRenderFreePicture (X11->display, X11->solid_fills[i].picture); |
3006 XRenderFreePicture (X11->display, X11->solid_fills[i].picture); |
2985 X11->solid_fills[i].picture = 0; |
3007 X11->solid_fills[i].picture = 0; |
2986 } |
3008 } |
3028 xd->colormap = a.colormap; |
3050 xd->colormap = a.colormap; |
3029 xd->defaultColormap = (a.colormap == QX11Info::appColormap(xinfo->screen())); |
3051 xd->defaultColormap = (a.colormap == QX11Info::appColormap(xinfo->screen())); |
3030 xinfo->setX11Data(xd); |
3052 xinfo->setX11Data(xd); |
3031 } |
3053 } |
3032 |
3054 |
|
3055 void QWidgetPrivate::updateX11AcceptFocus() |
|
3056 { |
|
3057 Q_Q(QWidget); |
|
3058 if (!q->isWindow() || !q->internalWinId()) |
|
3059 return; |
|
3060 |
|
3061 XWMHints *h = XGetWMHints(X11->display, q->internalWinId()); |
|
3062 XWMHints wm_hints; |
|
3063 if (!h) { |
|
3064 memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy |
|
3065 h = &wm_hints; |
|
3066 } |
|
3067 h->flags |= InputHint; |
|
3068 h->input = q->testAttribute(Qt::WA_X11DoNotAcceptFocus) ? False : True; |
|
3069 |
|
3070 XSetWMHints(X11->display, q->internalWinId(), h); |
|
3071 if (h != &wm_hints) |
|
3072 XFree((char *)h); |
|
3073 } |
|
3074 |
3033 QT_END_NAMESPACE |
3075 QT_END_NAMESPACE |