[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/klipper
From: Esben Mose Hansen <kde () mosehansen ! dk>
Date: 2009-11-28 11:07:16
Message-ID: 1259406436.149652.22807.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1055587 by esben:
Remove old XFixes support, which is now supported directly by QClipboard.
Also doubles the timeout for checking whether the clipboard is empty, to avoid false \
positives.
BUG: 166606
M +4 -0 clipboardpoll.cpp
M +15 -12 klipper.cpp
M +2 -3 klipper.h
--- trunk/KDE/kdebase/workspace/klipper/clipboardpoll.cpp #1055586:1055587
@@ -42,6 +42,10 @@
/*
+ After Qt 4.something, this part worked poorly. Meanwhile, XFixes was integrated \
into QClipboard, + and has become pretty ubiquitous, so I'm risking retiring this \
code. The alternative is essentially + reimplementation of QClipboard, and the \
duplication would help noone. (Esben Mose Hansen, 2009-11-28 11:44:43) +
The polling magic:
There's no way with X11 how to find out if the selection has changed (unless its \
ownership
--- trunk/KDE/kdebase/workspace/klipper/klipper.cpp #1055586:1055587
@@ -22,7 +22,6 @@
Boston, MA 02110-1301, USA.
*/
-#include <QClipboard>
#include <QtDBus/QDBusConnection>
#include <kaboutdata.h>
@@ -44,7 +43,6 @@
#include "klippersettings.h"
#include "urlgrabber.h"
#include "version.h"
-#include "clipboardpoll.h"
#include "history.h"
#include "historyitem.h"
#include "historystringitem.h"
@@ -126,6 +124,9 @@
updateTimestamp(); // read initial X user time
m_clip = kapp->clipboard();
+ connect( m_clip, SIGNAL(changed(QClipboard::Mode)),
+ this, SLOT( newClipData( QClipboard::Mode) ) );
+
connect( &m_overflowClearTimer, SIGNAL( timeout()), SLOT( slotClearOverflow()));
m_pendingCheckTimer.setSingleShot( true );
@@ -179,10 +180,6 @@
// if it's too old, drop it and just use load history
readProperties(m_config.data());
- m_poll = new ClipboardPoll;
- connect( m_poll, SIGNAL( clipboardChanged( bool ) ),
- this, SLOT( newClipData( bool ) ) );
-
KAction* a = m_collection->addAction("show_klipper_popup");
a->setText(i18n("Show Klipper Popup-Menu"));
a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::Key_V));
@@ -234,7 +231,6 @@
Klipper::~Klipper()
{
- delete m_poll;
delete m_session_managed;
delete m_showTimer;
delete m_hideTimer;
@@ -650,7 +646,7 @@
}
-void Klipper::newClipData( bool selectionMode )
+void Klipper::newClipData( QClipboard::Mode mode )
{
if ( m_locklevel ) {
return;
@@ -659,7 +655,7 @@
if( blockFetchingNewData())
return;
- checkClipData( selectionMode );
+ checkClipData( mode == QClipboard::Selection ? true : false );
}
@@ -719,7 +715,7 @@
return;
m_pendingContentsCheck = false; // blockFetchingNewData() will be called again
updateTimestamp();
- newClipData( true ); // always selection
+ newClipData( QClipboard::Selection ); // always selection
}
void Klipper::checkClipData( bool selectionMode )
@@ -777,8 +773,15 @@
// TODO: Rewrite to Qt4 !!!
//int lastSerialNo = selectionMode ? m_lastSelection : m_lastClipboard;
//bool changed = data->serialNumber() != lastSerialNo;
- bool changed = true; // ### FIXME
+ bool changed = true; // ### FIXME (only relevant under polling, might be better \
to simply remove polling and rely on XFixes) bool clipEmpty = \
data->formats().isEmpty(); + if (clipEmpty) {
+ // Might be a timeout. Try again
+ clipEmpty = data->formats().isEmpty();
+#ifdef NOISY_KLIPPER
+ kDebug() << "was empty. Retried, now " << (clipEmpty?" still empty":" no \
longer empty"); +#endif
+ }
if ( changed && clipEmpty && m_bNoNullClipboard ) {
const HistoryItem* top = history()->first();
@@ -883,7 +886,7 @@
if( m_overflowCounter > MAX_CLIPBOARD_CHANGES ) {
kDebug() << "App owning the clipboard/selection is lame";
// update to the latest data - this unfortunately may trigger the problem \
again
- newClipData( true ); // Always the selection.
+ newClipData( QClipboard::Selection ); // Always the selection.
}
m_overflowCounter = 0;
}
--- trunk/KDE/kdebase/workspace/klipper/klipper.h #1055586:1055587
@@ -25,6 +25,7 @@
#include <QKeyEvent>
#include <QMenu>
#include <QTimer>
+#include <QClipboard>
#include <KApplication>
#include <KIcon>
@@ -37,7 +38,6 @@
class KAboutData;
class KActionCollection;
class URLGrabber;
-class ClipboardPoll;
class QTime;
class History;
class QAction;
@@ -148,7 +148,7 @@
void disableURLGrabber();
private Q_SLOTS:
- void newClipData( bool selectionMode );
+ void newClipData( QClipboard::Mode );
void slotClearClipboard();
void slotSelectionChanged() {
@@ -214,7 +214,6 @@
QTimer m_overflowClearTimer;
QTimer m_pendingCheckTimer;
bool m_pendingContentsCheck;
- ClipboardPoll* m_poll;
static KAboutData* m_about_data;
bool blockFetchingNewData();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic