00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CMSWINDOWSDESKS_H
00016 #define CMSWINDOWSDESKS_H
00017
00018 #include "CSynergyHook.h"
00019 #include "KeyTypes.h"
00020 #include "MouseTypes.h"
00021 #include "OptionTypes.h"
00022 #include "CCondVar.h"
00023 #include "CMutex.h"
00024 #include "CString.h"
00025 #include "stdmap.h"
00026 #define WIN32_LEAN_AND_MEAN
00027 #include <windows.h>
00028
00029 class CEvent;
00030 class CEventQueueTimer;
00031 class CThread;
00032 class IJob;
00033 class IScreenSaver;
00034
00036
00051 class CMSWindowsDesks {
00052 public:
00054
00062 CMSWindowsDesks(bool isPrimary, HINSTANCE hookLibrary,
00063 const IScreenSaver* screensaver, IJob* updateKeys);
00064 ~CMSWindowsDesks();
00065
00067
00068
00070
00076 void enable();
00077
00079
00082 void disable();
00083
00085
00088 void enter();
00089
00091
00094 void leave(HKL keyLayout);
00095
00097
00100 void resetOptions();
00101
00103
00107 void setOptions(const COptionsList& options);
00108
00110
00114 void updateKeys();
00115
00117
00120 void setShape(SInt32 x, SInt32 y,
00121 SInt32 width, SInt32 height,
00122 SInt32 xCenter, SInt32 yCenter, bool isMultimon);
00123
00125
00130 void installScreensaverHooks(bool install);
00131
00133
00136 void fakeInputBegin();
00137
00139
00142 void fakeInputEnd();
00143
00145
00146
00147
00149
00152 void getCursorPos(SInt32& x, SInt32& y) const;
00153
00155
00158 void fakeKeyEvent(KeyButton button, UINT virtualKey,
00159 bool press, bool isAutoRepeat) const;
00160
00162
00165 void fakeMouseButton(ButtonID id, bool press) const;
00166
00168
00171 void fakeMouseMove(SInt32 x, SInt32 y) const;
00172
00174
00177 void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const;
00178
00180
00183 void fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const;
00184
00186
00187 private:
00188 class CDesk {
00189 public:
00190 CString m_name;
00191 CThread* m_thread;
00192 DWORD m_threadID;
00193 DWORD m_targetID;
00194 HDESK m_desk;
00195 HWND m_window;
00196 HWND m_foregroundWindow;
00197 bool m_lowLevel;
00198 };
00199 typedef std::map<CString, CDesk*> CDesks;
00200
00201
00202 void queryHookLibrary(HINSTANCE hookLibrary);
00203 HCURSOR createBlankCursor() const;
00204 void destroyCursor(HCURSOR cursor) const;
00205 ATOM createDeskWindowClass(bool isPrimary) const;
00206 void destroyClass(ATOM windowClass) const;
00207 HWND createWindow(ATOM windowClass, const char* name) const;
00208 void destroyWindow(HWND) const;
00209
00210
00211 void deskMouseMove(SInt32 x, SInt32 y) const;
00212 void deskMouseRelativeMove(SInt32 dx, SInt32 dy) const;
00213 void deskEnter(CDesk* desk);
00214 void deskLeave(CDesk* desk, HKL keyLayout);
00215 void deskThread(void* vdesk);
00216
00217
00218 CDesk* addDesk(const CString& name, HDESK hdesk);
00219 void removeDesks();
00220 void checkDesk();
00221 bool isDeskAccessible(const CDesk* desk) const;
00222 void handleCheckDesk(const CEvent& event, void*);
00223
00224
00225 void waitForDesk() const;
00226 void sendMessage(UINT, WPARAM, LPARAM) const;
00227
00228
00229 HWND getForegroundWindow() const;
00230
00231
00232 HDESK openInputDesktop();
00233 void closeDesktop(HDESK);
00234 CString getDesktopName(HDESK);
00235
00236
00237 static LRESULT CALLBACK primaryDeskProc(HWND, UINT, WPARAM, LPARAM);
00238 static LRESULT CALLBACK secondaryDeskProc(HWND, UINT, WPARAM, LPARAM);
00239
00240 private:
00241
00242 bool m_isPrimary;
00243
00244
00245 bool m_is95Family;
00246
00247
00248 bool m_isModernFamily;
00249
00250
00251 bool m_isOnScreen;
00252
00253
00254 ATOM m_deskClass;
00255 HCURSOR m_cursor;
00256
00257
00258 SInt32 m_x, m_y;
00259 SInt32 m_w, m_h;
00260 SInt32 m_xCenter, m_yCenter;
00261
00262
00263 bool m_multimon;
00264
00265
00266 CEventQueueTimer* m_timer;
00267
00268
00269 DWORD m_threadID;
00270 const IScreenSaver* m_screensaver;
00271 bool m_screensaverNotify;
00272
00273
00274 CDesk* m_activeDesk;
00275 CString m_activeDeskName;
00276
00277
00278 CMutex m_mutex;
00279 CCondVar<bool> m_deskReady;
00280 CDesks m_desks;
00281
00282
00283 InstallFunc m_install;
00284 UninstallFunc m_uninstall;
00285 InstallScreenSaverFunc m_installScreensaver;
00286 UninstallScreenSaverFunc m_uninstallScreensaver;
00287
00288
00289 IJob* m_updateKeys;
00290 HKL m_keyLayout;
00291
00292
00293 bool m_leaveForegroundOption;
00294 };
00295
00296 #endif