Changeset 7264 in vbox for trunk/src/VBox/Additions/x11/xclient/clipboard.h
- Timestamp:
- Mar 4, 2008 9:14:24 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/xclient/clipboard.h
r6202 r7264 20 20 # define __Additions_linux_clipboard_h 21 21 22 #include "thread.h" /* for VBoxGuestThread */ 23 22 24 extern void vboxClipboardDisconnect (void); 23 25 extern int vboxClipboardConnect (void); 24 26 extern int vboxClipboardMain (void); 25 27 28 /** 29 * Display change request monitor thread function 30 */ 31 class VBoxGuestClipboardThread : public VBoxGuestThreadFunction 32 { 33 private: 34 // Copying or assigning a thread object is not sensible 35 VBoxGuestClipboardThread(const VBoxGuestClipboardThread&); 36 VBoxGuestClipboardThread& operator=(const VBoxGuestClipboardThread&); 37 38 // Private member variables 39 /** Have we been initialised yet? */ 40 bool mInit; 41 /** The thread object running us. */ 42 VBoxGuestThread *mThread; 43 public: 44 VBoxGuestClipboardThread() { mInit = false; } 45 /** 46 * Initialise the class and check that the guest supports dynamic resizing. 47 * @returns iprt status value 48 */ 49 int init(void) 50 { 51 if (mInit) 52 return true; 53 return vboxClipboardConnect(); 54 } 55 /** 56 * The actual thread function. 57 * 58 * @returns iprt status code as thread return value 59 * @param pParent the VBoxGuestThread running this thread function 60 */ 61 virtual int threadFunction(VBoxGuestThread *pThread) 62 { 63 vboxClipboardMain(); 64 return VINF_SUCCESS; 65 } 66 /** 67 * Send a signal to the thread function that it should exit 68 */ 69 virtual void stop(void) { vboxClipboardDisconnect(); } 70 }; 71 72 class VBoxGuestClipboard 73 { 74 private: 75 /** No copying or assignment. */ 76 VBoxGuestClipboard(const VBoxGuestClipboard &); 77 VBoxGuestClipboard& operator=(const VBoxGuestClipboard &); 78 79 /** Our monitor thread function */ 80 VBoxGuestClipboardThread mThreadFunction; 81 /** And the thread for the thread function */ 82 VBoxGuestThread mThread; 83 /** Are we initialised? */ 84 bool mInit; 85 public: 86 /** 87 * Initialise the class. 88 * @returns iprt status value 89 */ 90 int init(void) 91 { 92 int rc = mThreadFunction.init(); 93 if (RT_SUCCESS(rc)) 94 rc = mThread.start(); 95 if (RT_SUCCESS(rc)) 96 mInit = true; 97 return rc; 98 } 99 /** 100 * Uninitialise the class. 101 * @param cMillies how long to wait for the thread to stop 102 */ 103 void uninit(unsigned cMillies = RT_INDEFINITE_WAIT) 104 { 105 if (mInit) 106 mThread.stop(cMillies, NULL); 107 } 108 109 VBoxGuestClipboard() : mThread(&mThreadFunction, 0, RTTHREADTYPE_MSG_PUMP, 110 RTTHREADFLAGS_WAITABLE, "SHCLIP MAIN") 111 { mInit = false; } 112 ~VBoxGuestClipboard() 113 { 114 if (mInit) 115 try { 116 uninit(2000); 117 } catch (...) { } 118 } 119 }; 120 26 121 #endif /* __Additions_linux_clipboard_h not defined */
Note:
See TracChangeset
for help on using the changeset viewer.