kmanagerselection.h
00001 /**************************************************************************** 00002 00003 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org> 00004 00005 Permission is hereby granted, free of charge, to any person obtaining a 00006 copy of this software and associated documentation files (the "Software"), 00007 to deal in the Software without restriction, including without limitation 00008 the rights to use, copy, modify, merge, publish, distribute, sublicense, 00009 and/or sell copies of the Software, and to permit persons to whom the 00010 Software is furnished to do so, subject to the following conditions: 00011 00012 The above copyright notice and this permission notice shall be included in 00013 all copies or substantial portions of the Software. 00014 00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00018 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00019 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00020 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00021 DEALINGS IN THE SOFTWARE. 00022 00023 ****************************************************************************/ 00024 00025 #ifndef __KMANAGERSELECTION_H 00026 #define __KMANAGERSELECTION_H 00027 00028 #include <tqobject.h> 00029 #include <kdelibs_export.h> 00030 00031 #ifdef Q_MOC_RUN 00032 #define Q_WS_X11 00033 #endif // Q_MOC_RUN 00034 00035 #ifdef Q_WS_X11 // FIXME(E) 00036 00037 #include <X11/Xlib.h> 00038 00039 class KSelectionOwnerPrivate; 00040 00050 class KDECORE_EXPORT KSelectionOwner 00051 : public TQObject 00052 { 00053 Q_OBJECT 00054 public: 00063 KSelectionOwner( Atom selection, int screen = -1, TQObject* parent = NULL ); 00073 KSelectionOwner( const char* selection, int screen = -1, TQObject* parent = NULL ); 00077 virtual ~KSelectionOwner(); 00088 bool claim( bool force, bool force_kill = true ); 00092 void release(); 00097 Window ownerWindow() const; // None if not owning the selection 00101 bool filterEvent( XEvent* ev_P ); // internal 00102 signals: 00109 void lostOwnership(); 00110 protected: 00115 virtual bool handleMessage( XEvent* ev ); 00125 virtual bool genericReply( Atom target, Atom property, Window requestor ); 00131 virtual void replyTargets( Atom property, Window requestor ); 00138 virtual void getAtoms(); 00144 void setData( long extra1, long extra2 ); 00145 private: 00146 void filter_selection_request( XSelectionRequestEvent& ev_P ); 00147 bool handle_selection( Atom target_P, Atom property_P, Window requestor_P ); 00148 const Atom selection; 00149 const int screen; 00150 Window window; 00151 Time timestamp; 00152 long extra1, extra2; 00153 static Atom manager_atom; 00154 static Atom xa_multiple; 00155 static Atom xa_targets; 00156 static Atom xa_timestamp; 00157 protected: 00158 virtual void virtual_hook( int id, void* data ); 00159 private: 00160 KSelectionOwnerPrivate* d; 00161 }; 00162 00163 class KSelectionWatcherPrivate; 00164 00173 class KDECORE_EXPORT KSelectionWatcher 00174 : public TQObject 00175 { 00176 Q_OBJECT 00177 public: 00186 KSelectionWatcher( Atom selection, int screen = -1, TQObject* parent = NULL ); 00196 KSelectionWatcher( const char* selection, int screen = -1, TQObject* parent = NULL ); 00197 virtual ~KSelectionWatcher(); 00201 Window owner(); 00205 void filterEvent( XEvent* ev_P ); // internal 00206 signals: 00212 void newOwner( Window owner ); 00219 void lostOwner(); 00220 private: 00221 void init(); 00222 const Atom selection; 00223 const int screen; 00224 Window selection_owner; 00225 static Atom manager_atom; 00226 protected: 00227 virtual void virtual_hook( int id, void* data ); 00228 private: 00229 KSelectionWatcherPrivate* d; 00230 }; 00231 00232 #endif 00233 #endif