~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to klipper/clipboardpoll.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*-
 
2
/* This file is part of the KDE project
 
3
   Copyright (C) 2003 by Lubos Lunak <l.lunak@kde.org>
 
4
 
 
5
   This program is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2 of the License, or (at your option) any later version.
 
9
 
 
10
   This program is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
    General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU General Public License
 
16
   along with this program; see the file COPYING.  If not, write to
 
17
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
18
   Boston, MA 02110-1301, USA.
 
19
*/
 
20
#ifndef _CLIPBOARDPOLL_H_
 
21
#define _CLIPBOARDPOLL_H_
 
22
#ifdef Q_WS_X11
 
23
 
 
24
#include <QWidget>
 
25
#include <QTimer>
 
26
#include <X11/Xlib.h>
 
27
#include <fixx11h.h>
 
28
 
 
29
class ClipboardPoll
 
30
    : public QWidget
 
31
    {
 
32
    Q_OBJECT
 
33
    public:
 
34
        ClipboardPoll();
 
35
    Q_SIGNALS:
 
36
        void clipboardChanged( bool selectionMode );
 
37
    protected:
 
38
        virtual bool x11Event( XEvent* );
 
39
    private Q_SLOTS:
 
40
        void timeout();
 
41
        void qtSelectionChanged();
 
42
        void qtClipboardChanged();
 
43
    private:
 
44
        struct SelectionData
 
45
        {
 
46
            Atom atom;
 
47
            Atom sentinel_atom;
 
48
            Atom timestamp_atom;
 
49
            Window last_owner;
 
50
            bool owner_is_qt;
 
51
            Time last_change;
 
52
            bool waiting_for_timestamp;
 
53
            Time waiting_x_time;
 
54
        };
 
55
        void updateQtOwnership( SelectionData& data );
 
56
        bool checkTimestamp( SelectionData& data );
 
57
        bool changedTimestamp( SelectionData& data, const XEvent& e );
 
58
        void initPolling();
 
59
        QTimer m_timer;
 
60
        SelectionData m_selection;
 
61
        SelectionData m_clipboard;
 
62
        Atom m_xa_clipboard;
 
63
        Atom m_xa_timestamp;
 
64
        int m_xfixes_event_base;
 
65
    };
 
66
    
 
67
#endif
 
68
#endif