Changeset 846 for trunk/src/gui/kernel/qclipboard_x11.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/kernel/qclipboard_x11.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 66 66 #include "qdesktopwidget.h" 67 67 #include "qbitmap.h" 68 #include "qdatetime.h"69 68 #include "qiodevice.h" 70 69 #include "qbuffer.h" … … 77 76 #include "qx11info_x11.h" 78 77 #include "qimagewriter.h" 78 #include "qelapsedtimer.h" 79 79 #include "qvariant.h" 80 80 #include "qdnd_p.h" … … 133 133 requestor->createWinId(); 134 134 requestor->setObjectName(QLatin1String("internal clipboard requestor")); 135 // We don t need this internal widgets to appear in QApplication::topLevelWidgets()135 // We don't need this internal widgets to appear in QApplication::topLevelWidgets() 136 136 if (QWidgetPrivate::allWidgets) { 137 137 QWidgetPrivate::allWidgets->remove(owner); … … 457 457 if (data.timestamp == CurrentTime) { 458 458 setupOwner(); 459 int dummy = 0; 459 // We need this value just for completeness, we don't use it. 460 long dummy = 0; 460 461 Window ownerId = owner->internalWinId(); 461 462 XChangeProperty(X11->display, ownerId, … … 517 518 bool QX11Data::clipboardWaitForEvent(Window win, int type, XEvent *event, int timeout) 518 519 { 519 QTime started = QTime::currentTime(); 520 QTime now = started; 520 QElapsedTimer started; 521 started.start(); 522 QElapsedTimer now = started; 521 523 522 524 if (QAbstractEventDispatcher::instance()->inherits("QtMotif") … … 546 548 usleep(50000); 547 549 548 now = QTime::currentTime(); 549 if (started > now) // crossed midnight 550 started = now; 550 now.start(); 551 551 552 552 QEventLoop::ProcessEventsFlags flags(QEventLoop::ExcludeUserInputEvents … … 577 577 qApp->x11ProcessEvent(&e); 578 578 579 now = QTime::currentTime(); 580 if ( started > now ) // crossed midnight 581 started = now; 579 now.start(); 582 580 583 581 XFlush(X11->display); … … 598 596 599 597 bool QX11Data::clipboardReadProperty(Window win, Atom property, bool deleteProperty, 600 QByteArray *buffer, int *size, Atom *type, int *format , bool nullterm)598 QByteArray *buffer, int *size, Atom *type, int *format) 601 599 { 602 600 int maxsize = maxSelectionIncr(display); … … 644 642 } 645 643 646 int newSize = proplen + (nullterm ? 1 : 0);644 int newSize = proplen; 647 645 buffer->resize(newSize); 648 646 … … 650 648 VDEBUG("QClipboard: read_property(): buffer resized to %d", buffer->size()); 651 649 652 if (ok ) {650 if (ok && newSize) { 653 651 // could allocate buffer 654 652 … … 686 684 textprop.encoding = *type; 687 685 textprop.format = *format; 688 textprop.nitems = length;686 textprop.nitems = buffer_offset; 689 687 textprop.value = (unsigned char *) buffer->data(); 690 688 … … 693 691 if (XmbTextPropertyToTextList(display, &textprop, &list_ret, 694 692 &count) == Success && count && list_ret) { 695 offset = strlen(list_ret[0]);696 buffer->resize(offset + (nullterm ? 1 : 0));693 offset = buffer_offset = strlen(list_ret[0]); 694 buffer->resize(offset); 697 695 memcpy(buffer->data(), list_ret[0], offset); 698 696 } 699 697 if (list_ret) XFreeStringList(list_ret); 700 698 } 701 702 // zero-terminate (for text)703 if (nullterm)704 buffer->data()[buffer_offset] = '\0';705 699 } 706 700 … … 745 739 event.xproperty.state != PropertyNewValue) 746 740 continue; 747 if (X11->clipboardReadProperty(win, property, true, &tmp_buf, &length, 0, 0 , false)) {741 if (X11->clipboardReadProperty(win, property, true, &tmp_buf, &length, 0, 0)) { 748 742 if (length == 0) { // no more data, we're done 749 743 if (nullterm) { … … 776 770 requestor = new QWidget(0); 777 771 requestor->setObjectName(QLatin1String("internal clipboard requestor")); 778 // We don t need this internal widget to appear in QApplication::topLevelWidgets()772 // We don't need this internal widget to appear in QApplication::topLevelWidgets() 779 773 if (QWidgetPrivate::allWidgets) 780 774 QWidgetPrivate::allWidgets->remove(requestor); … … 839 833 840 834 (void)new QClipboardINCRTransaction(window, property, atomFormat, dataFormat, data, increment); 841 return ATOM(INCR);835 return property; 842 836 } 843 837 … … 1073 1067 if (req->property == XNone 1074 1068 || !X11->clipboardReadProperty(req->requestor, req->property, false, &multi_data, 1075 0, &multi_type, &multi_format , 0)1069 0, &multi_type, &multi_format) 1076 1070 || multi_format != 32) { 1077 1071 // MULTIPLE property not formatted correctly … … 1295 1289 XSelectInput(dpy, win, PropertyChangeMask); 1296 1290 1297 if (X11->clipboardReadProperty(win, ATOM(_QT_SELECTION), true, &buf, 0, &type, 0 , false)) {1291 if (X11->clipboardReadProperty(win, ATOM(_QT_SELECTION), true, &buf, 0, &type, 0)) { 1298 1292 if (type == ATOM(INCR)) { 1299 1293 int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0; … … 1522 1516 #endif 1523 1517 if (!owner || (selectionOwner && selectionOwner != owner->internalWinId()) || 1524 (!selectionOwner && d->timestamp != CurrentTime && d->timestamp < timestamp))1518 (!selectionOwner && (d->timestamp == CurrentTime || d->timestamp < timestamp))) 1525 1519 return qt_check_selection_sentinel(); 1526 1520 return false; … … 1536 1530 #endif 1537 1531 if (!owner || (clipboardOwner && clipboardOwner != owner->internalWinId()) || 1538 (!clipboardOwner && d->timestamp != CurrentTime && d->timestamp < timestamp))1532 (!clipboardOwner && (d->timestamp == CurrentTime || d->timestamp < timestamp))) 1539 1533 return qt_check_clipboard_sentinel(); 1540 1534 return false;
Note:
See TracChangeset
for help on using the changeset viewer.