id
int64 0
755k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
65
| repo_stars
int64 100
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 9
values | repo_extraction_date
stringclasses 92
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
13,889
|
ClientProxy1_4.h
|
deskflow_deskflow/src/lib/server/ClientProxy1_4.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "server/ClientProxy1_3.h"
class Server;
//! Proxy for client implementing protocol version 1.4
class ClientProxy1_4 : public ClientProxy1_3
{
public:
ClientProxy1_4(const String &name, deskflow::IStream *adoptedStream, Server *server, IEventQueue *events);
~ClientProxy1_4();
//! @name accessors
//@{
//! get server pointer
Server *getServer()
{
return m_server;
}
//@}
// IClient overrides
virtual void keyDown(KeyID key, KeyModifierMask mask, KeyButton button, const String &);
virtual void keyRepeat(KeyID key, KeyModifierMask mask, SInt32 count, KeyButton button, const String &lang);
virtual void keyUp(KeyID key, KeyModifierMask mask, KeyButton button);
virtual void keepAlive();
Server *m_server;
};
| 1,502
|
C++
|
.h
| 41
| 34.195122
| 110
| 0.75551
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,890
|
ClientProxyUnknown.h
|
deskflow_deskflow/src/lib/server/ClientProxyUnknown.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/Event.h"
#include "base/EventTypes.h"
#include "base/String.h"
#include "deskflow/option_types.h"
class ClientProxy;
class EventQueueTimer;
namespace deskflow {
class IStream;
}
class Server;
class IEventQueue;
class ClientProxyUnknown
{
public:
ClientProxyUnknown(deskflow::IStream *stream, double timeout, Server *server, IEventQueue *events);
ClientProxyUnknown(ClientProxyUnknown const &) = delete;
ClientProxyUnknown(ClientProxyUnknown &&) = delete;
~ClientProxyUnknown();
ClientProxyUnknown &operator=(ClientProxyUnknown const &) = delete;
ClientProxyUnknown &operator=(ClientProxyUnknown &&) = delete;
//! @name manipulators
//@{
//! Get the client proxy
/*!
Returns the client proxy created after a successful handshake
(i.e. when this object sends a success event). Returns NULL
if the handshake is unsuccessful or incomplete.
*/
ClientProxy *orphanClientProxy();
//! Get the stream
deskflow::IStream *getStream()
{
return m_stream;
}
//@}
private:
void sendSuccess();
void sendFailure();
void addStreamHandlers();
void addProxyHandlers();
void removeHandlers();
void initProxy(const String &name, int major, int minor);
void removeTimer();
void handleData(const Event &, void *);
void handleWriteError(const Event &, void *);
void handleTimeout(const Event &, void *);
void handleDisconnect(const Event &, void *);
void handleReady(const Event &, void *);
private:
deskflow::IStream *m_stream;
EventQueueTimer *m_timer;
ClientProxy *m_proxy;
bool m_ready;
Server *m_server;
IEventQueue *m_events;
};
| 2,360
|
C++
|
.h
| 74
| 29.445946
| 101
| 0.754725
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,891
|
InputFilter.h
|
deskflow_deskflow/src/lib/server/InputFilter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2005 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/String.h"
#include "common/stdmap.h"
#include "common/stdset.h"
#include "deskflow/IPlatformScreen.h"
#include "deskflow/key_types.h"
#include "deskflow/mouse_types.h"
#include "deskflow/protocol_types.h"
class PrimaryClient;
class Event;
class IEventQueue;
class InputFilter
{
public:
// -------------------------------------------------------------------------
// Input Filter Condition Classes
// -------------------------------------------------------------------------
enum EFilterStatus
{
kNoMatch,
kActivate,
kDeactivate
};
class Condition
{
public:
Condition();
virtual ~Condition();
virtual Condition *clone() const = 0;
virtual String format() const = 0;
virtual EFilterStatus match(const Event &) = 0;
virtual void enablePrimary(PrimaryClient *);
virtual void disablePrimary(PrimaryClient *);
};
// KeystrokeCondition
class KeystrokeCondition : public Condition
{
public:
KeystrokeCondition(IEventQueue *events, IPlatformScreen::KeyInfo *);
KeystrokeCondition(IEventQueue *events, KeyID key, KeyModifierMask mask);
virtual ~KeystrokeCondition();
KeyID getKey() const;
KeyModifierMask getMask() const;
// Condition overrides
virtual Condition *clone() const;
virtual String format() const;
virtual EFilterStatus match(const Event &);
virtual void enablePrimary(PrimaryClient *);
virtual void disablePrimary(PrimaryClient *);
private:
UInt32 m_id;
KeyID m_key;
KeyModifierMask m_mask;
IEventQueue *m_events;
};
// MouseButtonCondition
class MouseButtonCondition : public Condition
{
public:
MouseButtonCondition(IEventQueue *events, IPlatformScreen::ButtonInfo *);
MouseButtonCondition(IEventQueue *events, ButtonID, KeyModifierMask mask);
virtual ~MouseButtonCondition();
ButtonID getButton() const;
KeyModifierMask getMask() const;
// Condition overrides
virtual Condition *clone() const;
virtual String format() const;
virtual EFilterStatus match(const Event &);
private:
ButtonID m_button;
KeyModifierMask m_mask;
IEventQueue *m_events;
};
// ScreenConnectedCondition
class ScreenConnectedCondition : public Condition
{
public:
ScreenConnectedCondition(IEventQueue *events, const String &screen);
virtual ~ScreenConnectedCondition();
// Condition overrides
virtual Condition *clone() const;
virtual String format() const;
virtual EFilterStatus match(const Event &);
private:
String m_screen;
IEventQueue *m_events;
};
// -------------------------------------------------------------------------
// Input Filter Action Classes
// -------------------------------------------------------------------------
class Action
{
public:
Action();
virtual ~Action();
virtual Action *clone() const = 0;
virtual String format() const = 0;
virtual void perform(const Event &) = 0;
};
// LockCursorToScreenAction
class LockCursorToScreenAction : public Action
{
public:
enum Mode
{
kOff,
kOn,
kToggle
};
LockCursorToScreenAction(IEventQueue *events, Mode = kToggle);
Mode getMode() const;
// Action overrides
virtual Action *clone() const;
virtual String format() const;
virtual void perform(const Event &);
private:
Mode m_mode;
IEventQueue *m_events;
};
class RestartServer : public Action
{
public:
enum Mode
{
restart
};
RestartServer(IEventQueue *events, Mode = restart);
Mode getMode() const;
// Action overrides
virtual Action *clone() const;
virtual String format() const;
virtual void perform(const Event &);
private:
Mode m_mode;
IEventQueue *m_events;
};
// SwitchToScreenAction
class SwitchToScreenAction : public Action
{
public:
SwitchToScreenAction(IEventQueue *events, const String &screen);
String getScreen() const;
// Action overrides
virtual Action *clone() const;
virtual String format() const;
virtual void perform(const Event &);
private:
String m_screen;
IEventQueue *m_events;
};
// SwitchInDirectionAction
class SwitchInDirectionAction : public Action
{
public:
SwitchInDirectionAction(IEventQueue *events, EDirection);
EDirection getDirection() const;
// Action overrides
virtual Action *clone() const;
virtual String format() const;
virtual void perform(const Event &);
private:
EDirection m_direction;
IEventQueue *m_events;
};
// KeyboardBroadcastAction
class KeyboardBroadcastAction : public Action
{
public:
enum Mode
{
kOff,
kOn,
kToggle
};
KeyboardBroadcastAction(IEventQueue *events, Mode = kToggle);
KeyboardBroadcastAction(IEventQueue *events, Mode, const std::set<String> &screens);
Mode getMode() const;
std::set<String> getScreens() const;
// Action overrides
virtual Action *clone() const;
virtual String format() const;
virtual void perform(const Event &);
private:
Mode m_mode;
String m_screens;
IEventQueue *m_events;
};
// KeystrokeAction
class KeystrokeAction : public Action
{
public:
KeystrokeAction(IEventQueue *events, IPlatformScreen::KeyInfo *adoptedInfo, bool press);
KeystrokeAction(KeystrokeAction const &) = delete;
KeystrokeAction(KeystrokeAction &&) = delete;
~KeystrokeAction();
KeystrokeAction &operator=(KeystrokeAction const &) = delete;
KeystrokeAction &operator=(KeystrokeAction &&) = delete;
void adoptInfo(IPlatformScreen::KeyInfo *);
const IPlatformScreen::KeyInfo *getInfo() const;
bool isOnPress() const;
// Action overrides
virtual Action *clone() const;
virtual String format() const;
virtual void perform(const Event &);
protected:
virtual const char *formatName() const;
private:
IPlatformScreen::KeyInfo *m_keyInfo;
bool m_press;
IEventQueue *m_events;
};
// MouseButtonAction -- modifier combinations not implemented yet
class MouseButtonAction : public Action
{
public:
MouseButtonAction(IEventQueue *events, IPlatformScreen::ButtonInfo *adoptedInfo, bool press);
MouseButtonAction(MouseButtonAction const &) = delete;
MouseButtonAction(MouseButtonAction &&) = delete;
~MouseButtonAction();
MouseButtonAction &operator=(MouseButtonAction const &) = delete;
MouseButtonAction &operator=(MouseButtonAction &&) = delete;
const IPlatformScreen::ButtonInfo *getInfo() const;
bool isOnPress() const;
// Action overrides
virtual Action *clone() const;
virtual String format() const;
virtual void perform(const Event &);
protected:
virtual const char *formatName() const;
private:
IPlatformScreen::ButtonInfo *m_buttonInfo;
bool m_press;
IEventQueue *m_events;
};
class Rule
{
public:
Rule();
Rule(Condition *adopted);
Rule(const Rule &);
~Rule();
Rule &operator=(const Rule &);
// replace the condition
void setCondition(Condition *adopted);
// add an action to the rule
void adoptAction(Action *, bool onActivation);
// remove an action from the rule
void removeAction(bool onActivation, UInt32 index);
// replace an action in the rule
void replaceAction(Action *adopted, bool onActivation, UInt32 index);
// enable/disable
void enable(PrimaryClient *);
void disable(PrimaryClient *);
// event handling
bool handleEvent(const Event &);
// convert rule to a string
String format() const;
// get the rule's condition
const Condition *getCondition() const;
// get number of actions
UInt32 getNumActions(bool onActivation) const;
// get action by index
const Action &getAction(bool onActivation, UInt32 index) const;
private:
void clear();
void copy(const Rule &);
private:
typedef std::vector<Action *> ActionList;
Condition *m_condition;
ActionList m_activateActions;
ActionList m_deactivateActions;
};
// -------------------------------------------------------------------------
// Input Filter Class
// -------------------------------------------------------------------------
typedef std::vector<Rule> RuleList;
InputFilter(IEventQueue *events);
InputFilter(const InputFilter &);
virtual ~InputFilter();
#ifdef TEST_ENV
InputFilter() : m_primaryClient(NULL)
{
}
#endif
InputFilter &operator=(const InputFilter &);
// add rule, adopting the condition and the actions
void addFilterRule(const Rule &rule);
// remove a rule
void removeFilterRule(UInt32 index);
// get rule by index
Rule &getRule(UInt32 index);
// enable event filtering using the given primary client. disable
// if client is NULL.
virtual void setPrimaryClient(PrimaryClient *client);
// convert rules to a string
String format(const String &linePrefix) const;
// get number of rules
UInt32 getNumRules() const;
//! Compare filters
bool operator==(const InputFilter &) const;
//! Compare filters
bool operator!=(const InputFilter &) const;
private:
// event handling
void handleEvent(const Event &, void *);
private:
RuleList m_ruleList;
PrimaryClient *m_primaryClient;
IEventQueue *m_events;
};
| 10,118
|
C++
|
.h
| 327
| 26.743119
| 97
| 0.688099
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,892
|
ClientProxy1_7.h
|
deskflow_deskflow/src/lib/server/ClientProxy1_7.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "server/ClientProxy1_6.h"
//! Proxy for client implementing protocol version 1.7
class ClientProxy1_7 : public ClientProxy1_6
{
public:
ClientProxy1_7(const String &name, deskflow::IStream *adoptedStream, Server *server, IEventQueue *events);
~ClientProxy1_7() override = default;
void secureInputNotification(const String &app) const override;
private:
IEventQueue *m_events;
};
| 1,106
|
C++
|
.h
| 28
| 37.5
| 108
| 0.771668
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,893
|
ClientListener.h
|
deskflow_deskflow/src/lib/server/ClientListener.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/Event.h"
#include "base/EventTypes.h"
#include "common/stddeque.h"
#include "common/stdset.h"
#include "server/Config.h"
class ClientProxy;
class ClientProxyUnknown;
class NetworkAddress;
class IListenSocket;
class ISocketFactory;
class Server;
class IEventQueue;
class IDataSocket;
class ClientListener
{
public:
// The factories are adopted.
ClientListener(const NetworkAddress &, ISocketFactory *, IEventQueue *events, bool enableCrypto);
ClientListener(ClientListener const &) = delete;
ClientListener(ClientListener &&) = delete;
~ClientListener();
ClientListener &operator=(ClientListener const &) = delete;
ClientListener &operator=(ClientListener &&) = delete;
//! @name manipulators
//@{
void setServer(Server *server);
//@}
//! @name accessors
//@{
//! Get next connected client
/*!
Returns the next connected client and removes it from the internal
list. The client is responsible for deleting the returned client.
Returns NULL if no clients are available.
*/
ClientProxy *getNextClient();
//! Get server which owns this listener
Server *getServer()
{
return m_server;
}
//! This method restarts the listener
void restart();
//@}
private:
// client connection event handlers
void handleClientConnecting(const Event &, void *);
void handleClientAccepted(const Event &, void *);
void handleUnknownClient(const Event &, void *);
void handleUnknownClientFailure(const Event &, void *);
void handleClientDisconnected(const Event &, void *);
void cleanupListenSocket();
void cleanupClientSockets();
void start();
void stop();
void removeUnknownClient(ClientProxyUnknown *unknownClient);
private:
typedef std::set<ClientProxyUnknown *> NewClients;
typedef std::deque<ClientProxy *> WaitingClients;
typedef std::set<IDataSocket *> ClientSockets;
IListenSocket *m_listen;
ISocketFactory *m_socketFactory;
NewClients m_newClients;
WaitingClients m_waitingClients;
Server *m_server;
IEventQueue *m_events;
bool m_useSecureNetwork;
ClientSockets m_clientSockets;
NetworkAddress m_address;
};
| 2,871
|
C++
|
.h
| 88
| 30.068182
| 99
| 0.764642
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,894
|
ClientProxy1_0.h
|
deskflow_deskflow/src/lib/server/ClientProxy1_0.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "deskflow/Clipboard.h"
#include "deskflow/protocol_types.h"
#include "server/ClientProxy.h"
class Event;
class EventQueueTimer;
class IEventQueue;
//! Proxy for client implementing protocol version 1.0
class ClientProxy1_0 : public ClientProxy
{
public:
ClientProxy1_0(const String &name, deskflow::IStream *adoptedStream, IEventQueue *events);
ClientProxy1_0(ClientProxy1_0 const &) = delete;
ClientProxy1_0(ClientProxy1_0 &&) = delete;
~ClientProxy1_0();
ClientProxy1_0 &operator=(ClientProxy1_0 const &) = delete;
ClientProxy1_0 &operator=(ClientProxy1_0 &&) = delete;
// IScreen
bool getClipboard(ClipboardID id, IClipboard *) const override;
void getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const override;
void getCursorPos(SInt32 &x, SInt32 &y) const override;
// IClient overrides
void enter(SInt32 xAbs, SInt32 yAbs, UInt32 seqNum, KeyModifierMask mask, bool forScreensaver) override;
bool leave() override;
void setClipboard(ClipboardID, const IClipboard *) override;
void grabClipboard(ClipboardID) override;
void setClipboardDirty(ClipboardID, bool) override;
void keyDown(KeyID, KeyModifierMask, KeyButton, const String &) override;
void keyRepeat(KeyID, KeyModifierMask, SInt32 count, KeyButton, const String &) override;
void keyUp(KeyID, KeyModifierMask, KeyButton) override;
void mouseDown(ButtonID) override;
void mouseUp(ButtonID) override;
void mouseMove(SInt32 xAbs, SInt32 yAbs) override;
void mouseRelativeMove(SInt32 xRel, SInt32 yRel) override;
void mouseWheel(SInt32 xDelta, SInt32 yDelta) override;
void screensaver(bool activate) override;
void resetOptions() override;
void setOptions(const OptionsList &options) override;
void sendDragInfo(UInt32 fileCount, const char *info, size_t size) override;
void fileChunkSending(UInt8 mark, char *data, size_t dataSize) override;
String getSecureInputApp() const override;
void secureInputNotification(const String &app) const override;
protected:
virtual bool parseHandshakeMessage(const UInt8 *code);
virtual bool parseMessage(const UInt8 *code);
virtual void resetHeartbeatRate();
virtual void setHeartbeatRate(double rate, double alarm);
virtual void resetHeartbeatTimer();
virtual void addHeartbeatTimer();
virtual void removeHeartbeatTimer();
virtual bool recvClipboard();
private:
void disconnect();
void removeHandlers();
void handleData(const Event &, void *);
void handleDisconnect(const Event &, void *);
void handleWriteError(const Event &, void *);
void handleFlatline(const Event &, void *);
bool recvInfo();
bool recvGrabClipboard();
protected:
struct ClientClipboard
{
public:
ClientClipboard();
public:
Clipboard m_clipboard;
UInt32 m_sequenceNumber;
bool m_dirty;
};
ClientClipboard m_clipboard[kClipboardEnd];
private:
typedef bool (ClientProxy1_0::*MessageParser)(const UInt8 *);
ClientInfo m_info;
double m_heartbeatAlarm;
EventQueueTimer *m_heartbeatTimer;
MessageParser m_parser;
IEventQueue *m_events;
};
| 3,822
|
C++
|
.h
| 96
| 37.072917
| 106
| 0.776759
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,895
|
Config.h
|
deskflow_deskflow/src/lib/server/Config.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/String.h"
#include "base/XBase.h"
#include "common/stdmap.h"
#include "common/stdset.h"
#include "deskflow/IPlatformScreen.h"
#include "deskflow/option_types.h"
#include "deskflow/protocol_types.h"
#include "net/NetworkAddress.h"
#include "server/InputFilter.h"
#include <iosfwd>
namespace deskflow::server {
class Config;
class ConfigReadContext;
} // namespace deskflow::server
class IEventQueue;
namespace std {
template <> struct iterator_traits<deskflow::server::Config>
{
typedef String value_type;
typedef ptrdiff_t difference_type;
typedef bidirectional_iterator_tag iterator_category;
typedef String *pointer;
typedef String &reference;
};
}; // namespace std
namespace deskflow::server {
//! Server configuration
/*!
This class holds server configuration information. That includes
the names of screens and their aliases, the links between them,
and network addresses.
Note that case is preserved in screen names but is ignored when
comparing names. Screen names and their aliases share a
namespace and must be unique.
*/
class Config
{
public:
typedef std::map<OptionID, OptionValue> ScreenOptions;
typedef std::pair<float, float> Interval;
class CellEdge
{
public:
CellEdge(EDirection side, float position);
CellEdge(EDirection side, const Interval &);
CellEdge(const String &name, EDirection side, const Interval &);
~CellEdge();
Interval getInterval() const;
void setName(const String &newName);
String getName() const;
EDirection getSide() const;
bool overlaps(const CellEdge &) const;
bool isInside(float x) const;
// transform position to [0,1]
float transform(float x) const;
// transform [0,1] to position
float inverseTransform(float x) const;
// compares side and start of interval
bool operator<(const CellEdge &) const;
// compares side and interval
bool operator==(const CellEdge &) const;
bool operator!=(const CellEdge &) const;
private:
void init(const String &name, EDirection side, const Interval &);
private:
String m_name;
EDirection m_side;
Interval m_interval;
};
private:
class Name
{
public:
Name(Config *, const String &name);
bool operator==(const String &name) const;
private:
Config *m_config;
String m_name;
};
class Cell
{
private:
typedef std::map<CellEdge, CellEdge> EdgeLinks;
public:
typedef EdgeLinks::const_iterator const_iterator;
bool add(const CellEdge &src, const CellEdge &dst);
void remove(EDirection side);
void remove(EDirection side, float position);
void remove(const Name &destinationName);
void rename(const Name &oldName, const String &newName);
bool hasEdge(const CellEdge &) const;
bool overlaps(const CellEdge &) const;
bool getLink(EDirection side, float position, const CellEdge *&src, const CellEdge *&dst) const;
bool operator==(const Cell &) const;
bool operator!=(const Cell &) const;
const_iterator begin() const;
const_iterator end() const;
private:
EdgeLinks m_neighbors;
public:
ScreenOptions m_options;
};
typedef std::map<String, Cell, deskflow::string::CaselessCmp> CellMap;
typedef std::map<String, String, deskflow::string::CaselessCmp> NameMap;
public:
typedef Cell::const_iterator link_const_iterator;
typedef CellMap::const_iterator internal_const_iterator;
typedef NameMap::const_iterator all_const_iterator;
class const_iterator : std::iterator_traits<Config>
{
public:
explicit const_iterator() : m_i()
{
}
explicit const_iterator(const internal_const_iterator &i) : m_i(i)
{
}
const_iterator(const const_iterator &src) = default;
~const_iterator() = default;
const_iterator &operator=(const const_iterator &i)
{
m_i = i.m_i;
return *this;
}
String operator*()
{
return m_i->first;
}
const String *operator->()
{
return &(m_i->first);
}
const_iterator &operator++()
{
++m_i;
return *this;
}
const_iterator operator++(int)
{
return const_iterator(m_i++);
}
const_iterator &operator--()
{
--m_i;
return *this;
}
const_iterator operator--(int)
{
return const_iterator(m_i--);
}
bool operator==(const const_iterator &i) const
{
return (m_i == i.m_i);
}
bool operator!=(const const_iterator &i) const
{
return (m_i != i.m_i);
}
private:
internal_const_iterator m_i;
};
Config(IEventQueue *events);
virtual ~Config();
#ifdef TEST_ENV
Config() : m_inputFilter(NULL)
{
}
#endif
//! @name manipulators
//@{
//! Add screen
/*!
Adds a screen, returning true iff successful. If a screen or
alias with the given name exists then it fails.
*/
bool addScreen(const String &name);
//! Rename screen
/*!
Renames a screen. All references to the name are updated.
Returns true iff successful.
*/
bool renameScreen(const String &oldName, const String &newName);
//! Remove screen
/*!
Removes a screen. This also removes aliases for the screen and
disconnects any connections to the screen. \c name may be an
alias.
*/
void removeScreen(const String &name);
//! Remove all screens
/*!
Removes all screens, aliases, and connections.
*/
void removeAllScreens();
//! Add alias
/*!
Adds an alias for a screen name. An alias can be used
any place the canonical screen name can (except addScreen()).
Returns false if the alias name already exists or the canonical
name is unknown, otherwise returns true.
*/
bool addAlias(const String &canonical, const String &alias);
//! Remove alias
/*!
Removes an alias for a screen name. It returns false if the
alias is unknown or a canonical name, otherwise returns true.
*/
bool removeAlias(const String &alias);
//! Remove aliases
/*!
Removes all aliases for a canonical screen name. It returns false
if the canonical name is unknown, otherwise returns true.
*/
bool removeAliases(const String &canonical);
//! Remove all aliases
/*!
This removes all aliases but not the screens.
*/
void removeAllAliases();
//! Connect screens
/*!
Establishes a one-way connection between portions of opposite edges
of two screens. Each portion is described by an interval defined
by two numbers, the start and end of the interval half-open on the
end. The numbers range from 0 to 1, inclusive, for the left/top
to the right/bottom. The user will be able to jump from the
\c srcStart to \c srcSend interval of \c srcSide of screen
\c srcName to the opposite side of screen \c dstName in the interval
\c dstStart and \c dstEnd when both screens are connected to the
server and the user isn't locked to a screen. Returns false if
\c srcName is unknown. \c srcStart must be less than or equal to
\c srcEnd and \c dstStart must be less then or equal to \c dstEnd
and all of \c srcStart, \c srcEnd, \c dstStart, or \c dstEnd must
be inside the range [0,1].
*/
bool connect(
const String &srcName, EDirection srcSide, float srcStart, float srcEnd, const String &dstName, float dstStart,
float dstEnd
);
//! Disconnect screens
/*!
Removes all connections created by connect() on side \c srcSide.
Returns false if \c srcName is unknown.
*/
bool disconnect(const String &srcName, EDirection srcSide);
//! Disconnect screens
/*!
Removes the connections created by connect() on side \c srcSide
covering position \c position. Returns false if \c srcName is
unknown.
*/
bool disconnect(const String &srcName, EDirection srcSide, float position);
//! Set server address
/*!
Set the deskflow listen addresses. There is no default address so
this must be called to run a server using this configuration.
*/
void setDeskflowAddress(const NetworkAddress &);
//! Add a screen option
/*!
Adds an option and its value to the named screen. Replaces the
existing option's value if there is one. Returns true iff \c name
is a known screen.
*/
bool addOption(const String &name, OptionID option, OptionValue value);
//! Remove a screen option
/*!
Removes an option and its value from the named screen. Does
nothing if the option doesn't exist on the screen. Returns true
iff \c name is a known screen.
*/
bool removeOption(const String &name, OptionID option);
//! Remove a screen options
/*!
Removes all options and values from the named screen. Returns true
iff \c name is a known screen.
*/
bool removeOptions(const String &name);
//! Get the hot key input filter
/*!
Returns the hot key input filter. Clients can modify hotkeys using
that object.
*/
virtual InputFilter *getInputFilter();
//@}
//! @name accessors
//@{
//! Test screen name validity
/*!
Returns true iff \c name is a valid screen name.
*/
bool isValidScreenName(const String &name) const;
//! Get beginning (canonical) screen name iterator
const_iterator begin() const;
//! Get ending (canonical) screen name iterator
const_iterator end() const;
//! Get beginning screen name iterator
all_const_iterator beginAll() const;
//! Get ending screen name iterator
all_const_iterator endAll() const;
//! Test for screen name
/*!
Returns true iff \c name names a screen.
*/
virtual bool isScreen(const String &name) const;
//! Test for canonical screen name
/*!
Returns true iff \c name is the canonical name of a screen.
*/
bool isCanonicalName(const String &name) const;
//! Get canonical name
/*!
Returns the canonical name of a screen or the empty string if
the name is unknown. Returns the canonical name if one is given.
*/
String getCanonicalName(const String &name) const;
//! Get neighbor
/*!
Returns the canonical screen name of the neighbor in the given
direction (set through connect()) at position \c position. Returns
the empty string if there is no neighbor in that direction, otherwise
saves the position on the neighbor in \c positionOut if it's not
\c NULL.
*/
String getNeighbor(const String &, EDirection, float position, float *positionOut) const;
//! Check for neighbor
/*!
Returns \c true if the screen has a neighbor anywhere along the edge
given by the direction.
*/
bool hasNeighbor(const String &, EDirection) const;
//! Check for neighbor
/*!
Returns \c true if the screen has a neighbor in the given range along
the edge given by the direction.
*/
bool hasNeighbor(const String &, EDirection, float start, float end) const;
//! Get beginning neighbor iterator
link_const_iterator beginNeighbor(const String &) const;
//! Get ending neighbor iterator
link_const_iterator endNeighbor(const String &) const;
//! Get the server address
const NetworkAddress &getDeskflowAddress() const;
//! Get the screen options
/*!
Returns all the added options for the named screen. Returns NULL
if the screen is unknown and an empty collection if there are no
options.
*/
const ScreenOptions *getOptions(const String &name) const;
//! Check for lock to screen action
/*!
Returns \c true if this configuration has a lock to screen action.
This is for backwards compatible support of ScrollLock locking.
*/
bool hasLockToScreenAction() const;
//! Compare configurations
bool operator==(const Config &) const;
//! Compare configurations
bool operator!=(const Config &) const;
//! Read configuration
/*!
Reads a configuration from a context. Throws XConfigRead on error
and context is unchanged.
*/
void read(ConfigReadContext &context);
//! Read configuration
/*!
Reads a configuration from a stream. Throws XConfigRead on error.
*/
friend std::istream &operator>>(std::istream &, Config &);
//! Write configuration
/*!
Writes a configuration to a stream.
*/
friend std::ostream &operator<<(std::ostream &, const Config &);
//! Get direction name
/*!
Returns the name of a direction (for debugging).
*/
static const char *dirName(EDirection);
//! Get interval as string
/*!
Returns an interval as a parseable string.
*/
static String formatInterval(const Interval &);
//! Get client address as a string
/*!
* Return client address a string.
*/
String getClientAddress() const;
//! Return true if server started in client mode
/*!
* In client mode the server initiates connection to client
*/
bool isClientMode() const;
//@}
private:
void readSection(ConfigReadContext &);
void readSectionOptions(ConfigReadContext &);
void readSectionScreens(ConfigReadContext &);
void readSectionLinks(ConfigReadContext &);
void readSectionAliases(ConfigReadContext &);
InputFilter::Condition *parseCondition(ConfigReadContext &, const String &condition, const std::vector<String> &args);
void parseAction(
ConfigReadContext &, const String &action, const std::vector<String> &args, InputFilter::Rule &, bool activate
);
void parseScreens(ConfigReadContext &, const String &, std::set<String> &screens) const;
static const char *getOptionName(OptionID);
static String getOptionValue(OptionID, OptionValue);
private:
CellMap m_map;
NameMap m_nameToCanonicalName;
NetworkAddress m_deskflowAddress;
ScreenOptions m_globalOptions;
InputFilter m_inputFilter;
bool m_hasLockToScreenAction;
IEventQueue *m_events;
String m_ClientAddress;
};
//! Configuration read context
/*!
Maintains a context when reading a configuration from a stream.
*/
class ConfigReadContext
{
public:
typedef std::vector<String> ArgList;
ConfigReadContext(std::istream &, SInt32 firstLine = 1);
~ConfigReadContext();
bool readLine(String &);
UInt32 getLineNumber() const;
bool operator!() const;
OptionValue parseBoolean(const String &) const;
OptionValue parseInt(const String &) const;
OptionValue parseModifierKey(const String &) const;
OptionValue parseCorner(const String &) const;
OptionValue parseCorners(const String &) const;
OptionValue parseProtocol(const String &) const;
Config::Interval parseInterval(const ArgList &args) const;
void parseNameWithArgs(
const String &type, const String &line, const String &delim, String::size_type &index, String &name, ArgList &args
) const;
IPlatformScreen::KeyInfo *parseKeystroke(const String &keystroke) const;
IPlatformScreen::KeyInfo *parseKeystroke(const String &keystroke, const std::set<String> &screens) const;
IPlatformScreen::ButtonInfo *parseMouse(const String &mouse) const;
KeyModifierMask parseModifier(const String &modifiers) const;
std::istream &getStream() const
{
return m_stream;
};
private:
// not implemented
ConfigReadContext &operator=(const ConfigReadContext &);
static String concatArgs(const ArgList &args);
private:
std::istream &m_stream;
SInt32 m_line;
};
//! Configuration stream read exception
/*!
Thrown when a configuration stream cannot be parsed.
*/
class XConfigRead : public XBase
{
public:
XConfigRead(const ConfigReadContext &context, const String &);
XConfigRead(const ConfigReadContext &context, const char *errorFmt, const String &arg);
virtual ~XConfigRead() _NOEXCEPT;
protected:
// XBase overrides
virtual String getWhat() const throw();
private:
String m_error;
};
} // namespace deskflow::server
| 16,210
|
C++
|
.h
| 494
| 29.45749
| 120
| 0.730577
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,896
|
PrimaryClient.h
|
deskflow_deskflow/src/lib/server/PrimaryClient.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "deskflow/protocol_types.h"
#include "server/BaseClientProxy.h"
namespace deskflow {
class Screen;
}
//! Primary screen as pseudo-client
/*!
The primary screen does not have a client associated with it. This
class provides a pseudo-client to allow the primary screen to be
treated as if it was a client.
*/
class PrimaryClient : public BaseClientProxy
{
public:
/*!
\c name is the name of the server and \p screen is primary screen.
*/
PrimaryClient(const String &name, deskflow::Screen *screen);
~PrimaryClient();
#ifdef TEST_ENV
PrimaryClient() : BaseClientProxy("")
{
}
#endif
//! @name manipulators
//@{
//! Update configuration
/*!
Handles reconfiguration of jump zones.
*/
virtual void reconfigure(UInt32 activeSides);
//! Register a system hotkey
/*!
Registers a system-wide hotkey for key \p key with modifiers \p mask.
Returns an id used to unregister the hotkey.
*/
virtual UInt32 registerHotKey(KeyID key, KeyModifierMask mask);
//! Unregister a system hotkey
/*!
Unregisters a previously registered hot key.
*/
virtual void unregisterHotKey(UInt32 id);
//! 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 \c fakeInputBegin() and
\c fakeInputEnd() may be nested; only the outermost have an effect.
*/
void fakeInputBegin();
//! Done synthesizing input on primary screen
/*!
Undoes whatever \c fakeInputBegin() did.
*/
void fakeInputEnd();
//@}
//! @name accessors
//@{
//! 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.
*/
SInt32 getJumpZoneSize() const;
//! 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.
*/
void getCursorCenter(SInt32 &x, SInt32 &y) const;
//! Get toggle key state
/*!
Returns the primary screen's current toggle modifier key state.
*/
virtual KeyModifierMask getToggleMask() const;
//! Get screen lock state
/*!
Returns true if the user is locked to the screen.
*/
bool isLockedToScreen() const;
//@}
// FIXME -- these probably belong on IScreen
virtual void enable();
virtual void disable();
// IScreen overrides
void *getEventTarget() const override;
bool getClipboard(ClipboardID id, IClipboard *) const override;
void getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const override;
void getCursorPos(SInt32 &x, SInt32 &y) const override;
// IClient overrides
void enter(SInt32 xAbs, SInt32 yAbs, UInt32 seqNum, KeyModifierMask mask, bool forScreensaver) override;
bool leave() override;
void setClipboard(ClipboardID, const IClipboard *) override;
void grabClipboard(ClipboardID) override;
void setClipboardDirty(ClipboardID, bool) override;
void keyDown(KeyID, KeyModifierMask, KeyButton, const String &) override;
void keyRepeat(KeyID, KeyModifierMask, SInt32 count, KeyButton, const String &) override;
void keyUp(KeyID, KeyModifierMask, KeyButton) override;
void mouseDown(ButtonID) override;
void mouseUp(ButtonID) override;
void mouseMove(SInt32 xAbs, SInt32 yAbs) override;
void mouseRelativeMove(SInt32 xRel, SInt32 yRel) override;
void mouseWheel(SInt32 xDelta, SInt32 yDelta) override;
void screensaver(bool activate) override;
void resetOptions() override;
void setOptions(const OptionsList &options) override;
void sendDragInfo(UInt32 fileCount, const char *info, size_t size) override;
void fileChunkSending(UInt8 mark, char *data, size_t dataSize) override;
String getSecureInputApp() const override;
void secureInputNotification(const String &app) const override;
deskflow::IStream *getStream() const override
{
return nullptr;
}
bool isPrimary() const override
{
return true;
}
private:
deskflow::Screen *m_screen;
bool m_clipboardDirty[kClipboardEnd];
SInt32 m_fakeInputCount;
};
| 4,971
|
C++
|
.h
| 142
| 32.21831
| 106
| 0.755149
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,897
|
ClientProxy.h
|
deskflow_deskflow/src/lib/server/ClientProxy.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/Event.h"
#include "base/EventTypes.h"
#include "base/String.h"
#include "server/BaseClientProxy.h"
namespace deskflow {
class IStream;
}
//! Generic proxy for client
class ClientProxy : public BaseClientProxy
{
public:
/*!
\c name is the name of the client.
*/
ClientProxy(const String &name, deskflow::IStream *adoptedStream);
ClientProxy(ClientProxy const &) = delete;
ClientProxy(ClientProxy &&) = delete;
~ClientProxy();
ClientProxy &operator=(ClientProxy const &) = delete;
ClientProxy &operator=(ClientProxy &&) = delete;
//! @name manipulators
//@{
//! Disconnect
/*!
Ask the client to disconnect, using \p msg as the reason.
*/
void close(const char *msg);
//@}
//! @name accessors
//@{
//! Get stream
/*!
Returns the original stream passed to the c'tor.
*/
deskflow::IStream *getStream() const override;
//@}
// IScreen
void *getEventTarget() const override;
bool getClipboard(ClipboardID id, IClipboard *) const override = 0;
void getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const override = 0;
void getCursorPos(SInt32 &x, SInt32 &y) const override = 0;
// IClient overrides
void enter(SInt32 xAbs, SInt32 yAbs, UInt32 seqNum, KeyModifierMask mask, bool forScreensaver) override = 0;
bool leave() override = 0;
void setClipboard(ClipboardID, const IClipboard *) override = 0;
void grabClipboard(ClipboardID) override = 0;
void setClipboardDirty(ClipboardID, bool) override = 0;
void keyDown(KeyID, KeyModifierMask, KeyButton, const String &) override = 0;
void keyRepeat(KeyID, KeyModifierMask, SInt32 count, KeyButton, const String &lang) override = 0;
void keyUp(KeyID, KeyModifierMask, KeyButton) override = 0;
void mouseDown(ButtonID) override = 0;
void mouseUp(ButtonID) override = 0;
void mouseMove(SInt32 xAbs, SInt32 yAbs) override = 0;
void mouseRelativeMove(SInt32 xRel, SInt32 yRel) override = 0;
void mouseWheel(SInt32 xDelta, SInt32 yDelta) override = 0;
void screensaver(bool activate) override = 0;
void resetOptions() override = 0;
void setOptions(const OptionsList &options) override = 0;
void sendDragInfo(UInt32 fileCount, const char *info, size_t size) override = 0;
void fileChunkSending(UInt8 mark, char *data, size_t dataSize) override = 0;
void secureInputNotification(const String &app) const override = 0;
private:
deskflow::IStream *m_stream;
};
| 3,175
|
C++
|
.h
| 82
| 36.121951
| 110
| 0.744481
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,898
|
ClientProxy1_8.h
|
deskflow_deskflow/src/lib/server/ClientProxy1_8.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2015-2021 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "server/ClientProxy1_7.h"
class ClientProxy1_8 : public ClientProxy1_7
{
public:
ClientProxy1_8(const String &name, deskflow::IStream *adoptedStream, Server *server, IEventQueue *events);
~ClientProxy1_8() override = default;
void keyDown(KeyID, KeyModifierMask, KeyButton, const String &) override;
private:
void synchronizeLanguages() const;
};
| 1,072
|
C++
|
.h
| 27
| 37.703704
| 108
| 0.769452
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,899
|
ClientProxy1_1.h
|
deskflow_deskflow/src/lib/server/ClientProxy1_1.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "server/ClientProxy1_0.h"
//! Proxy for client implementing protocol version 1.1
class ClientProxy1_1 : public ClientProxy1_0
{
public:
ClientProxy1_1(const String &name, deskflow::IStream *adoptedStream, IEventQueue *events);
~ClientProxy1_1();
// IClient overrides
virtual void keyDown(KeyID, KeyModifierMask, KeyButton, const String &);
virtual void keyRepeat(KeyID, KeyModifierMask, SInt32 count, KeyButton, const String &);
virtual void keyUp(KeyID, KeyModifierMask, KeyButton);
};
| 1,255
|
C++
|
.h
| 30
| 39.766667
| 92
| 0.77068
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,900
|
BaseClientProxy.h
|
deskflow_deskflow/src/lib/server/BaseClientProxy.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/String.h"
#include "deskflow/IClient.h"
namespace deskflow {
class IStream;
}
//! Generic proxy for client or primary
class BaseClientProxy : public IClient
{
public:
/*!
\c name is the name of the client.
*/
BaseClientProxy(const String &name);
~BaseClientProxy();
//! @name manipulators
//@{
//! Save cursor position
/*!
Save the position of the cursor when jumping from client.
*/
void setJumpCursorPos(SInt32 x, SInt32 y);
//@}
//! @name accessors
//@{
//! Get cursor position
/*!
Get the position of the cursor when last jumping from client.
*/
void getJumpCursorPos(SInt32 &x, SInt32 &y) const;
//! Get cursor position
/*!
Return if this proxy is for client or primary.
*/
virtual bool isPrimary() const
{
return false;
}
//@}
// IScreen
virtual void *getEventTarget() const = 0;
virtual bool getClipboard(ClipboardID id, IClipboard *) const = 0;
virtual void getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const = 0;
virtual void getCursorPos(SInt32 &x, SInt32 &y) const = 0;
// IClient overrides
virtual void enter(SInt32 xAbs, SInt32 yAbs, UInt32 seqNum, KeyModifierMask mask, bool forScreensaver) = 0;
virtual bool leave() = 0;
virtual void setClipboard(ClipboardID, const IClipboard *) = 0;
virtual void grabClipboard(ClipboardID) = 0;
virtual void setClipboardDirty(ClipboardID, bool) = 0;
virtual void keyDown(KeyID, KeyModifierMask, KeyButton, const String &) = 0;
virtual void keyRepeat(KeyID, KeyModifierMask, SInt32 count, KeyButton, const String &lang) = 0;
virtual void keyUp(KeyID, KeyModifierMask, KeyButton) = 0;
virtual void mouseDown(ButtonID) = 0;
virtual void mouseUp(ButtonID) = 0;
virtual void mouseMove(SInt32 xAbs, SInt32 yAbs) = 0;
virtual void mouseRelativeMove(SInt32 xRel, SInt32 yRel) = 0;
virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta) = 0;
virtual void screensaver(bool activate) = 0;
virtual void resetOptions() = 0;
virtual void setOptions(const OptionsList &options) = 0;
virtual void sendDragInfo(UInt32 fileCount, const char *info, size_t size) = 0;
virtual void fileChunkSending(UInt8 mark, char *data, size_t dataSize) = 0;
virtual String getSecureInputApp() const = 0;
virtual void secureInputNotification(const String &app) const = 0;
virtual String getName() const;
virtual deskflow::IStream *getStream() const = 0;
private:
String m_name;
SInt32 m_x, m_y;
};
| 3,220
|
C++
|
.h
| 88
| 33.897727
| 109
| 0.739019
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,901
|
ClientProxy1_3.h
|
deskflow_deskflow/src/lib/server/ClientProxy1_3.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2006 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "server/ClientProxy1_2.h"
//! Proxy for client implementing protocol version 1.3
class ClientProxy1_3 : public ClientProxy1_2
{
public:
ClientProxy1_3(const String &name, deskflow::IStream *adoptedStream, IEventQueue *events);
ClientProxy1_3(ClientProxy1_3 const &) = delete;
ClientProxy1_3(ClientProxy1_3 &&) = delete;
~ClientProxy1_3();
ClientProxy1_3 &operator=(ClientProxy1_3 const &) = delete;
ClientProxy1_3 &operator=(ClientProxy1_3 &&) = delete;
// IClient overrides
virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta);
void handleKeepAlive(const Event &, void *);
protected:
// ClientProxy overrides
virtual bool parseMessage(const UInt8 *code);
virtual void resetHeartbeatRate();
virtual void setHeartbeatRate(double rate, double alarm);
virtual void resetHeartbeatTimer();
virtual void addHeartbeatTimer();
virtual void removeHeartbeatTimer();
virtual void keepAlive();
private:
double m_keepAliveRate;
EventQueueTimer *m_keepAliveTimer;
IEventQueue *m_events;
};
| 1,777
|
C++
|
.h
| 46
| 36.23913
| 92
| 0.769588
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,902
|
ClientProxy1_5.h
|
deskflow_deskflow/src/lib/server/ClientProxy1_5.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2013-2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/Stopwatch.h"
#include "common/stdvector.h"
#include "server/ClientProxy1_4.h"
class Server;
class IEventQueue;
//! Proxy for client implementing protocol version 1.5
class ClientProxy1_5 : public ClientProxy1_4
{
public:
ClientProxy1_5(const String &name, deskflow::IStream *adoptedStream, Server *server, IEventQueue *events);
ClientProxy1_5(ClientProxy1_5 const &) = delete;
ClientProxy1_5(ClientProxy1_5 &&) = delete;
~ClientProxy1_5();
ClientProxy1_5 &operator=(ClientProxy1_5 const &) = delete;
ClientProxy1_5 &operator=(ClientProxy1_5 &&) = delete;
virtual void sendDragInfo(UInt32 fileCount, const char *info, size_t size);
virtual void fileChunkSending(UInt8 mark, char *data, size_t dataSize);
virtual bool parseMessage(const UInt8 *code);
void fileChunkReceived();
void dragInfoReceived();
private:
IEventQueue *m_events;
};
| 1,585
|
C++
|
.h
| 40
| 37.475
| 108
| 0.76658
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,903
|
Server.h
|
deskflow_deskflow/src/lib/server/Server.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/Event.h"
#include "base/EventTypes.h"
#include "base/Stopwatch.h"
#include "common/stdmap.h"
#include "common/stdset.h"
#include "common/stdvector.h"
#include "deskflow/Clipboard.h"
#include "deskflow/DragInformation.h"
#include "deskflow/INode.h"
#include "deskflow/ServerArgs.h"
#include "deskflow/clipboard_types.h"
#include "deskflow/key_types.h"
#include "deskflow/mouse_types.h"
#include "deskflow/option_types.h"
#include "server/Config.h"
#include <memory>
class BaseClientProxy;
class EventQueueTimer;
class PrimaryClient;
class InputFilter;
namespace deskflow {
class Screen;
}
class IEventQueue;
class Thread;
class ClientListener;
//! Deskflow server
/*!
This class implements the top-level server algorithms for deskflow.
*/
class Server : public INode
{
using ServerConfig = deskflow::server::Config;
public:
//! Lock cursor to screen data
class LockCursorToScreenInfo
{
public:
enum State
{
kOff,
kOn,
kToggle
};
static LockCursorToScreenInfo *alloc(State state = kToggle);
public:
State m_state;
};
//! Switch to screen data
class SwitchToScreenInfo
{
public:
static SwitchToScreenInfo *alloc(const String &screen);
public:
// this is a C-string; this type is a variable size structure
char m_screen[1];
};
//! Switch in direction data
class SwitchInDirectionInfo
{
public:
static SwitchInDirectionInfo *alloc(EDirection direction);
public:
EDirection m_direction;
};
//! Screen connected data
class ScreenConnectedInfo
{
public:
ScreenConnectedInfo(String screen) : m_screen(screen)
{
}
public:
String m_screen; // was char[1]
};
//! Keyboard broadcast data
class KeyboardBroadcastInfo
{
public:
enum State
{
kOff,
kOn,
kToggle
};
static KeyboardBroadcastInfo *alloc(State state = kToggle);
static KeyboardBroadcastInfo *alloc(State state, const String &screens);
public:
State m_state;
char m_screens[1];
};
/*!
Start the server with the configuration \p config and the primary
client (local screen) \p primaryClient. The client retains
ownership of \p primaryClient.
*/
Server(
ServerConfig &config, PrimaryClient *primaryClient, deskflow::Screen *screen, IEventQueue *events,
deskflow::ServerArgs const &args
);
Server(Server const &) = delete;
Server(Server &&) = delete;
~Server();
Server &operator=(Server const &) = delete;
Server &operator=(Server &&) = delete;
#ifdef TEST_ENV
Server() : m_mock(true), m_config(NULL)
{
}
void setActive(BaseClientProxy *active)
{
m_active = active;
}
#endif
//! @name manipulators
//@{
//! Set configuration
/*!
Change the server's configuration. Returns true iff the new
configuration was accepted (it must include the server's name).
This will disconnect any clients no longer in the configuration.
*/
bool setConfig(const ServerConfig &);
//! Add a client
/*!
Adds \p client to the server. The client is adopted and will be
destroyed when the client disconnects or is disconnected.
*/
void adoptClient(BaseClientProxy *client);
//! Disconnect clients
/*!
Disconnect clients. This tells them to disconnect but does not wait
for them to actually do so. The server sends the disconnected event
when they're all disconnected (or immediately if none are connected).
The caller can also just destroy this object to force the disconnection.
*/
void disconnect();
//! Create a new thread and use it to send file to client
void sendFileToClient(const char *filename);
//! Received dragging information from client
void dragInfoReceived(UInt32 fileNum, String content);
//! Store ClientListener pointer
void setListener(ClientListener *p)
{
m_clientListener = p;
}
//@}
//! @name accessors
//@{
//! Get the network protocol
/*!
Returns the network protocol used by the server.
*/
std::string protocolString() const;
//! Get number of connected clients
/*!
Returns the number of connected clients, including the server itself.
*/
UInt32 getNumClients() const;
//! Get the list of connected clients
/*!
Set the \c list to the names of the currently connected clients.
*/
void getClients(std::vector<String> &list) const;
//! Return true if recieved file size is valid
bool isReceivedFileSizeValid();
//! Return expected file data size
size_t &getExpectedFileSize()
{
return m_expectedFileSize;
}
//! Return received file data
String &getReceivedFileData()
{
return m_receivedFileData;
}
//! Return fake drag file list
DragFileList getFakeDragFileList()
{
return m_fakeDragFileList;
}
//! Returns true if it's client mode and server initiates connection
bool isClientMode() const;
//@}
private:
// get canonical name of client
String getName(const BaseClientProxy *) const;
// get the sides of the primary screen that have neighbors
UInt32 getActivePrimarySides() const;
// returns true iff mouse should be locked to the current screen
// according to this object only, ignoring what the primary client
// says.
bool isLockedToScreenServer() const;
// returns true iff mouse should be locked to the current screen
// according to this object or the primary client.
bool isLockedToScreen() const;
// returns the jump zone of the client
SInt32 getJumpZoneSize(BaseClientProxy *) const;
// change the active screen
void switchScreen(BaseClientProxy *, SInt32 x, SInt32 y, bool forScreenSaver);
// jump to screen
void jumpToScreen(BaseClientProxy *);
// convert pixel position to fraction, using x or y depending on the
// direction.
float mapToFraction(BaseClientProxy *, EDirection, SInt32 x, SInt32 y) const;
// convert fraction to pixel position, writing only x or y depending
// on the direction.
void mapToPixel(BaseClientProxy *, EDirection, float f, SInt32 &x, SInt32 &y) const;
// returns true if the client has a neighbor anywhere along the edge
// indicated by the direction.
bool hasAnyNeighbor(BaseClientProxy *, EDirection) const;
// lookup neighboring screen, mapping the coordinate independent of
// the direction to the neighbor's coordinate space.
BaseClientProxy *getNeighbor(BaseClientProxy *, EDirection, SInt32 &x, SInt32 &y) const;
// lookup neighboring screen. given a position relative to the
// source screen, find the screen we should move onto and where.
// if the position is sufficiently far from the source then we
// cross multiple screens. if there is no suitable screen then
// return NULL and x,y are not modified.
BaseClientProxy *mapToNeighbor(BaseClientProxy *, EDirection, SInt32 &x, SInt32 &y) const;
// adjusts x and y or neither to avoid ending up in a jump zone
// after entering the client in the given direction.
void avoidJumpZone(BaseClientProxy *, EDirection, SInt32 &x, SInt32 &y) const;
// test if a switch is permitted. this includes testing user
// options like switch delay and tracking any state required to
// implement them. returns true iff a switch is permitted.
bool isSwitchOkay(BaseClientProxy *dst, EDirection, SInt32 x, SInt32 y, SInt32 xActive, SInt32 yActive);
// update switch state due to a mouse move at \p x, \p y that
// doesn't switch screens.
void noSwitch(SInt32 x, SInt32 y);
// stop switch timers
void stopSwitch();
// start two tap switch timer
void startSwitchTwoTap();
// arm the two tap switch timer if \p x, \p y is outside the tap zone
void armSwitchTwoTap(SInt32 x, SInt32 y);
// stop the two tap switch timer
void stopSwitchTwoTap();
// returns true iff the two tap switch timer is started
bool isSwitchTwoTapStarted() const;
// returns true iff should switch because of two tap
bool shouldSwitchTwoTap() const;
// start delay switch timer
void startSwitchWait(SInt32 x, SInt32 y);
// stop delay switch timer
void stopSwitchWait();
// returns true iff the delay switch timer is started
bool isSwitchWaitStarted() const;
// returns the corner (EScreenSwitchCornerMasks) where x,y is on the
// given client. corners have the given size.
UInt32 getCorner(BaseClientProxy *, SInt32 x, SInt32 y, SInt32 size) const;
// stop relative mouse moves
void stopRelativeMoves();
// send screen options to \c client
void sendOptions(BaseClientProxy *client) const;
// process options from configuration
void processOptions();
// event handlers
void handleShapeChanged(const Event &, void *);
void handleClipboardGrabbed(const Event &, void *);
void handleClipboardChanged(const Event &, void *);
void handleKeyDownEvent(const Event &, void *);
void handleKeyUpEvent(const Event &, void *);
void handleKeyRepeatEvent(const Event &, void *);
void handleButtonDownEvent(const Event &, void *);
void handleButtonUpEvent(const Event &, void *);
void handleMotionPrimaryEvent(const Event &, void *);
void handleMotionSecondaryEvent(const Event &, void *);
void handleWheelEvent(const Event &, void *);
void handleScreensaverActivatedEvent(const Event &, void *);
void handleScreensaverDeactivatedEvent(const Event &, void *);
void handleSwitchWaitTimeout(const Event &, void *);
void handleClientDisconnected(const Event &, void *);
void handleClientCloseTimeout(const Event &, void *);
void handleSwitchToScreenEvent(const Event &, void *);
void handleSwitchInDirectionEvent(const Event &, void *);
void handleKeyboardBroadcastEvent(const Event &, void *);
void handleLockCursorToScreenEvent(const Event &, void *);
void handleFakeInputBeginEvent(const Event &, void *);
void handleFakeInputEndEvent(const Event &, void *);
void handleFileChunkSendingEvent(const Event &, void *);
void handleFileRecieveCompletedEvent(const Event &, void *);
// event processing
void onClipboardChanged(BaseClientProxy *sender, ClipboardID id, UInt32 seqNum);
void onScreensaver(bool activated);
void onKeyDown(KeyID, KeyModifierMask, KeyButton, const String &, const char *screens);
void onKeyUp(KeyID, KeyModifierMask, KeyButton, const char *screens);
void onKeyRepeat(KeyID, KeyModifierMask, SInt32, KeyButton, const String &);
void onMouseDown(ButtonID);
void onMouseUp(ButtonID);
bool onMouseMovePrimary(SInt32 x, SInt32 y);
void onMouseMoveSecondary(SInt32 dx, SInt32 dy);
void onMouseWheel(SInt32 xDelta, SInt32 yDelta);
void onFileChunkSending(const void *data);
void onFileRecieveCompleted();
// add client to list and attach event handlers for client
bool addClient(BaseClientProxy *);
// remove client from list and detach event handlers for client
bool removeClient(BaseClientProxy *);
// close a client
void closeClient(BaseClientProxy *, const char *msg);
// close clients not in \p config
void closeClients(const ServerConfig &config);
// close all clients whether they've completed the handshake or not,
// except the primary client
void closeAllClients();
// remove clients from internal state
void removeActiveClient(BaseClientProxy *);
void removeOldClient(BaseClientProxy *);
// force the cursor off of \p client
void forceLeaveClient(BaseClientProxy *client);
// thread funciton for sending file
void sendFileThread(void *);
// thread function for writing file to drop directory
void writeToDropDirThread(void *);
// thread function for sending drag information
void sendDragInfoThread(void *);
// send drag info to new client screen
void sendDragInfo(BaseClientProxy *newScreen);
public:
bool m_mock;
private:
class ClipboardInfo
{
public:
ClipboardInfo();
public:
Clipboard m_clipboard;
String m_clipboardData;
String m_clipboardOwner;
UInt32 m_clipboardSeqNum;
};
// used in hello message sent to the client
ENetworkProtocol m_protocol;
// the primary screen client
PrimaryClient *m_primaryClient;
// all clients (including the primary client) indexed by name
typedef std::map<String, BaseClientProxy *> ClientList;
typedef std::set<BaseClientProxy *> ClientSet;
ClientList m_clients;
ClientSet m_clientSet;
// all old connections that we're waiting to hangup
typedef std::map<BaseClientProxy *, EventQueueTimer *> OldClients;
OldClients m_oldClients;
// the client with focus
BaseClientProxy *m_active;
// the sequence number of enter messages
UInt32 m_seqNum;
// current mouse position (in absolute screen coordinates) on
// whichever screen is active
SInt32 m_x, m_y;
// last mouse deltas. this is needed to smooth out double tap
// on win32 which reports bogus mouse motion at the edge of
// the screen when using low level hooks, synthesizing motion
// in the opposite direction the mouse actually moved.
SInt32 m_xDelta, m_yDelta;
SInt32 m_xDelta2, m_yDelta2;
// current configuration
ServerConfig *m_config;
// input filter (from m_config);
InputFilter *m_inputFilter;
// clipboard cache
ClipboardInfo m_clipboards[kClipboardEnd];
// state saved when screen saver activates
BaseClientProxy *m_activeSaver;
SInt32 m_xSaver, m_ySaver;
// common state for screen switch tests. all tests are always
// trying to reach the same screen in the same direction.
EDirection m_switchDir;
BaseClientProxy *m_switchScreen;
// state for delayed screen switching
double m_switchWaitDelay;
EventQueueTimer *m_switchWaitTimer;
SInt32 m_switchWaitX, m_switchWaitY;
// state for double-tap screen switching
double m_switchTwoTapDelay;
Stopwatch m_switchTwoTapTimer;
bool m_switchTwoTapEngaged;
bool m_switchTwoTapArmed;
SInt32 m_switchTwoTapZone;
// modifiers needed before switching
bool m_switchNeedsShift;
bool m_switchNeedsControl;
bool m_switchNeedsAlt;
// relative mouse move option
bool m_relativeMoves;
// flag whether or not we have broadcasting enabled and the screens to
// which we should send broadcasted keys.
bool m_keyboardBroadcasting;
String m_keyboardBroadcastingScreens;
// screen locking (former scroll lock)
bool m_lockedToScreen;
// server screen
deskflow::Screen *m_screen;
IEventQueue *m_events;
// file transfer
using AutoThread = std::unique_ptr<Thread>;
size_t m_expectedFileSize;
String m_receivedFileData;
DragFileList m_dragFileList;
DragFileList m_fakeDragFileList;
AutoThread m_sendFileThread;
AutoThread m_writeToDropDirThread;
String m_dragFileExt;
bool m_ignoreFileTransfer;
bool m_disableLockToScreen;
bool m_enableClipboard;
size_t m_maximumClipboardSize;
AutoThread m_sendDragInfoThread;
bool m_waitDragInfoThread;
ClientListener *m_clientListener;
deskflow::ServerArgs m_args;
};
| 15,536
|
C++
|
.h
| 431
| 32.814385
| 106
| 0.75475
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,904
|
ClientProxy1_6.h
|
deskflow_deskflow/src/lib/server/ClientProxy1_6.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "server/ClientProxy1_5.h"
class Server;
class IEventQueue;
//! Proxy for client implementing protocol version 1.6
class ClientProxy1_6 : public ClientProxy1_5
{
public:
ClientProxy1_6(const String &name, deskflow::IStream *adoptedStream, Server *server, IEventQueue *events);
~ClientProxy1_6();
virtual void setClipboard(ClipboardID id, const IClipboard *clipboard);
virtual bool recvClipboard();
private:
void handleClipboardSendingEvent(const Event &, void *);
private:
IEventQueue *m_events;
};
| 1,230
|
C++
|
.h
| 33
| 35.242424
| 108
| 0.77479
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,905
|
ClientProxy1_2.h
|
deskflow_deskflow/src/lib/server/ClientProxy1_2.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "server/ClientProxy1_1.h"
class IEventQueue;
//! Proxy for client implementing protocol version 1.2
class ClientProxy1_2 : public ClientProxy1_1
{
public:
ClientProxy1_2(const String &name, deskflow::IStream *adoptedStream, IEventQueue *events);
~ClientProxy1_2();
// IClient overrides
virtual void mouseRelativeMove(SInt32 xRel, SInt32 yRel);
};
| 1,112
|
C++
|
.h
| 29
| 36.344828
| 92
| 0.770872
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,906
|
IpcLogOutputter.h
|
deskflow_deskflow/src/lib/ipc/IpcLogOutputter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "arch/Arch.h"
#include "arch/IArchMultithread.h"
#include "base/ILogOutputter.h"
#include "common/ipc.h"
#include <deque>
class IpcServer;
class Event;
class IpcClientProxy;
//! Write log to GUI over IPC
/*!
This outputter writes output to the GUI via IPC.
*/
class IpcLogOutputter : public ILogOutputter
{
public:
/*!
If \p useThread is \c true, the buffer will be sent using a thread.
If \p useThread is \c false, then the buffer needs to be sent manually
using the \c sendBuffer() function.
*/
IpcLogOutputter(IpcServer &ipcServer, IpcClientType clientType, bool useThread);
IpcLogOutputter(IpcLogOutputter const &) = delete;
virtual ~IpcLogOutputter();
// ILogOutputter overrides
virtual void open(const char *title);
virtual void close();
virtual void show(bool showIfEmpty);
virtual bool write(ELevel level, const char *message);
//! @name manipulators
//@{
//! Notify that the buffer should be sent.
void notifyBuffer();
//! Set the buffer size
/*!
Set the maximum size of the buffer to protect memory
from runaway logging.
*/
void bufferMaxSize(UInt16 bufferMaxSize);
//! Set the rate limit
/*!
Set the maximum number of \p writeRate for every \p timeRate in seconds.
*/
void bufferRateLimit(UInt16 writeLimit, double timeLimit);
//! Send the buffer
/*!
Sends a chunk of the buffer to the IPC server, normally called
when threaded mode is on.
*/
void sendBuffer();
//@}
//! @name accessors
//@{
//! Get the buffer size
/*!
Returns the maximum size of the buffer.
*/
UInt16 bufferMaxSize() const;
//@}
private:
void init();
void bufferThread(void *);
String getChunk(size_t count);
void appendBuffer(const String &text);
bool isRunning();
private:
typedef std::deque<String> Buffer;
IpcServer &m_ipcServer;
Buffer m_buffer;
ArchMutex m_bufferMutex;
bool m_sending;
Thread *m_bufferThread;
bool m_running;
ArchCond m_notifyCond;
ArchMutex m_notifyMutex;
bool m_bufferWaiting;
IArchMultithread::ThreadID m_bufferThreadId;
UInt16 m_bufferMaxSize;
UInt16 m_bufferRateWriteLimit;
double m_bufferRateTimeLimit;
UInt16 m_bufferWriteCount;
double m_bufferRateStart;
IpcClientType m_clientType;
ArchMutex m_runningMutex;
};
| 3,019
|
C++
|
.h
| 102
| 26.970588
| 82
| 0.748189
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,907
|
IpcClientProxy.h
|
deskflow_deskflow/src/lib/ipc/IpcClientProxy.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "arch/Arch.h"
#include "arch/IArchMultithread.h"
#include "base/Event.h"
#include "base/EventTypes.h"
#include "common/ipc.h"
namespace deskflow {
class IStream;
}
class IpcMessage;
class IpcCommandMessage;
class IpcSettingMessage;
class IpcHelloMessage;
class IEventQueue;
class IpcClientProxy
{
friend class IpcServer;
public:
IpcClientProxy(deskflow::IStream &stream, IEventQueue *events);
IpcClientProxy(IpcClientProxy const &) = delete;
IpcClientProxy(IpcClientProxy &&) = delete;
virtual ~IpcClientProxy();
IpcClientProxy &operator=(IpcClientProxy const &) = delete;
IpcClientProxy &operator=(IpcClientProxy &&) = delete;
private:
void send(const IpcMessage &message);
void handleData(const Event &, void *);
void handleDisconnect(const Event &, void *);
void handleWriteError(const Event &, void *);
IpcHelloMessage *parseHello();
IpcCommandMessage *parseCommand();
IpcSettingMessage *parseSetting() const;
void disconnect();
private:
deskflow::IStream &m_stream;
IEventQueue *m_events;
IpcClientType m_clientType = IpcClientType::Unknown;
bool m_disconnecting = false;
ArchMutex m_readMutex = ARCH->newMutex();
ArchMutex m_writeMutex = ARCH->newMutex();
};
| 1,923
|
C++
|
.h
| 57
| 31.596491
| 72
| 0.772336
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,908
|
IpcServer.h
|
deskflow_deskflow/src/lib/ipc/IpcServer.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "arch/Arch.h"
#include "base/EventTypes.h"
#include "common/ipc.h"
#include "net/NetworkAddress.h"
#include "net/TCPListenSocket.h"
#include <list>
class Event;
class IpcClientProxy;
class IpcMessage;
class IEventQueue;
class SocketMultiplexer;
//! IPC server for communication between daemon and GUI.
/*!
The IPC server listens on localhost. The IPC client runs on both the
client/server process or the GUI. The IPC server runs on the daemon process.
This allows the GUI to send config changes to the daemon and client/server,
and allows the daemon and client/server to send log data to the GUI.
*/
class IpcServer
{
public:
IpcServer(IEventQueue *events, SocketMultiplexer *socketMultiplexer);
IpcServer(IEventQueue *events, SocketMultiplexer *socketMultiplexer, int port);
IpcServer(IpcServer const &) = delete;
IpcServer(IpcServer &&) = delete;
virtual ~IpcServer();
IpcServer &operator=(IpcServer const &) = delete;
IpcServer &operator=(IpcServer &&) = delete;
//! @name manipulators
//@{
//! Opens a TCP socket only allowing local connections.
virtual void listen();
//! Send a message to all clients matching the filter type.
virtual void send(const IpcMessage &message, IpcClientType filterType);
//@}
//! @name accessors
//@{
//! Returns true when there are clients of the specified type connected.
virtual bool hasClients(IpcClientType clientType) const;
//@}
private:
void init();
void handleClientConnecting(const Event &, void *);
void handleClientDisconnected(const Event &, void *);
void handleMessageReceived(const Event &, void *);
void deleteClient(IpcClientProxy *proxy);
private:
typedef std::list<IpcClientProxy *> ClientList;
bool m_mock;
IEventQueue *m_events;
SocketMultiplexer *m_socketMultiplexer;
TCPListenSocket *m_socket;
NetworkAddress m_address;
ClientList m_clients;
ArchMutex m_clientsMutex;
#ifdef TEST_ENV
public:
IpcServer() : m_mock(true), m_events(nullptr), m_socketMultiplexer(nullptr), m_socket(nullptr)
{
}
#endif
};
| 2,791
|
C++
|
.h
| 80
| 32.6125
| 96
| 0.765121
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,909
|
IpcSettingMessage.h
|
deskflow_deskflow/src/lib/ipc/IpcSettingMessage.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "IpcMessage.h"
#include <string>
class IpcSettingMessage : public IpcMessage
{
public:
//!
//! \brief IpcSettingMessage constructor
//! \param name - setting name
//! \param value - setting value
//!
IpcSettingMessage(const std::string &name, const std::string &value);
//!
//! \brief getName is a getter for the setting name
//! \return setting name
//!
const std::string &getName() const;
//!
//! \brief getValue is a getter for the setting value
//! \return setting value
//!
const std::string &getValue() const;
private:
std::string m_name;
std::string m_value;
};
| 1,358
|
C++
|
.h
| 43
| 29.232558
| 72
| 0.728037
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,910
|
IpcMessage.h
|
deskflow_deskflow/src/lib/ipc/IpcMessage.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/Event.h"
#include "base/String.h"
#include "common/ipc.h"
class IpcMessage : public EventData
{
public:
~IpcMessage() override = default;
//! Gets the message type ID.
IpcMessageType type() const
{
return m_type;
}
protected:
explicit IpcMessage(IpcMessageType type);
private:
IpcMessageType m_type;
};
class IpcHelloMessage : public IpcMessage
{
public:
explicit IpcHelloMessage(IpcClientType clientType);
~IpcHelloMessage() override = default;
//! Gets the message type ID.
IpcClientType clientType() const
{
return m_clientType;
}
private:
IpcClientType m_clientType;
};
class IpcHelloBackMessage : public IpcMessage
{
public:
explicit IpcHelloBackMessage();
~IpcHelloBackMessage() override = default;
};
class IpcShutdownMessage : public IpcMessage
{
public:
explicit IpcShutdownMessage();
~IpcShutdownMessage() override = default;
};
class IpcLogLineMessage : public IpcMessage
{
public:
explicit IpcLogLineMessage(const String &logLine);
~IpcLogLineMessage() override = default;
//! Gets the log line.
String logLine() const
{
return m_logLine;
}
private:
String m_logLine;
};
class IpcCommandMessage : public IpcMessage
{
public:
explicit IpcCommandMessage(const String &command, bool elevate);
~IpcCommandMessage() override = default;
//! Gets the command.
String command() const
{
return m_command;
}
//! Gets whether or not the process should be elevated on MS Windows.
bool elevate() const
{
return m_elevate;
}
private:
String m_command;
bool m_elevate;
};
| 2,295
|
C++
|
.h
| 91
| 22.824176
| 72
| 0.759378
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,911
|
IpcServerProxy.h
|
deskflow_deskflow/src/lib/ipc/IpcServerProxy.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/Event.h"
#include "base/EventTypes.h"
namespace deskflow {
class IStream;
}
class IpcMessage;
class IpcLogLineMessage;
class IEventQueue;
class IpcServerProxy
{
friend class IpcClient;
public:
IpcServerProxy(deskflow::IStream &stream, IEventQueue *events);
IpcServerProxy(IpcServerProxy const &) = delete;
virtual ~IpcServerProxy();
private:
void send(const IpcMessage &message);
void handleData(const Event &, void *);
IpcLogLineMessage *parseLogLine();
void disconnect();
private:
deskflow::IStream &m_stream;
IEventQueue *m_events;
};
| 1,319
|
C++
|
.h
| 42
| 29.357143
| 72
| 0.772262
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,912
|
IpcClient.h
|
deskflow_deskflow/src/lib/ipc/IpcClient.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/EventTypes.h"
#include "net/NetworkAddress.h"
#include "net/TCPSocket.h"
class IpcServerProxy;
class IpcMessage;
class IEventQueue;
class SocketMultiplexer;
//! IPC client for communication between daemon and GUI.
/*!
* See \ref IpcServer description.
*/
class IpcClient
{
public:
IpcClient(IEventQueue *events, SocketMultiplexer *socketMultiplexer);
IpcClient(IEventQueue *events, SocketMultiplexer *socketMultiplexer, int port);
virtual ~IpcClient();
//! @name manipulators
//@{
//! Connects to the IPC server at localhost.
void connect();
//! Disconnects from the IPC server.
void disconnect();
//! Sends a message to the server.
void send(const IpcMessage &message);
//@}
private:
void init();
void handleConnected(const Event &, void *);
void handleMessageReceived(const Event &, void *);
private:
NetworkAddress m_serverAddress;
TCPSocket m_socket;
IpcServerProxy *m_server;
IEventQueue *m_events;
};
| 1,711
|
C++
|
.h
| 54
| 29.444444
| 81
| 0.760024
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,913
|
wayland.h
|
deskflow_deskflow/src/lib/platform/wayland.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2024 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
namespace deskflow::platform {
#if WINAPI_LIBEI
const auto kHasEi = true;
#else
const auto kHasEi = false;
#endif
#if WINAPI_LIBPORTAL
const auto kHasPortal = true;
#else
const auto kHasPortal = false;
#endif
#if HAVE_LIBPORTAL_INPUTCAPTURE
const auto kHasPortalInputCapture = true;
#else
const auto kHasPortalInputCapture = false;
#endif
inline bool isWayland()
{
const auto session = getenv("XDG_SESSION_TYPE");
return session != nullptr && std::string(session) == "wayland";
}
} // namespace deskflow::platform
| 1,243
|
C++
|
.h
| 40
| 29.4
| 72
| 0.770711
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,914
|
MSWindowsEventQueueBuffer.h
|
deskflow_deskflow/src/lib/platform/MSWindowsEventQueueBuffer.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/IEventQueueBuffer.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
class IEventQueue;
//! Event queue buffer for Win32
class MSWindowsEventQueueBuffer : public IEventQueueBuffer
{
public:
MSWindowsEventQueueBuffer(IEventQueue *events);
virtual ~MSWindowsEventQueueBuffer();
// IEventQueueBuffer overrides
virtual void init()
{
}
virtual void waitForEvent(double timeout);
virtual Type getEvent(Event &event, UInt32 &dataID);
virtual bool addEvent(UInt32 dataID);
virtual bool isEmpty() const;
virtual EventQueueTimer *newTimer(double duration, bool oneShot) const;
virtual void deleteTimer(EventQueueTimer *) const;
private:
DWORD m_thread;
UINT m_userEvent;
MSG m_event;
UINT m_daemonQuit;
IEventQueue *m_events;
};
| 1,519
|
C++
|
.h
| 45
| 31.488889
| 73
| 0.777096
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,915
|
OSXMediaKeySupport.h
|
deskflow_deskflow/src/lib/platform/OSXMediaKeySupport.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2016 Symless.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#import <Carbon/Carbon.h>
#import <CoreFoundation/CoreFoundation.h>
#include "deskflow/key_types.h"
#if defined(__cplusplus)
extern "C"
{
#endif
bool fakeNativeMediaKey(KeyID id);
bool isMediaKeyEvent(CGEventRef event);
bool getMediaKeyEventInfo(CGEventRef event, KeyID *keyId, bool *down, bool *isRepeat);
#if defined(__cplusplus)
}
#endif
| 1,046
|
C++
|
.h
| 30
| 33.033333
| 88
| 0.769763
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,916
|
MSWindowsWatchdog.h
|
deskflow_deskflow/src/lib/platform/MSWindowsWatchdog.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2009 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "arch/IArchMultithread.h"
#include "deskflow/XDeskflow.h"
#include "platform/MSWindowsSession.h"
#include <map>
#include <string>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
class Thread;
class IpcLogOutputter;
class IpcServer;
class FileLogOutputter;
class MSWindowsWatchdog
{
public:
MSWindowsWatchdog(bool autoDetectCommand, IpcServer &ipcServer, IpcLogOutputter &ipcLogOutputter, bool foreground);
virtual ~MSWindowsWatchdog();
void startAsync();
std::string getCommand() const;
void setCommand(const std::string &command, bool elevate);
void stop();
bool isProcessActive();
void setFileLogOutputter(FileLogOutputter *outputter);
private:
void mainLoop(void *);
void outputLoop(void *);
void shutdownProcess(HANDLE handle, DWORD pid, int timeout);
void shutdownExistingProcesses();
HANDLE duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES security);
HANDLE getUserToken(LPSECURITY_ATTRIBUTES security);
void startProcess();
BOOL startProcessAsUser(String &command, HANDLE userToken, LPSECURITY_ATTRIBUTES sa);
BOOL startProcessInForeground(String &command);
void sendSas();
void getActiveDesktop(LPSECURITY_ATTRIBUTES security);
void testOutput(String buffer);
void setStartupInfo(STARTUPINFO &si);
void checkChildren();
/**
* @brief This closes the handles held to a child thread
* @param pid the ID of the process to kill, will do nothing if PID is not a
* valid child
* @param removeFromMap should the function remove the item from the children
* map
*/
void closeProcessHandles(unsigned long pid, bool removeFromMap = true);
/**
* @brief This kills off all children's handles created by this process
*/
void clearAllChildren();
private:
Thread *m_thread;
bool m_autoDetectCommand;
std::string m_command;
bool m_monitoring;
bool m_commandChanged;
HANDLE m_stdOutWrite;
HANDLE m_stdOutRead;
Thread *m_outputThread;
IpcServer &m_ipcServer;
IpcLogOutputter &m_ipcLogOutputter;
bool m_elevateProcess;
MSWindowsSession m_session;
PROCESS_INFORMATION m_processInfo;
int m_processFailures;
bool m_processRunning;
FileLogOutputter *m_fileLogOutputter;
bool m_autoElevated;
ArchMutex m_mutex;
ArchCond m_condVar;
bool m_ready;
bool m_foreground;
std::string m_activeDesktop;
/// @brief Save the info of all process made
/// We will use this to track all processes we make and
/// kill off handels and children that we no longer need
std::map<unsigned long, PROCESS_INFORMATION> m_children;
};
//! Relauncher error
/*!
An error occured in the process watchdog.
*/
class XMSWindowsWatchdogError : public XDeskflow
{
public:
XMSWindowsWatchdogError(const String &msg) : XDeskflow(msg)
{
}
// XBase overrides
virtual String getWhat() const throw()
{
return what();
}
};
| 3,605
|
C++
|
.h
| 111
| 29.90991
| 117
| 0.768811
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,917
|
OSXClipboardUTF8Converter.h
|
deskflow_deskflow/src/lib/platform/OSXClipboardUTF8Converter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/OSXClipboardAnyTextConverter.h"
class OSXClipboardUTF8Converter : public OSXClipboardAnyTextConverter
{
public:
virtual CFStringRef getOSXFormat() const;
private:
virtual String doFromIClipboard(const String &) const;
virtual String doToIClipboard(const String &) const;
};
| 1,045
|
C++
|
.h
| 27
| 36.777778
| 72
| 0.784236
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,918
|
OSXScreenSaverUtil.h
|
deskflow_deskflow/src/lib/platform/OSXScreenSaverUtil.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common/common.h"
#if defined(__cplusplus)
extern "C"
{
#endif
void *screenSaverUtilCreatePool();
void screenSaverUtilReleasePool(void *);
void *screenSaverUtilCreateController();
void screenSaverUtilReleaseController(void *);
void screenSaverUtilEnable(void *);
void screenSaverUtilDisable(void *);
void screenSaverUtilActivate(void *);
void screenSaverUtilDeactivate(void *, int isEnabled);
int screenSaverUtilIsActive(void *);
#if defined(__cplusplus)
}
#endif
| 1,240
|
C++
|
.h
| 35
| 33.285714
| 72
| 0.773978
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,919
|
EiKeyState.h
|
deskflow_deskflow/src/lib/platform/EiKeyState.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2022 Red Hat, Inc.
* Copyright (C) 2024 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "deskflow/KeyState.h"
#include "platform/EiScreen.h"
struct xkb_context;
struct xkb_keymap;
struct xkb_state;
namespace deskflow {
/// A key state for Ei
class EiKeyState : public KeyState
{
public:
EiKeyState(EiScreen *screen, IEventQueue *events);
~EiKeyState();
void init(int fd, std::size_t len);
void init_default_keymap();
// IKeyState overrides
bool fakeCtrlAltDel() override;
KeyModifierMask pollActiveModifiers() const override;
std::int32_t pollActiveGroup() const override;
void pollPressedKeys(KeyButtonSet &pressedKeys) const override;
KeyID map_key_from_keyval(std::uint32_t keyval) const;
void update_xkb_state(std::uint32_t keyval, bool is_pressed);
protected:
// KeyState overrides
void getKeyMap(KeyMap &keyMap) override;
void fakeKey(const Keystroke &keystroke) override;
private:
std::uint32_t convert_mod_mask(std::uint32_t xkb_mask) const;
void assign_generated_modifiers(std::uint32_t keycode, KeyMap::KeyItem &item);
EiScreen *screen_ = nullptr;
xkb_context *xkb_ = nullptr;
xkb_keymap *xkb_keymap_ = nullptr;
xkb_state *xkb_state_ = nullptr;
};
} // namespace deskflow
| 1,890
|
C++
|
.h
| 52
| 34.038462
| 80
| 0.761774
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,920
|
XWindowsClipboardBMPConverter.h
|
deskflow_deskflow/src/lib/platform/XWindowsClipboardBMPConverter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/XWindowsClipboard.h"
//! Convert to/from some text encoding
class XWindowsClipboardBMPConverter : public IXWindowsClipboardConverter
{
public:
XWindowsClipboardBMPConverter(Display *display);
virtual ~XWindowsClipboardBMPConverter();
// IXWindowsClipboardConverter overrides
virtual IClipboard::EFormat getFormat() const;
virtual Atom getAtom() const;
virtual int getDataSize() const;
virtual String fromIClipboard(const String &) const;
virtual String toIClipboard(const String &) const;
private:
Atom m_atom;
};
| 1,299
|
C++
|
.h
| 34
| 36.058824
| 72
| 0.784921
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| true
| true
| false
| false
| false
| false
| false
| false
|
13,921
|
XWindowsClipboardTextConverter.h
|
deskflow_deskflow/src/lib/platform/XWindowsClipboardTextConverter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/XWindowsClipboard.h"
//! Convert to/from locale text encoding
class XWindowsClipboardTextConverter : public IXWindowsClipboardConverter
{
public:
/*!
\c name is converted to an atom and that is reported by getAtom().
*/
XWindowsClipboardTextConverter(Display *display, const char *name);
virtual ~XWindowsClipboardTextConverter();
// IXWindowsClipboardConverter overrides
virtual IClipboard::EFormat getFormat() const;
virtual Atom getAtom() const;
virtual int getDataSize() const;
virtual String fromIClipboard(const String &) const;
virtual String toIClipboard(const String &) const;
private:
Atom m_atom;
};
| 1,402
|
C++
|
.h
| 37
| 35.675676
| 73
| 0.777206
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,922
|
OSXDragSimulator.h
|
deskflow_deskflow/src/lib/platform/OSXDragSimulator.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2013-2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common/common.h"
#import <CoreFoundation/CoreFoundation.h>
#if defined(__cplusplus)
extern "C"
{
#endif
void runCocoaApp();
void stopCocoaLoop();
void fakeDragging(const char *str, int cursorX, int cursorY);
CFStringRef getCocoaDropTarget();
#if defined(__cplusplus)
}
#endif
| 1,003
|
C++
|
.h
| 30
| 31.5
| 72
| 0.764463
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| true
| true
| false
| false
| false
| false
| false
| false
|
13,923
|
OSXUchrKeyResource.h
|
deskflow_deskflow/src/lib/platform/OSXUchrKeyResource.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "deskflow/KeyState.h"
#include "platform/IOSXKeyResource.h"
#include <Carbon/Carbon.h>
typedef TISInputSourceRef KeyLayout;
class OSXUchrKeyResource : public IOSXKeyResource
{
public:
OSXUchrKeyResource(const void *, UInt32 keyboardType);
// KeyResource overrides
virtual bool isValid() const;
virtual UInt32 getNumModifierCombinations() const;
virtual UInt32 getNumTables() const;
virtual UInt32 getNumButtons() const;
virtual UInt32 getTableForModifier(UInt32 mask) const;
virtual KeyID getKey(UInt32 table, UInt32 button) const;
private:
typedef std::vector<KeyID> KeySequence;
bool getDeadKey(KeySequence &keys, UInt16 index) const;
bool getKeyRecord(KeySequence &keys, UInt16 index, UInt16 &state) const;
bool addSequence(KeySequence &keys, UCKeyCharSeq c) const;
private:
const UCKeyboardLayout *m_resource;
const UCKeyModifiersToTableNum *m_m;
const UCKeyToCharTableIndex *m_cti;
const UCKeySequenceDataIndex *m_sdi;
const UCKeyStateRecordsIndex *m_sri;
const UCKeyStateTerminators *m_st;
UInt16 m_spaceOutput;
};
| 1,776
|
C++
|
.h
| 46
| 36.26087
| 74
| 0.790238
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,924
|
MSWindowsScreenSaver.h
|
deskflow_deskflow/src/lib/platform/MSWindowsScreenSaver.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/String.h"
#include "deskflow/IScreenSaver.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
class Thread;
//! Microsoft windows screen saver implementation
class MSWindowsScreenSaver : public IScreenSaver
{
public:
MSWindowsScreenSaver();
virtual ~MSWindowsScreenSaver();
//! @name manipulators
//@{
//! Check if screen saver started
/*!
Check if the screen saver really started. Returns false if it
hasn't, true otherwise. When the screen saver stops, \c msg will
be posted to the current thread's message queue with the given
parameters.
*/
bool checkStarted(UINT msg, WPARAM, LPARAM);
//@}
// IScreenSaver overrides
virtual void enable();
virtual void disable();
virtual void activate();
virtual void deactivate();
virtual bool isActive() const;
private:
class FindScreenSaverInfo
{
public:
HDESK m_desktop;
HWND m_window;
};
static BOOL CALLBACK killScreenSaverFunc(HWND hwnd, LPARAM lParam);
void watchDesktop();
void watchProcess(HANDLE process);
void unwatchProcess();
void watchDesktopThread(void *);
void watchProcessThread(void *);
void setSecure(bool secure, bool saveSecureAsInt);
bool isSecure(bool *wasSecureAnInt) const;
private:
BOOL m_wasEnabled;
bool m_wasSecure;
bool m_wasSecureAnInt;
HANDLE m_process;
Thread *m_watch;
DWORD m_threadID;
UINT m_msg;
WPARAM m_wParam;
LPARAM m_lParam;
// checkActive state. true if the screen saver is being watched
// for deactivation (and is therefore active).
bool m_active;
};
| 2,306
|
C++
|
.h
| 75
| 28.066667
| 72
| 0.755756
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,925
|
OSXScreenSaver.h
|
deskflow_deskflow/src/lib/platform/OSXScreenSaver.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "deskflow/IScreenSaver.h"
#include <Carbon/Carbon.h>
class IEventQueue;
//! OSX screen saver implementation
class OSXScreenSaver : public IScreenSaver
{
public:
OSXScreenSaver(IEventQueue *events, void *eventTarget);
virtual ~OSXScreenSaver();
// IScreenSaver overrides
virtual void enable();
virtual void disable();
virtual void activate();
virtual void deactivate();
virtual bool isActive() const;
private:
void processLaunched(ProcessSerialNumber psn);
void processTerminated(ProcessSerialNumber psn);
static pascal OSStatus launchTerminationCallback(EventHandlerCallRef nextHandler, EventRef theEvent, void *userData);
private:
// the target for the events we generate
void *m_eventTarget;
bool m_enabled;
void *m_screenSaverController;
void *m_autoReleasePool;
EventHandlerRef m_launchTerminationEventHandlerRef;
ProcessSerialNumber m_screenSaverPSN;
IEventQueue *m_events;
};
| 1,682
|
C++
|
.h
| 47
| 33.425532
| 119
| 0.787692
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,926
|
OSXScreenSaverControl.h
|
deskflow_deskflow/src/lib/platform/OSXScreenSaverControl.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2009 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// ScreenSaver.framework private API
// Class dumping by Alex Harper http://www.ragingmenace.com/
#pragma once
#import <Foundation/NSObject.h>
@protocol ScreenSaverControl
- (double)screenSaverTimeRemaining;
- (void)restartForUser:fp12;
- (void)screenSaverStopNow;
- (void)screenSaverStartNow;
- (void)setScreenSaverCanRun:(char)fp12;
- (BOOL)screenSaverCanRun;
- (BOOL)screenSaverIsRunning;
@end
@interface ScreenSaverController : NSObject <ScreenSaverControl>
+ controller;
+ monitor;
+ daemonConnectionName;
+ daemonPath;
+ enginePath;
- init;
- (void)dealloc;
- (void)_connectionClosed:fp12;
- (BOOL)screenSaverIsRunning;
- (BOOL)screenSaverCanRun;
- (void)setScreenSaverCanRun:(char)fp12;
- (void)screenSaverStartNow;
- (void)screenSaverStopNow;
- (void)restartForUser:fp12;
- (double)screenSaverTimeRemaining;
@end
| 1,557
|
C++
|
.h
| 47
| 31.659574
| 72
| 0.787899
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,927
|
IOSXKeyResource.h
|
deskflow_deskflow/src/lib/platform/IOSXKeyResource.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "deskflow/KeyState.h"
class IOSXKeyResource : public IInterface
{
public:
virtual bool isValid() const = 0;
virtual UInt32 getNumModifierCombinations() const = 0;
virtual UInt32 getNumTables() const = 0;
virtual UInt32 getNumButtons() const = 0;
virtual UInt32 getTableForModifier(UInt32 mask) const = 0;
virtual KeyID getKey(UInt32 table, UInt32 button) const = 0;
// Convert a character in the current script to the equivalent KeyID
static KeyID getKeyID(UInt8);
// Convert a unicode character to the equivalent KeyID.
static KeyID unicharToKeyID(UniChar);
};
| 1,295
|
C++
|
.h
| 32
| 38.21875
| 72
| 0.76868
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,928
|
XWindowsPowerManager.h
|
deskflow_deskflow/src/lib/platform/XWindowsPowerManager.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
class XWindowsPowerManager
{
public:
XWindowsPowerManager() = default;
~XWindowsPowerManager();
/**
* @brief Prevent the system from sleep
*/
void disableSleep() const;
/**
* @brief Enables automatical sleep
*/
void enableSleep() const;
XWindowsPowerManager(const XWindowsPowerManager &) = delete;
XWindowsPowerManager &operator=(const XWindowsPowerManager &) = delete;
};
| 1,148
|
C++
|
.h
| 34
| 31.352941
| 73
| 0.755856
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,929
|
PortalRemoteDesktop.h
|
deskflow_deskflow/src/lib/platform/PortalRemoteDesktop.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2022 Red Hat, Inc.
* Copyright (C) 2024 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "mt/Thread.h"
#include "platform/EiScreen.h"
#include <glib.h>
#include <libportal/portal.h>
namespace deskflow {
class PortalRemoteDesktop
{
public:
PortalRemoteDesktop(EiScreen *screen, IEventQueue *events);
~PortalRemoteDesktop();
private:
void glib_thread(void *);
gboolean timeout_handler();
gboolean init_remote_desktop_session();
void cb_init_remote_desktop_session(GObject *object, GAsyncResult *res);
void cb_session_started(GObject *object, GAsyncResult *res);
void cb_session_closed(XdpSession *session);
void reconnect(unsigned int timeout = 1000);
/// g_signal_connect callback wrapper
static void cb_session_closed_cb(XdpSession *session, gpointer data)
{
reinterpret_cast<PortalRemoteDesktop *>(data)->cb_session_closed(session);
}
int fake_eis_fd();
private:
EiScreen *screen_;
IEventQueue *events_;
Thread *glib_thread_;
GMainLoop *glib_main_loop_ = nullptr;
XdpPortal *portal_ = nullptr;
XdpSession *session_ = nullptr;
char *session_restore_token_ = nullptr;
guint session_signal_id_ = 0;
/// The number of successful sessions we've had already
guint session_iteration_ = 0;
};
} // namespace deskflow
| 1,931
|
C++
|
.h
| 55
| 32.618182
| 78
| 0.755639
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,930
|
OSXClipboardAnyTextConverter.h
|
deskflow_deskflow/src/lib/platform/OSXClipboardAnyTextConverter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/OSXClipboard.h"
//! Convert to/from some text encoding
class OSXClipboardAnyTextConverter : public IOSXClipboardConverter
{
public:
OSXClipboardAnyTextConverter();
virtual ~OSXClipboardAnyTextConverter();
// IOSXClipboardConverter overrides
virtual IClipboard::EFormat getFormat() const;
virtual CFStringRef getOSXFormat() const = 0;
virtual String fromIClipboard(const String &) const;
virtual String toIClipboard(const String &) const;
protected:
//! Convert from IClipboard format
/*!
Do UTF-8 conversion and linefeed conversion.
*/
virtual String doFromIClipboard(const String &) const = 0;
//! Convert to IClipboard format
/*!
Do UTF-8 conversion and Linefeed conversion.
*/
virtual String doToIClipboard(const String &) const = 0;
private:
static String convertLinefeedToMacOS(const String &);
static String convertLinefeedToUnix(const String &);
};
| 1,663
|
C++
|
.h
| 45
| 34.6
| 72
| 0.775295
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,931
|
PortalInputCapture.h
|
deskflow_deskflow/src/lib/platform/PortalInputCapture.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2022 Red Hat, Inc.
* Copyright (C) 2024 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "mt/Thread.h"
#include "platform/EiScreen.h"
#include <glib.h>
#include <libportal/inputcapture.h>
#include <libportal/portal.h>
#include <memory>
namespace deskflow {
class PortalInputCapture
{
public:
PortalInputCapture(EiScreen *screen, IEventQueue *events);
~PortalInputCapture();
void enable();
void disable();
void release();
void release(double x, double y);
bool is_active() const
{
return is_active_;
}
private:
void glib_thread(void *);
gboolean timeout_handler();
gboolean init_input_capture_session();
void cb_init_input_capture_session(GObject *object, GAsyncResult *res);
void cb_set_pointer_barriers(GObject *object, GAsyncResult *res);
void cb_session_closed(XdpSession *session);
void cb_disabled(XdpInputCaptureSession *session);
void cb_activated(XdpInputCaptureSession *session, std::uint32_t activation_id, GVariant *options);
void cb_deactivated(XdpInputCaptureSession *session, std::uint32_t activation_id, GVariant *options);
void cb_zones_changed(XdpInputCaptureSession *session, GVariant *options);
/// g_signal_connect callback wrapper
static void cb_session_closed_cb(XdpSession *session, gpointer data)
{
reinterpret_cast<PortalInputCapture *>(data)->cb_session_closed(session);
}
static void cb_disabled_cb(XdpInputCaptureSession *session, gpointer data)
{
reinterpret_cast<PortalInputCapture *>(data)->cb_disabled(session);
}
static void
cb_activated_cb(XdpInputCaptureSession *session, std::uint32_t activation_id, GVariant *options, gpointer data)
{
reinterpret_cast<PortalInputCapture *>(data)->cb_activated(session, activation_id, options);
}
static void
cb_deactivated_cb(XdpInputCaptureSession *session, std::uint32_t activation_id, GVariant *options, gpointer data)
{
reinterpret_cast<PortalInputCapture *>(data)->cb_deactivated(session, activation_id, options);
}
static void cb_zones_changed_cb(XdpInputCaptureSession *session, GVariant *options, gpointer data)
{
reinterpret_cast<PortalInputCapture *>(data)->cb_zones_changed(session, options);
}
int fake_eis_fd();
private:
EiScreen *screen_ = nullptr;
IEventQueue *events_ = nullptr;
Thread *glib_thread_;
GMainLoop *glib_main_loop_ = nullptr;
XdpPortal *portal_ = nullptr;
XdpInputCaptureSession *session_ = nullptr;
std::vector<guint> signals_;
bool enabled_ = false;
bool is_active_ = false;
std::uint32_t activation_id_ = 0;
std::vector<XdpInputCapturePointerBarrier *> barriers_;
};
} // namespace deskflow
| 3,286
|
C++
|
.h
| 87
| 35.011494
| 115
| 0.76005
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,932
|
OSXDragView.h
|
deskflow_deskflow/src/lib/platform/OSXDragView.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2013-2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#import <Cocoa/Cocoa.h>
#ifdef MAC_OS_X_VERSION_10_7
@interface OSXDragView : NSView <NSDraggingSource, NSDraggingInfo> {
NSMutableString *m_dropTarget;
NSString *m_dragFileExt;
}
- (CFStringRef)getDropTarget;
- (void)clearDropTarget;
- (void)setFileExt:(NSString *)ext;
@end
#endif
| 997
|
C++
|
.h
| 28
| 33.714286
| 72
| 0.767394
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,933
|
MSWindowsSession.h
|
deskflow_deskflow/src/lib/platform/MSWindowsSession.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2013-2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/String.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <Tlhelp32.h>
class MSWindowsSession
{
public:
MSWindowsSession();
~MSWindowsSession();
//!
/*!
Returns true if the session ID has changed since updateActiveSession was
called.
*/
BOOL hasChanged();
bool isProcessInSession(const char *name, PHANDLE process);
HANDLE getUserToken(LPSECURITY_ATTRIBUTES security);
DWORD getActiveSessionId()
{
return m_activeSessionId;
}
void updateActiveSession();
String getActiveDesktopName();
private:
BOOL nextProcessEntry(HANDLE snapshot, LPPROCESSENTRY32 entry);
private:
DWORD m_activeSessionId;
};
| 1,375
|
C++
|
.h
| 45
| 28.088889
| 74
| 0.769932
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,934
|
XWindowsScreenSaver.h
|
deskflow_deskflow/src/lib/platform/XWindowsScreenSaver.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/IEventQueue.h"
#include "common/stdmap.h"
#include "deskflow/IScreenSaver.h"
#if X_DISPLAY_MISSING
#error X11 is required to build deskflow
#else
#include <X11/Xlib.h>
#endif
class Event;
class EventQueueTimer;
//! X11 screen saver implementation
class XWindowsScreenSaver : public IScreenSaver
{
public:
XWindowsScreenSaver(Display *, Window, void *eventTarget, IEventQueue *events);
XWindowsScreenSaver(XWindowsScreenSaver const &) = delete;
XWindowsScreenSaver(XWindowsScreenSaver &&) = delete;
virtual ~XWindowsScreenSaver();
XWindowsScreenSaver &operator=(XWindowsScreenSaver const &) = delete;
XWindowsScreenSaver &operator=(XWindowsScreenSaver &&) = delete;
//! @name manipulators
//@{
//! Event filtering
/*!
Should be called for each system event before event translation and
dispatch. Returns true to skip translation and dispatch.
*/
bool handleXEvent(const XEvent *);
//! Destroy without the display
/*!
Tells this object to delete itself without using the X11 display.
It may leak some resources as a result.
*/
void destroy();
//@}
// IScreenSaver overrides
virtual void enable();
virtual void disable();
virtual void activate();
virtual void deactivate();
virtual bool isActive() const;
private:
// find and set the running xscreensaver's window. returns true iff
// found.
bool findXScreenSaver();
// set the xscreensaver's window, updating the activation state flag
void setXScreenSaver(Window);
// returns true if the window appears to be the xscreensaver window
bool isXScreenSaver(Window) const;
// set xscreensaver's activation state flag. sends notification
// if the state has changed.
void setXScreenSaverActive(bool activated);
// send a command to xscreensaver
void sendXScreenSaverCommand(Atom, long = 0, long = 0);
// watch all windows that could potentially be the xscreensaver for
// the events that will confirm it.
void watchForXScreenSaver();
// stop watching all watched windows
void clearWatchForXScreenSaver();
// add window to the watch list
void addWatchXScreenSaver(Window window);
// install/uninstall the job used to suppress the screensaver
void updateDisableTimer();
// called periodically to prevent the screen saver from starting
void handleDisableTimer(const Event &, void *);
// force DPMS to activate or deactivate
void activateDPMS(bool activate);
// enable/disable DPMS screen saver
void enableDPMS(bool);
// check if DPMS is enabled
bool isDPMSEnabled() const;
// check if DPMS is activate
bool isDPMSActivated() const;
private:
typedef std::map<Window, long> WatchList;
// the X display
Display *m_display;
// window to receive xscreensaver responses
Window m_xscreensaverSink;
// the target for the events we generate
void *m_eventTarget;
// xscreensaver's window
Window m_xscreensaver;
// xscreensaver activation state
bool m_xscreensaverActive;
// old event mask on root window
long m_rootEventMask;
// potential xscreensaver windows being watched
WatchList m_watchWindows;
// atoms used to communicate with xscreensaver's window
Atom m_atomScreenSaver;
Atom m_atomScreenSaverVersion;
Atom m_atomScreenSaverActivate;
Atom m_atomScreenSaverDeactivate;
// built-in screen saver settings
int m_timeout;
int m_interval;
int m_preferBlanking;
int m_allowExposures;
// DPMS screen saver settings
bool m_dpms;
bool m_dpmsEnabled;
// true iff the client wants the screen saver suppressed
bool m_disabled;
// true iff we're ignoring m_disabled. this is true, for example,
// when the client has called activate() and so presumably wants
// to activate the screen saver even if disabled.
bool m_suppressDisable;
// the disable timer (NULL if not installed)
EventQueueTimer *m_disableTimer;
// fake mouse motion position for suppressing the screen saver.
// xscreensaver since 2.21 requires the mouse to move more than 10
// pixels to be considered significant.
SInt32 m_disablePos;
IEventQueue *m_events;
};
| 4,854
|
C++
|
.h
| 134
| 33.320896
| 81
| 0.766403
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,935
|
OSXClipboardAnyBitmapConverter.h
|
deskflow_deskflow/src/lib/platform/OSXClipboardAnyBitmapConverter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
* Patch by Ryan Chapman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/OSXClipboard.h"
//! Convert to/from some text encoding
class OSXClipboardAnyBitmapConverter : public IOSXClipboardConverter
{
public:
OSXClipboardAnyBitmapConverter();
virtual ~OSXClipboardAnyBitmapConverter();
// IOSXClipboardConverter overrides
virtual IClipboard::EFormat getFormat() const;
virtual CFStringRef getOSXFormat() const = 0;
virtual String fromIClipboard(const String &) const;
virtual String toIClipboard(const String &) const;
protected:
//! Convert from IClipboard format
/*!
Do UTF-8 conversion and linefeed conversion.
*/
virtual String doFromIClipboard(const String &) const = 0;
//! Convert to IClipboard format
/*!
Do UTF-8 conversion and Linefeed conversion.
*/
virtual String doToIClipboard(const String &) const = 0;
};
| 1,536
|
C++
|
.h
| 42
| 34.190476
| 72
| 0.771505
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,936
|
MSWindowsUtil.h
|
deskflow_deskflow/src/lib/platform/MSWindowsUtil.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/String.h"
#define WINDOWS_LEAN_AND_MEAN
#include <Windows.h>
class MSWindowsUtil
{
public:
//! Get message string
/*!
Gets a string for \p id from the string table of \p instance.
*/
static String getString(HINSTANCE instance, DWORD id);
//! Get error string
/*!
Gets a system error message for \p error. If the error cannot be
found return the string for \p id, replacing ${1} with \p error.
*/
static String getErrorString(HINSTANCE, DWORD error, DWORD id);
};
| 1,249
|
C++
|
.h
| 36
| 32.5
| 72
| 0.746689
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,937
|
MSWindowsPowerManager.h
|
deskflow_deskflow/src/lib/platform/MSWindowsPowerManager.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2021 Symless Ltd.
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
class MSWindowsPowerManager
{
public:
~MSWindowsPowerManager();
/**
* @brief Prevents the system from sleep automatically
*/
void disableSleep();
/**
* @brief Enable automatically sleeping
*/
void enableSleep();
};
| 992
|
C++
|
.h
| 31
| 29.677419
| 72
| 0.74739
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,938
|
OSXAutoTypes.h
|
deskflow_deskflow/src/lib/platform/OSXAutoTypes.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2022 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#if WINAPI_CARBON
#include <Carbon/Carbon.h>
#include <memory>
using CFDeallocator = decltype(&CFRelease);
using AutoCFArray = std::unique_ptr<const __CFArray, CFDeallocator>;
using AutoCFDictionary = std::unique_ptr<const __CFDictionary, CFDeallocator>;
using AutoTISInputSourceRef = std::unique_ptr<__TISInputSource, CFDeallocator>;
#endif
| 1,044
|
C++
|
.h
| 25
| 40.04
| 79
| 0.774606
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,939
|
MSWindowsHook.h
|
deskflow_deskflow/src/lib/platform/MSWindowsHook.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2011 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/dfwhook.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
//! Loads and provides functions for the Windows hook
class MSWindowsHook
{
public:
MSWindowsHook();
virtual ~MSWindowsHook();
void loadLibrary();
int init(DWORD threadID);
int cleanup();
void setSides(UInt32 sides);
void setZone(SInt32 x, SInt32 y, SInt32 w, SInt32 h, SInt32 jumpZoneSize);
void setMode(EHookMode mode);
static EHookResult install();
static int uninstall();
static int installScreenSaver();
static int uninstallScreenSaver();
};
| 1,307
|
C++
|
.h
| 38
| 31.973684
| 76
| 0.763347
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,940
|
MSWindowsClipboardFacade.h
|
deskflow_deskflow/src/lib/platform/MSWindowsClipboardFacade.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/IMSWindowsClipboardFacade.h"
#include "deskflow/IClipboard.h"
class MSWindowsClipboardFacade : public IMSWindowsClipboardFacade
{
public:
virtual void write(HANDLE win32Data, UINT win32Format);
};
| 965
|
C++
|
.h
| 25
| 36.72
| 72
| 0.780983
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,941
|
XWindowsClipboardHTMLConverter.h
|
deskflow_deskflow/src/lib/platform/XWindowsClipboardHTMLConverter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/XWindowsClipboard.h"
//! Convert to/from HTML encoding
class XWindowsClipboardHTMLConverter : public IXWindowsClipboardConverter
{
public:
/*!
\c name is converted to an atom and that is reported by getAtom().
*/
XWindowsClipboardHTMLConverter(Display *display, const char *name);
virtual ~XWindowsClipboardHTMLConverter();
// IXWindowsClipboardConverter overrides
virtual IClipboard::EFormat getFormat() const;
virtual Atom getAtom() const;
virtual int getDataSize() const;
virtual String fromIClipboard(const String &) const;
virtual String toIClipboard(const String &) const;
private:
Atom m_atom;
};
| 1,395
|
C++
|
.h
| 37
| 35.486486
| 73
| 0.776792
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| true
| true
| false
| false
| false
| false
| false
| false
|
13,942
|
XWindowsClipboard.h
|
deskflow_deskflow/src/lib/platform/XWindowsClipboard.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common/stdlist.h"
#include "common/stdmap.h"
#include "common/stdvector.h"
#include "deskflow/IClipboard.h"
#include "deskflow/clipboard_types.h"
#if X_DISPLAY_MISSING
#error X11 is required to build deskflow
#else
#include <X11/Xlib.h>
#endif
class IXWindowsClipboardConverter;
//! X11 clipboard implementation
class XWindowsClipboard : public IClipboard
{
public:
/*!
Use \c window as the window that owns or interacts with the
clipboard identified by \c id.
*/
XWindowsClipboard(Display *, Window window, ClipboardID id);
XWindowsClipboard(XWindowsClipboard const &) = delete;
XWindowsClipboard(XWindowsClipboard &&) = delete;
virtual ~XWindowsClipboard();
XWindowsClipboard &operator=(XWindowsClipboard const &) = delete;
XWindowsClipboard &operator=(XWindowsClipboard &&) = delete;
//! Notify clipboard was lost
/*!
Tells clipboard it lost ownership at the given time.
*/
void lost(Time);
//! Add clipboard request
/*!
Adds a selection request to the request list. If the given
owner window isn't this clipboard's window then this simply
sends a failure event to the requestor.
*/
void addRequest(Window owner, Window requestor, Atom target, ::Time time, Atom property);
//! Process clipboard request
/*!
Continues processing a selection request. Returns true if the
request was handled, false if the request was unknown.
*/
bool processRequest(Window requestor, ::Time time, Atom property);
//! Cancel clipboard request
/*!
Terminate a selection request. Returns true iff the request
was known and handled.
*/
bool destroyRequest(Window requestor);
//! Get window
/*!
Returns the clipboard's window (passed the c'tor).
*/
Window getWindow() const;
//! Get selection atom
/*!
Returns the selection atom that identifies the clipboard to X11
(e.g. XA_PRIMARY).
*/
Atom getSelection() const;
// IClipboard overrides
virtual bool empty();
virtual void add(EFormat, const String &data);
virtual bool open(Time) const;
virtual void close() const;
virtual Time getTime() const;
virtual bool has(EFormat) const;
virtual String get(EFormat) const;
private:
// remove all converters from our list
void clearConverters();
// get the converter for a clipboard format. returns NULL if no
// suitable converter. iff onlyIfNotAdded is true then also
// return NULL if a suitable converter was found but we already
// have data of the converter's clipboard format.
IXWindowsClipboardConverter *getConverter(Atom target, bool onlyIfNotAdded = false) const;
// convert target atom to clipboard format
EFormat getFormat(Atom target) const;
// add a non-MULTIPLE request. does not verify that the selection
// was owned at the given time. returns true if the conversion
// could be performed, false otherwise. in either case, the
// reply is inserted.
bool addSimpleRequest(Window requestor, Atom target, ::Time time, Atom property);
// if not already checked then see if the cache is stale and, if so,
// clear it. this has the side effect of updating m_timeOwned.
void checkCache() const;
// clear the cache, resetting the cached flag and the added flag for
// each format.
void clearCache() const;
void doClearCache();
// cache all formats of the selection
void fillCache() const;
void doFillCache();
protected:
//
// helper classes
//
// read an ICCCM conforming selection
class CICCCMGetClipboard
{
public:
CICCCMGetClipboard(Window requestor, Time time, Atom property);
~CICCCMGetClipboard() = default;
// convert the given selection to the given type. returns
// true iff the conversion was successful or the conversion
// cannot be performed (in which case *actualTarget == None).
bool readClipboard(Display *display, Atom selection, Atom target, Atom *actualTarget, String *data);
private:
bool processEvent(Display *display, XEvent *event);
private:
Window m_requestor;
Time m_time;
Atom m_property;
bool m_incr = false;
bool m_failed = false;
bool m_done = false;
// atoms needed for the protocol
Atom m_atomNone = None;
Atom m_atomIncr = None;
// true iff we've received the selection notify
bool m_reading = false;
// the converted selection data
String *m_data = nullptr;
// the actual type of the data. if this is None then the
// selection owner cannot convert to the requested type.
Atom *m_actualTarget = nullptr;
// true iff the selection owner didn't follow ICCCM conventions
bool m_error = false;
public:
bool error() const
{
return m_error;
}
};
// Motif structure IDs
enum class MotifClip : SInt32
{
Format = 1,
Item = 2,
Header = 3
};
// _MOTIF_CLIP_HEADER structure
class MotifClipHeader
{
public:
MotifClip m_id;
SInt32 m_pad1[3];
SInt32 m_item;
SInt32 m_pad2[4];
SInt32 m_numItems;
SInt32 m_pad3[3];
SInt32 m_selectionOwner; // a Window
SInt32 m_pad4[2];
};
// Motif clip item structure
class MotifClipItem
{
public:
MotifClip m_id;
SInt32 m_pad1[5];
SInt32 m_size;
SInt32 m_numFormats;
SInt32 m_numDeletedFormats;
SInt32 m_pad2[6];
};
// Motif clip format structure
class MotifClipFormat
{
public:
MotifClip m_id;
SInt32 m_pad1[6];
SInt32 m_length;
SInt32 m_data;
SInt32 m_type; // an Atom
SInt32 m_pad2[1];
SInt32 m_deleted;
SInt32 m_pad3[4];
};
// stores data needed to respond to a selection request
class Reply
{
public:
Reply(Window, Atom target, ::Time);
Reply(Window, Atom target, ::Time, Atom property, const String &data, Atom type, int format);
public:
// information about the request
Window m_requestor;
Atom m_target;
::Time m_time;
Atom m_property;
// true iff we've sent the notification for this reply
bool m_replied;
// true iff the reply has sent its last message
bool m_done;
// the data to send and its type and format
String m_data;
Atom m_type;
int m_format;
// index of next byte in m_data to send
UInt32 m_ptr;
};
typedef std::list<Reply *> ReplyList;
typedef std::map<Window, ReplyList> ReplyMap;
typedef std::map<Window, long> ReplyEventMask;
// ICCCM interoperability methods
void icccmFillCache();
bool icccmGetSelection(Atom target, Atom *actualTarget, String *data) const;
Time icccmGetTime() const;
// motif interoperability methods
bool motifLockClipboard() const;
void motifUnlockClipboard() const;
bool motifOwnsClipboard() const;
void motifFillCache();
bool motifGetSelection(const MotifClipFormat *, Atom *actualTarget, String *data) const;
Time motifGetTime() const;
// reply methods
bool insertMultipleReply(Window, ::Time, Atom);
void insertReply(Reply *);
void pushReplies();
void pushReplies(ReplyMap::iterator &, ReplyList &, ReplyList::iterator);
bool sendReply(Reply *);
void clearReplies();
void clearReplies(ReplyList &);
void sendNotify(Window requestor, Atom selection, Atom target, Atom property, Time time);
bool wasOwnedAtTime(::Time) const;
// data conversion methods
Atom getTargetsData(String &, int *format) const;
Atom getTimestampData(String &, int *format) const;
private:
typedef std::vector<IXWindowsClipboardConverter *> ConverterList;
Display *m_display;
Window m_window;
ClipboardID m_id;
Atom m_selection;
mutable bool m_open;
mutable Time m_time;
bool m_owner;
mutable Time m_timeOwned;
Time m_timeLost;
// true iff open and clipboard owned by a motif app
mutable bool m_motif;
// the added/cached clipboard data
mutable bool m_checkCache;
bool m_cached;
Time m_cacheTime;
bool m_added[kNumFormats];
String m_data[kNumFormats];
// conversion request replies
ReplyMap m_replies;
ReplyEventMask m_eventMasks;
// clipboard format converters
ConverterList m_converters;
// atoms we'll need
Atom m_atomTargets;
Atom m_atomMultiple;
Atom m_atomTimestamp;
Atom m_atomInteger;
Atom m_atomAtom;
Atom m_atomAtomPair;
Atom m_atomData;
Atom m_atomINCR;
Atom m_atomMotifClipLock;
Atom m_atomMotifClipHeader;
Atom m_atomMotifClipAccess;
Atom m_atomGDKSelection;
};
//! Clipboard format converter interface
/*!
This interface defines the methods common to all X11 clipboard format
converters.
*/
class IXWindowsClipboardConverter : public IInterface
{
public:
//! @name accessors
//@{
//! Get clipboard format
/*!
Return the clipboard format this object converts from/to.
*/
virtual IClipboard::EFormat getFormat() const = 0;
//! Get X11 format atom
/*!
Return the atom representing the X selection format that
this object converts from/to.
*/
virtual Atom getAtom() const = 0;
//! Get X11 property datum size
/*!
Return the size (in bits) of data elements returned by
toIClipboard().
*/
virtual int getDataSize() const = 0;
//! Convert from IClipboard format
/*!
Convert from the IClipboard format to the X selection format.
The input data must be in the IClipboard format returned by
getFormat(). The return data will be in the X selection
format returned by getAtom().
*/
virtual String fromIClipboard(const String &) const = 0;
//! Convert to IClipboard format
/*!
Convert from the X selection format to the IClipboard format
(i.e., the reverse of fromIClipboard()).
*/
virtual String toIClipboard(const String &) const = 0;
//@}
};
| 10,330
|
C++
|
.h
| 327
| 28.201835
| 104
| 0.730893
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,943
|
MSWindowsClipboardAnyTextConverter.h
|
deskflow_deskflow/src/lib/platform/MSWindowsClipboardAnyTextConverter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/MSWindowsClipboard.h"
//! Convert to/from some text encoding
class MSWindowsClipboardAnyTextConverter : public IMSWindowsClipboardConverter
{
public:
MSWindowsClipboardAnyTextConverter();
virtual ~MSWindowsClipboardAnyTextConverter();
// IMSWindowsClipboardConverter overrides
virtual IClipboard::EFormat getFormat() const;
virtual UINT getWin32Format() const = 0;
virtual HANDLE fromIClipboard(const String &) const;
virtual String toIClipboard(HANDLE) const;
protected:
//! Convert from IClipboard format
/*!
Do UTF-8 conversion only. Memory handle allocation and
linefeed conversion is done by this class. doFromIClipboard()
must include the nul terminator in the returned string (not
including the String's nul terminator).
*/
virtual String doFromIClipboard(const String &) const = 0;
//! Convert to IClipboard format
/*!
Do UTF-8 conversion only. Memory handle allocation and
linefeed conversion is done by this class.
*/
virtual String doToIClipboard(const String &) const = 0;
private:
String convertLinefeedToWin32(const String &) const;
String convertLinefeedToUnix(const String &) const;
};
| 1,920
|
C++
|
.h
| 49
| 36.77551
| 78
| 0.781116
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,944
|
EiScreen.h
|
deskflow_deskflow/src/lib/platform/EiScreen.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2022 Red Hat, Inc.
* Copyright (C) 2024 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "deskflow/KeyMap.h"
#include "deskflow/PlatformScreen.h"
#include <libei.h>
#include <mutex>
#include <set>
#include <vector>
struct ei;
struct ei_event;
struct ei_seat;
struct ei_device;
namespace deskflow {
class EiClipboard;
class EiKeyState;
class PortalRemoteDesktop;
class PortalInputCapture;
//! Implementation of IPlatformScreen for X11
class EiScreen : public PlatformScreen
{
public:
EiScreen(bool is_primary, IEventQueue *events, bool use_portal);
~EiScreen();
// IScreen overrides
void *getEventTarget() const override;
bool getClipboard(ClipboardID id, IClipboard *) const override;
void getShape(std::int32_t &x, std::int32_t &y, std::int32_t &width, std::int32_t &height) const override;
void getCursorPos(std::int32_t &x, std::int32_t &y) const override;
// IPrimaryScreen overrides
void reconfigure(std::uint32_t activeSides) override;
void warpCursor(std::int32_t x, std::int32_t y) override;
std::uint32_t registerHotKey(KeyID key, KeyModifierMask mask) override;
void unregisterHotKey(std::uint32_t id) override;
void fakeInputBegin() override;
void fakeInputEnd() override;
std::int32_t getJumpZoneSize() const override;
bool isAnyMouseButtonDown(std::uint32_t &buttonID) const override;
void getCursorCenter(std::int32_t &x, std::int32_t &y) const override;
// ISecondaryScreen overrides
void fakeMouseButton(ButtonID id, bool press) override;
void fakeMouseMove(std::int32_t x, std::int32_t y) override;
void fakeMouseRelativeMove(std::int32_t dx, std::int32_t dy) const override;
void fakeMouseWheel(std::int32_t xDelta, std::int32_t yDelta) const override;
void fakeKey(std::uint32_t keycode, bool is_down) const;
// IPlatformScreen overrides
void enable() override;
void disable() override;
void enter() override;
bool canLeave() override;
void leave() override;
bool setClipboard(ClipboardID, const IClipboard *) override;
void checkClipboards() override;
void openScreensaver(bool notify) override;
void closeScreensaver() override;
void screensaver(bool activate) override;
void resetOptions() override;
void setOptions(const OptionsList &options) override;
void setSequenceNumber(std::uint32_t) override;
bool isPrimary() const override;
protected:
// IPlatformScreen overrides
void handleSystemEvent(const Event &event, void *) override;
void updateButtons() override;
IKeyState *getKeyState() const override;
String getSecureInputApp() const override;
void update_shape();
void add_device(ei_device *device);
void remove_device(ei_device *device);
private:
void init_ei();
void cleanup_ei();
void sendEvent(Event::Type type, void *data);
ButtonID map_button_from_evdev(ei_event *event) const;
void on_key_event(ei_event *event);
void on_button_event(ei_event *event);
void send_wheel_events(ei_device *device, const int threshold, double dx, double dy, bool is_discrete);
void on_pointer_scroll_event(ei_event *event);
void on_pointer_scroll_discrete_event(ei_event *event);
void on_motion_event(ei_event *event);
void on_abs_motion_event(ei_event *event);
bool on_hotkey(KeyID key, bool is_press, KeyModifierMask mask);
void handle_ei_log_event(ei *ei, ei_log_priority priority, const char *message, ei_log_context *context);
void handle_connected_to_eis_event(const Event &event, void *);
void handle_portal_session_closed(const Event &event, void *);
static void cb_handle_ei_log_event(ei *ei, ei_log_priority priority, const char *message, ei_log_context *context)
{
auto screen = reinterpret_cast<EiScreen *>(ei_get_user_data(ei));
screen->handle_ei_log_event(ei, priority, message, context);
}
private:
// true if screen is being used as a primary screen, false otherwise
bool is_primary_ = false;
IEventQueue *events_ = nullptr;
// keyboard stuff
EiKeyState *key_state_ = nullptr;
std::vector<ei_device *> ei_devices_;
ei *ei_ = nullptr;
ei_seat *ei_seat_ = nullptr;
ei_device *ei_pointer_ = nullptr;
ei_device *ei_keyboard_ = nullptr;
ei_device *ei_abs_ = nullptr;
std::uint32_t sequence_number_ = 0;
std::uint32_t x_ = 0;
std::uint32_t y_ = 0;
std::uint32_t w_ = 0;
std::uint32_t h_ = 0;
// true if mouse has entered the screen
bool is_on_screen_;
// server: last pointer position
// client: position sent before enter()
std::int32_t cursor_x_ = 0;
std::int32_t cursor_y_ = 0;
double buffer_dx = 0;
double buffer_dy = 0;
mutable std::mutex mutex_;
PortalRemoteDesktop *portal_remote_desktop_ = nullptr;
PortalInputCapture *portal_input_capture_ = nullptr;
struct HotKeyItem
{
public:
HotKeyItem(std::uint32_t mask, std::uint32_t id);
bool operator<(const HotKeyItem &other) const
{
return mask_ < other.mask_;
};
public:
std::uint32_t mask_ = 0;
std::uint32_t id_ = 0; // for registering the hotkey
};
class HotKeySet
{
public:
HotKeySet(KeyID keyid);
KeyID keyid() const
{
return id_;
};
bool remove_by_id(std::uint32_t id);
void add_item(HotKeyItem item);
std::uint32_t find_by_mask(std::uint32_t mask) const;
private:
KeyID id_ = 0;
std::vector<HotKeyItem> set_;
};
using HotKeyMap = std::map<KeyID, HotKeySet>;
HotKeyMap hotkeys_;
};
} // namespace deskflow
| 6,066
|
C++
|
.h
| 164
| 33.945122
| 116
| 0.736412
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,945
|
MSWindowsDebugOutputter.h
|
deskflow_deskflow/src/lib/platform/MSWindowsDebugOutputter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/ILogOutputter.h"
//! Write log to debugger
/*!
This outputter writes output to the debugger. In Visual Studio, this
can be seen in the Output window.
*/
class MSWindowsDebugOutputter : public ILogOutputter
{
public:
MSWindowsDebugOutputter();
virtual ~MSWindowsDebugOutputter();
// ILogOutputter overrides
virtual void open(const char *title);
virtual void close();
virtual void show(bool showIfEmpty);
virtual bool write(ELevel level, const char *message);
virtual void flush();
};
| 1,256
|
C++
|
.h
| 36
| 32.888889
| 72
| 0.768092
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,946
|
XWindowsClipboardUCS2Converter.h
|
deskflow_deskflow/src/lib/platform/XWindowsClipboardUCS2Converter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/XWindowsClipboard.h"
//! Convert to/from UCS-2 encoding
class XWindowsClipboardUCS2Converter : public IXWindowsClipboardConverter
{
public:
/*!
\c name is converted to an atom and that is reported by getAtom().
*/
XWindowsClipboardUCS2Converter(Display *display, const char *name);
virtual ~XWindowsClipboardUCS2Converter();
// IXWindowsClipboardConverter overrides
virtual IClipboard::EFormat getFormat() const;
virtual Atom getAtom() const;
virtual int getDataSize() const;
virtual String fromIClipboard(const String &) const;
virtual String toIClipboard(const String &) const;
private:
Atom m_atom;
};
| 1,396
|
C++
|
.h
| 37
| 35.513514
| 73
| 0.776219
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,947
|
EiEventQueueBuffer.h
|
deskflow_deskflow/src/lib/platform/EiEventQueueBuffer.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2022 Red Hat, Inc.
* Copyright (C) 2024 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/IEventQueueBuffer.h"
#include "deskflow/IScreen.h"
#include "mt/Thread.h"
#include "platform/EiScreen.h"
#include <libei.h>
#include <memory>
#include <mutex>
#include <queue>
namespace deskflow {
//! Event queue buffer for Ei
class EiEventQueueBuffer : public IEventQueueBuffer
{
public:
EiEventQueueBuffer(EiScreen *screen, ei *ei, IEventQueue *events);
~EiEventQueueBuffer();
// IEventQueueBuffer overrides
void init() override
{
}
void waitForEvent(double timeout_in_ms) override;
Type getEvent(Event &event, uint32_t &dataID) override;
bool addEvent(uint32_t dataID) override;
bool isEmpty() const override;
EventQueueTimer *newTimer(double duration, bool oneShot) const override;
void deleteTimer(EventQueueTimer *) const override;
private:
ei *ei_;
IEventQueue *events_;
std::queue<std::pair<bool, uint32_t>> queue_;
int pipe_w_, pipe_r_;
mutable std::mutex mutex_;
};
} // namespace deskflow
| 1,693
|
C++
|
.h
| 51
| 31.039216
| 74
| 0.759951
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,948
|
OSXScreen.h
|
deskflow_deskflow/src/lib/platform/OSXScreen.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/EventTypes.h"
#include "common/stdmap.h"
#include "common/stdvector.h"
#include "deskflow/DragInformation.h"
#include "deskflow/PlatformScreen.h"
#include "platform/OSXClipboard.h"
#include "platform/OSXPowerManager.h"
#include <Carbon/Carbon.h>
#include <IOKit/IOMessage.h>
#include <bitset>
#include <mach/mach_init.h>
#include <mach/mach_interface.h>
#include <mach/mach_port.h>
#include <memory>
extern "C"
{
typedef int CGSConnectionID;
CGError CGSSetConnectionProperty(CGSConnectionID cid, CGSConnectionID targetCID, CFStringRef key, CFTypeRef value);
int _CGSDefaultConnection();
}
template <class T> class CondVar;
class EventQueueTimer;
class Mutex;
class Thread;
class OSXKeyState;
class OSXScreenSaver;
class IEventQueue;
class Mutex;
//! Implementation of IPlatformScreen for OS X
class OSXScreen : public PlatformScreen
{
public:
OSXScreen(
IEventQueue *events, bool isPrimary, bool enableLangSync = false,
deskflow::ClientScrollDirection scrollDirection = deskflow::ClientScrollDirection::SERVER
);
virtual ~OSXScreen();
IEventQueue *getEvents() const
{
return m_events;
}
// IScreen overrides
void *getEventTarget() const override;
bool getClipboard(ClipboardID id, IClipboard *) const override;
void getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const override;
void getCursorPos(SInt32 &x, SInt32 &y) const override;
// IPrimaryScreen overrides
void reconfigure(UInt32 activeSides) override;
void warpCursor(SInt32 x, SInt32 y) override;
UInt32 registerHotKey(KeyID key, KeyModifierMask mask) override;
void unregisterHotKey(UInt32 id) override;
void fakeInputBegin() override;
void fakeInputEnd() override;
SInt32 getJumpZoneSize() const override;
bool isAnyMouseButtonDown(UInt32 &buttonID) const override;
void getCursorCenter(SInt32 &x, SInt32 &y) const override;
// ISecondaryScreen overrides
void fakeMouseButton(ButtonID id, bool press) override;
void fakeMouseMove(SInt32 x, SInt32 y) override;
void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const override;
void fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const override;
// IPlatformScreen overrides
void enable() override;
void disable() override;
void enter() override;
bool canLeave() override;
void leave() override;
bool setClipboard(ClipboardID, const IClipboard *) override;
void checkClipboards() override;
void openScreensaver(bool notify) override;
void closeScreensaver() override;
void screensaver(bool activate) override;
void resetOptions() override;
void setOptions(const OptionsList &options) override;
void setSequenceNumber(UInt32) override;
bool isPrimary() const override;
void fakeDraggingFiles(DragFileList fileList) override;
String &getDraggingFilename() override;
String getSecureInputApp() const override;
const String &getDropTarget() const override
{
return m_dropTarget;
}
void waitForCarbonLoop() const;
protected:
// IPlatformScreen overrides
void handleSystemEvent(const Event &, void *) override;
void updateButtons() override;
IKeyState *getKeyState() const override;
private:
bool updateScreenShape();
bool updateScreenShape(const CGDirectDisplayID, const CGDisplayChangeSummaryFlags);
void postMouseEvent(CGPoint &) const;
// convenience function to send events
void sendEvent(Event::Type type, void * = NULL) const;
void sendClipboardEvent(Event::Type type, ClipboardID id) const;
// message handlers
bool onMouseMove(CGFloat mx, CGFloat my);
// mouse button handler. pressed is true if this is a mousedown
// event, false if it is a mouseup event. macButton is the index
// of the button pressed using the mac button mapping.
bool onMouseButton(bool pressed, UInt16 macButton);
bool onMouseWheel(SInt32 xDelta, SInt32 yDelta) const;
void constructMouseButtonEventMap();
bool onKey(CGEventRef event);
void onMediaKey(CGEventRef event);
bool onHotKey(EventRef event) const;
// Added here to allow the carbon cursor hack to be called.
void showCursor();
void hideCursor();
// map deskflow mouse button to mac buttons
ButtonID mapDeskflowButtonToMac(UInt16) const;
// map mac mouse button to deskflow buttons
ButtonID mapMacButtonToDeskflow(UInt16) const;
// map mac scroll wheel value to a deskflow scroll wheel value
SInt32 mapScrollWheelToDeskflow(SInt32) const;
// map deskflow scroll wheel value to a mac scroll wheel value
SInt32 mapScrollWheelFromDeskflow(SInt32) const;
// get the current scroll wheel speed
double getScrollSpeed() const;
// enable/disable drag handling for buttons 3 and up
void enableDragTimer(bool enable);
// drag timer handler
void handleDrag(const Event &, void *);
// clipboard check timer handler
void handleClipboardCheck(const Event &, void *);
// Resolution switch callback
static void displayReconfigurationCallback(CGDirectDisplayID, CGDisplayChangeSummaryFlags, void *);
// fast user switch callback
static pascal OSStatus userSwitchCallback(EventHandlerCallRef nextHandler, EventRef theEvent, void *inUserData);
// sleep / wakeup support
void watchSystemPowerThread(void *);
static void testCanceled(CFRunLoopTimerRef timer, void *info);
static void powerChangeCallback(void *refcon, io_service_t service, natural_t messageType, void *messageArgument);
void handlePowerChangeRequest(natural_t messageType, void *messageArgument);
void handleConfirmSleep(const Event &event, void *);
// global hotkey operating mode
static bool isGlobalHotKeyOperatingModeAvailable();
static void setGlobalHotKeysEnabled(bool enabled);
static bool getGlobalHotKeysEnabled();
// Quartz event tap support
static CGEventRef handleCGInputEvent(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon);
static CGEventRef
handleCGInputEventSecondary(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon);
// convert CFString to char*
static char *CFStringRefToUTF8String(CFStringRef aString);
void getDropTargetThread(void *);
private:
struct HotKeyItem
{
public:
HotKeyItem(UInt32, UInt32);
HotKeyItem(EventHotKeyRef, UInt32, UInt32);
EventHotKeyRef getRef() const;
bool operator<(const HotKeyItem &) const;
private:
EventHotKeyRef m_ref;
UInt32 m_keycode;
UInt32 m_mask;
};
enum EMouseButtonState
{
kMouseButtonUp = 0,
kMouseButtonDragged,
kMouseButtonDown,
kMouseButtonStateMax
};
class MouseButtonState
{
public:
void set(UInt32 button, EMouseButtonState state);
bool any();
void reset();
void overwrite(UInt32 buttons);
bool test(UInt32 button) const;
SInt8 getFirstButtonDown() const;
private:
std::bitset<NumButtonIDs> m_buttons;
};
typedef std::map<UInt32, HotKeyItem> HotKeyMap;
typedef std::vector<UInt32> HotKeyIDList;
typedef std::map<KeyModifierMask, UInt32> ModifierHotKeyMap;
typedef std::map<HotKeyItem, UInt32> HotKeyToIDMap;
// true if screen is being used as a primary screen, false otherwise
bool m_isPrimary;
// true if mouse has entered the screen
bool m_isOnScreen;
// the display
CGDirectDisplayID m_displayID;
// screen shape stuff
SInt32 m_x, m_y;
SInt32 m_w, m_h;
SInt32 m_xCenter, m_yCenter;
// mouse state
mutable SInt32 m_xCursor, m_yCursor;
mutable bool m_cursorPosValid;
/* FIXME: this data structure is explicitly marked mutable due
to a need to track the state of buttons since the remote
side only lets us know of change events, and because the
fakeMouseButton button method is marked 'const'. This is
Evil, and this should be moved to a place where it need not
be mutable as soon as possible. */
mutable MouseButtonState m_buttonState;
typedef std::map<UInt16, CGEventType> MouseButtonEventMapType;
std::vector<MouseButtonEventMapType> MouseButtonEventMap;
bool m_cursorHidden;
SInt32 m_dragNumButtonsDown;
Point m_dragLastPoint;
EventQueueTimer *m_dragTimer;
// keyboard stuff
OSXKeyState *m_keyState;
// clipboards
OSXClipboard m_pasteboard;
UInt32 m_sequenceNumber;
// screen saver stuff
OSXScreenSaver *m_screensaver;
bool m_screensaverNotify;
// clipboard stuff
bool m_ownClipboard;
EventQueueTimer *m_clipboardTimer;
// window object that gets user input events when the server
// has focus.
WindowRef m_hiddenWindow;
// window object that gets user input events when the server
// does not have focus.
WindowRef m_userInputWindow;
// fast user switching
EventHandlerRef m_switchEventHandlerRef;
// sleep / wakeup
Mutex *m_pmMutex;
Thread *m_pmWatchThread;
CondVar<bool> *m_pmThreadReady;
CFRunLoopRef m_pmRunloop;
io_connect_t m_pmRootPort;
// hot key stuff
HotKeyMap m_hotKeys;
HotKeyIDList m_oldHotKeyIDs;
ModifierHotKeyMap m_modifierHotKeys;
UInt32 m_activeModifierHotKey;
KeyModifierMask m_activeModifierHotKeyMask;
HotKeyToIDMap m_hotKeyToIDMap;
// global hotkey operating mode
static bool s_testedForGHOM;
static bool s_hasGHOM;
// Quartz input event support
CFMachPortRef m_eventTapPort;
CFRunLoopSourceRef m_eventTapRLSR;
// for double click coalescing.
double m_lastClickTime;
int m_clickState;
SInt32 m_lastSingleClickXCursor;
SInt32 m_lastSingleClickYCursor;
IEventQueue *m_events;
std::unique_ptr<Thread> m_getDropTargetThread;
String m_dropTarget;
#if defined(MAC_OS_X_VERSION_10_7)
Mutex *m_carbonLoopMutex;
CondVar<bool> *m_carbonLoopReady;
#endif
OSXPowerManager m_powerManager;
class OSXScreenImpl *m_impl;
};
| 10,398
|
C++
|
.h
| 280
| 33.982143
| 117
| 0.781051
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,949
|
dfwhook.h
|
deskflow_deskflow/src/lib/platform/dfwhook.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
// hack: vs2005 doesn't declare _WIN32_WINNT, so we need to hard code it.
// however, some say that this should be hard coded since it defines the
// target system, but since this is suposed to compile on pre-XP, maybe
// we should just leave it like this.
#if _MSC_VER == 1400
#define _WIN32_WINNT 0x0400
#endif
#include "base/EventTypes.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#if defined(dfwhook_EXPORTS)
#define CDESKFLOWHOOK_API __declspec(dllexport)
#else
#define CDESKFLOWHOOK_API __declspec(dllimport)
#endif
#define DESKFLOW_MSG_MARK WM_APP + 0x0011 // mark id; <unused>
#define DESKFLOW_MSG_KEY WM_APP + 0x0012 // vk code; key data
#define DESKFLOW_MSG_MOUSE_BUTTON WM_APP + 0x0013 // button msg; <unused>
#define DESKFLOW_MSG_MOUSE_WHEEL WM_APP + 0x0014 // delta; <unused>
#define DESKFLOW_MSG_MOUSE_MOVE WM_APP + 0x0015 // x; y
#define DESKFLOW_MSG_POST_WARP WM_APP + 0x0016 // <unused>; <unused>
#define DESKFLOW_MSG_PRE_WARP WM_APP + 0x0017 // x; y
#define DESKFLOW_MSG_SCREEN_SAVER WM_APP + 0x0018 // activated; <unused>
#define DESKFLOW_MSG_DEBUG WM_APP + 0x0019 // data, data
#define DESKFLOW_MSG_INPUT_FIRST DESKFLOW_MSG_KEY
#define DESKFLOW_MSG_INPUT_LAST DESKFLOW_MSG_PRE_WARP
#define DESKFLOW_HOOK_LAST_MSG DESKFLOW_MSG_DEBUG
#define DESKFLOW_HOOK_FAKE_INPUT_VIRTUAL_KEY VK_CANCEL
#define DESKFLOW_HOOK_FAKE_INPUT_SCANCODE 0
extern "C"
{
enum EHookResult
{
kHOOK_FAILED,
kHOOK_OKAY,
kHOOK_OKAY_LL
};
enum EHookMode
{
kHOOK_DISABLE,
kHOOK_WATCH_JUMP_ZONE,
kHOOK_RELAY_EVENTS
};
}
| 2,335
|
C++
|
.h
| 62
| 35.66129
| 73
| 0.741935
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,950
|
XWindowsUtil.h
|
deskflow_deskflow/src/lib/platform/XWindowsUtil.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/EventTypes.h"
#include "base/String.h"
#include "common/stdmap.h"
#include "common/stdvector.h"
#if X_DISPLAY_MISSING
#error X11 is required to build deskflow
#else
#include <X11/Xlib.h>
#endif
//! X11 utility functions
class XWindowsUtil
{
public:
typedef std::vector<KeySym> KeySyms;
//! Get property
/*!
Gets property \c property on \c window. \b Appends the data to
\c *data if \c data is not NULL, saves the property type in \c *type
if \c type is not NULL, and saves the property format in \c *format
if \c format is not NULL. If \c deleteProperty is true then the
property is deleted after being read.
*/
static bool getWindowProperty(
Display *, Window window, Atom property, String *data, Atom *type, SInt32 *format, bool deleteProperty
);
//! Set property
/*!
Sets property \c property on \c window to \c size bytes of data from
\c data.
*/
static bool
setWindowProperty(Display *, Window window, Atom property, const void *data, UInt32 size, Atom type, SInt32 format);
//! Get X server time
/*!
Returns the current X server time.
*/
static Time getCurrentTime(Display *, Window);
//! Convert KeySym to KeyID
/*!
Converts a KeySym to the equivalent KeyID. Returns kKeyNone if the
KeySym cannot be mapped.
*/
static UInt32 mapKeySymToKeyID(KeySym);
//! Convert KeySym to corresponding KeyModifierMask
/*!
Converts a KeySym to the corresponding KeyModifierMask, or 0 if the
KeySym is not a modifier.
*/
static UInt32 getModifierBitForKeySym(KeySym keysym);
//! Convert Atom to its string
/*!
Converts \p atom to its string representation.
*/
static String atomToString(Display *, Atom atom);
//! Convert several Atoms to a string
/*!
Converts each atom in \p atoms to its string representation and
concatenates the results.
*/
static String atomsToString(Display *display, const Atom *atom, UInt32 num);
//! Prepare a property of atoms for use
/*!
64-bit systems may need to modify a property's data if it's a
list of Atoms before using it.
*/
static void convertAtomProperty(String &data);
//! Append an Atom to property data
/*!
Converts \p atom to a 32-bit on-the-wire format and appends it to
\p data.
*/
static void appendAtomData(String &data, Atom atom);
//! Replace an Atom in property data
/*!
Converts \p atom to a 32-bit on-the-wire format and replaces the atom
at index \p index in \p data.
*/
static void replaceAtomData(String &data, UInt32 index, Atom atom);
//! Append an Time to property data
/*!
Converts \p time to a 32-bit on-the-wire format and appends it to
\p data.
*/
static void appendTimeData(String &data, Time time);
//! X11 error handler
/*!
This class sets an X error handler in the c'tor and restores the
previous error handler in the d'tor. A lock should only be
installed while the display is locked by the thread.
ErrorLock() ignores errors
ErrorLock(bool* flag) sets *flag to true if any error occurs
*/
class ErrorLock
{
public:
//! Error handler type
typedef void (*ErrorHandler)(Display *, XErrorEvent *, void *userData);
/*!
Ignore X11 errors.
*/
ErrorLock(Display *);
ErrorLock(ErrorLock const &) = delete;
ErrorLock(ErrorLock &&) = delete;
ErrorLock &operator=(ErrorLock const &) = delete;
ErrorLock &operator=(ErrorLock &&) = delete;
/*!
Set \c *errorFlag if any error occurs.
*/
ErrorLock(Display *, bool *errorFlag);
/*!
Call \c handler on each error.
*/
ErrorLock(Display *, ErrorHandler handler, void *userData);
~ErrorLock();
private:
void install(ErrorHandler, void *);
static int internalHandler(Display *, XErrorEvent *);
static void ignoreHandler(Display *, XErrorEvent *, void *);
static void saveHandler(Display *, XErrorEvent *, void *);
private:
typedef int (*XErrorHandler)(Display *, XErrorEvent *);
Display *m_display;
ErrorHandler m_handler;
void *m_userData;
XErrorHandler m_oldXHandler;
ErrorLock *m_next;
static ErrorLock *s_top;
};
private:
class PropertyNotifyPredicateInfo
{
public:
Window m_window;
Atom m_property;
};
static Bool propertyNotifyPredicate(Display *, XEvent *xevent, XPointer arg);
static void initKeyMaps();
private:
typedef std::map<KeySym, UInt32> KeySymMap;
static KeySymMap s_keySymToUCS4;
};
| 5,197
|
C++
|
.h
| 159
| 29.396226
| 118
| 0.721046
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,951
|
MSWindowsDesks.h
|
deskflow_deskflow/src/lib/platform/MSWindowsDesks.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/String.h"
#include "common/stdmap.h"
#include "deskflow/key_types.h"
#include "deskflow/mouse_types.h"
#include "deskflow/option_types.h"
#include "mt/CondVar.h"
#include "mt/Mutex.h"
#include "platform/dfwhook.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
class Event;
class EventQueueTimer;
class Thread;
class IJob;
class IScreenSaver;
class IEventQueue;
//! Microsoft Windows desk handling
/*!
Desks in Microsoft Windows are only remotely like desktops on X11
systems. A desk is another virtual surface for windows but desks
impose serious restrictions: a thread can interact with only one
desk at a time, you can't switch desks if the thread has any hooks
installed or owns any windows, windows cannot exist on multiple
desks at once, etc. Basically, they're useless except for running
the login window or the screensaver, which is what they're used
for. Deskflow must deal with them mainly because of the login
window and screensaver but users can create their own desks and
deskflow should work on those too.
This class encapsulates all the desk nastiness. Clients of this
object don't have to know anything about desks.
*/
class MSWindowsDesks
{
public:
//! Constructor
/*!
\p isPrimary is true iff the desk is for a primary screen.
\p screensaver points to a screensaver object and it's used
only to check if the screensaver is active. The \p updateKeys
job is adopted and is called when the key state should be
updated in a thread attached to the current desk.
\p hookLibrary must be a handle to the hook library.
*/
MSWindowsDesks(
bool isPrimary, bool noHooks, const IScreenSaver *screensaver, IEventQueue *events, IJob *updateKeys,
bool stopOnDeskSwitch
);
~MSWindowsDesks();
//! @name manipulators
//@{
//! Enable desk tracking
/*!
Enables desk tracking. While enabled, this object checks to see
if the desk has changed and ensures that the hooks are installed
on the new desk. \c setShape should be called at least once
before calling \c enable.
*/
void enable();
//! Disable desk tracking
/*!
Disables desk tracking. \sa enable.
*/
void disable();
//! Notify of entering a desk
/*!
Prepares a desk for when the cursor enters it.
*/
void enter();
//! Notify of leaving a desk
/*!
Prepares a desk for when the cursor leaves it.
*/
void leave(HKL keyLayout);
//! Notify of options changes
/*!
Resets all options to their default values.
*/
void resetOptions();
//! Notify of options changes
/*!
Set options to given values. Ignores unknown options and doesn't
modify options that aren't given in \c options.
*/
void setOptions(const OptionsList &options);
//! Update the key state
/*!
Causes the key state to get updated to reflect the physical keyboard
state and current keyboard mapping.
*/
void updateKeys();
//! Tell desk about new size
/*!
This tells the desks that the display size has changed.
*/
void setShape(SInt32 x, SInt32 y, SInt32 width, SInt32 height, SInt32 xCenter, SInt32 yCenter, bool isMultimon);
//! Install/uninstall screensaver hooks
/*!
If \p install is true then the screensaver hooks are installed and,
if desk tracking is enabled, updated whenever the desk changes. If
\p install is false then the screensaver hooks are uninstalled.
*/
void installScreensaverHooks(bool install);
//! Start ignoring user input
/*!
Starts ignoring user input so we don't pick up our own synthesized events.
*/
void fakeInputBegin();
//! Stop ignoring user input
/*!
Undoes whatever \c fakeInputBegin() did.
*/
void fakeInputEnd();
//@}
//! @name accessors
//@{
//! Get cursor position
/*!
Return the current position of the cursor in \c x and \c y.
*/
void getCursorPos(SInt32 &x, SInt32 &y) const;
//! Fake key press/release
/*!
Synthesize a press or release of key \c button.
*/
void fakeKeyEvent(WORD virtualKey, WORD scanCode, DWORD flags, bool isAutoRepeat) const;
//! Fake mouse press/release
/*!
Synthesize a press or release of mouse button \c id.
*/
void fakeMouseButton(ButtonID id, bool press);
//! Fake mouse move
/*!
Synthesize a mouse move to the absolute coordinates \c x,y.
*/
void fakeMouseMove(SInt32 x, SInt32 y) const;
//! Fake mouse move
/*!
Synthesize a mouse move to the relative coordinates \c dx,dy.
*/
void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const;
//! Fake mouse wheel
/*!
Synthesize a mouse wheel event of amount \c delta in direction \c axis.
*/
void fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const;
//@}
private:
class Desk
{
public:
String m_name;
Thread *m_thread;
DWORD m_threadID;
DWORD m_targetID;
HDESK m_desk;
HWND m_window;
HWND m_foregroundWindow;
bool m_lowLevel;
};
typedef std::map<String, Desk *> Desks;
// initialization and shutdown operations
HCURSOR createBlankCursor() const;
void destroyCursor(HCURSOR cursor) const;
ATOM createDeskWindowClass(bool isPrimary) const;
void destroyClass(ATOM windowClass) const;
HWND createWindow(ATOM windowClass, const char *name) const;
void destroyWindow(HWND) const;
// message handlers
void deskMouseMove(SInt32 x, SInt32 y) const;
void deskMouseRelativeMove(SInt32 dx, SInt32 dy) const;
void deskEnter(Desk *desk);
void deskLeave(Desk *desk, HKL keyLayout);
void deskThread(void *vdesk);
// desk switch checking and handling
Desk *addDesk(const String &name, HDESK hdesk);
void removeDesks();
void checkDesk();
bool isDeskAccessible(const Desk *desk) const;
void handleCheckDesk(const Event &event, void *);
// communication with desk threads
void waitForDesk() const;
void sendMessage(UINT, WPARAM, LPARAM) const;
// work around for messed up keyboard events from low-level hooks
HWND getForegroundWindow() const;
// desk API wrappers
HDESK openInputDesktop();
void closeDesktop(HDESK);
String getDesktopName(HDESK);
// our desk window procs
static LRESULT CALLBACK primaryDeskProc(HWND, UINT, WPARAM, LPARAM);
static LRESULT CALLBACK secondaryDeskProc(HWND, UINT, WPARAM, LPARAM);
private:
// true if screen is being used as a primary screen, false otherwise
bool m_isPrimary;
// true if hooks are not to be installed (useful for debugging)
bool m_noHooks;
// true if mouse has entered the screen
bool m_isOnScreen;
// our resources
ATOM m_deskClass;
HCURSOR m_cursor;
// screen shape stuff
SInt32 m_x, m_y;
SInt32 m_w, m_h;
SInt32 m_xCenter, m_yCenter;
// true if system appears to have multiple monitors
bool m_multimon;
// the timer used to check for desktop switching
EventQueueTimer *m_timer;
// screen saver stuff
DWORD m_threadID;
const IScreenSaver *m_screensaver;
bool m_screensaverNotify;
// the current desk and it's name
Desk *m_activeDesk;
String m_activeDeskName;
// one desk per desktop and a cond var to communicate with it
Mutex m_mutex;
CondVar<bool> m_deskReady;
Desks m_desks;
// keyboard stuff
IJob *m_updateKeys;
HKL m_keyLayout;
// options
bool m_leaveForegroundOption;
IEventQueue *m_events;
// true if program should stop on desk switch.
bool m_stopOnDeskSwitch;
};
| 8,045
|
C++
|
.h
| 247
| 29.659919
| 114
| 0.744258
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,952
|
OSXClipboard.h
|
deskflow_deskflow/src/lib/platform/OSXClipboard.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "deskflow/IClipboard.h"
#include <Carbon/Carbon.h>
#include <vector>
class IOSXClipboardConverter;
//! OS X clipboard implementation
class OSXClipboard : public IClipboard
{
public:
OSXClipboard();
virtual ~OSXClipboard();
//! Test if clipboard is owned by deskflow
static bool isOwnedByDeskflow();
// IClipboard overrides
virtual bool empty();
virtual void add(EFormat, const String &data);
virtual bool open(Time) const;
virtual void close() const;
virtual Time getTime() const;
virtual bool has(EFormat) const;
virtual String get(EFormat) const;
bool synchronize();
private:
void clearConverters();
private:
typedef std::vector<IOSXClipboardConverter *> ConverterList;
mutable Time m_time;
ConverterList m_converters;
PasteboardRef m_pboard;
};
//! Clipboard format converter interface
/*!
This interface defines the methods common to all Scrap book format
*/
class IOSXClipboardConverter : public IInterface
{
public:
//! @name accessors
//@{
//! Get clipboard format
/*!
Return the clipboard format this object converts from/to.
*/
virtual IClipboard::EFormat getFormat() const = 0;
//! returns the scrap flavor type that this object converts from/to
virtual CFStringRef getOSXFormat() const = 0;
//! Convert from IClipboard format
/*!
Convert from the IClipboard format to the Carbon scrap format.
The input data must be in the IClipboard format returned by
getFormat(). The return data will be in the scrap
format returned by getOSXFormat().
*/
virtual String fromIClipboard(const String &) const = 0;
//! Convert to IClipboard format
/*!
Convert from the carbon scrap format to the IClipboard format
(i.e., the reverse of fromIClipboard()).
*/
virtual String toIClipboard(const String &) const = 0;
//@}
};
| 2,569
|
C++
|
.h
| 79
| 30.037975
| 72
| 0.758188
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,953
|
OSXKeyState.h
|
deskflow_deskflow/src/lib/platform/OSXKeyState.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "OSXAutoTypes.h"
#include "common/stdmap.h"
#include "common/stdset.h"
#include "common/stdvector.h"
#include "deskflow/KeyState.h"
#include <Carbon/Carbon.h>
class IOSXKeyResource;
//! OS X key state
/*!
A key state for OS X.
*/
class OSXKeyState : public KeyState
{
public:
typedef std::vector<KeyID> KeyIDs;
OSXKeyState(IEventQueue *events, std::vector<String> layouts, bool isLangSyncEnabled);
OSXKeyState(IEventQueue *events, deskflow::KeyMap &keyMap, std::vector<String> layouts, bool isLangSyncEnabled);
virtual ~OSXKeyState();
//! @name modifiers
//@{
//! Handle modifier key change
/*!
Determines which modifier keys have changed and updates the modifier
state and sends key events as appropriate.
*/
void handleModifierKeys(void *target, KeyModifierMask oldMask, KeyModifierMask newMask);
//@}
//! @name accessors
//@{
//! Convert OS X modifier mask to deskflow mask
/*!
Returns the deskflow modifier mask corresponding to the OS X modifier
mask in \p mask.
*/
KeyModifierMask mapModifiersFromOSX(UInt32 mask) const;
//! Convert CG flags-style modifier mask to old-style Carbon
/*!
Still required in a few places for translation calls.
*/
KeyModifierMask mapModifiersToCarbon(UInt32 mask) const;
//! Map key event to keys
/*!
Converts a key event into a sequence of KeyIDs and the shadow modifier
state to a modifier mask. The KeyIDs list, in order, the characters
generated by the key press/release. It returns the id of the button
that was pressed or released, or 0 if the button doesn't map to a known
KeyID.
*/
KeyButton mapKeyFromEvent(KeyIDs &ids, KeyModifierMask *maskOut, CGEventRef event) const;
//! Map key and mask to native values
/*!
Calculates mac virtual key and mask for a key \p key and modifiers
\p mask. Returns \c true if the key can be mapped, \c false otherwise.
*/
bool mapDeskflowHotKeyToMac(KeyID key, KeyModifierMask mask, UInt32 &macVirtualKey, UInt32 &macModifierMask) const;
//@}
// IKeyState overrides
virtual bool fakeCtrlAltDel();
virtual bool fakeMediaKey(KeyID id);
virtual KeyModifierMask pollActiveModifiers() const;
virtual SInt32 pollActiveGroup() const;
virtual void pollPressedKeys(KeyButtonSet &pressedKeys) const;
CGEventFlags getModifierStateAsOSXFlags() const;
protected:
// KeyState overrides
virtual void getKeyMap(deskflow::KeyMap &keyMap);
virtual void fakeKey(const Keystroke &keystroke);
private:
class KeyResource;
// Add hard coded special keys to a deskflow::KeyMap.
void getKeyMapForSpecialKeys(deskflow::KeyMap &keyMap, SInt32 group) const;
// Convert keyboard resource to a key map
bool getKeyMap(deskflow::KeyMap &keyMap, SInt32 group, const IOSXKeyResource &r) const;
// Get the available keyboard groups
bool getGroups(AutoCFArray &) const;
// Change active keyboard group to group
void setGroup(SInt32 group);
// Send an event for the given modifier key
void handleModifierKey(void *target, UInt32 virtualKey, KeyID id, bool down, KeyModifierMask newMask);
// Checks if any in \p ids is a glyph key and if \p isCommand is false.
// If so it adds the AltGr modifier to \p mask. This allows OS X
// servers to use the option key both as AltGr and as a modifier. If
// option is acting as AltGr (i.e. it generates a glyph and there are
// no command modifiers active) then we don't send the super modifier
// to clients because they'd try to match it as a command modifier.
void adjustAltGrModifier(const KeyIDs &ids, KeyModifierMask *mask, bool isCommand) const;
// Maps an OS X virtual key id to a KeyButton. This simply remaps
// the ids so we don't use KeyButton 0.
static KeyButton mapVirtualKeyToKeyButton(UInt32 keyCode);
// Maps a KeyButton to an OS X key code. This is the inverse of
// mapVirtualKeyToKeyButton.
static UInt32 mapKeyButtonToVirtualKey(KeyButton keyButton);
void init();
// Post a key event to HID manager. It posts an event to HID client, a
// much lower level than window manager which's the target from carbon
// CGEventPost
kern_return_t postHIDVirtualKey(UInt8 virtualKeyCode, bool postDown);
// Get keyboard event flags accorfing to keyboard modifiers
CGEventFlags getKeyboardEventFlags() const;
CGEventFlags getDeviceDependedFlags() const;
void setKeyboardModifiers(CGKeyCode virtualKey, bool keyDown);
void postKeyboardKey(CGKeyCode virtualKey, bool keyDown);
private:
// OS X uses a physical key if 0 for the 'A' key. deskflow reserves
// KeyButton 0 so we offset all OS X physical key ids by this much
// when used as a KeyButton and by minus this much to map a KeyButton
// to a physical button.
enum
{
KeyButtonOffset = 1
};
typedef std::map<CFDataRef, SInt32> GroupMap;
typedef std::map<UInt32, KeyID> VirtualKeyMap;
VirtualKeyMap m_virtualKeyMap;
mutable UInt32 m_deadKeyState;
AutoCFArray m_groups{nullptr, CFRelease};
GroupMap m_groupMap;
bool m_shiftPressed;
bool m_controlPressed;
bool m_altPressed;
bool m_superPressed;
bool m_capsPressed;
};
| 5,860
|
C++
|
.h
| 141
| 38.702128
| 117
| 0.763764
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,954
|
MSWindowsClipboard.h
|
deskflow_deskflow/src/lib/platform/MSWindowsClipboard.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common/stdvector.h"
#include "deskflow/IClipboard.h"
#include "platform/MSWindowsClipboardFacade.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
class IMSWindowsClipboardConverter;
class IMSWindowsClipboardFacade;
//! Microsoft windows clipboard implementation
class MSWindowsClipboard : public IClipboard
{
public:
MSWindowsClipboard(HWND window);
MSWindowsClipboard(HWND window, IMSWindowsClipboardFacade &facade);
virtual ~MSWindowsClipboard();
//! Empty clipboard without ownership
/*!
Take ownership of the clipboard and clear all data from it.
This must be called between a successful open() and close().
Return false if the clipboard ownership could not be taken;
the clipboard should not be emptied in this case. Unlike
empty(), isOwnedByDeskflow() will return false when emptied
this way. This is useful when deskflow wants to put data on
clipboard but pretend (to itself) that some other app did it.
When using empty(), deskflow assumes the data came from the
server and doesn't need to be sent back. emptyUnowned()
makes deskflow send the data to the server.
*/
bool emptyUnowned();
//! Test if clipboard is owned by deskflow
static bool isOwnedByDeskflow();
// IClipboard overrides
virtual bool empty();
virtual void add(EFormat, const String &data);
virtual bool open(Time) const;
virtual void close() const;
virtual Time getTime() const;
virtual bool has(EFormat) const;
virtual String get(EFormat) const;
void setFacade(IMSWindowsClipboardFacade &facade);
private:
void clearConverters();
UINT convertFormatToWin32(EFormat) const;
HANDLE convertTextToWin32(const String &data) const;
String convertTextFromWin32(HANDLE) const;
static UINT getOwnershipFormat();
private:
typedef std::vector<IMSWindowsClipboardConverter *> ConverterList;
HWND m_window;
mutable Time m_time;
ConverterList m_converters;
static UINT s_ownershipFormat;
IMSWindowsClipboardFacade *m_facade;
bool m_deleteFacade;
};
//! Clipboard format converter interface
/*!
This interface defines the methods common to all win32 clipboard format
converters.
*/
class IMSWindowsClipboardConverter : public IInterface
{
public:
// accessors
// return the clipboard format this object converts from/to
virtual IClipboard::EFormat getFormat() const = 0;
// return the atom representing the win32 clipboard format that
// this object converts from/to
virtual UINT getWin32Format() const = 0;
// convert from the IClipboard format to the win32 clipboard format.
// the input data must be in the IClipboard format returned by
// getFormat(). the return data will be in the win32 clipboard
// format returned by getWin32Format(), allocated by GlobalAlloc().
virtual HANDLE fromIClipboard(const String &) const = 0;
// convert from the win32 clipboard format to the IClipboard format
// (i.e., the reverse of fromIClipboard()).
virtual String toIClipboard(HANDLE data) const = 0;
};
| 3,741
|
C++
|
.h
| 95
| 36.873684
| 72
| 0.780259
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,955
|
OSXPowerManager.h
|
deskflow_deskflow/src/lib/platform/OSXPowerManager.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2021 Symless Ltd.
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <IOKit/pwr_mgt/IOPMLib.h>
class OSXPowerManager
{
public:
OSXPowerManager();
~OSXPowerManager();
/**
* @brief Prevents the system from sleep automatically
*/
void disableSleep();
/**
* @brief Enable automatically sleeping
*/
void enableSleep();
OSXPowerManager(const OSXPowerManager &) = delete;
OSXPowerManager &operator=(const OSXPowerManager &) = delete;
private:
// handler for assertion preventing the system from going to sleep
IOPMAssertionID m_sleepPreventionAssertionID = 0;
};
| 1,287
|
C++
|
.h
| 38
| 31.421053
| 72
| 0.756039
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,956
|
XWindowsScreen.h
|
deskflow_deskflow/src/lib/platform/XWindowsScreen.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "arch/Arch.h"
#include "common/stdset.h"
#include "common/stdvector.h"
#include "deskflow/ClientArgs.h"
#include "deskflow/KeyMap.h"
#include "deskflow/PlatformScreen.h"
#include "platform/XWindowsPowerManager.h"
#if X_DISPLAY_MISSING
#error X11 is required to build deskflow
#else
#include <X11/Xlib.h>
#endif
class XWindowsClipboard;
class XWindowsKeyState;
class XWindowsScreenSaver;
//! Implementation of IPlatformScreen for X11
class XWindowsScreen : public PlatformScreen
{
public:
XWindowsScreen(
const char *displayName, bool isPrimary, bool disableXInitThreads, int mouseScrollDelta, IEventQueue *events,
deskflow::ClientScrollDirection m_clientScrollDirection = deskflow::ClientScrollDirection::SERVER
);
virtual ~XWindowsScreen() override;
//! @name manipulators
//@{
//@}
// IScreen overrides
void *getEventTarget() const override;
bool getClipboard(ClipboardID id, IClipboard *) const override;
void getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const override;
void getCursorPos(SInt32 &x, SInt32 &y) const override;
// IPrimaryScreen overrides
void reconfigure(UInt32 activeSides) override;
void warpCursor(SInt32 x, SInt32 y) override;
UInt32 registerHotKey(KeyID key, KeyModifierMask mask) override;
void unregisterHotKey(UInt32 id) override;
void fakeInputBegin() override;
void fakeInputEnd() override;
SInt32 getJumpZoneSize() const override;
bool isAnyMouseButtonDown(UInt32 &buttonID) const override;
void getCursorCenter(SInt32 &x, SInt32 &y) const override;
// ISecondaryScreen overrides
void fakeMouseButton(ButtonID id, bool press) override;
void fakeMouseMove(SInt32 x, SInt32 y) override;
void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const override;
void fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const override;
// IPlatformScreen overrides
void enable() override;
void disable() override;
void enter() override;
bool canLeave() override;
void leave() override;
bool setClipboard(ClipboardID, const IClipboard *) override;
void checkClipboards() override;
void openScreensaver(bool notify) override;
void closeScreensaver() override;
void screensaver(bool activate) override;
void resetOptions() override;
void setOptions(const OptionsList &options) override;
void setSequenceNumber(UInt32) override;
bool isPrimary() const override;
String getSecureInputApp() const override;
protected:
// IPlatformScreen overrides
void handleSystemEvent(const Event &, void *) override;
void updateButtons() override;
IKeyState *getKeyState() const override;
private:
// event sending
void sendEvent(Event::Type, void * = NULL);
void sendClipboardEvent(Event::Type, ClipboardID);
// create the transparent cursor
Cursor createBlankCursor() const;
// determine the clipboard from the X selection. returns
// kClipboardEnd if no such clipboard.
ClipboardID getClipboardID(Atom selection) const;
// continue processing a selection request
void processClipboardRequest(Window window, Time time, Atom property);
// terminate a selection request
void destroyClipboardRequest(Window window);
// X I/O error handler
void onError();
static int ioErrorHandler(Display *);
private:
class KeyEventFilter
{
public:
int m_event;
Window m_window;
Time m_time;
KeyCode m_keycode;
};
Display *openDisplay(const char *displayName);
void saveShape();
void setShape(SInt32 width, SInt32 height);
Window openWindow() const;
void openIM();
bool grabMouseAndKeyboard();
void onKeyPress(XKeyEvent &);
void onKeyRelease(XKeyEvent &, bool isRepeat);
bool onHotKey(XKeyEvent &, bool isRepeat);
void onMousePress(const XButtonEvent &);
void onMouseRelease(const XButtonEvent &);
void onMouseMove(const XMotionEvent &);
bool detectXI2();
#ifdef HAVE_XI2
void selectXIRawMotion();
#endif
void selectEvents(Window) const;
void doSelectEvents(Window) const;
KeyID mapKeyFromX(XKeyEvent *) const;
ButtonID mapButtonFromX(const XButtonEvent *) const;
unsigned int mapButtonToX(ButtonID id) const;
void warpCursorNoFlush(SInt32 x, SInt32 y);
void refreshKeyboard(XEvent *);
static Bool findKeyEvent(Display *, XEvent *xevent, XPointer arg);
private:
struct HotKeyItem
{
public:
HotKeyItem(int, unsigned int);
bool operator<(const HotKeyItem &) const;
private:
int m_keycode;
unsigned int m_mask;
};
typedef std::set<bool> FilteredKeycodes;
typedef std::vector<std::pair<int, unsigned int>> HotKeyList;
typedef std::map<UInt32, HotKeyList> HotKeyMap;
typedef std::vector<UInt32> HotKeyIDList;
typedef std::map<HotKeyItem, UInt32> HotKeyToIDMap;
// true if screen is being used as a primary screen, false otherwise
bool m_isPrimary;
int m_mouseScrollDelta;
Display *m_display;
Window m_root;
Window m_window;
// true if mouse has entered the screen
bool m_isOnScreen;
// screen shape stuff
SInt32 m_x, m_y;
SInt32 m_w, m_h;
SInt32 m_xCenter, m_yCenter;
// last mouse position
SInt32 m_xCursor, m_yCursor;
// keyboard stuff
XWindowsKeyState *m_keyState;
// hot key stuff
HotKeyMap m_hotKeys;
HotKeyIDList m_oldHotKeyIDs;
HotKeyToIDMap m_hotKeyToIDMap;
// input focus stuff
Window m_lastFocus;
int m_lastFocusRevert;
// input method stuff
XIM m_im;
XIC m_ic;
KeyCode m_lastKeycode;
FilteredKeycodes m_filtered;
// clipboards
XWindowsClipboard *m_clipboard[kClipboardEnd];
UInt32 m_sequenceNumber;
// screen saver stuff
XWindowsScreenSaver *m_screensaver;
bool m_screensaverNotify;
// logical to physical button mapping. m_buttons[i] gives the
// physical button for logical button i+1.
std::vector<unsigned char> m_buttons;
// true if global auto-repeat was enabled before we turned it off
bool m_autoRepeat;
// stuff to workaround xtest being xinerama unaware. attempting
// to fake a mouse motion under xinerama may behave strangely,
// especially if screen 0 is not at 0,0 or if faking a motion on
// a screen other than screen 0.
bool m_xtestIsXineramaUnaware;
bool m_xinerama;
// stuff to work around lost focus issues on certain systems
// (ie: a MythTV front-end).
bool m_preserveFocus;
// XKB extension stuff
bool m_xkb;
int m_xkbEventBase;
bool m_xi2detected;
// XRandR extension stuff
bool m_xrandr;
int m_xrandrEventBase;
IEventQueue *m_events;
deskflow::KeyMap m_keyMap;
// pointer to (singleton) screen. this is only needed by
// ioErrorHandler().
static XWindowsScreen *s_screen;
XWindowsPowerManager m_powerManager;
};
| 7,398
|
C++
|
.h
| 212
| 31.891509
| 115
| 0.76825
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,957
|
MSWindowsDropTarget.h
|
deskflow_deskflow/src/lib/platform/MSWindowsDropTarget.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <oleidl.h>
class MSWindowsScreen;
class MSWindowsDropTarget : public IDropTarget
{
public:
MSWindowsDropTarget();
~MSWindowsDropTarget();
// IUnknown implementation
HRESULT __stdcall QueryInterface(REFIID iid, void **object);
ULONG __stdcall AddRef(void);
ULONG __stdcall Release(void);
// IDropTarget implementation
HRESULT __stdcall DragEnter(IDataObject *dataObject, DWORD keyState, POINTL point, DWORD *effect);
HRESULT __stdcall DragOver(DWORD keyState, POINTL point, DWORD *effect);
HRESULT __stdcall DragLeave(void);
HRESULT __stdcall Drop(IDataObject *dataObject, DWORD keyState, POINTL point, DWORD *effect);
void setDraggingFilename(char *const);
std::string getDraggingFilename();
void clearDraggingFilename();
static MSWindowsDropTarget &instance();
private:
bool queryDataObject(IDataObject *dataObject);
long m_refCount;
bool m_allowDrop;
std::string m_dragFilename;
static MSWindowsDropTarget *s_instance;
};
| 1,755
|
C++
|
.h
| 47
| 34.93617
| 100
| 0.775486
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,958
|
MSWindowsClipboardBitmapConverter.h
|
deskflow_deskflow/src/lib/platform/MSWindowsClipboardBitmapConverter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/MSWindowsClipboard.h"
//! Convert to/from some text encoding
class MSWindowsClipboardBitmapConverter : public IMSWindowsClipboardConverter
{
public:
MSWindowsClipboardBitmapConverter();
virtual ~MSWindowsClipboardBitmapConverter();
// IMSWindowsClipboardConverter overrides
virtual IClipboard::EFormat getFormat() const;
virtual UINT getWin32Format() const;
virtual HANDLE fromIClipboard(const String &) const;
virtual String toIClipboard(HANDLE) const;
};
| 1,237
|
C++
|
.h
| 31
| 37.806452
| 77
| 0.790349
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,959
|
MSWindowsKeyState.h
|
deskflow_deskflow/src/lib/platform/MSWindowsKeyState.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2003 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/String.h"
#include "common/stdvector.h"
#include "deskflow/KeyState.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
class Event;
class EventQueueTimer;
class MSWindowsDesks;
class IEventQueue;
//! Microsoft Windows key mapper
/*!
This class maps KeyIDs to keystrokes.
*/
class MSWindowsKeyState : public KeyState
{
public:
MSWindowsKeyState(
MSWindowsDesks *desks, void *eventTarget, IEventQueue *events, std::vector<String> layouts, bool isLangSyncEnabled
);
MSWindowsKeyState(
MSWindowsDesks *desks, void *eventTarget, IEventQueue *events, deskflow::KeyMap &keyMap,
std::vector<String> layouts, bool isLangSyncEnabled
);
virtual ~MSWindowsKeyState();
//! @name manipulators
//@{
//! Handle screen disabling
/*!
Called when screen is disabled. This is needed to deal with platform
brokenness.
*/
void disable();
//! Set the active keyboard layout
/*!
Uses \p keyLayout when querying the keyboard.
*/
void setKeyLayout(HKL keyLayout);
//! Test and set autorepeat state
/*!
Returns true if the given button is autorepeating and updates internal
state.
*/
bool testAutoRepeat(bool press, bool isRepeat, KeyButton);
//! Remember modifier state
/*!
Records the current non-toggle modifier state.
*/
void saveModifiers();
//! Set effective modifier state
/*!
Temporarily sets the non-toggle modifier state to those saved by the
last call to \c saveModifiers if \p enable is \c true. Restores the
modifier state to the current modifier state if \p enable is \c false.
This is for synthesizing keystrokes on the primary screen when the
cursor is on a secondary screen. When on a secondary screen we capture
all non-toggle modifier state, track the state internally and do not
pass it on. So if Alt+F1 synthesizes Alt+X we need to synthesize
not just X but also Alt, despite the fact that our internal modifier
state indicates Alt is down, because local apps never saw the Alt down
event.
*/
void useSavedModifiers(bool enable);
//@}
//! @name accessors
//@{
//! Map a virtual key to a button
/*!
Returns the button for the \p virtualKey.
*/
KeyButton virtualKeyToButton(UINT virtualKey) const;
//! Map key event to a key
/*!
Converts a key event into a KeyID and the shadow modifier state
to a modifier mask.
*/
KeyID mapKeyFromEvent(WPARAM charAndVirtKey, LPARAM info, KeyModifierMask *maskOut) const;
//! Check if keyboard groups have changed
/*!
Returns true iff the number or order of the keyboard groups have
changed since the last call to updateKeys().
*/
bool didGroupsChange() const;
//! Map key to virtual key
/*!
Returns the virtual key for key \p key or 0 if there's no such virtual
key.
*/
UINT mapKeyToVirtualKey(KeyID key) const;
//! Map virtual key and button to KeyID
/*!
Returns the KeyID for virtual key \p virtualKey and button \p button
(button should include the extended key bit), or kKeyNone if there is
no such key.
*/
KeyID getKeyID(UINT virtualKey, KeyButton button) const;
//! Map button to virtual key
/*!
Returns the virtual key for button \p button
(button should include the extended key bit), or kKeyNone if there is
no such key.
*/
UINT mapButtonToVirtualKey(KeyButton button) const;
//@}
// IKeyState overrides
virtual void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const String &lang);
virtual bool fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const String &lang);
virtual bool fakeCtrlAltDel();
virtual KeyModifierMask pollActiveModifiers() const;
virtual SInt32 pollActiveGroup() const;
virtual void pollPressedKeys(KeyButtonSet &pressedKeys) const;
// KeyState overrides
virtual void onKey(KeyButton button, bool down, KeyModifierMask newState);
virtual void sendKeyEvent(
void *target, bool press, bool isAutoRepeat, KeyID key, KeyModifierMask mask, SInt32 count, KeyButton button
);
// Unit test accessors
KeyButton getLastDown() const
{
return m_lastDown;
}
void setLastDown(KeyButton value)
{
m_lastDown = value;
}
KeyModifierMask getSavedModifiers() const
{
return m_savedModifiers;
}
void setSavedModifiers(KeyModifierMask value)
{
m_savedModifiers = value;
}
protected:
// KeyState overrides
virtual void getKeyMap(deskflow::KeyMap &keyMap);
virtual void fakeKey(const Keystroke &keystroke);
virtual KeyModifierMask &getActiveModifiersRValue();
private:
typedef std::vector<HKL> GroupList;
// send ctrl+alt+del hotkey event on NT family
static void ctrlAltDelThread(void *);
bool getGroups(GroupList &) const;
void setWindowGroup(SInt32 group);
KeyID getIDForKey(deskflow::KeyMap::KeyItem &item, KeyButton button, UINT virtualKey, PBYTE keyState, HKL hkl) const;
void addKeyEntry(deskflow::KeyMap &keyMap, deskflow::KeyMap::KeyItem &item);
void init();
private:
// not implemented
MSWindowsKeyState(const MSWindowsKeyState &);
MSWindowsKeyState &operator=(const MSWindowsKeyState &);
private:
typedef std::map<HKL, SInt32> GroupMap;
typedef std::map<KeyID, UINT> KeyToVKMap;
void *m_eventTarget;
MSWindowsDesks *m_desks;
HKL m_keyLayout;
UINT m_buttonToVK[512];
UINT m_buttonToNumpadVK[512];
KeyButton m_virtualKeyToButton[256];
KeyToVKMap m_keyToVKMap;
IEventQueue *m_events;
// the timer used to check for fixing key state
EventQueueTimer *m_fixTimer;
// the groups (keyboard layouts)
GroupList m_groups;
GroupMap m_groupMap;
// the last button that we generated a key down event for. this
// is zero if the last key event was a key up. we use this to
// synthesize key repeats since the low level keyboard hook can't
// tell us if an event is a key repeat.
KeyButton m_lastDown;
// modifier tracking
bool m_useSavedModifiers;
KeyModifierMask m_savedModifiers;
KeyModifierMask m_originalSavedModifiers;
// pointer to ToUnicodeEx. on win95 family this will be NULL.
typedef int(WINAPI *ToUnicodeEx_t)(
UINT wVirtKey, UINT wScanCode, PBYTE lpKeyState, LPWSTR pwszBuff, int cchBuff, UINT wFlags, HKL dwhkl
);
ToUnicodeEx_t m_ToUnicodeEx;
static const KeyID s_virtualKey[];
};
| 7,023
|
C++
|
.h
| 200
| 32.095
| 120
| 0.75608
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,960
|
XWindowsClipboardAnyBitmapConverter.h
|
deskflow_deskflow/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/XWindowsClipboard.h"
//! Convert to/from some text encoding
class XWindowsClipboardAnyBitmapConverter : public IXWindowsClipboardConverter
{
public:
XWindowsClipboardAnyBitmapConverter();
virtual ~XWindowsClipboardAnyBitmapConverter();
// IXWindowsClipboardConverter overrides
virtual IClipboard::EFormat getFormat() const;
virtual Atom getAtom() const = 0;
virtual int getDataSize() const;
virtual String fromIClipboard(const String &) const;
virtual String toIClipboard(const String &) const;
protected:
//! Convert from IClipboard format
/*!
Convert raw BGR pixel data to another image format.
*/
virtual String doBGRFromIClipboard(const UInt8 *bgrData, UInt32 w, UInt32 h) const = 0;
//! Convert from IClipboard format
/*!
Convert raw BGRA pixel data to another image format.
*/
virtual String doBGRAFromIClipboard(const UInt8 *bgrData, UInt32 w, UInt32 h) const = 0;
//! Convert to IClipboard format
/*!
Convert an image into raw BGR or BGRA image data and store the
width, height, and image depth (24 or 32).
*/
virtual String doToIClipboard(const String &, UInt32 &w, UInt32 &h, UInt32 &depth) const = 0;
};
| 1,932
|
C++
|
.h
| 49
| 36.979592
| 95
| 0.767058
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,961
|
IMSWindowsClipboardFacade.h
|
deskflow_deskflow/src/lib/platform/IMSWindowsClipboardFacade.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common/IInterface.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
class IMSWindowsClipboardConverter;
class IMSWindowsClipboardFacade : public IInterface
{
public:
virtual void write(HANDLE win32Data, UINT win32Format) = 0;
virtual ~IMSWindowsClipboardFacade()
{
}
};
| 1,038
|
C++
|
.h
| 30
| 32.633333
| 72
| 0.774676
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,962
|
XWindowsEventQueueBuffer.h
|
deskflow_deskflow/src/lib/platform/XWindowsEventQueueBuffer.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/IEventQueueBuffer.h"
#include "common/stdvector.h"
#include "mt/Mutex.h"
#if X_DISPLAY_MISSING
#error X11 is required to build deskflow
#else
#include <X11/Xlib.h>
#endif
class IEventQueue;
//! Event queue buffer for X11
class XWindowsEventQueueBuffer : public IEventQueueBuffer
{
public:
XWindowsEventQueueBuffer(Display *, Window, IEventQueue *events);
XWindowsEventQueueBuffer(XWindowsEventQueueBuffer const &) = delete;
XWindowsEventQueueBuffer(XWindowsEventQueueBuffer &&) = delete;
virtual ~XWindowsEventQueueBuffer();
XWindowsEventQueueBuffer &operator=(XWindowsEventQueueBuffer const &) = delete;
XWindowsEventQueueBuffer &operator=(XWindowsEventQueueBuffer &&) = delete;
// IEventQueueBuffer overrides
virtual void init()
{
}
virtual void waitForEvent(double timeout);
virtual Type getEvent(Event &event, UInt32 &dataID);
virtual bool addEvent(UInt32 dataID);
virtual bool isEmpty() const;
virtual EventQueueTimer *newTimer(double duration, bool oneShot) const;
virtual void deleteTimer(EventQueueTimer *) const;
private:
void flush();
int getPendingCountLocked();
private:
typedef std::vector<XEvent> EventList;
Mutex m_mutex;
Display *m_display;
Window m_window;
Atom m_userEvent;
XEvent m_event;
EventList m_postedEvents;
bool m_waiting;
int m_pipefd[2];
IEventQueue *m_events;
};
| 2,118
|
C++
|
.h
| 62
| 31.822581
| 81
| 0.78044
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,963
|
OSXEventQueueBuffer.h
|
deskflow_deskflow/src/lib/platform/OSXEventQueueBuffer.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/IEventQueueBuffer.h"
#include <Carbon/Carbon.h>
class IEventQueue;
//! Event queue buffer for OS X
class OSXEventQueueBuffer : public IEventQueueBuffer
{
public:
OSXEventQueueBuffer(IEventQueue *eventQueue);
virtual ~OSXEventQueueBuffer();
// IEventQueueBuffer overrides
virtual void init();
virtual void waitForEvent(double timeout);
virtual Type getEvent(Event &event, UInt32 &dataID);
virtual bool addEvent(UInt32 dataID);
virtual bool isEmpty() const;
virtual EventQueueTimer *newTimer(double duration, bool oneShot) const;
virtual void deleteTimer(EventQueueTimer *) const;
private:
EventRef m_event;
IEventQueue *m_eventQueue;
EventQueueRef m_carbonEventQueue;
};
| 1,461
|
C++
|
.h
| 40
| 34.3
| 73
| 0.781471
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| true
| true
| false
| false
| false
| false
| false
| false
|
13,964
|
OSXClipboardBMPConverter.h
|
deskflow_deskflow/src/lib/platform/OSXClipboardBMPConverter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
* Patch by Ryan Chapman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/OSXClipboard.h"
//! Convert to/from some text encoding
class OSXClipboardBMPConverter : public IOSXClipboardConverter
{
public:
OSXClipboardBMPConverter();
virtual ~OSXClipboardBMPConverter();
// IMSWindowsClipboardConverter overrides
virtual IClipboard::EFormat getFormat() const;
virtual CFStringRef getOSXFormat() const;
// OSXClipboardAnyBMPConverter overrides
virtual String fromIClipboard(const String &) const;
virtual String toIClipboard(const String &) const;
// generic encoding converter
static String convertString(const String &data, CFStringEncoding fromEncoding, CFStringEncoding toEncoding);
};
| 1,386
|
C++
|
.h
| 34
| 38.5
| 110
| 0.791078
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| true
| true
| false
| false
| false
| false
| false
| false
|
13,965
|
OSXClipboardTextConverter.h
|
deskflow_deskflow/src/lib/platform/OSXClipboardTextConverter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/OSXClipboardAnyTextConverter.h"
//! Convert to/from locale text encoding
class OSXClipboardTextConverter : public OSXClipboardAnyTextConverter
{
public:
OSXClipboardTextConverter();
virtual ~OSXClipboardTextConverter();
// IOSXClipboardAnyTextConverter overrides
virtual CFStringRef getOSXFormat() const;
protected:
// OSXClipboardAnyTextConverter overrides
virtual String doFromIClipboard(const String &) const;
virtual String doToIClipboard(const String &) const;
// generic encoding converter
static String convertString(const String &data, CFStringEncoding fromEncoding, CFStringEncoding toEncoding);
};
| 1,394
|
C++
|
.h
| 34
| 38.823529
| 110
| 0.796898
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,966
|
XWindowsKeyState.h
|
deskflow_deskflow/src/lib/platform/XWindowsKeyState.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2003 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common/stdmap.h"
#include "common/stdvector.h"
#include "deskflow/KeyState.h"
#if X_DISPLAY_MISSING
#error X11 is required to build deskflow
#else
#include <X11/Xlib.h>
#if HAVE_X11_EXTENSIONS_XTEST_H
#include <X11/extensions/XTest.h>
#else
#error The XTest extension is required to build deskflow
#endif
#if HAVE_XKB_EXTENSION
#include <X11/extensions/XKBstr.h>
#endif
#endif
class IEventQueue;
//! X Windows key state
/*!
A key state for X Windows.
*/
class XWindowsKeyState : public KeyState
{
public:
typedef std::vector<int> KeycodeList;
enum
{
kGroupPoll = -1,
kGroupPollAndSet = -2
};
XWindowsKeyState(Display *, bool useXKB, IEventQueue *events);
XWindowsKeyState(Display *, bool useXKB, IEventQueue *events, deskflow::KeyMap &keyMap);
~XWindowsKeyState();
//! @name modifiers
//@{
//! Set active group
/*!
Sets the active group to \p group. This is the group returned by
\c pollActiveGroup(). If \p group is \c kGroupPoll then
\c pollActiveGroup() will really poll, but that's a slow operation
on X11. If \p group is \c kGroupPollAndSet then this will poll the
active group now and use it for future calls to \c pollActiveGroup().
*/
void setActiveGroup(SInt32 group);
//! Set the auto-repeat state
/*!
Sets the auto-repeat state.
*/
void setAutoRepeat(const XKeyboardState &);
//@}
//! @name accessors
//@{
//! Convert X modifier mask to deskflow mask
/*!
Returns the deskflow modifier mask corresponding to the X modifier
mask in \p state.
*/
KeyModifierMask mapModifiersFromX(unsigned int state) const;
//! Convert deskflow modifier mask to X mask
/*!
Converts the deskflow modifier mask to the corresponding X modifier
mask. Returns \c true if successful and \c false if any modifier
could not be converted.
*/
bool mapModifiersToX(KeyModifierMask, unsigned int &) const;
//! Convert deskflow key to all corresponding X keycodes
/*!
Converts the deskflow key \p key to all of the keycodes that map to
that key.
*/
void mapKeyToKeycodes(KeyID key, KeycodeList &keycodes) const;
//@}
// IKeyState overrides
virtual bool fakeCtrlAltDel();
virtual KeyModifierMask pollActiveModifiers() const;
virtual SInt32 pollActiveGroup() const;
virtual void pollPressedKeys(KeyButtonSet &pressedKeys) const;
protected:
// KeyState overrides
virtual void getKeyMap(deskflow::KeyMap &keyMap);
virtual void fakeKey(const Keystroke &keystroke);
private:
void init(Display *display, bool useXKB);
void updateKeysymMap(deskflow::KeyMap &);
void updateKeysymMapXKB(deskflow::KeyMap &);
bool hasModifiersXKB() const;
int getEffectiveGroup(KeyCode, int group) const;
UInt32 getGroupFromState(unsigned int state) const;
//! Create and send language change request to \p group by DBus interface
/*!
Returns the existance of nedeed DBus interface.
*/
bool setCurrentLanguageWithDBus(SInt32 group) const;
static void remapKeyModifiers(KeyID, SInt32, deskflow::KeyMap::KeyItem &, void *);
private:
struct XKBModifierInfo
{
public:
unsigned char m_level;
UInt32 m_mask;
bool m_lock;
};
#ifdef TEST_ENV
public: // yuck
#endif
typedef std::vector<KeyModifierMask> KeyModifierMaskList;
private:
typedef std::map<KeyModifierMask, unsigned int> KeyModifierToXMask;
typedef std::multimap<KeyID, KeyCode> KeyToKeyCodeMap;
typedef std::map<KeyCode, unsigned int> NonXKBModifierMap;
typedef std::map<UInt32, XKBModifierInfo> XKBModifierMap;
Display *m_display;
#if HAVE_XKB_EXTENSION
XkbDescPtr m_xkb;
#endif
SInt32 m_group;
XKBModifierMap m_lastGoodXKBModifiers;
NonXKBModifierMap m_lastGoodNonXKBModifiers;
// X modifier (bit number) to deskflow modifier (mask) mapping
KeyModifierMaskList m_modifierFromX;
// deskflow modifier (mask) to X modifier (mask)
KeyModifierToXMask m_modifierToX;
// map KeyID to all keycodes that can synthesize that KeyID
KeyToKeyCodeMap m_keyCodeFromKey;
// autorepeat state
XKeyboardState m_keyboardState;
#ifdef TEST_ENV
public:
SInt32 group() const
{
return m_group;
}
void group(const SInt32 &group)
{
m_group = group;
}
KeyModifierMaskList modifierFromX() const
{
return m_modifierFromX;
}
#endif
};
| 5,020
|
C++
|
.h
| 160
| 28.6875
| 90
| 0.759313
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,967
|
MSWindowsScreen.h
|
deskflow_deskflow/src/lib/platform/MSWindowsScreen.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/String.h"
#include "deskflow/ClientArgs.h"
#include "deskflow/DragInformation.h"
#include "deskflow/PlatformScreen.h"
#include "mt/CondVar.h"
#include "mt/Mutex.h"
#include "platform/MSWindowsHook.h"
#include "platform/MSWindowsPowerManager.h"
#include "platform/dfwhook.h"
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
class EventQueueTimer;
class MSWindowsDesks;
class MSWindowsKeyState;
class MSWindowsScreenSaver;
class Thread;
class MSWindowsDropTarget;
//! Implementation of IPlatformScreen for Microsoft Windows
class MSWindowsScreen : public PlatformScreen
{
public:
MSWindowsScreen(
bool isPrimary, bool noHooks, bool stopOnDeskSwitch, IEventQueue *events, bool enableLangSync = false,
deskflow::ClientScrollDirection scrollDirection = deskflow::ClientScrollDirection::SERVER
);
virtual ~MSWindowsScreen();
//! @name manipulators
//@{
//! Initialize
/*!
Saves the application's HINSTANCE. This \b must be called by
WinMain with the HINSTANCE it was passed.
*/
static void init(HINSTANCE);
//@}
//! @name accessors
//@{
//! Get instance
/*!
Returns the application instance handle passed to init().
*/
static HINSTANCE getWindowInstance();
//@}
// IScreen overrides
virtual void *getEventTarget() const;
virtual bool getClipboard(ClipboardID id, IClipboard *) const;
virtual void getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const;
virtual void getCursorPos(SInt32 &x, SInt32 &y) const;
/**
* \brief Get the position of the cursor on the current machine
* \param pos the object that the function will use to store the position of
* the cursor \return true if the function was successful
*/
virtual bool getThisCursorPos(LPPOINT pos);
/**
* \brief Sets the cursor position on the current machine
* \param x The x coordinate of the cursor
* \param y The Y coordinate of the cursor
* \return True is successful
*/
virtual bool setThisCursorPos(int x, int y);
/**
* \brief This function will attempt to switch to the current desktop the
* mouse is located on
*/
virtual void updateDesktopThread();
// IPrimaryScreen overrides
virtual void reconfigure(UInt32 activeSides);
virtual void warpCursor(SInt32 x, SInt32 y);
virtual UInt32 registerHotKey(KeyID key, KeyModifierMask mask);
virtual void unregisterHotKey(UInt32 id);
virtual void fakeInputBegin();
virtual void fakeInputEnd();
virtual SInt32 getJumpZoneSize() const;
virtual bool isAnyMouseButtonDown(UInt32 &buttonID) const;
virtual void getCursorCenter(SInt32 &x, SInt32 &y) const;
// ISecondaryScreen overrides
virtual void fakeMouseButton(ButtonID id, bool press);
virtual void fakeMouseMove(SInt32 x, SInt32 y);
virtual void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const;
virtual void fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const;
// IKeyState overrides
virtual void updateKeys();
virtual void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const String &lang);
virtual bool fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const String &lang);
virtual bool fakeKeyUp(KeyButton button);
virtual void fakeAllKeysUp();
// IPlatformScreen overrides
virtual void enable();
virtual void disable();
virtual void enter();
virtual bool canLeave();
virtual void leave();
virtual bool setClipboard(ClipboardID, const IClipboard *);
virtual void checkClipboards();
virtual void openScreensaver(bool notify);
virtual void closeScreensaver();
virtual void screensaver(bool activate);
virtual void resetOptions();
virtual void setOptions(const OptionsList &options);
virtual void setSequenceNumber(UInt32);
virtual bool isPrimary() const;
virtual void fakeDraggingFiles(DragFileList fileList);
virtual String &getDraggingFilename();
virtual const String &getDropTarget() const;
String getSecureInputApp() const override;
protected:
// IPlatformScreen overrides
virtual void handleSystemEvent(const Event &, void *);
virtual void updateButtons();
virtual IKeyState *getKeyState() const;
// simulate a local key to the system directly
void fakeLocalKey(KeyButton button, bool press) const;
private:
// initialization and shutdown operations
HCURSOR createBlankCursor() const;
void destroyCursor(HCURSOR cursor) const;
ATOM createWindowClass() const;
ATOM createDeskWindowClass(bool isPrimary) const;
void destroyClass(ATOM windowClass) const;
HWND createWindow(ATOM windowClass, const char *name) const;
HWND createDropWindow(ATOM windowClass, const char *name) const;
void destroyWindow(HWND) const;
// convenience function to send events
public: // HACK
void sendEvent(Event::Type type, void * = NULL);
private: // HACK
void sendClipboardEvent(Event::Type type, ClipboardID id);
// handle message before it gets dispatched. returns true iff
// the message should not be dispatched.
bool onPreDispatch(HWND, UINT, WPARAM, LPARAM);
// handle message before it gets dispatched. returns true iff
// the message should not be dispatched.
bool onPreDispatchPrimary(HWND, UINT, WPARAM, LPARAM);
// handle secondary message before it gets dispatched. returns true iff
// the message should not be dispatched.
bool onPreDispatchSecondary(HWND, UINT, WPARAM, LPARAM);
// handle message. returns true iff handled and optionally sets
// \c *result (which defaults to 0).
bool onEvent(HWND, UINT, WPARAM, LPARAM, LRESULT *result);
// message handlers
bool onMark(UInt32 mark);
bool onKey(WPARAM, LPARAM);
bool onHotKey(WPARAM, LPARAM);
bool onMouseButton(WPARAM, LPARAM);
bool onMouseMove(SInt32 x, SInt32 y);
bool onMouseWheel(SInt32 xDelta, SInt32 yDelta);
bool onScreensaver(bool activated);
bool onDisplayChange();
bool onClipboardChange();
// warp cursor without discarding queued events
void warpCursorNoFlush(SInt32 x, SInt32 y);
// discard posted messages
void nextMark();
// test if event should be ignored
bool ignore() const;
// update screen size cache
void updateScreenShape();
// fix timer callback
void handleFixes(const Event &, void *);
// fix the clipboard viewer chain
void fixClipboardViewer();
// enable/disable special key combinations so we can catch/pass them
void enableSpecialKeys(bool) const;
// map a button event to a button ID
ButtonID mapButtonFromEvent(WPARAM msg, LPARAM button) const;
// map a button event to a press (true) or release (false)
bool mapPressFromEvent(WPARAM msg, LPARAM button) const;
// job to update the key state
void updateKeysCB(void *);
// determine whether the mouse is hidden by the system and force
// it to be displayed if user has entered this secondary screen.
void forceShowCursor();
// forceShowCursor uses MouseKeys to show the cursor. since we
// don't actually want MouseKeys behavior we have to make sure
// it applies when NumLock is in whatever state it's not in now.
// this method does that.
void updateForceShowCursor();
// our window proc
static LRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM);
// save last position of mouse to compute next delta movement
void saveMousePosition(SInt32 x, SInt32 y);
// check if it is a modifier key repeating message
bool isModifierRepeat(KeyModifierMask oldState, KeyModifierMask state, WPARAM wParam) const;
// send drag info and data back to server
void sendDragThread(void *);
private:
struct HotKeyItem
{
public:
HotKeyItem(UINT vk, UINT modifiers);
UINT getVirtualKey() const;
bool operator<(const HotKeyItem &) const;
private:
UINT m_keycode;
UINT m_mask;
};
typedef std::map<UInt32, HotKeyItem> HotKeyMap;
typedef std::vector<UInt32> HotKeyIDList;
typedef std::map<HotKeyItem, UInt32> HotKeyToIDMap;
typedef std::vector<KeyButton> PrimaryKeyDownList;
static HINSTANCE s_windowInstance;
// true if screen is being used as a primary screen, false otherwise
bool m_isPrimary;
// true if hooks are not to be installed (useful for debugging)
bool m_noHooks;
// true if mouse has entered the screen
bool m_isOnScreen;
// our resources
ATOM m_class;
// screen shape stuff
SInt32 m_x, m_y;
SInt32 m_w, m_h;
SInt32 m_xCenter, m_yCenter;
// true if system appears to have multiple monitors
bool m_multimon;
// last mouse position
SInt32 m_xCursor, m_yCursor;
// last clipboard
UInt32 m_sequenceNumber;
// used to discard queued messages that are no longer needed
UInt32 m_mark;
UInt32 m_markReceived;
// the main loop's thread id
DWORD m_threadID;
// timer for periodically checking stuff that requires polling
EventQueueTimer *m_fixTimer;
// the keyboard layout to use when off primary screen
HKL m_keyLayout;
// screen saver stuff
MSWindowsScreenSaver *m_screensaver;
bool m_screensaverNotify;
bool m_screensaverActive;
// clipboard stuff. our window is used mainly as a clipboard
// owner and as a link in the clipboard viewer chain.
HWND m_window;
HWND m_nextClipboardWindow;
bool m_ownClipboard;
// one desk per desktop and a cond var to communicate with it
MSWindowsDesks *m_desks;
// keyboard stuff
MSWindowsKeyState *m_keyState;
// hot key stuff
HotKeyMap m_hotKeys;
HotKeyIDList m_oldHotKeyIDs;
HotKeyToIDMap m_hotKeyToIDMap;
// map of button state
bool m_buttons[1 + kButtonExtra0 + 1];
// the system shows the mouse cursor when an internal display count
// is >= 0. this count is maintained per application but there's
// apparently a system wide count added to the application's count.
// this system count is 0 if there's a mouse attached to the system
// and -1 otherwise. the MouseKeys accessibility feature can modify
// this system count by making the system appear to have a mouse.
//
// m_hasMouse is true iff there's a mouse attached to the system or
// MouseKeys is simulating one. we track this so we can force the
// cursor to be displayed when the user has entered this screen.
// m_showingMouse is true when we're doing that.
bool m_hasMouse;
bool m_showingMouse;
bool m_gotOldMouseKeys;
MOUSEKEYS m_mouseKeys;
MOUSEKEYS m_oldMouseKeys;
MSWindowsHook m_hook;
static MSWindowsScreen *s_screen;
IEventQueue *m_events;
String m_desktopPath;
MSWindowsDropTarget *m_dropTarget;
HWND m_dropWindow;
const int m_dropWindowSize;
Thread *m_sendDragThread;
PrimaryKeyDownList m_primaryKeyDownList;
MSWindowsPowerManager m_powerManager;
};
| 11,345
|
C++
|
.h
| 293
| 35.617747
| 113
| 0.764802
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,968
|
MSWindowsClipboardTextConverter.h
|
deskflow_deskflow/src/lib/platform/MSWindowsClipboardTextConverter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/MSWindowsClipboardAnyTextConverter.h"
//! Convert to/from locale text encoding
class MSWindowsClipboardTextConverter : public MSWindowsClipboardAnyTextConverter
{
public:
MSWindowsClipboardTextConverter();
virtual ~MSWindowsClipboardTextConverter();
// IMSWindowsClipboardConverter overrides
virtual UINT getWin32Format() const;
protected:
// MSWindowsClipboardAnyTextConverter overrides
virtual String doFromIClipboard(const String &) const;
virtual String doToIClipboard(const String &) const;
};
| 1,280
|
C++
|
.h
| 32
| 37.90625
| 81
| 0.797265
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,969
|
OSXPasteboardPeeker.h
|
deskflow_deskflow/src/lib/platform/OSXPasteboardPeeker.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2013-2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common/common.h"
#import <CoreFoundation/CoreFoundation.h>
#if defined(__cplusplus)
extern "C"
{
#endif
CFStringRef getDraggedFileURL();
#if defined(__cplusplus)
}
#endif
| 893
|
C++
|
.h
| 27
| 31.222222
| 72
| 0.766279
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| true
| true
| false
| false
| false
| false
| false
| false
|
13,970
|
MSWindowsClipboardUTF16Converter.h
|
deskflow_deskflow/src/lib/platform/MSWindowsClipboardUTF16Converter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/MSWindowsClipboardAnyTextConverter.h"
//! Convert to/from UTF-16 encoding
class MSWindowsClipboardUTF16Converter : public MSWindowsClipboardAnyTextConverter
{
public:
MSWindowsClipboardUTF16Converter();
virtual ~MSWindowsClipboardUTF16Converter();
// IMSWindowsClipboardConverter overrides
virtual UINT getWin32Format() const;
protected:
// MSWindowsClipboardAnyTextConverter overrides
virtual String doFromIClipboard(const String &) const;
virtual String doToIClipboard(const String &) const;
};
| 1,278
|
C++
|
.h
| 32
| 37.84375
| 82
| 0.796938
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,971
|
MSWindowsClipboardHTMLConverter.h
|
deskflow_deskflow/src/lib/platform/MSWindowsClipboardHTMLConverter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/MSWindowsClipboardAnyTextConverter.h"
//! Convert to/from HTML encoding
class MSWindowsClipboardHTMLConverter : public MSWindowsClipboardAnyTextConverter
{
public:
MSWindowsClipboardHTMLConverter();
virtual ~MSWindowsClipboardHTMLConverter();
// IMSWindowsClipboardConverter overrides
virtual IClipboard::EFormat getFormat() const;
virtual UINT getWin32Format() const;
protected:
// MSWindowsClipboardAnyTextConverter overrides
virtual String doFromIClipboard(const String &) const;
virtual String doToIClipboard(const String &) const;
private:
String findArg(const String &data, const String &name) const;
private:
UINT m_format;
};
| 1,423
|
C++
|
.h
| 37
| 36.297297
| 81
| 0.794779
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| true
| true
| false
| false
| false
| false
| false
| false
|
13,972
|
OSXClipboardHTMLConverter.h
|
deskflow_deskflow/src/lib/platform/OSXClipboardHTMLConverter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
* Patch by Ryan Chapman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "OSXClipboardAnyTextConverter.h"
//! Convert to/from HTML encoding
class OSXClipboardHTMLConverter : public OSXClipboardAnyTextConverter
{
public:
OSXClipboardHTMLConverter();
virtual ~OSXClipboardHTMLConverter();
// IMSWindowsClipboardConverter overrides
virtual IClipboard::EFormat getFormat() const;
virtual CFStringRef getOSXFormat() const;
protected:
// OSXClipboardAnyTextConverter overrides
virtual String doFromIClipboard(const String &) const;
virtual String doToIClipboard(const String &) const;
// generic encoding converter
static String convertString(const String &data, CFStringEncoding fromEncoding, CFStringEncoding toEncoding);
};
| 1,413
|
C++
|
.h
| 35
| 38.142857
| 110
| 0.79577
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| true
| true
| false
| false
| false
| false
| false
| false
|
13,973
|
OSXClipboardUTF16Converter.h
|
deskflow_deskflow/src/lib/platform/OSXClipboardUTF16Converter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/OSXClipboardAnyTextConverter.h"
//! Convert to/from UTF-16 encoding
class OSXClipboardUTF16Converter : public OSXClipboardAnyTextConverter
{
public:
OSXClipboardUTF16Converter();
virtual ~OSXClipboardUTF16Converter();
// IOSXClipboardAnyTextConverter overrides
virtual CFStringRef getOSXFormat() const;
protected:
// OSXClipboardAnyTextConverter overrides
virtual String doFromIClipboard(const String &) const;
virtual String doToIClipboard(const String &) const;
};
| 1,248
|
C++
|
.h
| 32
| 36.90625
| 72
| 0.791908
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| true
| true
| false
| false
| false
| false
| false
| false
|
13,974
|
XWindowsClipboardUTF8Converter.h
|
deskflow_deskflow/src/lib/platform/XWindowsClipboardUTF8Converter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "platform/XWindowsClipboard.h"
//! Convert to/from UTF-8 encoding
class XWindowsClipboardUTF8Converter : public IXWindowsClipboardConverter
{
public:
/*!
\c name is converted to an atom and that is reported by getAtom().
*/
XWindowsClipboardUTF8Converter(Display *display, const char *name, bool normalize = false);
virtual ~XWindowsClipboardUTF8Converter();
// IXWindowsClipboardConverter overrides
virtual IClipboard::EFormat getFormat() const;
virtual Atom getAtom() const;
virtual int getDataSize() const;
virtual String fromIClipboard(const String &) const;
virtual String toIClipboard(const String &) const;
private:
Atom m_atom;
bool m_normalize;
};
| 1,440
|
C++
|
.h
| 38
| 35.657895
| 93
| 0.775233
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| true
| false
| false
| false
| false
| false
| false
|
13,975
|
StreamFilter.h
|
deskflow_deskflow/src/lib/io/StreamFilter.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/IEventQueue.h"
#include "io/IStream.h"
//! A stream filter
/*!
This class wraps a stream. Subclasses provide indirect access
to the wrapped stream, typically performing some filtering.
*/
class StreamFilter : public deskflow::IStream
{
public:
/*!
Create a wrapper around \c stream. Iff \c adoptStream is true then
this object takes ownership of the stream and will delete it in the
d'tor.
*/
StreamFilter(IEventQueue *events, deskflow::IStream *stream, bool adoptStream = true);
StreamFilter(StreamFilter const &) = delete;
StreamFilter(StreamFilter &&) = delete;
virtual ~StreamFilter();
StreamFilter &operator=(StreamFilter const &) = delete;
StreamFilter &operator=(StreamFilter &&) = delete;
// IStream overrides
// These all just forward to the underlying stream except getEventTarget.
// Override as necessary. getEventTarget returns a pointer to this.
virtual void close();
virtual UInt32 read(void *buffer, UInt32 n);
virtual void write(const void *buffer, UInt32 n);
virtual void flush();
virtual void shutdownInput();
virtual void shutdownOutput();
virtual void *getEventTarget() const;
virtual bool isReady() const;
virtual UInt32 getSize() const;
//! Get the stream
/*!
Returns the stream passed to the c'tor.
*/
deskflow::IStream *getStream() const;
protected:
//! Handle events from source stream
/*!
Does the event filtering. The default simply dispatches an event
identical except using this object as the event target.
*/
virtual void filterEvent(const Event &);
private:
void handleUpstreamEvent(const Event &, void *);
private:
deskflow::IStream *m_stream;
bool m_adopted;
IEventQueue *m_events;
};
| 2,466
|
C++
|
.h
| 70
| 32.785714
| 88
| 0.754504
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,977
|
XIO.h
|
deskflow_deskflow/src/lib/io/XIO.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/XBase.h"
//! Generic I/O exception
XBASE_SUBCLASS(XIO, XBase);
//! I/O closing exception
/*!
Thrown if a stream cannot be closed.
*/
XBASE_SUBCLASS(XIOClose, XIO);
//! I/O already closed exception
/*!
Thrown when attempting to close or perform I/O on an already closed.
stream.
*/
XBASE_SUBCLASS_WHAT(XIOClosed, XIO);
//! I/O end of stream exception
/*!
Thrown when attempting to read beyond the end of a stream.
*/
XBASE_SUBCLASS_WHAT(XIOEndOfStream, XIO);
//! I/O would block exception
/*!
Thrown if an operation on a stream would block.
*/
XBASE_SUBCLASS_WHAT(XIOWouldBlock, XIO);
| 1,349
|
C++
|
.h
| 42
| 30.571429
| 72
| 0.76
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| true
| true
| false
| false
| false
| false
| false
| false
|
13,978
|
StreamBuffer.h
|
deskflow_deskflow/src/lib/io/StreamBuffer.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "base/EventTypes.h"
#include "common/stdlist.h"
#include "common/stdvector.h"
//! FIFO of bytes
/*!
This class maintains a FIFO (first-in, last-out) buffer of bytes.
*/
class StreamBuffer
{
public:
StreamBuffer();
~StreamBuffer();
//! @name manipulators
//@{
//! Read data without removing from buffer
/*!
Return a pointer to memory with the next \c n bytes in the buffer
(which must be <= getSize()). The caller must not modify the returned
memory nor delete it.
*/
const void *peek(UInt32 n);
//! Discard data
/*!
Discards the next \c n bytes. If \c n >= getSize() then the buffer
is cleared.
*/
void pop(UInt32 n);
//! Write data to buffer
/*!
Appends \c n bytes from \c data to the buffer.
*/
void write(const void *data, UInt32 n);
//@}
//! @name accessors
//@{
//! Get size of buffer
/*!
Returns the number of bytes in the buffer.
*/
UInt32 getSize() const;
//@}
private:
static const UInt32 kChunkSize;
typedef std::vector<UInt8> Chunk;
typedef std::list<Chunk> ChunkList;
ChunkList m_chunks;
UInt32 m_size;
UInt32 m_headUsed;
};
| 1,878
|
C++
|
.h
| 67
| 25.492537
| 72
| 0.714127
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,979
|
OSXHelpers.h
|
deskflow_deskflow/src/lib/gui/OSXHelpers.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2015 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QString>
enum class IconsTheme
{
ICONS_DARK,
ICONS_LIGHT,
ICONS_TEMPLATE
};
void requestOSXNotificationPermission();
bool isOSXDevelopmentBuild();
bool showOSXNotification(const QString &title, const QString &body);
bool isOSXInterfaceStyleDark();
IconsTheme getOSXIconsTheme();
| 998
|
C++
|
.h
| 29
| 32.551724
| 72
| 0.781347
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,980
|
style_utils.h
|
deskflow_deskflow/src/lib/gui/style_utils.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2024 Symless
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QGuiApplication>
#include <QPalette>
#include <QStyleHints>
namespace deskflow::gui {
/**
* @brief Detects dark mode in a universal manner (all Qt versions).
* Until better platform support is added, it's more reliable to use the old way (compare text and window lightness),
* because the newer versions in Qt 6.5+ are not always correct and some return `UnknownScheme`.
* https://www.qt.io/blog/dark-mode-on-windows-11-with-qt-6.5
*/
inline bool isDarkMode()
{
const QPalette defaultPalette;
const auto text = defaultPalette.color(QPalette::WindowText);
const auto window = defaultPalette.color(QPalette::Window);
return text.lightness() > window.lightness();
}
} // namespace deskflow::gui
| 1,414
|
C++
|
.h
| 35
| 38.457143
| 117
| 0.763464
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,981
|
diagnostic.h
|
deskflow_deskflow/src/lib/gui/diagnostic.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2024 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "gui/config/ConfigScopes.h"
namespace deskflow::gui::diagnostic {
void clearSettings(ConfigScopes &scopes, bool enableRestart);
}
| 843
|
C++
|
.h
| 21
| 38.190476
| 72
| 0.771114
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,982
|
Logger.h
|
deskflow_deskflow/src/lib/gui/Logger.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2024 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QObject>
#ifdef NDEBUG
const bool kDebug = false;
#else
const bool kDebug = true;
#endif
namespace deskflow::gui {
class Logger : public QObject
{
Q_OBJECT
public:
static Logger &instance()
{
return s_instance;
}
void loadEnvVars();
void handleMessage(const QtMsgType type, const QString &fileLine, const QString &message);
void logVerbose(const QString &message) const;
signals:
void newLine(const QString &line);
private:
static Logger s_instance;
bool m_debug = kDebug;
bool m_verbose = false;
};
inline void logVerbose(const QString &message)
{
Logger::instance().logVerbose(message);
}
} // namespace deskflow::gui
| 1,368
|
C++
|
.h
| 47
| 26.957447
| 92
| 0.760305
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,983
|
string_utils.h
|
deskflow_deskflow/src/lib/gui/string_utils.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2024 Symless
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QString>
/**
* @brief Useful for environment variables that have string boolean values.
*/
inline bool strToTrue(const QString &str)
{
return str.toLower() == "true" || str == "1";
}
inline QString trimEnd(const QString &str)
{
QString result = str;
while (!result.isEmpty() && result.at(result.size() - 1).isSpace()) {
result.chop(1);
}
return result;
}
| 1,079
|
C++
|
.h
| 33
| 30.636364
| 75
| 0.736084
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,984
|
VersionChecker.h
|
deskflow_deskflow/src/lib/gui/VersionChecker.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2012 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "proxy/QNetworkAccessManagerProxy.h"
#include <QObject>
#include <QString>
#include <memory>
class QNetworkAccessManager;
class QNetworkReply;
class VersionCheckerTests;
class VersionChecker : public QObject
{
using QNetworkAccessManagerProxy = deskflow::gui::proxy::QNetworkAccessManagerProxy;
Q_OBJECT
friend class VersionCheckerTests;
public:
explicit VersionChecker(std::shared_ptr<QNetworkAccessManagerProxy> network = nullptr);
void checkLatest() const;
public slots:
void replyFinished(QNetworkReply *reply);
signals:
void updateFound(const QString &version);
private:
static int compareVersions(const QString &left, const QString &right);
/**
* \brief Converts a string stage to a integer value
* \param stage The string containing the stage version
* \return An integer representation of the stage, the higher the number the
* more recent the version
*/
static int getStageVersion(QString stage);
std::shared_ptr<QNetworkAccessManagerProxy> m_network;
};
| 1,720
|
C++
|
.h
| 47
| 34.255319
| 89
| 0.7858
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,985
|
constants.h
|
deskflow_deskflow/src/lib/gui/constants.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2024 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QString>
namespace deskflow::gui {
// important: this is used for settings paths on some platforms,
// and must not be a url. qt automatically converts this to reverse domain
// notation (rdn), e.g. org.deskflow
const auto kOrgDomain = QStringLiteral("deskflow.org");
const auto kLinkDownload = R"(<a href="%1" style="color: %2">Download now</a>)";
const auto kUrlSourceQuery = "source=gui";
const auto kUrlApp = QStringLiteral("https://deskflow.org");
const auto kUrlHelp = QString("%1/help?%2").arg(kUrlApp, kUrlSourceQuery);
const auto kUrlDownload = QString("%1/download?%2").arg(kUrlApp, kUrlSourceQuery);
#if defined(Q_OS_LINUX)
const auto kUrlGnomeTrayFix = "https://extensions.gnome.org/extension/2890/tray-icons-reloaded/";
#endif
} // namespace deskflow::gui
| 1,486
|
C++
|
.h
| 32
| 44.71875
| 97
| 0.759336
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,986
|
byte_utils.h
|
deskflow_deskflow/src/lib/gui/byte_utils.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2024 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QByteArray>
#include <QDataStream>
#include <QIODevice>
#include <QtGlobal>
namespace deskflow::gui {
inline int bytesToInt(const char *buffer, size_t size)
{
QByteArray byteArray(buffer, static_cast<int>(size));
QDataStream stream(byteArray);
int result;
stream >> result;
return result;
}
inline QByteArray intToBytes(int value)
{
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
stream << value;
return bytes;
}
} // namespace deskflow::gui
| 1,196
|
C++
|
.h
| 38
| 29.447368
| 72
| 0.763889
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,987
|
paths.h
|
deskflow_deskflow/src/lib/gui/paths.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2024 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common/constants.h"
#include "core/CoreTool.h"
#include <QDir>
#include <QStandardPaths>
#include <QString>
// TODO: Reduce duplication of these strings between here and SecureSocket.cpp
const auto kCertificateFilename = QStringLiteral("%1.pem").arg(kAppId);
const auto kSslDir = "tls";
namespace deskflow::gui::paths {
/**
* @brief Gets the org config dir (parent of app config dir).
*/
inline QDir configDir(const bool persist = false)
{
const QDir configDir(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation));
// HACK: since we have the org name set to the app name, the config dir is
// confusing. make this simple by using the org dir instead.
// use `filePath("..")` instead of `cdUp` to avoid the existence check.
const QDir orgDir = configDir.filePath("..");
if (persist) {
const auto orgDirPath = orgDir.absolutePath();
if (!QDir().mkpath(orgDirPath)) {
qFatal("failed to persist config dir: %s", qPrintable(orgDirPath));
}
}
return orgDir.absolutePath();
}
/**
* @brief Uses the Core tool to get the profile dir.
*/
inline QDir coreProfileDir()
{
CoreTool coreTool;
return QDir(coreTool.getProfileDir());
}
inline QString defaultTlsCertPath()
{
const auto root = coreProfileDir();
const auto sslDirPath = QDir(root.filePath(kSslDir));
return sslDirPath.filePath(kCertificateFilename);
}
} // namespace deskflow::gui::paths
| 2,120
|
C++
|
.h
| 59
| 33.661017
| 92
| 0.749634
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,988
|
messages.h
|
deskflow_deskflow/src/lib/gui/messages.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2024 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QMessageLogContext>
#include <QString>
class QWidget;
namespace deskflow::gui::messages {
enum class ClientError
{
AlreadyConnected,
HostnameError,
GenericError
};
enum class NewClientPromptResult
{
Add,
Ignore
};
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
void raiseCriticalDialog();
void showFirstServerStartMessage(QWidget *parent);
void showFirstConnectedMessage(QWidget *parent, bool closeToTray, bool enableService, bool isServer);
void showCloseReminder(QWidget *parent);
void showClientConnectError(QWidget *parent, ClientError error, const QString &address);
NewClientPromptResult showNewClientPrompt(QWidget *parent, const QString &clientName);
bool showClearSettings(QWidget *parent);
void showReadOnlySettings(QWidget *parent, const QString &systemSettingsPath);
void showWaylandLibraryError(QWidget *parent);
bool showUpdateCheckOption(QWidget *parent);
} // namespace deskflow::gui::messages
| 1,692
|
C++
|
.h
| 44
| 36.477273
| 101
| 0.807975
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
13,989
|
env_vars.h
|
deskflow_deskflow/src/lib/gui/env_vars.h
|
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2024 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QString>
namespace deskflow::gui::env_vars {
inline QString versionUrl()
{
return qEnvironmentVariable("DESKFLOW_VERSION_URL", QStringLiteral("https://api.deskflow.org/version"));
}
} // namespace deskflow::gui::env_vars
| 937
|
C++
|
.h
| 24
| 37.125
| 106
| 0.764317
|
deskflow/deskflow
| 10,364
| 3,653
| 93
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.