diff --git a/.gitignore b/.gitignore index 10c604b0..839f5b88 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ CMakeCache.txt # Transient in-project-directory dependencies /deps/ /out/build/x64-Debug +.clangd/ +tags +compile_commands.json diff --git a/src/gui/src/Action.cpp b/src/gui/src/Action.cpp index 2e0f3397..a5ea2d76 100644 --- a/src/gui/src/Action.cpp +++ b/src/gui/src/Action.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 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 @@ -24,7 +24,8 @@ const char* Action::m_ActionTypeNames[] = { "keyDown", "keyUp", "keystroke", - "switchToScreen", "switchInDirection", "lockCursorToScreen", + "switchToScreen", "toggleScreen", + "switchInDirection", "lockCursorToScreen", "mouseDown", "mouseUp", "mousebutton" }; @@ -45,7 +46,8 @@ Action::Action() : QString Action::text() const { - QString text = QString(m_ActionTypeNames[keySequence().isMouseButton() ? type() + 6 : type() ]) + "("; + /* The server config parser don't support () with no argument inside, but support no () */ + QString text = QString(m_ActionTypeNames[keySequence().isMouseButton() ? type() + 6 : type() ]); switch (type()) { @@ -53,6 +55,7 @@ QString Action::text() const case keyUp: case keystroke: { + text += "("; text += keySequence().toString(); if (!keySequence().isMouseButton()) @@ -72,19 +75,29 @@ QString Action::text() const else text += ",*"; } + text += ")"; } break; case switchToScreen: + text += "("; text += switchScreenName(); + text += ")"; + break; + + case toggleScreen: break; case switchInDirection: + text += "("; text += m_SwitchDirectionNames[m_SwitchDirection]; + text += ")"; break; case lockCursorToScreen: + text += "("; text += m_LockCursorModeNames[m_LockCursorMode]; + text += ")"; break; default: @@ -92,7 +105,6 @@ QString Action::text() const break; } - text += ")"; return text; } diff --git a/src/gui/src/Action.h b/src/gui/src/Action.h index 27868422..154bee08 100644 --- a/src/gui/src/Action.h +++ b/src/gui/src/Action.h @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 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 @@ -36,7 +36,7 @@ class Action friend QTextStream& operator<<(QTextStream& outStream, const Action& action); public: - enum ActionType { keyDown, keyUp, keystroke, switchToScreen, switchInDirection, lockCursorToScreen, mouseDown, mouseUp, mousebutton }; + enum ActionType { keyDown, keyUp, keystroke, switchToScreen, toggleScreen, switchInDirection, lockCursorToScreen, mouseDown, mouseUp, mousebutton }; enum SwitchDirection { switchLeft, switchRight, switchUp, switchDown }; enum LockCursorMode { lockCursorToggle, lockCursonOn, lockCursorOff }; diff --git a/src/gui/src/ActionDialog.cpp b/src/gui/src/ActionDialog.cpp index 3565cfbc..aff46a01 100644 --- a/src/gui/src/ActionDialog.cpp +++ b/src/gui/src/ActionDialog.cpp @@ -2,11 +2,11 @@ * barrier -- mouse and keyboard sharing utility * Copyright (C) 2012-2016 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 @@ -39,7 +39,7 @@ ActionDialog::ActionDialog(QWidget* parent, ServerConfig& config, Hotkey& hotkey // work around Qt Designer's lack of a QButtonGroup; we need it to get // at the button id of the checked radio button - QRadioButton* const typeButtons[] = { m_pRadioPress, m_pRadioRelease, m_pRadioPressAndRelease, m_pRadioSwitchToScreen, m_pRadioSwitchInDirection, m_pRadioLockCursorToScreen }; + QRadioButton* const typeButtons[] = { m_pRadioPress, m_pRadioRelease, m_pRadioPressAndRelease, m_pRadioSwitchToScreen, m_pRadioToggleScreen, m_pRadioSwitchInDirection, m_pRadioLockCursorToScreen }; for (unsigned int i = 0; i < sizeof(typeButtons) / sizeof(typeButtons[0]); i++) m_pButtonGroupType->addButton(typeButtons[i], i); diff --git a/src/gui/src/ActionDialogBase.ui b/src/gui/src/ActionDialogBase.ui index f6dff784..9c6ad0a0 100644 --- a/src/gui/src/ActionDialogBase.ui +++ b/src/gui/src/ActionDialogBase.ui @@ -142,6 +142,17 @@ + + + + + + Toggle screen + + + + + diff --git a/src/lib/base/EventTypes.cpp b/src/lib/base/EventTypes.cpp index 9a3e46c6..d54a2d50 100644 --- a/src/lib/base/EventTypes.cpp +++ b/src/lib/base/EventTypes.cpp @@ -1,11 +1,11 @@ /* * barrier -- 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 @@ -133,6 +133,7 @@ REGISTER_EVENT(Server, error) REGISTER_EVENT(Server, connected) REGISTER_EVENT(Server, disconnected) REGISTER_EVENT(Server, switchToScreen) +REGISTER_EVENT(Server, toggleScreen) REGISTER_EVENT(Server, switchInDirection) REGISTER_EVENT(Server, keyboardBroadcast) REGISTER_EVENT(Server, lockCursorToScreen) diff --git a/src/lib/base/EventTypes.h b/src/lib/base/EventTypes.h index d044c86f..ba54032b 100644 --- a/src/lib/base/EventTypes.h +++ b/src/lib/base/EventTypes.h @@ -1,11 +1,11 @@ /* * barrier -- 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 @@ -134,7 +134,7 @@ public: Event::Type outputShutdown(); //@} - + private: Event::Type m_inputReady; Event::Type m_outputFlushed; @@ -159,7 +159,7 @@ public: Event::Type messageReceived(); //@} - + private: Event::Type m_connected; Event::Type m_messageReceived; @@ -179,7 +179,7 @@ public: //! Raised when the client disconnects from the server. Event::Type disconnected(); - + //@} private: @@ -198,7 +198,7 @@ public: //! Raised when we have created the client proxy. Event::Type clientConnected(); - + //! Raised when a message is received through a client proxy. Event::Type messageReceived(); @@ -242,7 +242,7 @@ public: event when a remote connection has been established. */ Event::Type connected(); - + //! Get secure connected event type /*! Returns the secure socket connected event type. A secure socket sends @@ -342,14 +342,14 @@ public: //! @name accessors //@{ - + //! Get accepted event type /*! Returns the accepted event type. This is sent whenever a server accepts a client. */ Event::Type accepted(); - + //! Get connected event type /*! Returns the connected event type. This is sent whenever a @@ -419,7 +419,7 @@ public: Event::Type failure(); //@} - + private: Event::Type m_success; Event::Type m_failure; @@ -432,6 +432,7 @@ public: m_connected(Event::kUnknown), m_disconnected(Event::kUnknown), m_switchToScreen(Event::kUnknown), + m_toggleScreen(Event::kUnknown), m_switchInDirection(Event::kUnknown), m_keyboardBroadcast(Event::kUnknown), m_lockCursorToScreen(Event::kUnknown), @@ -470,6 +471,13 @@ public: */ Event::Type switchToScreen(); + //! Get toggle screen event type + /*! + Returns the toggle screen event type. The server responds to this + by toggling screens. There is no event data. + */ + Event::Type toggleScreen(); + //! Get switch in direction event type /*! Returns the switch in direction event type. The server responds to this @@ -502,12 +510,13 @@ public: Event::Type screenSwitched(); //@} - + private: Event::Type m_error; Event::Type m_connected; Event::Type m_disconnected; Event::Type m_switchToScreen; + Event::Type m_toggleScreen; Event::Type m_switchInDirection; Event::Type m_keyboardBroadcast; Event::Type m_lockCursorToScreen; @@ -520,16 +529,16 @@ public: m_reloadConfig(Event::kUnknown), m_forceReconnect(Event::kUnknown), m_resetServer(Event::kUnknown) { } - + //! @name accessors //@{ - + Event::Type reloadConfig(); Event::Type forceReconnect(); Event::Type resetServer(); //@} - + private: Event::Type m_reloadConfig; Event::Type m_forceReconnect; @@ -556,7 +565,7 @@ public: Event::Type keyRepeat(); //@} - + private: Event::Type m_keyDown; Event::Type m_keyUp; @@ -580,7 +589,7 @@ public: //! @name accessors //@{ - + //! button down event type. Event data is ButtonInfo*. Event::Type buttonDown(); @@ -668,7 +677,7 @@ public: to sleep or a user session is deactivated (fast user switching). */ Event::Type suspend(); - + //! Get resume event type /*! Returns the resume event type. This is sent whenever the system wakes @@ -677,7 +686,7 @@ public: Event::Type resume(); //@} - + private: Event::Type m_error; Event::Type m_shapeChanged; @@ -713,7 +722,7 @@ public: //! Clipboard sending event type /*! - Returns the clipboard sending event type. This is used to send + Returns the clipboard sending event type. This is used to send clipboard chunks. */ Event::Type clipboardSending(); diff --git a/src/lib/server/Config.cpp b/src/lib/server/Config.cpp index 3cf60a5b..be4e30e7 100644 --- a/src/lib/server/Config.cpp +++ b/src/lib/server/Config.cpp @@ -2,11 +2,11 @@ * barrier -- 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 @@ -1182,6 +1182,10 @@ Config::parseAction(ConfigReadContext& s, action = new InputFilter::SwitchToScreenAction(m_events, screen); } + else if (name == "toggleScreen") { + action = new InputFilter::ToggleScreenAction(m_events); + } + else if (name == "switchInDirection") { if (args.size() != 1) { throw XConfigRead(s, "syntax for action: switchInDirection()"); @@ -1808,7 +1812,7 @@ operator<<(std::ostream& s, const Config& config) for (Config::link_const_iterator link = config.beginNeighbor(*screen), - nend = config.endNeighbor(*screen); link != nend; ++link) { + nend = config.endNeighbor(*screen); link != nend; ++link) { s << "\t\t" << Config::dirName(link->first.getSide()) << Config::formatInterval(link->first.getInterval()) << " = " << link->second.getName().c_str() << diff --git a/src/lib/server/InputFilter.cpp b/src/lib/server/InputFilter.cpp index 9e73f45e..26469800 100644 --- a/src/lib/server/InputFilter.cpp +++ b/src/lib/server/InputFilter.cpp @@ -2,11 +2,11 @@ * barrier -- 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 @@ -193,7 +193,7 @@ InputFilter::MouseButtonCondition::format() const return barrier::string::sprintf("mousebutton(%s%d)", key.c_str(), m_button); } -InputFilter::EFilterStatus +InputFilter::EFilterStatus InputFilter::MouseButtonCondition::match(const Event& event) { static const KeyModifierMask s_ignoreMask = @@ -255,7 +255,7 @@ InputFilter::EFilterStatus InputFilter::ScreenConnectedCondition::match(const Event& event) { if (event.getType() == m_events->forServer().connected()) { - Server::ScreenConnectedInfo* info = + Server::ScreenConnectedInfo* info = static_cast(event.getData()); if (m_screen == info->m_screen || m_screen.empty()) { return kActivate; @@ -316,7 +316,7 @@ InputFilter::LockCursorToScreenAction::perform(const Event& event) }; // send event - Server::LockCursorToScreenInfo* info = + Server::LockCursorToScreenInfo* info = Server::LockCursorToScreenInfo::alloc(s_state[m_mode]); m_events->addEvent(Event(m_events->forServer().lockCursorToScreen(), event.getTarget(), info, @@ -356,7 +356,7 @@ InputFilter::SwitchToScreenAction::perform(const Event& event) // event if it has one. String screen = m_screen; if (screen.empty() && event.getType() == m_events->forServer().connected()) { - Server::ScreenConnectedInfo* info = + Server::ScreenConnectedInfo* info = static_cast(event.getData()); screen = info->m_screen; } @@ -369,6 +369,32 @@ InputFilter::SwitchToScreenAction::perform(const Event& event) Event::kDeliverImmediately)); } +InputFilter::ToggleScreenAction::ToggleScreenAction(IEventQueue* events) : + m_events(events) +{ + // do nothing +} + +InputFilter::Action* +InputFilter::ToggleScreenAction::clone() const +{ + return new ToggleScreenAction(*this); +} + +String +InputFilter::ToggleScreenAction::format() const +{ + return barrier::string::sprintf("toggleScreen"); +} + +void +InputFilter::ToggleScreenAction::perform(const Event& event) +{ + m_events->addEvent(Event(m_events->forServer().toggleScreen(), + event.getTarget(), nullptr, + Event::kDeliverImmediately)); +} + InputFilter::SwitchInDirectionAction::SwitchInDirectionAction( IEventQueue* events, EDirection direction) : m_direction(direction), @@ -478,7 +504,7 @@ InputFilter::KeyboardBroadcastAction::perform(const Event& event) }; // send event - Server::KeyboardBroadcastInfo* info = + Server::KeyboardBroadcastInfo* info = Server::KeyboardBroadcastInfo::alloc(s_state[m_mode], m_screens); m_events->addEvent(Event(m_events->forServer().keyboardBroadcast(), event.getTarget(), info, @@ -555,7 +581,7 @@ InputFilter::KeystrokeAction::perform(const Event& event) Event::Type type = m_press ? m_events->forIKeyState().keyDown() : m_events->forIKeyState().keyUp(); - + m_events->addEvent(Event(m_events->forIPrimaryScreen().fakeInputBegin(), event.getTarget(), NULL, Event::kDeliverImmediately)); diff --git a/src/lib/server/InputFilter.h b/src/lib/server/InputFilter.h index 73afe970..a067744b 100644 --- a/src/lib/server/InputFilter.h +++ b/src/lib/server/InputFilter.h @@ -2,11 +2,11 @@ * barrier -- 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 @@ -54,7 +54,7 @@ public: virtual void enablePrimary(PrimaryClient*); virtual void disablePrimary(PrimaryClient*); }; - + // KeystrokeCondition class KeystrokeCondition : public Condition { public: @@ -119,7 +119,7 @@ public: // ------------------------------------------------------------------------- // Input Filter Action Classes // ------------------------------------------------------------------------- - + class Action { public: Action(); @@ -130,7 +130,7 @@ public: virtual void perform(const Event&) = 0; }; - + // LockCursorToScreenAction class LockCursorToScreenAction : public Action { public: @@ -149,7 +149,7 @@ public: Mode m_mode; IEventQueue* m_events; }; - + // SwitchToScreenAction class SwitchToScreenAction : public Action { public: @@ -166,7 +166,22 @@ public: String m_screen; IEventQueue* m_events; }; - + + // ToggleScreenAction + class ToggleScreenAction : public Action { + public: + ToggleScreenAction(IEventQueue* events); + + // Action overrides + virtual Action* clone() const; + virtual String format() const; + virtual void perform(const Event&); + + private: + IEventQueue* m_events; + }; + + // SwitchInDirectionAction class SwitchInDirectionAction : public Action { public: @@ -183,7 +198,7 @@ public: EDirection m_direction; IEventQueue* m_events; }; - + // KeyboardBroadcastAction class KeyboardBroadcastAction : public Action { public: diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index 12aedd0b..f20c4ba8 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -163,6 +163,10 @@ Server::Server( m_inputFilter, new TMethodEventJob(this, &Server::handleSwitchToScreenEvent)); + m_events->adoptHandler(m_events->forServer().toggleScreen(), + m_inputFilter, + new TMethodEventJob(this, + &Server::handleToggleScreenEvent)); m_events->adoptHandler(m_events->forServer().switchInDirection(), m_inputFilter, new TMethodEventJob(this, @@ -1407,6 +1411,22 @@ Server::handleSwitchToScreenEvent(const Event& event, void*) } } +void +Server::handleToggleScreenEvent(const Event& event, void*) +{ + std::string current = getName(m_active); + ClientList::const_iterator index = m_clients.find(current); + if (index == m_clients.end()) { + LOG((CLOG_DEBUG1 "screen \"%s\" not active", current.c_str())); + } + else { + ++index; + if (index == m_clients.end()) index = m_clients.begin(); + jumpToScreen(index->second); + } +} + + void Server::handleSwitchInDirectionEvent(const Event& event, void*) { diff --git a/src/lib/server/Server.h b/src/lib/server/Server.h index 609af212..1df34a87 100644 --- a/src/lib/server/Server.h +++ b/src/lib/server/Server.h @@ -2,11 +2,11 @@ * barrier -- 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 @@ -150,7 +150,7 @@ public: //! Store ClientListener pointer void setListener(ClientListener* p) { m_clientListener = p; } - + //@} //! @name accessors //@{ @@ -166,7 +166,7 @@ public: Set the \c list to the names of the currently connected clients. */ void getClients(std::vector& list) const; - + //! Return true if recieved file size is valid bool isReceivedFileSizeValid(); @@ -308,6 +308,7 @@ private: void handleClientDisconnected(const Event&, void*); void handleClientCloseTimeout(const Event&, void*); void handleSwitchToScreenEvent(const Event&, void*); + void handleToggleScreenEvent(const Event&, void*); void handleSwitchInDirectionEvent(const Event&, void*); void handleKeyboardBroadcastEvent(const Event&,void*); void handleLockCursorToScreenEvent(const Event&, void*); @@ -355,10 +356,10 @@ private: // 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*); @@ -447,7 +448,7 @@ private: bool m_switchNeedsShift; bool m_switchNeedsControl; bool m_switchNeedsAlt; - + // relative mouse move option bool m_relativeMoves;