Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/kernel/qwidget_x11.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5050#include "qlayout.h"
    5151#include "qtextcodec.h"
    52 #include "qdatetime.h"
     52#include "qelapsedtimer.h"
    5353#include "qcursor.h"
    5454#include "qstack.h"
     
    353353    QApplication::flush();
    354354    XEvent ev;
    355     QTime t;
     355    QElapsedTimer t;
    356356    t.start();
    357357    static const int maximumWaitTime = 2000;
     
    781781        memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy
    782782        wm_hints.flags = InputHint | StateHint | WindowGroupHint;
    783         wm_hints.input = True;
     783        wm_hints.input = q->testAttribute(Qt::WA_X11DoNotAcceptFocus) ? False : True;
    784784        wm_hints.initial_state = NormalState;
    785785        wm_hints.window_group = X11->wm_client_leader;
     
    890890
    891891        }
    892     } else if (q->testAttribute(Qt::WA_SetCursor) && q->internalWinId()) {
     892    } else if (q->internalWinId()) {
    893893        qt_x11_enforce_cursor(q);
     894        if (QWidget *p = q->parentWidget()) // reset the cursor on the native parent
     895            qt_x11_enforce_cursor(p);
    894896    }
    895897
     
    10241026{
    10251027    Q_D(QWidget);
     1028    d->aboutToDestroy();
    10261029    if (!isWindow() && parentWidget())
    10271030        parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));
     
    11671170    // keep compatibility with previous versions, we need to preserve the created state
    11681171    // (but we recreate the winId for the widget being reparented, again for compatibility)
    1169     if (wasCreated || (!q->isWindow() && parent->testAttribute(Qt::WA_WState_Created)))
     1172    if (wasCreated)
    11701173        createWinId();
    11711174    if (q->isWindow() || (!parent || parent->isVisible()) || explicitlyHidden)
     
    16421645            X11->userTime = X11->time;
    16431646        qt_net_update_user_time(tlw, X11->userTime);
    1644         XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time);
     1647
     1648        if (X11->isSupportedByWM(ATOM(_NET_ACTIVE_WINDOW))
     1649            && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)) {
     1650            XEvent e;
     1651            e.xclient.type = ClientMessage;
     1652            e.xclient.message_type = ATOM(_NET_ACTIVE_WINDOW);
     1653            e.xclient.display = X11->display;
     1654            e.xclient.window = tlw->internalWinId();
     1655            e.xclient.format = 32;
     1656            e.xclient.data.l[0] = 1;     // 1 == application
     1657            e.xclient.data.l[1] = X11->userTime;
     1658            if (QWidget *aw = QApplication::activeWindow())
     1659                e.xclient.data.l[2] = aw->internalWinId();
     1660            else
     1661                e.xclient.data.l[2] = XNone;
     1662            e.xclient.data.l[3] = 0;
     1663            e.xclient.data.l[4] = 0;
     1664            XSendEvent(X11->display, RootWindow(X11->display, tlw->x11Info().screen()),
     1665                       false, SubstructureNotifyMask | SubstructureRedirectMask, &e);
     1666        } else {
     1667            if (!qt_widget_private(tlw)->topData()->waitingForMapNotify)
     1668                XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time);
     1669        }
    16451670    }
    16461671}
     
    19091934            if (flags & Qt::WindowStaysOnBottomHint)
    19101935                qWarning() << "QWidget: Incompatible window flags: the window can't be on top and on bottom at the same time";
    1911             netWmState.append(ATOM(_NET_WM_STATE_ABOVE));
    1912             netWmState.append(ATOM(_NET_WM_STATE_STAYS_ON_TOP));
     1936            if (!netWmState.contains(ATOM(_NET_WM_STATE_ABOVE)))
     1937                netWmState.append(ATOM(_NET_WM_STATE_ABOVE));
     1938            if (!netWmState.contains(ATOM(_NET_WM_STATE_STAYS_ON_TOP)))
     1939                netWmState.append(ATOM(_NET_WM_STATE_STAYS_ON_TOP));
    19131940        } else if (flags & Qt::WindowStaysOnBottomHint) {
    1914             netWmState.append(ATOM(_NET_WM_STATE_BELOW));
     1941            if (!netWmState.contains(ATOM(_NET_WM_STATE_BELOW)))
     1942                netWmState.append(ATOM(_NET_WM_STATE_BELOW));
    19151943        }
    19161944        if (q->isFullScreen()) {
    1917             netWmState.append(ATOM(_NET_WM_STATE_FULLSCREEN));
     1945            if (!netWmState.contains(ATOM(_NET_WM_STATE_FULLSCREEN)))
     1946                netWmState.append(ATOM(_NET_WM_STATE_FULLSCREEN));
    19181947        }
    19191948        if (q->isMaximized()) {
    1920             netWmState.append(ATOM(_NET_WM_STATE_MAXIMIZED_HORZ));
    1921             netWmState.append(ATOM(_NET_WM_STATE_MAXIMIZED_VERT));
     1949            if (!netWmState.contains(ATOM(_NET_WM_STATE_MAXIMIZED_HORZ)))
     1950                netWmState.append(ATOM(_NET_WM_STATE_MAXIMIZED_HORZ));
     1951            if (!netWmState.contains(ATOM(_NET_WM_STATE_MAXIMIZED_VERT)))
     1952                netWmState.append(ATOM(_NET_WM_STATE_MAXIMIZED_VERT));
    19221953        }
    19231954        if (data.window_modality != Qt::NonModal) {
    1924             netWmState.append(ATOM(_NET_WM_STATE_MODAL));
     1955            if (!netWmState.contains(ATOM(_NET_WM_STATE_MODAL)))
     1956                netWmState.append(ATOM(_NET_WM_STATE_MODAL));
    19251957        }
    19261958
     
    29793011    }
    29803012    // none found, replace one
    2981     int i = rand() % 16;
     3013    int i = qrand() % 16;
    29823014
    29833015    if (X11->solid_fills[i].screen != screen && X11->solid_fills[i].picture) {
     
    30313063}
    30323064
     3065void QWidgetPrivate::updateX11AcceptFocus()
     3066{
     3067    Q_Q(QWidget);
     3068    if (!q->isWindow() || !q->internalWinId())
     3069        return;
     3070
     3071    XWMHints *h = XGetWMHints(X11->display, q->internalWinId());
     3072    XWMHints wm_hints;
     3073    if (!h) {
     3074        memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy
     3075        h = &wm_hints;
     3076    }
     3077    h->flags |= InputHint;
     3078    h->input = q->testAttribute(Qt::WA_X11DoNotAcceptFocus) ? False : True;
     3079
     3080    XSetWMHints(X11->display, q->internalWinId(), h);
     3081    if (h != &wm_hints)
     3082        XFree((char *)h);
     3083}
     3084
    30333085QT_END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.