Deskflow 1.22.0.197
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
OSXScreen Class Reference

Implementation of IPlatformScreen for OS X. More...

#include <OSXScreen.h>

Inheritance diagram for OSXScreen:
Collaboration diagram for OSXScreen:

Public Member Functions

 OSXScreen (IEventQueue *events, bool isPrimary, bool enableLangSync=false, deskflow::ClientScrollDirection scrollDirection=deskflow::ClientScrollDirection::Normal)
virtual ~OSXScreen ()
IEventQueuegetEvents () const
void * getEventTarget () const override
 Get event target.
bool getClipboard (ClipboardID id, IClipboard *) const override
 Get clipboard.
void getShape (int32_t &x, int32_t &y, int32_t &width, int32_t &height) const override
 Get screen shape.
void getCursorPos (int32_t &x, int32_t &y) const override
 Get cursor position.
void reconfigure (uint32_t activeSides) override
 Update configuration.
uint32_t activeSides () override
 activeSides
void warpCursor (int32_t x, int32_t y) override
 Warp cursor.
uint32_t registerHotKey (KeyID key, KeyModifierMask mask) override
 Register a system hotkey.
void unregisterHotKey (uint32_t id) override
 Unregister a system hotkey.
void fakeInputBegin () override
 Prepare to synthesize input on primary screen.
void fakeInputEnd () override
 Done synthesizing input on primary screen.
int32_t getJumpZoneSize () const override
 Get jump zone size.
bool isAnyMouseButtonDown (uint32_t &buttonID) const override
 Test if mouse is pressed.
void getCursorCenter (int32_t &x, int32_t &y) const override
 Get cursor center position.
void fakeMouseButton (ButtonID id, bool press) override
 Fake mouse press/release.
void fakeMouseMove (int32_t x, int32_t y) override
 Fake mouse move.
void fakeMouseRelativeMove (int32_t dx, int32_t dy) const override
 Fake mouse move.
void fakeMouseWheel (int32_t xDelta, int32_t yDelta) const override
 Fake mouse wheel.
void enable () override
 Enable screen.
void disable () override
 Disable screen.
void enter () override
 Enter screen.
bool canLeave () override
 Leave screen.
void leave () override
 Leave screen.
bool setClipboard (ClipboardID, const IClipboard *) override
 Set clipboard.
void checkClipboards () override
 Check clipboard owner.
void openScreensaver (bool notify) override
 Open screen saver.
void closeScreensaver () override
 Close screen saver.
void screensaver (bool activate) override
 Activate/deactivate screen saver.
void resetOptions () override
 Notify of options changes.
void setOptions (const OptionsList &options) override
 Notify of options changes.
void setSequenceNumber (uint32_t) override
 Set clipboard sequence number.
bool isPrimary () const override
 Test if is primary screen.
std::string getSecureInputApp () const override
 Determine the name of the app causing a secure input state.
void waitForCarbonLoop () const
Public Member Functions inherited from PlatformScreen
 PlatformScreen (IEventQueue *events, deskflow::ClientScrollDirection scrollDirection=deskflow::ClientScrollDirection::Normal)
 ~PlatformScreen () override=default
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.
Public Member Functions inherited from IPlatformScreen
 IPlatformScreen (const IEventQueue *events)
bool fakeMediaKey (KeyID id) override
 Fake a media key.
Public Member Functions inherited from IScreen
Public Member Functions inherited from IInterface
virtual ~IInterface ()=default
 Interface destructor does nothing.
Public Member Functions inherited from IPrimaryScreen
Public Member Functions inherited from ISecondaryScreen
Public Member Functions inherited from IKeyState
 IKeyState (const IEventQueue *events)

Protected Member Functions

void handleSystemEvent (const Event &e) override
 Handle system event.
void updateButtons () override
 Update mouse buttons.
IKeyStategetKeyState () const override
 Get the key state.
Protected Member Functions inherited from PlatformScreen
virtual int32_t mapClientScrollDirection (int32_t) const
 mapClientScrollDirection Convert scroll according to client scroll directio

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

Implementation of IPlatformScreen for OS X.

Constructor & Destructor Documentation

◆ OSXScreen()

OSXScreen::OSXScreen ( IEventQueue * events,
bool isPrimary,
bool enableLangSync = false,
deskflow::ClientScrollDirection scrollDirection = deskflow::ClientScrollDirection::Normal )

◆ ~OSXScreen()

OSXScreen::~OSXScreen ( )
virtual

Member Function Documentation

◆ activeSides()

uint32_t OSXScreen::activeSides ( )
overridevirtual

activeSides

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

Implements PlatformScreen.

◆ canLeave()

bool OSXScreen::canLeave ( )
overridevirtual

Leave screen.

Called when the user navigates off the screen. 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 screen. Secondary screens should not fail.

Implements PlatformScreen.

◆ checkClipboards()

void OSXScreen::checkClipboards ( )
overridevirtual

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 PlatformScreen.

◆ closeScreensaver()

void OSXScreen::closeScreensaver ( )
overridevirtual

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 PlatformScreen.

◆ disable()

void OSXScreen::disable ( )
overridevirtual

Disable screen.

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

Implements PlatformScreen.

◆ enable()

void OSXScreen::enable ( )
overridevirtual

Enable screen.

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

Implements PlatformScreen.

◆ enter()

void OSXScreen::enter ( )
overridevirtual

Enter screen.

Called when the user navigates to this screen.

Implements PlatformScreen.

◆ fakeInputBegin()

void OSXScreen::fakeInputBegin ( )
overridevirtual

Prepare to synthesize input on primary screen.

Prepares the primary screen 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 PlatformScreen.

◆ fakeInputEnd()

void OSXScreen::fakeInputEnd ( )
overridevirtual

Done synthesizing input on primary screen.

Undoes whatever fakeInputBegin() did.

Implements PlatformScreen.

◆ fakeMouseButton()

void OSXScreen::fakeMouseButton ( ButtonID id,
bool press )
overridevirtual

Fake mouse press/release.

Synthesize a press or release of mouse button id.

Implements PlatformScreen.

◆ fakeMouseMove()

void OSXScreen::fakeMouseMove ( int32_t x,
int32_t y )
overridevirtual

Fake mouse move.

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

Implements PlatformScreen.

◆ fakeMouseRelativeMove()

void OSXScreen::fakeMouseRelativeMove ( int32_t dx,
int32_t dy ) const
overridevirtual

Fake mouse move.

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

Implements PlatformScreen.

◆ fakeMouseWheel()

void OSXScreen::fakeMouseWheel ( int32_t xDelta,
int32_t yDelta ) const
overridevirtual

Fake mouse wheel.

Synthesize a mouse wheel event of amount xDelta and yDelta.

Implements PlatformScreen.

◆ getClipboard()

bool OSXScreen::getClipboard ( ClipboardID id,
IClipboard *  ) const
overridevirtual

Get clipboard.

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

Implements PlatformScreen.

◆ getCursorCenter()

void OSXScreen::getCursorCenter ( int32_t & x,
int32_t & y ) const
overridevirtual

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 screen, typically the center.

Implements PlatformScreen.

◆ getCursorPos()

void OSXScreen::getCursorPos ( int32_t & x,
int32_t & y ) const
overridevirtual

Get cursor position.

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

Implements PlatformScreen.

◆ getEvents()

IEventQueue * OSXScreen::getEvents ( ) const
inline

◆ getEventTarget()

void * OSXScreen::getEventTarget ( ) const
overridevirtual

Get event target.

Returns the target used for events created by this object.

Implements PlatformScreen.

◆ getJumpZoneSize()

int32_t OSXScreen::getJumpZoneSize ( ) const
overridevirtual

Get jump zone size.

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

Implements PlatformScreen.

◆ getKeyState()

IKeyState * OSXScreen::getKeyState ( ) const
overrideprotectedvirtual

Get the key state.

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

Implements PlatformScreen.

◆ getSecureInputApp()

std::string OSXScreen::getSecureInputApp ( ) const
overridevirtual

Determine the name of the app causing a secure input state.

On MacOS check which app causes a secure input state to be enabled. No alternative on other platforms

Implements IPlatformScreen.

◆ getShape()

void OSXScreen::getShape ( int32_t & x,
int32_t & y,
int32_t & width,
int32_t & height ) const
overridevirtual

Get screen shape.

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

Implements PlatformScreen.

◆ handleSystemEvent()

void OSXScreen::handleSystemEvent ( const Event & event)
overrideprotectedvirtual

Handle system event.

A platform screen 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 IScreen as appropriate.

A primary screen has further responsibilities. It should post the events in IPrimaryScreen 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 PlatformScreen.

◆ isAnyMouseButtonDown()

bool OSXScreen::isAnyMouseButtonDown ( uint32_t & buttonID) const
overridevirtual

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 PlatformScreen.

◆ isPrimary()

bool OSXScreen::isPrimary ( ) const
overridevirtual

Test if is primary screen.

Return true iff this screen is a primary screen.

Implements PlatformScreen.

◆ leave()

void OSXScreen::leave ( )
overridevirtual

Leave screen.

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

Implements PlatformScreen.

◆ openScreensaver()

void OSXScreen::openScreensaver ( bool notify)
overridevirtual

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 PlatformScreen.

◆ reconfigure()

void OSXScreen::reconfigure ( uint32_t activeSides)
overridevirtual

Update configuration.

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

Implements PlatformScreen.

◆ registerHotKey()

uint32_t OSXScreen::registerHotKey ( KeyID key,
KeyModifierMask mask )
overridevirtual

Register a system hotkey.

Registers a system-wide hotkey. The screen should arrange for an event to be delivered to itself when the hot key is pressed or released. When that happens the screen 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 PlatformScreen.

◆ resetOptions()

void OSXScreen::resetOptions ( )
overridevirtual

Notify of options changes.

Reset all options to their default values.

Implements PlatformScreen.

◆ screensaver()

void OSXScreen::screensaver ( bool activate)
overridevirtual

Activate/deactivate screen saver.

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

Implements PlatformScreen.

◆ setClipboard()

bool OSXScreen::setClipboard ( ClipboardID id,
const IClipboard *  )
overridevirtual

Set clipboard.

Set the contents of the system clipboard indicated by id.

Implements PlatformScreen.

◆ setOptions()

void OSXScreen::setOptions ( const OptionsList & options)
overridevirtual

Notify of options changes.

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

Implements PlatformScreen.

◆ setSequenceNumber()

void OSXScreen::setSequenceNumber ( uint32_t )
overridevirtual

Set clipboard sequence number.

Sets the sequence number to use in subsequent clipboard events.

Implements PlatformScreen.

◆ unregisterHotKey()

void OSXScreen::unregisterHotKey ( uint32_t id)
overridevirtual

Unregister a system hotkey.

Unregisters a previously registered hot key.

Implements PlatformScreen.

◆ updateButtons()

void OSXScreen::updateButtons ( )
overrideprotectedvirtual

Update mouse buttons.

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

Implements PlatformScreen.

◆ waitForCarbonLoop()

void OSXScreen::waitForCarbonLoop ( ) const

◆ warpCursor()

void OSXScreen::warpCursor ( int32_t x,
int32_t y )
overridevirtual

Warp cursor.

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

Implements PlatformScreen.


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