diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 4aed2c8219774f5d797760606b8489a92ddc5163 (patch) | |
tree | 3f8c130f7d269626bf6a9447407ef6c35954426a /kdesktop/pixmapserver.h | |
download | tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdesktop/pixmapserver.h')
-rw-r--r-- | kdesktop/pixmapserver.h | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/kdesktop/pixmapserver.h b/kdesktop/pixmapserver.h new file mode 100644 index 000000000..e0f871988 --- /dev/null +++ b/kdesktop/pixmapserver.h @@ -0,0 +1,124 @@ +/* vi: ts=8 sts=4 sw=4 + * + * This file is part of the KDE project, module kdesktop. + * Copyright (C) 1999 Geert Jansen <[email protected]> + * + * You can Freely distribute this program under the GNU General Public + * License. See the file "COPYING" for the exact licensing terms. + */ + +#ifndef __PixmapServer_h_Included__ +#define __PixmapServer_h_Included__ + +#include <qwindowdefs.h> + +#include <qwidget.h> +#include <qmap.h> + +#include <X11/X.h> +#include <X11/Xlib.h> + +/** + * Used internally by KPixmapServer. + */ + +struct KPixmapInode +{ + Qt::HANDLE handle; + Atom selection; +}; + +struct KPixmapData +{ + QPixmap *pixmap; + int usecount; + int refcount; +}; + +struct KSelectionInode +{ + Qt::HANDLE handle; + QString name; +}; + +/** + * KPixmapServer: Share pixmaps between X clients with deletion and + * multi-server capabilities. + * The sharing is implemented using X11 Selections. + * + * @author Geert Jansen <[email protected]> + */ +class KPixmapServer: public QWidget +{ + Q_OBJECT + +public: + KPixmapServer(); + ~KPixmapServer(); + + /** + * Adds a pixmap to this server. This will make it available to all + * other X clients on the current display. + * + * You must never delete a pixmap that you add()'ed. The pixmap is + * deleted when you call remove() and after all clients have stopped + * using it. + * + * You can add the same pixmap under multiple names. + * + * @param name An X11-wide unique identifier for the pixmap. + * @param pm A pointer to the pixmap. + * @param overwrite Should an pixmap with the same name be overwritten? + */ + void add(QString name, QPixmap *pm, bool overwrite=true); + + /** + * Remove a pixmap from the server. This will delete the pixmap after + * all clients have stopped using it. + * + * @param name The name of the shared pixmap. + */ + void remove(QString name); + + /** + * List all pixmaps currently served by this server. + * + * @return A QStringList containing all the shared pixmaps. + */ + QStringList list(); + + /** + * Re-set ownership of the selection providing the shared pixmap. + * + * @param name The name of the shared pixmap. + */ + void setOwner(QString name); + +signals: + /** + * This signal is emitted when the selection providing the named pixmap + * is disowned. This means that said pixmap won't be served anymore by + * this server, though it can be served by another. You can re-aqcuire + * the selection by calling setOwner(). + */ + void selectionCleared(QString name); + +protected: + bool x11Event(XEvent *); + +private: + Atom pixmap; + + QMap<QString,KPixmapInode> m_Names; + QMap<Atom,KSelectionInode> m_Selections; + QMap<HANDLE,KPixmapData> m_Data; + QMap<Atom,HANDLE> m_Active; + + typedef QMap<QString,KPixmapInode>::Iterator NameIterator; + typedef QMap<Atom,KSelectionInode>::Iterator SelectionIterator; + typedef QMap<HANDLE,KPixmapData>::Iterator DataIterator; + typedef QMap<Atom,HANDLE>::Iterator AtomIterator; +}; + + +#endif // __PixmapServer_h_Included__ |