[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/klipper
From:       Luboš Luňák <l.lunak () kde ! org>
Date:       2010-02-11 16:26:02
Message-ID: 1265905562.844133.19668.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1088793 by lunakl:

http://bugreports.qt.nokia.com/browse/QTBUG-8157
QClipboard is a bit broken again, shalalala.



 M  +61 -0     klipper.cpp  
 M  +15 -0     klipper.h  


--- trunk/KDE/kdebase/workspace/klipper/klipper.cpp #1088792:1088793
@@ -22,6 +22,8 @@
    Boston, MA 02110-1301, USA.
 */
 
+#include <config-X11.h>
+
 #include <QtDBus/QDBusConnection>
 
 #include <kaboutdata.h>
@@ -53,7 +55,10 @@
 #ifdef Q_WS_X11
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
+#ifdef HAVE_XFIXES
+#include <X11/extensions/Xfixes.h>
 #endif
+#endif
 
 //#define NOISY_KLIPPER
 #include <KPassivePopup>
@@ -128,6 +133,8 @@
 
     connect( m_clip, SIGNAL(changed(QClipboard::Mode)),
              this, SLOT( newClipData( QClipboard::Mode) ) );
+    connect( &m_empty_detector, SIGNAL(changed(QClipboard::Mode)),
+             this, SLOT( newClipData( QClipboard::Mode) ) );
 
     connect( &m_overflowClearTimer, SIGNAL( timeout()), SLOT( slotClearOverflow()));
 
@@ -1177,4 +1184,58 @@
     return rv;
 }
 
+// http://bugreports.qt.nokia.com/browse/QTBUG-8157
+#if KDE_IS_VERSION( 4, 4, 85 )
+#warning Check if this is still needed, hopefully not.
+#endif
+KlipperEmptyDetector::KlipperEmptyDetector()
+: m_xfixes_event_base( -1 )
+, m_xa_clipboard( None )
+{
+#ifdef HAVE_XFIXES
+    m_xa_clipboard = XInternAtom( QX11Info::display(), "CLIPBOARD", False );
+    kapp->installX11EventFilter( this );
+    int dummy;
+    if( XFixesQueryExtension( QX11Info::display(), &m_xfixes_event_base, &dummy ))
+    {
+        XFixesSelectSelectionInput( QX11Info::display(), QX11Info::appRootWindow( 0 \
), XA_PRIMARY, +            XFixesSetSelectionOwnerNotifyMask |
+            XFixesSelectionWindowDestroyNotifyMask |
+            XFixesSelectionClientCloseNotifyMask );
+        XFixesSelectSelectionInput( QX11Info::display(), QX11Info::appRootWindow( 0 \
), m_xa_clipboard, +            XFixesSetSelectionOwnerNotifyMask |
+            XFixesSelectionWindowDestroyNotifyMask |
+            XFixesSelectionClientCloseNotifyMask );
+    }
+#endif
+}
+
+bool KlipperEmptyDetector::x11Event( XEvent* e )
+{
+#ifdef HAVE_XFIXES
+    if( m_xfixes_event_base != -1 && e->type == m_xfixes_event_base + \
XFixesSelectionNotify ) +    {
+        XFixesSelectionNotifyEvent* ev = reinterpret_cast< \
XFixesSelectionNotifyEvent* >( e ); +        if( ev->subtype == \
XFixesSelectionWindowDestroyNotify || ev->subtype == XFixesSelectionClientCloseNotify \
) +        {
+            if( ev->selection == XA_PRIMARY && !kapp->clipboard()->ownsSelection())
+            {
+#ifdef NOISY_KLIPPER
+                kDebug() << "Selection lost";
+#endif
+                emit changed( QClipboard::Selection );
+            }
+            else if( ev->selection == m_xa_clipboard && \
!kapp->clipboard()->ownsClipboard()) +            {
+#ifdef NOISY_KLIPPER
+                kDebug() << "Clipboard lost";
+#endif
+                emit changed( QClipboard::Clipboard );
+            }
+        }
+    }
+#endif
+    return false;
+}
+
 #include "klipper.moc"
--- trunk/KDE/kdebase/workspace/klipper/klipper.h #1088792:1088793
@@ -45,6 +45,20 @@
 class HistoryItem;
 class KlipperSessionManager;
 
+class KlipperEmptyDetector : public QWidget
+{
+Q_OBJECT
+public:
+    KlipperEmptyDetector();
+signals:
+    void changed( QClipboard::Mode m );
+protected:
+    virtual bool x11Event( XEvent* e );
+private:
+    int m_xfixes_event_base;
+    unsigned int m_xa_clipboard;
+};
+
 class Klipper : public QObject
 {
   Q_OBJECT
@@ -220,6 +234,7 @@
     QString cycleText() const;
     KlipperSessionManager* m_session_managed;
     KActionCollection *m_collection;
+    KlipperEmptyDetector m_empty_detector;
 };
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic