CPrimaryClient.cpp

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2002 Chris Schoeneman
00004  * 
00005  * This package is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * found in the file COPYING that should have accompanied this file.
00008  * 
00009  * This package is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  */
00014 
00015 #include "CPrimaryClient.h"
00016 #include "CScreen.h"
00017 #include "CClipboard.h"
00018 #include "CLog.h"
00019 
00020 //
00021 // CPrimaryClient
00022 //
00023 
00024 CPrimaryClient::CPrimaryClient(const CString& name, CScreen* screen) :
00025     CBaseClientProxy(name),
00026     m_screen(screen),
00027     m_fakeInputCount(0)
00028 {
00029     // all clipboards are clean
00030     for (UInt32 i = 0; i < kClipboardEnd; ++i) {
00031         m_clipboardDirty[i] = false;
00032     }
00033 }
00034 
00035 CPrimaryClient::~CPrimaryClient()
00036 {
00037     // do nothing
00038 }
00039 
00040 void
00041 CPrimaryClient::reconfigure(UInt32 activeSides)
00042 {
00043     m_screen->reconfigure(activeSides);
00044 }
00045 
00046 UInt32
00047 CPrimaryClient::registerHotKey(KeyID key, KeyModifierMask mask)
00048 {
00049     return m_screen->registerHotKey(key, mask);
00050 }
00051 
00052 void
00053 CPrimaryClient::unregisterHotKey(UInt32 id)
00054 {
00055     m_screen->unregisterHotKey(id);
00056 }
00057 
00058 void
00059 CPrimaryClient::fakeInputBegin()
00060 {
00061     if (++m_fakeInputCount == 1) {
00062         m_screen->fakeInputBegin();
00063     }
00064 }
00065 
00066 void
00067 CPrimaryClient::fakeInputEnd()
00068 {
00069     if (--m_fakeInputCount == 0) {
00070         m_screen->fakeInputEnd();
00071     }
00072 }
00073 
00074 SInt32
00075 CPrimaryClient::getJumpZoneSize() const
00076 {
00077     return m_screen->getJumpZoneSize();
00078 }
00079 
00080 void
00081 CPrimaryClient::getCursorCenter(SInt32& x, SInt32& y) const
00082 {
00083     m_screen->getCursorCenter(x, y);
00084 }
00085 
00086 KeyModifierMask
00087 CPrimaryClient::getToggleMask() const
00088 {
00089     return m_screen->pollActiveModifiers();
00090 }
00091 
00092 bool
00093 CPrimaryClient::isLockedToScreen() const
00094 {
00095     return m_screen->isLockedToScreen();
00096 }
00097 
00098 void*
00099 CPrimaryClient::getEventTarget() const
00100 {
00101     return m_screen->getEventTarget();
00102 }
00103 
00104 bool
00105 CPrimaryClient::getClipboard(ClipboardID id, IClipboard* clipboard) const
00106 {
00107     return m_screen->getClipboard(id, clipboard);
00108 }
00109 
00110 void
00111 CPrimaryClient::getShape(SInt32& x, SInt32& y,
00112                 SInt32& width, SInt32& height) const
00113 {
00114     m_screen->getShape(x, y, width, height);
00115 }
00116 
00117 void
00118 CPrimaryClient::getCursorPos(SInt32& x, SInt32& y) const
00119 {
00120     m_screen->getCursorPos(x, y);
00121 }
00122 
00123 void
00124 CPrimaryClient::enable()
00125 {
00126     m_screen->enable();
00127 }
00128 
00129 void
00130 CPrimaryClient::disable()
00131 {
00132     m_screen->disable();
00133 }
00134 
00135 void
00136 CPrimaryClient::enter(SInt32 xAbs, SInt32 yAbs,
00137                 UInt32 seqNum, KeyModifierMask mask, bool screensaver)
00138 {
00139     m_screen->setSequenceNumber(seqNum);
00140     if (!screensaver) {
00141         m_screen->warpCursor(xAbs, yAbs);
00142     }
00143     m_screen->enter(mask);
00144 }
00145 
00146 bool
00147 CPrimaryClient::leave()
00148 {
00149     return m_screen->leave();
00150 }
00151 
00152 void
00153 CPrimaryClient::setClipboard(ClipboardID id, const IClipboard* clipboard)
00154 {
00155     // ignore if this clipboard is already clean
00156     if (m_clipboardDirty[id]) {
00157         // this clipboard is now clean
00158         m_clipboardDirty[id] = false;
00159 
00160         // set clipboard
00161         m_screen->setClipboard(id, clipboard);
00162     }
00163 }
00164 
00165 void
00166 CPrimaryClient::grabClipboard(ClipboardID id)
00167 {
00168     // grab clipboard
00169     m_screen->grabClipboard(id);
00170 
00171     // clipboard is dirty (because someone else owns it now)
00172     m_clipboardDirty[id] = true;
00173 }
00174 
00175 void
00176 CPrimaryClient::setClipboardDirty(ClipboardID id, bool dirty)
00177 {
00178     m_clipboardDirty[id] = dirty;
00179 }
00180 
00181 void
00182 CPrimaryClient::keyDown(KeyID key, KeyModifierMask mask, KeyButton button)
00183 {
00184     if (m_fakeInputCount > 0) {
00185 // XXX -- don't forward keystrokes to primary screen for now
00186         (void)key;
00187         (void)mask;
00188         (void)button;
00189 //      m_screen->keyDown(key, mask, button);
00190     }
00191 }
00192 
00193 void
00194 CPrimaryClient::keyRepeat(KeyID, KeyModifierMask, SInt32, KeyButton)
00195 {
00196     // ignore
00197 }
00198 
00199 void
00200 CPrimaryClient::keyUp(KeyID key, KeyModifierMask mask, KeyButton button)
00201 {
00202     if (m_fakeInputCount > 0) {
00203 // XXX -- don't forward keystrokes to primary screen for now
00204         (void)key;
00205         (void)mask;
00206         (void)button;
00207 //      m_screen->keyUp(key, mask, button);
00208     }
00209 }
00210 
00211 void
00212 CPrimaryClient::mouseDown(ButtonID)
00213 {
00214     // ignore
00215 }
00216 
00217 void
00218 CPrimaryClient::mouseUp(ButtonID)
00219 {
00220     // ignore
00221 }
00222 
00223 void
00224 CPrimaryClient::mouseMove(SInt32 x, SInt32 y)
00225 {
00226     m_screen->warpCursor(x, y);
00227 }
00228 
00229 void
00230 CPrimaryClient::mouseRelativeMove(SInt32, SInt32)
00231 {
00232     // ignore
00233 }
00234 
00235 void
00236 CPrimaryClient::mouseWheel(SInt32, SInt32)
00237 {
00238     // ignore
00239 }
00240 
00241 void
00242 CPrimaryClient::screensaver(bool)
00243 {
00244     // ignore
00245 }
00246 
00247 void
00248 CPrimaryClient::resetOptions()
00249 {
00250     m_screen->resetOptions();
00251 }
00252 
00253 void
00254 CPrimaryClient::setOptions(const COptionsList& options)
00255 {
00256     m_screen->setOptions(options);
00257 }

Generated on Fri Nov 6 00:18:45 2009 for synergy-plus by  doxygen 1.4.7