"Fossies" - the Fresh Open Source Software Archive

Member "cb2bib-2.0.1/src/clipboardPoll.h" (12 Feb 2021, 2548 Bytes) of package /linux/privat/cb2bib-2.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "clipboardPoll.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.0.0_vs_2.0.1.

    1 /***************************************************************************
    2  *   clipboardPoll, modified by Pere Constans for cb2Bib, 2005
    3  *   constans@molspaces.com
    4  *   cb2Bib version 2.0.1. Licensed under the GNU GPL version 3.
    5  *
    6  *
    7  *   Author and Copyright (C) 2003 by Lubos Lunak <l.lunak@kde.org>
    8  *   Distributed under the GNU General Public License
    9  *
   10  *
   11  *   This file is part of the KDE project
   12  *   Copyright (C) 2003 by Lubos Lunak <l.lunak@kde.org>
   13  *
   14  *   This program is free software; you can redistribute it and/or
   15  *   modify it under the terms of the GNU General Public
   16  *   License as published by the Free Software Foundation; either
   17  *   version 2 of the License, or (at your option) any later version.
   18  *
   19  *   This program is distributed in the hope that it will be useful,
   20  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   21  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   22  *   General Public License for more details.
   23  *
   24  *   You should have received a copy of the GNU General Public License
   25  *   along with this program; see the file COPYING.  If not, write to
   26  *   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   27  *   Boston, MA 02111-1307, USA.
   28  ***************************************************************************/
   29 #ifndef CLIPBOARDPOLL_H
   30 #define CLIPBOARDPOLL_H
   31 
   32 
   33 #include <QApplication>
   34 #include <QTimer>
   35 #include <QWidget>
   36 #include <X11/Xlib.h>
   37 #undef Bool // Workaround for unqualified-id before 'int' for bool signal and slot
   38 
   39 
   40 /**
   41     @author Lubos Lunak
   42 */
   43 class clipboardPoll : public QWidget
   44 {
   45 
   46     Q_OBJECT
   47 
   48 public:
   49     explicit clipboardPoll(QWidget* parentw = 0);
   50     ~clipboardPoll();
   51 
   52     inline void startT(uint interval)
   53     {
   54         timer->start(interval);
   55     }
   56 
   57     inline void stopT()
   58     {
   59         timer->stop();
   60     }
   61 
   62 
   63 signals:
   64     void clipboardChanged(bool selectionMode);
   65 
   66 
   67 protected:
   68     virtual bool x11Event(XEvent*);
   69 
   70 
   71 private slots:
   72     void timeout();
   73 
   74 
   75 private:
   76     struct SelectionData
   77     {
   78         Atom atom;
   79         Atom sentinel_atom;
   80         Atom timestamp_atom;
   81         Window last_owner;
   82         bool owner_is_qt;
   83         Time last_change;
   84         bool waiting_for_timestamp;
   85         Time waiting_x_time;
   86     };
   87     Atom xa_clipboard;
   88     Atom xa_timestamp;
   89     bool changedTimestamp(SelectionData& sData, const XEvent& ev);
   90     bool checkTimestamp(SelectionData& sData);
   91     QTimer* timer;
   92     SelectionData clipboard;
   93     SelectionData selection;
   94     void updateQtOwnership(SelectionData& sData);
   95 };
   96 
   97 #endif