00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CMSWINDOWSDESKS_H
00020 #define CMSWINDOWSDESKS_H
00021
00022 #include "CSynergyHook.h"
00023 #include "KeyTypes.h"
00024 #include "MouseTypes.h"
00025 #include "OptionTypes.h"
00026 #include "CCondVar.h"
00027 #include "CMutex.h"
00028 #include "CString.h"
00029 #include "stdmap.h"
00030 #define WIN32_LEAN_AND_MEAN
00031 #include <windows.h>
00032
00033 class CEvent;
00034 class CEventQueueTimer;
00035 class CThread;
00036 class IJob;
00037 class IScreenSaver;
00038 class IEventQueue;
00039
00041
00056 class CMSWindowsDesks {
00057 public:
00059
00067 CMSWindowsDesks(
00068 bool isPrimary, bool noHooks, HINSTANCE hookLibrary,
00069 const IScreenSaver* screensaver, IEventQueue& eventQueue,
00070 IJob* updateKeys, bool stopOnDeskSwitch);
00071 ~CMSWindowsDesks();
00072
00074
00075
00077
00083 void enable();
00084
00086
00089 void disable();
00090
00092
00095 void enter();
00096
00098
00101 void leave(HKL keyLayout);
00102
00104
00107 void resetOptions();
00108
00110
00114 void setOptions(const COptionsList& options);
00115
00117
00121 void updateKeys();
00122
00124
00127 void setShape(SInt32 x, SInt32 y,
00128 SInt32 width, SInt32 height,
00129 SInt32 xCenter, SInt32 yCenter, bool isMultimon);
00130
00132
00137 void installScreensaverHooks(bool install);
00138
00140
00143 void fakeInputBegin();
00144
00146
00149 void fakeInputEnd();
00150
00152
00153
00154
00156
00159 void getCursorPos(SInt32& x, SInt32& y) const;
00160
00162
00165 void fakeKeyEvent(KeyButton button, UINT virtualKey,
00166 bool press, bool isAutoRepeat) const;
00167
00169
00172 void fakeMouseButton(ButtonID id, bool press);
00173
00175
00178 void fakeMouseMove(SInt32 x, SInt32 y) const;
00179
00181
00184 void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const;
00185
00187
00190 void fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const;
00191
00193
00194 private:
00195 class CDesk {
00196 public:
00197 CString m_name;
00198 CThread* m_thread;
00199 DWORD m_threadID;
00200 DWORD m_targetID;
00201 HDESK m_desk;
00202 HWND m_window;
00203 HWND m_foregroundWindow;
00204 bool m_lowLevel;
00205 };
00206 typedef std::map<CString, CDesk*> CDesks;
00207
00208
00209 void queryHookLibrary(HINSTANCE hookLibrary);
00210 HCURSOR createBlankCursor() const;
00211 void destroyCursor(HCURSOR cursor) const;
00212 ATOM createDeskWindowClass(bool isPrimary) const;
00213 void destroyClass(ATOM windowClass) const;
00214 HWND createWindow(ATOM windowClass, const char* name) const;
00215 void destroyWindow(HWND) const;
00216
00217
00218 void deskMouseMove(SInt32 x, SInt32 y) const;
00219 void deskMouseRelativeMove(SInt32 dx, SInt32 dy) const;
00220 void deskEnter(CDesk* desk);
00221 void deskLeave(CDesk* desk, HKL keyLayout);
00222 void deskThread(void* vdesk);
00223 void xinputThread();
00224
00225
00226 CDesk* addDesk(const CString& name, HDESK hdesk);
00227 void removeDesks();
00228 void checkDesk();
00229 bool isDeskAccessible(const CDesk* desk) const;
00230 void handleCheckDesk(const CEvent& event, void*);
00231
00232
00233 void waitForDesk() const;
00234 void sendMessage(UINT, WPARAM, LPARAM) const;
00235
00236
00237 HWND getForegroundWindow() const;
00238
00239
00240 HDESK openInputDesktop();
00241 void closeDesktop(HDESK);
00242 CString getDesktopName(HDESK);
00243
00244
00245 static LRESULT CALLBACK primaryDeskProc(HWND, UINT, WPARAM, LPARAM);
00246 static LRESULT CALLBACK secondaryDeskProc(HWND, UINT, WPARAM, LPARAM);
00247
00248 private:
00249
00250 bool m_isPrimary;
00251
00252
00253 bool m_noHooks;
00254
00255
00256 bool m_is95Family;
00257
00258
00259 bool m_isModernFamily;
00260
00261
00262 bool m_isOnScreen;
00263
00264
00265 ATOM m_deskClass;
00266 HCURSOR m_cursor;
00267
00268
00269 SInt32 m_x, m_y;
00270 SInt32 m_w, m_h;
00271 SInt32 m_xCenter, m_yCenter;
00272
00273
00274 bool m_multimon;
00275
00276
00277 CEventQueueTimer* m_timer;
00278
00279
00280 DWORD m_threadID;
00281 const IScreenSaver* m_screensaver;
00282 bool m_screensaverNotify;
00283
00284
00285 CDesk* m_activeDesk;
00286 CString m_activeDeskName;
00287
00288
00289 CMutex m_mutex;
00290 CCondVar<bool> m_deskReady;
00291 CDesks m_desks;
00292
00293
00294 InstallFunc m_install;
00295 UninstallFunc m_uninstall;
00296 InstallScreenSaverFunc
00297 m_installScreensaver;
00298 UninstallScreenSaverFunc
00299 m_uninstallScreensaver;
00300
00301
00302 IJob* m_updateKeys;
00303 HKL m_keyLayout;
00304
00305
00306 bool m_leaveForegroundOption;
00307
00308 IEventQueue& m_eventQueue;
00309
00310
00311 bool m_stopOnDeskSwitch;
00312 };
00313
00314 #endif