Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ include_directories(./src)

# gui library autogen headers:
# qt doesn't seem to auto include the autogen headers for libraries.
# single-config generators (Make) use include/, multi-config (VS) use include_$<CONFIG>/
include_directories(${PROJECT_BINARY_DIR}/src/lib/gui/gui_autogen/include)
include_directories(${PROJECT_BINARY_DIR}/src/lib/gui/gui_autogen/include_$<CONFIG>)
Comment on lines +44 to +46
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why this change was needed. Maybe it should be a separate PR?


# generated includes
include_directories(${PROJECT_BINARY_DIR}/config)
Expand Down
10 changes: 9 additions & 1 deletion src/gui/src/ServerConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ bool ServerConfig::operator==(const ServerConfig &sc) const
m_SwitchCornerSize == sc.m_SwitchCornerSize && m_SwitchCorners == sc.m_SwitchCorners &&
m_Hotkeys == sc.m_Hotkeys && m_pAppConfig == sc.m_pAppConfig &&
m_DisableLockToScreen == sc.m_DisableLockToScreen && m_ClipboardSharing == sc.m_ClipboardSharing &&
m_ClipboardSharingSize == sc.m_ClipboardSharingSize && m_pMainWindow == sc.m_pMainWindow;
m_ClipboardSharingSize == sc.m_ClipboardSharingSize && m_TouchActivateScreen == sc.m_TouchActivateScreen &&
m_pMainWindow == sc.m_pMainWindow;
}

void ServerConfig::save(QFile &file) const
Expand Down Expand Up @@ -127,6 +128,7 @@ void ServerConfig::commit()
settings().setValue("disableLockToScreen", disableLockToScreen());
settings().setValue("clipboardSharing", clipboardSharing());
settings().setValue("clipboardSharingSize", QVariant::fromValue(clipboardSharingSize()));
settings().setValue("touchActivateScreen", touchActivateScreen());

if (!getClientAddress().isEmpty()) {
settings().setValue("clientAddress", getClientAddress());
Expand Down Expand Up @@ -182,6 +184,9 @@ void ServerConfig::recall()
settings().value("clipboardSharingSize", (int)ServerConfig::defaultClipboardSharingSize()).toULongLong()
);
setClipboardSharing(settings().value("clipboardSharing", true).toBool());
setTouchActivateScreen(
settings().value("touchActivateScreen",
settings().value("touchInputLocal", false)).toBool());
setClientAddress(settings().value("clientAddress", "").toString());

readSettings(settings(), switchCorners(), "switchCorner", 0, static_cast<int>(NumSwitchCorners));
Expand Down Expand Up @@ -310,6 +315,9 @@ QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config)
outStream << "\t"
<< "switchCornerSize = " << config.switchCornerSize() << Qt::endl;

outStream << "\t"
<< "touchActivateScreen = " << (config.touchActivateScreen() ? "true" : "false") << Qt::endl;

foreach (const Hotkey &hotkey, config.hotkeys())
outStream << hotkey;

Expand Down
9 changes: 9 additions & 0 deletions src/gui/src/ServerConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ class ServerConfig : public ScreenConfig, public deskflow::gui::IServerConfig
{
return m_ClipboardSharingSize;
}
bool touchActivateScreen() const
{
return m_TouchActivateScreen;
}
static size_t defaultClipboardSharingSize();

//
Expand Down Expand Up @@ -224,6 +228,10 @@ class ServerConfig : public ScreenConfig, public deskflow::gui::IServerConfig
{
m_ClipboardSharing = on;
}
void setTouchActivateScreen(bool on)
{
m_TouchActivateScreen = on;
}
void setConfigFile(const QString &configFile);
void setUseExternalConfig(bool useExternalConfig);
size_t setClipboardSharingSize(size_t size);
Expand Down Expand Up @@ -253,6 +261,7 @@ class ServerConfig : public ScreenConfig, public deskflow::gui::IServerConfig
int m_SwitchCornerSize = 0;
bool m_DisableLockToScreen = false;
bool m_ClipboardSharing = true;
bool m_TouchActivateScreen = false;
QString m_ClientAddress = "";
QList<bool> m_SwitchCorners;
HotkeyList m_Hotkeys;
Expand Down
9 changes: 9 additions & 0 deletions src/gui/src/ServerConfigDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, Ap
m_pCheckBoxCornerBottomRight->setChecked(serverConfig().switchCorner(static_cast<int>(BottomRight)));
m_pSpinBoxSwitchCornerSize->setValue(serverConfig().switchCornerSize());
m_pCheckBoxDisableLockToScreen->setChecked(serverConfig().disableLockToScreen());
m_pCheckBoxTouchActivateScreen->setChecked(serverConfig().touchActivateScreen());

m_pCheckBoxEnableClipboard->setChecked(serverConfig().clipboardSharing());
int clipboardSharingSizeM = static_cast<int>(serverConfig().clipboardSharingSize() / 1024);
Expand Down Expand Up @@ -142,6 +143,10 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, Ap
serverConfig().setDisableLockToScreen(v);
onChange();
});
connect(m_pCheckBoxTouchActivateScreen, &QCheckBox::stateChanged, this, [this](const int &v) {
serverConfig().setTouchActivateScreen(v);
onChange();
});
connect(m_pCheckBoxCornerTopLeft, &QCheckBox::stateChanged, this, [this](const int &v) {
serverConfig().setSwitchCorner(static_cast<int>(TopLeft), v);
onChange();
Expand Down Expand Up @@ -192,6 +197,10 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, Ap
serverConfig().setDisableLockToScreen(v == Qt::Checked);
onChange();
});
connect(m_pCheckBoxTouchActivateScreen, &QCheckBox::checkStateChanged, this, [this](const Qt::CheckState &v) {
serverConfig().setTouchActivateScreen(v == Qt::Checked);
onChange();
});
connect(m_pCheckBoxCornerTopLeft, &QCheckBox::checkStateChanged, this, [this](const Qt::CheckState &v) {
serverConfig().setSwitchCorner(static_cast<int>(TopLeft), v == Qt::Checked);
onChange();
Expand Down
11 changes: 11 additions & 0 deletions src/gui/src/ServerConfigDialogBase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,16 @@
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="m_pCheckBoxTouchActivateScreen">
<property name="text">
<string>Switch screens on touch</string>
</property>
<property name="toolTip">
<string>Touch any screen to switch to that computer</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="m_pCheckBoxWin32KeepForeground">
<property name="enabled">
Expand Down Expand Up @@ -1168,6 +1178,7 @@ Enabling this setting will disable the server config GUI.</string>
<tabstop>m_pCheckBoxWin32KeepForeground</tabstop>
<tabstop>m_pCheckBoxIgnoreAutoConfigClient</tabstop>
<tabstop>m_pCheckBoxDisableLockToScreen</tabstop>
<tabstop>m_pCheckBoxTouchActivateScreen</tabstop>
<tabstop>m_pCheckBoxCornerTopLeft</tabstop>
<tabstop>m_pCheckBoxCornerBottomLeft</tabstop>
<tabstop>m_pCheckBoxCornerTopRight</tabstop>
Expand Down
3 changes: 3 additions & 0 deletions src/lib/base/EventTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ REGISTER_EVENT(ClientListener, connected)

REGISTER_EVENT(ClientProxy, ready)
REGISTER_EVENT(ClientProxy, disconnected)
REGISTER_EVENT(ClientProxy, grabScreen)

//
// ClientProxyUnknown
Expand Down Expand Up @@ -167,6 +168,7 @@ REGISTER_EVENT(IPrimaryScreen, hotKeyDown)
REGISTER_EVENT(IPrimaryScreen, hotKeyUp)
REGISTER_EVENT(IPrimaryScreen, fakeInputBegin)
REGISTER_EVENT(IPrimaryScreen, fakeInputEnd)
REGISTER_EVENT(IPrimaryScreen, touchActivatedPrimary)

//
// IScreen
Expand All @@ -176,6 +178,7 @@ REGISTER_EVENT(IScreen, error)
REGISTER_EVENT(IScreen, shapeChanged)
REGISTER_EVENT(IScreen, suspend)
REGISTER_EVENT(IScreen, resume)
REGISTER_EVENT(IScreen, grabScreen)

//
// IpcServer
Expand Down
34 changes: 31 additions & 3 deletions src/lib/base/EventTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ class ClientListenerEvents : public EventTypes
class ClientProxyEvents : public EventTypes
{
public:
ClientProxyEvents() : m_ready(Event::kUnknown), m_disconnected(Event::kUnknown)
ClientProxyEvents() : m_ready(Event::kUnknown), m_disconnected(Event::kUnknown), m_grabScreen(Event::kUnknown)
{
}

Expand All @@ -410,11 +410,20 @@ class ClientProxyEvents : public EventTypes
*/
Event::Type disconnected();

//! Get grab screen event type
/*!
Returns the grab screen event type. This is sent when a client
requests to become the active screen (e.g., due to touch input).
Event data is MotionInfo* with the position where activation occurred.
*/
Event::Type grabScreen();

//@}

private:
Event::Type m_ready;
Event::Type m_disconnected;
Event::Type m_grabScreen;
};

class ClientProxyUnknownEvents : public EventTypes
Expand Down Expand Up @@ -603,7 +612,8 @@ class IPrimaryScreenEvents : public EventTypes
m_hotKeyDown(Event::kUnknown),
m_hotKeyUp(Event::kUnknown),
m_fakeInputBegin(Event::kUnknown),
m_fakeInputEnd(Event::kUnknown)
m_fakeInputEnd(Event::kUnknown),
m_touchActivatedPrimary(Event::kUnknown)
{
}

Expand Down Expand Up @@ -650,6 +660,13 @@ class IPrimaryScreenEvents : public EventTypes
//! end of fake input event type
Event::Type fakeInputEnd();

//! touch activated primary screen event type
/*!
Event data is MotionInfo* with the position where touch occurred.
This is sent when touch input on the primary screen should activate it.
*/
Event::Type touchActivatedPrimary();

//@}

private:
Expand All @@ -664,6 +681,7 @@ class IPrimaryScreenEvents : public EventTypes
Event::Type m_hotKeyUp;
Event::Type m_fakeInputBegin;
Event::Type m_fakeInputEnd;
Event::Type m_touchActivatedPrimary;
};

class IScreenEvents : public EventTypes
Expand All @@ -673,7 +691,8 @@ class IScreenEvents : public EventTypes
: m_error(Event::kUnknown),
m_shapeChanged(Event::kUnknown),
m_suspend(Event::kUnknown),
m_resume(Event::kUnknown)
m_resume(Event::kUnknown),
m_grabScreen(Event::kUnknown)
{
}

Expand Down Expand Up @@ -708,13 +727,22 @@ class IScreenEvents : public EventTypes
*/
Event::Type resume();

//! Get grab screen event type
/*!
Returns the grab screen event type. This is sent when a secondary screen
requests to become the active screen (e.g., due to touch input).
Event data is MotionInfo* with the position where activation occurred.
*/
Event::Type grabScreen();

//@}

private:
Event::Type m_error;
Event::Type m_shapeChanged;
Event::Type m_suspend;
Event::Type m_resume;
Event::Type m_grabScreen;
};

class ClipboardEvents : public EventTypes
Expand Down
19 changes: 18 additions & 1 deletion src/lib/client/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "deskflow/DropHelper.h"
#include "deskflow/FileChunk.h"
#include "deskflow/IPlatformScreen.h"
#include "deskflow/IPrimaryScreen.h"
#include "deskflow/PacketStreamFilter.h"
#include "deskflow/ProtocolUtil.h"
#include "deskflow/Screen.h"
Expand Down Expand Up @@ -87,6 +88,10 @@ Client::Client(
m_events->adoptHandler(
m_events->forIScreen().resume(), getEventTarget(), new TMethodEventJob<Client>(this, &Client::handleResume)
);
m_events->adoptHandler(
m_events->forIScreen().grabScreen(), m_screen->getEventTarget(),
new TMethodEventJob<Client>(this, &Client::handleGrabScreen)
);

if (m_args.m_enableDragDrop) {
m_events->adoptHandler(
Expand All @@ -107,6 +112,7 @@ Client::~Client()

m_events->removeHandler(m_events->forIScreen().suspend(), getEventTarget());
m_events->removeHandler(m_events->forIScreen().resume(), getEventTarget());
m_events->removeHandler(m_events->forIScreen().grabScreen(), m_screen->getEventTarget());

cleanupTimer();
cleanupScreen();
Expand Down Expand Up @@ -655,7 +661,8 @@ bool Client::isCompatible(int major, int minor) const
{
const std::map<int, std::set<int>> compatibleTable{
{6, {7, 8}}, // 1.6 is compatible with 1.7 and 1.8
{7, {8}} // 1.7 is compatible with 1.8
{7, {8}}, // 1.7 is compatible with 1.8
{8, {9}} // 1.8 is compatible with 1.9 (touch-to-switch unavailable)
};
Comment on lines 662 to 666
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This table has been removed upstream, as it doesn't make sense. I wonder if it's pointless modifying it.


bool isCompatible = false;
Expand Down Expand Up @@ -737,6 +744,16 @@ void Client::handleResume(const Event &, void *)
}
}

void Client::handleGrabScreen(const Event &event, void *)
{
// Forward grab screen request to server via protocol
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment doesn't explain why -- is it redundant?

IPrimaryScreen::MotionInfo *info = static_cast<IPrimaryScreen::MotionInfo *>(event.getData());
if (m_server != NULL) {
LOG((CLOG_DEBUG1 "requesting screen grab at %d,%d", info->m_x, info->m_y));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LOG((CLOG_DEBUG1 "requesting screen grab at %d,%d", info->m_x, info->m_y));
LOG((CLOG_DEBUG1 "requesting grab input at %d,%d", info->m_x, info->m_y));

m_server->grabScreen(info->m_x, info->m_y);
}
}

void Client::handleFileChunkSending(const Event &event, void *)
{
sendFileChunk(event.getDataObject());
Expand Down
1 change: 1 addition & 0 deletions src/lib/client/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ class Client : public IClient, public INode
void handleHello(const Event &, void *);
void handleSuspend(const Event &event, void *);
void handleResume(const Event &event, void *);
void handleGrabScreen(const Event &event, void *);
void handleFileChunkSending(const Event &, void *);
void handleFileRecieveCompleted(const Event &, void *);
void handleStopRetry(const Event &, void *);
Expand Down
6 changes: 6 additions & 0 deletions src/lib/client/ServerProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@ bool ServerProxy::onGrabClipboard(ClipboardID id)
return true;
}

void ServerProxy::grabScreen(SInt32 x, SInt32 y)
{
LOG((CLOG_DEBUG1 "requesting screen grab at %d,%d", x, y));
ProtocolUtil::writef(m_stream, kMsgCGrabScreen, x, y);
}

void ServerProxy::onClipboardChanged(ClipboardID id, const IClipboard *clipboard)
{
String data = IClipboard::marshall(clipboard);
Expand Down
7 changes: 7 additions & 0 deletions src/lib/client/ServerProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ class ServerProxy
bool onGrabClipboard(ClipboardID);
void onClipboardChanged(ClipboardID, const IClipboard *);

//! Request to grab screen
/*!
Sends a request to the server to make this client the active screen.
This is typically called when touch input is detected on the client.
*/
void grabScreen(SInt32 x, SInt32 y);

//@}

// sending file chunk to server
Expand Down
9 changes: 9 additions & 0 deletions src/lib/deskflow/IPlatformScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ class IPlatformScreen : public IScreen, public IPrimaryScreen, public ISecondary
virtual void pollPressedKeys(KeyButtonSet &pressedKeys) const = 0;
virtual void clearStaleModifiers() = 0;

//! Activate the window at the given screen coordinates
/*!
Brings the window at position \c x, \c y to the foreground.
Default implementation does nothing; platforms override as needed.
*/
virtual void activateWindowAt(SInt32 x, SInt32 y)
{
}
Comment on lines +209 to +210
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
}
{
// do nothing
}


// Drag-and-drop overrides
virtual String &getDraggingFilename() = 0;
virtual void clearDraggingFilename() = 0;
Expand Down
5 changes: 5 additions & 0 deletions src/lib/deskflow/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,11 @@ void Screen::leaveSecondary()
m_screen->fakeAllKeysUp();
}

void Screen::activateWindowAt(SInt32 x, SInt32 y)
{
m_screen->activateWindowAt(x, y);
}

String Screen::getSecureInputApp() const
{
return m_screen->getSecureInputApp();
Expand Down
3 changes: 3 additions & 0 deletions src/lib/deskflow/Screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ class Screen : public IScreen

void setEnableDragDrop(bool enabled);

//! Activate the window at the given screen coordinates
void activateWindowAt(SInt32 x, SInt32 y);

//! Determine the name of the app causing a secure input state
/*!
On MacOS check which app causes a secure input state to be enabled. No
Expand Down
1 change: 1 addition & 0 deletions src/lib/deskflow/option_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ static const OptionID kOptionWin32KeepForeground = OPTION_CODE("_KFW");
static const OptionID kOptionDisableLockToScreen = OPTION_CODE("DLTS");
static const OptionID kOptionClipboardSharing = OPTION_CODE("CLPS");
static const OptionID kOptionClipboardSharingSize = OPTION_CODE("CLSZ");
static const OptionID kOptionTouchActivateScreen = OPTION_CODE("TILC");
//@}

//! @name Screen switch corner enumeration
Expand Down
1 change: 1 addition & 0 deletions src/lib/deskflow/protocol_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const char *const kMsgDFileTransfer = "DFTR%1i%s";
const char *const kMsgDDragInfo = "DDRG%2i%s";
const char *const kMsgDSecureInputNotification = "SECN%s";
const char *const kMsgDLanguageSynchronisation = "LSYN%s";
const char *const kMsgCGrabScreen = "CGRB%2i%2i";
const char *const kMsgQInfo = "QINF";
const char *const kMsgEIncompatible = "EICV%2i%2i";
const char *const kMsgEBusy = "EBSY";
Expand Down
Loading