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/qdnd_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)
     
    5252#include "qdesktopwidget.h"
    5353#include "qevent.h"
    54 #include "qdatetime.h"
    5554#include "qiodevice.h"
    5655#include "qpointer.h"
    5756#include "qcursor.h"
     57#include "qelapsedtimer.h"
    5858#include "qvariant.h"
    5959#include "qvector.h"
     
    6565
    6666#include "qdnd_p.h"
     67#include "qapplication_p.h"
    6768#include "qt_x11_p.h"
    6869#include "qx11info_x11.h"
     
    11121113}
    11131114
    1114 
     1115// TODO: remove and use QApplication::currentKeyboardModifiers() in Qt 4.8.
     1116static Qt::KeyboardModifiers currentKeyboardModifiers()
     1117{
     1118    Window root;
     1119    Window child;
     1120    int root_x, root_y, win_x, win_y;
     1121    uint keybstate;
     1122    for (int i = 0; i < ScreenCount(X11->display); ++i) {
     1123        if (XQueryPointer(X11->display, QX11Info::appRootWindow(i), &root, &child,
     1124                          &root_x, &root_y, &win_x, &win_y, &keybstate))
     1125            return X11->translateModifiers(keybstate & 0x00ff);
     1126    }
     1127    return 0;
     1128}
    11151129
    11161130void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive)
     
    11591173        if (!dropData)
    11601174            dropData = (manager->object) ? manager->dragPrivate()->data : manager->dropData;
     1175
     1176        // Drop coming from another app? Update keyboard modifiers.
     1177        if (!qt_xdnd_dragging) {
     1178            QApplicationPrivate::modifier_buttons = currentKeyboardModifiers();
     1179        }
    11611180
    11621181        QDropEvent de(qt_xdnd_current_position, possible_actions, dropData,
     
    13001319    }
    13011320
     1321    if (e->type() == QEvent::ShortcutOverride) {
     1322        // prevent accelerators from firing while dragging
     1323        e->accept();
     1324        return true;
     1325    }
     1326
    13021327    if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) {
    13031328        QKeyEvent *ke = ((QKeyEvent*)e);
     
    13411366#ifndef QT_NO_CURSOR
    13421367        noDropCursor = new QCursor(Qt::ForbiddenCursor);
    1343         moveCursor = new QCursor(dragCursor(Qt::MoveAction), 0,0);
    1344         copyCursor = new QCursor(dragCursor(Qt::CopyAction), 0,0);
    1345         linkCursor = new QCursor(dragCursor(Qt::LinkAction), 0,0);
     1368        moveCursor = new QCursor(Qt::DragMoveCursor);
     1369        copyCursor = new QCursor(Qt::DragCopyCursor);
     1370        linkCursor = new QCursor(Qt::DragLinkCursor);
    13461371#endif
    13471372    }
     
    18631888        Atom type;
    18641889
    1865         if (X11->clipboardReadProperty(tw->effectiveWinId(), ATOM(XdndSelection), true, &result, 0, &type, 0, false)) {
     1890        if (X11->clipboardReadProperty(tw->effectiveWinId(), ATOM(XdndSelection), true, &result, 0, &type, 0)) {
    18661891            if (type == ATOM(INCR)) {
    18671892                int nbytes = result.size() >= 4 ? *((int*)result.data()) : 0;
     
    19121937        QApplication::flush();
    19131938
    1914         QTime started = QTime::currentTime();
    1915         QTime now = started;
     1939        QElapsedTimer timer;
     1940        timer.start();
    19161941        do {
    19171942            XEvent event;
    19181943            if (XCheckTypedEvent(X11->display, ClientMessage, &event))
    19191944                qApp->x11ProcessEvent(&event);
    1920 
    1921             now = QTime::currentTime();
    1922             if (started > now) // crossed midnight
    1923                 started = now;
    19241945
    19251946            // sleep 50 ms, so we don't use up CPU cycles all the time.
     
    19281949            usleep_tv.tv_usec = 50000;
    19291950            select(0, 0, 0, 0, &usleep_tv);
    1930         } while (object && started.msecsTo(now) < 1000);
     1951        } while (object && timer.hasExpired(1000));
    19311952    }
    19321953
Note: See TracChangeset for help on using the changeset viewer.