| 1 | /*
|
|---|
| 2 | * synergy -- mouse and keyboard sharing utility
|
|---|
| 3 | * Copyright (C) 2002 Chris Schoeneman
|
|---|
| 4 | *
|
|---|
| 5 | * This package is free software; you can redistribute it and/or
|
|---|
| 6 | * modify it under the terms of the GNU General Public License
|
|---|
| 7 | * found in the file COPYING that should have accompanied this file.
|
|---|
| 8 | *
|
|---|
| 9 | * This package is distributed in the hope that it will be useful,
|
|---|
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | * GNU General Public License for more details.
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | #include "CPrimaryClient.h"
|
|---|
| 16 | #include "CScreen.h"
|
|---|
| 17 | #include "CClipboard.h"
|
|---|
| 18 | #include "CLog.h"
|
|---|
| 19 |
|
|---|
| 20 | //
|
|---|
| 21 | // CPrimaryClient
|
|---|
| 22 | //
|
|---|
| 23 |
|
|---|
| 24 | CPrimaryClient::CPrimaryClient(const CString& name, CScreen* screen) :
|
|---|
| 25 | CBaseClientProxy(name),
|
|---|
| 26 | m_screen(screen),
|
|---|
| 27 | m_fakeInputCount(0)
|
|---|
| 28 | {
|
|---|
| 29 | // all clipboards are clean
|
|---|
| 30 | for (UInt32 i = 0; i < kClipboardEnd; ++i) {
|
|---|
| 31 | m_clipboardDirty[i] = false;
|
|---|
| 32 | }
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | CPrimaryClient::~CPrimaryClient()
|
|---|
| 36 | {
|
|---|
| 37 | // do nothing
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | void
|
|---|
| 41 | CPrimaryClient::reconfigure(UInt32 activeSides)
|
|---|
| 42 | {
|
|---|
| 43 | m_screen->reconfigure(activeSides);
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | UInt32
|
|---|
| 47 | CPrimaryClient::registerHotKey(KeyID key, KeyModifierMask mask)
|
|---|
| 48 | {
|
|---|
| 49 | return m_screen->registerHotKey(key, mask);
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | void
|
|---|
| 53 | CPrimaryClient::unregisterHotKey(UInt32 id)
|
|---|
| 54 | {
|
|---|
| 55 | m_screen->unregisterHotKey(id);
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | void
|
|---|
| 59 | CPrimaryClient::fakeInputBegin()
|
|---|
| 60 | {
|
|---|
| 61 | if (++m_fakeInputCount == 1) {
|
|---|
| 62 | m_screen->fakeInputBegin();
|
|---|
| 63 | }
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | void
|
|---|
| 67 | CPrimaryClient::fakeInputEnd()
|
|---|
| 68 | {
|
|---|
| 69 | if (--m_fakeInputCount == 0) {
|
|---|
| 70 | m_screen->fakeInputEnd();
|
|---|
| 71 | }
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | SInt32
|
|---|
| 75 | CPrimaryClient::getJumpZoneSize() const
|
|---|
| 76 | {
|
|---|
| 77 | return m_screen->getJumpZoneSize();
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | void
|
|---|
| 81 | CPrimaryClient::getCursorCenter(SInt32& x, SInt32& y) const
|
|---|
| 82 | {
|
|---|
| 83 | m_screen->getCursorCenter(x, y);
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | KeyModifierMask
|
|---|
| 87 | CPrimaryClient::getToggleMask() const
|
|---|
| 88 | {
|
|---|
| 89 | return m_screen->pollActiveModifiers();
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | bool
|
|---|
| 93 | CPrimaryClient::isLockedToScreen() const
|
|---|
| 94 | {
|
|---|
| 95 | return m_screen->isLockedToScreen();
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | void*
|
|---|
| 99 | CPrimaryClient::getEventTarget() const
|
|---|
| 100 | {
|
|---|
| 101 | return m_screen->getEventTarget();
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | bool
|
|---|
| 105 | CPrimaryClient::getClipboard(ClipboardID id, IClipboard* clipboard) const
|
|---|
| 106 | {
|
|---|
| 107 | return m_screen->getClipboard(id, clipboard);
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | void
|
|---|
| 111 | CPrimaryClient::getShape(SInt32& x, SInt32& y,
|
|---|
| 112 | SInt32& width, SInt32& height) const
|
|---|
| 113 | {
|
|---|
| 114 | m_screen->getShape(x, y, width, height);
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | void
|
|---|
| 118 | CPrimaryClient::getCursorPos(SInt32& x, SInt32& y) const
|
|---|
| 119 | {
|
|---|
| 120 | m_screen->getCursorPos(x, y);
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | void
|
|---|
| 124 | CPrimaryClient::enable()
|
|---|
| 125 | {
|
|---|
| 126 | m_screen->enable();
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | void
|
|---|
| 130 | CPrimaryClient::disable()
|
|---|
| 131 | {
|
|---|
| 132 | m_screen->disable();
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | void
|
|---|
| 136 | CPrimaryClient::enter(SInt32 xAbs, SInt32 yAbs,
|
|---|
| 137 | UInt32 seqNum, KeyModifierMask mask, bool screensaver)
|
|---|
| 138 | {
|
|---|
| 139 | m_screen->setSequenceNumber(seqNum);
|
|---|
| 140 | if (!screensaver) {
|
|---|
| 141 | m_screen->warpCursor(xAbs, yAbs);
|
|---|
| 142 | }
|
|---|
| 143 | m_screen->enter(mask);
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | bool
|
|---|
| 147 | CPrimaryClient::leave()
|
|---|
| 148 | {
|
|---|
| 149 | return m_screen->leave();
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | void
|
|---|
| 153 | CPrimaryClient::setClipboard(ClipboardID id, const IClipboard* clipboard)
|
|---|
| 154 | {
|
|---|
| 155 | // ignore if this clipboard is already clean
|
|---|
| 156 | if (m_clipboardDirty[id]) {
|
|---|
| 157 | // this clipboard is now clean
|
|---|
| 158 | m_clipboardDirty[id] = false;
|
|---|
| 159 |
|
|---|
| 160 | // set clipboard
|
|---|
| 161 | m_screen->setClipboard(id, clipboard);
|
|---|
| 162 | }
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | void
|
|---|
| 166 | CPrimaryClient::grabClipboard(ClipboardID id)
|
|---|
| 167 | {
|
|---|
| 168 | // grab clipboard
|
|---|
| 169 | m_screen->grabClipboard(id);
|
|---|
| 170 |
|
|---|
| 171 | // clipboard is dirty (because someone else owns it now)
|
|---|
| 172 | m_clipboardDirty[id] = true;
|
|---|
| 173 | }
|
|---|
| 174 |
|
|---|
| 175 | void
|
|---|
| 176 | CPrimaryClient::setClipboardDirty(ClipboardID id, bool dirty)
|
|---|
| 177 | {
|
|---|
| 178 | m_clipboardDirty[id] = dirty;
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | void
|
|---|
| 182 | CPrimaryClient::keyDown(KeyID key, KeyModifierMask mask, KeyButton button)
|
|---|
| 183 | {
|
|---|
| 184 | if (m_fakeInputCount > 0) {
|
|---|
| 185 | // XXX -- don't forward keystrokes to primary screen for now
|
|---|
| 186 | (void)key;
|
|---|
| 187 | (void)mask;
|
|---|
| 188 | (void)button;
|
|---|
| 189 | // m_screen->keyDown(key, mask, button);
|
|---|
| 190 | }
|
|---|
| 191 | }
|
|---|
| 192 |
|
|---|
| 193 | void
|
|---|
| 194 | CPrimaryClient::keyRepeat(KeyID, KeyModifierMask, SInt32, KeyButton)
|
|---|
| 195 | {
|
|---|
| 196 | // ignore
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 | void
|
|---|
| 200 | CPrimaryClient::keyUp(KeyID key, KeyModifierMask mask, KeyButton button)
|
|---|
| 201 | {
|
|---|
| 202 | if (m_fakeInputCount > 0) {
|
|---|
| 203 | // XXX -- don't forward keystrokes to primary screen for now
|
|---|
| 204 | (void)key;
|
|---|
| 205 | (void)mask;
|
|---|
| 206 | (void)button;
|
|---|
| 207 | // m_screen->keyUp(key, mask, button);
|
|---|
| 208 | }
|
|---|
| 209 | }
|
|---|
| 210 |
|
|---|
| 211 | void
|
|---|
| 212 | CPrimaryClient::mouseDown(ButtonID)
|
|---|
| 213 | {
|
|---|
| 214 | // ignore
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | void
|
|---|
| 218 | CPrimaryClient::mouseUp(ButtonID)
|
|---|
| 219 | {
|
|---|
| 220 | // ignore
|
|---|
| 221 | }
|
|---|
| 222 |
|
|---|
| 223 | void
|
|---|
| 224 | CPrimaryClient::mouseMove(SInt32 x, SInt32 y)
|
|---|
| 225 | {
|
|---|
| 226 | m_screen->warpCursor(x, y);
|
|---|
| 227 | }
|
|---|
| 228 |
|
|---|
| 229 | void
|
|---|
| 230 | CPrimaryClient::mouseRelativeMove(SInt32, SInt32)
|
|---|
| 231 | {
|
|---|
| 232 | // ignore
|
|---|
| 233 | }
|
|---|
| 234 |
|
|---|
| 235 | void
|
|---|
| 236 | CPrimaryClient::mouseWheel(SInt32, SInt32)
|
|---|
| 237 | {
|
|---|
| 238 | // ignore
|
|---|
| 239 | }
|
|---|
| 240 |
|
|---|
| 241 | void
|
|---|
| 242 | CPrimaryClient::screensaver(bool)
|
|---|
| 243 | {
|
|---|
| 244 | // ignore
|
|---|
| 245 | }
|
|---|
| 246 |
|
|---|
| 247 | void
|
|---|
| 248 | CPrimaryClient::resetOptions()
|
|---|
| 249 | {
|
|---|
| 250 | m_screen->resetOptions();
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 | void
|
|---|
| 254 | CPrimaryClient::setOptions(const COptionsList& options)
|
|---|
| 255 | {
|
|---|
| 256 | m_screen->setOptions(options);
|
|---|
| 257 | }
|
|---|