Skip to content
Closed
7 changes: 6 additions & 1 deletion src/gui/src/ServerConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ bool ServerConfig::operator==(const ServerConfig &sc) const
m_HasSwitchDoubleTap == sc.m_HasSwitchDoubleTap && m_SwitchDoubleTap == sc.m_SwitchDoubleTap &&
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_DisableLockToScreen == sc.m_DisableLockToScreen && m_TouchActivateScreen == sc.m_TouchActivateScreen &&
m_ClipboardSharing == sc.m_ClipboardSharing &&
m_ClipboardSharingSize == sc.m_ClipboardSharingSize && m_pMainWindow == sc.m_pMainWindow;
}

Expand Down Expand Up @@ -125,6 +126,7 @@ void ServerConfig::commit()
settings().setValue("switchDoubleTap", switchDoubleTap());
settings().setValue("switchCornerSize", switchCornerSize());
settings().setValue("disableLockToScreen", disableLockToScreen());
settings().setValue("touchActivateScreen", touchActivateScreen());
settings().setValue("clipboardSharing", clipboardSharing());
settings().setValue("clipboardSharingSize", QVariant::fromValue(clipboardSharingSize()));

Expand Down Expand Up @@ -178,6 +180,7 @@ void ServerConfig::recall()
setSwitchDoubleTap(settings().value("switchDoubleTap", 250).toInt());
setSwitchCornerSize(settings().value("switchCornerSize").toInt());
setDisableLockToScreen(settings().value("disableLockToScreen", false).toBool());
setTouchActivateScreen(settings().value("touchActivateScreen", false).toBool());
setClipboardSharingSize(
settings().value("clipboardSharingSize", (int)ServerConfig::defaultClipboardSharingSize()).toULongLong()
);
Expand Down Expand Up @@ -282,6 +285,8 @@ QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config)
<< "win32KeepForeground = " << (config.win32KeepForeground() ? "true" : "false") << Qt::endl;
outStream << "\t"
<< "disableLockToScreen = " << (config.disableLockToScreen() ? "true" : "false") << Qt::endl;
outStream << "\t"
<< "touchActivateScreen = " << (config.touchActivateScreen() ? "true" : "false") << Qt::endl;
outStream << "\t"
<< "clipboardSharing = " << (config.clipboardSharing() ? "true" : "false") << Qt::endl;
outStream << "\t"
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 @@ -120,6 +120,10 @@ class ServerConfig : public ScreenConfig, public deskflow::gui::IServerConfig
{
return m_DisableLockToScreen;
}
bool touchActivateScreen() const
{
return m_TouchActivateScreen;
}
bool clipboardSharing() const
{
return m_ClipboardSharing;
Expand Down Expand Up @@ -220,6 +224,10 @@ class ServerConfig : public ScreenConfig, public deskflow::gui::IServerConfig
{
m_DisableLockToScreen = on;
}
void setTouchActivateScreen(bool on)
{
m_TouchActivateScreen = on;
}
void setClipboardSharing(bool on)
{
m_ClipboardSharing = on;
Expand Down Expand Up @@ -252,6 +260,7 @@ class ServerConfig : public ScreenConfig, public deskflow::gui::IServerConfig
int m_SwitchDoubleTap = 0;
int m_SwitchCornerSize = 0;
bool m_DisableLockToScreen = false;
bool m_TouchActivateScreen = false;
bool m_ClipboardSharing = true;
QString m_ClientAddress = "";
QList<bool> m_SwitchCorners;
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
8 changes: 8 additions & 0 deletions src/gui/src/ServerConfigDialogBase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,13 @@
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="m_pCheckBoxTouchActivateScreen">
<property name="text">
<string>Touch screen to activate (switch by tapping touchscreen)</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="m_pCheckBoxWin32KeepForeground">
<property name="enabled">
Expand Down Expand Up @@ -1168,6 +1175,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, grabInput)

//
// 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, grabInput)

//
// IpcServer
Expand Down
20 changes: 17 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_grabInput(Event::kUnknown)
{
}

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

//! Get grab input event type
Event::Type grabInput();

//@}

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

class ClientProxyUnknownEvents : public EventTypes
Expand Down Expand Up @@ -603,7 +607,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 +655,9 @@ class IPrimaryScreenEvents : public EventTypes
//! end of fake input event type
Event::Type fakeInputEnd();

//! touch activated primary screen event type
Event::Type touchActivatedPrimary();

//@}

private:
Expand All @@ -664,6 +672,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 +682,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_grabInput(Event::kUnknown)
{
}

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

//! Get grab input event type
Event::Type grabInput();

//@}

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

class ClipboardEvents : public EventTypes
Expand Down
22 changes: 22 additions & 0 deletions src/lib/client/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ Client::Client(
m_events->adoptHandler(
m_events->forIScreen().resume(), getEventTarget(), new TMethodEventJob<Client>(this, &Client::handleResume)
);
m_events->adoptHandler(
m_events->forIScreen().grabInput(), m_screen->getEventTarget(),
new TMethodEventJob<Client>(this, &Client::handleGrabInput)
);

if (m_args.m_enableDragDrop) {
m_events->adoptHandler(
Expand All @@ -107,6 +111,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().grabInput(), m_screen->getEventTarget());

cleanupTimer();
cleanupScreen();
Expand Down Expand Up @@ -240,6 +245,13 @@ void Client::enter(SInt32 xAbs, SInt32 yAbs, UInt32, KeyModifierMask mask, bool)
m_screen->mouseMove(xAbs, yAbs);
m_screen->enter(mask);

SInt32 tx, ty;
if (m_screen->consumePendingTouchActivation(tx, ty)) {
LOG((CLOG_DEBUG "client enter: consuming pending touch at %d,%d", tx, ty));
m_screen->activateWindowAt(tx, ty);
m_screen->fakeTouchClick(tx, ty);
}

if (m_sendFileThread) {
StreamChunker::interruptFile();
m_sendFileThread.reset(nullptr);
Expand Down Expand Up @@ -719,6 +731,16 @@ void Client::handleResume(const Event &, void *)
}
}

void Client::handleGrabInput(const Event &event, void *)
{
IPrimaryScreen::MotionInfo *info = static_cast<IPrimaryScreen::MotionInfo *>(event.getData());
if (m_server != NULL) {
LOG((CLOG_DEBUG "requesting grab input at %d,%d", info->m_x, info->m_y));
m_screen->setPendingTouchActivation(info->m_x, info->m_y);
m_server->grabInput(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 @@ -220,6 +220,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 handleGrabInput(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 @@ -380,6 +380,12 @@ void ServerProxy::onClipboardChanged(ClipboardID id, const IClipboard *clipboard
StreamChunker::sendClipboard(data, data.size(), id, m_seqNum, m_events, this);
}

void ServerProxy::grabInput(SInt32 x, SInt32 y)
{
LOG((CLOG_DEBUG "sending grab input at %d,%d", x, y));
ProtocolUtil::writef(m_stream, kMsgCGrabInput, x, y);
}

void ServerProxy::flushCompressedMouse()
{
if (m_compressMouse) {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/client/ServerProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class ServerProxy
bool onGrabClipboard(ClipboardID);
void onClipboardChanged(ClipboardID, const IClipboard *);

void grabInput(SInt32 x, SInt32 y);

//@}

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

// Touch-to-switch overrides
virtual void activateWindowAt(SInt32 x, SInt32 y) {}
virtual void fakeTouchClick(SInt32 x, SInt32 y) {}
virtual void setPendingTouchActivation(SInt32 x, SInt32 y) { (void)x; (void)y; }
virtual bool consumePendingTouchActivation(SInt32 &x, SInt32 &y) { (void)x; (void)y; return false; }

// Drag-and-drop overrides
virtual String &getDraggingFilename() = 0;
virtual void clearDraggingFilename() = 0;
Expand Down
20 changes: 20 additions & 0 deletions src/lib/deskflow/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,26 @@ void Screen::keyUp(KeyID, KeyModifierMask, KeyButton button)
m_screen->fakeKeyUp(button);
}

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

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

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

bool Screen::consumePendingTouchActivation(SInt32 &x, SInt32 &y)
{
return m_screen->consumePendingTouchActivation(x, y);
}

void Screen::mouseDown(ButtonID button)
{
m_screen->fakeMouseButton(button, true);
Expand Down
12 changes: 12 additions & 0 deletions src/lib/deskflow/Screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ class Screen : public IScreen
*/
void keyUp(KeyID id, KeyModifierMask, KeyButton);

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

//! Inject a touch click at the given coordinates
void fakeTouchClick(SInt32 x, SInt32 y);

//! Store coordinates for deferred touch activation after screen switch
void setPendingTouchActivation(SInt32 x, SInt32 y);

//! Consume pending touch activation, returning true if one was pending
bool consumePendingTouchActivation(SInt32 &x, SInt32 &y);

//! Notify of mouse press
/*!
Synthesize mouse events to generate a press of mouse button \c id.
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 kMsgCGrabInput = "CGRB%2i%2i";
const char *const kMsgQInfo = "QINF";
const char *const kMsgEIncompatible = "EICV%2i%2i";
const char *const kMsgEBusy = "EBSY";
Expand Down
Loading