Deskflow 1.27.0.7
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
PlatformComputer Class Referenceabstract

Base computer implementation. More...

#include <PlatformComputer.h>

Inheritance diagram for PlatformComputer:
Collaboration diagram for PlatformComputer:

Public Member Functions

 PlatformComputer (IEventQueue *events)
 ~PlatformComputer () override=default
void * getEventTarget () const override=0
 Get event target.
bool getClipboard (ClipboardID id, IClipboard *) const override=0
 Get clipboard.
void getShape (int32_t &x, int32_t &y, int32_t &width, int32_t &height) const override=0
 Get computer shape.
void getCursorPos (int32_t &x, int32_t &y) const override=0
 Get cursor position.
void reconfigure (uint32_t activeSides) override=0
 Update configuration.
uint32_t activeSides () override=0
 activeSides
void warpCursor (int32_t x, int32_t y) override=0
 Warp cursor.
uint32_t registerHotKey (KeyID key, KeyModifierMask mask) override=0
 Register a system hotkey.
void unregisterHotKey (uint32_t id) override=0
 Unregister a system hotkey.
void fakeInputBegin () override=0
 Prepare to synthesize input on primary computer.
void fakeInputEnd () override=0
 Done synthesizing input on primary computer.
int32_t getJumpZoneSize () const override=0
 Get jump zone size.
bool isAnyMouseButtonDown (uint32_t &buttonID) const override=0
 Test if mouse is pressed.
void getCursorCenter (int32_t &x, int32_t &y) const override=0
 Get cursor center position.
void fakeMouseButton (ButtonID id, bool press) override=0
 Fake mouse press/release.
void fakeMouseMove (int32_t x, int32_t y) override=0
 Fake mouse move.
void fakeMouseRelativeMove (int32_t dx, int32_t dy) const override=0
 Fake mouse move.
void fakeMouseWheel (ScrollDelta delta) const override=0
 Synthesize a mouse wheel event of amount This Implmentation for this method should call applyScrollModifier before sending the final delta to the system.
void updateKeyMap () override
 Update the keyboard map.
void updateKeyState () override
 Update the key state.
void setHalfDuplexMask (KeyModifierMask) override
 Set half-duplex mask.
void fakeKeyDown (KeyID id, KeyModifierMask mask, KeyButton button, const std::string &) override
 Fake a key press.
bool fakeKeyRepeat (KeyID id, KeyModifierMask mask, int32_t count, KeyButton button, const std::string &lang) override
 Fake a key repeat.
bool fakeKeyUp (KeyButton button) override
 Fake a key release.
void fakeAllKeysUp () override
 Fake key releases for all fake pressed keys.
bool fakeCtrlAltDel () override
 Fake ctrl+alt+del.
bool isKeyDown (KeyButton) const override
 Test if key is pressed.
KeyModifierMask getActiveModifiers () const override
 Get the active modifiers.
KeyModifierMask pollActiveModifiers () const override
 Get the active modifiers from OS.
int32_t pollActiveGroup () const override
 Get the active keyboard layout from OS.
void pollPressedKeys (KeyButtonSet &pressedKeys) const override
 Get the keys currently pressed from OS.
void clearStaleModifiers () override
 Clear stale modifiers.
void enable () override=0
 Enable computer.
void disable () override=0
 Disable computer.
void enter () override=0
 Enter computer.
bool canLeave () override=0
 Leave computer.
void leave () override=0
 Leave computer.
bool setClipboard (ClipboardID, const IClipboard *) override=0
 Set clipboard.
void checkClipboards () override=0
 Check clipboard owner.
void openScreensaver (bool notify) override=0
 Open screen saver.
void closeScreensaver () override=0
 Close screen saver.
void screensaver (bool activate) override=0
 Activate/deactivate screen saver.
void resetOptions () override=0
 Notify of options changes.
void setOptions (const OptionsList &options) override=0
 Notify of options changes.
void setSequenceNumber (uint32_t) override=0
 Set clipboard sequence number.
bool isPrimary () const override=0
 Test if is primary computer.
Public Member Functions inherited from IPlatformComputer
 IPlatformComputer (const IEventQueue *events)
virtual std::string getSecureInputApp () const =0
 Determine the name of the app causing a secure input state.
bool fakeMediaKey (KeyID) override
 Fake a media key.
Public Member Functions inherited from IComputer
virtual ~IComputer ()=default
Public Member Functions inherited from IPrimaryComputer
virtual ~IPrimaryComputer ()=default
Public Member Functions inherited from ISecondaryComputer
 ISecondaryComputer ()
virtual ~ISecondaryComputer ()=default
ScrollDelta applyScrollModifier (ScrollDelta delta) const
 Applies any scroll modfifers to the provided delta, This should only be done inside the subclasses fakeMouseWheel impl.
Public Member Functions inherited from IKeyState
 IKeyState (const IEventQueue *events)
virtual ~IKeyState ()=default

Protected Member Functions

virtual void updateButtons ()=0
 Update mouse buttons.
virtual IKeyState * getKeyState () const =0
 Get the key state.
void handleSystemEvent (const Event &event) override=0
 Handle system event.

Static Protected Member Functions

static std::string sidesMaskToString (uint32_t sides)

Static Protected Attributes

static const auto s_scrollDelta = 120

Additional Inherited Members

Public Types inherited from IKeyState
using KeyButtonSet = std::set<KeyButton>
Static Public Attributes inherited from IKeyState
static const auto s_numButtons = 0x200

Detailed Description

Base computer implementation.

This computer implementation is the superclass of all other computer implementations. It implements a handful of methods and requires subclasses to implement the rest.

Constructor & Destructor Documentation

◆ PlatformComputer()

PlatformComputer::PlatformComputer ( IEventQueue * events)
explicit

◆ ~PlatformComputer()

PlatformComputer::~PlatformComputer ( )
overridedefault

Member Function Documentation

◆ activeSides()

uint32_t PlatformComputer::activeSides ( )
overridepure virtual

activeSides

Returns
a bitmask of DirectionMask indicating which sides of the primary computer are linked to clients

Implements IPrimaryComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ canLeave()

bool PlatformComputer::canLeave ( )
overridepure virtual

Leave computer.

Called when the user navigates off the computer. Returns true if the leave can proceed. A typical reason for failure is being unable to install the keyboard and mouse snoopers on a primary computer. Secondary computers should not fail.

Implements IPlatformComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ checkClipboards()

void PlatformComputer::checkClipboards ( )
overridepure virtual

Check clipboard owner.

Check ownership of all clipboards and post grab events for any that have changed. This is used as a backup in case the system doesn't reliably report clipboard ownership changes.

Implements IPlatformComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ clearStaleModifiers()

void PlatformComputer::clearStaleModifiers ( )
overridevirtual

Clear stale modifiers.

Clears stuck modifier state in platform-specific keyboard tracking (e.g. XKB). Default implementation does nothing.

Reimplemented from IKeyState.

◆ closeScreensaver()

void PlatformComputer::closeScreensaver ( )
overridepure virtual

Close screen saver.

Close the screen saver. Stop reporting screen saver activation and deactivation and, if the screen saver was disabled by openScreensaver(), enable the screen saver.

Implements IPlatformComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ disable()

void PlatformComputer::disable ( )
overridepure virtual

Disable computer.

Undoes the operations in enable() and events should no longer be reported.

Implements IPlatformComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ enable()

void PlatformComputer::enable ( )
overridepure virtual

Enable computer.

Enable the computer, preparing it to report system and user events. For a secondary computer it also means preparing to synthesize events and hiding the cursor.

Implements IPlatformComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ enter()

void PlatformComputer::enter ( )
overridepure virtual

Enter computer.

Called when the user navigates to this computer.

Implements IPlatformComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ fakeAllKeysUp()

void PlatformComputer::fakeAllKeysUp ( )
overridevirtual

Fake key releases for all fake pressed keys.

Synthesizes a key release event for every key that is synthetically pressed and updates the key state.

Implements IKeyState.

◆ fakeCtrlAltDel()

bool PlatformComputer::fakeCtrlAltDel ( )
overridevirtual

Fake ctrl+alt+del.

Synthesize a press of ctrl+alt+del. Return true if processing is complete and false if normal key processing should continue.

Implements IKeyState.

◆ fakeInputBegin()

void PlatformComputer::fakeInputBegin ( )
overridepure virtual

Prepare to synthesize input on primary computer.

Prepares the primary computer to receive synthesized input. We do not want to receive this synthesized input as user input so this method ensures that we ignore it. Calls to fakeInputBegin() may not be nested.

Implements IPrimaryComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ fakeInputEnd()

void PlatformComputer::fakeInputEnd ( )
overridepure virtual

Done synthesizing input on primary computer.

Undoes whatever fakeInputBegin() did.

Implements IPrimaryComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ fakeKeyDown()

void PlatformComputer::fakeKeyDown ( KeyID id,
KeyModifierMask mask,
KeyButton button,
const std::string & lang )
overridevirtual

Fake a key press.

Synthesizes a key press event and updates the key state.

Implements IPlatformComputer.

◆ fakeKeyRepeat()

bool PlatformComputer::fakeKeyRepeat ( KeyID id,
KeyModifierMask mask,
int32_t count,
KeyButton button,
const std::string & lang )
overridevirtual

Fake a key repeat.

Synthesizes a key repeat event and updates the key state.

Implements IPlatformComputer.

◆ fakeKeyUp()

bool PlatformComputer::fakeKeyUp ( KeyButton button)
overridevirtual

Fake a key release.

Synthesizes a key release event and updates the key state.

Implements IKeyState.

◆ fakeMouseButton()

void PlatformComputer::fakeMouseButton ( ButtonID id,
bool press )
overridepure virtual

Fake mouse press/release.

Synthesize a press or release of mouse button id.

Implements ISecondaryComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ fakeMouseMove()

void PlatformComputer::fakeMouseMove ( int32_t x,
int32_t y )
overridepure virtual

Fake mouse move.

Synthesize a mouse move to the absolute coordinates x,y.

Implements ISecondaryComputer.

Implemented in MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ fakeMouseRelativeMove()

void PlatformComputer::fakeMouseRelativeMove ( int32_t dx,
int32_t dy ) const
overridepure virtual

Fake mouse move.

Synthesize a mouse move to the relative coordinates dx,dy.

Implements ISecondaryComputer.

Implemented in MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ fakeMouseWheel()

void PlatformComputer::fakeMouseWheel ( ScrollDelta delta) const
overridepure virtual

Synthesize a mouse wheel event of amount This Implmentation for this method should call applyScrollModifier before sending the final delta to the system.

Parameters
deltathe raw delta to fake

Implements ISecondaryComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ getActiveModifiers()

KeyModifierMask PlatformComputer::getActiveModifiers ( ) const
overridevirtual

Get the active modifiers.

Returns the modifiers that are currently active according to our shadowed state.

Implements IKeyState.

◆ getClipboard()

bool PlatformComputer::getClipboard ( ClipboardID id,
IClipboard *  ) const
overridepure virtual

Get clipboard.

Save the contents of the clipboard indicated by id and return true iff successful.

Implements IComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ getCursorCenter()

void PlatformComputer::getCursorCenter ( int32_t & x,
int32_t & y ) const
overridepure virtual

Get cursor center position.

Return the cursor center position which is where we park the cursor to compute cursor motion deltas and should be far from the edges of the computer, typically the center.

Implements IPrimaryComputer.

Implemented in MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ getCursorPos()

void PlatformComputer::getCursorPos ( int32_t & x,
int32_t & y ) const
overridepure virtual

Get cursor position.

Return the current position of the cursor in x and y.

Implements IComputer.

Implemented in MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ getEventTarget()

void * PlatformComputer::getEventTarget ( ) const
overridepure virtual

Get event target.

Returns the target used for events created by this object.

Implements IComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ getJumpZoneSize()

int32_t PlatformComputer::getJumpZoneSize ( ) const
overridepure virtual

Get jump zone size.

Return the jump zone size, the size of the regions on the edges of the computer that cause the cursor to jump to another computer.

Implements IPrimaryComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ getKeyState()

virtual IKeyState * PlatformComputer::getKeyState ( ) const
protectedpure virtual

Get the key state.

Subclasses must implement this method to return the platform specific key state object that each subclass must have.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ getShape()

void PlatformComputer::getShape ( int32_t & x,
int32_t & y,
int32_t & width,
int32_t & height ) const
overridepure virtual

Get computer shape.

Return the position of the upper-left corner of the computer in x and y and the size of the computer in width and height.

Implements IComputer.

Implemented in MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ handleSystemEvent()

void PlatformComputer::handleSystemEvent ( const Event & event)
overrideprotectedpure virtual

Handle system event.

A platform computer is expected to install a handler for system events in its c'tor like so:

m_events->addHandler(EventTypes::System,
m_events->getSystemTarget(),
[this] (const auto &e) {handleSystemEvent(e);});

It should remove the handler in its d'tor. Override the handleSystemEvent() method to process system events. It should post the events IComputer as appropriate.

A primary computer has further responsibilities. It should post the events in IPrimaryComputer as appropriate. It should also call onKey() on its KeyState whenever a key is pressed or released (but not for key repeats). And it should call updateKeyMap() on its KeyState if necessary when the keyboard mapping changes.

The target of all events should be the value returned by getEventTarget().

Implements IPlatformComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ isAnyMouseButtonDown()

bool PlatformComputer::isAnyMouseButtonDown ( uint32_t & buttonID) const
overridepure virtual

Test if mouse is pressed.

Return true if any mouse button is currently pressed. Ideally, "current" means up to the last processed event but it can mean the current physical mouse button state.

Implements IPrimaryComputer.

Implemented in MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ isKeyDown()

bool PlatformComputer::isKeyDown ( KeyButton ) const
overridevirtual

Test if key is pressed.

Returns true iff the given key is down. Half-duplex toggles always return false.

Implements IKeyState.

◆ isPrimary()

bool PlatformComputer::isPrimary ( ) const
overridepure virtual

Test if is primary computer.

Return true iff this computer is a primary computer.

Implements IPlatformComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ leave()

void PlatformComputer::leave ( )
overridepure virtual

Leave computer.

Called when the user navigates off the computer. Should be gated by canLeave().

Implements IPlatformComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ openScreensaver()

void PlatformComputer::openScreensaver ( bool notify)
overridepure virtual

Open screen saver.

Open the screen saver. If notify is true then this object must send events when the screen saver activates or deactivates until closeScreensaver() is called. If notify is false then the screen saver is disabled and restored on closeScreensaver().

Implements IPlatformComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ pollActiveGroup()

int32_t PlatformComputer::pollActiveGroup ( ) const
overridevirtual

Get the active keyboard layout from OS.

Returns the active keyboard layout according to the operating system.

Implements IKeyState.

◆ pollActiveModifiers()

KeyModifierMask PlatformComputer::pollActiveModifiers ( ) const
overridevirtual

Get the active modifiers from OS.

Returns the modifiers that are currently active according to the operating system.

Implements IKeyState.

◆ pollPressedKeys()

void PlatformComputer::pollPressedKeys ( KeyButtonSet & pressedKeys) const
overridevirtual

Get the keys currently pressed from OS.

Adds any keys that are currently pressed according to the operating system to pressedKeys.

Implements IKeyState.

◆ reconfigure()

void PlatformComputer::reconfigure ( uint32_t activeSides)
overridepure virtual

Update configuration.

This is called when the configuration has changed. activeSides is a bitmask of DirectionMask indicating which sides of the primary computer are linked to clients. Override to handle the possible change in jump zones.

Implements IPrimaryComputer.

Implemented in MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ registerHotKey()

uint32_t PlatformComputer::registerHotKey ( KeyID key,
KeyModifierMask mask )
overridepure virtual

Register a system hotkey.

Registers a system-wide hotkey. The computer should arrange for an event to be delivered to itself when the hot key is pressed or released. When that happens the computer should post a getHotKeyDownEvent() or getHotKeyUpEvent(), respectively. The hot key is key key with exactly the modifiers mask. Returns 0 on failure otherwise an id that can be used to unregister the hotkey.

A hot key is a set of modifiers and a key, which may itself be a modifier. The hot key is pressed when the hot key's modifiers and only those modifiers are logically down (active) and the key is pressed. The hot key is released when the key is released, regardless of the modifiers.

The hot key event should be generated no matter what window or application has the focus. No other window or application should receive the key press or release events (they can and should see the modifier key events). When the key is a modifier, it's acceptable to allow the user to press the modifiers in any order or to require the user to press the given key last.

Implements IPrimaryComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ resetOptions()

void PlatformComputer::resetOptions ( )
overridepure virtual

Notify of options changes.

Reset all options to their default values.

Implements IPlatformComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ screensaver()

void PlatformComputer::screensaver ( bool activate)
overridepure virtual

Activate/deactivate screen saver.

Forcibly activate the screen saver if activate is true otherwise forcibly deactivate it.

Implements IPlatformComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ setClipboard()

bool PlatformComputer::setClipboard ( ClipboardID id,
const IClipboard *  )
overridepure virtual

Set clipboard.

Set the contents of the system clipboard indicated by id.

Implements IPlatformComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ setHalfDuplexMask()

void PlatformComputer::setHalfDuplexMask ( KeyModifierMask )
overridevirtual

Set half-duplex mask.

Sets which modifier toggle keys are half-duplex. A half-duplex toggle key doesn't report a key release when toggled on and doesn't report a key press when toggled off.

Implements IKeyState.

◆ setOptions()

void PlatformComputer::setOptions ( const OptionsList & options)
overridepure virtual

Notify of options changes.

Set options to given values. Ignore unknown options and don't modify options that aren't given in options.

Implements IPlatformComputer.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ setSequenceNumber()

void PlatformComputer::setSequenceNumber ( uint32_t )
overridepure virtual

Set clipboard sequence number.

Sets the sequence number to use in subsequent clipboard events.

Implements IPlatformComputer.

Implemented in MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ sidesMaskToString()

std::string PlatformComputer::sidesMaskToString ( uint32_t sides)
staticprotected

Converts a sides mask (e.g. LeftMask | RightMask) to a string representation (e.g. "LR").

◆ unregisterHotKey()

void PlatformComputer::unregisterHotKey ( uint32_t id)
overridepure virtual

Unregister a system hotkey.

Unregisters a previously registered hot key.

Implements IPrimaryComputer.

Implemented in MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ updateButtons()

virtual void PlatformComputer::updateButtons ( )
protectedpure virtual

Update mouse buttons.

Subclasses must implement this method to update their internal mouse button mapping and, if desired, state tracking.

Implemented in deskflow::EiComputer, MSWindowsComputer, OSXComputer, and XWindowsComputer.

◆ updateKeyMap()

void PlatformComputer::updateKeyMap ( )
overridevirtual

Update the keyboard map.

Causes the key state to get updated to reflect the current keyboard mapping.

Implements IKeyState.

◆ updateKeyState()

void PlatformComputer::updateKeyState ( )
overridevirtual

Update the key state.

Causes the key state to get updated to reflect the physical keyboard state.

Implements IKeyState.

◆ warpCursor()

void PlatformComputer::warpCursor ( int32_t x,
int32_t y )
overridepure virtual

Warp cursor.

Warp the cursor to the absolute coordinates x,y. Also discard input events up to and including the warp before returning.

Implements IPrimaryComputer.

Implemented in MSWindowsComputer, OSXComputer, and XWindowsComputer.

Member Data Documentation

◆ s_scrollDelta

const auto PlatformComputer::s_scrollDelta = 120
staticprotected

The documentation for this class was generated from the following files: