From e435953af70852f1b157ce699450de5a87eb6054 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Tue, 16 Jul 2024 14:36:44 +0100 Subject: [PATCH] Make Clang param and arg alignment more readable (#7387) * Turn off alignment of params * Apply Clang format * Change AlignAfterOpenBracket to AlwaysBreak and add extra bin pack settings * Restore default bin packing * Apply format --- .clang-format | 17 + .../MSWindowsClientTaskBarReceiver.cpp | 39 +- .../synergyc/MSWindowsClientTaskBarReceiver.h | 8 +- src/cmd/synergyc/OSXClientTaskBarReceiver.cpp | 9 +- .../XWindowsClientTaskBarReceiver.cpp | 5 +- .../synergyc/XWindowsClientTaskBarReceiver.h | 4 +- .../MSWindowsServerTaskBarReceiver.cpp | 55 +- .../synergys/MSWindowsServerTaskBarReceiver.h | 8 +- src/cmd/synergys/OSXServerTaskBarReceiver.cpp | 9 +- .../XWindowsServerTaskBarReceiver.cpp | 5 +- .../synergys/XWindowsServerTaskBarReceiver.h | 4 +- src/gui/src/AboutDialog.cpp | 4 +- src/gui/src/Action.cpp | 14 +- src/gui/src/ActionDialog.cpp | 26 +- src/gui/src/ActionDialog.h | 4 +- src/gui/src/ActivationDialog.cpp | 15 +- src/gui/src/ActivationDialog.h | 4 +- src/gui/src/ActivationNotifier.cpp | 6 +- src/gui/src/ActivationNotifier.h | 5 +- src/gui/src/AddClientDialog.cpp | 10 +- src/gui/src/AppConfig.cpp | 81 +- src/gui/src/AppConfig.h | 8 +- src/gui/src/AppDelegate.h | 5 +- src/gui/src/BaseConfig.cpp | 4 +- src/gui/src/BaseConfig.h | 14 +- src/gui/src/CancelActivationDialog.cpp | 3 +- src/gui/src/CommandProcess.cpp | 8 +- src/gui/src/ConfigWriter.cpp | 32 +- src/gui/src/ConfigWriter.h | 6 +- src/gui/src/DataDownloader.cpp | 9 +- src/gui/src/FailedLoginDialog.cpp | 3 +- src/gui/src/HotkeyDialog.cpp | 3 +- src/gui/src/KeySequence.cpp | 99 +- src/gui/src/KeySequenceWidget.cpp | 11 +- src/gui/src/LicenseManager.cpp | 15 +- src/gui/src/LicenseRegistry.cpp | 5 +- src/gui/src/MainWindow.cpp | 158 +-- src/gui/src/MainWindow.h | 4 +- src/gui/src/QIpcClient.cpp | 17 +- src/gui/src/Screen.cpp | 9 +- src/gui/src/ScreenSettingsDialog.cpp | 27 +- src/gui/src/ScreenSettingsDialog.h | 5 +- src/gui/src/ScreenSetupModel.cpp | 27 +- src/gui/src/ScreenSetupModel.h | 5 +- src/gui/src/ScreenSetupView.cpp | 4 +- src/gui/src/ServerConfig.cpp | 43 +- src/gui/src/ServerConfig.h | 9 +- src/gui/src/ServerConfigDialog.cpp | 231 ++-- src/gui/src/ServerConfigDialog.h | 4 +- src/gui/src/ServerConnection.cpp | 8 +- src/gui/src/ServerMessage.cpp | 3 +- src/gui/src/SettingsDialog.cpp | 45 +- src/gui/src/SettingsDialog.h | 8 +- src/gui/src/SetupWizard.cpp | 5 +- src/gui/src/SetupWizardBlocker.cpp | 14 +- src/gui/src/SslCertificate.cpp | 5 +- src/gui/src/SslCertificate.h | 6 +- src/gui/src/TrayIcon.cpp | 5 +- src/gui/src/TrayIcon.h | 4 +- src/gui/src/UpgradeDialog.cpp | 5 +- src/gui/src/VersionChecker.cpp | 16 +- src/gui/src/main.cpp | 21 +- src/gui/src/validators/AliasValidator.h | 4 +- .../src/validators/ComputerNameValidator.cpp | 4 +- src/gui/src/validators/LineEditValidator.cpp | 3 +- src/gui/src/validators/LineEditValidator.h | 4 +- .../ScreenDuplicationsValidator.cpp | 3 +- .../validators/ScreenDuplicationsValidator.h | 6 +- .../src/validators/ScreenNameValidator.cpp | 4 +- src/gui/src/validators/ScreenNameValidator.h | 6 +- src/gui/src/widgets/ClientStateLabel.cpp | 5 +- src/lib/arch/ArchDaemonNone.cpp | 4 +- src/lib/arch/ArchDaemonNone.h | 6 +- src/lib/arch/IArchDaemon.h | 6 +- src/lib/arch/IArchFile.h | 4 +- src/lib/arch/IArchString.cpp | 8 +- src/lib/arch/IArchSystem.h | 4 +- src/lib/arch/unix/ArchFileUnix.cpp | 4 +- src/lib/arch/unix/ArchFileUnix.h | 4 +- src/lib/arch/unix/ArchMultithreadPosix.cpp | 34 +- src/lib/arch/unix/ArchNetworkBSD.cpp | 59 +- src/lib/arch/unix/ArchSleepUnix.cpp | 6 +- src/lib/arch/unix/ArchSystemUnix.cpp | 16 +- src/lib/arch/unix/ArchSystemUnix.h | 4 +- src/lib/arch/win32/ArchDaemonWindows.cpp | 25 +- src/lib/arch/win32/ArchDaemonWindows.h | 6 +- src/lib/arch/win32/ArchFileWindows.cpp | 4 +- src/lib/arch/win32/ArchFileWindows.h | 4 +- src/lib/arch/win32/ArchLogWindows.cpp | 13 +- src/lib/arch/win32/ArchMiscWindows.cpp | 61 +- src/lib/arch/win32/ArchMiscWindows.h | 4 +- src/lib/arch/win32/ArchMultithreadWindows.cpp | 22 +- src/lib/arch/win32/ArchNetworkWinsock.cpp | 227 ++-- src/lib/arch/win32/ArchSystemWindows.cpp | 4 +- src/lib/arch/win32/ArchSystemWindows.h | 4 +- src/lib/arch/win32/ArchTaskBarWindows.cpp | 28 +- src/lib/arch/win32/ArchTaskBarWindows.h | 4 +- src/lib/arch/win32/XArchWindows.cpp | 10 +- src/lib/base/Event.cpp | 15 +- src/lib/base/EventQueue.cpp | 46 +- src/lib/base/EventQueue.h | 5 +- src/lib/base/EventTypes.h | 64 +- src/lib/base/FunctionEventJob.cpp | 7 +- src/lib/base/FunctionJob.cpp | 3 +- src/lib/base/IEventQueue.h | 4 +- src/lib/base/Log.cpp | 23 +- src/lib/base/Path.cpp | 8 +- src/lib/base/PriorityQueue.h | 7 +- src/lib/base/SimpleEventQueueBuffer.cpp | 4 +- src/lib/base/Stopwatch.cpp | 4 +- src/lib/base/String.cpp | 17 +- src/lib/base/String.h | 4 +- src/lib/base/TMethodEventJob.h | 8 +- src/lib/base/TMethodJob.h | 8 +- src/lib/base/Unicode.cpp | 13 +- src/lib/base/Unicode.h | 14 +- src/lib/client/Client.cpp | 126 ++- src/lib/client/Client.h | 20 +- src/lib/client/ServerProxy.cpp | 126 ++- src/lib/common/stdsstream.h | 30 +- src/lib/io/StreamFilter.cpp | 15 +- src/lib/io/StreamFilter.h | 4 +- src/lib/ipc/IpcClient.cpp | 25 +- src/lib/ipc/IpcClient.h | 4 +- src/lib/ipc/IpcClientProxy.cpp | 52 +- src/lib/ipc/IpcLogOutputter.cpp | 23 +- src/lib/ipc/IpcLogOutputter.h | 4 +- src/lib/ipc/IpcMessage.cpp | 10 +- src/lib/ipc/IpcServer.cpp | 35 +- src/lib/ipc/IpcServer.h | 8 +- src/lib/ipc/IpcServerProxy.cpp | 12 +- src/lib/ipc/IpcSettingMessage.cpp | 8 +- src/lib/mt/CondVar.h | 6 +- src/lib/net/ISocketFactory.h | 6 +- src/lib/net/ISocketMultiplexerJob.h | 4 +- .../InverseSockets/InverseClientSocket.cpp | 28 +- .../net/InverseSockets/InverseClientSocket.h | 8 +- .../InverseSockets/InverseServerSocket.cpp | 14 +- .../net/InverseSockets/InverseServerSocket.h | 9 +- .../InverseSockets/InverseSocketFactory.cpp | 17 +- .../net/InverseSockets/InverseSocketFactory.h | 9 +- .../net/InverseSockets/SecureClientSocket.cpp | 25 +- .../net/InverseSockets/SecureClientSocket.h | 13 +- .../net/InverseSockets/SecureServerSocket.cpp | 10 +- .../net/InverseSockets/SecureServerSocket.h | 5 +- src/lib/net/InverseSockets/SslApi.cpp | 29 +- src/lib/net/NetworkAddress.cpp | 6 +- src/lib/net/SecureListenSocket.cpp | 10 +- src/lib/net/SecureListenSocket.h | 5 +- src/lib/net/SecureSocket.cpp | 79 +- src/lib/net/SecureSocket.h | 22 +- src/lib/net/SocketMultiplexer.cpp | 7 +- src/lib/net/TCPListenSocket.cpp | 18 +- src/lib/net/TCPListenSocket.h | 9 +- src/lib/net/TCPSocket.cpp | 40 +- src/lib/net/TCPSocket.h | 18 +- src/lib/net/TCPSocketFactory.cpp | 17 +- src/lib/net/TCPSocketFactory.h | 12 +- src/lib/net/TSocketMultiplexerMethodJob.h | 16 +- src/lib/net/XSocket.cpp | 13 +- src/lib/platform/MSWindowsClipboard.cpp | 7 +- .../MSWindowsClipboardBitmapConverter.cpp | 10 +- .../MSWindowsClipboardHTMLConverter.cpp | 19 +- src/lib/platform/MSWindowsDesks.cpp | 146 +-- src/lib/platform/MSWindowsDesks.h | 14 +- src/lib/platform/MSWindowsDropTarget.cpp | 12 +- src/lib/platform/MSWindowsDropTarget.h | 8 +- .../platform/MSWindowsEventQueueBuffer.cpp | 9 +- src/lib/platform/MSWindowsHook.cpp | 51 +- src/lib/platform/MSWindowsKeyState.cpp | 112 +- src/lib/platform/MSWindowsKeyState.h | 43 +- src/lib/platform/MSWindowsScreen.cpp | 281 +++-- src/lib/platform/MSWindowsScreen.h | 26 +- src/lib/platform/MSWindowsScreenSaver.cpp | 35 +- src/lib/platform/MSWindowsSession.cpp | 20 +- src/lib/platform/MSWindowsUtil.cpp | 18 +- src/lib/platform/MSWindowsWatchdog.cpp | 66 +- src/lib/platform/MSWindowsWatchdog.h | 9 +- src/lib/platform/OSXClipboard.cpp | 21 +- src/lib/platform/OSXClipboardBMPConverter.h | 5 +- .../platform/OSXClipboardHTMLConverter.cpp | 23 +- src/lib/platform/OSXClipboardHTMLConverter.h | 5 +- .../platform/OSXClipboardTextConverter.cpp | 27 +- src/lib/platform/OSXClipboardTextConverter.h | 5 +- src/lib/platform/OSXEventQueueBuffer.cpp | 12 +- src/lib/platform/OSXKeyState.cpp | 110 +- src/lib/platform/OSXKeyState.h | 36 +- src/lib/platform/OSXMediaKeySupport.h | 4 +- src/lib/platform/OSXScreen.h | 44 +- src/lib/platform/OSXScreenSaver.cpp | 22 +- src/lib/platform/OSXUchrKeyResource.cpp | 14 +- src/lib/platform/XWindowsClipboard.cpp | 258 +++-- src/lib/platform/XWindowsClipboard.h | 30 +- .../XWindowsClipboardAnyBitmapConverter.cpp | 20 +- .../XWindowsClipboardAnyBitmapConverter.h | 12 +- .../XWindowsClipboardHTMLConverter.cpp | 4 +- .../XWindowsClipboardTextConverter.cpp | 4 +- .../XWindowsClipboardUCS2Converter.cpp | 4 +- .../XWindowsClipboardUTF8Converter.cpp | 8 +- .../platform/XWindowsClipboardUTF8Converter.h | 4 +- src/lib/platform/XWindowsEventQueueBuffer.cpp | 19 +- src/lib/platform/XWindowsKeyState.cpp | 117 ++- src/lib/platform/XWindowsKeyState.h | 8 +- src/lib/platform/XWindowsPowerManager.cpp | 12 +- src/lib/platform/XWindowsScreen.cpp | 227 ++-- src/lib/platform/XWindowsScreen.h | 14 +- src/lib/platform/XWindowsScreenSaver.cpp | 70 +- src/lib/platform/XWindowsScreenSaver.h | 4 +- src/lib/platform/XWindowsUtil.cpp | 69 +- src/lib/platform/XWindowsUtil.h | 12 +- src/lib/server/BaseClientProxy.cpp | 4 +- src/lib/server/BaseClientProxy.h | 17 +- src/lib/server/ClientListener.cpp | 44 +- src/lib/server/ClientListener.h | 5 +- src/lib/server/ClientProxy.cpp | 3 +- src/lib/server/ClientProxy.h | 18 +- src/lib/server/ClientProxy1_0.cpp | 140 +-- src/lib/server/ClientProxy1_0.h | 17 +- src/lib/server/ClientProxy1_1.cpp | 26 +- src/lib/server/ClientProxy1_1.h | 8 +- src/lib/server/ClientProxy1_2.cpp | 7 +- src/lib/server/ClientProxy1_2.h | 4 +- src/lib/server/ClientProxy1_3.cpp | 20 +- src/lib/server/ClientProxy1_3.h | 4 +- src/lib/server/ClientProxy1_4.cpp | 17 +- src/lib/server/ClientProxy1_4.h | 14 +- src/lib/server/ClientProxy1_5.cpp | 24 +- src/lib/server/ClientProxy1_5.h | 5 +- src/lib/server/ClientProxy1_6.cpp | 15 +- src/lib/server/ClientProxy1_6.h | 5 +- src/lib/server/ClientProxy1_7.cpp | 11 +- src/lib/server/ClientProxy1_7.h | 5 +- src/lib/server/ClientProxy1_8.cpp | 24 +- src/lib/server/ClientProxy1_8.h | 5 +- src/lib/server/ClientProxyUnknown.cpp | 97 +- src/lib/server/ClientProxyUnknown.h | 5 +- src/lib/server/Config.cpp | 136 +-- src/lib/server/Config.h | 47 +- src/lib/server/InputFilter.cpp | 186 ++-- src/lib/server/InputFilter.h | 13 +- src/lib/server/PrimaryClient.cpp | 25 +- src/lib/server/PrimaryClient.h | 13 +- src/lib/server/Server.cpp | 339 +++--- src/lib/server/Server.h | 30 +- src/lib/shared/SerialKeyEdition.h | 4 +- src/lib/shared/SerialKeyParser.cpp | 9 +- src/lib/synergy/App.cpp | 43 +- src/lib/synergy/App.h | 4 +- src/lib/synergy/ArgParser.cpp | 51 +- src/lib/synergy/ArgParser.h | 29 +- src/lib/synergy/ClientApp.cpp | 80 +- src/lib/synergy/ClientApp.h | 13 +- src/lib/synergy/ClientTaskBarReceiver.cpp | 23 +- src/lib/synergy/ClientTaskBarReceiver.h | 5 +- src/lib/synergy/ClipboardChunk.cpp | 27 +- src/lib/synergy/ClipboardChunk.h | 13 +- src/lib/synergy/DaemonApp.cpp | 17 +- src/lib/synergy/DragInformation.cpp | 10 +- src/lib/synergy/DragInformation.h | 4 +- src/lib/synergy/DropHelper.cpp | 10 +- src/lib/synergy/DropHelper.h | 4 +- src/lib/synergy/FileChunk.cpp | 20 +- src/lib/synergy/FileChunk.h | 8 +- src/lib/synergy/IApp.h | 4 +- src/lib/synergy/IAppUtil.h | 4 +- src/lib/synergy/IClient.h | 18 +- src/lib/synergy/IClipboard.cpp | 4 +- src/lib/synergy/IKeyState.cpp | 17 +- src/lib/synergy/IKeyState.h | 14 +- src/lib/synergy/IPlatformScreen.h | 13 +- src/lib/synergy/IPrimaryScreen.cpp | 12 +- src/lib/synergy/IScreen.h | 4 +- src/lib/synergy/KeyMap.cpp | 216 ++-- src/lib/synergy/KeyMap.h | 138 ++- src/lib/synergy/KeyState.cpp | 990 ++++++++++++------ src/lib/synergy/KeyState.h | 46 +- src/lib/synergy/PacketStreamFilter.cpp | 11 +- src/lib/synergy/PacketStreamFilter.h | 4 +- src/lib/synergy/PlatformScreen.cpp | 15 +- src/lib/synergy/PlatformScreen.h | 19 +- src/lib/synergy/ProtocolUtil.cpp | 64 +- src/lib/synergy/ProtocolUtil.h | 4 +- src/lib/synergy/Screen.cpp | 29 +- src/lib/synergy/Screen.h | 8 +- src/lib/synergy/ServerApp.cpp | 84 +- src/lib/synergy/ServerApp.h | 8 +- src/lib/synergy/ServerTaskBarReceiver.cpp | 11 +- src/lib/synergy/ServerTaskBarReceiver.h | 5 +- src/lib/synergy/StreamChunker.cpp | 22 +- src/lib/synergy/StreamChunker.h | 6 +- src/lib/synergy/ToolArgs.cpp | 6 +- src/lib/synergy/XSynergy.cpp | 15 +- src/lib/synergy/languages/LanguageManager.cpp | 16 +- src/lib/synergy/languages/LanguageManager.h | 5 +- src/lib/synergy/unix/AppUtilUnix.cpp | 25 +- src/lib/synergy/unix/X11LayoutsParser.cpp | 45 +- src/lib/synergy/unix/X11LayoutsParser.h | 24 +- src/lib/synergy/win32/AppUtilWindows.cpp | 33 +- src/test/global/TestEventQueue.cpp | 7 +- src/test/integtests/ipc/IpcTests.cpp | 15 +- src/test/integtests/net/NetworkTests.cpp | 64 +- .../platform/MSWindowsKeyStateTests.cpp | 54 +- .../integtests/platform/OSXKeyStateTests.cpp | 4 +- src/test/mock/ipc/MockIpcServer.h | 3 +- src/test/mock/synergy/MockApp.h | 4 +- src/test/mock/synergy/MockEventQueue.h | 20 +- src/test/mock/synergy/MockKeyMap.h | 9 +- src/test/mock/synergy/MockKeyState.h | 9 +- src/test/mock/synergy/MockScreen.h | 5 +- src/test/unittests/arch/IArchStringTests.cpp | 5 +- src/test/unittests/base/LogTests.cpp | 8 +- src/test/unittests/gui/MainWindowTests.cpp | 4 +- src/test/unittests/synergy/ArgParserTests.cpp | 41 +- .../synergy/ClientArgsParsingTests.cpp | 5 +- .../synergy/GenericArgsParsingTests.cpp | 15 +- src/test/unittests/synergy/KeyMapTests.cpp | 20 +- src/test/unittests/synergy/KeyStateTests.cpp | 19 +- src/test/unittests/synergy/ServerAppTests.cpp | 4 +- .../synergy/X11LayoutParserTests.cpp | 21 +- .../languages/LanguageManagerTests.cpp | 10 +- 320 files changed, 5242 insertions(+), 3930 deletions(-) diff --git a/.clang-format b/.clang-format index f0a989e26..06204b36e 100644 --- a/.clang-format +++ b/.clang-format @@ -9,3 +9,20 @@ # $ pip install clang-format== BasedOnStyle: LLVM + +# Turn off LLVM default alignment of params with the opening bracket, +# which can be less readable in some cases in our code base. +# +# Using `AlwaysBreak` will result in: +# void fooBarBazQuxHelloWorld( +# int a, +# int b); +# +# Instead of: +# void fooBarBazQuxHelloWorld(int a, +# int b); +AlignAfterOpenBracket: AlwaysBreak + +# Turn off LLVM default packing of ctor initializers. +# This makes it easier to see which members were initialized and in what order. +PackConstructorInitializers: CurrentLine diff --git a/src/cmd/synergyc/MSWindowsClientTaskBarReceiver.cpp b/src/cmd/synergyc/MSWindowsClientTaskBarReceiver.cpp index 1d0926357..6b87c4b86 100644 --- a/src/cmd/synergyc/MSWindowsClientTaskBarReceiver.cpp +++ b/src/cmd/synergyc/MSWindowsClientTaskBarReceiver.cpp @@ -40,7 +40,9 @@ const UINT MSWindowsClientTaskBarReceiver::s_stateToIconID[kMaxState] = { MSWindowsClientTaskBarReceiver::MSWindowsClientTaskBarReceiver( HINSTANCE appInstance, const BufferedLogOutputter *logBuffer, IEventQueue *events) - : ClientTaskBarReceiver(events), m_appInstance(appInstance), m_window(NULL), + : ClientTaskBarReceiver(events), + m_appInstance(appInstance), + m_window(NULL), m_logBuffer(logBuffer) { for (UInt32 i = 0; i < kMaxState; ++i) { m_icon[i] = loadIcon(s_stateToIconID[i]); @@ -135,8 +137,8 @@ void MSWindowsClientTaskBarReceiver::runMenu(int x, int y) { HMENU menu = GetSubMenu(m_menu, 0); SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE); HMENU logLevelMenu = GetSubMenu(menu, 3); - CheckMenuRadioItem(logLevelMenu, 0, 6, CLOG->getFilter() - kERROR, - MF_BYPOSITION); + CheckMenuRadioItem( + logLevelMenu, 0, 6, CLOG->getFilter() - kERROR, MF_BYPOSITION); int n = TrackPopupMenu( menu, TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTBUTTON | TPM_RIGHTBUTTON, x, y, 0, m_window, NULL); @@ -226,8 +228,8 @@ void MSWindowsClientTaskBarReceiver::onStatusChanged() { HICON MSWindowsClientTaskBarReceiver::loadIcon(UINT id) { - HANDLE icon = LoadImage(m_appInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, - LR_DEFAULTCOLOR); + HANDLE icon = LoadImage( + m_appInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); return static_cast(icon); } @@ -267,8 +269,8 @@ void MSWindowsClientTaskBarReceiver::destroyWindow() { } } -BOOL MSWindowsClientTaskBarReceiver::dlgProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM) { +BOOL MSWindowsClientTaskBarReceiver::dlgProc( + HWND hwnd, UINT msg, WPARAM wParam, LPARAM) { switch (msg) { case WM_INITDIALOG: // use default focus @@ -284,9 +286,8 @@ BOOL MSWindowsClientTaskBarReceiver::dlgProc(HWND hwnd, UINT msg, WPARAM wParam, return FALSE; } -BOOL CALLBACK MSWindowsClientTaskBarReceiver::staticDlgProc(HWND hwnd, UINT msg, - WPARAM wParam, - LPARAM lParam) { +BOOL CALLBACK MSWindowsClientTaskBarReceiver::staticDlgProc( + HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { // if msg is WM_INITDIALOG, extract the MSWindowsClientTaskBarReceiver* // and put it in the extra window data then forward the call. MSWindowsClientTaskBarReceiver *self = NULL; @@ -310,15 +311,15 @@ BOOL CALLBACK MSWindowsClientTaskBarReceiver::staticDlgProc(HWND hwnd, UINT msg, } } -IArchTaskBarReceiver * -createTaskBarReceiver(const BufferedLogOutputter *logBuffer, - IEventQueue *events) { - ArchMiscWindows::setIcons((HICON)LoadImage(ArchMiscWindows::instanceWin32(), - MAKEINTRESOURCE(IDI_SYNERGY), - IMAGE_ICON, 32, 32, LR_SHARED), - (HICON)LoadImage(ArchMiscWindows::instanceWin32(), - MAKEINTRESOURCE(IDI_SYNERGY), - IMAGE_ICON, 16, 16, LR_SHARED)); +IArchTaskBarReceiver *createTaskBarReceiver( + const BufferedLogOutputter *logBuffer, IEventQueue *events) { + ArchMiscWindows::setIcons( + (HICON)LoadImage( + ArchMiscWindows::instanceWin32(), MAKEINTRESOURCE(IDI_SYNERGY), + IMAGE_ICON, 32, 32, LR_SHARED), + (HICON)LoadImage( + ArchMiscWindows::instanceWin32(), MAKEINTRESOURCE(IDI_SYNERGY), + IMAGE_ICON, 16, 16, LR_SHARED)); return new MSWindowsClientTaskBarReceiver( MSWindowsScreen::getWindowInstance(), logBuffer, events); diff --git a/src/cmd/synergyc/MSWindowsClientTaskBarReceiver.h b/src/cmd/synergyc/MSWindowsClientTaskBarReceiver.h index 75d10580f..e952685eb 100644 --- a/src/cmd/synergyc/MSWindowsClientTaskBarReceiver.h +++ b/src/cmd/synergyc/MSWindowsClientTaskBarReceiver.h @@ -29,8 +29,8 @@ class IEventQueue; //! Implementation of ClientTaskBarReceiver for Microsoft Windows class MSWindowsClientTaskBarReceiver : public ClientTaskBarReceiver { public: - MSWindowsClientTaskBarReceiver(HINSTANCE, const BufferedLogOutputter *, - IEventQueue *events); + MSWindowsClientTaskBarReceiver( + HINSTANCE, const BufferedLogOutputter *, IEventQueue *events); virtual ~MSWindowsClientTaskBarReceiver(); // IArchTaskBarReceiver overrides @@ -53,8 +53,8 @@ private: void destroyWindow(); BOOL dlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - static BOOL CALLBACK staticDlgProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam); + static BOOL CALLBACK + staticDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); private: HINSTANCE m_appInstance; diff --git a/src/cmd/synergyc/OSXClientTaskBarReceiver.cpp b/src/cmd/synergyc/OSXClientTaskBarReceiver.cpp index 4d86b6e3f..424a27564 100644 --- a/src/cmd/synergyc/OSXClientTaskBarReceiver.cpp +++ b/src/cmd/synergyc/OSXClientTaskBarReceiver.cpp @@ -23,8 +23,8 @@ // OSXClientTaskBarReceiver // -OSXClientTaskBarReceiver::OSXClientTaskBarReceiver(const BufferedLogOutputter *, - IEventQueue *events) +OSXClientTaskBarReceiver::OSXClientTaskBarReceiver( + const BufferedLogOutputter *, IEventQueue *events) : ClientTaskBarReceiver(events) { // add ourself to the task bar ARCH->addReceiver(this); @@ -50,8 +50,7 @@ const IArchTaskBarReceiver::Icon OSXClientTaskBarReceiver::getIcon() const { return NULL; } -IArchTaskBarReceiver * -createTaskBarReceiver(const BufferedLogOutputter *logBuffer, - IEventQueue *events) { +IArchTaskBarReceiver *createTaskBarReceiver( + const BufferedLogOutputter *logBuffer, IEventQueue *events) { return new OSXClientTaskBarReceiver(logBuffer, events); } diff --git a/src/cmd/synergyc/XWindowsClientTaskBarReceiver.cpp b/src/cmd/synergyc/XWindowsClientTaskBarReceiver.cpp index 2075681fd..0c124e536 100644 --- a/src/cmd/synergyc/XWindowsClientTaskBarReceiver.cpp +++ b/src/cmd/synergyc/XWindowsClientTaskBarReceiver.cpp @@ -51,8 +51,7 @@ CXWindowsClientTaskBarReceiver::getIcon() const { return NULL; } -IArchTaskBarReceiver * -createTaskBarReceiver(const BufferedLogOutputter *logBuffer, - IEventQueue *events) { +IArchTaskBarReceiver *createTaskBarReceiver( + const BufferedLogOutputter *logBuffer, IEventQueue *events) { return new CXWindowsClientTaskBarReceiver(logBuffer, events); } diff --git a/src/cmd/synergyc/XWindowsClientTaskBarReceiver.h b/src/cmd/synergyc/XWindowsClientTaskBarReceiver.h index 24aaec6be..f38ee596e 100644 --- a/src/cmd/synergyc/XWindowsClientTaskBarReceiver.h +++ b/src/cmd/synergyc/XWindowsClientTaskBarReceiver.h @@ -26,8 +26,8 @@ class IEventQueue; //! Implementation of ClientTaskBarReceiver for X Windows class CXWindowsClientTaskBarReceiver : public ClientTaskBarReceiver { public: - CXWindowsClientTaskBarReceiver(const BufferedLogOutputter *, - IEventQueue *events); + CXWindowsClientTaskBarReceiver( + const BufferedLogOutputter *, IEventQueue *events); CXWindowsClientTaskBarReceiver(const CXWindowsClientTaskBarReceiver &) = delete; CXWindowsClientTaskBarReceiver(CXWindowsClientTaskBarReceiver &&) = delete; diff --git a/src/cmd/synergys/MSWindowsServerTaskBarReceiver.cpp b/src/cmd/synergys/MSWindowsServerTaskBarReceiver.cpp index 33d84c389..b54737e91 100644 --- a/src/cmd/synergys/MSWindowsServerTaskBarReceiver.cpp +++ b/src/cmd/synergys/MSWindowsServerTaskBarReceiver.cpp @@ -41,8 +41,11 @@ const UINT MSWindowsServerTaskBarReceiver::s_stateToIconID[kMaxState] = { MSWindowsServerTaskBarReceiver::MSWindowsServerTaskBarReceiver( HINSTANCE appInstance, const BufferedLogOutputter *logBuffer, IEventQueue *events) - : ServerTaskBarReceiver(events), m_events(events), - m_appInstance(appInstance), m_window(NULL), m_logBuffer(logBuffer) { + : ServerTaskBarReceiver(events), + m_events(events), + m_appInstance(appInstance), + m_window(NULL), + m_logBuffer(logBuffer) { for (UInt32 i = 0; i < kMaxState; ++i) { m_icon[i] = loadIcon(s_stateToIconID[i]); } @@ -150,8 +153,8 @@ void MSWindowsServerTaskBarReceiver::runMenu(int x, int y) { HMENU menu = GetSubMenu(m_menu, 0); SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE); HMENU logLevelMenu = GetSubMenu(menu, 3); - CheckMenuRadioItem(logLevelMenu, 0, 6, CLOG->getFilter() - kERROR, - MF_BYPOSITION); + CheckMenuRadioItem( + logLevelMenu, 0, 6, CLOG->getFilter() - kERROR, MF_BYPOSITION); int n = TrackPopupMenu( menu, TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTBUTTON | TPM_RIGHTBUTTON, x, y, 0, m_window, NULL); @@ -172,18 +175,19 @@ void MSWindowsServerTaskBarReceiver::runMenu(int x, int y) { break; case IDC_RELOAD_CONFIG: - m_events->addEvent(Event(m_events->forServerApp().reloadConfig(), - m_events->getSystemTarget())); + m_events->addEvent(Event( + m_events->forServerApp().reloadConfig(), m_events->getSystemTarget())); break; case IDC_FORCE_RECONNECT: - m_events->addEvent(Event(m_events->forServerApp().forceReconnect(), - m_events->getSystemTarget())); + m_events->addEvent(Event( + m_events->forServerApp().forceReconnect(), + m_events->getSystemTarget())); break; case ID_SYNERGY_RESETSERVER: - m_events->addEvent(Event(m_events->forServerApp().resetServer(), - m_events->getSystemTarget())); + m_events->addEvent(Event( + m_events->forServerApp().resetServer(), m_events->getSystemTarget())); break; case IDC_TASKBAR_LOG_LEVEL_ERROR: @@ -256,8 +260,8 @@ void MSWindowsServerTaskBarReceiver::onStatusChanged() { HICON MSWindowsServerTaskBarReceiver::loadIcon(UINT id) { - HANDLE icon = LoadImage(m_appInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, - LR_DEFAULTCOLOR); + HANDLE icon = LoadImage( + m_appInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); return static_cast(icon); } @@ -297,8 +301,8 @@ void MSWindowsServerTaskBarReceiver::destroyWindow() { } } -BOOL MSWindowsServerTaskBarReceiver::dlgProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM) { +BOOL MSWindowsServerTaskBarReceiver::dlgProc( + HWND hwnd, UINT msg, WPARAM wParam, LPARAM) { switch (msg) { case WM_INITDIALOG: // use default focus @@ -314,9 +318,8 @@ BOOL MSWindowsServerTaskBarReceiver::dlgProc(HWND hwnd, UINT msg, WPARAM wParam, return FALSE; } -BOOL CALLBACK MSWindowsServerTaskBarReceiver::staticDlgProc(HWND hwnd, UINT msg, - WPARAM wParam, - LPARAM lParam) { +BOOL CALLBACK MSWindowsServerTaskBarReceiver::staticDlgProc( + HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { // if msg is WM_INITDIALOG, extract the MSWindowsServerTaskBarReceiver* // and put it in the extra window data then forward the call. MSWindowsServerTaskBarReceiver *self = NULL; @@ -341,15 +344,15 @@ BOOL CALLBACK MSWindowsServerTaskBarReceiver::staticDlgProc(HWND hwnd, UINT msg, } } -IArchTaskBarReceiver * -createTaskBarReceiver(const BufferedLogOutputter *logBuffer, - IEventQueue *events) { - ArchMiscWindows::setIcons((HICON)LoadImage(ArchMiscWindows::instanceWin32(), - MAKEINTRESOURCE(IDI_SYNERGY), - IMAGE_ICON, 32, 32, LR_SHARED), - (HICON)LoadImage(ArchMiscWindows::instanceWin32(), - MAKEINTRESOURCE(IDI_SYNERGY), - IMAGE_ICON, 16, 16, LR_SHARED)); +IArchTaskBarReceiver *createTaskBarReceiver( + const BufferedLogOutputter *logBuffer, IEventQueue *events) { + ArchMiscWindows::setIcons( + (HICON)LoadImage( + ArchMiscWindows::instanceWin32(), MAKEINTRESOURCE(IDI_SYNERGY), + IMAGE_ICON, 32, 32, LR_SHARED), + (HICON)LoadImage( + ArchMiscWindows::instanceWin32(), MAKEINTRESOURCE(IDI_SYNERGY), + IMAGE_ICON, 16, 16, LR_SHARED)); return new MSWindowsServerTaskBarReceiver( MSWindowsScreen::getWindowInstance(), logBuffer, events); diff --git a/src/cmd/synergys/MSWindowsServerTaskBarReceiver.h b/src/cmd/synergys/MSWindowsServerTaskBarReceiver.h index 8f9e9d309..d5f544f05 100644 --- a/src/cmd/synergys/MSWindowsServerTaskBarReceiver.h +++ b/src/cmd/synergys/MSWindowsServerTaskBarReceiver.h @@ -29,8 +29,8 @@ class IEventQueue; //! Implementation of ServerTaskBarReceiver for Microsoft Windows class MSWindowsServerTaskBarReceiver : public ServerTaskBarReceiver { public: - MSWindowsServerTaskBarReceiver(HINSTANCE, const BufferedLogOutputter *, - IEventQueue *events); + MSWindowsServerTaskBarReceiver( + HINSTANCE, const BufferedLogOutputter *, IEventQueue *events); virtual ~MSWindowsServerTaskBarReceiver(); // IArchTaskBarReceiver overrides @@ -53,8 +53,8 @@ private: void destroyWindow(); BOOL dlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - static BOOL CALLBACK staticDlgProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam); + static BOOL CALLBACK + staticDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); private: HINSTANCE m_appInstance; diff --git a/src/cmd/synergys/OSXServerTaskBarReceiver.cpp b/src/cmd/synergys/OSXServerTaskBarReceiver.cpp index f16f695f7..ab4311c22 100644 --- a/src/cmd/synergys/OSXServerTaskBarReceiver.cpp +++ b/src/cmd/synergys/OSXServerTaskBarReceiver.cpp @@ -23,8 +23,8 @@ // OSXServerTaskBarReceiver // -OSXServerTaskBarReceiver::OSXServerTaskBarReceiver(const BufferedLogOutputter *, - IEventQueue *events) +OSXServerTaskBarReceiver::OSXServerTaskBarReceiver( + const BufferedLogOutputter *, IEventQueue *events) : ServerTaskBarReceiver(events) { // add ourself to the task bar ARCH->addReceiver(this); @@ -50,8 +50,7 @@ const IArchTaskBarReceiver::Icon OSXServerTaskBarReceiver::getIcon() const { return NULL; } -IArchTaskBarReceiver * -createTaskBarReceiver(const BufferedLogOutputter *logBuffer, - IEventQueue *events) { +IArchTaskBarReceiver *createTaskBarReceiver( + const BufferedLogOutputter *logBuffer, IEventQueue *events) { return new OSXServerTaskBarReceiver(logBuffer, events); } diff --git a/src/cmd/synergys/XWindowsServerTaskBarReceiver.cpp b/src/cmd/synergys/XWindowsServerTaskBarReceiver.cpp index d75cadc96..124f7a96d 100644 --- a/src/cmd/synergys/XWindowsServerTaskBarReceiver.cpp +++ b/src/cmd/synergys/XWindowsServerTaskBarReceiver.cpp @@ -51,8 +51,7 @@ CXWindowsServerTaskBarReceiver::getIcon() const { return NULL; } -IArchTaskBarReceiver * -createTaskBarReceiver(const BufferedLogOutputter *logBuffer, - IEventQueue *events) { +IArchTaskBarReceiver *createTaskBarReceiver( + const BufferedLogOutputter *logBuffer, IEventQueue *events) { return new CXWindowsServerTaskBarReceiver(logBuffer, events); } diff --git a/src/cmd/synergys/XWindowsServerTaskBarReceiver.h b/src/cmd/synergys/XWindowsServerTaskBarReceiver.h index be70475b3..35a8f18cd 100644 --- a/src/cmd/synergys/XWindowsServerTaskBarReceiver.h +++ b/src/cmd/synergys/XWindowsServerTaskBarReceiver.h @@ -26,8 +26,8 @@ class IEventQueue; //! Implementation of ServerTaskBarReceiver for X Windows class CXWindowsServerTaskBarReceiver : public ServerTaskBarReceiver { public: - CXWindowsServerTaskBarReceiver(const BufferedLogOutputter *, - IEventQueue *events); + CXWindowsServerTaskBarReceiver( + const BufferedLogOutputter *, IEventQueue *events); CXWindowsServerTaskBarReceiver(const CXWindowsServerTaskBarReceiver &) = delete; CXWindowsServerTaskBarReceiver(CXWindowsServerTaskBarReceiver &&) = delete; diff --git a/src/gui/src/AboutDialog.cpp b/src/gui/src/AboutDialog.cpp index 70f45acc0..03f3adc93 100644 --- a/src/gui/src/AboutDialog.cpp +++ b/src/gui/src/AboutDialog.cpp @@ -91,6 +91,6 @@ QString AboutDialog::getCopyright() const { QString copyright("Copyright © 2012-%%YEAR%% Symless Ltd.\n" "Copyright © 2009-2012 Nick Bolton\n" "Copyright © 2002-2009 Chris Schoeneman"); - return copyright.replace(QString("%%YEAR%%"), - QString::number(buildDate.year())); + return copyright.replace( + QString("%%YEAR%%"), QString::number(buildDate.year())); } diff --git a/src/gui/src/Action.cpp b/src/gui/src/Action.cpp index f697f8c33..3a4823752 100644 --- a/src/gui/src/Action.cpp +++ b/src/gui/src/Action.cpp @@ -32,15 +32,19 @@ const char *Action::m_SwitchDirectionNames[] = {"left", "right", "up", "down"}; const char *Action::m_LockCursorModeNames[] = {"toggle", "on", "off"}; Action::Action() - : m_KeySequence(), m_Type(keystroke), m_TypeScreenNames(), - m_SwitchScreenName(), m_SwitchDirection(switchLeft), - m_LockCursorMode(lockCursorToggle), m_ActiveOnRelease(false), + : m_KeySequence(), + m_Type(keystroke), + m_TypeScreenNames(), + m_SwitchScreenName(), + m_SwitchDirection(switchLeft), + m_LockCursorMode(lockCursorToggle), + m_ActiveOnRelease(false), m_HasScreens(false) {} QString Action::text() const { QString text = - QString(m_ActionTypeNames[keySequence().isMouseButton() ? type() + 6 - : type()]) + + QString(m_ActionTypeNames + [keySequence().isMouseButton() ? type() + 6 : type()]) + "("; switch (type()) { diff --git a/src/gui/src/ActionDialog.cpp b/src/gui/src/ActionDialog.cpp index cf6569cc1..4a3c8b5e0 100644 --- a/src/gui/src/ActionDialog.cpp +++ b/src/gui/src/ActionDialog.cpp @@ -27,22 +27,26 @@ #include #include -ActionDialog::ActionDialog(QWidget *parent, ServerConfig &config, - Hotkey &hotkey, Action &action) +ActionDialog::ActionDialog( + QWidget *parent, ServerConfig &config, Hotkey &hotkey, Action &action) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), - Ui::ActionDialogBase(), m_ServerConfig(config), m_Hotkey(hotkey), - m_Action(action), m_pButtonGroupType(new QButtonGroup(this)) { + Ui::ActionDialogBase(), + m_ServerConfig(config), + m_Hotkey(hotkey), + m_Action(action), + m_pButtonGroupType(new QButtonGroup(this)) { setupUi(this); // 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, - m_pRadioRestartAllConnections}; + QRadioButton *const typeButtons[] = { + m_pRadioPress, + m_pRadioRelease, + m_pRadioPressAndRelease, + m_pRadioSwitchToScreen, + m_pRadioSwitchInDirection, + m_pRadioLockCursorToScreen, + m_pRadioRestartAllConnections}; for (unsigned int i = 0; i < sizeof(typeButtons) / sizeof(typeButtons[0]); i++) diff --git a/src/gui/src/ActionDialog.h b/src/gui/src/ActionDialog.h index c5ae1acdd..c112dd2c9 100644 --- a/src/gui/src/ActionDialog.h +++ b/src/gui/src/ActionDialog.h @@ -34,8 +34,8 @@ class ActionDialog : public QDialog, public Ui::ActionDialogBase { Q_OBJECT public: - ActionDialog(QWidget *parent, ServerConfig &config, Hotkey &hotkey, - Action &action); + ActionDialog( + QWidget *parent, ServerConfig &config, Hotkey &hotkey, Action &action); protected slots: void accept(); diff --git a/src/gui/src/ActivationDialog.cpp b/src/gui/src/ActivationDialog.cpp index e07f9ae01..c119be711 100644 --- a/src/gui/src/ActivationDialog.cpp +++ b/src/gui/src/ActivationDialog.cpp @@ -13,9 +13,11 @@ #include #include -ActivationDialog::ActivationDialog(QWidget *parent, AppConfig &appConfig, - LicenseManager &licenseManager) - : QDialog(parent), ui(new Ui::ActivationDialog), m_appConfig(&appConfig), +ActivationDialog::ActivationDialog( + QWidget *parent, AppConfig &appConfig, LicenseManager &licenseManager) + : QDialog(parent), + ui(new Ui::ActivationDialog), + m_appConfig(&appConfig), m_LicenseManager(&licenseManager) { ui->setupUi(this); refreshSerialKey(); @@ -92,9 +94,10 @@ void ActivationDialog::accept() { if (m_LicenseManager->serialKey().isTrial()) { message.information(this, "Thanks!", thanksMessage); } else { - message.information(this, "Activated!", - tr("Thanks for activating %1!") - .arg(m_LicenseManager->getEditionName(edition))); + message.information( + this, "Activated!", + tr("Thanks for activating %1!") + .arg(m_LicenseManager->getEditionName(edition))); } } diff --git a/src/gui/src/ActivationDialog.h b/src/gui/src/ActivationDialog.h index ed623d5bc..b752d1fc6 100644 --- a/src/gui/src/ActivationDialog.h +++ b/src/gui/src/ActivationDialog.h @@ -14,8 +14,8 @@ class ActivationDialog : public QDialog { Q_OBJECT public: - ActivationDialog(QWidget *parent, AppConfig &appConfig, - LicenseManager &licenseManager); + ActivationDialog( + QWidget *parent, AppConfig &appConfig, LicenseManager &licenseManager); ~ActivationDialog(); public slots: diff --git a/src/gui/src/ActivationNotifier.cpp b/src/gui/src/ActivationNotifier.cpp index 778e39c65..ede3910fb 100644 --- a/src/gui/src/ActivationNotifier.cpp +++ b/src/gui/src/ActivationNotifier.cpp @@ -25,9 +25,9 @@ void ActivationNotifier::setIdentity(QString identity) { m_Identity = identity; } -void ActivationNotifier::setUpdateInfo(QString const &fromVersion, - QString const &toVersion, - QString const &serialKey) { +void ActivationNotifier::setUpdateInfo( + QString const &fromVersion, QString const &toVersion, + QString const &serialKey) { m_fromVersion = fromVersion; m_toVersion = toVersion; m_serialKey = serialKey; diff --git a/src/gui/src/ActivationNotifier.h b/src/gui/src/ActivationNotifier.h index 3c971fc26..554fe536f 100644 --- a/src/gui/src/ActivationNotifier.h +++ b/src/gui/src/ActivationNotifier.h @@ -26,8 +26,9 @@ public: explicit ActivationNotifier(QObject *parent = 0); void setIdentity(QString identity); - void setUpdateInfo(QString const &fromVersion, QString const &toVersion, - QString const &serialKey); + void setUpdateInfo( + QString const &fromVersion, QString const &toVersion, + QString const &serialKey); public slots: void notify(); diff --git a/src/gui/src/AddClientDialog.cpp b/src/gui/src/AddClientDialog.cpp index d70768460..d9d5cd91a 100644 --- a/src/gui/src/AddClientDialog.cpp +++ b/src/gui/src/AddClientDialog.cpp @@ -23,12 +23,14 @@ AddClientDialog::AddClientDialog(const QString &clientName, QWidget *parent) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), - Ui::AddClientDialog(), m_AddResult(kAddClientIgnore) { + Ui::AddClientDialog(), + m_AddResult(kAddClientIgnore) { setupUi(this); - m_pLabelHead->setText("A client wants to connect. " - "Please choose a location for " + - clientName + "."); + m_pLabelHead->setText( + "A client wants to connect. " + "Please choose a location for " + + clientName + "."); QIcon icon(":res/icons/64x64/video-display.png"); QSize IconSize(32, 32); diff --git a/src/gui/src/AppConfig.cpp b/src/gui/src/AppConfig.cpp index a1991f5b8..f5e844a17 100644 --- a/src/gui/src/AppConfig.cpp +++ b/src/gui/src/AppConfig.cpp @@ -85,13 +85,26 @@ const char *AppConfig::m_SynergySettingsName[] = { static const char *logLevelNames[] = {"INFO", "DEBUG", "DEBUG1", "DEBUG2"}; AppConfig::AppConfig(bool globalLoad) - : m_ScreenName(), m_Port(24800), m_Interface(), m_LogLevel(0), - m_LogToFile(), m_WizardLastRun(0), m_ProcessMode(kDefaultProcessMode), - m_StartedBefore(), m_ElevateMode(kDefaultElevateMode), - m_Edition(kUnregistered), m_CryptoEnabled(false), m_AutoHide(false), - m_LastExpiringWarningTime(0), m_ActivationHasRun(), - m_MinimizeToTray(false), m_ServerGroupChecked(), m_UseExternalConfig(), - m_UseInternalConfig(), m_ClientGroupChecked(), m_LoadFromSystemScope() { + : m_ScreenName(), + m_Port(24800), + m_Interface(), + m_LogLevel(0), + m_LogToFile(), + m_WizardLastRun(0), + m_ProcessMode(kDefaultProcessMode), + m_StartedBefore(), + m_ElevateMode(kDefaultElevateMode), + m_Edition(kUnregistered), + m_CryptoEnabled(false), + m_AutoHide(false), + m_LastExpiringWarningTime(0), + m_ActivationHasRun(), + m_MinimizeToTray(false), + m_ServerGroupChecked(), + m_UseExternalConfig(), + m_UseInternalConfig(), + m_ClientGroupChecked(), + m_LoadFromSystemScope() { auto writer = ConfigWriter::make(); @@ -105,13 +118,13 @@ AppConfig::AppConfig(bool globalLoad) } // User settings exist and the load from system scope variable is true - if (writer->hasSetting(settingName(Setting::kLoadSystemSettings), - ConfigWriter::kUser)) { + if (writer->hasSetting( + settingName(Setting::kLoadSystemSettings), ConfigWriter::kUser)) { setLoadFromSystemScope(m_LoadFromSystemScope); } // If user setting don't exist but system ones do, load the system settings - else if (writer->hasSetting(settingName(Setting::kScreenName), - ConfigWriter::kSystem)) { + else if (writer->hasSetting( + settingName(Setting::kScreenName), ConfigWriter::kSystem)) { setLoadFromSystemScope(true); } } @@ -187,9 +200,9 @@ void AppConfig::loadSettings() { // TODO Investigate why kElevateModeEnum isn't loaded fully QVariant elevateMode = loadSetting(Setting::kElevateModeEnum); if (!elevateMode.isValid()) { - elevateMode = - loadSetting(Setting::kElevateModeSetting, - QVariant(static_cast(kDefaultElevateMode))); + elevateMode = loadSetting( + Setting::kElevateModeSetting, + QVariant(static_cast(kDefaultElevateMode))); } m_ElevateMode = static_cast(elevateMode.toInt()); } @@ -208,9 +221,10 @@ void AppConfig::loadSettings() { loadSetting(Setting::kGroupServerCheck, false).toBool(); m_UseExternalConfig = loadSetting(Setting::kUseExternalConfig, false).toBool(); - m_ConfigFile = loadSetting(Setting::kConfigFile, - QDir::homePath() + "/" + m_SynergyConfigName) - .toString(); + m_ConfigFile = + loadSetting( + Setting::kConfigFile, QDir::homePath() + "/" + m_SynergyConfigName) + .toString(); m_UseInternalConfig = loadSetting(Setting::kUseInternalConfig, false).toBool(); m_ClientGroupChecked = @@ -221,10 +235,10 @@ void AppConfig::loadSettings() { m_InvertScrollDirection = loadSetting(Setting::kInvertScrollDirection, false).toBool(); m_guid = loadCommonSetting(Setting::kGuid, QUuid::createUuid()).toString(); - m_licenseRegistryUrl = - loadCommonSetting(Setting::kLicenseRegistryUrl, - "https://api2.prod.symless.com/license/register") - .toString(); + m_licenseRegistryUrl = loadCommonSetting( + Setting::kLicenseRegistryUrl, + "https://api2.prod.symless.com/license/register") + .toString(); m_licenseNextCheck = loadCommonSetting(Setting::kLicenseNextCheck, 0).toULongLong(); m_ClientHostMode = loadSetting(Setting::kClientHostMode, true).toBool(); @@ -394,8 +408,9 @@ bool AppConfig::isCryptoAvailable() const { bool result{true}; #ifdef SYNERGY_ENABLE_LICENSING - result = (edition() == kPro || edition() == kProChina || - edition() == kBusiness || edition() == kUltimate); + result = + (edition() == kPro || edition() == kProChina || edition() == kBusiness || + edition() == kUltimate); #endif // SYNERGY_ENABLE_LICENSING return result; @@ -471,18 +486,18 @@ template void AppConfig::setSetting(Setting name, T value) { } template void AppConfig::setCommonSetting(Setting name, T value) { - ConfigWriter::make()->setSetting(settingName(name), value, - ConfigWriter::kUser); - ConfigWriter::make()->setSetting(settingName(name), value, - ConfigWriter::kSystem); + ConfigWriter::make()->setSetting( + settingName(name), value, ConfigWriter::kUser); + ConfigWriter::make()->setSetting( + settingName(name), value, ConfigWriter::kSystem); } QVariant AppConfig::loadSetting(Setting name, const QVariant &defaultValue) { return ConfigWriter::make()->loadSetting(settingName(name), defaultValue); } -QVariant AppConfig::loadCommonSetting(Setting name, - const QVariant &defaultValue) const { +QVariant +AppConfig::loadCommonSetting(Setting name, const QVariant &defaultValue) const { QVariant result(defaultValue); QString setting(settingName(name)); auto &writer = *ConfigWriter::make(); @@ -506,8 +521,8 @@ void AppConfig::loadScope(ConfigWriter::Scope scope) { if (writer->getScope() != scope) { setDefaultValues(); writer->setScope(scope); - if (writer->hasSetting(settingName(Setting::kScreenName), - writer->getScope())) { + if (writer->hasSetting( + settingName(Setting::kScreenName), writer->getScope())) { // If the user already has settings, then load them up now. writer->globalLoad(); } @@ -608,7 +623,7 @@ void AppConfig::setTLSKeyLength(const QString &length) { void AppConfig::generateCertificate(bool forceGeneration) const { SslCertificate sslCertificate; - sslCertificate.generateCertificate(getTLSCertPath(), getTLSKeyLength(), - forceGeneration); + sslCertificate.generateCertificate( + getTLSCertPath(), getTLSKeyLength(), forceGeneration); emit sslToggled(); } diff --git a/src/gui/src/AppConfig.h b/src/gui/src/AppConfig.h index 92fa83b64..d66c50f9b 100644 --- a/src/gui/src/AppConfig.h +++ b/src/gui/src/AppConfig.h @@ -303,14 +303,14 @@ private: /// @brief Loads a setting /// @param [in] name The setting to be loaded /// @param [in] defaultValue The default value of the setting - QVariant loadSetting(AppConfig::Setting name, - const QVariant &defaultValue = QVariant()); + QVariant loadSetting( + AppConfig::Setting name, const QVariant &defaultValue = QVariant()); /// @brief Loads a common setting /// @param [in] name The setting to be loaded /// @param [in] defaultValue The default value of the setting - QVariant loadCommonSetting(AppConfig::Setting name, - const QVariant &defaultValue = QVariant()) const; + QVariant loadCommonSetting( + AppConfig::Setting name, const QVariant &defaultValue = QVariant()) const; /// @brief As the settings will be accessible by multiple objects this lock /// will ensure that diff --git a/src/gui/src/AppDelegate.h b/src/gui/src/AppDelegate.h index 755dfd742..808d40b9a 100644 --- a/src/gui/src/AppDelegate.h +++ b/src/gui/src/AppDelegate.h @@ -8,8 +8,9 @@ extern "C" { #if OSX_DEPLOYMENT_TARGET >= 1014 #import @interface AppDelegate - : NSObject + : NSObject < + NSApplicationDelegate, NSUserNotificationCenterDelegate, + UNUserNotificationCenterDelegate> #else @interface AppDelegate : NSObject diff --git a/src/gui/src/BaseConfig.cpp b/src/gui/src/BaseConfig.cpp index c2528ae4b..c7dab36e7 100644 --- a/src/gui/src/BaseConfig.cpp +++ b/src/gui/src/BaseConfig.cpp @@ -25,5 +25,5 @@ const char *BaseConfig::m_FixNames[] = { "halfDuplexCapsLock", "halfDuplexNumLock", "halfDuplexScrollLock", "xtestIsXineramaUnaware"}; -const char *BaseConfig::m_SwitchCornerNames[] = {"top-left", "top-right", - "bottom-left", "bottom-right"}; +const char *BaseConfig::m_SwitchCornerNames[] = { + "top-left", "top-right", "bottom-left", "bottom-right"}; diff --git a/src/gui/src/BaseConfig.h b/src/gui/src/BaseConfig.h index d293c0bb9..becfd623e 100644 --- a/src/gui/src/BaseConfig.h +++ b/src/gui/src/BaseConfig.h @@ -51,8 +51,9 @@ protected: protected: template - void readSettings(QSettings &settings, T1 &array, const QString &arrayName, - const T2 &deflt) { + void readSettings( + QSettings &settings, T1 &array, const QString &arrayName, + const T2 &deflt) { int entries = settings.beginReadArray(arrayName + "Array"); array.clear(); for (int i = 0; i < entries; i++) { @@ -64,8 +65,9 @@ protected: } template - void readSettings(QSettings &settings, T1 &array, const QString &arrayName, - const T2 &deflt, int entries) { + void readSettings( + QSettings &settings, T1 &array, const QString &arrayName, const T2 &deflt, + int entries) { Q_ASSERT(array.size() >= entries); settings.beginReadArray(arrayName + "Array"); for (int i = 0; i < entries; i++) { @@ -77,8 +79,8 @@ protected: } template - void writeSettings(QSettings &settings, const T &array, - const QString &arrayName) const { + void writeSettings( + QSettings &settings, const T &array, const QString &arrayName) const { settings.beginWriteArray(arrayName + "Array"); for (int i = 0; i < array.size(); i++) { settings.setArrayIndex(i); diff --git a/src/gui/src/CancelActivationDialog.cpp b/src/gui/src/CancelActivationDialog.cpp index 95c62cde2..cf6b08652 100644 --- a/src/gui/src/CancelActivationDialog.cpp +++ b/src/gui/src/CancelActivationDialog.cpp @@ -2,7 +2,8 @@ #include "ui_CancelActivationDialog.h" CancelActivationDialog::CancelActivationDialog(QWidget *parent) - : QDialog(parent), ui(new Ui::CancelActivationDialog) { + : QDialog(parent), + ui(new Ui::CancelActivationDialog) { ui->setupUi(this); } diff --git a/src/gui/src/CommandProcess.cpp b/src/gui/src/CommandProcess.cpp index 3b2fc7210..dcaa63ce2 100644 --- a/src/gui/src/CommandProcess.cpp +++ b/src/gui/src/CommandProcess.cpp @@ -20,9 +20,11 @@ #include #include -CommandProcess::CommandProcess(QString cmd, QStringList arguments, - QString input) - : m_Command(cmd), m_Arguments(arguments), m_Input(input) {} +CommandProcess::CommandProcess( + QString cmd, QStringList arguments, QString input) + : m_Command(cmd), + m_Arguments(arguments), + m_Input(input) {} QString CommandProcess::run() { QProcess process; diff --git a/src/gui/src/ConfigWriter.cpp b/src/gui/src/ConfigWriter.cpp index 4d1a9c5f5..26b04b4c1 100644 --- a/src/gui/src/ConfigWriter.cpp +++ b/src/gui/src/ConfigWriter.cpp @@ -48,11 +48,12 @@ QString getSystemSettingPath() { #if defined(Q_OS_WIN) void loadOldSystemSettings(QSettings &settings) { if (!QFile(settings.fileName()).exists()) { - QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, - "SystemConfig.ini"); - QSettings oldSystemSettings(QSettings::IniFormat, QSettings::SystemScope, - QCoreApplication::organizationName(), - QCoreApplication::applicationName()); + QSettings::setPath( + QSettings::IniFormat, QSettings::SystemScope, "SystemConfig.ini"); + QSettings oldSystemSettings( + QSettings::IniFormat, QSettings::SystemScope, + QCoreApplication::organizationName(), + QCoreApplication::applicationName()); if (QFile(oldSystemSettings.fileName()).exists()) { for (const auto &key : oldSystemSettings.allKeys()) { @@ -61,8 +62,8 @@ void loadOldSystemSettings(QSettings &settings) { } // Restore system settings path - QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, - getSystemSettingPath()); + QSettings::setPath( + QSettings::IniFormat, QSettings::SystemScope, getSystemSettingPath()); } } #endif @@ -83,15 +84,16 @@ ConfigWriter *ConfigWriter::make() { } ConfigWriter::ConfigWriter() { - QSettings::setPath(QSettings::Format::IniFormat, - QSettings::Scope::SystemScope, getSystemSettingPath()); + QSettings::setPath( + QSettings::Format::IniFormat, QSettings::Scope::SystemScope, + getSystemSettingPath()); // Config will default to User settings if they exist, // otherwise it will load System setting and save them to User settings - m_pSettingsSystem = - new QSettings(QSettings::Format::IniFormat, QSettings::Scope::SystemScope, - QCoreApplication::organizationName(), - QCoreApplication::applicationName()); + m_pSettingsSystem = new QSettings( + QSettings::Format::IniFormat, QSettings::Scope::SystemScope, + QCoreApplication::organizationName(), + QCoreApplication::applicationName()); #if defined(Q_OS_WIN) // This call is needed for backwardcapability with old settings. @@ -134,8 +136,8 @@ bool ConfigWriter::isWritable() const { return m_pSettingsCurrent->isWritable(); } -QVariant ConfigWriter::loadSetting(const QString &name, - const QVariant &defaultValue, Scope scope) { +QVariant ConfigWriter::loadSetting( + const QString &name, const QVariant &defaultValue, Scope scope) { switch (scope) { case kUser: return m_pSettingsUser->value(name, defaultValue); diff --git a/src/gui/src/ConfigWriter.h b/src/gui/src/ConfigWriter.h index bddbd59d0..870e0d1a8 100644 --- a/src/gui/src/ConfigWriter.h +++ b/src/gui/src/ConfigWriter.h @@ -67,9 +67,9 @@ public: /// @param [in] defaultValue The default value of the setting /// @param [in] scope The scope to get the value from, default is current /// scope - QVariant loadSetting(const QString &name, - const QVariant &defaultValue = QVariant(), - Scope scope = kCurrent); + QVariant loadSetting( + const QString &name, const QVariant &defaultValue = QVariant(), + Scope scope = kCurrent); /// @brief Changes the setting save and load location between System and User /// scope diff --git a/src/gui/src/DataDownloader.cpp b/src/gui/src/DataDownloader.cpp index 5b81d86c3..4fa279708 100644 --- a/src/gui/src/DataDownloader.cpp +++ b/src/gui/src/DataDownloader.cpp @@ -18,9 +18,12 @@ #include "DataDownloader.h" DataDownloader::DataDownloader(QObject *parent) - : QObject(parent), m_pReply(nullptr), m_IsFinished(false) { - connect(&m_NetworkManager, SIGNAL(finished(QNetworkReply *)), - SLOT(complete(QNetworkReply *))); + : QObject(parent), + m_pReply(nullptr), + m_IsFinished(false) { + connect( + &m_NetworkManager, SIGNAL(finished(QNetworkReply *)), + SLOT(complete(QNetworkReply *))); } DataDownloader::~DataDownloader() {} diff --git a/src/gui/src/FailedLoginDialog.cpp b/src/gui/src/FailedLoginDialog.cpp index 48cfa8bea..c78903f04 100644 --- a/src/gui/src/FailedLoginDialog.cpp +++ b/src/gui/src/FailedLoginDialog.cpp @@ -2,7 +2,8 @@ #include "ui_FailedLoginDialog.h" FailedLoginDialog::FailedLoginDialog(QWidget *parent, QString message) - : QDialog(parent), ui(new Ui::FailedLoginDialog) { + : QDialog(parent), + ui(new Ui::FailedLoginDialog) { ui->setupUi(this); ui->messageLabel->setText(ui->messageLabel->text().arg(message)); } diff --git a/src/gui/src/HotkeyDialog.cpp b/src/gui/src/HotkeyDialog.cpp index 377bba2d8..6212b3cd3 100644 --- a/src/gui/src/HotkeyDialog.cpp +++ b/src/gui/src/HotkeyDialog.cpp @@ -23,7 +23,8 @@ HotkeyDialog::HotkeyDialog(QWidget *parent, Hotkey &hotkey) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), - Ui::HotkeyDialogBase(), m_Hotkey(hotkey) { + Ui::HotkeyDialogBase(), + m_Hotkey(hotkey) { setupUi(this); m_pKeySequenceWidgetHotkey->setText(m_Hotkey.text()); diff --git a/src/gui/src/KeySequence.cpp b/src/gui/src/KeySequence.cpp index f6cf936f6..ab05f3671 100644 --- a/src/gui/src/KeySequence.cpp +++ b/src/gui/src/KeySequence.cpp @@ -26,55 +26,56 @@ static const struct { int key; const char *name; -} keyname[] = {{Qt::Key_Space, "Space"}, - {Qt::Key_Escape, "Escape"}, - {Qt::Key_Tab, "Tab"}, - {Qt::Key_Backtab, "LeftTab"}, - {Qt::Key_Backspace, "BackSpace"}, - {Qt::Key_Return, "Return"}, - {Qt::Key_Insert, "Insert"}, - {Qt::Key_Delete, "Delete"}, - {Qt::Key_Pause, "Pause"}, - {Qt::Key_Print, "Print"}, - {Qt::Key_SysReq, "SysReq"}, - {Qt::Key_Home, "Home"}, - {Qt::Key_End, "End"}, - {Qt::Key_Left, "Left"}, - {Qt::Key_Up, "Up"}, - {Qt::Key_Right, "Right"}, - {Qt::Key_Down, "Down"}, - {Qt::Key_PageUp, "PageUp"}, - {Qt::Key_PageDown, "PageDown"}, - {Qt::Key_CapsLock, "CapsLock"}, - {Qt::Key_NumLock, "NumLock"}, - {Qt::Key_ScrollLock, "ScrollLock"}, - {Qt::Key_Menu, "Menu"}, - {Qt::Key_Help, "Help"}, - {Qt::Key_Enter, "KP_Enter"}, - {Qt::Key_Clear, "Clear"}, +} keyname[] = { + {Qt::Key_Space, "Space"}, + {Qt::Key_Escape, "Escape"}, + {Qt::Key_Tab, "Tab"}, + {Qt::Key_Backtab, "LeftTab"}, + {Qt::Key_Backspace, "BackSpace"}, + {Qt::Key_Return, "Return"}, + {Qt::Key_Insert, "Insert"}, + {Qt::Key_Delete, "Delete"}, + {Qt::Key_Pause, "Pause"}, + {Qt::Key_Print, "Print"}, + {Qt::Key_SysReq, "SysReq"}, + {Qt::Key_Home, "Home"}, + {Qt::Key_End, "End"}, + {Qt::Key_Left, "Left"}, + {Qt::Key_Up, "Up"}, + {Qt::Key_Right, "Right"}, + {Qt::Key_Down, "Down"}, + {Qt::Key_PageUp, "PageUp"}, + {Qt::Key_PageDown, "PageDown"}, + {Qt::Key_CapsLock, "CapsLock"}, + {Qt::Key_NumLock, "NumLock"}, + {Qt::Key_ScrollLock, "ScrollLock"}, + {Qt::Key_Menu, "Menu"}, + {Qt::Key_Help, "Help"}, + {Qt::Key_Enter, "KP_Enter"}, + {Qt::Key_Clear, "Clear"}, - {Qt::Key_Back, "WWWBack"}, - {Qt::Key_Forward, "WWWForward"}, - {Qt::Key_Stop, "WWWStop"}, - {Qt::Key_Refresh, "WWWRefresh"}, - {Qt::Key_VolumeDown, "AudioDown"}, - {Qt::Key_VolumeMute, "AudioMute"}, - {Qt::Key_VolumeUp, "AudioUp"}, - {Qt::Key_MediaPlay, "AudioPlay"}, - {Qt::Key_MediaStop, "AudioStop"}, - {Qt::Key_MediaPrevious, "AudioPrev"}, - {Qt::Key_MediaNext, "AudioNext"}, - {Qt::Key_HomePage, "WWWHome"}, - {Qt::Key_Favorites, "WWWFavorites"}, - {Qt::Key_Search, "WWWSearch"}, - {Qt::Key_Standby, "Sleep"}, - {Qt::Key_LaunchMail, "AppMail"}, - {Qt::Key_LaunchMedia, "AppMedia"}, - {Qt::Key_Launch0, "AppUser1"}, - {Qt::Key_Launch1, "AppUser2"}, - {Qt::Key_Select, "Select"}, + {Qt::Key_Back, "WWWBack"}, + {Qt::Key_Forward, "WWWForward"}, + {Qt::Key_Stop, "WWWStop"}, + {Qt::Key_Refresh, "WWWRefresh"}, + {Qt::Key_VolumeDown, "AudioDown"}, + {Qt::Key_VolumeMute, "AudioMute"}, + {Qt::Key_VolumeUp, "AudioUp"}, + {Qt::Key_MediaPlay, "AudioPlay"}, + {Qt::Key_MediaStop, "AudioStop"}, + {Qt::Key_MediaPrevious, "AudioPrev"}, + {Qt::Key_MediaNext, "AudioNext"}, + {Qt::Key_HomePage, "WWWHome"}, + {Qt::Key_Favorites, "WWWFavorites"}, + {Qt::Key_Search, "WWWSearch"}, + {Qt::Key_Standby, "Sleep"}, + {Qt::Key_LaunchMail, "AppMail"}, + {Qt::Key_LaunchMedia, "AppMedia"}, + {Qt::Key_Launch0, "AppUser1"}, + {Qt::Key_Launch1, "AppUser2"}, + {Qt::Key_Select, "Select"}, - {0, 0}}; + {0, 0}}; KeySequence::KeySequence() : m_Sequence(), m_Modifiers(0), m_IsValid(false) {} @@ -207,8 +208,8 @@ QString KeySequence::keyToString(int key) { // representable in ucs2? if (key < 0x10000) - return QString("\\u%1").arg(QChar(key).toLower().unicode(), 4, 16, - QChar('0')); + return QString("\\u%1").arg( + QChar(key).toLower().unicode(), 4, 16, QChar('0')); // give up, synergy probably won't handle this return ""; diff --git a/src/gui/src/KeySequenceWidget.cpp b/src/gui/src/KeySequenceWidget.cpp index 18fad7f0a..4e389f9c9 100644 --- a/src/gui/src/KeySequenceWidget.cpp +++ b/src/gui/src/KeySequenceWidget.cpp @@ -22,9 +22,14 @@ #include KeySequenceWidget::KeySequenceWidget(QWidget *parent, const KeySequence &seq) - : QPushButton(parent), m_KeySequence(seq), m_BackupSequence(seq), - m_Status(Stopped), m_MousePrefix("mousebutton("), m_MousePostfix(")"), - m_KeyPrefix("keystroke("), m_KeyPostfix(")") { + : QPushButton(parent), + m_KeySequence(seq), + m_BackupSequence(seq), + m_Status(Stopped), + m_MousePrefix("mousebutton("), + m_MousePostfix(")"), + m_KeyPrefix("keystroke("), + m_KeyPostfix(")") { setFocusPolicy(Qt::NoFocus); updateOutput(); } diff --git a/src/gui/src/LicenseManager.cpp b/src/gui/src/LicenseManager.cpp index 8c617b198..39ef75d5b 100644 --- a/src/gui/src/LicenseManager.cpp +++ b/src/gui/src/LicenseManager.cpp @@ -66,7 +66,8 @@ void checkSerialKey(const SerialKey &serialKey, bool acceptExpired) { } // namespace LicenseManager::LicenseManager(AppConfig *appConfig) - : m_AppConfig(appConfig), m_serialKey(appConfig->edition()), + : m_AppConfig(appConfig), + m_serialKey(appConfig->edition()), m_registry(*appConfig) {} void LicenseManager::setSerialKey(SerialKey serialKey, bool acceptExpired) { @@ -88,15 +89,15 @@ void LicenseManager::setSerialKey(SerialKey serialKey, bool acceptExpired) { } } -void LicenseManager::notifyUpdate(QString fromVersion, - QString toVersion) const { +void LicenseManager::notifyUpdate( + QString fromVersion, QString toVersion) const { if ((fromVersion == "Unknown") && (m_serialKey == SerialKey(kUnregistered))) { return; } ActivationNotifier *notifier = new ActivationNotifier(); - notifier->setUpdateInfo(fromVersion, toVersion, - QString::fromStdString(m_serialKey.toString())); + notifier->setUpdateInfo( + fromVersion, toVersion, QString::fromStdString(m_serialKey.toString())); QThread *thread = new QThread(); connect(notifier, SIGNAL(finished()), thread, SLOT(quit())); @@ -227,8 +228,8 @@ QString LicenseManager::getTemporaryNotice() const { void LicenseManager::validateSerialKey() const { if (m_serialKey.isValid()) { if (m_serialKey.isTemporary()) { - QTimer::singleShot(m_serialKey.getSpanLeft(), this, - SLOT(validateSerialKey())); + QTimer::singleShot( + m_serialKey.getSpanLeft(), this, SLOT(validateSerialKey())); } } else { emit InvalidLicense(); diff --git a/src/gui/src/LicenseRegistry.cpp b/src/gui/src/LicenseRegistry.cpp index 88553a187..45d09f3bd 100644 --- a/src/gui/src/LicenseRegistry.cpp +++ b/src/gui/src/LicenseRegistry.cpp @@ -37,8 +37,9 @@ void LicenseRegistry::registerLicense() { request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); m_manager.post(request, getRequestData()); - connect(&m_manager, SIGNAL(finished(QNetworkReply *)), this, - SLOT(handleResponse(QNetworkReply *))); + connect( + &m_manager, SIGNAL(finished(QNetworkReply *)), this, + SLOT(handleResponse(QNetworkReply *))); } } diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index a19bfad68..909ab7594 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -83,15 +83,24 @@ MainWindow::MainWindow(AppConfig &appConfig) #endif : #ifdef SYNERGY_ENABLE_LICENSING - m_LicenseManager(&licenseManager), m_ActivationDialogRunning(false), + m_LicenseManager(&licenseManager), + m_ActivationDialogRunning(false), #endif - m_AppConfig(&appConfig), m_pSynergy(NULL), + m_AppConfig(&appConfig), + m_pSynergy(NULL), m_SynergyState(synergyDisconnected), - m_ServerConfig(5, 3, m_AppConfig, this), m_AlreadyHidden(false), - m_pMenuBar(NULL), m_pMenuFile(NULL), m_pMenuEdit(NULL), - m_pMenuWindow(NULL), m_pMenuHelp(NULL), m_pCancelButton(NULL), - m_ExpectedRunningState(kStopped), m_SecureSocket(false), - m_serverConnection(*this), m_clientConnection(*this) { + m_ServerConfig(5, 3, m_AppConfig, this), + m_AlreadyHidden(false), + m_pMenuBar(NULL), + m_pMenuFile(NULL), + m_pMenuEdit(NULL), + m_pMenuWindow(NULL), + m_pMenuHelp(NULL), + m_pCancelButton(NULL), + m_ExpectedRunningState(kStopped), + m_SecureSocket(false), + m_serverConnection(*this), + m_clientConnection(*this) { setupUi(this); @@ -108,22 +117,26 @@ MainWindow::MainWindow(AppConfig &appConfig) m_VersionChecker.setApp(appPath(appConfig.synergycName())); updateScreenName(); - connect(m_AppConfig, SIGNAL(screenNameChanged()), this, - SLOT(updateScreenName())); + connect( + m_AppConfig, SIGNAL(screenNameChanged()), this, SLOT(updateScreenName())); m_pLabelIpAddresses->setText( tr("This computer's IP addresses: %1").arg(getIPAddresses())); #if defined(Q_OS_WIN) // ipc must always be enabled, so that we can disable command when switching // to desktop mode. - connect(&m_IpcClient, SIGNAL(readLogLine(const QString &)), this, - SLOT(appendLogRaw(const QString &))); - connect(&m_IpcClient, SIGNAL(errorMessage(const QString &)), this, - SLOT(appendLogError(const QString &))); - connect(&m_IpcClient, SIGNAL(infoMessage(const QString &)), this, - SLOT(appendLogInfo(const QString &))); - connect(&m_IpcClient, SIGNAL(readLogLine(const QString &)), this, - SLOT(handleIdleService(const QString &))); + connect( + &m_IpcClient, SIGNAL(readLogLine(const QString &)), this, + SLOT(appendLogRaw(const QString &))); + connect( + &m_IpcClient, SIGNAL(errorMessage(const QString &)), this, + SLOT(appendLogError(const QString &))); + connect( + &m_IpcClient, SIGNAL(infoMessage(const QString &)), this, + SLOT(appendLogInfo(const QString &))); + connect( + &m_IpcClient, SIGNAL(readLogLine(const QString &)), this, + SLOT(handleIdleService(const QString &))); m_IpcClient.connectToHost(); #endif @@ -141,21 +154,26 @@ MainWindow::MainWindow(AppConfig &appConfig) // hide padlock icon secureSocket(false); - connect(this, SIGNAL(windowShown()), this, SLOT(on_windowShown()), - Qt::QueuedConnection); + connect( + this, SIGNAL(windowShown()), this, SLOT(on_windowShown()), + Qt::QueuedConnection); #ifdef SYNERGY_ENABLE_LICENSING - connect(m_LicenseManager, SIGNAL(editionChanged(Edition)), this, - SLOT(setEdition(Edition)), Qt::QueuedConnection); + connect( + m_LicenseManager, SIGNAL(editionChanged(Edition)), this, + SLOT(setEdition(Edition)), Qt::QueuedConnection); - connect(m_LicenseManager, SIGNAL(showLicenseNotice(QString)), this, - SLOT(showLicenseNotice(QString)), Qt::QueuedConnection); + connect( + m_LicenseManager, SIGNAL(showLicenseNotice(QString)), this, + SLOT(showLicenseNotice(QString)), Qt::QueuedConnection); - connect(m_LicenseManager, SIGNAL(InvalidLicense()), this, - SLOT(InvalidLicense()), Qt::QueuedConnection); + connect( + m_LicenseManager, SIGNAL(InvalidLicense()), this, SLOT(InvalidLicense()), + Qt::QueuedConnection); #endif - connect(m_AppConfig, SIGNAL(sslToggled()), this, - SLOT(updateLocalFingerprint()), Qt::QueuedConnection); + connect( + m_AppConfig, SIGNAL(sslToggled()), this, SLOT(updateLocalFingerprint()), + Qt::QueuedConnection); updateWindowTitle(); @@ -260,12 +278,13 @@ void MainWindow::loadSettings() { void MainWindow::initConnections() { connect(m_pActionMinimize, SIGNAL(triggered()), this, SLOT(hide())); connect(m_pActionRestore, SIGNAL(triggered()), this, SLOT(showNormal())); - connect(m_pActionStartSynergy, SIGNAL(triggered()), this, - SLOT(actionStart())); + connect( + m_pActionStartSynergy, SIGNAL(triggered()), this, SLOT(actionStart())); connect(m_pActionStopSynergy, SIGNAL(triggered()), this, SLOT(stopSynergy())); connect(m_pActionQuit, SIGNAL(triggered()), qApp, SLOT(quit())); - connect(&m_VersionChecker, SIGNAL(updateFound(const QString &)), this, - SLOT(updateFound(const QString &))); + connect( + &m_VersionChecker, SIGNAL(updateFound(const QString &)), this, + SLOT(updateFound(const QString &))); } void MainWindow::saveSettings() { @@ -421,8 +440,9 @@ void MainWindow::checkConnected(const QString &line) { } } else if (line.contains("started server")) { setSynergyState(synergyListening); - } else if (line.contains("disconnected from server") || - line.contains("process exited")) { + } else if ( + line.contains("disconnected from server") || + line.contains("process exited")) { setSynergyState(synergyDisconnected); } else if (line.contains("connecting to")) { setSynergyState(synergyConnecting); @@ -497,10 +517,10 @@ void MainWindow::checkOSXNotification(const QString &line) { if (line.contains(OSXNotificationSubstring) && line.contains('|')) { int delimterPosition = line.indexOf('|'); int notificationStartPosition = line.indexOf(OSXNotificationSubstring); - QString title = - line.mid(notificationStartPosition + OSXNotificationSubstring.length(), - delimterPosition - notificationStartPosition - - OSXNotificationSubstring.length()); + QString title = line.mid( + notificationStartPosition + OSXNotificationSubstring.length(), + delimterPosition - notificationStartPosition - + OSXNotificationSubstring.length()); QString body = line.mid(delimterPosition + 1, line.length() - delimterPosition); if (!showOSXNotification(title, body)) { @@ -616,8 +636,9 @@ void MainWindow::startSynergy() { if (!m_pLogOutput->toPlainText().isEmpty()) appendLogRaw(""); - appendLogInfo("starting " + - QString(synergyType() == synergyServer ? "server" : "client")); + appendLogInfo( + "starting " + + QString(synergyType() == synergyServer ? "server" : "client")); if ((synergyType() == synergyClient && !clientArgs(args, app)) || (synergyType() == synergyServer && !serverArgs(args, app))) { @@ -626,12 +647,15 @@ void MainWindow::startSynergy() { } if (desktopMode) { - connect(synergyProcess(), SIGNAL(finished(int, QProcess::ExitStatus)), this, - SLOT(synergyFinished(int, QProcess::ExitStatus))); - connect(synergyProcess(), SIGNAL(readyReadStandardOutput()), this, - SLOT(logOutput())); - connect(synergyProcess(), SIGNAL(readyReadStandardError()), this, - SLOT(logError())); + connect( + synergyProcess(), SIGNAL(finished(int, QProcess::ExitStatus)), this, + SLOT(synergyFinished(int, QProcess::ExitStatus))); + connect( + synergyProcess(), SIGNAL(readyReadStandardOutput()), this, + SLOT(logOutput())); + connect( + synergyProcess(), SIGNAL(readyReadStandardError()), this, + SLOT(logError())); } qDebug() << args; @@ -712,9 +736,10 @@ bool MainWindow::clientArgs(QStringList &args, QString &app) { if (m_pLineEditHostname->text().isEmpty() && !appConfig().getClientHostMode()) { show(); - QMessageBox::warning(this, tr("Hostname is empty"), - tr("Please fill in a hostname for the synergy " - "client to connect to.")); + QMessageBox::warning( + this, tr("Hostname is empty"), + tr("Please fill in a hostname for the synergy " + "client to connect to.")); return false; } @@ -769,8 +794,8 @@ QString MainWindow::configFilename() { } if (configFullPath.isEmpty()) { - QMessageBox::critical(this, tr("Cannot write configuration file"), - errors.join('\n')); + QMessageBox::critical( + this, tr("Cannot write configuration file"), errors.join('\n')); } } @@ -807,8 +832,9 @@ bool MainWindow::serverArgs(QStringList &args, QString &app) { if (appConfig().getServerClientMode() && m_pLineEditClienIp->text().isEmpty()) { - QMessageBox::warning(this, tr("Client IP address or name is empty"), - tr("Please fill in a client IP address or name.")); + QMessageBox::warning( + this, tr("Client IP address or name is empty"), + tr("Please fill in a client IP address or name.")); return false; } @@ -911,17 +937,21 @@ void MainWindow::setSynergyState(qSynergyState state) { if ((state == synergyConnected) || (state == synergyConnecting) || (state == synergyListening) || (state == synergyPendingRetry)) { - disconnect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy, - SLOT(trigger())); - connect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStopSynergy, - SLOT(trigger())); + disconnect( + m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy, + SLOT(trigger())); + connect( + m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStopSynergy, + SLOT(trigger())); m_pButtonToggleStart->setText(tr("&Stop")); m_pButtonApply->setEnabled(true); } else if (state == synergyDisconnected) { - disconnect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStopSynergy, - SLOT(trigger())); - connect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy, - SLOT(trigger())); + disconnect( + m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStopSynergy, + SLOT(trigger())); + connect( + m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy, + SLOT(trigger())); m_pButtonToggleStart->setText(tr("&Start")); m_pButtonApply->setEnabled(false); } @@ -1060,8 +1090,8 @@ bool MainWindow::on_m_pActionSave_triggered() { QFileDialog::getSaveFileName(this, tr("Save configuration as...")); if (!fileName.isEmpty() && !serverConfig().save(fileName)) { - QMessageBox::warning(this, tr("Save failed"), - tr("Could not save configuration to file.")); + QMessageBox::warning( + this, tr("Save failed"), tr("Could not save configuration to file.")); return true; } @@ -1218,8 +1248,8 @@ void MainWindow::on_m_pLabelComputerName_linkActivated(const QString &) { } void MainWindow::on_m_pLabelFingerprint_linkActivated(const QString &) { - QMessageBox::information(this, "SSL/TLS fingerprint", - Fingerprint::local().readFirst()); + QMessageBox::information( + this, "SSL/TLS fingerprint", Fingerprint::local().readFirst()); } void MainWindow::windowStateChanged() { diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h index 610840a26..232cb4c05 100644 --- a/src/gui/src/MainWindow.h +++ b/src/gui/src/MainWindow.h @@ -169,8 +169,8 @@ protected: bool clientArgs(QStringList &args, QString &app); bool serverArgs(QStringList &args, QString &app); void setStatus(const QString &status); - void sendIpcMessage(qIpcMessageType type, const char *buffer, - bool showErrors); + void + sendIpcMessage(qIpcMessageType type, const char *buffer, bool showErrors); void updateFromLogLine(const QString &line); QString getIPAddresses(); void stopService(); diff --git a/src/gui/src/QIpcClient.cpp b/src/gui/src/QIpcClient.cpp index 02224e6fa..6a327e73a 100644 --- a/src/gui/src/QIpcClient.cpp +++ b/src/gui/src/QIpcClient.cpp @@ -24,7 +24,8 @@ #include QIpcClient::QIpcClient(const StreamProvider &streamProvider) - : m_ReaderStarted(false), m_Enabled(false), + : m_ReaderStarted(false), + m_Enabled(false), m_StreamProvider(streamProvider) { m_Socket = new QTcpSocket(this); @@ -36,12 +37,14 @@ QIpcClient::QIpcClient(const StreamProvider &streamProvider) } connect(m_Socket, SIGNAL(connected()), this, SLOT(connected())); - connect(m_Socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, - SLOT(error(QAbstractSocket::SocketError))); + connect( + m_Socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, + SLOT(error(QAbstractSocket::SocketError))); m_Reader = new IpcReader(m_Socket); - connect(m_Reader, SIGNAL(readLogLine(const QString &)), this, - SLOT(handleReadLogLine(const QString &))); + connect( + m_Reader, SIGNAL(readLogLine(const QString &)), this, + SLOT(handleReadLogLine(const QString &))); } QIpcClient::~QIpcClient() { @@ -106,8 +109,8 @@ void QIpcClient::sendHello() { stream->writeRawData(typeBuf, 1); } -void QIpcClient::sendCommand(const QString &command, - ElevateMode const elevate) { +void QIpcClient::sendCommand( + const QString &command, ElevateMode const elevate) { auto stream = m_StreamProvider(); stream->writeRawData(kIpcMsgCommand, 4); diff --git a/src/gui/src/Screen.cpp b/src/gui/src/Screen.cpp index 401871f3e..bb5f0c688 100644 --- a/src/gui/src/Screen.cpp +++ b/src/gui/src/Screen.cpp @@ -64,10 +64,11 @@ void Screen::loadSettings(QSettings &settings) { setSwitchCornerSize(settings.value("switchCornerSize").toInt()); readSettings(settings, aliases(), "alias", QString("")); - readSettings(settings, modifiers(), "modifier", static_cast(DefaultMod), - NumModifiers); - readSettings(settings, switchCorners(), "switchCorner", false, - NumSwitchCorners); + readSettings( + settings, modifiers(), "modifier", static_cast(DefaultMod), + NumModifiers); + readSettings( + settings, switchCorners(), "switchCorner", false, NumSwitchCorners); readSettings(settings, fixes(), "fix", false, NumFixes); } diff --git a/src/gui/src/ScreenSettingsDialog.cpp b/src/gui/src/ScreenSettingsDialog.cpp index 0f91faabb..530d15f88 100644 --- a/src/gui/src/ScreenSettingsDialog.cpp +++ b/src/gui/src/ScreenSettingsDialog.cpp @@ -25,10 +25,11 @@ #include #include -ScreenSettingsDialog::ScreenSettingsDialog(QWidget *parent, Screen *pScreen, - const ScreenList *pScreens) +ScreenSettingsDialog::ScreenSettingsDialog( + QWidget *parent, Screen *pScreen, const ScreenList *pScreens) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), - Ui::ScreenSettingsDialogBase(), m_pScreen(pScreen) { + Ui::ScreenSettingsDialogBase(), + m_pScreen(pScreen) { setupUi(this); m_pLineEditName->setText(m_pScreen->name()); @@ -97,14 +98,14 @@ void ScreenSettingsDialog::accept() { m_pScreen->setModifier(Screen::Meta, m_pComboBoxMeta->currentIndex()); m_pScreen->setModifier(Screen::Super, m_pComboBoxSuper->currentIndex()); - m_pScreen->setSwitchCorner(Screen::TopLeft, - m_pCheckBoxCornerTopLeft->isChecked()); - m_pScreen->setSwitchCorner(Screen::TopRight, - m_pCheckBoxCornerTopRight->isChecked()); - m_pScreen->setSwitchCorner(Screen::BottomLeft, - m_pCheckBoxCornerBottomLeft->isChecked()); - m_pScreen->setSwitchCorner(Screen::BottomRight, - m_pCheckBoxCornerBottomRight->isChecked()); + m_pScreen->setSwitchCorner( + Screen::TopLeft, m_pCheckBoxCornerTopLeft->isChecked()); + m_pScreen->setSwitchCorner( + Screen::TopRight, m_pCheckBoxCornerTopRight->isChecked()); + m_pScreen->setSwitchCorner( + Screen::BottomLeft, m_pCheckBoxCornerBottomLeft->isChecked()); + m_pScreen->setSwitchCorner( + Screen::BottomRight, m_pCheckBoxCornerBottomRight->isChecked()); m_pScreen->setSwitchCornerSize(m_pSpinBoxSwitchCornerSize->value()); m_pScreen->setFix(Screen::CapsLock, m_pCheckBoxCapsLock->isChecked()); @@ -126,8 +127,8 @@ void ScreenSettingsDialog::on_m_pButtonAddAlias_clicked() { void ScreenSettingsDialog::on_m_pLineEditAlias_textChanged( const QString &text) { - m_pButtonAddAlias->setEnabled(!text.isEmpty() && - m_pLabelAliasError->text().isEmpty()); + m_pButtonAddAlias->setEnabled( + !text.isEmpty() && m_pLabelAliasError->text().isEmpty()); } void ScreenSettingsDialog::on_m_pButtonRemoveAlias_clicked() { diff --git a/src/gui/src/ScreenSettingsDialog.h b/src/gui/src/ScreenSettingsDialog.h index 781cefb75..ec0cda1a7 100644 --- a/src/gui/src/ScreenSettingsDialog.h +++ b/src/gui/src/ScreenSettingsDialog.h @@ -36,8 +36,9 @@ class ScreenSettingsDialog : public QDialog, Q_OBJECT public: - ScreenSettingsDialog(QWidget *parent, Screen *pScreen = nullptr, - const ScreenList *pScreens = nullptr); + ScreenSettingsDialog( + QWidget *parent, Screen *pScreen = nullptr, + const ScreenList *pScreens = nullptr); public slots: void accept(); diff --git a/src/gui/src/ScreenSetupModel.cpp b/src/gui/src/ScreenSetupModel.cpp index 1baa48ee2..73a6794b7 100644 --- a/src/gui/src/ScreenSetupModel.cpp +++ b/src/gui/src/ScreenSetupModel.cpp @@ -24,14 +24,17 @@ const QString ScreenSetupModel::m_MimeType = "application/x-qsynergy-screen"; -ScreenSetupModel::ScreenSetupModel(ScreenList &screens, int numColumns, - int numRows) - : QAbstractTableModel(NULL), m_Screens(screens), m_NumColumns(numColumns), +ScreenSetupModel::ScreenSetupModel( + ScreenList &screens, int numColumns, int numRows) + : QAbstractTableModel(NULL), + m_Screens(screens), + m_NumColumns(numColumns), m_NumRows(numRows) { if (m_NumColumns * m_NumRows > screens.size()) - qFatal("Not enough elements (%lld) in screens QList for %d columns and %d " - "rows", - screens.size(), m_NumColumns, m_NumRows); + qFatal( + "Not enough elements (%lld) in screens QList for %d columns and %d " + "rows", + screens.size(), m_NumColumns, m_NumRows); } QVariant ScreenSetupModel::data(const QModelIndex &index, int role) const { @@ -96,9 +99,9 @@ QMimeData *ScreenSetupModel::mimeData(const QModelIndexList &indexes) const { return pMimeData; } -bool ScreenSetupModel::dropMimeData(const QMimeData *data, - Qt::DropAction action, int row, int column, - const QModelIndex &parent) { +bool ScreenSetupModel::dropMimeData( + const QMimeData *data, Qt::DropAction action, int row, int column, + const QModelIndex &parent) { if (action == Qt::IgnoreAction) return true; @@ -145,9 +148,9 @@ void ScreenSetupModel::addScreen(const Screen &newScreen) { } bool ScreenSetupModel::isFull() const { - auto emptyScreen = - std::find_if(m_Screens.cbegin(), m_Screens.cend(), - [](const Screen &item) { return item.isNull(); }); + auto emptyScreen = std::find_if( + m_Screens.cbegin(), m_Screens.cend(), + [](const Screen &item) { return item.isNull(); }); return (emptyScreen == m_Screens.cend()); } diff --git a/src/gui/src/ScreenSetupModel.h b/src/gui/src/ScreenSetupModel.h index 2445698be..1b54a4e98 100644 --- a/src/gui/src/ScreenSetupModel.h +++ b/src/gui/src/ScreenSetupModel.h @@ -56,8 +56,9 @@ signals: void screensChanged(); protected: - bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, - int column, const QModelIndex &parent); + bool dropMimeData( + const QMimeData *data, Qt::DropAction action, int row, int column, + const QModelIndex &parent); const Screen &screen(const QModelIndex &index) const { return screen(index.column(), index.row()); } diff --git a/src/gui/src/ScreenSetupView.cpp b/src/gui/src/ScreenSetupView.cpp index c9baed9f2..5bf8027cf 100644 --- a/src/gui/src/ScreenSetupView.cpp +++ b/src/gui/src/ScreenSetupView.cpp @@ -65,8 +65,8 @@ void ScreenSetupView::mouseDoubleClickEvent(QMouseEvent *event) { int row = rowAt(event->pos().y()); if (!model()->screen(col, row).isNull()) { - ScreenSettingsDialog dlg(this, &model()->screen(col, row), - &model()->m_Screens); + ScreenSettingsDialog dlg( + this, &model()->screen(col, row), &model()->m_Screens); dlg.exec(); emit model() -> screensChanged(); } diff --git a/src/gui/src/ServerConfig.cpp b/src/gui/src/ServerConfig.cpp index 31ee503e5..e8f633823 100644 --- a/src/gui/src/ServerConfig.cpp +++ b/src/gui/src/ServerConfig.cpp @@ -40,13 +40,17 @@ static const struct { const int serverDefaultIndex = 7; -ServerConfig::ServerConfig(int numColumns, int numRows, AppConfig *appConfig, - MainWindow *mainWindow) +ServerConfig::ServerConfig( + int numColumns, int numRows, AppConfig *appConfig, MainWindow *mainWindow) : - m_Screens(numColumns), m_NumColumns(numColumns), m_NumRows(numRows), - m_pAppConfig(appConfig), m_EnableDragAndDrop(false), - m_DisableLockToScreen(false), m_ClipboardSharing(true), + m_Screens(numColumns), + m_NumColumns(numColumns), + m_NumRows(numRows), + m_pAppConfig(appConfig), + m_EnableDragAndDrop(false), + m_DisableLockToScreen(false), + m_ClipboardSharing(true), m_ClipboardSharingSize(defaultClipboardSharingSize()), m_pMainWindow(mainWindow) { GUI::Config::ConfigWriter::make()->registerClass(this); @@ -131,8 +135,8 @@ void ServerConfig::saveSettings() { settings().setValue("disableLockToScreen", disableLockToScreen()); settings().setValue("enableDragAndDrop", enableDragAndDrop()); settings().setValue("clipboardSharing", clipboardSharing()); - settings().setValue("clipboardSharingSize", - QVariant::fromValue(clipboardSharingSize())); + settings().setValue( + "clipboardSharingSize", QVariant::fromValue(clipboardSharingSize())); if (!getClientAddress().isEmpty()) { settings().setValue("clientAddress", getClientAddress()); @@ -190,14 +194,15 @@ void ServerConfig::loadSettings() { setEnableDragAndDrop(settings().value("enableDragAndDrop", false).toBool()); setClipboardSharingSize( settings() - .value("clipboardSharingSize", - (int)ServerConfig::defaultClipboardSharingSize()) + .value( + "clipboardSharingSize", + (int)ServerConfig::defaultClipboardSharingSize()) .toULongLong()); setClipboardSharing(settings().value("clipboardSharing", true).toBool()); setClientAddress(settings().value("clientAddress", "").toString()); - readSettings(settings(), switchCorners(), "switchCorner", false, - NumSwitchCorners); + readSettings( + settings(), switchCorners(), "switchCorner", false, NumSwitchCorners); int numScreens = settings().beginReadArray("screens"); Q_ASSERT(numScreens <= screens().size()); @@ -222,8 +227,8 @@ void ServerConfig::loadSettings() { settings().endGroup(); } -int ServerConfig::adjacentScreenIndex(int idx, int deltaColumn, - int deltaRow) const { +int ServerConfig::adjacentScreenIndex( + int idx, int deltaColumn, int deltaRow) const { if (screens()[idx].isNull()) return -1; @@ -266,8 +271,8 @@ QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config) { for (unsigned int j = 0; j < sizeof(neighbourDirs) / sizeof(neighbourDirs[0]); j++) { - int idx = config.adjacentScreenIndex(i, neighbourDirs[j].x, - neighbourDirs[j].y); + int idx = config.adjacentScreenIndex( + i, neighbourDirs[j].x, neighbourDirs[j].y); if (idx != -1 && !config.screens()[idx].isNull()) outStream << "\t\t" << neighbourDirs[j].name << " = " << config.screens()[idx].name() << Qt::endl; @@ -380,8 +385,8 @@ int ServerConfig::autoAddScreen(const QString name) { dirIndex = 3; } - int idx = adjacentScreenIndex(startIndex, neighbourDirs[dirIndex].x, - neighbourDirs[dirIndex].y); + int idx = adjacentScreenIndex( + startIndex, neighbourDirs[dirIndex].x, neighbourDirs[dirIndex].y); while (idx != -1) { if (screens()[idx].isNull()) { m_Screens[idx].setName(name); @@ -390,8 +395,8 @@ int ServerConfig::autoAddScreen(const QString name) { } startIndex += offset; - idx = adjacentScreenIndex(startIndex, neighbourDirs[dirIndex].x, - neighbourDirs[dirIndex].y); + idx = adjacentScreenIndex( + startIndex, neighbourDirs[dirIndex].x, neighbourDirs[dirIndex].y); } if (!success) { diff --git a/src/gui/src/ServerConfig.h b/src/gui/src/ServerConfig.h index ec1045175..7b3610434 100644 --- a/src/gui/src/ServerConfig.h +++ b/src/gui/src/ServerConfig.h @@ -38,12 +38,13 @@ class AppConfig; class ServerConfig : public BaseConfig, public GUI::Config::ConfigBase { friend class ServerConfigDialog; friend class ServerConnection; - friend QTextStream &operator<<(QTextStream &outStream, - const ServerConfig &config); + friend QTextStream & + operator<<(QTextStream &outStream, const ServerConfig &config); public: - ServerConfig(int numColumns, int numRows, AppConfig *appConfig, - MainWindow *mainWindow); + ServerConfig( + int numColumns, int numRows, AppConfig *appConfig, + MainWindow *mainWindow); ServerConfig(const ServerConfig &src) = default; ServerConfig(ServerConfig &&) = default; diff --git a/src/gui/src/ServerConfigDialog.cpp b/src/gui/src/ServerConfigDialog.cpp index ed2e1f445..edaee081b 100644 --- a/src/gui/src/ServerConfigDialog.cpp +++ b/src/gui/src/ServerConfigDialog.cpp @@ -29,16 +29,19 @@ #include #include -ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, - AppConfig &appConfig) +ServerConfigDialog::ServerConfigDialog( + QWidget *parent, ServerConfig &config, AppConfig &appConfig) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), - Ui::ServerConfigDialogBase(), m_OrigServerConfig(config), + Ui::ServerConfigDialogBase(), + m_OrigServerConfig(config), m_OrigServerAppConfigUseExternalConfig(config.getUseExternalConfig()), m_OrigServerAppConfigExternalConfigFile(config.getConfigFile()), m_ServerConfig(config), - m_ScreenSetupModel(serverConfig().screens(), serverConfig().numColumns(), - serverConfig().numRows()), - m_Message(""), m_appConfig(appConfig) { + m_ScreenSetupModel( + serverConfig().screens(), serverConfig().numColumns(), + serverConfig().numRows()), + m_Message(""), + m_appConfig(appConfig) { setupUi(this); m_pEditConfigFile->setText(serverConfig().getConfigFile()); @@ -90,115 +93,135 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, if (server == screens.end()) { Screen serverScreen(serverConfig().getServerName()); serverScreen.markAsServer(); - model().screen(serverConfig().numColumns() / 2, - serverConfig().numRows() / 2) = serverScreen; + model().screen( + serverConfig().numColumns() / 2, serverConfig().numRows() / 2) = + serverScreen; } else { server->markAsServer(); } m_pButtonAddComputer->setEnabled(!model().isFull()); - connect(m_pTrashScreenWidget, SIGNAL(screenRemoved()), this, - SLOT(onScreenRemoved())); + connect( + m_pTrashScreenWidget, SIGNAL(screenRemoved()), this, + SLOT(onScreenRemoved())); onChange(); // computers - connect(&m_ScreenSetupModel, &ScreenSetupModel::screensChanged, this, - &ServerConfigDialog::onChange); + connect( + &m_ScreenSetupModel, &ScreenSetupModel::screensChanged, this, + &ServerConfigDialog::onChange); // advanced - connect(m_pCheckBoxSwitchDelay, &QCheckBox::stateChanged, this, - [this](const int &v) { - serverConfig().haveSwitchDelay(v); - onChange(); - }); - connect(m_pSpinBoxSwitchDelay, - static_cast(&QSpinBox::valueChanged), this, - [this](const int &v) { - serverConfig().setSwitchDelay(v); - onChange(); - }); - connect(m_pCheckBoxSwitchDoubleTap, &QCheckBox::stateChanged, this, - [this](const int &v) { - serverConfig().haveSwitchDoubleTap(v); - onChange(); - }); - connect(m_pSpinBoxSwitchDoubleTap, - static_cast(&QSpinBox::valueChanged), this, - [this](const int &v) { - serverConfig().setSwitchDoubleTap(v); - onChange(); - }); - connect(m_pCheckBoxEnableClipboard, &QCheckBox::stateChanged, this, - [this](const int &v) { - serverConfig().setClipboardSharing(v); - onChange(); - }); - connect(m_pSpinBoxClipboardSizeLimit, - static_cast(&QSpinBox::valueChanged), this, - [this](const int &v) { - serverConfig().setClipboardSharingSize(v * 1024); - onChange(); - }); - connect(m_pCheckBoxHeartbeat, &QCheckBox::stateChanged, this, - [this](const int &v) { - serverConfig().haveHeartbeat(v); - onChange(); - }); - connect(m_pSpinBoxHeartbeat, - static_cast(&QSpinBox::valueChanged), this, - [this](const int &v) { - serverConfig().setHeartbeat(v); - onChange(); - }); - connect(m_pCheckBoxRelativeMouseMoves, &QCheckBox::stateChanged, this, - [this](const int &v) { - serverConfig().setRelativeMouseMoves(v); - onChange(); - }); - connect(m_pCheckBoxWin32KeepForeground, &QCheckBox::stateChanged, this, - [this](const int &v) { - serverConfig().setWin32KeepForeground(v); - onChange(); - }); - connect(m_pCheckBoxDisableLockToScreen, &QCheckBox::stateChanged, this, - [this](const int &v) { - serverConfig().setDisableLockToScreen(v); - onChange(); - }); - connect(m_pCheckBoxCornerTopLeft, &QCheckBox::stateChanged, this, - [this](const int &v) { - serverConfig().setSwitchCorner(BaseConfig::TopLeft, v); - onChange(); - }); - connect(m_pCheckBoxCornerTopRight, &QCheckBox::stateChanged, this, - [this](const int &v) { - serverConfig().setSwitchCorner(BaseConfig::TopRight, v); - onChange(); - }); - connect(m_pCheckBoxCornerBottomLeft, &QCheckBox::stateChanged, this, - [this](const int &v) { - serverConfig().setSwitchCorner(BaseConfig::BottomLeft, v); - onChange(); - }); - connect(m_pCheckBoxCornerBottomRight, &QCheckBox::stateChanged, this, - [this](const int &v) { - serverConfig().setSwitchCorner(BaseConfig::BottomRight, v); - onChange(); - }); - connect(m_pSpinBoxSwitchCornerSize, - static_cast(&QSpinBox::valueChanged), this, - [this](const int &v) { - serverConfig().setSwitchCornerSize(v); - onChange(); - }); + connect( + m_pCheckBoxSwitchDelay, &QCheckBox::stateChanged, this, + [this](const int &v) { + serverConfig().haveSwitchDelay(v); + onChange(); + }); + connect( + m_pSpinBoxSwitchDelay, + static_cast(&QSpinBox::valueChanged), this, + [this](const int &v) { + serverConfig().setSwitchDelay(v); + onChange(); + }); + connect( + m_pCheckBoxSwitchDoubleTap, &QCheckBox::stateChanged, this, + [this](const int &v) { + serverConfig().haveSwitchDoubleTap(v); + onChange(); + }); + connect( + m_pSpinBoxSwitchDoubleTap, + static_cast(&QSpinBox::valueChanged), this, + [this](const int &v) { + serverConfig().setSwitchDoubleTap(v); + onChange(); + }); + connect( + m_pCheckBoxEnableClipboard, &QCheckBox::stateChanged, this, + [this](const int &v) { + serverConfig().setClipboardSharing(v); + onChange(); + }); + connect( + m_pSpinBoxClipboardSizeLimit, + static_cast(&QSpinBox::valueChanged), this, + [this](const int &v) { + serverConfig().setClipboardSharingSize(v * 1024); + onChange(); + }); + connect( + m_pCheckBoxHeartbeat, &QCheckBox::stateChanged, this, + [this](const int &v) { + serverConfig().haveHeartbeat(v); + onChange(); + }); + connect( + m_pSpinBoxHeartbeat, + static_cast(&QSpinBox::valueChanged), this, + [this](const int &v) { + serverConfig().setHeartbeat(v); + onChange(); + }); + connect( + m_pCheckBoxRelativeMouseMoves, &QCheckBox::stateChanged, this, + [this](const int &v) { + serverConfig().setRelativeMouseMoves(v); + onChange(); + }); + connect( + m_pCheckBoxWin32KeepForeground, &QCheckBox::stateChanged, this, + [this](const int &v) { + serverConfig().setWin32KeepForeground(v); + onChange(); + }); + connect( + m_pCheckBoxDisableLockToScreen, &QCheckBox::stateChanged, this, + [this](const int &v) { + serverConfig().setDisableLockToScreen(v); + onChange(); + }); + connect( + m_pCheckBoxCornerTopLeft, &QCheckBox::stateChanged, this, + [this](const int &v) { + serverConfig().setSwitchCorner(BaseConfig::TopLeft, v); + onChange(); + }); + connect( + m_pCheckBoxCornerTopRight, &QCheckBox::stateChanged, this, + [this](const int &v) { + serverConfig().setSwitchCorner(BaseConfig::TopRight, v); + onChange(); + }); + connect( + m_pCheckBoxCornerBottomLeft, &QCheckBox::stateChanged, this, + [this](const int &v) { + serverConfig().setSwitchCorner(BaseConfig::BottomLeft, v); + onChange(); + }); + connect( + m_pCheckBoxCornerBottomRight, &QCheckBox::stateChanged, this, + [this](const int &v) { + serverConfig().setSwitchCorner(BaseConfig::BottomRight, v); + onChange(); + }); + connect( + m_pSpinBoxSwitchCornerSize, + static_cast(&QSpinBox::valueChanged), this, + [this](const int &v) { + serverConfig().setSwitchCornerSize(v); + onChange(); + }); // config - connect(m_pCheckBoxUseExternalConfig, &QCheckBox::stateChanged, this, - [this](const int &v) { - serverConfig().setUseExternalConfig(v); - onChange(); - }); + connect( + m_pCheckBoxUseExternalConfig, &QCheckBox::stateChanged, this, + [this](const int &v) { + serverConfig().setUseExternalConfig(v); + onChange(); + }); connect(m_pEditConfigFile, &QLineEdit::textChanged, this, [this]() { serverConfig().setConfigFile(m_pEditConfigFile->text()); onChange(); @@ -441,6 +464,6 @@ void ServerConfigDialog::onChange() { serverConfig().getUseExternalConfig() && m_OrigServerAppConfigExternalConfigFile == serverConfig().getConfigFile(); m_pButtonBox->button(QDialogButtonBox::Ok) - ->setEnabled(!isAppConfigDataEqual || - !(m_OrigServerConfig == m_ServerConfig)); + ->setEnabled( + !isAppConfigDataEqual || !(m_OrigServerConfig == m_ServerConfig)); } diff --git a/src/gui/src/ServerConfigDialog.h b/src/gui/src/ServerConfigDialog.h index 4650811d8..31722f753 100644 --- a/src/gui/src/ServerConfigDialog.h +++ b/src/gui/src/ServerConfigDialog.h @@ -32,8 +32,8 @@ class ServerConfigDialog : public QDialog, public Ui::ServerConfigDialogBase { Q_OBJECT public: - ServerConfigDialog(QWidget *parent, ServerConfig &config, - AppConfig &appConfig); + ServerConfigDialog( + QWidget *parent, ServerConfig &config, AppConfig &appConfig); bool addClient(const QString &clientName); public slots: diff --git a/src/gui/src/ServerConnection.cpp b/src/gui/src/ServerConnection.cpp index 8e8d62db3..2528a2b25 100644 --- a/src/gui/src/ServerConnection.cpp +++ b/src/gui/src/ServerConnection.cpp @@ -55,8 +55,8 @@ void ServerConnection::addClient(const QString &clientName) { checkMainWindow()) { QMessageBox message(&m_parent); message.addButton(QObject::tr("Ignore"), QMessageBox::RejectRole); - message.addButton(QObject::tr("Accept and configure"), - QMessageBox::AcceptRole); + message.addButton( + QObject::tr("Accept and configure"), QMessageBox::AcceptRole); message.setText( QObject::tr("%1 client has made a connection request").arg(clientName)); @@ -69,8 +69,8 @@ void ServerConnection::addClient(const QString &clientName) { } void ServerConnection::configureClient(const QString &clientName) { - ServerConfigDialog dlg(&m_parent, m_parent.serverConfig(), - m_parent.appConfig()); + ServerConfigDialog dlg( + &m_parent, m_parent.serverConfig(), m_parent.appConfig()); if (dlg.addClient(clientName) && dlg.exec() == QDialog::Accepted) { m_parent.restartSynergy(); diff --git a/src/gui/src/ServerMessage.cpp b/src/gui/src/ServerMessage.cpp index 96810ce1e..4b58af082 100644 --- a/src/gui/src/ServerMessage.cpp +++ b/src/gui/src/ServerMessage.cpp @@ -18,7 +18,8 @@ #include "ServerMessage.h" ServerMessage::ServerMessage(const QString &message) - : m_message(message), m_clienName(parseClientName(message)) {} + : m_message(message), + m_clienName(parseClientName(message)) {} bool ServerMessage::isNewClientMessage() const { return m_message.contains("unrecognised client name"); diff --git a/src/gui/src/SettingsDialog.cpp b/src/gui/src/SettingsDialog.cpp index e8b40c9cd..f28117bde 100644 --- a/src/gui/src/SettingsDialog.cpp +++ b/src/gui/src/SettingsDialog.cpp @@ -34,7 +34,8 @@ SettingsDialog::SettingsDialog(QWidget *parent, AppConfig &config) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), - Ui::SettingsDialogBase(), m_appConfig(config) { + Ui::SettingsDialogBase(), + m_appConfig(config) { setupUi(this); // TODO: maybe just accept MainWindow type in ctor? @@ -52,28 +53,34 @@ SettingsDialog::SettingsDialog(QWidget *parent, AppConfig &config) m_pLineEditScreenName->setValidator(new validators::ScreenNameValidator( m_pLineEditScreenName, m_pLabelNameError, (&serveConfig.screens()))); - connect(m_pLineEditLogFilename, SIGNAL(textChanged(QString)), this, - SLOT(onChange())); - connect(m_pComboLogLevel, SIGNAL(currentIndexChanged(int)), this, - SLOT(onChange())); - connect(m_pLineEditCertificatePath, SIGNAL(textChanged(QString)), this, - SLOT(onChange())); + connect( + m_pLineEditLogFilename, SIGNAL(textChanged(QString)), this, + SLOT(onChange())); + connect( + m_pComboLogLevel, SIGNAL(currentIndexChanged(int)), this, + SLOT(onChange())); + connect( + m_pLineEditCertificatePath, SIGNAL(textChanged(QString)), this, + SLOT(onChange())); connect(m_pCheckBoxMinimizeToTray, SIGNAL(clicked()), this, SLOT(onChange())); connect(m_pCheckBoxAutoHide, SIGNAL(clicked()), this, SLOT(onChange())); connect(m_pCheckBoxPreventSleep, SIGNAL(clicked()), this, SLOT(onChange())); - connect(m_pLineEditInterface, SIGNAL(textEdited(QString)), this, - SLOT(onChange())); + connect( + m_pLineEditInterface, SIGNAL(textEdited(QString)), this, + SLOT(onChange())); connect(m_pSpinBoxPort, SIGNAL(valueChanged(int)), this, SLOT(onChange())); - connect(m_pLineEditScreenName, SIGNAL(textEdited(QString)), this, - SLOT(onChange())); - connect(m_pComboElevate, SIGNAL(currentIndexChanged(int)), this, - SLOT(onChange())); + connect( + m_pLineEditScreenName, SIGNAL(textEdited(QString)), this, + SLOT(onChange())); + connect( + m_pComboElevate, SIGNAL(currentIndexChanged(int)), this, + SLOT(onChange())); connect(m_pCheckBoxLanguageSync, SIGNAL(clicked()), this, SLOT(onChange())); - connect(m_pCheckBoxScrollDirection, SIGNAL(clicked()), this, - SLOT(onChange())); + connect( + m_pCheckBoxScrollDirection, SIGNAL(clicked()), this, SLOT(onChange())); connect(m_pCheckBoxClientHostMode, SIGNAL(clicked()), this, SLOT(onChange())); - connect(m_pCheckBoxServerClientMode, SIGNAL(clicked()), this, - SLOT(onChange())); + connect( + m_pCheckBoxServerClientMode, SIGNAL(clicked()), this, SLOT(onChange())); adjustSize(); } @@ -266,8 +273,8 @@ void SettingsDialog::updateRegenButton() { // NOR the above bools, if any have changed regen should be disabled as it // will be done on save auto nor = !(keyChanged || pathChanged); - m_pPushButtonRegenCert->setEnabled(nor && - m_pCheckBoxEnableCrypto->isChecked()); + m_pPushButtonRegenCert->setEnabled( + nor && m_pCheckBoxEnableCrypto->isChecked()); } void SettingsDialog::on_m_pPushButtonRegenCert_clicked() { diff --git a/src/gui/src/SettingsDialog.h b/src/gui/src/SettingsDialog.h index 160ca1a71..d0af1287d 100644 --- a/src/gui/src/SettingsDialog.h +++ b/src/gui/src/SettingsDialog.h @@ -34,10 +34,10 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase { public: SettingsDialog(QWidget *parent, AppConfig &config); - static QString browseForSynergyc(QWidget *parent, const QString &programDir, - const QString &synergycName); - static QString browseForSynergys(QWidget *parent, const QString &programDir, - const QString &synergysName); + static QString browseForSynergyc( + QWidget *parent, const QString &programDir, const QString &synergycName); + static QString browseForSynergys( + QWidget *parent, const QString &programDir, const QString &synergysName); protected: void accept() override; diff --git a/src/gui/src/SetupWizard.cpp b/src/gui/src/SetupWizard.cpp index 41121bcae..07d6ebf9d 100644 --- a/src/gui/src/SetupWizard.cpp +++ b/src/gui/src/SetupWizard.cpp @@ -27,8 +27,9 @@ SetupWizard::SetupWizard(MainWindow &mainWindow) : m_MainWindow(mainWindow) { new validators::ScreenNameValidator(m_pLineEditName, label_ErrorMessage)); connect(m_pButtonApply, SIGNAL(clicked()), this, SLOT(accept())); - connect(m_pLineEditName, SIGNAL(textEdited(QString)), this, - SLOT(onNameChanged())); + connect( + m_pLineEditName, SIGNAL(textEdited(QString)), this, + SLOT(onNameChanged())); } void SetupWizard::accept() { diff --git a/src/gui/src/SetupWizardBlocker.cpp b/src/gui/src/SetupWizardBlocker.cpp index 87906b2a1..3fc0954bd 100644 --- a/src/gui/src/SetupWizardBlocker.cpp +++ b/src/gui/src/SetupWizardBlocker.cpp @@ -32,8 +32,8 @@ static const std::vector blockerText = { "Please switch to Xorg if you wish to continue using Synergy today.", }; -SetupWizardBlocker::SetupWizardBlocker(MainWindow &mainWindow, - qBlockerType type) +SetupWizardBlocker::SetupWizardBlocker( + MainWindow &mainWindow, qBlockerType type) : m_MainWindow(mainWindow) { setupUi(this); @@ -41,10 +41,12 @@ SetupWizardBlocker::SetupWizardBlocker(MainWindow &mainWindow, label_HelpInfo->setText(blockerText[static_cast(type)]); - connect(m_pButtonSupport, &QPushButton::released, this, - &SetupWizardBlocker::onlineSupport); - connect(m_pButtonCancel, &QPushButton::released, this, - &SetupWizardBlocker::cancel); + connect( + m_pButtonSupport, &QPushButton::released, this, + &SetupWizardBlocker::onlineSupport); + connect( + m_pButtonCancel, &QPushButton::released, this, + &SetupWizardBlocker::cancel); } void SetupWizardBlocker::onlineSupport() { diff --git a/src/gui/src/SslCertificate.cpp b/src/gui/src/SslCertificate.cpp index e177a0bde..98224cde8 100644 --- a/src/gui/src/SslCertificate.cpp +++ b/src/gui/src/SslCertificate.cpp @@ -85,9 +85,8 @@ bool SslCertificate::runTool(const QStringList &args) { return true; } -void SslCertificate::generateCertificate(const QString &path, - const QString &keyLength, - bool forceGen) { +void SslCertificate::generateCertificate( + const QString &path, const QString &keyLength, bool forceGen) { QString sslDirPath = QString("%1%2%3").arg(m_ProfileDir).arg(QDir::separator()).arg(kSslDir); diff --git a/src/gui/src/SslCertificate.h b/src/gui/src/SslCertificate.h index 0d1b33136..9efea6db5 100644 --- a/src/gui/src/SslCertificate.h +++ b/src/gui/src/SslCertificate.h @@ -34,9 +34,9 @@ public slots: /// @param [in] QString keyLength The size of the private key. default: 2048 /// @param [in] bool Should the file be created regardless of if the file /// already exists - void generateCertificate(const QString &path = QString(), - const QString &keyLength = "2048", - bool forceGen = false); + void generateCertificate( + const QString &path = QString(), const QString &keyLength = "2048", + bool forceGen = false); /// @brief Get the key length of a TLS private key /// @param [in] QString path The path of the file to checked diff --git a/src/gui/src/TrayIcon.cpp b/src/gui/src/TrayIcon.cpp index bf4ef9ddd..35c9940c9 100644 --- a/src/gui/src/TrayIcon.cpp +++ b/src/gui/src/TrayIcon.cpp @@ -9,8 +9,9 @@ void TrayIcon::tryCreate() const { // underlying DBus connection // (on DBus) m_pTrayIcon->show(); - m_connector(m_pTrayIcon.get(), - SIGNAL(activated(QSystemTrayIcon::ActivationReason))); + m_connector( + m_pTrayIcon.get(), + SIGNAL(activated(QSystemTrayIcon::ActivationReason))); } else { QTimer::singleShot(2500, this, &TrayIcon::tryCreate); } diff --git a/src/gui/src/TrayIcon.h b/src/gui/src/TrayIcon.h index 0a5c77395..00487a80f 100644 --- a/src/gui/src/TrayIcon.h +++ b/src/gui/src/TrayIcon.h @@ -18,8 +18,8 @@ public: } template - void create(TActionContainer const &actionContainer, - TConnector const &connector) { + void + create(TActionContainer const &actionContainer, TConnector const &connector) { m_connector = connector; m_pTrayIconMenu = std::make_unique(); diff --git a/src/gui/src/UpgradeDialog.cpp b/src/gui/src/UpgradeDialog.cpp index 6c34f8998..8a7bb6e73 100644 --- a/src/gui/src/UpgradeDialog.cpp +++ b/src/gui/src/UpgradeDialog.cpp @@ -29,7 +29,8 @@ void UpgradeDialog::showDialog(const QString &text) { setText(QObject::tr(text.toStdString().c_str())); if (exec() == QMessageBox::Accepted) { - QDesktopServices::openUrl(QUrl(QCoreApplication::organizationDomain() + - "/synergy/purchase/upgrade?source=gui")); + QDesktopServices::openUrl(QUrl( + QCoreApplication::organizationDomain() + + "/synergy/purchase/upgrade?source=gui")); } } diff --git a/src/gui/src/VersionChecker.cpp b/src/gui/src/VersionChecker.cpp index a2ce822aa..26d176262 100644 --- a/src/gui/src/VersionChecker.cpp +++ b/src/gui/src/VersionChecker.cpp @@ -28,18 +28,20 @@ VersionChecker::VersionChecker(std::shared_ptr nam) : m_manager(nam ? nam : std::make_shared(this)) { - connect(m_manager.get(), SIGNAL(finished(QNetworkReply *)), this, - SLOT(replyFinished(QNetworkReply *))); + connect( + m_manager.get(), SIGNAL(finished(QNetworkReply *)), this, + SLOT(replyFinished(QNetworkReply *))); } void VersionChecker::checkLatest() { auto request = QNetworkRequest(QUrl(SYNERGY_VERSION_URL)); - request.setHeader(QNetworkRequest::UserAgentHeader, - QString("Synergy (") + SYNERGY_VERSION + ") " + - QSysInfo::prettyProductName()); + request.setHeader( + QNetworkRequest::UserAgentHeader, QString("Synergy (") + SYNERGY_VERSION + + ") " + + QSysInfo::prettyProductName()); request.setRawHeader("X-Synergy-Version", SYNERGY_VERSION); - request.setRawHeader("X-Synergy-Language", - QLocale::system().name().toStdString().c_str()); + request.setRawHeader( + "X-Synergy-Language", QLocale::system().name().toStdString().c_str()); m_manager->get(request); } diff --git a/src/gui/src/main.cpp b/src/gui/src/main.cpp index 2eaef7bd2..1b8d6e1f4 100644 --- a/src/gui/src/main.cpp +++ b/src/gui/src/main.cpp @@ -66,9 +66,10 @@ int main(int argc, char *argv[]) { #if defined(Q_OS_MAC) if (app.applicationDirPath().startsWith("/Volumes/")) { - QMessageBox::information(NULL, "Synergy", - "Please drag Synergy to the Applications folder, " - "and open it from there."); + QMessageBox::information( + NULL, "Synergy", + "Please drag Synergy to the Applications folder, " + "and open it from there."); return 1; } @@ -93,8 +94,9 @@ int main(int argc, char *argv[]) { MainWindow mainWindow(appConfig); #endif - QObject::connect(dynamic_cast(&app), SIGNAL(aboutToQuit()), - &mainWindow, SLOT(saveSettings())); + QObject::connect( + dynamic_cast(&app), SIGNAL(aboutToQuit()), &mainWindow, + SLOT(saveSettings())); std::unique_ptr setupBlocker; if (qgetenv("XDG_SESSION_TYPE") == "wayland") { @@ -143,10 +145,11 @@ bool checkMacAssistiveDevices() { // now deprecated in mavericks. bool result = AXAPIEnabled(); if (!result) { - QMessageBox::information(NULL, "Synergy", - "Please enable access to assistive devices " - "System Preferences -> Security & Privacy -> " - "Privacy -> Accessibility, then re-open Synergy."); + QMessageBox::information( + NULL, "Synergy", + "Please enable access to assistive devices " + "System Preferences -> Security & Privacy -> " + "Privacy -> Accessibility, then re-open Synergy."); } return result; diff --git a/src/gui/src/validators/AliasValidator.h b/src/gui/src/validators/AliasValidator.h index 1ed40758b..f8bdfe73a 100644 --- a/src/gui/src/validators/AliasValidator.h +++ b/src/gui/src/validators/AliasValidator.h @@ -24,8 +24,8 @@ namespace validators { class AliasValidator : public LineEditValidator { public: - explicit AliasValidator(QLineEdit *parent = nullptr, - QLabel *errors = nullptr); + explicit AliasValidator( + QLineEdit *parent = nullptr, QLabel *errors = nullptr); }; } // namespace validators diff --git a/src/gui/src/validators/ComputerNameValidator.cpp b/src/gui/src/validators/ComputerNameValidator.cpp index 5c99b950b..d5bbd34a7 100644 --- a/src/gui/src/validators/ComputerNameValidator.cpp +++ b/src/gui/src/validators/ComputerNameValidator.cpp @@ -25,8 +25,8 @@ ComputerNameValidator::ComputerNameValidator(const QString &message) : IStringValidator(message) {} bool ComputerNameValidator::validate(const QString &input) const { - const QRegularExpression re("^[\\w\\._-]{0,255}$", - QRegularExpression::CaseInsensitiveOption); + const QRegularExpression re( + "^[\\w\\._-]{0,255}$", QRegularExpression::CaseInsensitiveOption); auto match = re.match(input); auto result = match.hasMatch(); return result; diff --git a/src/gui/src/validators/LineEditValidator.cpp b/src/gui/src/validators/LineEditValidator.cpp index 8cc2692ea..7604437c4 100644 --- a/src/gui/src/validators/LineEditValidator.cpp +++ b/src/gui/src/validators/LineEditValidator.cpp @@ -20,7 +20,8 @@ namespace validators { LineEditValidator::LineEditValidator(QLineEdit *parent, QLabel *errors) - : m_pErrors(errors), m_pControl(parent) { + : m_pErrors(errors), + m_pControl(parent) { if (m_pErrors) { m_pErrors->hide(); } diff --git a/src/gui/src/validators/LineEditValidator.h b/src/gui/src/validators/LineEditValidator.h index d72338b8e..c7c87aa0e 100644 --- a/src/gui/src/validators/LineEditValidator.h +++ b/src/gui/src/validators/LineEditValidator.h @@ -31,8 +31,8 @@ namespace validators { class LineEditValidator : public QValidator { public: - explicit LineEditValidator(QLineEdit *parent = nullptr, - QLabel *errors = nullptr); + explicit LineEditValidator( + QLineEdit *parent = nullptr, QLabel *errors = nullptr); QValidator::State validate(QString &input, int &pos) const override; void addValidator(std::unique_ptr validator); diff --git a/src/gui/src/validators/ScreenDuplicationsValidator.cpp b/src/gui/src/validators/ScreenDuplicationsValidator.cpp index 4bb9213e0..7e9545c1b 100644 --- a/src/gui/src/validators/ScreenDuplicationsValidator.cpp +++ b/src/gui/src/validators/ScreenDuplicationsValidator.cpp @@ -22,7 +22,8 @@ namespace validators { ScreenDuplicationsValidator::ScreenDuplicationsValidator( const QString &message, const QString &defaultName, const ScreenList *pScreens) - : IStringValidator(message), m_defaultName(defaultName), + : IStringValidator(message), + m_defaultName(defaultName), m_pScreenList(pScreens) {} bool ScreenDuplicationsValidator::validate(const QString &input) const { diff --git a/src/gui/src/validators/ScreenDuplicationsValidator.h b/src/gui/src/validators/ScreenDuplicationsValidator.h index 6fb37d81b..075048977 100644 --- a/src/gui/src/validators/ScreenDuplicationsValidator.h +++ b/src/gui/src/validators/ScreenDuplicationsValidator.h @@ -28,9 +28,9 @@ class ScreenDuplicationsValidator : public IStringValidator { const ScreenList *m_pScreenList = nullptr; public: - ScreenDuplicationsValidator(const QString &message, - const QString &defaultName, - const ScreenList *pScreens); + ScreenDuplicationsValidator( + const QString &message, const QString &defaultName, + const ScreenList *pScreens); bool validate(const QString &input) const override; }; diff --git a/src/gui/src/validators/ScreenNameValidator.cpp b/src/gui/src/validators/ScreenNameValidator.cpp index 5a7f6564a..a505c1d5d 100644 --- a/src/gui/src/validators/ScreenNameValidator.cpp +++ b/src/gui/src/validators/ScreenNameValidator.cpp @@ -27,8 +27,8 @@ namespace validators { -ScreenNameValidator::ScreenNameValidator(QLineEdit *parent, QLabel *errors, - const ScreenList *pScreens) +ScreenNameValidator::ScreenNameValidator( + QLineEdit *parent, QLabel *errors, const ScreenList *pScreens) : LineEditValidator(parent, errors) { addValidator( std::make_unique("Computer name cannot be empty")); diff --git a/src/gui/src/validators/ScreenNameValidator.h b/src/gui/src/validators/ScreenNameValidator.h index 87032c383..f34dabd55 100644 --- a/src/gui/src/validators/ScreenNameValidator.h +++ b/src/gui/src/validators/ScreenNameValidator.h @@ -25,9 +25,9 @@ namespace validators { class ScreenNameValidator : public LineEditValidator { public: - explicit ScreenNameValidator(QLineEdit *parent = nullptr, - QLabel *errors = nullptr, - const ScreenList *pScreens = nullptr); + explicit ScreenNameValidator( + QLineEdit *parent = nullptr, QLabel *errors = nullptr, + const ScreenList *pScreens = nullptr); }; } // namespace validators diff --git a/src/gui/src/widgets/ClientStateLabel.cpp b/src/gui/src/widgets/ClientStateLabel.cpp index c2f21c442..d0140dfc9 100644 --- a/src/gui/src/widgets/ClientStateLabel.cpp +++ b/src/gui/src/widgets/ClientStateLabel.cpp @@ -24,8 +24,9 @@ ClientStateLabel::ClientStateLabel(QWidget *parent) : QLabel(parent) { hide(); } void ClientStateLabel::updateClientState(const QString &line) { if (line.contains("connected to server")) { show(); - } else if (line.contains("disconnected from server") || - line.contains("process exited")) { + } else if ( + line.contains("disconnected from server") || + line.contains("process exited")) { hide(); } } diff --git a/src/lib/arch/ArchDaemonNone.cpp b/src/lib/arch/ArchDaemonNone.cpp index 3c49ff5f9..14510bd21 100644 --- a/src/lib/arch/ArchDaemonNone.cpp +++ b/src/lib/arch/ArchDaemonNone.cpp @@ -30,8 +30,8 @@ ArchDaemonNone::~ArchDaemonNone() { // do nothing } -void ArchDaemonNone::installDaemon(const char *, const char *, const char *, - const char *, const char *) { +void ArchDaemonNone::installDaemon( + const char *, const char *, const char *, const char *, const char *) { // do nothing } diff --git a/src/lib/arch/ArchDaemonNone.h b/src/lib/arch/ArchDaemonNone.h index e2210f419..e0adfbdd9 100644 --- a/src/lib/arch/ArchDaemonNone.h +++ b/src/lib/arch/ArchDaemonNone.h @@ -35,9 +35,9 @@ public: virtual ~ArchDaemonNone(); // IArchDaemon overrides - virtual void installDaemon(const char *name, const char *description, - const char *pathname, const char *commandLine, - const char *dependencies); + virtual void installDaemon( + const char *name, const char *description, const char *pathname, + const char *commandLine, const char *dependencies); virtual void uninstallDaemon(const char *name); virtual int daemonize(const char *name, DaemonFunc func); virtual bool canInstallDaemon(const char *name); diff --git a/src/lib/arch/IArchDaemon.h b/src/lib/arch/IArchDaemon.h index 806eaff0c..c496b785a 100644 --- a/src/lib/arch/IArchDaemon.h +++ b/src/lib/arch/IArchDaemon.h @@ -47,9 +47,9 @@ public: followed by a NUL; the daemon will be configured to startup after the listed daemons. Throws an \c XArchDaemon exception on failure. */ - virtual void installDaemon(const char *name, const char *description, - const char *pathname, const char *commandLine, - const char *dependencies) = 0; + virtual void installDaemon( + const char *name, const char *description, const char *pathname, + const char *commandLine, const char *dependencies) = 0; //! Uninstall daemon /*! diff --git a/src/lib/arch/IArchFile.h b/src/lib/arch/IArchFile.h index d41213bb8..50148cbe0 100644 --- a/src/lib/arch/IArchFile.h +++ b/src/lib/arch/IArchFile.h @@ -85,8 +85,8 @@ public: is longer than allowed by the system; we'll rely on the system calls to tell us that. */ - virtual std::string concatPath(const std::string &prefix, - const std::string &suffix) = 0; + virtual std::string + concatPath(const std::string &prefix, const std::string &suffix) = 0; //@} //! Set the user's profile directory diff --git a/src/lib/arch/IArchString.cpp b/src/lib/arch/IArchString.cpp index 9c1cb63ac..e89fbd4b5 100644 --- a/src/lib/arch/IArchString.cpp +++ b/src/lib/arch/IArchString.cpp @@ -37,8 +37,8 @@ IArchString::~IArchString() { } } -int IArchString::convStringWCToMB(char *dst, const wchar_t *src, UInt32 n, - bool *errors) { +int IArchString::convStringWCToMB( + char *dst, const wchar_t *src, UInt32 n, bool *errors) { ptrdiff_t len = 0; bool dummyErrors; @@ -94,8 +94,8 @@ int IArchString::convStringWCToMB(char *dst, const wchar_t *src, UInt32 n, return static_cast(len); } -int IArchString::convStringMBToWC(wchar_t *dst, const char *src, UInt32 n, - bool *errors) { +int IArchString::convStringMBToWC( + wchar_t *dst, const char *src, UInt32 n, bool *errors) { ptrdiff_t len = 0; wchar_t dummy; diff --git a/src/lib/arch/IArchSystem.h b/src/lib/arch/IArchSystem.h index 5ee5de346..b443e808f 100644 --- a/src/lib/arch/IArchSystem.h +++ b/src/lib/arch/IArchSystem.h @@ -54,7 +54,7 @@ public: /*! Writes a Synergy setting from the system. */ - virtual void setting(const std::string &valueName, - const std::string &valueString) const = 0; + virtual void setting( + const std::string &valueName, const std::string &valueString) const = 0; //@} }; diff --git a/src/lib/arch/unix/ArchFileUnix.cpp b/src/lib/arch/unix/ArchFileUnix.cpp index 9167a8480..065872e5a 100644 --- a/src/lib/arch/unix/ArchFileUnix.cpp +++ b/src/lib/arch/unix/ArchFileUnix.cpp @@ -113,8 +113,8 @@ std::string ArchFileUnix::getProfileDirectory() { return dir; } -std::string ArchFileUnix::concatPath(const std::string &prefix, - const std::string &suffix) { +std::string +ArchFileUnix::concatPath(const std::string &prefix, const std::string &suffix) { std::string path; path.reserve(prefix.size() + 1 + suffix.size()); path += prefix; diff --git a/src/lib/arch/unix/ArchFileUnix.h b/src/lib/arch/unix/ArchFileUnix.h index 8c5938989..a2098f7fd 100644 --- a/src/lib/arch/unix/ArchFileUnix.h +++ b/src/lib/arch/unix/ArchFileUnix.h @@ -36,8 +36,8 @@ public: virtual std::string getLogDirectory(); virtual std::string getPluginDirectory(); virtual std::string getProfileDirectory(); - virtual std::string concatPath(const std::string &prefix, - const std::string &suffix); + virtual std::string + concatPath(const std::string &prefix, const std::string &suffix); virtual void setProfileDirectory(const String &s); virtual void setPluginDirectory(const String &s); diff --git a/src/lib/arch/unix/ArchMultithreadPosix.cpp b/src/lib/arch/unix/ArchMultithreadPosix.cpp index da9aa397a..c000a42e7 100644 --- a/src/lib/arch/unix/ArchMultithreadPosix.cpp +++ b/src/lib/arch/unix/ArchMultithreadPosix.cpp @@ -77,8 +77,14 @@ public: }; ArchThreadImpl::ArchThreadImpl() - : m_refCount(1), m_id(0), m_func(NULL), m_userData(NULL), m_cancel(false), - m_cancelling(false), m_exited(false), m_result(NULL), + : m_refCount(1), + m_id(0), + m_func(NULL), + m_userData(NULL), + m_cancel(false), + m_cancelling(false), + m_exited(false), + m_result(NULL), m_networkData(NULL) { // do nothing } @@ -90,7 +96,8 @@ ArchThreadImpl::ArchThreadImpl() ArchMultithreadPosix *ArchMultithreadPosix::s_instance = NULL; ArchMultithreadPosix::ArchMultithreadPosix() - : m_newThreadCalled(false), m_nextID(0) { + : m_newThreadCalled(false), + m_nextID(0) { assert(s_instance == NULL); s_instance = this; @@ -186,8 +193,8 @@ void ArchMultithreadPosix::broadcastCondVar(ArchCond cond) { assert(status == 0); } -bool ArchMultithreadPosix::waitCondVar(ArchCond cond, ArchMutex mutex, - double timeout) { +bool ArchMultithreadPosix::waitCondVar( + ArchCond cond, ArchMutex mutex, double timeout) { // we can't wait on a condition variable and also wake it up for // cancellation since we don't use posix cancellation. so we // must wake up periodically to check for cancellation. we @@ -326,8 +333,8 @@ ArchThread ArchMultithreadPosix::newThread(ThreadFunc func, void *data) { pthread_attr_t attr; int status = pthread_attr_init(&attr); if (status == 0) { - status = pthread_create(&thread->m_thread, &attr, - &ArchMultithreadPosix::threadFunc, thread); + status = pthread_create( + &thread->m_thread, &attr, &ArchMultithreadPosix::threadFunc, thread); pthread_attr_destroy(&attr); } @@ -471,8 +478,8 @@ bool ArchMultithreadPosix::wait(ArchThread target, double timeout) { } } -bool ArchMultithreadPosix::isSameThread(ArchThread thread1, - ArchThread thread2) { +bool ArchMultithreadPosix::isSameThread( + ArchThread thread1, ArchThread thread2) { return (thread1 == thread2); } @@ -495,8 +502,8 @@ ArchMultithreadPosix::getIDOfThread(ArchThread thread) { return thread->m_id; } -void ArchMultithreadPosix::setSignalHandler(ESignal signal, SignalFunc func, - void *userData) { +void ArchMultithreadPosix::setSignalHandler( + ESignal signal, SignalFunc func, void *userData) { lockMutex(m_threadMutex); m_signalFunc[signal] = func; m_signalUserData[signal] = userData; @@ -528,8 +535,9 @@ void ArchMultithreadPosix::startSignalHandler() { pthread_attr_t attr; int status = pthread_attr_init(&attr); if (status == 0) { - status = pthread_create(&m_signalThread, &attr, - &ArchMultithreadPosix::threadSignalHandler, NULL); + status = pthread_create( + &m_signalThread, &attr, &ArchMultithreadPosix::threadSignalHandler, + NULL); pthread_attr_destroy(&attr); } if (status != 0) { diff --git a/src/lib/arch/unix/ArchNetworkBSD.cpp b/src/lib/arch/unix/ArchNetworkBSD.cpp index 5389307f9..657aaac05 100644 --- a/src/lib/arch/unix/ArchNetworkBSD.cpp +++ b/src/lib/arch/unix/ArchNetworkBSD.cpp @@ -406,9 +406,10 @@ int ArchNetworkBSD::pollSocket(PollEntry pe[], int num, double timeout) { } // do the select - n = select((SELECT_TYPE_ARG1)n + 1, SELECT_TYPE_ARG234 readSetP, - SELECT_TYPE_ARG234 writeSetP, SELECT_TYPE_ARG234 errSetP, - SELECT_TYPE_ARG5 timeout2P); + n = select( + (SELECT_TYPE_ARG1)n + 1, SELECT_TYPE_ARG234 readSetP, + SELECT_TYPE_ARG234 writeSetP, SELECT_TYPE_ARG234 errSetP, + SELECT_TYPE_ARG5 timeout2P); // reset the unblock pipe if (n > 0 && unblockPipe != NULL && FD_ISSET(unblockPipe[0], &readSet)) { @@ -493,8 +494,9 @@ void ArchNetworkBSD::throwErrorOnSocket(ArchSocket s) { // get the error from the socket layer int err = 0; auto size = static_cast(sizeof(err)); - if (getsockopt(s->m_fd, SOL_SOCKET, SO_ERROR, - reinterpret_cast(&err), &size) == -1) { + if (getsockopt( + s->m_fd, SOL_SOCKET, SO_ERROR, reinterpret_cast(&err), + &size) == -1) { err = errno; } @@ -527,15 +529,17 @@ bool ArchNetworkBSD::setNoDelayOnSocket(ArchSocket s, bool noDelay) { // get old state int oflag; auto size = static_cast(sizeof(oflag)); - if (getsockopt(s->m_fd, IPPROTO_TCP, TCP_NODELAY, - reinterpret_cast(&oflag), &size) == -1) { + if (getsockopt( + s->m_fd, IPPROTO_TCP, TCP_NODELAY, + reinterpret_cast(&oflag), &size) == -1) { throwError(errno); } int flag = noDelay ? 1 : 0; size = static_cast(sizeof(flag)); - if (setsockopt(s->m_fd, IPPROTO_TCP, TCP_NODELAY, - reinterpret_cast(&flag), size) == -1) { + if (setsockopt( + s->m_fd, IPPROTO_TCP, TCP_NODELAY, + reinterpret_cast(&flag), size) == -1) { throwError(errno); } @@ -548,15 +552,17 @@ bool ArchNetworkBSD::setReuseAddrOnSocket(ArchSocket s, bool reuse) { // get old state int oflag; auto size = static_cast(sizeof(oflag)); - if (getsockopt(s->m_fd, SOL_SOCKET, SO_REUSEADDR, - reinterpret_cast(&oflag), &size) == -1) { + if (getsockopt( + s->m_fd, SOL_SOCKET, SO_REUSEADDR, + reinterpret_cast(&oflag), &size) == -1) { throwError(errno); } int flag = reuse ? 1 : 0; size = static_cast(sizeof(flag)); - if (setsockopt(s->m_fd, SOL_SOCKET, SO_REUSEADDR, - reinterpret_cast(&flag), size) == -1) { + if (setsockopt( + s->m_fd, SOL_SOCKET, SO_REUSEADDR, + reinterpret_cast(&flag), size) == -1) { throwError(errno); } @@ -648,8 +654,8 @@ ArchNetworkBSD::nameToAddr(const std::string &name) { addresses.back()->m_len = (socklen_t)sizeof(struct sockaddr_in6); } - memcpy(&addresses.back()->m_addr, address->ai_addr, - addresses.back()->m_len); + memcpy( + &addresses.back()->m_addr, address->ai_addr, addresses.back()->m_len); } freeaddrinfo(pResult); @@ -671,8 +677,9 @@ std::string ArchNetworkBSD::addrToName(ArchNetAddress addr) { ARCH->lockMutex(m_mutex); char host[1024]; char service[20]; - int ret = getnameinfo(TYPED_ADDR(struct sockaddr, addr), addr->m_len, host, - sizeof(host), service, sizeof(service), 0); + int ret = getnameinfo( + TYPED_ADDR(struct sockaddr, addr), addr->m_len, host, sizeof(host), + service, sizeof(service), 0); if (ret != 0) { ARCH->unlockMutex(m_mutex); throwNameError(ret); @@ -777,16 +784,18 @@ bool ArchNetworkBSD::isAnyAddr(ArchNetAddress addr) { switch (getAddrFamily(addr)) { case kINET: { auto *ipAddr = TYPED_ADDR(struct sockaddr_in, addr); - return (ipAddr->sin_addr.s_addr == INADDR_ANY && - addr->m_len == static_cast(sizeof(struct sockaddr_in))); + return ( + ipAddr->sin_addr.s_addr == INADDR_ANY && + addr->m_len == static_cast(sizeof(struct sockaddr_in))); } case kINET6: { struct sockaddr_in6 *ipAddr = TYPED_ADDR(struct sockaddr_in6, addr); - return (addr->m_len == (socklen_t)sizeof(struct sockaddr_in6) && - memcmp(static_cast(&ipAddr->sin6_addr), - static_cast(&in6addr_any), - sizeof(in6_addr)) == 0); + return ( + addr->m_len == (socklen_t)sizeof(struct sockaddr_in6) && + memcmp( + static_cast(&ipAddr->sin6_addr), + static_cast(&in6addr_any), sizeof(in6_addr)) == 0); } default: @@ -796,8 +805,8 @@ bool ArchNetworkBSD::isAnyAddr(ArchNetAddress addr) { } bool ArchNetworkBSD::isEqualAddr(ArchNetAddress a, ArchNetAddress b) { - return (a->m_len == b->m_len && - memcmp(&a->m_addr, &b->m_addr, a->m_len) == 0); + return ( + a->m_len == b->m_len && memcmp(&a->m_addr, &b->m_addr, a->m_len) == 0); } const int *ArchNetworkBSD::getUnblockPipe() { diff --git a/src/lib/arch/unix/ArchSleepUnix.cpp b/src/lib/arch/unix/ArchSleepUnix.cpp index 3c837d941..1f22a13dd 100644 --- a/src/lib/arch/unix/ArchSleepUnix.cpp +++ b/src/lib/arch/unix/ArchSleepUnix.cpp @@ -77,9 +77,9 @@ void ArchSleepUnix::sleep(double timeout) { struct timeval timeout2; timeout2.tv_sec = static_cast(timeLeft); timeout2.tv_usec = static_cast(1.0e+6 * (timeLeft - timeout2.tv_sec)); - select((SELECT_TYPE_ARG1)0, SELECT_TYPE_ARG234 NULL, - SELECT_TYPE_ARG234 NULL, SELECT_TYPE_ARG234 NULL, - SELECT_TYPE_ARG5 & timeout2); + select( + (SELECT_TYPE_ARG1)0, SELECT_TYPE_ARG234 NULL, SELECT_TYPE_ARG234 NULL, + SELECT_TYPE_ARG234 NULL, SELECT_TYPE_ARG5 & timeout2); ARCH->testCancelThread(); timeLeft = timeout - (ARCH->time() - startTime); } diff --git a/src/lib/arch/unix/ArchSystemUnix.cpp b/src/lib/arch/unix/ArchSystemUnix.cpp index dc2216a3c..46094c9dd 100644 --- a/src/lib/arch/unix/ArchSystemUnix.cpp +++ b/src/lib/arch/unix/ArchSystemUnix.cpp @@ -69,13 +69,13 @@ std::string ArchSystemUnix::getLibsUsed(void) const { } #ifndef __APPLE__ -bool ArchSystemUnix::DBusInhibitScreenCall(InhibitScreenServices serviceID, - bool state, std::string &error) { +bool ArchSystemUnix::DBusInhibitScreenCall( + InhibitScreenServices serviceID, bool state, std::string &error) { error = ""; - static const std::array services = {"org.freedesktop.ScreenSaver", - "org.gnome.SessionManager"}; - static const std::array paths = {"/org/freedesktop/ScreenSaver", - "/org/gnome/SessionManager"}; + static const std::array services = { + "org.freedesktop.ScreenSaver", "org.gnome.SessionManager"}; + static const std::array paths = { + "/org/freedesktop/ScreenSaver", "/org/gnome/SessionManager"}; static std::array cookies; auto serviceNum = static_cast(serviceID); @@ -86,8 +86,8 @@ bool ArchSystemUnix::DBusInhibitScreenCall(InhibitScreenServices serviceID, return false; } - QDBusInterface screenSaverInterface(services[serviceNum], paths[serviceNum], - services[serviceNum], bus); + QDBusInterface screenSaverInterface( + services[serviceNum], paths[serviceNum], services[serviceNum], bus); if (!screenSaverInterface.isValid()) { error = "screen saver interface failed to initialize"; diff --git a/src/lib/arch/unix/ArchSystemUnix.h b/src/lib/arch/unix/ArchSystemUnix.h index 377d40671..7737faf79 100644 --- a/src/lib/arch/unix/ArchSystemUnix.h +++ b/src/lib/arch/unix/ArchSystemUnix.h @@ -37,7 +37,7 @@ public: #ifndef __APPLE__ enum class InhibitScreenServices { kScreenSaver, kSessionManager }; - static bool DBusInhibitScreenCall(InhibitScreenServices serviceID, bool state, - std::string &error); + static bool DBusInhibitScreenCall( + InhibitScreenServices serviceID, bool state, std::string &error); #endif }; diff --git a/src/lib/arch/win32/ArchDaemonWindows.cpp b/src/lib/arch/win32/ArchDaemonWindows.cpp index 1b2cc059d..21f8fbcf5 100644 --- a/src/lib/arch/win32/ArchDaemonWindows.cpp +++ b/src/lib/arch/win32/ArchDaemonWindows.cpp @@ -62,10 +62,9 @@ void ArchDaemonWindows::daemonFailed(int result) { throw XArchDaemonRunFailed(result); } -void ArchDaemonWindows::installDaemon(const char *name, const char *description, - const char *pathname, - const char *commandLine, - const char *dependencies) { +void ArchDaemonWindows::installDaemon( + const char *name, const char *description, const char *pathname, + const char *commandLine, const char *dependencies) { // open service manager SC_HANDLE mgr = OpenSCManager(NULL, NULL, GENERIC_WRITE); if (mgr == NULL) { @@ -74,11 +73,11 @@ void ArchDaemonWindows::installDaemon(const char *name, const char *description, } // create the service - SC_HANDLE service = - CreateService(mgr, name, name, 0, - SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, - SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, pathname, NULL, - NULL, dependencies, NULL, NULL); + SC_HANDLE service = CreateService( + mgr, name, name, 0, + SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, + SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, pathname, NULL, NULL, + dependencies, NULL, NULL); if (service == NULL) { // can't create service @@ -255,8 +254,8 @@ bool ArchDaemonWindows::isDaemonInstalled(const char *name) { } HKEY ArchDaemonWindows::openNTServicesKey() { - static const char *s_keyNames[] = {_T("SYSTEM"), _T("CurrentControlSet"), - _T("Services"), NULL}; + static const char *s_keyNames[] = { + _T("SYSTEM"), _T("CurrentControlSet"), _T("Services"), NULL}; return ArchMiscWindows::addKey(HKEY_LOCAL_MACHINE, s_keyNames); } @@ -606,8 +605,8 @@ void ArchDaemonWindows::installDaemon() { ss << path; ss << '"'; - installDaemon(DEFAULT_DAEMON_NAME, DEFAULT_DAEMON_INFO, ss.str().c_str(), - "", ""); + installDaemon( + DEFAULT_DAEMON_NAME, DEFAULT_DAEMON_INFO, ss.str().c_str(), "", ""); } start(DEFAULT_DAEMON_NAME); diff --git a/src/lib/arch/win32/ArchDaemonWindows.h b/src/lib/arch/win32/ArchDaemonWindows.h index bad076e52..0f457bd61 100644 --- a/src/lib/arch/win32/ArchDaemonWindows.h +++ b/src/lib/arch/win32/ArchDaemonWindows.h @@ -75,9 +75,9 @@ public: static UINT getDaemonQuitMessage(); // IArchDaemon overrides - virtual void installDaemon(const char *name, const char *description, - const char *pathname, const char *commandLine, - const char *dependencies); + virtual void installDaemon( + const char *name, const char *description, const char *pathname, + const char *commandLine, const char *dependencies); virtual void uninstallDaemon(const char *name); virtual void installDaemon(); virtual void uninstallDaemon(); diff --git a/src/lib/arch/win32/ArchFileWindows.cpp b/src/lib/arch/win32/ArchFileWindows.cpp index d5a727a04..d8a29c88b 100644 --- a/src/lib/arch/win32/ArchFileWindows.cpp +++ b/src/lib/arch/win32/ArchFileWindows.cpp @@ -155,8 +155,8 @@ std::string ArchFileWindows::getProfileDirectory() { return dir; } -std::string ArchFileWindows::concatPath(const std::string &prefix, - const std::string &suffix) { +std::string ArchFileWindows::concatPath( + const std::string &prefix, const std::string &suffix) { std::string path; path.reserve(prefix.size() + 1 + suffix.size()); path += prefix; diff --git a/src/lib/arch/win32/ArchFileWindows.h b/src/lib/arch/win32/ArchFileWindows.h index 218863def..df4a67091 100644 --- a/src/lib/arch/win32/ArchFileWindows.h +++ b/src/lib/arch/win32/ArchFileWindows.h @@ -36,8 +36,8 @@ public: virtual std::string getLogDirectory(); virtual std::string getPluginDirectory(); virtual std::string getProfileDirectory(); - virtual std::string concatPath(const std::string &prefix, - const std::string &suffix); + virtual std::string + concatPath(const std::string &prefix, const std::string &suffix); virtual void setProfileDirectory(const String &s); virtual void setPluginDirectory(const String &s); diff --git a/src/lib/arch/win32/ArchLogWindows.cpp b/src/lib/arch/win32/ArchLogWindows.cpp index 7006251ac..717b5fb2b 100644 --- a/src/lib/arch/win32/ArchLogWindows.cpp +++ b/src/lib/arch/win32/ArchLogWindows.cpp @@ -74,11 +74,12 @@ void ArchLogWindows::writeLog(ELevel level, const char *msg) { // just dump our string into the raw data section of the event // so users can at least see the message. note that we use our // level as the event category. - ReportEvent(m_eventLog, type, static_cast(level), - 0, // event ID - NULL, 0, - (DWORD)strlen(msg) + 1, // raw data size - NULL, - const_cast(msg)); // raw data + ReportEvent( + m_eventLog, type, static_cast(level), + 0, // event ID + NULL, 0, + (DWORD)strlen(msg) + 1, // raw data size + NULL, + const_cast(msg)); // raw data } } diff --git a/src/lib/arch/win32/ArchMiscWindows.cpp b/src/lib/arch/win32/ArchMiscWindows.cpp index a2f2cf820..0871921d1 100644 --- a/src/lib/arch/win32/ArchMiscWindows.cpp +++ b/src/lib/arch/win32/ArchMiscWindows.cpp @@ -114,8 +114,9 @@ HKEY ArchMiscWindows::openKey(HKEY key, const TCHAR *keyName, bool create) { RegOpenKeyEx(key, keyName, 0, KEY_WRITE | KEY_QUERY_VALUE, &newKey); if (result != ERROR_SUCCESS && create) { DWORD disp; - result = RegCreateKeyEx(key, keyName, 0, NULL, 0, - KEY_WRITE | KEY_QUERY_VALUE, NULL, &newKey, &disp); + result = RegCreateKeyEx( + key, keyName, 0, NULL, 0, KEY_WRITE | KEY_QUERY_VALUE, NULL, &newKey, + &disp); } if (result != ERROR_SUCCESS) { RegCloseKey(key); @@ -127,8 +128,8 @@ HKEY ArchMiscWindows::openKey(HKEY key, const TCHAR *keyName, bool create) { return newKey; } -HKEY ArchMiscWindows::openKey(HKEY key, const TCHAR *const *keyNames, - bool create) { +HKEY ArchMiscWindows::openKey( + HKEY key, const TCHAR *const *keyNames, bool create) { for (size_t i = 0; key != NULL && keyNames[i] != NULL; ++i) { // open next key key = openKey(key, keyNames[i], create); @@ -165,8 +166,8 @@ bool ArchMiscWindows::hasValue(HKEY key, const TCHAR *name) { return (result == ERROR_SUCCESS && (type == REG_DWORD || type == REG_SZ)); } -ArchMiscWindows::EValueType ArchMiscWindows::typeOfValue(HKEY key, - const TCHAR *name) { +ArchMiscWindows::EValueType +ArchMiscWindows::typeOfValue(HKEY key, const TCHAR *name) { DWORD type; LONG result = RegQueryValueEx(key, name, 0, &type, NULL, NULL); if (result != ERROR_SUCCESS) { @@ -187,16 +188,16 @@ ArchMiscWindows::EValueType ArchMiscWindows::typeOfValue(HKEY key, } } -void ArchMiscWindows::setValue(HKEY key, const TCHAR *name, - const std::string &value) { +void ArchMiscWindows::setValue( + HKEY key, const TCHAR *name, const std::string &value) { assert(key != NULL); if (key == NULL) { // TODO: throw exception return; } - RegSetValueEx(key, name, 0, REG_SZ, - reinterpret_cast(value.c_str()), - (DWORD)value.size() + 1); + RegSetValueEx( + key, name, 0, REG_SZ, reinterpret_cast(value.c_str()), + (DWORD)value.size() + 1); } void ArchMiscWindows::setValue(HKEY key, const TCHAR *name, DWORD value) { @@ -205,25 +206,26 @@ void ArchMiscWindows::setValue(HKEY key, const TCHAR *name, DWORD value) { // TODO: throw exception return; } - RegSetValueEx(key, name, 0, REG_DWORD, reinterpret_cast(&value), - sizeof(DWORD)); + RegSetValueEx( + key, name, 0, REG_DWORD, reinterpret_cast(&value), + sizeof(DWORD)); } -void ArchMiscWindows::setValueBinary(HKEY key, const TCHAR *name, - const std::string &value) { +void ArchMiscWindows::setValueBinary( + HKEY key, const TCHAR *name, const std::string &value) { assert(key != NULL); assert(name != NULL); if (key == NULL || name == NULL) { // TODO: throw exception return; } - RegSetValueEx(key, name, 0, REG_BINARY, - reinterpret_cast(value.data()), - (DWORD)value.size()); + RegSetValueEx( + key, name, 0, REG_BINARY, reinterpret_cast(value.data()), + (DWORD)value.size()); } -std::string ArchMiscWindows::readBinaryOrString(HKEY key, const TCHAR *name, - DWORD type) { +std::string +ArchMiscWindows::readBinaryOrString(HKEY key, const TCHAR *name, DWORD type) { // get the size of the string DWORD actualType; DWORD size = 0; @@ -241,8 +243,8 @@ std::string ArchMiscWindows::readBinaryOrString(HKEY key, const TCHAR *name, char *buffer = new char[size]; // read it - result = RegQueryValueEx(key, name, 0, &actualType, - reinterpret_cast(buffer), &size); + result = RegQueryValueEx( + key, name, 0, &actualType, reinterpret_cast(buffer), &size); if (result != ERROR_SUCCESS || actualType != type) { delete[] buffer; return std::string(); @@ -271,8 +273,8 @@ ArchMiscWindows::readValueInt(HKEY key, const TCHAR *name) { DWORD type; DWORD value; DWORD size = sizeof(value); - LONG result = RegQueryValueEx(key, name, 0, &type, - reinterpret_cast(&value), &size); + LONG result = RegQueryValueEx( + key, name, 0, &type, reinterpret_cast(&value), &size); if (result != ERROR_SUCCESS || type != REG_DWORD) { return 0; } @@ -396,13 +398,13 @@ BOOL WINAPI ArchMiscWindows::getParentProcessEntry(PROCESSENTRY32 &entry) { return getProcessEntry(entry, selfEntry.th32ParentProcessID); } -BOOL WINAPI ArchMiscWindows::getProcessEntry(PROCESSENTRY32 &entry, - DWORD processID) { +BOOL WINAPI +ArchMiscWindows::getProcessEntry(PROCESSENTRY32 &entry, DWORD processID) { // first we need to take a snapshot of the running processes HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (snapshot == INVALID_HANDLE_VALUE) { - LOG((CLOG_ERR "could not get process snapshot (error: %i)", - GetLastError())); + LOG(( + CLOG_ERR "could not get process snapshot (error: %i)", GetLastError())); return FALSE; } @@ -412,7 +414,8 @@ BOOL WINAPI ArchMiscWindows::getProcessEntry(PROCESSENTRY32 &entry, // unlikely we can go any further BOOL gotEntry = Process32First(snapshot, &entry); if (!gotEntry) { - LOG((CLOG_ERR "could not get first process entry (error: %i)", + LOG( + (CLOG_ERR "could not get first process entry (error: %i)", GetLastError())); return FALSE; } diff --git a/src/lib/arch/win32/ArchMiscWindows.h b/src/lib/arch/win32/ArchMiscWindows.h index 192681aa0..4a459af2d 100644 --- a/src/lib/arch/win32/ArchMiscWindows.h +++ b/src/lib/arch/win32/ArchMiscWindows.h @@ -114,8 +114,8 @@ public: /*! Sets the \p name value of \p key to \p value.data(). */ - static void setValueBinary(HKEY key, const TCHAR *name, - const std::string &value); + static void + setValueBinary(HKEY key, const TCHAR *name, const std::string &value); //! Read a string value from the registry static std::string readValueString(HKEY, const TCHAR *name); diff --git a/src/lib/arch/win32/ArchMultithreadWindows.cpp b/src/lib/arch/win32/ArchMultithreadWindows.cpp index e58cbadcd..c893df4e2 100644 --- a/src/lib/arch/win32/ArchMultithreadWindows.cpp +++ b/src/lib/arch/win32/ArchMultithreadWindows.cpp @@ -59,8 +59,14 @@ public: }; ArchThreadImpl::ArchThreadImpl() - : m_refCount(1), m_thread(NULL), m_id(0), m_func(NULL), m_userData(NULL), - m_cancelling(false), m_result(NULL), m_networkData(NULL) { + : m_refCount(1), + m_thread(NULL), + m_id(0), + m_func(NULL), + m_userData(NULL), + m_cancelling(false), + m_result(NULL), + m_networkData(NULL) { m_exit = CreateEvent(NULL, TRUE, FALSE, NULL); m_cancel = CreateEvent(NULL, TRUE, FALSE, NULL); } @@ -177,8 +183,8 @@ void ArchMultithreadWindows::broadcastCondVar(ArchCond cond) { } } -bool ArchMultithreadWindows::waitCondVar(ArchCond cond, ArchMutex mutex, - double timeout) { +bool ArchMultithreadWindows::waitCondVar( + ArchCond cond, ArchMutex mutex, double timeout) { // prepare to wait const DWORD winTimeout = (timeout < 0.0) ? INFINITE : static_cast(1000.0 * timeout); @@ -451,8 +457,8 @@ bool ArchMultithreadWindows::wait(ArchThread target, double timeout) { } } -bool ArchMultithreadWindows::isSameThread(ArchThread thread1, - ArchThread thread2) { +bool ArchMultithreadWindows::isSameThread( + ArchThread thread1, ArchThread thread2) { return (thread1 == thread2); } @@ -473,8 +479,8 @@ ArchMultithreadWindows::getIDOfThread(ArchThread thread) { return static_cast(thread->m_id); } -void ArchMultithreadWindows::setSignalHandler(ESignal signal, SignalFunc func, - void *userData) { +void ArchMultithreadWindows::setSignalHandler( + ESignal signal, SignalFunc func, void *userData) { lockMutex(m_threadMutex); m_signalFunc[signal] = func; m_signalUserData[signal] = userData; diff --git a/src/lib/arch/win32/ArchNetworkWinsock.cpp b/src/lib/arch/win32/ArchNetworkWinsock.cpp index d01a234ae..e1d5e6762 100644 --- a/src/lib/arch/win32/ArchNetworkWinsock.cpp +++ b/src/lib/arch/win32/ArchNetworkWinsock.cpp @@ -31,34 +31,32 @@ static const int s_family[] = { }; static const int s_type[] = {SOCK_DGRAM, SOCK_STREAM}; -static SOCKET(PASCAL FAR *accept_winsock)(SOCKET s, struct sockaddr FAR *addr, - int FAR *addrlen); -static int(PASCAL FAR *bind_winsock)(SOCKET s, const struct sockaddr FAR *addr, - int namelen); +static SOCKET(PASCAL FAR *accept_winsock)( + SOCKET s, struct sockaddr FAR *addr, int FAR *addrlen); +static int(PASCAL FAR *bind_winsock)( + SOCKET s, const struct sockaddr FAR *addr, int namelen); static int(PASCAL FAR *close_winsock)(SOCKET s); -static int(PASCAL FAR *connect_winsock)(SOCKET s, - const struct sockaddr FAR *name, - int namelen); +static int(PASCAL FAR *connect_winsock)( + SOCKET s, const struct sockaddr FAR *name, int namelen); static int(PASCAL FAR *gethostname_winsock)(char FAR *name, int namelen); static int(PASCAL FAR *getsockerror_winsock)(void); -static int(PASCAL FAR *getsockopt_winsock)(SOCKET s, int level, int optname, - void FAR *optval, int FAR *optlen); +static int(PASCAL FAR *getsockopt_winsock)( + SOCKET s, int level, int optname, void FAR *optval, int FAR *optlen); static u_short(PASCAL FAR *htons_winsock)(u_short v); static char FAR *(PASCAL FAR *inet_ntoa_winsock)(struct in_addr in); static unsigned long(PASCAL FAR *inet_addr_winsock)(const char FAR *cp); static int(PASCAL FAR *ioctl_winsock)(SOCKET s, int cmd, void FAR *data); static int(PASCAL FAR *listen_winsock)(SOCKET s, int backlog); static u_short(PASCAL FAR *ntohs_winsock)(u_short v); -static int(PASCAL FAR *recv_winsock)(SOCKET s, void FAR *buf, int len, - int flags); -static int(PASCAL FAR *select_winsock)(int nfds, fd_set FAR *readfds, - fd_set FAR *writefds, - fd_set FAR *exceptfds, - const struct timeval FAR *timeout); -static int(PASCAL FAR *send_winsock)(SOCKET s, const void FAR *buf, int len, - int flags); -static int(PASCAL FAR *setsockopt_winsock)(SOCKET s, int level, int optname, - const void FAR *optval, int optlen); +static int(PASCAL FAR *recv_winsock)( + SOCKET s, void FAR *buf, int len, int flags); +static int(PASCAL FAR *select_winsock)( + int nfds, fd_set FAR *readfds, fd_set FAR *writefds, fd_set FAR *exceptfds, + const struct timeval FAR *timeout); +static int(PASCAL FAR *send_winsock)( + SOCKET s, const void FAR *buf, int len, int flags); +static int(PASCAL FAR *setsockopt_winsock)( + SOCKET s, int level, int optname, const void FAR *optval, int optlen); static int(PASCAL FAR *shutdown_winsock)(SOCKET s, int how); static SOCKET(PASCAL FAR *socket_winsock)(int af, int type, int protocol); static struct hostent FAR *(PASCAL FAR *gethostbyaddr_winsock)( @@ -72,11 +70,10 @@ static BOOL(PASCAL FAR *WSACloseEvent_winsock)(WSAEVENT); static BOOL(PASCAL FAR *WSASetEvent_winsock)(WSAEVENT); static BOOL(PASCAL FAR *WSAResetEvent_winsock)(WSAEVENT); static int(PASCAL FAR *WSAEventSelect_winsock)(SOCKET, WSAEVENT, long); -static DWORD(PASCAL FAR *WSAWaitForMultipleEvents_winsock)(DWORD, - const WSAEVENT FAR *, - BOOL, DWORD, BOOL); -static int(PASCAL FAR *WSAEnumNetworkEvents_winsock)(SOCKET, WSAEVENT, - LPWSANETWORKEVENTS); +static DWORD(PASCAL FAR *WSAWaitForMultipleEvents_winsock)( + DWORD, const WSAEVENT FAR *, BOOL, DWORD, BOOL); +static int(PASCAL FAR *WSAEnumNetworkEvents_winsock)( + SOCKET, WSAEVENT, LPWSANETWORKEVENTS); #undef FD_ISSET #define FD_ISSET(fd, set) WSAFDIsSet_winsock((SOCKET)(fd), (fd_set FAR *)(set)) @@ -167,69 +164,89 @@ void ArchNetworkWinsock::initModule(HMODULE module) { } // get function addresses - setfunc(accept_winsock, accept, - SOCKET(PASCAL FAR *)(SOCKET s, struct sockaddr FAR * addr, - int FAR *addrlen)); - setfunc(bind_winsock, bind, - int(PASCAL FAR *)(SOCKET s, const struct sockaddr FAR *addr, - int namelen)); + setfunc( + accept_winsock, accept, + SOCKET(PASCAL FAR *)( + SOCKET s, struct sockaddr FAR * addr, int FAR *addrlen)); + setfunc( + bind_winsock, bind, + int(PASCAL FAR *)( + SOCKET s, const struct sockaddr FAR *addr, int namelen)); setfunc(close_winsock, closesocket, int(PASCAL FAR *)(SOCKET s)); - setfunc(connect_winsock, connect, - int(PASCAL FAR *)(SOCKET s, const struct sockaddr FAR *name, - int namelen)); - setfunc(gethostname_winsock, gethostname, - int(PASCAL FAR *)(char FAR *name, int namelen)); + setfunc( + connect_winsock, connect, + int(PASCAL FAR *)( + SOCKET s, const struct sockaddr FAR *name, int namelen)); + setfunc( + gethostname_winsock, gethostname, + int(PASCAL FAR *)(char FAR *name, int namelen)); setfunc(getsockerror_winsock, WSAGetLastError, int(PASCAL FAR *)(void)); - setfunc(getsockopt_winsock, getsockopt, - int(PASCAL FAR *)(SOCKET s, int level, int optname, void FAR *optval, - int FAR *optlen)); + setfunc( + getsockopt_winsock, getsockopt, + int(PASCAL FAR *)( + SOCKET s, int level, int optname, void FAR *optval, int FAR *optlen)); setfunc(htons_winsock, htons, u_short(PASCAL FAR *)(u_short v)); - setfunc(inet_ntoa_winsock, inet_ntoa, - char FAR *(PASCAL FAR *)(struct in_addr in)); - setfunc(inet_addr_winsock, inet_addr, - unsigned long(PASCAL FAR *)(const char FAR *cp)); - setfunc(ioctl_winsock, ioctlsocket, - int(PASCAL FAR *)(SOCKET s, int cmd, void FAR *)); + setfunc( + inet_ntoa_winsock, inet_ntoa, + char FAR *(PASCAL FAR *)(struct in_addr in)); + setfunc( + inet_addr_winsock, inet_addr, + unsigned long(PASCAL FAR *)(const char FAR *cp)); + setfunc( + ioctl_winsock, ioctlsocket, + int(PASCAL FAR *)(SOCKET s, int cmd, void FAR *)); setfunc(listen_winsock, listen, int(PASCAL FAR *)(SOCKET s, int backlog)); setfunc(ntohs_winsock, ntohs, u_short(PASCAL FAR *)(u_short v)); - setfunc(recv_winsock, recv, - int(PASCAL FAR *)(SOCKET s, void FAR *buf, int len, int flags)); - setfunc(select_winsock, select, - int(PASCAL FAR *)(int nfds, fd_set FAR *readfds, fd_set FAR *writefds, - fd_set FAR *exceptfds, - const struct timeval FAR *timeout)); - setfunc(send_winsock, send, - int(PASCAL FAR *)(SOCKET s, const void FAR *buf, int len, int flags)); - setfunc(setsockopt_winsock, setsockopt, - int(PASCAL FAR *)(SOCKET s, int level, int optname, - const void FAR *optval, int optlen)); + setfunc( + recv_winsock, recv, + int(PASCAL FAR *)(SOCKET s, void FAR *buf, int len, int flags)); + setfunc( + select_winsock, select, + int(PASCAL FAR *)( + int nfds, fd_set FAR *readfds, fd_set FAR *writefds, + fd_set FAR *exceptfds, const struct timeval FAR *timeout)); + setfunc( + send_winsock, send, + int(PASCAL FAR *)(SOCKET s, const void FAR *buf, int len, int flags)); + setfunc( + setsockopt_winsock, setsockopt, + int(PASCAL FAR *)( + SOCKET s, int level, int optname, const void FAR *optval, + int optlen)); setfunc(shutdown_winsock, shutdown, int(PASCAL FAR *)(SOCKET s, int how)); - setfunc(socket_winsock, socket, - SOCKET(PASCAL FAR *)(int af, int type, int protocol)); - setfunc(gethostbyaddr_winsock, gethostbyaddr, - struct hostent FAR * - (PASCAL FAR *)(const char FAR *addr, int len, int type)); - setfunc(gethostbyname_winsock, gethostbyname, - struct hostent FAR * (PASCAL FAR *)(const char FAR *name)); + setfunc( + socket_winsock, socket, + SOCKET(PASCAL FAR *)(int af, int type, int protocol)); + setfunc( + gethostbyaddr_winsock, gethostbyaddr, + struct hostent FAR * + (PASCAL FAR *)(const char FAR *addr, int len, int type)); + setfunc( + gethostbyname_winsock, gethostbyname, + struct hostent FAR * (PASCAL FAR *)(const char FAR *name)); setfunc(WSACleanup_winsock, WSACleanup, int(PASCAL FAR *)(void)); - setfunc(WSAFDIsSet_winsock, __WSAFDIsSet, - int(PASCAL FAR *)(SOCKET, fd_set FAR *)); + setfunc( + WSAFDIsSet_winsock, __WSAFDIsSet, + int(PASCAL FAR *)(SOCKET, fd_set FAR *)); setfunc(WSACreateEvent_winsock, WSACreateEvent, WSAEVENT(PASCAL FAR *)(void)); setfunc(WSACloseEvent_winsock, WSACloseEvent, BOOL(PASCAL FAR *)(WSAEVENT)); setfunc(WSASetEvent_winsock, WSASetEvent, BOOL(PASCAL FAR *)(WSAEVENT)); setfunc(WSAResetEvent_winsock, WSAResetEvent, BOOL(PASCAL FAR *)(WSAEVENT)); - setfunc(WSAEventSelect_winsock, WSAEventSelect, - int(PASCAL FAR *)(SOCKET, WSAEVENT, long)); - setfunc(WSAWaitForMultipleEvents_winsock, WSAWaitForMultipleEvents, - DWORD(PASCAL FAR *)(DWORD, const WSAEVENT FAR *, BOOL, DWORD, BOOL)); - setfunc(WSAEnumNetworkEvents_winsock, WSAEnumNetworkEvents, - int(PASCAL FAR *)(SOCKET, WSAEVENT, LPWSANETWORKEVENTS)); + setfunc( + WSAEventSelect_winsock, WSAEventSelect, + int(PASCAL FAR *)(SOCKET, WSAEVENT, long)); + setfunc( + WSAWaitForMultipleEvents_winsock, WSAWaitForMultipleEvents, + DWORD(PASCAL FAR *)(DWORD, const WSAEVENT FAR *, BOOL, DWORD, BOOL)); + setfunc( + WSAEnumNetworkEvents_winsock, WSAEnumNetworkEvents, + int(PASCAL FAR *)(SOCKET, WSAEVENT, LPWSANETWORKEVENTS)); s_networkModule = module; } -ArchSocket ArchNetworkWinsock::newSocket(EAddressFamily family, - ESocketType type) { +ArchSocket +ArchNetworkWinsock::newSocket(EAddressFamily family, ESocketType type) { // create socket SOCKET fd = socket_winsock(s_family[family], s_type[type], 0); if (fd == INVALID_SOCKET) { @@ -314,8 +331,9 @@ void ArchNetworkWinsock::bindSocket(ArchSocket s, ArchNetAddress addr) { assert(s != NULL); assert(addr != NULL); - if (bind_winsock(s->m_socket, TYPED_ADDR(struct sockaddr, addr), - addr->m_len) == SOCKET_ERROR) { + if (bind_winsock( + s->m_socket, TYPED_ADDR(struct sockaddr, addr), addr->m_len) == + SOCKET_ERROR) { throwError(getsockerror_winsock()); } } @@ -329,8 +347,8 @@ void ArchNetworkWinsock::listenOnSocket(ArchSocket s) { } } -ArchSocket ArchNetworkWinsock::acceptSocket(ArchSocket s, - ArchNetAddress *const addr) { +ArchSocket +ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress *const addr) { assert(s != NULL); // create new socket and temporary address @@ -338,8 +356,8 @@ ArchSocket ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress tmp = ArchNetAddressImpl::alloc(sizeof(struct sockaddr_in6)); // accept on socket - SOCKET fd = accept_winsock(s->m_socket, TYPED_ADDR(struct sockaddr, tmp), - &tmp->m_len); + SOCKET fd = accept_winsock( + s->m_socket, TYPED_ADDR(struct sockaddr, tmp), &tmp->m_len); if (fd == INVALID_SOCKET) { int err = getsockerror_winsock(); delete socket; @@ -384,8 +402,9 @@ bool ArchNetworkWinsock::connectSocket(ArchSocket s, ArchNetAddress addr) { assert(s != NULL); assert(addr != NULL); - if (connect_winsock(s->m_socket, TYPED_ADDR(struct sockaddr, addr), - addr->m_len) == SOCKET_ERROR) { + if (connect_winsock( + s->m_socket, TYPED_ADDR(struct sockaddr, addr), addr->m_len) == + SOCKET_ERROR) { if (getsockerror_winsock() == WSAEISCONN) { return true; } @@ -437,8 +456,8 @@ int ArchNetworkWinsock::pollSocket(PollEntry pe[], int num, double timeout) { } // select socket for desired events - WSAEventSelect_winsock(pe[i].m_socket->m_socket, pe[i].m_socket->m_event, - socketEvents); + WSAEventSelect_winsock( + pe[i].m_socket->m_socket, pe[i].m_socket->m_event, socketEvents); // add socket event to wait list events[n++] = pe[i].m_socket->m_event; @@ -500,9 +519,9 @@ int ArchNetworkWinsock::pollSocket(PollEntry pe[], int num, double timeout) { // get events WSANETWORKEVENTS info; - if (WSAEnumNetworkEvents_winsock(pe[i].m_socket->m_socket, - pe[i].m_socket->m_event, - &info) == SOCKET_ERROR) { + if (WSAEnumNetworkEvents_winsock( + pe[i].m_socket->m_socket, pe[i].m_socket->m_event, &info) == + SOCKET_ERROR) { continue; } if ((info.lNetworkEvents & FD_READ) != 0) { @@ -569,8 +588,8 @@ size_t ArchNetworkWinsock::readSocket(ArchSocket s, void *buf, size_t len) { return static_cast(n); } -size_t ArchNetworkWinsock::writeSocket(ArchSocket s, const void *buf, - size_t len) { +size_t +ArchNetworkWinsock::writeSocket(ArchSocket s, const void *buf, size_t len) { assert(s != NULL); int n = send_winsock(s->m_socket, buf, (int)len, 0); @@ -620,8 +639,9 @@ bool ArchNetworkWinsock::setNoDelayOnSocket(ArchSocket s, bool noDelay) { // get old state BOOL oflag; int size = sizeof(oflag); - if (getsockopt_winsock(s->m_socket, IPPROTO_TCP, TCP_NODELAY, &oflag, - &size) == SOCKET_ERROR) { + if (getsockopt_winsock( + s->m_socket, IPPROTO_TCP, TCP_NODELAY, &oflag, &size) == + SOCKET_ERROR) { throwError(getsockerror_winsock()); } @@ -642,8 +662,9 @@ bool ArchNetworkWinsock::setReuseAddrOnSocket(ArchSocket s, bool reuse) { // get old state BOOL oflag; int size = sizeof(oflag); - if (getsockopt_winsock(s->m_socket, SOL_SOCKET, SO_REUSEADDR, &oflag, - &size) == SOCKET_ERROR) { + if (getsockopt_winsock( + s->m_socket, SOL_SOCKET, SO_REUSEADDR, &oflag, &size) == + SOCKET_ERROR) { throwError(getsockerror_winsock()); } @@ -728,8 +749,8 @@ ArchNetworkWinsock::nameToAddr(const std::string &name) { addresses.back()->m_len = (socklen_t)sizeof(struct sockaddr_in6); } - memcpy(&addresses.back()->m_addr, address->ai_addr, - addresses.back()->m_len); + memcpy( + &addresses.back()->m_addr, address->ai_addr, addresses.back()->m_len); } freeaddrinfo(pResult); @@ -748,8 +769,9 @@ std::string ArchNetworkWinsock::addrToName(ArchNetAddress addr) { char host[1024]; char service[20]; - int ret = getnameinfo(TYPED_ADDR(struct sockaddr, addr), addr->m_len, host, - sizeof(host), service, sizeof(service), 0); + int ret = getnameinfo( + TYPED_ADDR(struct sockaddr, addr), addr->m_len, host, sizeof(host), + service, sizeof(service), 0); if (ret != NULL) { throwNameError(ret); @@ -846,14 +868,16 @@ bool ArchNetworkWinsock::isAnyAddr(ArchNetAddress addr) { switch (getAddrFamily(addr)) { case kINET: { struct sockaddr_in *ipAddr = TYPED_ADDR(struct sockaddr_in, addr); - return (addr->m_len == sizeof(struct sockaddr_in) && - ipAddr->sin_addr.s_addr == INADDR_ANY); + return ( + addr->m_len == sizeof(struct sockaddr_in) && + ipAddr->sin_addr.s_addr == INADDR_ANY); } case kINET6: { struct sockaddr_in6 *ipAddr = TYPED_ADDR(struct sockaddr_in6, addr); - return (addr->m_len == sizeof(struct sockaddr_in) && - memcmp(&ipAddr->sin6_addr, &in6addr_any, sizeof(in6addr_any)) == 0); + return ( + addr->m_len == sizeof(struct sockaddr_in) && + memcmp(&ipAddr->sin6_addr, &in6addr_any, sizeof(in6addr_any)) == 0); } default: @@ -863,8 +887,9 @@ bool ArchNetworkWinsock::isAnyAddr(ArchNetAddress addr) { } bool ArchNetworkWinsock::isEqualAddr(ArchNetAddress a, ArchNetAddress b) { - return (a == b || (a->m_len == b->m_len && - memcmp(&a->m_addr, &b->m_addr, a->m_len) == 0)); + return ( + a == b || + (a->m_len == b->m_len && memcmp(&a->m_addr, &b->m_addr, a->m_len) == 0)); } void ArchNetworkWinsock::throwError(int err) { diff --git a/src/lib/arch/win32/ArchSystemWindows.cpp b/src/lib/arch/win32/ArchSystemWindows.cpp index f7dd3b359..099fdb073 100644 --- a/src/lib/arch/win32/ArchSystemWindows.cpp +++ b/src/lib/arch/win32/ArchSystemWindows.cpp @@ -85,8 +85,8 @@ std::string ArchSystemWindows::setting(const std::string &valueName) const { return ArchMiscWindows::readValueString(key, valueName.c_str()); } -void ArchSystemWindows::setting(const std::string &valueName, - const std::string &valueString) const { +void ArchSystemWindows::setting( + const std::string &valueName, const std::string &valueString) const { HKEY key = ArchMiscWindows::addKey(HKEY_LOCAL_MACHINE, s_settingsKeyNames); if (key == NULL) throw XArch(std::string("could not access registry key: ") + valueName); diff --git a/src/lib/arch/win32/ArchSystemWindows.h b/src/lib/arch/win32/ArchSystemWindows.h index e57e143a7..67de01847 100644 --- a/src/lib/arch/win32/ArchSystemWindows.h +++ b/src/lib/arch/win32/ArchSystemWindows.h @@ -32,8 +32,8 @@ public: virtual std::string getOSName() const; virtual std::string getPlatformName() const; virtual std::string setting(const std::string &valueName) const; - virtual void setting(const std::string &valueName, - const std::string &valueString) const; + virtual void + setting(const std::string &valueName, const std::string &valueString) const; bool isWOW64() const; }; diff --git a/src/lib/arch/win32/ArchTaskBarWindows.cpp b/src/lib/arch/win32/ArchTaskBarWindows.cpp index 3475ab17a..9d263df29 100644 --- a/src/lib/arch/win32/ArchTaskBarWindows.cpp +++ b/src/lib/arch/win32/ArchTaskBarWindows.cpp @@ -39,8 +39,13 @@ static const UINT kFirstReceiverID = WM_USER + 14; ArchTaskBarWindows *ArchTaskBarWindows::s_instance = NULL; ArchTaskBarWindows::ArchTaskBarWindows() - : m_mutex(NULL), m_condVar(NULL), m_ready(false), m_result(0), - m_thread(NULL), m_hwnd(NULL), m_taskBarRestart(0), + : m_mutex(NULL), + m_condVar(NULL), + m_ready(false), + m_result(0), + m_thread(NULL), + m_hwnd(NULL), + m_taskBarRestart(0), m_nextID(kFirstReceiverID) { // save the singleton instance s_instance = this; @@ -256,8 +261,8 @@ void ArchTaskBarWindows::removeIconNoLock(UINT id) { } } -void ArchTaskBarWindows::handleIconMessage(IArchTaskBarReceiver *receiver, - LPARAM lParam) { +void ArchTaskBarWindows::handleIconMessage( + IArchTaskBarReceiver *receiver, LPARAM lParam) { // process message switch (lParam) { case WM_LBUTTONDOWN: @@ -375,9 +380,8 @@ ArchTaskBarWindows::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { return DefWindowProc(hwnd, msg, wParam, lParam); } -LRESULT CALLBACK ArchTaskBarWindows::staticWndProc(HWND hwnd, UINT msg, - WPARAM wParam, - LPARAM lParam) { +LRESULT CALLBACK ArchTaskBarWindows::staticWndProc( + HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { // if msg is WM_NCCREATE, extract the ArchTaskBarWindows* and put // it in the extra window data then forward the call. ArchTaskBarWindows *self = NULL; @@ -385,8 +389,8 @@ LRESULT CALLBACK ArchTaskBarWindows::staticWndProc(HWND hwnd, UINT msg, CREATESTRUCT *createInfo; createInfo = reinterpret_cast(lParam); self = static_cast(createInfo->lpCreateParams); - SetWindowLongPtr(hwnd, 0, - reinterpret_cast(createInfo->lpCreateParams)); + SetWindowLongPtr( + hwnd, 0, reinterpret_cast(createInfo->lpCreateParams)); } else { // get the extra window data and forward the call LONG_PTR data = GetWindowLongPtr(hwnd, 0); @@ -425,9 +429,9 @@ void ArchTaskBarWindows::threadMainLoop() { ATOM windowClass = RegisterClassEx(&classInfo); // create window - m_hwnd = CreateWindowEx(WS_EX_TOOLWINDOW, className, TEXT("Synergy Task Bar"), - WS_POPUP, 0, 0, 1, 1, NULL, NULL, instanceWin32(), - static_cast(this)); + m_hwnd = CreateWindowEx( + WS_EX_TOOLWINDOW, className, TEXT("Synergy Task Bar"), WS_POPUP, 0, 0, 1, + 1, NULL, NULL, instanceWin32(), static_cast(this)); // signal ready ARCH->lockMutex(m_mutex); diff --git a/src/lib/arch/win32/ArchTaskBarWindows.h b/src/lib/arch/win32/ArchTaskBarWindows.h index 105f0bfd2..f28120b59 100644 --- a/src/lib/arch/win32/ArchTaskBarWindows.h +++ b/src/lib/arch/win32/ArchTaskBarWindows.h @@ -74,8 +74,8 @@ private: void updateIcon(UINT); void addAllIcons(); void removeAllIcons(); - void modifyIconNoLock(ReceiverToInfoMap::const_iterator, - DWORD taskBarMessage); + void + modifyIconNoLock(ReceiverToInfoMap::const_iterator, DWORD taskBarMessage); void removeIconNoLock(UINT id); void handleIconMessage(IArchTaskBarReceiver *, LPARAM); diff --git a/src/lib/arch/win32/XArchWindows.cpp b/src/lib/arch/win32/XArchWindows.cpp index c7f5e8a90..3f7e2365d 100644 --- a/src/lib/arch/win32/XArchWindows.cpp +++ b/src/lib/arch/win32/XArchWindows.cpp @@ -26,11 +26,11 @@ std::string XArchEvalWindows::eval() const throw() { char *cmsg; - if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_IGNORE_INSERTS | - FORMAT_MESSAGE_FROM_SYSTEM, - 0, m_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&cmsg, 0, NULL) == 0) { + if (FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | + FORMAT_MESSAGE_FROM_SYSTEM, + 0, m_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&cmsg, + 0, NULL) == 0) { cmsg = NULL; return synergy::string::sprintf("Unknown error, code %d", m_error); } diff --git a/src/lib/base/Event.cpp b/src/lib/base/Event.cpp index 59e507027..60ba9e13c 100644 --- a/src/lib/base/Event.cpp +++ b/src/lib/base/Event.cpp @@ -24,19 +24,28 @@ // Event::Event() - : m_type(kUnknown), m_target(NULL), m_data(NULL), m_flags(0), + : m_type(kUnknown), + m_target(NULL), + m_data(NULL), + m_flags(0), m_dataObject(nullptr) { // do nothing } Event::Event(Type type, void *target, void *data, Flags flags) - : m_type(type), m_target(target), m_data(data), m_flags(flags), + : m_type(type), + m_target(target), + m_data(data), + m_flags(flags), m_dataObject(nullptr) { // do nothing } Event::Event(Type type, void *target, EventData *dataObject) - : m_type(type), m_target(target), m_data(nullptr), m_flags(kNone), + : m_type(type), + m_target(target), + m_data(nullptr), + m_flags(kNone), m_dataObject(dataObject) {} Event::Type Event::getType() const { return m_type; } diff --git a/src/lib/base/EventQueue.cpp b/src/lib/base/EventQueue.cpp index 374b6260d..da2d12a82 100644 --- a/src/lib/base/EventQueue.cpp +++ b/src/lib/base/EventQueue.cpp @@ -60,16 +60,28 @@ static void interrupt(Arch::ESignal, void *data) { // EventQueue::EventQueue() - : m_systemTarget(0), m_nextType(Event::kLast), m_typesForClient(NULL), - m_typesForIStream(NULL), m_typesForIpcClient(NULL), - m_typesForIpcClientProxy(NULL), m_typesForIpcServer(NULL), - m_typesForIpcServerProxy(NULL), m_typesForIDataSocket(NULL), - m_typesForIListenSocket(NULL), m_typesForISocket(NULL), - m_typesForOSXScreen(NULL), m_typesForClientListener(NULL), - m_typesForClientProxy(NULL), m_typesForClientProxyUnknown(NULL), - m_typesForServer(NULL), m_typesForServerApp(NULL), - m_typesForIKeyState(NULL), m_typesForIPrimaryScreen(NULL), - m_typesForIScreen(NULL), m_typesForClipboard(NULL), m_typesForFile(NULL), + : m_systemTarget(0), + m_nextType(Event::kLast), + m_typesForClient(NULL), + m_typesForIStream(NULL), + m_typesForIpcClient(NULL), + m_typesForIpcClientProxy(NULL), + m_typesForIpcServer(NULL), + m_typesForIpcServerProxy(NULL), + m_typesForIDataSocket(NULL), + m_typesForIListenSocket(NULL), + m_typesForISocket(NULL), + m_typesForOSXScreen(NULL), + m_typesForClientListener(NULL), + m_typesForClientProxy(NULL), + m_typesForClientProxyUnknown(NULL), + m_typesForServer(NULL), + m_typesForServerApp(NULL), + m_typesForIKeyState(NULL), + m_typesForIPrimaryScreen(NULL), + m_typesForIScreen(NULL), + m_typesForClipboard(NULL), + m_typesForFile(NULL), m_readyMutex(new Mutex), m_readyCondVar(new CondVar(m_readyMutex, false)) { m_mutex = ARCH->newMutex(); @@ -328,8 +340,8 @@ void EventQueue::deleteTimer(EventQueueTimer *timer) { m_buffer->deleteTimer(timer); } -void EventQueue::adoptHandler(Event::Type type, void *target, - IEventJob *handler) { +void EventQueue::adoptHandler( + Event::Type type, void *target, IEventJob *handler) { ArchMutexLock lock(m_mutex); IEventJob *&job = m_handlers[target][type]; delete job; @@ -508,9 +520,13 @@ void EventQueue::waitForReady() const { // EventQueue::Timer // -EventQueue::Timer::Timer(EventQueueTimer *timer, double timeout, - double initialTime, void *target, bool oneShot) - : m_timer(timer), m_timeout(timeout), m_target(target), m_oneShot(oneShot), +EventQueue::Timer::Timer( + EventQueueTimer *timer, double timeout, double initialTime, void *target, + bool oneShot) + : m_timer(timer), + m_timeout(timeout), + m_target(target), + m_oneShot(oneShot), m_time(initialTime) { assert(m_timeout > 0.0); } diff --git a/src/lib/base/EventQueue.h b/src/lib/base/EventQueue.h index 853512b5b..e9cc30bbe 100644 --- a/src/lib/base/EventQueue.h +++ b/src/lib/base/EventQueue.h @@ -75,8 +75,9 @@ private: private: class Timer { public: - Timer(EventQueueTimer *, double timeout, double initialTime, void *target, - bool oneShot); + Timer( + EventQueueTimer *, double timeout, double initialTime, void *target, + bool oneShot); ~Timer(); void reset(); diff --git a/src/lib/base/EventTypes.h b/src/lib/base/EventTypes.h index 36c0d9491..71687658d 100644 --- a/src/lib/base/EventTypes.h +++ b/src/lib/base/EventTypes.h @@ -84,8 +84,10 @@ private: class IStreamEvents : public EventTypes { public: IStreamEvents() - : m_inputReady(Event::kUnknown), m_outputFlushed(Event::kUnknown), - m_outputError(Event::kUnknown), m_inputShutdown(Event::kUnknown), + : m_inputReady(Event::kUnknown), + m_outputFlushed(Event::kUnknown), + m_outputError(Event::kUnknown), + m_inputShutdown(Event::kUnknown), m_outputShutdown(Event::kUnknown) {} //! @name accessors @@ -145,7 +147,8 @@ private: class IpcClientEvents : public EventTypes { public: IpcClientEvents() - : m_connected(Event::kUnknown), m_messageReceived(Event::kUnknown) {} + : m_connected(Event::kUnknown), + m_messageReceived(Event::kUnknown) {} //! @name accessors //@{ @@ -166,7 +169,8 @@ private: class IpcClientProxyEvents : public EventTypes { public: IpcClientProxyEvents() - : m_messageReceived(Event::kUnknown), m_disconnected(Event::kUnknown) {} + : m_messageReceived(Event::kUnknown), + m_disconnected(Event::kUnknown) {} //! @name accessors //@{ @@ -187,8 +191,8 @@ private: class IpcServerEvents : public EventTypes { public: IpcServerEvents() - : m_clientConnected(Event::kUnknown), m_messageReceived(Event::kUnknown) { - } + : m_clientConnected(Event::kUnknown), + m_messageReceived(Event::kUnknown) {} //! @name accessors //@{ @@ -225,7 +229,8 @@ private: class IDataSocketEvents : public EventTypes { public: IDataSocketEvents() - : m_connected(Event::kUnknown), m_secureConnected(Event::kUnknown), + : m_connected(Event::kUnknown), + m_secureConnected(Event::kUnknown), m_connectionFailed(Event::kUnknown) {} //! @name accessors @@ -284,7 +289,8 @@ private: class ISocketEvents : public EventTypes { public: ISocketEvents() - : m_disconnected(Event::kUnknown), m_stopRetry(Event::kUnknown) {} + : m_disconnected(Event::kUnknown), + m_stopRetry(Event::kUnknown) {} //! @name accessors //@{ @@ -329,7 +335,8 @@ private: class ClientListenerEvents : public EventTypes { public: ClientListenerEvents() - : m_accepted(Event::kUnknown), m_connected(Event::kUnknown) {} + : m_accepted(Event::kUnknown), + m_connected(Event::kUnknown) {} //! @name accessors //@{ @@ -358,7 +365,8 @@ private: class ClientProxyEvents : public EventTypes { public: ClientProxyEvents() - : m_ready(Event::kUnknown), m_disconnected(Event::kUnknown) {} + : m_ready(Event::kUnknown), + m_disconnected(Event::kUnknown) {} //! @name accessors //@{ @@ -388,7 +396,8 @@ private: class ClientProxyUnknownEvents : public EventTypes { public: ClientProxyUnknownEvents() - : m_success(Event::kUnknown), m_failure(Event::kUnknown) {} + : m_success(Event::kUnknown), + m_failure(Event::kUnknown) {} //! @name accessors //@{ @@ -417,8 +426,10 @@ private: class ServerEvents : public EventTypes { public: ServerEvents() - : m_error(Event::kUnknown), m_connected(Event::kUnknown), - m_disconnected(Event::kUnknown), m_switchToScreen(Event::kUnknown), + : m_error(Event::kUnknown), + m_connected(Event::kUnknown), + m_disconnected(Event::kUnknown), + m_switchToScreen(Event::kUnknown), m_switchInDirection(Event::kUnknown), m_keyboardBroadcast(Event::kUnknown), m_lockCursorToScreen(Event::kUnknown), @@ -504,7 +515,8 @@ private: class ServerAppEvents : public EventTypes { public: ServerAppEvents() - : m_reloadConfig(Event::kUnknown), m_forceReconnect(Event::kUnknown), + : m_reloadConfig(Event::kUnknown), + m_forceReconnect(Event::kUnknown), m_resetServer(Event::kUnknown) {} //! @name accessors @@ -525,7 +537,8 @@ private: class IKeyStateEvents : public EventTypes { public: IKeyStateEvents() - : m_keyDown(Event::kUnknown), m_keyUp(Event::kUnknown), + : m_keyDown(Event::kUnknown), + m_keyUp(Event::kUnknown), m_keyRepeat(Event::kUnknown) {} //! @name accessors @@ -551,13 +564,17 @@ private: class IPrimaryScreenEvents : public EventTypes { public: IPrimaryScreenEvents() - : m_buttonDown(Event::kUnknown), m_buttonUp(Event::kUnknown), + : m_buttonDown(Event::kUnknown), + m_buttonUp(Event::kUnknown), m_motionOnPrimary(Event::kUnknown), - m_motionOnSecondary(Event::kUnknown), m_wheel(Event::kUnknown), + m_motionOnSecondary(Event::kUnknown), + m_wheel(Event::kUnknown), m_screensaverActivated(Event::kUnknown), m_screensaverDeactivated(Event::kUnknown), - m_hotKeyDown(Event::kUnknown), m_hotKeyUp(Event::kUnknown), - m_fakeInputBegin(Event::kUnknown), m_fakeInputEnd(Event::kUnknown) {} + m_hotKeyDown(Event::kUnknown), + m_hotKeyUp(Event::kUnknown), + m_fakeInputBegin(Event::kUnknown), + m_fakeInputEnd(Event::kUnknown) {} //! @name accessors //@{ @@ -621,8 +638,10 @@ private: class IScreenEvents : public EventTypes { public: IScreenEvents() - : m_error(Event::kUnknown), m_shapeChanged(Event::kUnknown), - m_suspend(Event::kUnknown), m_resume(Event::kUnknown) {} + : m_error(Event::kUnknown), + m_shapeChanged(Event::kUnknown), + m_suspend(Event::kUnknown), + m_resume(Event::kUnknown) {} //! @name accessors //@{ @@ -709,7 +728,8 @@ class FileEvents : public EventTypes { public: FileEvents() : m_fileChunkSending(Event::kUnknown), - m_fileRecieveCompleted(Event::kUnknown), m_keepAlive(Event::kUnknown) {} + m_fileRecieveCompleted(Event::kUnknown), + m_keepAlive(Event::kUnknown) {} //! @name accessors //@{ diff --git a/src/lib/base/FunctionEventJob.cpp b/src/lib/base/FunctionEventJob.cpp index a504c8dc4..e2311ee71 100644 --- a/src/lib/base/FunctionEventJob.cpp +++ b/src/lib/base/FunctionEventJob.cpp @@ -22,9 +22,10 @@ // FunctionEventJob // -FunctionEventJob::FunctionEventJob(void (*func)(const Event &, void *), - void *arg) - : m_func(func), m_arg(arg) { +FunctionEventJob::FunctionEventJob( + void (*func)(const Event &, void *), void *arg) + : m_func(func), + m_arg(arg) { // do nothing } diff --git a/src/lib/base/FunctionJob.cpp b/src/lib/base/FunctionJob.cpp index b1e6395e2..f806875eb 100644 --- a/src/lib/base/FunctionJob.cpp +++ b/src/lib/base/FunctionJob.cpp @@ -23,7 +23,8 @@ // FunctionJob::FunctionJob(void (*func)(void *), void *arg) - : m_func(func), m_arg(arg) { + : m_func(func), + m_arg(arg) { // do nothing } diff --git a/src/lib/base/IEventQueue.h b/src/lib/base/IEventQueue.h index 0453bc51b..787da00ff 100644 --- a/src/lib/base/IEventQueue.h +++ b/src/lib/base/IEventQueue.h @@ -149,8 +149,8 @@ public: of type \p type. If no such handler exists it will use the handler for \p target and type \p kUnknown if it exists. */ - virtual void adoptHandler(Event::Type type, void *target, - IEventJob *handler) = 0; + virtual void + adoptHandler(Event::Type type, void *target, IEventJob *handler) = 0; //! Unregister an event handler for an event type /*! diff --git a/src/lib/base/Log.cpp b/src/lib/base/Log.cpp index 98a693318..9a6b540ee 100644 --- a/src/lib/base/Log.cpp +++ b/src/lib/base/Log.cpp @@ -79,13 +79,15 @@ void makeTimeString(std::vector &buffer) { localtime_r(&t, &tm); #endif - snprintf(buffer.data(), buffer.size(), "%04i-%02i-%02iT%02i:%02i:%02i", - tm.tm_year + yearOffset, tm.tm_mon + monthOffset, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec); + snprintf( + buffer.data(), buffer.size(), "%04i-%02i-%02iT%02i:%02i:%02i", + tm.tm_year + yearOffset, tm.tm_mon + monthOffset, tm.tm_mday, tm.tm_hour, + tm.tm_min, tm.tm_sec); } -std::vector makeMessage(const char *filename, int lineNumber, - const char *message, ELevel priority) { +std::vector makeMessage( + const char *filename, int lineNumber, const char *message, + ELevel priority) { // base size includes null terminator, colon, space, etc. const int baseSize = 10; @@ -109,14 +111,15 @@ std::vector makeMessage(const char *filename, int lineNumber, bufferSize += filenameLength + lineNumberLength; std::vector buffer(bufferSize); - snprintf(buffer.data(), bufferSize, "[%s] %s: %s\n\t%s:%d", - timeBuffer.data(), g_priority[priority], message, filename, - lineNumber); + snprintf( + buffer.data(), bufferSize, "[%s] %s: %s\n\t%s:%d", timeBuffer.data(), + g_priority[priority], message, filename, lineNumber); return buffer; } else { std::vector buffer(bufferSize); - snprintf(buffer.data(), bufferSize, "[%s] %s: %s", timeBuffer.data(), - g_priority[priority], message); + snprintf( + buffer.data(), bufferSize, "[%s] %s: %s", timeBuffer.data(), + g_priority[priority], message); return buffer; } } diff --git a/src/lib/base/Path.cpp b/src/lib/base/Path.cpp index d407fcf80..642afe672 100644 --- a/src/lib/base/Path.cpp +++ b/src/lib/base/Path.cpp @@ -29,12 +29,12 @@ namespace filesystem { std::wstring path(const String &filePath) { std::wstring result; - auto lenght = MultiByteToWideChar(CP_UTF8, 0, filePath.c_str(), - filePath.length(), NULL, 0); + auto lenght = MultiByteToWideChar( + CP_UTF8, 0, filePath.c_str(), filePath.length(), NULL, 0); if (lenght > 0) { result.resize(lenght); - MultiByteToWideChar(CP_UTF8, 0, filePath.c_str(), filePath.length(), - &result[0], lenght); + MultiByteToWideChar( + CP_UTF8, 0, filePath.c_str(), filePath.length(), &result[0], lenght); } return result; diff --git a/src/lib/base/PriorityQueue.h b/src/lib/base/PriorityQueue.h index 384aedea2..6404cd66d 100644 --- a/src/lib/base/PriorityQueue.h +++ b/src/lib/base/PriorityQueue.h @@ -29,11 +29,12 @@ This priority queue is the same as a standard priority queue except: it sorts by std::greater, it has a forward iterator through the elements (which can appear in any order), and its contents can be swapped. */ -template , +template < + class T, class Container = std::vector, #if defined(_MSC_VER) - class Compare = std::greater> + class Compare = std::greater> #else - class Compare = std::greater> + class Compare = std::greater> #endif class PriorityQueue { public: diff --git a/src/lib/base/SimpleEventQueueBuffer.cpp b/src/lib/base/SimpleEventQueueBuffer.cpp index f303a7090..4f4176ea6 100644 --- a/src/lib/base/SimpleEventQueueBuffer.cpp +++ b/src/lib/base/SimpleEventQueueBuffer.cpp @@ -52,8 +52,8 @@ void SimpleEventQueueBuffer::waitForEvent(double timeout) { } } -IEventQueueBuffer::Type SimpleEventQueueBuffer::getEvent(Event &, - UInt32 &dataID) { +IEventQueueBuffer::Type +SimpleEventQueueBuffer::getEvent(Event &, UInt32 &dataID) { ArchMutexLock lock(m_queueMutex); if (!m_queueReady) { return kNone; diff --git a/src/lib/base/Stopwatch.cpp b/src/lib/base/Stopwatch.cpp index 5f40de303..94cfbf6ee 100644 --- a/src/lib/base/Stopwatch.cpp +++ b/src/lib/base/Stopwatch.cpp @@ -24,7 +24,9 @@ // Stopwatch::Stopwatch(bool triggered) - : m_mark(0.0), m_triggered(triggered), m_stopped(triggered) { + : m_mark(0.0), + m_triggered(triggered), + m_stopped(triggered) { if (!triggered) { m_mark = ARCH->time(); } diff --git a/src/lib/base/String.cpp b/src/lib/base/String.cpp index 9947708ff..1c8b8c268 100644 --- a/src/lib/base/String.cpp +++ b/src/lib/base/String.cpp @@ -153,8 +153,8 @@ String sprintf(const char *fmt, ...) { return result; } -void findReplaceAll(String &subject, const String &find, - const String &replace) { +void findReplaceAll( + String &subject, const String &find, const String &replace) { size_t pos = 0; while ((pos = subject.find(find, pos)) != String::npos) { subject.replace(pos, find.length(), replace); @@ -228,21 +228,22 @@ std::vector splitString(String string, const char c) { // CaselessCmp // -bool CaselessCmp::cmpEqual(const String::value_type &a, - const String::value_type &b) { +bool CaselessCmp::cmpEqual( + const String::value_type &a, const String::value_type &b) { // should use std::tolower but not in all versions of libstdc++ have it return tolower(a) == tolower(b); } -bool CaselessCmp::cmpLess(const String::value_type &a, - const String::value_type &b) { +bool CaselessCmp::cmpLess( + const String::value_type &a, const String::value_type &b) { // should use std::tolower but not in all versions of libstdc++ have it return tolower(a) < tolower(b); } bool CaselessCmp::less(const String &a, const String &b) { - return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end(), - &synergy::string::CaselessCmp::cmpLess); + return std::lexicographical_compare( + a.begin(), a.end(), b.begin(), b.end(), + &synergy::string::CaselessCmp::cmpLess); } bool CaselessCmp::equal(const String &a, const String &b) { diff --git a/src/lib/base/String.h b/src/lib/base/String.h index 8e26fc042..9b333cbdb 100644 --- a/src/lib/base/String.h +++ b/src/lib/base/String.h @@ -126,8 +126,8 @@ public: static bool cmpLess(const String::value_type &a, const String::value_type &b); //! Returns true iff \c a is lexicographically equal to \c b - static bool cmpEqual(const String::value_type &a, - const String::value_type &b); + static bool + cmpEqual(const String::value_type &a, const String::value_type &b); }; } // namespace string diff --git a/src/lib/base/TMethodEventJob.h b/src/lib/base/TMethodEventJob.h index 8332ec7aa..a67260d55 100644 --- a/src/lib/base/TMethodEventJob.h +++ b/src/lib/base/TMethodEventJob.h @@ -27,8 +27,8 @@ An event job class that invokes a member function. template class TMethodEventJob : public IEventJob { public: //! run(event) invokes \c object->method(event, arg) - TMethodEventJob(T *object, void (T::*method)(const Event &, void *), - void *arg = NULL); + TMethodEventJob( + T *object, void (T::*method)(const Event &, void *), void *arg = NULL); virtual ~TMethodEventJob(); // IJob overrides @@ -43,7 +43,9 @@ private: template inline TMethodEventJob::TMethodEventJob( T *object, void (T::*method)(const Event &, void *), void *arg) - : m_object(object), m_method(method), m_arg(arg) { + : m_object(object), + m_method(method), + m_arg(arg) { // do nothing } diff --git a/src/lib/base/TMethodJob.h b/src/lib/base/TMethodJob.h index 4163f16f4..6c4cc6bd3 100644 --- a/src/lib/base/TMethodJob.h +++ b/src/lib/base/TMethodJob.h @@ -40,9 +40,11 @@ private: }; template -inline TMethodJob::TMethodJob(T *object, void (T::*method)(void *), - void *arg) - : m_object(object), m_method(method), m_arg(arg) { +inline TMethodJob::TMethodJob( + T *object, void (T::*method)(void *), void *arg) + : m_object(object), + m_method(method), + m_arg(arg) { // do nothing } diff --git a/src/lib/base/Unicode.cpp b/src/lib/base/Unicode.cpp index 48311f7ea..88abaec49 100644 --- a/src/lib/base/Unicode.cpp +++ b/src/lib/base/Unicode.cpp @@ -253,8 +253,8 @@ String Unicode::UTF32ToUTF8(const String &src, bool *errors) { return doUTF32ToUTF8(reinterpret_cast(src.data()), n, errors); } -String Unicode::textToUTF8(const String &src, bool *errors, - IArchString::EWideCharEncoding encoding) { +String Unicode::textToUTF8( + const String &src, bool *errors, IArchString::EWideCharEncoding encoding) { // default to success resetError(errors); @@ -273,8 +273,8 @@ String Unicode::textToUTF8(const String &src, bool *errors, return utf8; } -wchar_t *Unicode::UTF8ToWideChar(const String &src, UInt32 &size, - bool *errors) { +wchar_t * +Unicode::UTF8ToWideChar(const String &src, UInt32 &size, bool *errors) { // convert to platform's wide character encoding String tmp; switch (ARCH->getWideCharEncoding()) { @@ -308,8 +308,9 @@ wchar_t *Unicode::UTF8ToWideChar(const String &src, UInt32 &size, return dst; } -String Unicode::wideCharToUTF8(const wchar_t *src, UInt32 size, bool *errors, - IArchString::EWideCharEncoding encoding) { +String Unicode::wideCharToUTF8( + const wchar_t *src, UInt32 size, bool *errors, + IArchString::EWideCharEncoding encoding) { if (encoding == IArchString::kPlatformDetermined) { encoding = ARCH->getWideCharEncoding(); } diff --git a/src/lib/base/Unicode.h b/src/lib/base/Unicode.h index f9958f224..45147ae97 100644 --- a/src/lib/base/Unicode.h +++ b/src/lib/base/Unicode.h @@ -112,9 +112,10 @@ public: Convert from the current locale encoding to UTF-8. If errors is not NULL then *errors is set to true iff any character could not be decoded. */ - static String textToUTF8(const String &, bool *errors = nullptr, - IArchString::EWideCharEncoding encoding = - IArchString::kPlatformDetermined); + static String textToUTF8( + const String &, bool *errors = nullptr, + IArchString::EWideCharEncoding encoding = + IArchString::kPlatformDetermined); //@} @@ -127,9 +128,10 @@ private: // convert nul terminated wchar_t string (in platform's native // encoding) to UTF8. - static String wideCharToUTF8(const wchar_t *, UInt32 size, bool *errors, - IArchString::EWideCharEncoding encoding = - IArchString::kPlatformDetermined); + static String wideCharToUTF8( + const wchar_t *, UInt32 size, bool *errors, + IArchString::EWideCharEncoding encoding = + IArchString::kPlatformDetermined); // internal conversion to UTF8 static String doUCS2ToUTF8(const UInt8 *src, UInt32 n, bool *errors); diff --git a/src/lib/client/Client.cpp b/src/lib/client/Client.cpp index 2fd3b8ab8..75028710d 100644 --- a/src/lib/client/Client.cpp +++ b/src/lib/client/Client.cpp @@ -53,16 +53,29 @@ // Client // -Client::Client(IEventQueue *events, const String &name, - const NetworkAddress &address, ISocketFactory *socketFactory, - synergy::Screen *screen, lib::synergy::ClientArgs const &args) - : m_mock(false), m_name(name), m_serverAddress(address), - m_socketFactory(socketFactory), m_screen(screen), m_stream(NULL), - m_timer(NULL), m_server(NULL), m_ready(false), m_active(false), - m_suspended(false), m_connectOnResume(false), m_events(events), - m_sendFileThread(nullptr), m_writeToDropDirThread(nullptr), - m_useSecureNetwork(args.m_enableCrypto), m_args(args), - m_enableClipboard(true), m_maximumClipboardSize(INT_MAX) { +Client::Client( + IEventQueue *events, const String &name, const NetworkAddress &address, + ISocketFactory *socketFactory, synergy::Screen *screen, + lib::synergy::ClientArgs const &args) + : m_mock(false), + m_name(name), + m_serverAddress(address), + m_socketFactory(socketFactory), + m_screen(screen), + m_stream(NULL), + m_timer(NULL), + m_server(NULL), + m_ready(false), + m_active(false), + m_suspended(false), + m_connectOnResume(false), + m_events(events), + m_sendFileThread(nullptr), + m_writeToDropDirThread(nullptr), + m_useSecureNetwork(args.m_enableCrypto), + m_args(args), + m_enableClipboard(true), + m_maximumClipboardSize(INT_MAX) { assert(m_socketFactory != NULL); assert(m_screen != NULL); @@ -110,7 +123,8 @@ void Client::connect(size_t addressIndex) { try { if (m_args.m_hostMode) { - LOG((CLOG_NOTE "waiting for server conection on %i port", + LOG( + (CLOG_NOTE "waiting for server conection on %i port", m_serverAddress.getPort())); } else { // resolve the server hostname. do this every time we connect @@ -123,7 +137,8 @@ void Client::connect(size_t addressIndex) { // m_serverAddress will be null if the hostname address is not reolved if (m_serverAddress.getAddress() != nullptr) { // to help users troubleshoot, show server host name (issue: 60) - LOG((CLOG_NOTE "connecting to '%s': %s:%i", + LOG( + (CLOG_NOTE "connecting to '%s': %s:%i", m_serverAddress.getHostname().c_str(), ARCH->addrToString(m_serverAddress.getAddress()).c_str(), m_serverAddress.getPort())); @@ -169,8 +184,9 @@ void Client::refuseConnection(const char *msg) { if (msg) { auto info = new FailInfo(msg); info->m_retry = true; - Event event(m_events->forClient().connectionRefused(), getEventTarget(), - info, Event::kDontFreeData); + Event event( + m_events->forClient().connectionRefused(), getEventTarget(), info, + Event::kDontFreeData); m_events->addEvent(event); } } @@ -201,8 +217,8 @@ void Client::getCursorPos(SInt32 &x, SInt32 &y) const { m_screen->getCursorPos(x, y); } -void Client::enter(SInt32 xAbs, SInt32 yAbs, UInt32, KeyModifierMask mask, - bool) { +void Client::enter( + SInt32 xAbs, SInt32 yAbs, UInt32, KeyModifierMask mask, bool) { m_active = true; m_screen->mouseMove(xAbs, yAbs); m_screen->enter(mask); @@ -246,13 +262,14 @@ void Client::setClipboardDirty(ClipboardID, bool) { assert(0 && "shouldn't be called"); } -void Client::keyDown(KeyID id, KeyModifierMask mask, KeyButton button, - const String &lang) { +void Client::keyDown( + KeyID id, KeyModifierMask mask, KeyButton button, const String &lang) { m_screen->keyDown(id, mask, button, lang); } -void Client::keyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, - KeyButton button, const String &lang) { +void Client::keyRepeat( + KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, + const String &lang) { m_screen->keyRepeat(id, mask, count, button, lang); } @@ -329,7 +346,8 @@ void Client::sendClipboard(ClipboardID id) { // marshall the data String data = clipboard.marshall(); if (data.size() >= m_maximumClipboardSize * 1024) { - LOG((CLOG_NOTE "skipping clipboard transfer because the clipboard" + LOG( + (CLOG_NOTE "skipping clipboard transfer because the clipboard" " contents exceeds the %i MB size limit set by the server", m_maximumClipboardSize / 1024)); return; @@ -353,8 +371,9 @@ void Client::sendEvent(Event::Type type, void *data) { void Client::sendConnectionFailedEvent(const char *msg) { FailInfo *info = new FailInfo(msg); info->m_retry = true; - Event event(m_events->forClient().connectionFailed(), getEventTarget(), info, - Event::kDontFreeData); + Event event( + m_events->forClient().connectionFailed(), getEventTarget(), info, + Event::kDontFreeData); m_events->addEvent(event); } @@ -364,8 +383,8 @@ void Client::sendFileChunk(const void *data) { assert(m_server != NULL); // relay - m_server->fileChunkSending(chunk->m_chunk[0], &chunk->m_chunk[1], - chunk->m_dataSize); + m_server->fileChunkSending( + chunk->m_chunk[0], &chunk->m_chunk[1], chunk->m_dataSize); } void Client::setupConnecting() { @@ -445,27 +464,28 @@ void Client::cleanup() { void Client::cleanupConnecting() { if (m_stream != NULL) { - m_events->removeHandler(m_events->forIDataSocket().connected(), - m_stream->getEventTarget()); - m_events->removeHandler(m_events->forIDataSocket().connectionFailed(), - m_stream->getEventTarget()); + m_events->removeHandler( + m_events->forIDataSocket().connected(), m_stream->getEventTarget()); + m_events->removeHandler( + m_events->forIDataSocket().connectionFailed(), + m_stream->getEventTarget()); } } void Client::cleanupConnection() { if (m_stream != NULL) { - m_events->removeHandler(m_events->forIStream().inputReady(), - m_stream->getEventTarget()); - m_events->removeHandler(m_events->forIStream().outputError(), - m_stream->getEventTarget()); - m_events->removeHandler(m_events->forIStream().inputShutdown(), - m_stream->getEventTarget()); - m_events->removeHandler(m_events->forIStream().outputShutdown(), - m_stream->getEventTarget()); - m_events->removeHandler(m_events->forISocket().disconnected(), - m_stream->getEventTarget()); - m_events->removeHandler(m_events->forISocket().stopRetry(), - m_stream->getEventTarget()); + m_events->removeHandler( + m_events->forIStream().inputReady(), m_stream->getEventTarget()); + m_events->removeHandler( + m_events->forIStream().outputError(), m_stream->getEventTarget()); + m_events->removeHandler( + m_events->forIStream().inputShutdown(), m_stream->getEventTarget()); + m_events->removeHandler( + m_events->forIStream().outputShutdown(), m_stream->getEventTarget()); + m_events->removeHandler( + m_events->forISocket().disconnected(), m_stream->getEventTarget()); + m_events->removeHandler( + m_events->forISocket().stopRetry(), m_stream->getEventTarget()); cleanupStream(); } } @@ -476,10 +496,10 @@ void Client::cleanupScreen() { m_screen->disable(); m_ready = false; } - m_events->removeHandler(m_events->forIScreen().shapeChanged(), - getEventTarget()); - m_events->removeHandler(m_events->forClipboard().clipboardGrabbed(), - getEventTarget()); + m_events->removeHandler( + m_events->forIScreen().shapeChanged(), getEventTarget()); + m_events->removeHandler( + m_events->forClipboard().clipboardGrabbed(), getEventTarget()); delete m_server; m_server = NULL; } @@ -616,8 +636,9 @@ void Client::handleHello(const Event &, void *) { // server LOG((CLOG_NOTE "downgrading protocol version for server")); helloBackMinor = minor; - } else if (major < kProtocolMajorVersion || (major == kProtocolMajorVersion && - minor < kProtocolMinorVersion)) { + } else if ( + major < kProtocolMajorVersion || + (major == kProtocolMajorVersion && minor < kProtocolMinorVersion)) { sendConnectionFailedEvent(XIncompatibleClient(major, minor).what()); cleanupTimer(); cleanupConnection(); @@ -626,8 +647,8 @@ void Client::handleHello(const Event &, void *) { // say hello back LOG((CLOG_DEBUG1 "say hello version %d.%d", helloBackMajor, helloBackMinor)); - ProtocolUtil::writef(m_stream, kMsgHelloBack, helloBackMajor, helloBackMinor, - &m_name); + ProtocolUtil::writef( + m_stream, kMsgHelloBack, helloBackMajor, helloBackMinor, &m_name); // now connected but waiting to complete handshake setupScreen(); @@ -681,7 +702,8 @@ void Client::onFileRecieveCompleted() { void Client::bindNetworkInterface(IDataSocket *socket) const { try { if (!m_args.m_synergyAddress.empty()) { - LOG((CLOG_DEBUG1 "bind to network interface: %s", + LOG( + (CLOG_DEBUG1 "bind to network interface: %s", m_args.m_synergyAddress.c_str())); NetworkAddress bindAddress(m_args.m_synergyAddress); @@ -707,8 +729,8 @@ void Client::writeToDropDirThread(void *) { ARCH->sleep(.1f); } - DropHelper::writeToDir(m_screen->getDropTarget(), m_dragFileList, - m_receivedFileData); + DropHelper::writeToDir( + m_screen->getDropTarget(), m_dragFileList, m_receivedFileData); } void Client::dragInfoReceived(UInt32 fileNum, String data) { diff --git a/src/lib/client/Client.h b/src/lib/client/Client.h index c0dfeaa2b..0072e61c3 100644 --- a/src/lib/client/Client.h +++ b/src/lib/client/Client.h @@ -62,9 +62,10 @@ public: as its name and \p address as the server's address and \p factory to create the socket. \p screen is the local screen. */ - Client(IEventQueue *events, const String &name, const NetworkAddress &address, - ISocketFactory *socketFactory, synergy::Screen *screen, - lib::synergy::ClientArgs const &args); + Client( + IEventQueue *events, const String &name, const NetworkAddress &address, + ISocketFactory *socketFactory, synergy::Screen *screen, + lib::synergy::ClientArgs const &args); Client(Client const &) = delete; Client(Client &&) = delete; ~Client(); @@ -156,20 +157,21 @@ public: // 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 + getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const; virtual void getCursorPos(SInt32 &x, SInt32 &y) const; // IClient overrides - virtual void enter(SInt32 xAbs, SInt32 yAbs, UInt32 seqNum, - KeyModifierMask mask, bool forScreensaver); + virtual void enter( + SInt32 xAbs, SInt32 yAbs, UInt32 seqNum, KeyModifierMask mask, + bool forScreensaver); virtual bool leave(); virtual void setClipboard(ClipboardID, const IClipboard *); virtual void grabClipboard(ClipboardID); virtual void setClipboardDirty(ClipboardID, bool); virtual void keyDown(KeyID, KeyModifierMask, KeyButton, const String &); - virtual void keyRepeat(KeyID, KeyModifierMask, SInt32 count, KeyButton, - const String &lang); + virtual void keyRepeat( + KeyID, KeyModifierMask, SInt32 count, KeyButton, const String &lang); virtual void keyUp(KeyID, KeyModifierMask, KeyButton); virtual void mouseDown(ButtonID); virtual void mouseUp(ButtonID); diff --git a/src/lib/client/ServerProxy.cpp b/src/lib/client/ServerProxy.cpp index 7e8e7199f..1d97a7c98 100644 --- a/src/lib/client/ServerProxy.cpp +++ b/src/lib/client/ServerProxy.cpp @@ -41,13 +41,22 @@ // ServerProxy // -ServerProxy::ServerProxy(Client *client, synergy::IStream *stream, - IEventQueue *events) - : m_client(client), m_stream(stream), m_seqNum(0), m_compressMouse(false), - m_compressMouseRelative(false), m_xMouse(0), m_yMouse(0), m_dxMouse(0), - m_dyMouse(0), m_ignoreMouse(false), m_keepAliveAlarm(0.0), +ServerProxy::ServerProxy( + Client *client, synergy::IStream *stream, IEventQueue *events) + : m_client(client), + m_stream(stream), + m_seqNum(0), + m_compressMouse(false), + m_compressMouseRelative(false), + m_xMouse(0), + m_yMouse(0), + m_dxMouse(0), + m_dyMouse(0), + m_ignoreMouse(false), + m_keepAliveAlarm(0.0), m_keepAliveAlarmTimer(NULL), - m_parser(&ServerProxy::parseHandshakeMessage), m_events(events) { + m_parser(&ServerProxy::parseHandshakeMessage), + m_events(events) { assert(m_client != NULL); assert(m_stream != NULL); @@ -60,9 +69,10 @@ ServerProxy::ServerProxy(Client *client, synergy::IStream *stream, m_events->forIStream().inputReady(), m_stream->getEventTarget(), new TMethodEventJob(this, &ServerProxy::handleData)); - m_events->adoptHandler(m_events->forClipboard().clipboardSending(), this, - new TMethodEventJob( - this, &ServerProxy::handleClipboardSendingEvent)); + m_events->adoptHandler( + m_events->forClipboard().clipboardSending(), this, + new TMethodEventJob( + this, &ServerProxy::handleClipboardSendingEvent)); // send heartbeat setKeepAliveRate(kKeepAliveRate); @@ -70,8 +80,8 @@ ServerProxy::ServerProxy(Client *client, synergy::IStream *stream, ServerProxy::~ServerProxy() { setKeepAliveRate(-1.0); - m_events->removeHandler(m_events->forIStream().inputReady(), - m_stream->getEventTarget()); + m_events->removeHandler( + m_events->forIStream().inputReady(), m_stream->getEventTarget()); } void ServerProxy::resetKeepAliveAlarm() { @@ -82,9 +92,10 @@ void ServerProxy::resetKeepAliveAlarm() { } if (m_keepAliveAlarm > 0.0) { m_keepAliveAlarmTimer = m_events->newOneShotTimer(m_keepAliveAlarm, NULL); - m_events->adoptHandler(Event::kTimer, m_keepAliveAlarmTimer, - new TMethodEventJob( - this, &ServerProxy::handleKeepAliveAlarm)); + m_events->adoptHandler( + Event::kTimer, m_keepAliveAlarmTimer, + new TMethodEventJob( + this, &ServerProxy::handleKeepAliveAlarm)); } } @@ -106,14 +117,16 @@ void ServerProxy::handleData(const Event &, void *) { } // parse message - LOG((CLOG_DEBUG2 "msg from server: %c%c%c%c", code[0], code[1], code[2], + LOG( + (CLOG_DEBUG2 "msg from server: %c%c%c%c", code[0], code[1], code[2], code[3])); switch ((this->*m_parser)(code)) { case kOkay: break; case kUnknown: - LOG((CLOG_ERR "invalid message from server: %c%c%c%c", code[0], code[1], + LOG( + (CLOG_ERR "invalid message from server: %c%c%c%c", code[0], code[1], code[2], code[3])); // not possible to determine message boundaries // read the whole stream to discard unkonwn data @@ -180,7 +193,8 @@ ServerProxy::EResult ServerProxy::parseHandshakeMessage(const UInt8 *code) { } else if (memcmp(code, kMsgEBusy, 4) == 0) { - LOG((CLOG_ERR "server already has a connected client with name \"%s\"", + LOG( + (CLOG_ERR "server already has a connected client with name \"%s\"", m_client->getName().c_str())); m_client->refuseConnection( "server already has a connected client with our name"); @@ -188,7 +202,8 @@ ServerProxy::EResult ServerProxy::parseHandshakeMessage(const UInt8 *code) { } else if (memcmp(code, kMsgEUnknown, 4) == 0) { - LOG((CLOG_ERR "server refused client with name \"%s\"", + LOG( + (CLOG_ERR "server refused client with name \"%s\"", m_client->getName().c_str())); m_client->refuseConnection("server refused client with our name"); return kDisconnect; @@ -225,7 +240,8 @@ ServerProxy::EResult ServerProxy::parseMessage(const UInt8 *code) { UInt16 mask = 0; UInt16 button = 0; ProtocolUtil::readf(m_stream, kMsgDKeyDown + 4, &id, &mask, &button); - LOG((CLOG_DEBUG1 "recv key down id=0x%08x, mask=0x%04x, button=0x%04x", id, + LOG( + (CLOG_DEBUG1 "recv key down id=0x%08x, mask=0x%04x, button=0x%04x", id, mask, button)); keyDown(id, mask, button, ""); @@ -237,9 +253,10 @@ ServerProxy::EResult ServerProxy::parseMessage(const UInt8 *code) { UInt16 mask = 0; UInt16 button = 0; - ProtocolUtil::readf(m_stream, kMsgDKeyDownLang + 4, &id, &mask, &button, - &lang); - LOG((CLOG_DEBUG1 + ProtocolUtil::readf( + m_stream, kMsgDKeyDownLang + 4, &id, &mask, &button, &lang); + LOG( + (CLOG_DEBUG1 "recv key down id=0x%08x, mask=0x%04x, button=0x%04x, lang=\"%s\"", id, mask, button, lang.c_str())); @@ -361,8 +378,8 @@ bool ServerProxy::onGrabClipboard(ClipboardID id) { return true; } -void ServerProxy::onClipboardChanged(ClipboardID id, - const IClipboard *clipboard) { +void ServerProxy::onClipboardChanged( + ClipboardID id, const IClipboard *clipboard) { String data = IClipboard::marshall(clipboard); LOG((CLOG_DEBUG "sending clipboard %d seqnum=%d", id, m_seqNum)); @@ -383,10 +400,12 @@ void ServerProxy::flushCompressedMouse() { } void ServerProxy::sendInfo(const ClientInfo &info) { - LOG((CLOG_DEBUG1 "sending info shape=%d,%d %dx%d", info.m_x, info.m_y, + LOG( + (CLOG_DEBUG1 "sending info shape=%d,%d %dx%d", info.m_x, info.m_y, info.m_w, info.m_h)); - ProtocolUtil::writef(m_stream, kMsgDInfo, info.m_x, info.m_y, info.m_w, - info.m_h, 0, info.m_mx, info.m_my); + ProtocolUtil::writef( + m_stream, kMsgDInfo, info.m_x, info.m_y, info.m_w, info.m_h, 0, info.m_mx, + info.m_my); } KeyID ServerProxy::translateKey(KeyID id) const { @@ -562,8 +581,8 @@ void ServerProxy::grabClipboard() { m_client->grabClipboard(id); } -void ServerProxy::keyDown(UInt16 id, UInt16 mask, UInt16 button, - const String &lang) { +void ServerProxy::keyDown( + UInt16 id, UInt16 mask, UInt16 button, const String &lang) { // get mouse up to date flushCompressedMouse(); setActiveServerLanguage(lang); @@ -574,7 +593,8 @@ void ServerProxy::keyDown(UInt16 id, UInt16 mask, UInt16 button, translateModifierMask(static_cast(mask)); if (id2 != static_cast(id) || mask2 != static_cast(mask)) - LOG((CLOG_DEBUG1 "key down translated to id=0x%08x, mask=0x%04x", id2, + LOG( + (CLOG_DEBUG1 "key down translated to id=0x%08x, mask=0x%04x", id2, mask2)); // forward @@ -588,9 +608,10 @@ void ServerProxy::keyRepeat() { // parse UInt16 id, mask, count, button; String lang; - ProtocolUtil::readf(m_stream, kMsgDKeyRepeat + 4, &id, &mask, &count, &button, - &lang); - LOG((CLOG_DEBUG1 "recv key repeat id=0x%08x, mask=0x%04x, count=%d, " + ProtocolUtil::readf( + m_stream, kMsgDKeyRepeat + 4, &id, &mask, &count, &button, &lang); + LOG( + (CLOG_DEBUG1 "recv key repeat id=0x%08x, mask=0x%04x, count=%d, " "button=0x%04x, lang=\"%s\"", id, mask, count, button, lang.c_str())); @@ -600,7 +621,8 @@ void ServerProxy::keyRepeat() { translateModifierMask(static_cast(mask)); if (id2 != static_cast(id) || mask2 != static_cast(mask)) - LOG((CLOG_DEBUG1 "key repeat translated to id=0x%08x, mask=0x%04x", id2, + LOG( + (CLOG_DEBUG1 "key repeat translated to id=0x%08x, mask=0x%04x", id2, mask2)); // forward @@ -614,7 +636,8 @@ void ServerProxy::keyUp() { // parse UInt16 id, mask, button; ProtocolUtil::readf(m_stream, kMsgDKeyUp + 4, &id, &mask, &button); - LOG((CLOG_DEBUG1 "recv key up id=0x%08x, mask=0x%04x, button=0x%04x", id, + LOG( + (CLOG_DEBUG1 "recv key up id=0x%08x, mask=0x%04x, button=0x%04x", id, mask, button)); // translate @@ -623,8 +646,8 @@ void ServerProxy::keyUp() { translateModifierMask(static_cast(mask)); if (id2 != static_cast(id) || mask2 != static_cast(mask)) - LOG((CLOG_DEBUG1 "key up translated to id=0x%08x, mask=0x%04x", id2, - mask2)); + LOG(( + CLOG_DEBUG1 "key up translated to id=0x%08x, mask=0x%04x", id2, mask2)); // forward m_client->keyUp(id2, mask2, button); @@ -786,7 +809,8 @@ void ServerProxy::setOptions() { if (id != kKeyModifierIDNull) { m_modifierTranslationTable[id] = static_cast(options[i + 1]); - LOG((CLOG_DEBUG1 "modifier %d mapped to %d", id, + LOG( + (CLOG_DEBUG1 "modifier %d mapped to %d", id, m_modifierTranslationTable[id])); } } @@ -805,8 +829,9 @@ void ServerProxy::infoAcknowledgment() { } void ServerProxy::fileChunkReceived() { - int result = FileChunk::assemble(m_stream, m_client->getReceivedFileData(), - m_client->getExpectedFileSize()); + int result = FileChunk::assemble( + m_stream, m_client->getReceivedFileData(), + m_client->getExpectedFileSize()); if (result == kFinish) { m_events->addEvent( @@ -836,8 +861,8 @@ void ServerProxy::fileChunkSending(UInt8 mark, char *data, size_t dataSize) { FileChunk::send(m_stream, mark, data, dataSize); } -void ServerProxy::sendDragInfo(UInt32 fileCount, const char *info, - size_t size) { +void ServerProxy::sendDragInfo( + UInt32 fileCount, const char *info, size_t size) { String data(info, size); ProtocolUtil::writef(m_stream, kMsgDDragInfo, fileCount, &data); } @@ -848,11 +873,11 @@ void ServerProxy::secureInputNotification() { // display this notification on the client if (app != "unknown") { - AppUtil::instance().showNotification("The keyboard may stop working.", - "'Secure input' enabled by " + app + - " on the server. " - "To fix the keyboard, " + - app + " must be closed."); + AppUtil::instance().showNotification( + "The keyboard may stop working.", "'Secure input' enabled by " + app + + " on the server. " + "To fix the keyboard, " + + app + " must be closed."); } else { AppUtil::instance().showNotification( "The keyboard may stop working.", @@ -863,8 +888,8 @@ void ServerProxy::secureInputNotification() { void ServerProxy::setServerLanguages() { String serverLanguages; - ProtocolUtil::readf(m_stream, kMsgDLanguageSynchronisation + 4, - &serverLanguages); + ProtocolUtil::readf( + m_stream, kMsgDLanguageSynchronisation + 4, &serverLanguages); m_languageManager.setRemoteLanguages(serverLanguages); } @@ -891,7 +916,8 @@ void ServerProxy::setActiveServerLanguage(const String &language) { void ServerProxy::checkMissedLanguages() const { auto missedLanguages = m_languageManager.getMissedLanguages(); if (!missedLanguages.empty()) { - LOG((CLOG_WARN + LOG( + (CLOG_WARN "You need to install these languages on this computer and restart " "Synergy to enable support for multiple languages: %s", missedLanguages.c_str())); diff --git a/src/lib/common/stdsstream.h b/src/lib/common/stdsstream.h index 8184ef053..d80ed7417 100644 --- a/src/lib/common/stdsstream.h +++ b/src/lib/common/stdsstream.h @@ -67,13 +67,17 @@ public: typedef streamoff off_type; explicit stringbuf(int which = ios::in | ios::out) - : streambuf(), mode(static_cast(which)), stream(NULL), + : streambuf(), + mode(static_cast(which)), + stream(NULL), stream_len(0) { stringbuf_init(); } explicit stringbuf(const string &str, int which = ios::in | ios::out) - : streambuf(), mode(static_cast(which)), stream(NULL), + : streambuf(), + mode(static_cast(which)), + stream(NULL), stream_len(0) { if (mode & (ios::in | ios::out)) { stream_len = str.size(); @@ -135,8 +139,8 @@ protected: return this; } - virtual pos_type seekoff(off_type off, ios::seek_dir way, - int which = ios::in | ios::out) { + virtual pos_type + seekoff(off_type off, ios::seek_dir way, int which = ios::in | ios::out) { pos_type ret = pos_type(off_type(-1)); bool testin = which & ios::in && mode & ios::in; bool testout = which & ios::out && mode & ios::out; @@ -217,10 +221,12 @@ public: typedef streamoff off_type; explicit istringstream(int which = ios::in) - : istream(&sb), sb(which | ios::in) {} + : istream(&sb), + sb(which | ios::in) {} explicit istringstream(const string &str, int which = ios::in) - : istream(&sb), sb(str, which | ios::in) {} + : istream(&sb), + sb(str, which | ios::in) {} stringbuf *rdbuf() const { return const_cast(&sb); } @@ -239,10 +245,12 @@ public: typedef streamoff off_type; explicit ostringstream(int which = ios::out) - : ostream(&sb), sb(which | ios::out) {} + : ostream(&sb), + sb(which | ios::out) {} explicit ostringstream(const string &str, int which = ios::out) - : ostream(&sb), sb(str, which | ios::out) {} + : ostream(&sb), + sb(str, which | ios::out) {} stringbuf *rdbuf() const { return const_cast(&sb); } @@ -262,10 +270,12 @@ public: typedef streamoff off_type; explicit stringstream(int which = ios::out | ios::in) - : iostream(&sb), sb(which) {} + : iostream(&sb), + sb(which) {} explicit stringstream(const string &str, int which = ios::out | ios::in) - : iostream(&sb), sb(str, which) {} + : iostream(&sb), + sb(str, which) {} stringbuf *rdbuf() const { return const_cast(&sb); } diff --git a/src/lib/io/StreamFilter.cpp b/src/lib/io/StreamFilter.cpp index db4c030f1..d17860eba 100644 --- a/src/lib/io/StreamFilter.cpp +++ b/src/lib/io/StreamFilter.cpp @@ -24,14 +24,17 @@ // StreamFilter // -StreamFilter::StreamFilter(IEventQueue *events, synergy::IStream *stream, - bool adoptStream) - : m_stream(stream), m_adopted(adoptStream), m_events(events) { +StreamFilter::StreamFilter( + IEventQueue *events, synergy::IStream *stream, bool adoptStream) + : m_stream(stream), + m_adopted(adoptStream), + m_events(events) { // replace handlers for m_stream m_events->removeHandlers(m_stream->getEventTarget()); - m_events->adoptHandler(Event::kUnknown, m_stream->getEventTarget(), - new TMethodEventJob( - this, &StreamFilter::handleUpstreamEvent)); + m_events->adoptHandler( + Event::kUnknown, m_stream->getEventTarget(), + new TMethodEventJob( + this, &StreamFilter::handleUpstreamEvent)); } StreamFilter::~StreamFilter() { diff --git a/src/lib/io/StreamFilter.h b/src/lib/io/StreamFilter.h index 23d46444c..41342562b 100644 --- a/src/lib/io/StreamFilter.h +++ b/src/lib/io/StreamFilter.h @@ -33,8 +33,8 @@ public: this object takes ownership of the stream and will delete it in the d'tor. */ - StreamFilter(IEventQueue *events, synergy::IStream *stream, - bool adoptStream = true); + StreamFilter( + IEventQueue *events, synergy::IStream *stream, bool adoptStream = true); StreamFilter(StreamFilter const &) = delete; StreamFilter(StreamFilter &&) = delete; virtual ~StreamFilter(); diff --git a/src/lib/ipc/IpcClient.cpp b/src/lib/ipc/IpcClient.cpp index 32876ee2b..fe8736908 100644 --- a/src/lib/ipc/IpcClient.cpp +++ b/src/lib/ipc/IpcClient.cpp @@ -28,14 +28,18 @@ IpcClient::IpcClient(IEventQueue *events, SocketMultiplexer *socketMultiplexer) : m_serverAddress(NetworkAddress(IPC_HOST, IPC_PORT)), - m_socket(events, socketMultiplexer), m_server(nullptr), m_events(events) { + m_socket(events, socketMultiplexer), + m_server(nullptr), + m_events(events) { init(); } -IpcClient::IpcClient(IEventQueue *events, SocketMultiplexer *socketMultiplexer, - int port) +IpcClient::IpcClient( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, int port) : m_serverAddress(NetworkAddress(IPC_HOST, port)), - m_socket(events, socketMultiplexer), m_server(nullptr), m_events(events) { + m_socket(events, socketMultiplexer), + m_server(nullptr), + m_events(events) { init(); } @@ -57,10 +61,10 @@ void IpcClient::connect() { } void IpcClient::disconnect() { - m_events->removeHandler(m_events->forIDataSocket().connected(), - m_socket.getEventTarget()); - m_events->removeHandler(m_events->forIpcServerProxy().messageReceived(), - m_server); + m_events->removeHandler( + m_events->forIDataSocket().connected(), m_socket.getEventTarget()); + m_events->removeHandler( + m_events->forIpcServerProxy().messageReceived(), m_server); m_server->disconnect(); delete m_server; @@ -73,8 +77,9 @@ void IpcClient::send(const IpcMessage &message) { } void IpcClient::handleConnected(const Event &, void *) { - m_events->addEvent(Event(m_events->forIpcClient().connected(), this, m_server, - Event::kDontFreeData)); + m_events->addEvent(Event( + m_events->forIpcClient().connected(), this, m_server, + Event::kDontFreeData)); IpcHelloMessage message(kIpcClientNode); send(message); diff --git a/src/lib/ipc/IpcClient.h b/src/lib/ipc/IpcClient.h index b03667de1..2c89ac1e4 100644 --- a/src/lib/ipc/IpcClient.h +++ b/src/lib/ipc/IpcClient.h @@ -34,8 +34,8 @@ class SocketMultiplexer; class IpcClient { public: IpcClient(IEventQueue *events, SocketMultiplexer *socketMultiplexer); - IpcClient(IEventQueue *events, SocketMultiplexer *socketMultiplexer, - int port); + IpcClient( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, int port); virtual ~IpcClient(); //! @name manipulators diff --git a/src/lib/ipc/IpcClientProxy.cpp b/src/lib/ipc/IpcClientProxy.cpp index 27d26096f..7c5dcc7fb 100644 --- a/src/lib/ipc/IpcClientProxy.cpp +++ b/src/lib/ipc/IpcClientProxy.cpp @@ -32,38 +32,41 @@ // IpcClientProxy::IpcClientProxy(synergy::IStream &stream, IEventQueue *events) - : m_stream(stream), m_clientType(kIpcClientUnknown), m_disconnecting(false), - m_readMutex(ARCH->newMutex()), m_writeMutex(ARCH->newMutex()), + : m_stream(stream), + m_clientType(kIpcClientUnknown), + m_disconnecting(false), + m_readMutex(ARCH->newMutex()), + m_writeMutex(ARCH->newMutex()), m_events(events) { m_events->adoptHandler( m_events->forIStream().inputReady(), stream.getEventTarget(), new TMethodEventJob(this, &IpcClientProxy::handleData)); - m_events->adoptHandler(m_events->forIStream().outputError(), - stream.getEventTarget(), - new TMethodEventJob( - this, &IpcClientProxy::handleWriteError)); + m_events->adoptHandler( + m_events->forIStream().outputError(), stream.getEventTarget(), + new TMethodEventJob( + this, &IpcClientProxy::handleWriteError)); - m_events->adoptHandler(m_events->forIStream().inputShutdown(), - stream.getEventTarget(), - new TMethodEventJob( - this, &IpcClientProxy::handleDisconnect)); + m_events->adoptHandler( + m_events->forIStream().inputShutdown(), stream.getEventTarget(), + new TMethodEventJob( + this, &IpcClientProxy::handleDisconnect)); - m_events->adoptHandler(m_events->forIStream().outputShutdown(), - stream.getEventTarget(), - new TMethodEventJob( - this, &IpcClientProxy::handleWriteError)); + m_events->adoptHandler( + m_events->forIStream().outputShutdown(), stream.getEventTarget(), + new TMethodEventJob( + this, &IpcClientProxy::handleWriteError)); } IpcClientProxy::~IpcClientProxy() { - m_events->removeHandler(m_events->forIStream().inputReady(), - m_stream.getEventTarget()); - m_events->removeHandler(m_events->forIStream().outputError(), - m_stream.getEventTarget()); - m_events->removeHandler(m_events->forIStream().inputShutdown(), - m_stream.getEventTarget()); - m_events->removeHandler(m_events->forIStream().outputShutdown(), - m_stream.getEventTarget()); + m_events->removeHandler( + m_events->forIStream().inputReady(), m_stream.getEventTarget()); + m_events->removeHandler( + m_events->forIStream().outputError(), m_stream.getEventTarget()); + m_events->removeHandler( + m_events->forIStream().inputShutdown(), m_stream.getEventTarget()); + m_events->removeHandler( + m_events->forIStream().outputShutdown(), m_stream.getEventTarget()); // don't delete the stream while it's being used. ARCH->lockMutex(m_readMutex); @@ -111,8 +114,9 @@ void IpcClientProxy::handleData(const Event &, void *) { } // don't delete with this event; the data is passed to a new event. - Event e(m_events->forIpcClientProxy().messageReceived(), this, NULL, - Event::kDontFreeData); + Event e( + m_events->forIpcClientProxy().messageReceived(), this, NULL, + Event::kDontFreeData); e.setDataObject(m); m_events->addEvent(e); diff --git a/src/lib/ipc/IpcLogOutputter.cpp b/src/lib/ipc/IpcLogOutputter.cpp index be9a8c5af..91891714a 100644 --- a/src/lib/ipc/IpcLogOutputter.cpp +++ b/src/lib/ipc/IpcLogOutputter.cpp @@ -37,16 +37,23 @@ enum EIpcLogOutputter { kBufferRateTimeLimit = 1 // seconds }; -IpcLogOutputter::IpcLogOutputter(IpcServer &ipcServer, - EIpcClientType clientType, bool useThread) - : m_ipcServer(ipcServer), m_bufferMutex(ARCH->newMutex()), m_sending(false), - m_bufferThread(nullptr), m_running(false), - m_notifyCond(ARCH->newCondVar()), m_notifyMutex(ARCH->newMutex()), - m_bufferThreadId(0), m_bufferWaiting(false), +IpcLogOutputter::IpcLogOutputter( + IpcServer &ipcServer, EIpcClientType clientType, bool useThread) + : m_ipcServer(ipcServer), + m_bufferMutex(ARCH->newMutex()), + m_sending(false), + m_bufferThread(nullptr), + m_running(false), + m_notifyCond(ARCH->newCondVar()), + m_notifyMutex(ARCH->newMutex()), + m_bufferThreadId(0), + m_bufferWaiting(false), m_bufferMaxSize(kBufferMaxSize), m_bufferRateWriteLimit(kBufferRateWriteLimit), - m_bufferRateTimeLimit(kBufferRateTimeLimit), m_bufferWriteCount(0), - m_bufferRateStart(ARCH->time()), m_clientType(clientType), + m_bufferRateTimeLimit(kBufferRateTimeLimit), + m_bufferWriteCount(0), + m_bufferRateStart(ARCH->time()), + m_clientType(clientType), m_runningMutex(ARCH->newMutex()) { if (useThread) { m_bufferThread = new Thread( diff --git a/src/lib/ipc/IpcLogOutputter.h b/src/lib/ipc/IpcLogOutputter.h index bc985776c..a0f866cc6 100644 --- a/src/lib/ipc/IpcLogOutputter.h +++ b/src/lib/ipc/IpcLogOutputter.h @@ -40,8 +40,8 @@ public: If \p useThread is \c false, then the buffer needs to be sent manually using the \c sendBuffer() function. */ - IpcLogOutputter(IpcServer &ipcServer, EIpcClientType clientType, - bool useThread); + IpcLogOutputter( + IpcServer &ipcServer, EIpcClientType clientType, bool useThread); IpcLogOutputter(IpcLogOutputter const &) = delete; virtual ~IpcLogOutputter(); diff --git a/src/lib/ipc/IpcMessage.cpp b/src/lib/ipc/IpcMessage.cpp index 5aef66f5d..e2fd70a64 100644 --- a/src/lib/ipc/IpcMessage.cpp +++ b/src/lib/ipc/IpcMessage.cpp @@ -24,7 +24,8 @@ IpcMessage::IpcMessage(UInt8 type) : m_type(type) {} IpcMessage::~IpcMessage() {} IpcHelloMessage::IpcHelloMessage(EIpcClientType clientType) - : IpcMessage(kIpcHello), m_clientType(clientType) {} + : IpcMessage(kIpcHello), + m_clientType(clientType) {} IpcHelloMessage::~IpcHelloMessage() {} @@ -37,11 +38,14 @@ IpcShutdownMessage::IpcShutdownMessage() : IpcMessage(kIpcShutdown) {} IpcShutdownMessage::~IpcShutdownMessage() {} IpcLogLineMessage::IpcLogLineMessage(const String &logLine) - : IpcMessage(kIpcLogLine), m_logLine(logLine) {} + : IpcMessage(kIpcLogLine), + m_logLine(logLine) {} IpcLogLineMessage::~IpcLogLineMessage() {} IpcCommandMessage::IpcCommandMessage(const String &command, bool elevate) - : IpcMessage(kIpcCommand), m_command(command), m_elevate(elevate) {} + : IpcMessage(kIpcCommand), + m_command(command), + m_elevate(elevate) {} IpcCommandMessage::~IpcCommandMessage() {} diff --git a/src/lib/ipc/IpcServer.cpp b/src/lib/ipc/IpcServer.cpp index c055ebffd..1cafec99d 100644 --- a/src/lib/ipc/IpcServer.cpp +++ b/src/lib/ipc/IpcServer.cpp @@ -33,21 +33,26 @@ // IpcServer::IpcServer(IEventQueue *events, SocketMultiplexer *socketMultiplexer) - : m_mock(false), m_events(events), m_socketMultiplexer(socketMultiplexer), - m_socket(nullptr), m_address(NetworkAddress(IPC_HOST, IPC_PORT)) { + : m_mock(false), + m_events(events), + m_socketMultiplexer(socketMultiplexer), + m_socket(nullptr), + m_address(NetworkAddress(IPC_HOST, IPC_PORT)) { init(); } -IpcServer::IpcServer(IEventQueue *events, SocketMultiplexer *socketMultiplexer, - int port) - : m_mock(false), m_events(events), m_socketMultiplexer(socketMultiplexer), +IpcServer::IpcServer( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, int port) + : m_mock(false), + m_events(events), + m_socketMultiplexer(socketMultiplexer), m_address(NetworkAddress(IPC_HOST, port)) { init(); } void IpcServer::init() { - m_socket = new TCPListenSocket(m_events, m_socketMultiplexer, - IArchNetwork::EAddressFamily::kINET); + m_socket = new TCPListenSocket( + m_events, m_socketMultiplexer, IArchNetwork::EAddressFamily::kINET); m_clientsMutex = ARCH->newMutex(); m_address.resolve(); @@ -93,16 +98,18 @@ void IpcServer::handleClientConnecting(const Event &, void *) { m_clients.push_back(proxy); ARCH->unlockMutex(m_clientsMutex); - m_events->adoptHandler(m_events->forIpcClientProxy().disconnected(), proxy, - new TMethodEventJob( - this, &IpcServer::handleClientDisconnected)); + m_events->adoptHandler( + m_events->forIpcClientProxy().disconnected(), proxy, + new TMethodEventJob( + this, &IpcServer::handleClientDisconnected)); m_events->adoptHandler( m_events->forIpcClientProxy().messageReceived(), proxy, new TMethodEventJob(this, &IpcServer::handleMessageReceived)); - m_events->addEvent(Event(m_events->forIpcServer().clientConnected(), this, - proxy, Event::kDontFreeData)); + m_events->addEvent(Event( + m_events->forIpcServer().clientConnected(), this, proxy, + Event::kDontFreeData)); } void IpcServer::handleClientDisconnected(const Event &e, void *) { @@ -122,8 +129,8 @@ void IpcServer::handleMessageReceived(const Event &e, void *) { } void IpcServer::deleteClient(IpcClientProxy *proxy) { - m_events->removeHandler(m_events->forIpcClientProxy().messageReceived(), - proxy); + m_events->removeHandler( + m_events->forIpcClientProxy().messageReceived(), proxy); m_events->removeHandler(m_events->forIpcClientProxy().disconnected(), proxy); delete proxy; } diff --git a/src/lib/ipc/IpcServer.h b/src/lib/ipc/IpcServer.h index 0f235ea99..36357d856 100644 --- a/src/lib/ipc/IpcServer.h +++ b/src/lib/ipc/IpcServer.h @@ -42,8 +42,8 @@ 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( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, int port); IpcServer(IpcServer const &) = delete; IpcServer(IpcServer &&) = delete; virtual ~IpcServer(); @@ -90,7 +90,9 @@ private: #ifdef TEST_ENV public: IpcServer() - : m_mock(true), m_events(nullptr), m_socketMultiplexer(nullptr), + : m_mock(true), + m_events(nullptr), + m_socketMultiplexer(nullptr), m_socket(nullptr) {} #endif }; diff --git a/src/lib/ipc/IpcServerProxy.cpp b/src/lib/ipc/IpcServerProxy.cpp index 480804964..545d9b2cb 100644 --- a/src/lib/ipc/IpcServerProxy.cpp +++ b/src/lib/ipc/IpcServerProxy.cpp @@ -30,15 +30,16 @@ // IpcServerProxy::IpcServerProxy(synergy::IStream &stream, IEventQueue *events) - : m_stream(stream), m_events(events) { + : m_stream(stream), + m_events(events) { m_events->adoptHandler( m_events->forIStream().inputReady(), stream.getEventTarget(), new TMethodEventJob(this, &IpcServerProxy::handleData)); } IpcServerProxy::~IpcServerProxy() { - m_events->removeHandler(m_events->forIStream().inputReady(), - m_stream.getEventTarget()); + m_events->removeHandler( + m_events->forIStream().inputReady(), m_stream.getEventTarget()); } void IpcServerProxy::handleData(const Event &, void *) { @@ -61,8 +62,9 @@ void IpcServerProxy::handleData(const Event &, void *) { } // don't delete with this event; the data is passed to a new event. - Event e(m_events->forIpcServerProxy().messageReceived(), this, NULL, - Event::kDontFreeData); + Event e( + m_events->forIpcServerProxy().messageReceived(), this, NULL, + Event::kDontFreeData); e.setDataObject(m); m_events->addEvent(e); diff --git a/src/lib/ipc/IpcSettingMessage.cpp b/src/lib/ipc/IpcSettingMessage.cpp index b31e86099..b539520bb 100644 --- a/src/lib/ipc/IpcSettingMessage.cpp +++ b/src/lib/ipc/IpcSettingMessage.cpp @@ -18,9 +18,11 @@ #include "IpcSettingMessage.h" -IpcSettingMessage::IpcSettingMessage(const std::string &name, - const std::string &value) - : IpcMessage(kIpcSetting), m_name(name), m_value(value) {} +IpcSettingMessage::IpcSettingMessage( + const std::string &name, const std::string &value) + : IpcMessage(kIpcSetting), + m_name(name), + m_value(value) {} const std::string &IpcSettingMessage::getName() const { return m_name; } diff --git a/src/lib/mt/CondVar.h b/src/lib/mt/CondVar.h index d8c30f68d..76dfaa183 100644 --- a/src/lib/mt/CondVar.h +++ b/src/lib/mt/CondVar.h @@ -172,13 +172,15 @@ private: template inline CondVar::CondVar(Mutex *mutex, const T &data) - : CondVarBase(mutex), m_data(data) { + : CondVarBase(mutex), + m_data(data) { // do nothing } template inline CondVar::CondVar(const CondVar &cv) - : CondVarBase(cv.getMutex()), m_data(cv.m_data) { + : CondVarBase(cv.getMutex()), + m_data(cv.m_data) { // do nothing } diff --git a/src/lib/net/ISocketFactory.h b/src/lib/net/ISocketFactory.h index 3f063c482..4e5f84d62 100644 --- a/src/lib/net/ISocketFactory.h +++ b/src/lib/net/ISocketFactory.h @@ -35,9 +35,9 @@ public: //@{ //! Create data socket - virtual IDataSocket * - create(bool secure, - IArchNetwork::EAddressFamily family = IArchNetwork::kINET) const = 0; + virtual IDataSocket *create( + bool secure, + IArchNetwork::EAddressFamily family = IArchNetwork::kINET) const = 0; //! Create listen socket virtual IListenSocket *createListen( diff --git a/src/lib/net/ISocketMultiplexerJob.h b/src/lib/net/ISocketMultiplexerJob.h index fdd819bb8..601592141 100644 --- a/src/lib/net/ISocketMultiplexerJob.h +++ b/src/lib/net/ISocketMultiplexerJob.h @@ -45,8 +45,8 @@ public: multiplexer. It must instead return the new job. It can, however, add or remove jobs for other sockets. */ - virtual ISocketMultiplexerJob *run(bool readable, bool writable, - bool error) = 0; + virtual ISocketMultiplexerJob * + run(bool readable, bool writable, bool error) = 0; //@} //! @name accessors diff --git a/src/lib/net/InverseSockets/InverseClientSocket.cpp b/src/lib/net/InverseSockets/InverseClientSocket.cpp index 07c8f0dbd..9c2ca6a7a 100644 --- a/src/lib/net/InverseSockets/InverseClientSocket.cpp +++ b/src/lib/net/InverseSockets/InverseClientSocket.cpp @@ -37,11 +37,14 @@ // InverseClientSocket // -InverseClientSocket::InverseClientSocket(IEventQueue *events, - SocketMultiplexer *socketMultiplexer, - IArchNetwork::EAddressFamily family) - : IDataSocket(events), m_events(events), m_socket(family), - m_listener(family), m_flushed(&m_mutex, true), +InverseClientSocket::InverseClientSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + IArchNetwork::EAddressFamily family) + : IDataSocket(events), + m_events(events), + m_socket(family), + m_listener(family), + m_flushed(&m_mutex, true), m_socketMultiplexer(socketMultiplexer) {} InverseClientSocket::~InverseClientSocket() { @@ -274,8 +277,9 @@ ISocketMultiplexerJob *InverseClientSocket::newJob(ArchSocket socket) { void InverseClientSocket::sendConnectionFailedEvent(const char *msg) { auto info = new ConnectionFailedInfo(msg); - m_events->addEvent(Event(m_events->forIDataSocket().connectionFailed(), - getEventTarget(), info, Event::kDontFreeData)); + m_events->addEvent(Event( + m_events->forIDataSocket().connectionFailed(), getEventTarget(), info, + Event::kDontFreeData)); } void InverseClientSocket::sendEvent(Event::Type type) { @@ -322,9 +326,8 @@ void InverseClientSocket::onDisconnected() { m_connected = false; } -ISocketMultiplexerJob * -InverseClientSocket::serviceConnecting(ISocketMultiplexerJob *job, bool read, - bool, bool) { +ISocketMultiplexerJob *InverseClientSocket::serviceConnecting( + ISocketMultiplexerJob *job, bool read, bool, bool) { Lock lock(&m_mutex); if (read) { @@ -336,9 +339,8 @@ InverseClientSocket::serviceConnecting(ISocketMultiplexerJob *job, bool read, return job; } -ISocketMultiplexerJob * -InverseClientSocket::serviceConnected(ISocketMultiplexerJob *job, bool read, - bool write, bool error) { +ISocketMultiplexerJob *InverseClientSocket::serviceConnected( + ISocketMultiplexerJob *job, bool read, bool write, bool error) { Lock lock(&m_mutex); if (error) { diff --git a/src/lib/net/InverseSockets/InverseClientSocket.h b/src/lib/net/InverseSockets/InverseClientSocket.h index 4136f1677..397279ec6 100644 --- a/src/lib/net/InverseSockets/InverseClientSocket.h +++ b/src/lib/net/InverseSockets/InverseClientSocket.h @@ -90,10 +90,10 @@ private: void onOutputShutdown(); void onDisconnected(); - ISocketMultiplexerJob *serviceConnecting(ISocketMultiplexerJob *, bool, bool, - bool); - ISocketMultiplexerJob *serviceConnected(ISocketMultiplexerJob *, bool, bool, - bool); + ISocketMultiplexerJob * + serviceConnecting(ISocketMultiplexerJob *, bool, bool, bool); + ISocketMultiplexerJob * + serviceConnected(ISocketMultiplexerJob *, bool, bool, bool); protected: bool m_readable = false; diff --git a/src/lib/net/InverseSockets/InverseServerSocket.cpp b/src/lib/net/InverseSockets/InverseServerSocket.cpp index 09e43c7fd..bfbab395d 100644 --- a/src/lib/net/InverseSockets/InverseServerSocket.cpp +++ b/src/lib/net/InverseSockets/InverseServerSocket.cpp @@ -35,10 +35,11 @@ // InverseServerSocket // -InverseServerSocket::InverseServerSocket(IEventQueue *events, - SocketMultiplexer *socketMultiplexer, - IArchNetwork::EAddressFamily family) - : m_socket(family), m_events(events), +InverseServerSocket::InverseServerSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + IArchNetwork::EAddressFamily family) + : m_socket(family), + m_events(events), m_socketMultiplexer(socketMultiplexer) {} InverseServerSocket::~InverseServerSocket() { @@ -93,9 +94,8 @@ void InverseServerSocket::setListeningJob(bool read) { m_socket.getRawSocket(), true, read)); } -ISocketMultiplexerJob * -InverseServerSocket::serviceListening(ISocketMultiplexerJob *job, bool, - bool write, bool error) { +ISocketMultiplexerJob *InverseServerSocket::serviceListening( + ISocketMultiplexerJob *job, bool, bool write, bool error) { if (error) { m_socket.connectSocket(m_address); return job; diff --git a/src/lib/net/InverseSockets/InverseServerSocket.h b/src/lib/net/InverseSockets/InverseServerSocket.h index a0fceb2b5..bbbd630b5 100644 --- a/src/lib/net/InverseSockets/InverseServerSocket.h +++ b/src/lib/net/InverseSockets/InverseServerSocket.h @@ -29,8 +29,9 @@ class SocketMultiplexer; class InverseServerSocket : public IListenSocket { public: - InverseServerSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, - IArchNetwork::EAddressFamily family); + InverseServerSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + IArchNetwork::EAddressFamily family); InverseServerSocket(InverseServerSocket const &) = delete; InverseServerSocket(InverseServerSocket &&) = delete; ~InverseServerSocket() override; @@ -50,8 +51,8 @@ protected: void setListeningJob(bool read = false); public: - ISocketMultiplexerJob *serviceListening(ISocketMultiplexerJob *, bool, bool, - bool); + ISocketMultiplexerJob * + serviceListening(ISocketMultiplexerJob *, bool, bool, bool); protected: AutoArchSocket m_socket; diff --git a/src/lib/net/InverseSockets/InverseSocketFactory.cpp b/src/lib/net/InverseSockets/InverseSocketFactory.cpp index 8840da937..2694304a0 100644 --- a/src/lib/net/InverseSockets/InverseSocketFactory.cpp +++ b/src/lib/net/InverseSockets/InverseSocketFactory.cpp @@ -24,13 +24,13 @@ // InverseSocketFactory // -InverseSocketFactory::InverseSocketFactory(IEventQueue *events, - SocketMultiplexer *socketMultiplexer) - : m_events(events), m_socketMultiplexer(socketMultiplexer) {} +InverseSocketFactory::InverseSocketFactory( + IEventQueue *events, SocketMultiplexer *socketMultiplexer) + : m_events(events), + m_socketMultiplexer(socketMultiplexer) {} -IDataSocket * -InverseSocketFactory::create(bool secure, - IArchNetwork::EAddressFamily family) const { +IDataSocket *InverseSocketFactory::create( + bool secure, IArchNetwork::EAddressFamily family) const { if (secure) { auto secureSocket = new SecureClientSocket(m_events, m_socketMultiplexer, family); @@ -40,9 +40,8 @@ InverseSocketFactory::create(bool secure, } } -IListenSocket * -InverseSocketFactory::createListen(bool secure, - IArchNetwork::EAddressFamily family) const { +IListenSocket *InverseSocketFactory::createListen( + bool secure, IArchNetwork::EAddressFamily family) const { IListenSocket *socket = nullptr; if (secure) { diff --git a/src/lib/net/InverseSockets/InverseSocketFactory.h b/src/lib/net/InverseSockets/InverseSocketFactory.h index 4526eacfb..2fe67e145 100644 --- a/src/lib/net/InverseSockets/InverseSocketFactory.h +++ b/src/lib/net/InverseSockets/InverseSocketFactory.h @@ -22,12 +22,13 @@ class SocketMultiplexer; class InverseSocketFactory : public ISocketFactory { public: - InverseSocketFactory(IEventQueue *events, - SocketMultiplexer *socketMultiplexer); + InverseSocketFactory( + IEventQueue *events, SocketMultiplexer *socketMultiplexer); // ISocketFactory overrides - IDataSocket *create(bool secure, IArchNetwork::EAddressFamily family = - IArchNetwork::kINET) const override; + IDataSocket *create( + bool secure, + IArchNetwork::EAddressFamily family = IArchNetwork::kINET) const override; IListenSocket *createListen( bool secure, IArchNetwork::EAddressFamily family = IArchNetwork::kINET) const override; diff --git a/src/lib/net/InverseSockets/SecureClientSocket.cpp b/src/lib/net/InverseSockets/SecureClientSocket.cpp index 83e1b1d84..10eb6c163 100644 --- a/src/lib/net/InverseSockets/SecureClientSocket.cpp +++ b/src/lib/net/InverseSockets/SecureClientSocket.cpp @@ -40,16 +40,16 @@ // constexpr float s_retryDelay = 0.01f; -SecureClientSocket::SecureClientSocket(IEventQueue *events, - SocketMultiplexer *socketMultiplexer, - IArchNetwork::EAddressFamily family) +SecureClientSocket::SecureClientSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + IArchNetwork::EAddressFamily family) : InverseClientSocket(events, socketMultiplexer, family) {} void SecureClientSocket::connect(const NetworkAddress &addr) { - m_events->adoptHandler(m_events->forIDataSocket().connected(), - getEventTarget(), - new TMethodEventJob( - this, &SecureClientSocket::handleTCPConnected)); + m_events->adoptHandler( + m_events->forIDataSocket().connected(), getEventTarget(), + new TMethodEventJob( + this, &SecureClientSocket::handleTCPConnected)); InverseClientSocket::connect(addr); } @@ -303,15 +303,16 @@ int SecureClientSocket::secureConnect(int socket) { } void SecureClientSocket::setFatal(int code) { - const std::set nonFatal{SSL_ERROR_NONE, SSL_ERROR_WANT_READ, - SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_CONNECT, - SSL_ERROR_WANT_ACCEPT}; + const std::set nonFatal{ + SSL_ERROR_NONE, SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE, + SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT}; m_fatal = nonFatal.find(code) == nonFatal.end(); } int SecureClientSocket::getRetry(int errorCode, int retry) const { - const std::set retryCodes{SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE, - SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_ACCEPT}; + const std::set retryCodes{ + SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_CONNECT, + SSL_ERROR_WANT_ACCEPT}; if (errorCode == SSL_ERROR_NONE || isFatal()) { retry = 0; diff --git a/src/lib/net/InverseSockets/SecureClientSocket.h b/src/lib/net/InverseSockets/SecureClientSocket.h index 4c343f10c..18ca34af5 100644 --- a/src/lib/net/InverseSockets/SecureClientSocket.h +++ b/src/lib/net/InverseSockets/SecureClientSocket.h @@ -24,8 +24,9 @@ A secure socket using SSL. */ class SecureClientSocket : public InverseClientSocket { public: - SecureClientSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, - IArchNetwork::EAddressFamily family); + SecureClientSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + IArchNetwork::EAddressFamily family); SecureClientSocket(SecureClientSocket const &) = delete; SecureClientSocket(SecureClientSocket &&) = delete; @@ -56,11 +57,11 @@ private: void checkResult(int n, int &retry); void disconnect(); - ISocketMultiplexerJob *serviceConnect(ISocketMultiplexerJob *, bool, bool, - bool); + ISocketMultiplexerJob * + serviceConnect(ISocketMultiplexerJob *, bool, bool, bool); - ISocketMultiplexerJob *serviceAccept(ISocketMultiplexerJob *, bool, bool, - bool); + ISocketMultiplexerJob * + serviceAccept(ISocketMultiplexerJob *, bool, bool, bool); void handleTCPConnected(const Event &, void *); diff --git a/src/lib/net/InverseSockets/SecureServerSocket.cpp b/src/lib/net/InverseSockets/SecureServerSocket.cpp index 62149ba67..de2c46f92 100644 --- a/src/lib/net/InverseSockets/SecureServerSocket.cpp +++ b/src/lib/net/InverseSockets/SecureServerSocket.cpp @@ -26,17 +26,17 @@ // // SecureServerSocket // -SecureServerSocket::SecureServerSocket(IEventQueue *events, - SocketMultiplexer *socketMultiplexer, - IArchNetwork::EAddressFamily family) +SecureServerSocket::SecureServerSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + IArchNetwork::EAddressFamily family) : InverseServerSocket(events, socketMultiplexer, family) {} IDataSocket *SecureServerSocket::accept() { SecureSocket *socket = nullptr; try { - socket = new SecureSocket(m_events, m_socketMultiplexer, - m_socket.getRawSocket()); + socket = new SecureSocket( + m_events, m_socketMultiplexer, m_socket.getRawSocket()); socket->initSsl(true); setListeningJob(); diff --git a/src/lib/net/InverseSockets/SecureServerSocket.h b/src/lib/net/InverseSockets/SecureServerSocket.h index 1bec6dcd9..62ff32b97 100644 --- a/src/lib/net/InverseSockets/SecureServerSocket.h +++ b/src/lib/net/InverseSockets/SecureServerSocket.h @@ -19,8 +19,9 @@ class SecureServerSocket : public InverseServerSocket { public: - SecureServerSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, - IArchNetwork::EAddressFamily family); + SecureServerSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + IArchNetwork::EAddressFamily family); // IListenSocket overrides IDataSocket *accept() override; diff --git a/src/lib/net/InverseSockets/SslApi.cpp b/src/lib/net/InverseSockets/SslApi.cpp index 719b848aa..e2e122fac 100644 --- a/src/lib/net/InverseSockets/SslApi.cpp +++ b/src/lib/net/InverseSockets/SslApi.cpp @@ -90,15 +90,15 @@ bool SslApi::loadCertificate(const std::string &filename) { bool result = false; if (isCertificateExists(filename)) { - auto r = SSL_CTX_use_certificate_file(m_context, filename.c_str(), - SSL_FILETYPE_PEM); + auto r = SSL_CTX_use_certificate_file( + m_context, filename.c_str(), SSL_FILETYPE_PEM); if (r <= 0) { SslLogger::logError("could not use tls certificate"); return false; } - r = SSL_CTX_use_PrivateKey_file(m_context, filename.c_str(), - SSL_FILETYPE_PEM); + r = SSL_CTX_use_PrivateKey_file( + m_context, filename.c_str(), SSL_FILETYPE_PEM); if (r <= 0) { SslLogger::logError("could not use tls private key"); return false; @@ -139,11 +139,12 @@ std::string SslApi::getFingerprint() const { AutoX509 cert(SSL_get_peer_certificate(m_ssl), &X509_free); unsigned int tempFingerprintLen = 0; unsigned char tempFingerprint[EVP_MAX_MD_SIZE] = {0}; - int digestResult = X509_digest(cert.get(), EVP_sha256(), tempFingerprint, - &tempFingerprintLen); + int digestResult = X509_digest( + cert.get(), EVP_sha256(), tempFingerprint, &tempFingerprintLen); if (digestResult <= 0) { - LOG((CLOG_ERR "failed to calculate fingerprint, digest result: %d", + LOG( + (CLOG_ERR "failed to calculate fingerprint, digest result: %d", digestResult)); return ""; } @@ -158,9 +159,9 @@ std::string SslApi::getFingerprint() const { } bool SslApi::isTrustedFingerprint(const std::string &fingerprint) const { - auto trustedServersFilename = - synergy::string::sprintf("%s/SSL/Fingerprints/TrustedServers.txt", - ARCH->getProfileDirectory().c_str()); + auto trustedServersFilename = synergy::string::sprintf( + "%s/SSL/Fingerprints/TrustedServers.txt", + ARCH->getProfileDirectory().c_str()); // check if this fingerprint exist std::ifstream file; @@ -177,7 +178,8 @@ bool SslApi::isTrustedFingerprint(const std::string &fingerprint) const { } } } else { - LOG((CLOG_ERR "failed to open trusted fingerprints file: %s", + LOG( + (CLOG_ERR "failed to open trusted fingerprints file: %s", trustedServersFilename.c_str())); } @@ -193,8 +195,9 @@ void SslApi::createContext(bool isServer) { } // Prevent the usage of of all version prior to TLSv1.2 as they are known to // be vulnerable - SSL_CTX_set_options(m_context, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | - SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1); + SSL_CTX_set_options( + m_context, + SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1); if (m_context) { m_ssl = SSL_new(m_context); diff --git a/src/lib/net/NetworkAddress.cpp b/src/lib/net/NetworkAddress.cpp index 568dbbfc9..dc6627333 100644 --- a/src/lib/net/NetworkAddress.cpp +++ b/src/lib/net/NetworkAddress.cpp @@ -38,12 +38,14 @@ NetworkAddress::NetworkAddress(int port) : m_port(port) { } NetworkAddress::NetworkAddress(const NetworkAddress &addr) - : m_hostname(addr.m_hostname), m_port(addr.m_port) { + : m_hostname(addr.m_hostname), + m_port(addr.m_port) { *this = addr; } NetworkAddress::NetworkAddress(const String &hostname, int port) - : m_hostname(hostname), m_port(port) { + : m_hostname(hostname), + m_port(port) { // detect internet protocol version with colom count auto isColomPredicate = [](char c) { return c == ':'; }; auto colomCount = diff --git a/src/lib/net/SecureListenSocket.cpp b/src/lib/net/SecureListenSocket.cpp index 6e7096b25..c38676d39 100644 --- a/src/lib/net/SecureListenSocket.cpp +++ b/src/lib/net/SecureListenSocket.cpp @@ -32,16 +32,16 @@ static const char s_certificateFilename[] = {"Synergy.pem"}; // SecureListenSocket // -SecureListenSocket::SecureListenSocket(IEventQueue *events, - SocketMultiplexer *socketMultiplexer, - IArchNetwork::EAddressFamily family) +SecureListenSocket::SecureListenSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + IArchNetwork::EAddressFamily family) : TCPListenSocket(events, socketMultiplexer, family) {} IDataSocket *SecureListenSocket::accept() { SecureSocket *socket = NULL; try { - socket = new SecureSocket(m_events, m_socketMultiplexer, - ARCH->acceptSocket(m_socket, NULL)); + socket = new SecureSocket( + m_events, m_socketMultiplexer, ARCH->acceptSocket(m_socket, NULL)); socket->initSsl(true); if (socket != NULL) { diff --git a/src/lib/net/SecureListenSocket.h b/src/lib/net/SecureListenSocket.h index 0bfc05586..986393a6a 100644 --- a/src/lib/net/SecureListenSocket.h +++ b/src/lib/net/SecureListenSocket.h @@ -26,8 +26,9 @@ class IDataSocket; class SecureListenSocket : public TCPListenSocket { public: - SecureListenSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, - IArchNetwork::EAddressFamily family); + SecureListenSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + IArchNetwork::EAddressFamily family); // IListenSocket overrides virtual IDataSocket *accept(); diff --git a/src/lib/net/SecureSocket.cpp b/src/lib/net/SecureSocket.cpp index 2480b1b5e..ca353d464 100644 --- a/src/lib/net/SecureSocket.cpp +++ b/src/lib/net/SecureSocket.cpp @@ -56,17 +56,21 @@ struct Ssl { SSL *m_ssl; }; -SecureSocket::SecureSocket(IEventQueue *events, - SocketMultiplexer *socketMultiplexer, - IArchNetwork::EAddressFamily family) - : TCPSocket(events, socketMultiplexer, family), m_ssl(nullptr), - m_secureReady(false), m_fatal(false) {} +SecureSocket::SecureSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + IArchNetwork::EAddressFamily family) + : TCPSocket(events, socketMultiplexer, family), + m_ssl(nullptr), + m_secureReady(false), + m_fatal(false) {} -SecureSocket::SecureSocket(IEventQueue *events, - SocketMultiplexer *socketMultiplexer, - ArchSocket socket) - : TCPSocket(events, socketMultiplexer, socket), m_ssl(nullptr), - m_secureReady(false), m_fatal(false) {} +SecureSocket::SecureSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + ArchSocket socket) + : TCPSocket(events, socketMultiplexer, socket), + m_ssl(nullptr), + m_secureReady(false), + m_fatal(false) {} SecureSocket::~SecureSocket() { freeSSL(); } @@ -76,10 +80,10 @@ void SecureSocket::close() { } void SecureSocket::connect(const NetworkAddress &addr) { - m_events->adoptHandler(m_events->forIDataSocket().connected(), - getEventTarget(), - new TMethodEventJob( - this, &SecureSocket::handleTCPConnected)); + m_events->adoptHandler( + m_events->forIDataSocket().connected(), getEventTarget(), + new TMethodEventJob( + this, &SecureSocket::handleTCPConnected)); TCPSocket::connect(addr); } @@ -285,15 +289,15 @@ bool SecureSocket::loadCertificates(String &filename) { } int r = 0; - r = SSL_CTX_use_certificate_file(m_ssl->m_context, filename.c_str(), - SSL_FILETYPE_PEM); + r = SSL_CTX_use_certificate_file( + m_ssl->m_context, filename.c_str(), SSL_FILETYPE_PEM); if (r <= 0) { SslLogger::logError("could not use tls certificate"); return false; } - r = SSL_CTX_use_PrivateKey_file(m_ssl->m_context, filename.c_str(), - SSL_FILETYPE_PEM); + r = SSL_CTX_use_PrivateKey_file( + m_ssl->m_context, filename.c_str(), SSL_FILETYPE_PEM); if (r <= 0) { SslLogger::logError("could not use tls private key"); return false; @@ -332,9 +336,9 @@ void SecureSocket::initContext(bool server) { // Prevent the usage of of all version prior to TLSv1.2 as they are known to // be vulnerable - SSL_CTX_set_options(m_ssl->m_context, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | - SSL_OP_NO_TLSv1 | - SSL_OP_NO_TLSv1_1); + SSL_CTX_set_options( + m_ssl->m_context, + SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1); if (m_ssl->m_context == NULL) { SslLogger::logError(); @@ -517,8 +521,8 @@ void SecureSocket::checkResult(int status, int &retry) { case SSL_ERROR_WANT_CONNECT: retry++; - LOG((CLOG_DEBUG2 "want to connect, error=%d, attempt=%d", errorCode, - retry)); + LOG(( + CLOG_DEBUG2 "want to connect, error=%d, attempt=%d", errorCode, retry)); break; case SSL_ERROR_WANT_ACCEPT: @@ -568,8 +572,8 @@ void SecureSocket::disconnect() { sendEvent(getEvents()->forIStream().inputShutdown()); } -void SecureSocket::formatFingerprint(String &fingerprint, bool hex, - bool separator) { +void SecureSocket::formatFingerprint( + String &fingerprint, bool hex, bool separator) { if (hex) { // to hexidecimal synergy::string::toHex(fingerprint, 2); @@ -594,18 +598,20 @@ bool SecureSocket::verifyCertFingerprint() { unsigned char tempFingerprint[EVP_MAX_MD_SIZE]; unsigned int tempFingerprintLen; - int digestResult = X509_digest(cert.get(), EVP_sha256(), tempFingerprint, - &tempFingerprintLen); + int digestResult = X509_digest( + cert.get(), EVP_sha256(), tempFingerprint, &tempFingerprintLen); if (digestResult <= 0) { - LOG((CLOG_ERR "failed to calculate fingerprint, digest result: %d", + LOG( + (CLOG_ERR "failed to calculate fingerprint, digest result: %d", digestResult)); return false; } // format fingerprint into hexdecimal format with colon separator - String fingerprint(static_cast(static_cast(tempFingerprint)), - tempFingerprintLen); + String fingerprint( + static_cast(static_cast(tempFingerprint)), + tempFingerprintLen); formatFingerprint(fingerprint); LOG((CLOG_NOTE "server fingerprint: %s", fingerprint.c_str())); @@ -629,7 +635,8 @@ bool SecureSocket::verifyCertFingerprint() { } } } else { - LOG((CLOG_ERR "fail to open trusted fingerprints file: %s", + LOG( + (CLOG_ERR "fail to open trusted fingerprints file: %s", trustedServersFilename.c_str())); } @@ -637,9 +644,8 @@ bool SecureSocket::verifyCertFingerprint() { return isValid; } -ISocketMultiplexerJob *SecureSocket::serviceConnect(ISocketMultiplexerJob *job, - bool, bool write, - bool error) { +ISocketMultiplexerJob *SecureSocket::serviceConnect( + ISocketMultiplexerJob *job, bool, bool write, bool error) { Lock lock(&getMutex()); int status = 0; @@ -666,9 +672,8 @@ ISocketMultiplexerJob *SecureSocket::serviceConnect(ISocketMultiplexerJob *job, isWritable()); } -ISocketMultiplexerJob *SecureSocket::serviceAccept(ISocketMultiplexerJob *job, - bool, bool write, - bool error) { +ISocketMultiplexerJob *SecureSocket::serviceAccept( + ISocketMultiplexerJob *job, bool, bool write, bool error) { Lock lock(&getMutex()); int status = 0; diff --git a/src/lib/net/SecureSocket.h b/src/lib/net/SecureSocket.h index 12fe432b8..88a5acb0e 100644 --- a/src/lib/net/SecureSocket.h +++ b/src/lib/net/SecureSocket.h @@ -32,10 +32,12 @@ A secure socket using SSL. */ class SecureSocket : public TCPSocket { public: - SecureSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, - IArchNetwork::EAddressFamily family); - SecureSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, - ArchSocket socket); + SecureSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + IArchNetwork::EAddressFamily family); + SecureSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + ArchSocket socket); SecureSocket(SecureSocket const &) = delete; SecureSocket(SecureSocket &&) = delete; ~SecureSocket(); @@ -72,15 +74,15 @@ private: bool showCertificate() const; void checkResult(int n, int &retry); void disconnect(); - void formatFingerprint(String &fingerprint, bool hex = true, - bool separator = true); + void formatFingerprint( + String &fingerprint, bool hex = true, bool separator = true); bool verifyCertFingerprint(); - ISocketMultiplexerJob *serviceConnect(ISocketMultiplexerJob *, bool, bool, - bool); + ISocketMultiplexerJob * + serviceConnect(ISocketMultiplexerJob *, bool, bool, bool); - ISocketMultiplexerJob *serviceAccept(ISocketMultiplexerJob *, bool, bool, - bool); + ISocketMultiplexerJob * + serviceAccept(ISocketMultiplexerJob *, bool, bool, bool); void handleTCPConnected(const Event &event, void *); diff --git a/src/lib/net/SocketMultiplexer.cpp b/src/lib/net/SocketMultiplexer.cpp index 115dfe45e..df9125b0f 100644 --- a/src/lib/net/SocketMultiplexer.cpp +++ b/src/lib/net/SocketMultiplexer.cpp @@ -34,11 +34,14 @@ // SocketMultiplexer::SocketMultiplexer() - : m_mutex(new Mutex), m_thread(NULL), m_update(false), + : m_mutex(new Mutex), + m_thread(NULL), + m_update(false), m_jobsReady(new CondVar(m_mutex, false)), m_jobListLock(new CondVar(m_mutex, false)), m_jobListLockLocked(new CondVar(m_mutex, false)), - m_jobListLocker(NULL), m_jobListLockLocker(NULL) { + m_jobListLocker(NULL), + m_jobListLockLocker(NULL) { // this pointer just has to be unique and not NULL. it will // never be dereferenced. it's used to identify cursor nodes // in the jobs list. diff --git a/src/lib/net/TCPListenSocket.cpp b/src/lib/net/TCPListenSocket.cpp index 32aab23d3..da389d1c6 100644 --- a/src/lib/net/TCPListenSocket.cpp +++ b/src/lib/net/TCPListenSocket.cpp @@ -35,10 +35,11 @@ // TCPListenSocket // -TCPListenSocket::TCPListenSocket(IEventQueue *events, - SocketMultiplexer *socketMultiplexer, - IArchNetwork::EAddressFamily family) - : m_events(events), m_socketMultiplexer(socketMultiplexer) { +TCPListenSocket::TCPListenSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + IArchNetwork::EAddressFamily family) + : m_events(events), + m_socketMultiplexer(socketMultiplexer) { m_mutex = new Mutex; try { m_socket = ARCH->newSocket(family, IArchNetwork::kSTREAM); @@ -98,8 +99,8 @@ void *TCPListenSocket::getEventTarget() const { IDataSocket *TCPListenSocket::accept() { IDataSocket *socket = NULL; try { - socket = new TCPSocket(m_events, m_socketMultiplexer, - ARCH->acceptSocket(m_socket, NULL)); + socket = new TCPSocket( + m_events, m_socketMultiplexer, ARCH->acceptSocket(m_socket, NULL)); if (socket != NULL) { setListeningJob(); } @@ -126,9 +127,8 @@ void TCPListenSocket::setListeningJob() { this, &TCPListenSocket::serviceListening, m_socket, true, false)); } -ISocketMultiplexerJob * -TCPListenSocket::serviceListening(ISocketMultiplexerJob *job, bool read, bool, - bool error) { +ISocketMultiplexerJob *TCPListenSocket::serviceListening( + ISocketMultiplexerJob *job, bool read, bool, bool error) { if (error) { close(); return NULL; diff --git a/src/lib/net/TCPListenSocket.h b/src/lib/net/TCPListenSocket.h index 021b61957..8a6045098 100644 --- a/src/lib/net/TCPListenSocket.h +++ b/src/lib/net/TCPListenSocket.h @@ -32,8 +32,9 @@ A listen socket using TCP. */ class TCPListenSocket : public IListenSocket { public: - TCPListenSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, - IArchNetwork::EAddressFamily family); + TCPListenSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + IArchNetwork::EAddressFamily family); TCPListenSocket(TCPListenSocket const &) = delete; TCPListenSocket(TCPListenSocket &&) = delete; virtual ~TCPListenSocket(); @@ -53,8 +54,8 @@ protected: void setListeningJob(); public: - ISocketMultiplexerJob *serviceListening(ISocketMultiplexerJob *, bool, bool, - bool); + ISocketMultiplexerJob * + serviceListening(ISocketMultiplexerJob *, bool, bool, bool); protected: ArchSocket m_socket; diff --git a/src/lib/net/TCPSocket.cpp b/src/lib/net/TCPSocket.cpp index 4b136d579..1c0c733c7 100644 --- a/src/lib/net/TCPSocket.cpp +++ b/src/lib/net/TCPSocket.cpp @@ -37,10 +37,14 @@ // TCPSocket // -TCPSocket::TCPSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, - IArchNetwork::EAddressFamily family) - : IDataSocket(events), m_events(events), m_mutex(), - m_flushed(&m_mutex, true), m_socketMultiplexer(socketMultiplexer) { +TCPSocket::TCPSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + IArchNetwork::EAddressFamily family) + : IDataSocket(events), + m_events(events), + m_mutex(), + m_flushed(&m_mutex, true), + m_socketMultiplexer(socketMultiplexer) { try { m_socket = ARCH->newSocket(family, IArchNetwork::kSTREAM); } catch (const XArchNetwork &e) { @@ -52,10 +56,15 @@ TCPSocket::TCPSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, init(); } -TCPSocket::TCPSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, - ArchSocket socket) - : IDataSocket(events), m_events(events), m_mutex(), m_socket(socket), - m_flushed(&m_mutex, true), m_socketMultiplexer(socketMultiplexer) { +TCPSocket::TCPSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + ArchSocket socket) + : IDataSocket(events), + m_events(events), + m_mutex(), + m_socket(socket), + m_flushed(&m_mutex, true), + m_socketMultiplexer(socketMultiplexer) { assert(m_socket != nullptr); LOG((CLOG_DEBUG "opening new socket: %08X", m_socket)); @@ -375,8 +384,9 @@ ISocketMultiplexerJob *TCPSocket::newJob() { void TCPSocket::sendConnectionFailedEvent(const char *msg) { ConnectionFailedInfo *info = new ConnectionFailedInfo(msg); - m_events->addEvent(Event(m_events->forIDataSocket().connectionFailed(), - getEventTarget(), info, Event::kDontFreeData)); + m_events->addEvent(Event( + m_events->forIDataSocket().connectionFailed(), getEventTarget(), info, + Event::kDontFreeData)); } void TCPSocket::sendEvent(Event::Type type) { @@ -419,9 +429,8 @@ void TCPSocket::onDisconnected() { m_connected = false; } -ISocketMultiplexerJob *TCPSocket::serviceConnecting(ISocketMultiplexerJob *job, - bool, bool write, - bool error) { +ISocketMultiplexerJob *TCPSocket::serviceConnecting( + ISocketMultiplexerJob *job, bool, bool write, bool error) { Lock lock(&m_mutex); // should only check for errors if error is true but checking a new @@ -461,9 +470,8 @@ ISocketMultiplexerJob *TCPSocket::serviceConnecting(ISocketMultiplexerJob *job, return job; } -ISocketMultiplexerJob *TCPSocket::serviceConnected(ISocketMultiplexerJob *job, - bool read, bool write, - bool error) { +ISocketMultiplexerJob *TCPSocket::serviceConnected( + ISocketMultiplexerJob *job, bool read, bool write, bool error) { Lock lock(&m_mutex); if (error) { diff --git a/src/lib/net/TCPSocket.h b/src/lib/net/TCPSocket.h index 13c06436c..dca6994d9 100644 --- a/src/lib/net/TCPSocket.h +++ b/src/lib/net/TCPSocket.h @@ -36,10 +36,12 @@ A data socket using TCP. */ class TCPSocket : public IDataSocket { public: - TCPSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, - IArchNetwork::EAddressFamily family = IArchNetwork::kINET); - TCPSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer, - ArchSocket socket); + TCPSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + IArchNetwork::EAddressFamily family = IArchNetwork::kINET); + TCPSocket( + IEventQueue *events, SocketMultiplexer *socketMultiplexer, + ArchSocket socket); TCPSocket(TCPSocket const &) = delete; TCPSocket(TCPSocket &&) = delete; virtual ~TCPSocket(); @@ -98,10 +100,10 @@ private: void onOutputShutdown(); void onDisconnected(); - ISocketMultiplexerJob *serviceConnecting(ISocketMultiplexerJob *, bool, bool, - bool); - ISocketMultiplexerJob *serviceConnected(ISocketMultiplexerJob *, bool, bool, - bool); + ISocketMultiplexerJob * + serviceConnecting(ISocketMultiplexerJob *, bool, bool, bool); + ISocketMultiplexerJob * + serviceConnected(ISocketMultiplexerJob *, bool, bool, bool); protected: bool m_readable; diff --git a/src/lib/net/TCPSocketFactory.cpp b/src/lib/net/TCPSocketFactory.cpp index 269efd5b8..28c265c5b 100644 --- a/src/lib/net/TCPSocketFactory.cpp +++ b/src/lib/net/TCPSocketFactory.cpp @@ -28,9 +28,10 @@ // TCPSocketFactory // -TCPSocketFactory::TCPSocketFactory(IEventQueue *events, - SocketMultiplexer *socketMultiplexer) - : m_events(events), m_socketMultiplexer(socketMultiplexer) { +TCPSocketFactory::TCPSocketFactory( + IEventQueue *events, SocketMultiplexer *socketMultiplexer) + : m_events(events), + m_socketMultiplexer(socketMultiplexer) { // do nothing } @@ -38,9 +39,8 @@ TCPSocketFactory::~TCPSocketFactory() { // do nothing } -IDataSocket * -TCPSocketFactory::create(bool secure, - IArchNetwork::EAddressFamily family) const { +IDataSocket *TCPSocketFactory::create( + bool secure, IArchNetwork::EAddressFamily family) const { if (secure) { SecureSocket *secureSocket = new SecureSocket(m_events, m_socketMultiplexer, family); @@ -51,9 +51,8 @@ TCPSocketFactory::create(bool secure, } } -IListenSocket * -TCPSocketFactory::createListen(bool secure, - IArchNetwork::EAddressFamily family) const { +IListenSocket *TCPSocketFactory::createListen( + bool secure, IArchNetwork::EAddressFamily family) const { IListenSocket *socket = NULL; if (secure) { socket = new SecureListenSocket(m_events, m_socketMultiplexer, family); diff --git a/src/lib/net/TCPSocketFactory.h b/src/lib/net/TCPSocketFactory.h index 13a27bb7d..53287a1b4 100644 --- a/src/lib/net/TCPSocketFactory.h +++ b/src/lib/net/TCPSocketFactory.h @@ -31,12 +31,12 @@ public: virtual ~TCPSocketFactory(); // ISocketFactory overrides - virtual IDataSocket * - create(bool secure, - IArchNetwork::EAddressFamily family = IArchNetwork::kINET) const; - virtual IListenSocket * - createListen(bool secure, - IArchNetwork::EAddressFamily family = IArchNetwork::kINET) const; + virtual IDataSocket *create( + bool secure, + IArchNetwork::EAddressFamily family = IArchNetwork::kINET) const; + virtual IListenSocket *createListen( + bool secure, + IArchNetwork::EAddressFamily family = IArchNetwork::kINET) const; private: IEventQueue *m_events; diff --git a/src/lib/net/TSocketMultiplexerMethodJob.h b/src/lib/net/TSocketMultiplexerMethodJob.h index 47e9b48ae..7b3eb1ae1 100644 --- a/src/lib/net/TSocketMultiplexerMethodJob.h +++ b/src/lib/net/TSocketMultiplexerMethodJob.h @@ -28,12 +28,13 @@ A socket multiplexer job class that invokes a member function. template class TSocketMultiplexerMethodJob : public ISocketMultiplexerJob { public: - typedef ISocketMultiplexerJob *(T::*Method)(ISocketMultiplexerJob *, bool, - bool, bool); + typedef ISocketMultiplexerJob *(T::*Method)( + ISocketMultiplexerJob *, bool, bool, bool); //! run() invokes \c object->method(arg) - TSocketMultiplexerMethodJob(T *object, Method method, ArchSocket socket, - bool readable, bool writeable); + TSocketMultiplexerMethodJob( + T *object, Method method, ArchSocket socket, bool readable, + bool writeable); TSocketMultiplexerMethodJob(TSocketMultiplexerMethodJob const &) = delete; TSocketMultiplexerMethodJob(TSocketMultiplexerMethodJob &&) = delete; virtual ~TSocketMultiplexerMethodJob(); @@ -61,8 +62,11 @@ private: template inline TSocketMultiplexerMethodJob::TSocketMultiplexerMethodJob( T *object, Method method, ArchSocket socket, bool readable, bool writable) - : m_object(object), m_method(method), m_socket(ARCH->copySocket(socket)), - m_readable(readable), m_writable(writable) { + : m_object(object), + m_method(method), + m_socket(ARCH->copySocket(socket)), + m_readable(readable), + m_writable(writable) { // do nothing } diff --git a/src/lib/net/XSocket.cpp b/src/lib/net/XSocket.cpp index 151dfb68b..85ab64787 100644 --- a/src/lib/net/XSocket.cpp +++ b/src/lib/net/XSocket.cpp @@ -23,10 +23,10 @@ // XSocketAddress // -XSocketAddress::XSocketAddress(EError error, const String &hostname, - int port) _NOEXCEPT : m_error(error), - m_hostname(hostname), - m_port(port) { +XSocketAddress::XSocketAddress(EError error, const String &hostname, int port) + _NOEXCEPT : m_error(error), + m_hostname(hostname), + m_port(port) { // do nothing } @@ -48,8 +48,9 @@ String XSocketAddress::getWhat() const throw() { "no address for: %{1}", "unsupported address for: %{1}", "invalid port" // m_port may not be set to the bad port }; - return format(s_errorID[m_error], s_errorMsg[m_error], m_hostname.c_str(), - synergy::string::sprintf("%d", m_port).c_str()); + return format( + s_errorID[m_error], s_errorMsg[m_error], m_hostname.c_str(), + synergy::string::sprintf("%d", m_port).c_str()); } // diff --git a/src/lib/platform/MSWindowsClipboard.cpp b/src/lib/platform/MSWindowsClipboard.cpp index d2cd2d89c..eff22a1c6 100644 --- a/src/lib/platform/MSWindowsClipboard.cpp +++ b/src/lib/platform/MSWindowsClipboard.cpp @@ -33,7 +33,9 @@ UINT MSWindowsClipboard::s_ownershipFormat = 0; MSWindowsClipboard::MSWindowsClipboard(HWND window) - : m_window(window), m_time(0), m_facade(new MSWindowsClipboardFacade()), + : m_window(window), + m_time(0), + m_facade(new MSWindowsClipboardFacade()), m_deleteFacade(true) { // add converters, most desired first m_converters.push_back(new MSWindowsClipboardUTF16Converter); @@ -98,7 +100,8 @@ void MSWindowsClipboard::add(EFormat format, const String &data) { if (converter->getFormat() == format) { HANDLE win32Data = converter->fromIClipboard(data); if (win32Data != NULL) { - LOG((CLOG_DEBUG "add %d bytes to clipboard format: %d", data.size(), + LOG( + (CLOG_DEBUG "add %d bytes to clipboard format: %d", data.size(), format)); m_facade->write(win32Data, converter->getWin32Format()); isSucceeded = true; diff --git a/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp b/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp index d2e883b37..54d8c2c2f 100644 --- a/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp +++ b/src/lib/platform/MSWindowsClipboardBitmapConverter.cpp @@ -69,7 +69,8 @@ String MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const { // check image type const BITMAPINFO *bitmap = static_cast(src); - LOG((CLOG_INFO "bitmap: %dx%d %d", bitmap->bmiHeader.biWidth, + LOG( + (CLOG_INFO "bitmap: %dx%d %d", bitmap->bmiHeader.biWidth, bitmap->bmiHeader.biHeight, (int)bitmap->bmiHeader.biBitCount)); if (bitmap->bmiHeader.biPlanes == 1 && (bitmap->bmiHeader.biBitCount == 24 || @@ -82,7 +83,8 @@ String MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const { } // create a destination DIB section - LOG((CLOG_INFO "convert image from: depth=%d comp=%d", + LOG( + (CLOG_INFO "convert image from: depth=%d comp=%d", bitmap->bmiHeader.biBitCount, bitmap->bmiHeader.biCompression)); void *raw; BITMAPINFOHEADER info; @@ -121,8 +123,8 @@ String MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const { // copy source image to destination image HDC dstDC = CreateCompatibleDC(dc); HGDIOBJ oldBitmap = SelectObject(dstDC, dst); - SetDIBitsToDevice(dstDC, 0, 0, w, h, 0, 0, 0, h, srcBits, bitmap, - DIB_RGB_COLORS); + SetDIBitsToDevice( + dstDC, 0, 0, w, h, 0, 0, 0, h, srcBits, bitmap, DIB_RGB_COLORS); SelectObject(dstDC, oldBitmap); DeleteDC(dstDC); GdiFlush(); diff --git a/src/lib/platform/MSWindowsClipboardHTMLConverter.cpp b/src/lib/platform/MSWindowsClipboardHTMLConverter.cpp index 607e8a28d..221d2f49b 100644 --- a/src/lib/platform/MSWindowsClipboardHTMLConverter.cpp +++ b/src/lib/platform/MSWindowsClipboardHTMLConverter.cpp @@ -55,12 +55,15 @@ MSWindowsClipboardHTMLConverter::doFromIClipboard(const String &data) const { // StartHTML is constant by the design of the prefix UInt32 EndHTML = EndFragment + (UInt32)suffix.size(); - prefix.replace(prefix.find("XXXXXXXXXX"), 10, - synergy::string::sprintf("%010u", StartFragment)); - prefix.replace(prefix.find("YYYYYYYYYY"), 10, - synergy::string::sprintf("%010u", EndFragment)); - prefix.replace(prefix.find("ZZZZZZZZZZ"), 10, - synergy::string::sprintf("%010u", EndHTML)); + prefix.replace( + prefix.find("XXXXXXXXXX"), 10, + synergy::string::sprintf("%010u", StartFragment)); + prefix.replace( + prefix.find("YYYYYYYYYY"), 10, + synergy::string::sprintf("%010u", EndFragment)); + prefix.replace( + prefix.find("ZZZZZZZZZZ"), 10, + synergy::string::sprintf("%010u", EndHTML)); // concatenate prefix += data; @@ -88,8 +91,8 @@ MSWindowsClipboardHTMLConverter::doToIClipboard(const String &data) const { return data.substr(start, end - start); } -String MSWindowsClipboardHTMLConverter::findArg(const String &data, - const String &name) const { +String MSWindowsClipboardHTMLConverter::findArg( + const String &data, const String &name) const { String::size_type i = data.find(name); if (i == String::npos) { return String(); diff --git a/src/lib/platform/MSWindowsDesks.cpp b/src/lib/platform/MSWindowsDesks.cpp index 20f8ed1f0..28a63592a 100644 --- a/src/lib/platform/MSWindowsDesks.cpp +++ b/src/lib/platform/MSWindowsDesks.cpp @@ -116,16 +116,29 @@ static void send_mouse_input(DWORD dwFlags, DWORD dx, DWORD dy, DWORD dwData) { // MSWindowsDesks // -MSWindowsDesks::MSWindowsDesks(bool isPrimary, bool noHooks, - const IScreenSaver *screensaver, - IEventQueue *events, IJob *updateKeys, - bool stopOnDeskSwitch) - : m_isPrimary(isPrimary), m_noHooks(noHooks), m_isOnScreen(m_isPrimary), - m_x(0), m_y(0), m_w(0), m_h(0), m_xCenter(0), m_yCenter(0), - m_multimon(false), m_timer(NULL), m_screensaver(screensaver), - m_screensaverNotify(false), m_activeDesk(NULL), m_activeDeskName(), - m_mutex(), m_deskReady(&m_mutex, false), m_updateKeys(updateKeys), - m_events(events), m_stopOnDeskSwitch(stopOnDeskSwitch) { +MSWindowsDesks::MSWindowsDesks( + bool isPrimary, bool noHooks, const IScreenSaver *screensaver, + IEventQueue *events, IJob *updateKeys, bool stopOnDeskSwitch) + : m_isPrimary(isPrimary), + m_noHooks(noHooks), + m_isOnScreen(m_isPrimary), + m_x(0), + m_y(0), + m_w(0), + m_h(0), + m_xCenter(0), + m_yCenter(0), + m_multimon(false), + m_timer(NULL), + m_screensaver(screensaver), + m_screensaverNotify(false), + m_activeDesk(NULL), + m_activeDeskName(), + m_mutex(), + m_deskReady(&m_mutex, false), + m_updateKeys(updateKeys), + m_events(events), + m_stopOnDeskSwitch(stopOnDeskSwitch) { m_cursor = createBlankCursor(); m_deskClass = createDeskWindowClass(m_isPrimary); @@ -151,9 +164,10 @@ void MSWindowsDesks::enable() { // we wouldn't need this if windows notified us of a desktop // change but as far as i can tell it doesn't. m_timer = m_events->newTimer(0.2, NULL); - m_events->adoptHandler(Event::kTimer, m_timer, - new TMethodEventJob( - this, &MSWindowsDesks::handleCheckDesk)); + m_events->adoptHandler( + Event::kTimer, m_timer, + new TMethodEventJob( + this, &MSWindowsDesks::handleCheckDesk)); updateKeys(); } @@ -184,7 +198,8 @@ void MSWindowsDesks::setOptions(const OptionsList &options) { for (UInt32 i = 0, n = (UInt32)options.size(); i < n; i += 2) { if (options[i] == kOptionWin32KeepForeground) { m_leaveForegroundOption = (options[i + 1] != 0); - LOG((CLOG_DEBUG1 "%s the foreground window", + LOG( + (CLOG_DEBUG1 "%s the foreground window", m_leaveForegroundOption ? "don\'t grab" : "grab")); } } @@ -192,8 +207,9 @@ void MSWindowsDesks::setOptions(const OptionsList &options) { void MSWindowsDesks::updateKeys() { sendMessage(SYNERGY_MSG_SYNC_KEYS, 0, 0); } -void MSWindowsDesks::setShape(SInt32 x, SInt32 y, SInt32 width, SInt32 height, - SInt32 xCenter, SInt32 yCenter, bool isMultimon) { +void MSWindowsDesks::setShape( + SInt32 x, SInt32 y, SInt32 width, SInt32 height, SInt32 xCenter, + SInt32 yCenter, bool isMultimon) { m_x = x; m_y = y; m_w = width; @@ -225,8 +241,8 @@ void MSWindowsDesks::getCursorPos(SInt32 &x, SInt32 &y) const { y = pos.y; } -void MSWindowsDesks::fakeKeyEvent(WORD virtualKey, WORD scanCode, DWORD flags, - bool /*isAutoRepeat*/) const { +void MSWindowsDesks::fakeKeyEvent( + WORD virtualKey, WORD scanCode, DWORD flags, bool /*isAutoRepeat*/) const { sendMessage(SYNERGY_MSG_FAKE_KEY, flags, MAKELPARAM(scanCode, virtualKey)); } @@ -282,13 +298,14 @@ void MSWindowsDesks::fakeMouseButton(ButtonID button, bool press) { } void MSWindowsDesks::fakeMouseMove(SInt32 x, SInt32 y) const { - sendMessage(SYNERGY_MSG_FAKE_MOVE, static_cast(x), - static_cast(y)); + sendMessage( + SYNERGY_MSG_FAKE_MOVE, static_cast(x), static_cast(y)); } void MSWindowsDesks::fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const { - sendMessage(SYNERGY_MSG_FAKE_REL_MOVE, static_cast(dx), - static_cast(dy)); + sendMessage( + SYNERGY_MSG_FAKE_REL_MOVE, static_cast(dx), + static_cast(dy)); } void MSWindowsDesks::fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const { @@ -311,8 +328,8 @@ MSWindowsDesks::createBlankCursor() const { UInt8 *cursorXOR = new UInt8[ch * ((cw + 31) >> 2)]; memset(cursorAND, 0xff, ch * ((cw + 31) >> 2)); memset(cursorXOR, 0x00, ch * ((cw + 31) >> 2)); - HCURSOR c = CreateCursor(MSWindowsScreen::getWindowInstance(), 0, 0, cw, ch, - cursorAND, cursorXOR); + HCURSOR c = CreateCursor( + MSWindowsScreen::getWindowInstance(), 0, 0, cw, ch, cursorAND, cursorXOR); delete[] cursorXOR; delete[] cursorAND; return c; @@ -344,16 +361,16 @@ ATOM MSWindowsDesks::createDeskWindowClass(bool isPrimary) const { void MSWindowsDesks::destroyClass(ATOM windowClass) const { if (windowClass != 0) { - UnregisterClass(MAKEINTATOM(windowClass), - MSWindowsScreen::getWindowInstance()); + UnregisterClass( + MAKEINTATOM(windowClass), MSWindowsScreen::getWindowInstance()); } } HWND MSWindowsDesks::createWindow(ATOM windowClass, const char *name) const { - HWND window = - CreateWindowEx(WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, - MAKEINTATOM(windowClass), name, WS_POPUP, 0, 0, 1, 1, NULL, - NULL, MSWindowsScreen::getWindowInstance(), NULL); + HWND window = CreateWindowEx( + WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, MAKEINTATOM(windowClass), name, + WS_POPUP, 0, 0, 1, 1, NULL, NULL, MSWindowsScreen::getWindowInstance(), + NULL); if (window == NULL) { LOG((CLOG_ERR "failed to create window: %d", GetLastError())); throw XScreenOpenFailure(); @@ -367,14 +384,13 @@ void MSWindowsDesks::destroyWindow(HWND hwnd) const { } } -LRESULT CALLBACK MSWindowsDesks::primaryDeskProc(HWND hwnd, UINT msg, - WPARAM wParam, LPARAM lParam) { +LRESULT CALLBACK MSWindowsDesks::primaryDeskProc( + HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { return DefWindowProc(hwnd, msg, wParam, lParam); } -LRESULT CALLBACK MSWindowsDesks::secondaryDeskProc(HWND hwnd, UINT msg, - WPARAM wParam, - LPARAM lParam) { +LRESULT CALLBACK MSWindowsDesks::secondaryDeskProc( + HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { // would like to detect any local user input and hide the hider // window but for now we just detect mouse motion. bool hide = false; @@ -388,8 +404,9 @@ LRESULT CALLBACK MSWindowsDesks::secondaryDeskProc(HWND hwnd, UINT msg, if (hide && IsWindowVisible(hwnd)) { ReleaseCapture(); - SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_HIDEWINDOW); + SetWindowPos( + hwnd, HWND_BOTTOM, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_HIDEWINDOW); } return DefWindowProc(hwnd, msg, wParam, lParam); @@ -401,9 +418,10 @@ void MSWindowsDesks::deskMouseMove(SInt32 x, SInt32 y) const { // the primary screen. SInt32 w = GetSystemMetrics(SM_CXSCREEN); SInt32 h = GetSystemMetrics(SM_CYSCREEN); - send_mouse_input(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, - (DWORD)((65535.0f * x) / (w - 1) + 0.5f), - (DWORD)((65535.0f * y) / (h - 1) + 0.5f), 0); + send_mouse_input( + MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, + (DWORD)((65535.0f * x) / (w - 1) + 0.5f), + (DWORD)((65535.0f * y) / (h - 1) + 0.5f), 0); } void MSWindowsDesks::deskMouseRelativeMove(SInt32 dx, SInt32 dy) const { @@ -444,8 +462,9 @@ void MSWindowsDesks::deskEnter(Desk *desk) { ReleaseCapture(); } ShowCursor(TRUE); - SetWindowPos(desk->m_window, HWND_BOTTOM, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_HIDEWINDOW); + SetWindowPos( + desk->m_window, HWND_BOTTOM, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_HIDEWINDOW); // restore the foreground window // XXX -- this raises the window to the top of the Z-order. we @@ -485,8 +504,8 @@ void MSWindowsDesks::deskLeave(Desk *desk, HKL keyLayout) { w = m_w; h = m_h; } - SetWindowPos(desk->m_window, HWND_TOP, x, y, w, h, - SWP_NOACTIVATE | SWP_SHOWWINDOW); + SetWindowPos( + desk->m_window, HWND_TOP, x, y, w, h, SWP_NOACTIVATE | SWP_SHOWWINDOW); // switch to requested keyboard layout ActivateKeyboardLayout(keyLayout, 0); @@ -523,8 +542,9 @@ void MSWindowsDesks::deskLeave(Desk *desk, HKL keyLayout) { } } else { // move hider window under the cursor center, raise, and show it - SetWindowPos(desk->m_window, HWND_TOP, m_xCenter, m_yCenter, 1, 1, - SWP_NOACTIVATE | SWP_SHOWWINDOW); + SetWindowPos( + desk->m_window, HWND_TOP, m_xCenter, m_yCenter, 1, 1, + SWP_NOACTIVATE | SWP_SHOWWINDOW); // watch for mouse motion. if we see any then we hide the // hider window so the user can use the physically attached @@ -533,8 +553,8 @@ void MSWindowsDesks::deskLeave(Desk *desk, HKL keyLayout) { SetCapture(desk->m_window); // warp the mouse to the cursor center - LOG((CLOG_DEBUG2 "warping cursor to center: %+d,%+d", m_xCenter, - m_yCenter)); + LOG(( + CLOG_DEBUG2 "warping cursor to center: %+d,%+d", m_xCenter, m_yCenter)); deskMouseMove(m_xCenter, m_yCenter); } } @@ -554,7 +574,8 @@ void MSWindowsDesks::deskThread(void *vdesk) { // create a window. we use this window to hide the cursor. try { desk->m_window = createWindow(m_deskClass, "SynergyDesk"); - LOG((CLOG_DEBUG "desk %s window is 0x%08x", desk->m_name.c_str(), + LOG( + (CLOG_DEBUG "desk %s window is 0x%08x", desk->m_name.c_str(), desk->m_window)); } catch (...) { // ignore @@ -618,8 +639,8 @@ void MSWindowsDesks::deskThread(void *vdesk) { case SYNERGY_MSG_FAKE_KEY: // Note, this is intended to be HI/LOWORD and not HI/LOBYTE - send_keyboard_input(HIWORD(msg.lParam), LOWORD(msg.lParam), - (DWORD)msg.wParam); + send_keyboard_input( + HIWORD(msg.lParam), LOWORD(msg.lParam), (DWORD)msg.wParam); break; case SYNERGY_MSG_FAKE_BUTTON: @@ -629,13 +650,13 @@ void MSWindowsDesks::deskThread(void *vdesk) { break; case SYNERGY_MSG_FAKE_MOVE: - deskMouseMove(static_cast(msg.wParam), - static_cast(msg.lParam)); + deskMouseMove( + static_cast(msg.wParam), static_cast(msg.lParam)); break; case SYNERGY_MSG_FAKE_REL_MOVE: - deskMouseRelativeMove(static_cast(msg.wParam), - static_cast(msg.lParam)); + deskMouseRelativeMove( + static_cast(msg.wParam), static_cast(msg.lParam)); break; case SYNERGY_MSG_FAKE_WHEEL: @@ -669,9 +690,9 @@ void MSWindowsDesks::deskThread(void *vdesk) { break; case SYNERGY_MSG_FAKE_INPUT: - send_keyboard_input(SYNERGY_HOOK_FAKE_INPUT_VIRTUAL_KEY, - SYNERGY_HOOK_FAKE_INPUT_SCANCODE, - msg.wParam ? 0 : KEYEVENTF_KEYUP); + send_keyboard_input( + SYNERGY_HOOK_FAKE_INPUT_VIRTUAL_KEY, SYNERGY_HOOK_FAKE_INPUT_SCANCODE, + msg.wParam ? 0 : KEYEVENTF_KEYUP); break; } @@ -735,7 +756,8 @@ void MSWindowsDesks::checkDesk() { // if we are told to shut down on desk switch, and this is not the // first switch, then shut down. if (m_stopOnDeskSwitch && m_activeDesk != NULL && name != m_activeDeskName) { - LOG((CLOG_DEBUG "shutting down because of desk switch to \"%s\"", + LOG( + (CLOG_DEBUG "shutting down because of desk switch to \"%s\"", name.c_str())); m_events->addEvent(Event(Event::kQuit)); return; @@ -817,9 +839,9 @@ void MSWindowsDesks::handleCheckDesk(const Event &, void *) { HDESK MSWindowsDesks::openInputDesktop() { - return OpenInputDesktop(DF_ALLOWOTHERACCOUNTHOOK, TRUE, - DESKTOP_CREATEWINDOW | DESKTOP_HOOKCONTROL | - GENERIC_WRITE); + return OpenInputDesktop( + DF_ALLOWOTHERACCOUNTHOOK, TRUE, + DESKTOP_CREATEWINDOW | DESKTOP_HOOKCONTROL | GENERIC_WRITE); } void MSWindowsDesks::closeDesktop(HDESK desk) { diff --git a/src/lib/platform/MSWindowsDesks.h b/src/lib/platform/MSWindowsDesks.h index eea2538f6..cce464bef 100644 --- a/src/lib/platform/MSWindowsDesks.h +++ b/src/lib/platform/MSWindowsDesks.h @@ -64,8 +64,9 @@ public: 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( + bool isPrimary, bool noHooks, const IScreenSaver *screensaver, + IEventQueue *events, IJob *updateKeys, bool stopOnDeskSwitch); ~MSWindowsDesks(); //! @name manipulators @@ -122,8 +123,9 @@ public: /*! 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); + void setShape( + SInt32 x, SInt32 y, SInt32 width, SInt32 height, SInt32 xCenter, + SInt32 yCenter, bool isMultimon); //! Install/uninstall screensaver hooks /*! @@ -159,8 +161,8 @@ public: /*! Synthesize a press or release of key \c button. */ - void fakeKeyEvent(WORD virtualKey, WORD scanCode, DWORD flags, - bool isAutoRepeat) const; + void fakeKeyEvent( + WORD virtualKey, WORD scanCode, DWORD flags, bool isAutoRepeat) const; //! Fake mouse press/release /*! diff --git a/src/lib/platform/MSWindowsDropTarget.cpp b/src/lib/platform/MSWindowsDropTarget.cpp index bcae720d2..2f5c16bce 100644 --- a/src/lib/platform/MSWindowsDropTarget.cpp +++ b/src/lib/platform/MSWindowsDropTarget.cpp @@ -39,8 +39,8 @@ MSWindowsDropTarget &MSWindowsDropTarget::instance() { } HRESULT -MSWindowsDropTarget::DragEnter(IDataObject *dataObject, DWORD keyState, - POINTL point, DWORD *effect) { +MSWindowsDropTarget::DragEnter( + IDataObject *dataObject, DWORD keyState, POINTL point, DWORD *effect) { // check if data object contain drop m_allowDrop = queryDataObject(dataObject); if (m_allowDrop) { @@ -63,8 +63,8 @@ HRESULT MSWindowsDropTarget::DragLeave(void) { return S_OK; } HRESULT -MSWindowsDropTarget::Drop(IDataObject *dataObject, DWORD keyState, POINTL point, - DWORD *effect) { +MSWindowsDropTarget::Drop( + IDataObject *dataObject, DWORD keyState, POINTL point, DWORD *effect) { *effect = DROPEFFECT_NONE; return S_OK; @@ -120,8 +120,8 @@ void getDropData(IDataObject *dataObject) { } } -HRESULT __stdcall MSWindowsDropTarget::QueryInterface(REFIID iid, - void **object) { +HRESULT __stdcall MSWindowsDropTarget::QueryInterface( + REFIID iid, void **object) { if (iid == IID_IDropTarget || iid == IID_IUnknown) { AddRef(); *object = this; diff --git a/src/lib/platform/MSWindowsDropTarget.h b/src/lib/platform/MSWindowsDropTarget.h index 12b1cb9f9..8acf8cc2a 100644 --- a/src/lib/platform/MSWindowsDropTarget.h +++ b/src/lib/platform/MSWindowsDropTarget.h @@ -35,12 +35,12 @@ public: ULONG __stdcall Release(void); // IDropTarget implementation - HRESULT __stdcall DragEnter(IDataObject *dataObject, DWORD keyState, - POINTL point, DWORD *effect); + 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); + HRESULT __stdcall Drop( + IDataObject *dataObject, DWORD keyState, POINTL point, DWORD *effect); void setDraggingFilename(char *const); std::string getDraggingFilename(); diff --git a/src/lib/platform/MSWindowsEventQueueBuffer.cpp b/src/lib/platform/MSWindowsEventQueueBuffer.cpp index 9c90506f6..332b34d42 100644 --- a/src/lib/platform/MSWindowsEventQueueBuffer.cpp +++ b/src/lib/platform/MSWindowsEventQueueBuffer.cpp @@ -76,8 +76,8 @@ void MSWindowsEventQueueBuffer::waitForEvent(double timeout) { MsgWaitForMultipleObjects(0, dummy, FALSE, t, QS_ALLPOSTMESSAGE); } -IEventQueueBuffer::Type MSWindowsEventQueueBuffer::getEvent(Event &event, - UInt32 &dataID) { +IEventQueueBuffer::Type +MSWindowsEventQueueBuffer::getEvent(Event &event, UInt32 &dataID) { // NOTE: QS_ALLINPUT was replaced with QS_ALLPOSTMESSAGE. // // peek at messages first. waiting for QS_ALLINPUT will return @@ -109,8 +109,9 @@ IEventQueueBuffer::Type MSWindowsEventQueueBuffer::getEvent(Event &event, } bool MSWindowsEventQueueBuffer::addEvent(UInt32 dataID) { - return (PostThreadMessage(m_thread, m_userEvent, static_cast(dataID), - 0) != 0); + return ( + PostThreadMessage( + m_thread, m_userEvent, static_cast(dataID), 0) != 0); } bool MSWindowsEventQueueBuffer::isEmpty() const { diff --git a/src/lib/platform/MSWindowsHook.cpp b/src/lib/platform/MSWindowsHook.cpp index da5181528..faa75b3c2 100644 --- a/src/lib/platform/MSWindowsHook.cpp +++ b/src/lib/platform/MSWindowsHook.cpp @@ -64,7 +64,8 @@ void MSWindowsHook::loadLibrary() { // initialize library if (init(GetCurrentThreadId()) == 0) { - LOG((CLOG_ERR "failed to init %s.dll, another program may be using it", + LOG( + (CLOG_ERR "failed to init %s.dll, another program may be using it", g_name)); LOG((CLOG_INFO "restarting your computer may solve this error")); throw XScreenOpenFailure(); @@ -122,8 +123,8 @@ int MSWindowsHook::cleanup() { void MSWindowsHook::setSides(UInt32 sides) { g_zoneSides = sides; } -void MSWindowsHook::setZone(SInt32 x, SInt32 y, SInt32 w, SInt32 h, - SInt32 jumpZoneSize) { +void MSWindowsHook::setZone( + SInt32 x, SInt32 y, SInt32 w, SInt32 h, SInt32 jumpZoneSize) { g_zoneSize = jumpZoneSize; g_xScreen = x; g_yScreen = y; @@ -212,8 +213,8 @@ static bool keyboardHookHandler(WPARAM wParam, LPARAM lParam) { ((lParam >> 16) & 0xffu) == SYNERGY_HOOK_FAKE_INPUT_SCANCODE) { // update flag g_fakeServerInput = ((lParam & 0x80000000u) == 0); - PostThreadMessage(g_threadID, SYNERGY_MSG_DEBUG, 0xff000000u | wParam, - lParam); + PostThreadMessage( + g_threadID, SYNERGY_MSG_DEBUG, 0xff000000u | wParam, lParam); // discard event return true; @@ -222,8 +223,8 @@ static bool keyboardHookHandler(WPARAM wParam, LPARAM lParam) { // if we're expecting fake input then just pass the event through // and do not forward to the server if (g_fakeServerInput) { - PostThreadMessage(g_threadID, SYNERGY_MSG_DEBUG, 0xfe000000u | wParam, - lParam); + PostThreadMessage( + g_threadID, SYNERGY_MSG_DEBUG, 0xfe000000u | wParam, lParam); return false; } @@ -240,8 +241,8 @@ static bool keyboardHookHandler(WPARAM wParam, LPARAM lParam) { if ((g_deadVirtKey == wParam || g_deadRelease == wParam) && (lParam & 0x80000000u) != 0) { g_deadRelease = 0; - PostThreadMessage(g_threadID, SYNERGY_MSG_DEBUG, wParam | 0x04000000, - lParam); + PostThreadMessage( + g_threadID, SYNERGY_MSG_DEBUG, wParam | 0x04000000, lParam); return false; } @@ -309,8 +310,8 @@ static bool keyboardHookHandler(WPARAM wParam, LPARAM lParam) { bool noAltGr = false; if (n == 0 && (control & 0x80) != 0 && (menu & 0x80) != 0) { noAltGr = true; - PostThreadMessage(g_threadID, SYNERGY_MSG_DEBUG, wParam | 0x05000000, - lParam); + PostThreadMessage( + g_threadID, SYNERGY_MSG_DEBUG, wParam | 0x05000000, lParam); setDeadKey(wc, 2, flags); BYTE keys2[256]; @@ -326,10 +327,11 @@ static bool keyboardHookHandler(WPARAM wParam, LPARAM lParam) { n = ToUnicode((UINT)wParam, scanCode, keys2, wc, 2, flags); } - PostThreadMessage(g_threadID, SYNERGY_MSG_DEBUG, - (wc[0] & 0xffff) | ((wParam & 0xff) << 16) | - ((n & 0xf) << 24) | 0x60000000, - lParam); + PostThreadMessage( + g_threadID, SYNERGY_MSG_DEBUG, + (wc[0] & 0xffff) | ((wParam & 0xff) << 16) | ((n & 0xf) << 24) | + 0x60000000, + lParam); WPARAM charAndVirtKey = 0; bool clearDeadKey = false; switch (n) { @@ -367,10 +369,12 @@ static bool keyboardHookHandler(WPARAM wParam, LPARAM lParam) { // previous dead key not composed. send a fake key press // and release for the dead key to our window. WPARAM deadCharAndVirtKey = makeKeyMsg((UINT)g_deadVirtKey, wc[0], noAltGr); - PostThreadMessage(g_threadID, SYNERGY_MSG_KEY, deadCharAndVirtKey, - g_deadLParam & 0x7fffffffu); - PostThreadMessage(g_threadID, SYNERGY_MSG_KEY, deadCharAndVirtKey, - g_deadLParam | 0x80000000u); + PostThreadMessage( + g_threadID, SYNERGY_MSG_KEY, deadCharAndVirtKey, + g_deadLParam & 0x7fffffffu); + PostThreadMessage( + g_threadID, SYNERGY_MSG_KEY, deadCharAndVirtKey, + g_deadLParam | 0x80000000u); // use uncomposed character charAndVirtKey = makeKeyMsg((UINT)wParam, wc[1], noAltGr); @@ -381,8 +385,9 @@ static bool keyboardHookHandler(WPARAM wParam, LPARAM lParam) { // put back the dead key, if any, for the application to use if (g_deadVirtKey != 0) { - ToUnicode((UINT)g_deadVirtKey, (g_deadLParam & 0x10ff0000u) >> 16, - g_deadKeyState, wc, 2, flags); + ToUnicode( + (UINT)g_deadVirtKey, (g_deadLParam & 0x10ff0000u) >> 16, g_deadKeyState, + wc, 2, flags); } // clear out old dead key state @@ -398,8 +403,8 @@ static bool keyboardHookHandler(WPARAM wParam, LPARAM lParam) { // XXX -- with hot keys for actions we may only need to do this when // forwarding. if (charAndVirtKey != 0) { - PostThreadMessage(g_threadID, SYNERGY_MSG_DEBUG, - charAndVirtKey | 0x07000000, lParam); + PostThreadMessage( + g_threadID, SYNERGY_MSG_DEBUG, charAndVirtKey | 0x07000000, lParam); PostThreadMessage(g_threadID, SYNERGY_MSG_KEY, charAndVirtKey, lParam); } diff --git a/src/lib/platform/MSWindowsKeyState.cpp b/src/lib/platform/MSWindowsKeyState.cpp index 36bf6e80d..b925165cb 100644 --- a/src/lib/platform/MSWindowsKeyState.cpp +++ b/src/lib/platform/MSWindowsKeyState.cpp @@ -568,28 +568,36 @@ static const Win32Modifiers s_modifiers[] = { {VK_RMENU, KeyModifierAlt}, {VK_LWIN, KeyModifierSuper}, {VK_RWIN, KeyModifierSuper}}; -MSWindowsKeyState::MSWindowsKeyState(MSWindowsDesks *desks, void *eventTarget, - IEventQueue *events, - std::vector layouts, - bool isLangSyncEnabled) +MSWindowsKeyState::MSWindowsKeyState( + MSWindowsDesks *desks, void *eventTarget, IEventQueue *events, + std::vector layouts, bool isLangSyncEnabled) : KeyState(events, std::move(layouts), isLangSyncEnabled), - m_eventTarget(eventTarget), m_desks(desks), - m_keyLayout(GetKeyboardLayout(0)), m_fixTimer(NULL), m_lastDown(0), - m_useSavedModifiers(false), m_savedModifiers(0), - m_originalSavedModifiers(0), m_events(events) { + m_eventTarget(eventTarget), + m_desks(desks), + m_keyLayout(GetKeyboardLayout(0)), + m_fixTimer(NULL), + m_lastDown(0), + m_useSavedModifiers(false), + m_savedModifiers(0), + m_originalSavedModifiers(0), + m_events(events) { init(); } -MSWindowsKeyState::MSWindowsKeyState(MSWindowsDesks *desks, void *eventTarget, - IEventQueue *events, - synergy::KeyMap &keyMap, - std::vector layouts, - bool isLangSyncEnabled) +MSWindowsKeyState::MSWindowsKeyState( + MSWindowsDesks *desks, void *eventTarget, IEventQueue *events, + synergy::KeyMap &keyMap, std::vector layouts, + bool isLangSyncEnabled) : KeyState(events, keyMap, std::move(layouts), isLangSyncEnabled), - m_eventTarget(eventTarget), m_desks(desks), - m_keyLayout(GetKeyboardLayout(0)), m_fixTimer(NULL), m_lastDown(0), - m_useSavedModifiers(false), m_savedModifiers(0), - m_originalSavedModifiers(0), m_events(events) { + m_eventTarget(eventTarget), + m_desks(desks), + m_keyLayout(GetKeyboardLayout(0)), + m_fixTimer(NULL), + m_lastDown(0), + m_useSavedModifiers(false), + m_savedModifiers(0), + m_originalSavedModifiers(0), + m_events(events) { init(); } @@ -616,8 +624,8 @@ KeyButton MSWindowsKeyState::virtualKeyToButton(UINT virtualKey) const { void MSWindowsKeyState::setKeyLayout(HKL keyLayout) { m_keyLayout = keyLayout; } -bool MSWindowsKeyState::testAutoRepeat(bool press, bool isRepeat, - KeyButton button) { +bool MSWindowsKeyState::testAutoRepeat( + bool press, bool isRepeat, KeyButton button) { if (!isRepeat) { isRepeat = (press && m_lastDown != 0 && button == m_lastDown); } @@ -646,8 +654,8 @@ void MSWindowsKeyState::useSavedModifiers(bool enable) { } } -KeyID MSWindowsKeyState::mapKeyFromEvent(WPARAM charAndVirtKey, LPARAM info, - KeyModifierMask *maskOut) const { +KeyID MSWindowsKeyState::mapKeyFromEvent( + WPARAM charAndVirtKey, LPARAM info, KeyModifierMask *maskOut) const { static const KeyModifierMask s_controlAlt = KeyModifierControl | KeyModifierAlt; @@ -702,15 +710,14 @@ UINT MSWindowsKeyState::mapKeyToVirtualKey(KeyID key) const { } } -void MSWindowsKeyState::onKey(KeyButton button, bool down, - KeyModifierMask newState) { +void MSWindowsKeyState::onKey( + KeyButton button, bool down, KeyModifierMask newState) { KeyState::onKey(button, down, newState); } -void MSWindowsKeyState::sendKeyEvent(void *target, bool press, - bool isAutoRepeat, KeyID key, - KeyModifierMask mask, SInt32 count, - KeyButton button) { +void MSWindowsKeyState::sendKeyEvent( + void *target, bool press, bool isAutoRepeat, KeyID key, + KeyModifierMask mask, SInt32 count, KeyButton button) { if (press || isAutoRepeat) { // send key if (press && !isAutoRepeat) { @@ -728,14 +735,14 @@ void MSWindowsKeyState::sendKeyEvent(void *target, bool press, } } -void MSWindowsKeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, - KeyButton button, const String &lang) { +void MSWindowsKeyState::fakeKeyDown( + KeyID id, KeyModifierMask mask, KeyButton button, const String &lang) { KeyState::fakeKeyDown(id, mask, button, lang); } -bool MSWindowsKeyState::fakeKeyRepeat(KeyID id, KeyModifierMask mask, - SInt32 count, KeyButton button, - const String &lang) { +bool MSWindowsKeyState::fakeKeyRepeat( + KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, + const String &lang) { return KeyState::fakeKeyRepeat(id, mask, count, button, lang); } @@ -764,8 +771,9 @@ void MSWindowsKeyState::ctrlAltDelThread(void *) { HDESK desk = OpenDesktop("Winlogon", 0, FALSE, MAXIMUM_ALLOWED); if (desk != NULL) { if (SetThreadDesktop(desk)) { - PostMessage(HWND_BROADCAST, WM_HOTKEY, 0, - MAKELPARAM(MOD_CONTROL | MOD_ALT, VK_DELETE)); + PostMessage( + HWND_BROADCAST, WM_HOTKEY, 0, + MAKELPARAM(MOD_CONTROL | MOD_ALT, VK_DELETE)); } else { LOG((CLOG_DEBUG "can't switch to Winlogon desk: %d", GetLastError())); } @@ -1148,7 +1156,8 @@ void MSWindowsKeyState::getKeyMap(synergy::KeyMap &keyMap) { void MSWindowsKeyState::fakeKey(const Keystroke &keystroke) { switch (keystroke.m_type) { case Keystroke::kButton: { - LOG((CLOG_DEBUG1 " %03x (%08x) %s", keystroke.m_data.m_button.m_button, + LOG( + (CLOG_DEBUG1 " %03x (%08x) %s", keystroke.m_data.m_button.m_button, keystroke.m_data.m_button.m_client, keystroke.m_data.m_button.m_press ? "down" : "up")); KeyButton scanCode = keystroke.m_data.m_button.m_button; @@ -1176,8 +1185,8 @@ void MSWindowsKeyState::fakeKey(const Keystroke &keystroke) { // vk,sc,flags,keystroke.m_data.m_button.m_repeat - m_desks->fakeKeyEvent(vk, scanCode, flags, - keystroke.m_data.m_button.m_repeat); + m_desks->fakeKeyEvent( + vk, scanCode, flags, keystroke.m_data.m_button.m_repeat); // synthesize event // m_desks->fakeKeyEvent(button, vk, @@ -1196,8 +1205,8 @@ void MSWindowsKeyState::fakeKey(const Keystroke &keystroke) { setWindowGroup(keystroke.m_data.m_group.m_group); } else { LOG((CLOG_DEBUG1 " group %+d", keystroke.m_data.m_group.m_group)); - setWindowGroup(getEffectiveGroup(pollActiveGroup(), - keystroke.m_data.m_group.m_group)); + setWindowGroup(getEffectiveGroup( + pollActiveGroup(), keystroke.m_data.m_group.m_group)); } } break; @@ -1240,8 +1249,9 @@ void MSWindowsKeyState::setWindowGroup(SInt32 group) { // XXX -- determine if m_groups[group] can be used with the system // character set. - if (!PostMessage(targetWindow, WM_INPUTLANGCHANGEREQUEST, sysCharSet ? 1 : 0, - (LPARAM)m_groups[group])) { + if (!PostMessage( + targetWindow, WM_INPUTLANGCHANGEREQUEST, sysCharSet ? 1 : 0, + (LPARAM)m_groups[group])) { LOG((CLOG_WARN "failed to post change language message")); } @@ -1275,12 +1285,13 @@ UINT MSWindowsKeyState::mapButtonToVirtualKey(KeyButton button) const { return m_buttonToVK[button]; } -KeyID MSWindowsKeyState::getIDForKey(synergy::KeyMap::KeyItem &item, - KeyButton button, UINT virtualKey, - PBYTE keyState, HKL hkl) const { +KeyID MSWindowsKeyState::getIDForKey( + synergy::KeyMap::KeyItem &item, KeyButton button, UINT virtualKey, + PBYTE keyState, HKL hkl) const { WCHAR unicode[2]; - int n = m_ToUnicodeEx(virtualKey, button, keyState, unicode, - sizeof(unicode) / sizeof(unicode[0]), 0, hkl); + int n = m_ToUnicodeEx( + virtualKey, button, keyState, unicode, + sizeof(unicode) / sizeof(unicode[0]), 0, hkl); KeyID id = static_cast(unicode[0]); switch (n) { @@ -1290,8 +1301,9 @@ KeyID MSWindowsKeyState::getIDForKey(synergy::KeyMap::KeyItem &item, // with different modifiers are not affected. BYTE emptyState[256] = {}; - n = m_ToUnicodeEx(VK_SPACE, 0, emptyState, unicode, - sizeof(unicode) / sizeof(unicode[0]), 0, hkl); + n = m_ToUnicodeEx( + VK_SPACE, 0, emptyState, unicode, sizeof(unicode) / sizeof(unicode[0]), + 0, hkl); // as an alternative, we could use the returned // buffer in unicode to look at the dead key character @@ -1314,8 +1326,8 @@ KeyID MSWindowsKeyState::getIDForKey(synergy::KeyMap::KeyItem &item, } } -void MSWindowsKeyState::addKeyEntry(synergy::KeyMap &keyMap, - synergy::KeyMap::KeyItem &item) { +void MSWindowsKeyState::addKeyEntry( + synergy::KeyMap &keyMap, synergy::KeyMap::KeyItem &item) { keyMap.addKeyEntry(item); if (item.m_group == 0) { m_keyToVKMap[item.m_id] = static_cast(item.m_client); diff --git a/src/lib/platform/MSWindowsKeyState.h b/src/lib/platform/MSWindowsKeyState.h index b833a21c5..7dbdd5e4c 100644 --- a/src/lib/platform/MSWindowsKeyState.h +++ b/src/lib/platform/MSWindowsKeyState.h @@ -36,12 +36,13 @@ This class maps KeyIDs to keystrokes. */ class MSWindowsKeyState : public KeyState { public: - MSWindowsKeyState(MSWindowsDesks *desks, void *eventTarget, - IEventQueue *events, std::vector layouts, - bool isLangSyncEnabled); - MSWindowsKeyState(MSWindowsDesks *desks, void *eventTarget, - IEventQueue *events, synergy::KeyMap &keyMap, - std::vector layouts, bool isLangSyncEnabled); + MSWindowsKeyState( + MSWindowsDesks *desks, void *eventTarget, IEventQueue *events, + std::vector layouts, bool isLangSyncEnabled); + MSWindowsKeyState( + MSWindowsDesks *desks, void *eventTarget, IEventQueue *events, + synergy::KeyMap &keyMap, std::vector layouts, + bool isLangSyncEnabled); virtual ~MSWindowsKeyState(); //! @name manipulators @@ -103,8 +104,8 @@ public: 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; + KeyID mapKeyFromEvent( + WPARAM charAndVirtKey, LPARAM info, KeyModifierMask *maskOut) const; //! Check if keyboard groups have changed /*! @@ -139,10 +140,11 @@ public: //@} // 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 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; @@ -150,9 +152,9 @@ public: // 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); + 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; } @@ -175,8 +177,9 @@ private: bool getGroups(GroupList &) const; void setWindowGroup(SInt32 group); - KeyID getIDForKey(synergy::KeyMap::KeyItem &item, KeyButton button, - UINT virtualKey, PBYTE keyState, HKL hkl) const; + KeyID getIDForKey( + synergy::KeyMap::KeyItem &item, KeyButton button, UINT virtualKey, + PBYTE keyState, HKL hkl) const; void addKeyEntry(synergy::KeyMap &keyMap, synergy::KeyMap::KeyItem &item); @@ -219,9 +222,9 @@ private: 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); + 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[]; diff --git a/src/lib/platform/MSWindowsScreen.cpp b/src/lib/platform/MSWindowsScreen.cpp index 6a63c592e..0ed92f5ad 100644 --- a/src/lib/platform/MSWindowsScreen.cpp +++ b/src/lib/platform/MSWindowsScreen.cpp @@ -94,16 +94,38 @@ MSWindowsScreen *MSWindowsScreen::s_screen = NULL; MSWindowsScreen::MSWindowsScreen( bool isPrimary, bool noHooks, bool stopOnDeskSwitch, IEventQueue *events, bool enableLangSync, lib::synergy::ClientScrollDirection scrollDirection) - : PlatformScreen(events, scrollDirection), m_isPrimary(isPrimary), - m_noHooks(noHooks), m_isOnScreen(m_isPrimary), m_class(0), m_x(0), m_y(0), - m_w(0), m_h(0), m_xCenter(0), m_yCenter(0), m_multimon(false), - m_xCursor(0), m_yCursor(0), m_sequenceNumber(0), m_mark(0), - m_markReceived(0), m_fixTimer(NULL), m_keyLayout(NULL), - m_screensaver(NULL), m_screensaverNotify(false), - m_screensaverActive(false), m_window(NULL), m_nextClipboardWindow(NULL), - m_ownClipboard(false), m_desks(NULL), m_keyState(NULL), - m_hasMouse(GetSystemMetrics(SM_MOUSEPRESENT) != 0), m_showingMouse(false), - m_events(events), m_dropWindow(NULL), m_dropWindowSize(20) { + : PlatformScreen(events, scrollDirection), + m_isPrimary(isPrimary), + m_noHooks(noHooks), + m_isOnScreen(m_isPrimary), + m_class(0), + m_x(0), + m_y(0), + m_w(0), + m_h(0), + m_xCenter(0), + m_yCenter(0), + m_multimon(false), + m_xCursor(0), + m_yCursor(0), + m_sequenceNumber(0), + m_mark(0), + m_markReceived(0), + m_fixTimer(NULL), + m_keyLayout(NULL), + m_screensaver(NULL), + m_screensaverNotify(false), + m_screensaverActive(false), + m_window(NULL), + m_nextClipboardWindow(NULL), + m_ownClipboard(false), + m_desks(NULL), + m_keyState(NULL), + m_hasMouse(GetSystemMetrics(SM_MOUSEPRESENT) != 0), + m_showingMouse(false), + m_events(events), + m_dropWindow(NULL), + m_dropWindowSize(20) { assert(s_windowInstance != NULL); assert(s_screen == NULL); @@ -126,7 +148,8 @@ MSWindowsScreen::MSWindowsScreen( m_class = createWindowClass(); m_window = createWindow(m_class, "Synergy"); forceShowCursor(); - LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, + LOG( + (CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_multimon ? "(multi-monitor)" : "")); LOG((CLOG_DEBUG "window is 0x%08x", m_window)); @@ -134,10 +157,12 @@ MSWindowsScreen::MSWindowsScreen( char desktopPath[MAX_PATH]; if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, 0, desktopPath))) { m_desktopPath = String(desktopPath); - LOG((CLOG_DEBUG "using desktop for file drag-drop target: %s", + LOG( + (CLOG_DEBUG "using desktop for file drag-drop target: %s", m_desktopPath.c_str())); } else { - LOG((CLOG_DEBUG "unable to use desktop as file drag-drop target, code=%d", + LOG( + (CLOG_DEBUG "unable to use desktop as file drag-drop target, code=%d", GetLastError())); } @@ -160,9 +185,10 @@ MSWindowsScreen::MSWindowsScreen( } // install event handlers - m_events->adoptHandler(Event::kSystem, m_events->getSystemTarget(), - new TMethodEventJob( - this, &MSWindowsScreen::handleSystemEvent)); + m_events->adoptHandler( + Event::kSystem, m_events->getSystemTarget(), + new TMethodEventJob( + this, &MSWindowsScreen::handleSystemEvent)); // install the platform event queue m_events->adoptBuffer(new MSWindowsEventQueueBuffer(m_events)); @@ -203,9 +229,10 @@ void MSWindowsScreen::enable() { // we need to poll some things to fix them m_fixTimer = m_events->newTimer(1.0, NULL); - m_events->adoptHandler(Event::kTimer, m_fixTimer, - new TMethodEventJob( - this, &MSWindowsScreen::handleFixes)); + m_events->adoptHandler( + Event::kTimer, m_fixTimer, + new TMethodEventJob( + this, &MSWindowsScreen::handleFixes)); // install our clipboard snooper m_nextClipboardWindow = SetClipboardViewer(m_window); @@ -303,7 +330,8 @@ bool MSWindowsScreen::leave() { if (m_isPrimary) { // warp to center - LOG((CLOG_DEBUG1 "warping cursor to center: %+d, %+d", m_xCenter, + LOG( + (CLOG_DEBUG1 "warping cursor to center: %+d, %+d", m_xCenter, m_yCenter)); warpCursor(m_xCenter, m_yCenter); @@ -323,7 +351,8 @@ bool MSWindowsScreen::leave() { for (KeyButton i = 0; i < IKeyState::kNumButtons; ++i) { if (m_keyState->isKeyDown(i)) { m_primaryKeyDownList.push_back(i); - LOG((CLOG_DEBUG1 + LOG( + (CLOG_DEBUG1 "key button %d is down before leaving to another screen", i)); } @@ -350,7 +379,8 @@ void MSWindowsScreen::sendDragThread(void *) { ClientApp &app = ClientApp::instance(); Client *client = app.getClientPtr(); UInt32 fileCount = 1; - LOG((CLOG_DEBUG "send dragging info to server: %s", + LOG( + (CLOG_DEBUG "send dragging info to server: %s", draggingFilename.c_str())); client->sendDragInfo(fileCount, draggingFilename, size); LOG((CLOG_DEBUG "send dragging file to server")); @@ -392,10 +422,10 @@ void MSWindowsScreen::checkClipboards() { LOG((CLOG_DEBUG "clipboard changed: lost ownership and no notification received")); m_ownClipboard = false; - sendClipboardEvent(m_events->forClipboard().clipboardGrabbed(), - kClipboardClipboard); - sendClipboardEvent(m_events->forClipboard().clipboardGrabbed(), - kClipboardSelection); + sendClipboardEvent( + m_events->forClipboard().clipboardGrabbed(), kClipboardClipboard); + sendClipboardEvent( + m_events->forClipboard().clipboardGrabbed(), kClipboardSelection); } } @@ -455,8 +485,8 @@ bool MSWindowsScreen::getClipboard(ClipboardID, IClipboard *dst) const { return true; } -void MSWindowsScreen::getShape(SInt32 &x, SInt32 &y, SInt32 &w, - SInt32 &h) const { +void MSWindowsScreen::getShape( + SInt32 &x, SInt32 &y, SInt32 &w, SInt32 &h) const { assert(m_class != 0); x = m_x; @@ -479,12 +509,14 @@ void MSWindowsScreen::getCursorPos(SInt32 &x, SInt32 &y) const { bool MSWindowsScreen::getThisCursorPos(LPPOINT pos) { auto result = GetCursorPos(pos); auto error = GetLastError(); - LOG((CLOG_DEBUG3 "%s Attempt: 1 , status %d, code: %d Pos {%d, %d}", __func__, + LOG( + (CLOG_DEBUG3 "%s Attempt: 1 , status %d, code: %d Pos {%d, %d}", __func__, result, error, pos->x, pos->y)); if (!result) { result = GetCursorPos(pos); error = GetLastError(); - LOG((CLOG_DEBUG3 "%s Attempt: 2, status %d, code: %d Pos {%d, %d}", + LOG( + (CLOG_DEBUG3 "%s Attempt: 2, status %d, code: %d Pos {%d, %d}", __func__, result, error, pos->x, pos->y)); updateDesktopThread(); } @@ -494,12 +526,14 @@ bool MSWindowsScreen::getThisCursorPos(LPPOINT pos) { bool MSWindowsScreen::setThisCursorPos(int x, int y) { auto result = SetCursorPos(x, y); auto error = GetLastError(); - LOG((CLOG_DEBUG3 "%s Attempt: 1, status %d, code: %d", __func__, result, + LOG( + (CLOG_DEBUG3 "%s Attempt: 1, status %d, code: %d", __func__, result, error)); if (!result) { result = SetCursorPos(x, y); error = GetLastError(); - LOG((CLOG_DEBUG3 "%s Attempt: 2, status %d, code: %d", __func__, result, + LOG( + (CLOG_DEBUG3 "%s Attempt: 2, status %d, code: %d", __func__, result, error)); updateDesktopThread(); } @@ -516,7 +550,8 @@ void MSWindowsScreen::updateDesktopThread() { LOG((CLOG_DEBUG3 "current desktop, handle=%p code=%d", cur_hdesk, error)); error = GetLastError(); - LOG((CLOG_DEBUG3 "setting desktop, return=%d code=%d", + LOG( + (CLOG_DEBUG3 "setting desktop, return=%d code=%d", SetThreadDesktop(cur_hdesk), GetLastError())); CloseDesktop(cur_hdesk); @@ -535,8 +570,8 @@ void MSWindowsScreen::warpCursor(SInt32 x, SInt32 y) { // remove all input events before and including warp MSG msg; - while (PeekMessage(&msg, NULL, SYNERGY_MSG_INPUT_FIRST, - SYNERGY_MSG_INPUT_LAST, PM_REMOVE)) { + while (PeekMessage( + &msg, NULL, SYNERGY_MSG_INPUT_FIRST, SYNERGY_MSG_INPUT_LAST, PM_REMOVE)) { // do nothing } @@ -615,12 +650,14 @@ UInt32 MSWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask) { } else { m_oldHotKeyIDs.push_back(id); m_hotKeys.erase(id); - LOG((CLOG_WARN "failed to register hotkey %s (id=%04x mask=%04x)", + LOG( + (CLOG_WARN "failed to register hotkey %s (id=%04x mask=%04x)", synergy::KeyMap::formatKey(key, mask).c_str(), key, mask)); return 0; } - LOG((CLOG_DEBUG "registered hotkey %s (id=%04x mask=%04x) as id=%d", + LOG( + (CLOG_DEBUG "registered hotkey %s (id=%04x mask=%04x) as id=%d", synergy::KeyMap::formatKey(key, mask).c_str(), key, mask, id)); return id; } @@ -725,15 +762,15 @@ void MSWindowsScreen::fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const { void MSWindowsScreen::updateKeys() { m_desks->updateKeys(); } -void MSWindowsScreen::fakeKeyDown(KeyID id, KeyModifierMask mask, - KeyButton button, const String &lang) { +void MSWindowsScreen::fakeKeyDown( + KeyID id, KeyModifierMask mask, KeyButton button, const String &lang) { PlatformScreen::fakeKeyDown(id, mask, button, lang); updateForceShowCursor(); } -bool MSWindowsScreen::fakeKeyRepeat(KeyID id, KeyModifierMask mask, - SInt32 count, KeyButton button, - const String &lang) { +bool MSWindowsScreen::fakeKeyRepeat( + KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, + const String &lang) { bool result = PlatformScreen::fakeKeyRepeat(id, mask, count, button, lang); updateForceShowCursor(); return result; @@ -797,10 +834,10 @@ void MSWindowsScreen::destroyClass(ATOM windowClass) const { } HWND MSWindowsScreen::createWindow(ATOM windowClass, const char *name) const { - HWND window = - CreateWindowEx(WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, - MAKEINTATOM(windowClass), name, WS_POPUP, 0, 0, 1, 1, NULL, - NULL, s_windowInstance, NULL); + HWND window = CreateWindowEx( + WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, + MAKEINTATOM(windowClass), name, WS_POPUP, 0, 0, 1, 1, NULL, NULL, + s_windowInstance, NULL); if (window == NULL) { LOG((CLOG_ERR "failed to create window: %d", GetLastError())); throw XScreenOpenFailure(); @@ -808,8 +845,8 @@ HWND MSWindowsScreen::createWindow(ATOM windowClass, const char *name) const { return window; } -HWND MSWindowsScreen::createDropWindow(ATOM windowClass, - const char *name) const { +HWND MSWindowsScreen::createDropWindow( + ATOM windowClass, const char *name) const { HWND window = CreateWindowEx( WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_ACCEPTFILES, MAKEINTATOM(m_class), name, WS_POPUP, 0, 0, m_dropWindowSize, @@ -872,8 +909,8 @@ void MSWindowsScreen::updateButtons() { IKeyState *MSWindowsScreen::getKeyState() const { return m_keyState; } -bool MSWindowsScreen::onPreDispatch(HWND hwnd, UINT message, WPARAM wParam, - LPARAM lParam) { +bool MSWindowsScreen::onPreDispatch( + HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { // handle event switch (message) { case SYNERGY_MSG_SCREEN_SAVER: @@ -891,8 +928,8 @@ bool MSWindowsScreen::onPreDispatch(HWND hwnd, UINT message, WPARAM wParam, return false; } -bool MSWindowsScreen::onPreDispatchPrimary(HWND, UINT message, WPARAM wParam, - LPARAM lParam) { +bool MSWindowsScreen::onPreDispatchPrimary( + HWND, UINT message, WPARAM wParam, LPARAM lParam) { LOG((CLOG_DEBUG5 "handling pre-dispatch primary")); // handle event @@ -907,8 +944,8 @@ bool MSWindowsScreen::onPreDispatchPrimary(HWND, UINT message, WPARAM wParam, return onMouseButton(wParam, lParam); case SYNERGY_MSG_MOUSE_MOVE: - return onMouseMove(static_cast(wParam), - static_cast(lParam)); + return onMouseMove( + static_cast(wParam), static_cast(lParam)); case SYNERGY_MSG_MOUSE_WHEEL: // XXX -- support x-axis scrolling @@ -945,8 +982,8 @@ bool MSWindowsScreen::onPreDispatchPrimary(HWND, UINT message, WPARAM wParam, return false; } -bool MSWindowsScreen::onEvent(HWND, UINT msg, WPARAM wParam, LPARAM lParam, - LRESULT *result) { +bool MSWindowsScreen::onEvent( + HWND, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *result) { switch (msg) { case WM_DRAWCLIPBOARD: // first pass on the message @@ -960,7 +997,8 @@ bool MSWindowsScreen::onEvent(HWND, UINT msg, WPARAM wParam, LPARAM lParam, case WM_CHANGECBCHAIN: if (m_nextClipboardWindow == (HWND)wParam) { m_nextClipboardWindow = (HWND)lParam; - LOG((CLOG_DEBUG "clipboard chain: new next: 0x%08x", + LOG( + (CLOG_DEBUG "clipboard chain: new next: 0x%08x", m_nextClipboardWindow)); } else if (m_nextClipboardWindow != NULL) { SendMessage(m_nextClipboardWindow, msg, wParam, lParam); @@ -973,8 +1011,9 @@ bool MSWindowsScreen::onEvent(HWND, UINT msg, WPARAM wParam, LPARAM lParam, /* On windows 10 we don't receive WM_POWERBROADCAST after sleep. We receive only WM_TIMECHANGE hence this message is used to resume.*/ case WM_TIMECHANGE: - m_events->addEvent(Event(m_events->forIScreen().resume(), getEventTarget(), - NULL, Event::kDeliverImmediately)); + m_events->addEvent(Event( + m_events->forIScreen().resume(), getEventTarget(), NULL, + Event::kDeliverImmediately)); break; case WM_POWERBROADCAST: @@ -982,15 +1021,15 @@ bool MSWindowsScreen::onEvent(HWND, UINT msg, WPARAM wParam, LPARAM lParam, case PBT_APMRESUMEAUTOMATIC: case PBT_APMRESUMECRITICAL: case PBT_APMRESUMESUSPEND: - m_events->addEvent(Event(m_events->forIScreen().resume(), - getEventTarget(), NULL, - Event::kDeliverImmediately)); + m_events->addEvent(Event( + m_events->forIScreen().resume(), getEventTarget(), NULL, + Event::kDeliverImmediately)); break; case PBT_APMSUSPEND: - m_events->addEvent(Event(m_events->forIScreen().suspend(), - getEventTarget(), NULL, - Event::kDeliverImmediately)); + m_events->addEvent(Event( + m_events->forIScreen().suspend(), getEventTarget(), NULL, + Event::kDeliverImmediately)); break; } *result = TRUE; @@ -1018,7 +1057,8 @@ bool MSWindowsScreen::onMark(UInt32 mark) { bool MSWindowsScreen::onKey(WPARAM wParam, LPARAM lParam) { static const KeyModifierMask s_ctrlAlt = KeyModifierControl | KeyModifierAlt; - LOG((CLOG_DEBUG1 "event: Key char=%d, vk=0x%02x, nagr=%d, lParam=0x%08x", + LOG( + (CLOG_DEBUG1 "event: Key char=%d, vk=0x%02x, nagr=%d, lParam=0x%08x", (wParam & 0xffffu), (wParam >> 16) & 0xffu, (wParam & 0x1000000u) ? 1 : 0, lParam)); @@ -1130,9 +1170,10 @@ bool MSWindowsScreen::onKey(WPARAM wParam, LPARAM lParam) { button = static_cast((lParam & 0x01ff0000u) >> 16); if (key != kKeyNone) { // do it - m_keyState->sendKeyEvent(getEventTarget(), ((lParam & 0x80000000u) == 0), - ((lParam & 0x40000000u) != 0), key, mask, - (SInt32)(lParam & 0xffff), button); + m_keyState->sendKeyEvent( + getEventTarget(), ((lParam & 0x80000000u) == 0), + ((lParam & 0x40000000u) != 0), key, mask, (SInt32)(lParam & 0xffff), + button); } else { LOG((CLOG_DEBUG1 "cannot map key")); } @@ -1212,14 +1253,16 @@ bool MSWindowsScreen::onMouseButton(WPARAM wParam, LPARAM lParam) { if (pressed) { LOG((CLOG_DEBUG1 "event: button press button=%d", button)); if (button != kButtonNone) { - sendEvent(m_events->forIPrimaryScreen().buttonDown(), - ButtonInfo::alloc(button, mask)); + sendEvent( + m_events->forIPrimaryScreen().buttonDown(), + ButtonInfo::alloc(button, mask)); } } else { LOG((CLOG_DEBUG1 "event: button release button=%d", button)); if (button != kButtonNone) { - sendEvent(m_events->forIPrimaryScreen().buttonUp(), - ButtonInfo::alloc(button, mask)); + sendEvent( + m_events->forIPrimaryScreen().buttonUp(), + ButtonInfo::alloc(button, mask)); } } } @@ -1243,7 +1286,8 @@ bool MSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my) { SInt32 x = mx - m_xCursor; SInt32 y = my - m_yCursor; - LOG((CLOG_DEBUG3 "mouse move - motion delta: %+d=(%+d - %+d),%+d=(%+d - %+d)", + LOG( + (CLOG_DEBUG3 "mouse move - motion delta: %+d=(%+d - %+d),%+d=(%+d - %+d)", x, mx, m_xCursor, y, my, m_yCursor)); // ignore if the mouse didn't move or if message posted prior @@ -1258,8 +1302,9 @@ bool MSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my) { if (m_isOnScreen) { // motion on primary screen - sendEvent(m_events->forIPrimaryScreen().motionOnPrimary(), - MotionInfo::alloc(m_xCursor, m_yCursor)); + sendEvent( + m_events->forIPrimaryScreen().motionOnPrimary(), + MotionInfo::alloc(m_xCursor, m_yCursor)); if (m_buttons[kButtonLeft] == true && m_draggingStarted == false) { m_draggingStarted = true; @@ -1269,7 +1314,8 @@ bool MSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my) { // center on the server screen. if we don't do this, then the mouse // will always try to return to the original entry point on the // secondary screen. - LOG((CLOG_DEBUG5 "warping server cursor to center: %+d,%+d", m_xCenter, + LOG( + (CLOG_DEBUG5 "warping server cursor to center: %+d,%+d", m_xCenter, m_yCenter)); warpCursorNoFlush(m_xCenter, m_yCenter); @@ -1287,8 +1333,9 @@ bool MSWindowsScreen::onMouseMove(SInt32 mx, SInt32 my) { LOG((CLOG_DEBUG "dropped bogus delta motion: %+d,%+d", x, y)); } else { // send motion - sendEvent(m_events->forIPrimaryScreen().motionOnSecondary(), - MotionInfo::alloc(x, y)); + sendEvent( + m_events->forIPrimaryScreen().motionOnSecondary(), + MotionInfo::alloc(x, y)); } } @@ -1299,8 +1346,9 @@ bool MSWindowsScreen::onMouseWheel(SInt32 xDelta, SInt32 yDelta) { // ignore message if posted prior to last mark change if (!ignore()) { LOG((CLOG_DEBUG1 "event: button wheel delta=%+d,%+d", xDelta, yDelta)); - sendEvent(m_events->forIPrimaryScreen().wheel(), - WheelInfo::alloc(xDelta, yDelta)); + sendEvent( + m_events->forIPrimaryScreen().wheel(), + WheelInfo::alloc(xDelta, yDelta)); } return true; } @@ -1315,8 +1363,9 @@ bool MSWindowsScreen::onScreensaver(bool activated) { // send SC_SCREENSAVE until the screen saver starts, even if // the screen saver is disabled! MSG msg; - if (PeekMessage(&msg, NULL, SYNERGY_MSG_SCREEN_SAVER, - SYNERGY_MSG_SCREEN_SAVER, PM_NOREMOVE)) { + if (PeekMessage( + &msg, NULL, SYNERGY_MSG_SCREEN_SAVER, SYNERGY_MSG_SCREEN_SAVER, + PM_NOREMOVE)) { return true; } @@ -1349,7 +1398,8 @@ bool MSWindowsScreen::onDisplayChange() { // warp mouse to center if off screen if (!m_isOnScreen) { - LOG((CLOG_DEBUG1 "warping cursor to center: %+d, %+d", m_xCenter, + LOG( + (CLOG_DEBUG1 "warping cursor to center: %+d, %+d", m_xCenter, m_yCenter)); warpCursor(m_xCenter, m_yCenter); } @@ -1363,7 +1413,8 @@ bool MSWindowsScreen::onDisplayChange() { // send new screen info sendEvent(m_events->forIScreen().shapeChanged()); - LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, + LOG( + (CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_multimon ? "(multi-monitor)" : "")); } @@ -1377,10 +1428,10 @@ bool MSWindowsScreen::onClipboardChange() { if (m_ownClipboard) { LOG((CLOG_DEBUG "clipboard changed: lost ownership")); m_ownClipboard = false; - sendClipboardEvent(m_events->forClipboard().clipboardGrabbed(), - kClipboardClipboard); - sendClipboardEvent(m_events->forClipboard().clipboardGrabbed(), - kClipboardSelection); + sendClipboardEvent( + m_events->forClipboard().clipboardGrabbed(), kClipboardClipboard); + sendClipboardEvent( + m_events->forClipboard().clipboardGrabbed(), kClipboardSelection); } } else if (!m_ownClipboard) { LOG((CLOG_DEBUG "clipboard changed: synergy owned")); @@ -1409,7 +1460,8 @@ void MSWindowsScreen::warpCursorNoFlush(SInt32 x, SInt32 y) { if ((cursorPos.x != x) && (cursorPos.y != y)) { LOG((CLOG_DEBUG "function 'SetCursorPos' failed; trying 'fakeMouseMove'")); - LOG((CLOG_DEBUG "cursor pos %d, %d expected pos %d, %d", cursorPos.x, + LOG( + (CLOG_DEBUG "cursor pos %d, %d expected pos %d, %d", cursorPos.x, cursorPos.y, x, y)); // when at Vista/7 login screen, SetCursorPos does not work (which could // be an MS security feature). instead we can use fakeMouseMove, which @@ -1464,8 +1516,9 @@ void MSWindowsScreen::updateScreenShape() { m_yCenter = GetSystemMetrics(SM_CYSCREEN) >> 1; // check for multiple monitors - m_multimon = (m_w != GetSystemMetrics(SM_CXSCREEN) || - m_h != GetSystemMetrics(SM_CYSCREEN)); + m_multimon = + (m_w != GetSystemMetrics(SM_CXSCREEN) || + m_h != GetSystemMetrics(SM_CYSCREEN)); // tell the desks m_desks->setShape(m_x, m_y, m_w, m_h, m_xCenter, m_yCenter, m_multimon); @@ -1609,8 +1662,8 @@ void MSWindowsScreen::updateKeysCB(void *) { KeyModifierMask mask = pollActiveModifiers(); for (KeyButton i = 0; i < IKeyState::kNumButtons; ++i) { if (down[i] && !m_keyState->isKeyDown(i)) { - m_keyState->sendKeyEvent(getEventTarget(), false, false, kKeyNone, mask, - 1, i); + m_keyState->sendKeyEvent( + getEventTarget(), false, false, kKeyNone, mask, 1, i); } } } @@ -1628,8 +1681,9 @@ void MSWindowsScreen::forceShowCursor() { if (showMouse) { m_oldMouseKeys.cbSize = sizeof(m_oldMouseKeys); m_gotOldMouseKeys = - (SystemParametersInfo(SPI_GETMOUSEKEYS, m_oldMouseKeys.cbSize, - &m_oldMouseKeys, 0) != 0); + (SystemParametersInfo( + SPI_GETMOUSEKEYS, m_oldMouseKeys.cbSize, &m_oldMouseKeys, 0) != + 0); if (m_gotOldMouseKeys) { m_mouseKeys = m_oldMouseKeys; m_showingMouse = true; @@ -1637,8 +1691,9 @@ void MSWindowsScreen::forceShowCursor() { } } else { if (m_gotOldMouseKeys) { - SystemParametersInfo(SPI_SETMOUSEKEYS, m_oldMouseKeys.cbSize, - &m_oldMouseKeys, SPIF_SENDCHANGE); + SystemParametersInfo( + SPI_SETMOUSEKEYS, m_oldMouseKeys.cbSize, &m_oldMouseKeys, + SPIF_SENDCHANGE); m_showingMouse = false; } } @@ -1659,13 +1714,13 @@ void MSWindowsScreen::updateForceShowCursor() { // update MouseKeys if (oldFlags != m_mouseKeys.dwFlags) { - SystemParametersInfo(SPI_SETMOUSEKEYS, m_mouseKeys.cbSize, &m_mouseKeys, - SPIF_SENDCHANGE); + SystemParametersInfo( + SPI_SETMOUSEKEYS, m_mouseKeys.cbSize, &m_mouseKeys, SPIF_SENDCHANGE); } } -LRESULT CALLBACK MSWindowsScreen::wndProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam) { +LRESULT CALLBACK +MSWindowsScreen::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { assert(s_screen != NULL); LRESULT result = 0; @@ -1692,15 +1747,17 @@ void MSWindowsScreen::fakeLocalKey(KeyButton button, bool press) const { // MSWindowsScreen::HotKeyItem::HotKeyItem(UINT keycode, UINT mask) - : m_keycode(keycode), m_mask(mask) { + : m_keycode(keycode), + m_mask(mask) { // do nothing } UINT MSWindowsScreen::HotKeyItem::getVirtualKey() const { return m_keycode; } bool MSWindowsScreen::HotKeyItem::operator<(const HotKeyItem &x) const { - return (m_keycode < x.m_keycode || - (m_keycode == x.m_keycode && m_mask < x.m_mask)); + return ( + m_keycode < x.m_keycode || + (m_keycode == x.m_keycode && m_mask < x.m_mask)); } void MSWindowsScreen::fakeDraggingFiles(DragFileList fileList) { @@ -1719,12 +1776,13 @@ String &MSWindowsScreen::getDraggingFilename() { SInt32 yPos = m_isPrimary ? m_yCursor : m_yCenter; xPos = (xPos - halfSize) < 0 ? 0 : xPos - halfSize; yPos = (yPos - halfSize) < 0 ? 0 : yPos - halfSize; - SetWindowPos(m_dropWindow, HWND_TOPMOST, xPos, yPos, m_dropWindowSize, - m_dropWindowSize, SWP_SHOWWINDOW); + SetWindowPos( + m_dropWindow, HWND_TOPMOST, xPos, yPos, m_dropWindowSize, + m_dropWindowSize, SWP_SHOWWINDOW); // TODO: fake these keys properly - fakeKeyDown(kKeyEscape, 8192, 1, - AppUtil::instance().getCurrentLanguageCode()); + fakeKeyDown( + kKeyEscape, 8192, 1, AppUtil::instance().getCurrentLanguageCode()); fakeKeyUp(1); fakeMouseButton(kButtonLeft, false); @@ -1763,9 +1821,8 @@ String MSWindowsScreen::getSecureInputApp() const { return ""; } -bool MSWindowsScreen::isModifierRepeat(KeyModifierMask oldState, - KeyModifierMask state, - WPARAM wParam) const { +bool MSWindowsScreen::isModifierRepeat( + KeyModifierMask oldState, KeyModifierMask state, WPARAM wParam) const { bool result = false; if (oldState == state && state != 0) { diff --git a/src/lib/platform/MSWindowsScreen.h b/src/lib/platform/MSWindowsScreen.h index 56d5ec7a9..27889082c 100644 --- a/src/lib/platform/MSWindowsScreen.h +++ b/src/lib/platform/MSWindowsScreen.h @@ -41,10 +41,11 @@ 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, - lib::synergy::ClientScrollDirection scrollDirection = - lib::synergy::ClientScrollDirection::SERVER); + MSWindowsScreen( + bool isPrimary, bool noHooks, bool stopOnDeskSwitch, IEventQueue *events, + bool enableLangSync = false, + lib::synergy::ClientScrollDirection scrollDirection = + lib::synergy::ClientScrollDirection::SERVER); virtual ~MSWindowsScreen(); //! @name manipulators @@ -72,8 +73,8 @@ public: // 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 + getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const; virtual void getCursorPos(SInt32 &x, SInt32 &y) const; /** @@ -115,10 +116,11 @@ public: // 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 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(); @@ -242,8 +244,8 @@ private: // HACK void saveMousePosition(SInt32 x, SInt32 y); // check if it is a modifier key repeating message - bool isModifierRepeat(KeyModifierMask oldState, KeyModifierMask state, - WPARAM wParam) const; + bool isModifierRepeat( + KeyModifierMask oldState, KeyModifierMask state, WPARAM wParam) const; // send drag info and data back to server void sendDragThread(void *); diff --git a/src/lib/platform/MSWindowsScreenSaver.cpp b/src/lib/platform/MSWindowsScreenSaver.cpp index a411eea57..bdd255215 100644 --- a/src/lib/platform/MSWindowsScreenSaver.cpp +++ b/src/lib/platform/MSWindowsScreenSaver.cpp @@ -34,16 +34,22 @@ static const TCHAR *g_isSecureNT = "ScreenSaverIsSecure"; static const TCHAR *g_isSecure9x = "ScreenSaveUsePassword"; -static const TCHAR *const g_pathScreenSaverIsSecure[] = {"Control Panel", - "Desktop", NULL}; +static const TCHAR *const g_pathScreenSaverIsSecure[] = { + "Control Panel", "Desktop", NULL}; // // MSWindowsScreenSaver // MSWindowsScreenSaver::MSWindowsScreenSaver() - : m_wasSecure(false), m_wasSecureAnInt(false), m_process(NULL), - m_watch(NULL), m_threadID(0), m_msg(0), m_wParam(0), m_lParam(0), + : m_wasSecure(false), + m_wasSecureAnInt(false), + m_process(NULL), + m_watch(NULL), + m_threadID(0), + m_msg(0), + m_wParam(0), + m_lParam(0), m_active(false) { // check if screen saver is enabled SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &m_wasEnabled, 0); @@ -51,8 +57,8 @@ MSWindowsScreenSaver::MSWindowsScreenSaver() MSWindowsScreenSaver::~MSWindowsScreenSaver() { unwatchProcess(); } -bool MSWindowsScreenSaver::checkStarted(UINT msg, WPARAM wParam, - LPARAM lParam) { +bool MSWindowsScreenSaver::checkStarted( + UINT msg, WPARAM wParam, LPARAM lParam) { // if already started then say it didn't just start if (m_active) { return false; @@ -128,11 +134,12 @@ void MSWindowsScreenSaver::deactivate() { bool killed = false; // NT runs screen saver in another desktop - HDESK desktop = OpenDesktop("Screen-saver", 0, FALSE, - DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS); + HDESK desktop = OpenDesktop( + "Screen-saver", 0, FALSE, DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS); if (desktop != NULL) { - EnumDesktopWindows(desktop, &MSWindowsScreenSaver::killScreenSaverFunc, - reinterpret_cast(&killed)); + EnumDesktopWindows( + desktop, &MSWindowsScreenSaver::killScreenSaverFunc, + reinterpret_cast(&killed)); CloseDesktop(desktop); } @@ -151,10 +158,10 @@ void MSWindowsScreenSaver::deactivate() { // force timer to restart SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &m_wasEnabled, 0); - SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, !m_wasEnabled, 0, - SPIF_SENDWININICHANGE); - SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, m_wasEnabled, 0, - SPIF_SENDWININICHANGE); + SystemParametersInfo( + SPI_SETSCREENSAVEACTIVE, !m_wasEnabled, 0, SPIF_SENDWININICHANGE); + SystemParametersInfo( + SPI_SETSCREENSAVEACTIVE, m_wasEnabled, 0, SPIF_SENDWININICHANGE); } bool MSWindowsScreenSaver::isActive() const { diff --git a/src/lib/platform/MSWindowsSession.cpp b/src/lib/platform/MSWindowsSession.cpp index 0a5af2664..a00ff4ce5 100644 --- a/src/lib/platform/MSWindowsSession.cpp +++ b/src/lib/platform/MSWindowsSession.cpp @@ -27,8 +27,8 @@ MSWindowsSession::MSWindowsSession() : m_activeSessionId(-1) {} MSWindowsSession::~MSWindowsSession() {} -bool MSWindowsSession::isProcessInSession(const char *name, - PHANDLE process = NULL) { +bool MSWindowsSession::isProcessInSession( + const char *name, PHANDLE process = NULL) { // first we need to take a snapshot of the running processes HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (snapshot == INVALID_HANDLE_VALUE) { @@ -64,7 +64,8 @@ bool MSWindowsSession::isProcessInSession(const char *name, if (!pidToSidRet) { // if we can not acquire session associated with a specified process, // simply ignore it - LOG((CLOG_DEBUG2 "could not get session id for process: %i %s, code=%i", + LOG( + (CLOG_DEBUG2 "could not get session id for process: %i %s, code=%i", entry.th32ProcessID, entry.szExeFile, GetLastError())); gotEntry = nextProcessEntry(snapshot, &entry); continue; @@ -93,7 +94,8 @@ bool MSWindowsSession::isProcessInSession(const char *name, nameListJoin.append(", "); } - LOG((CLOG_DEBUG2 "processes in session %d: %s", m_activeSessionId, + LOG( + (CLOG_DEBUG2 "processes in session %d: %s", m_activeSessionId, nameListJoin.c_str())); CloseHandle(snapshot); @@ -120,9 +122,9 @@ MSWindowsSession::getUserToken(LPSECURITY_ATTRIBUTES security) { } HANDLE newToken; - if (!DuplicateTokenEx(sourceToken, TOKEN_ASSIGN_PRIMARY | TOKEN_ALL_ACCESS, - security, SecurityImpersonation, TokenPrimary, - &newToken)) { + if (!DuplicateTokenEx( + sourceToken, TOKEN_ASSIGN_PRIMARY | TOKEN_ALL_ACCESS, security, + SecurityImpersonation, TokenPrimary, &newToken)) { LOG((CLOG_ERR "could not duplicate token")); throw XArch(new XArchEvalWindows); @@ -140,8 +142,8 @@ void MSWindowsSession::updateActiveSession() { m_activeSessionId = WTSGetActiveConsoleSessionId(); } -BOOL MSWindowsSession::nextProcessEntry(HANDLE snapshot, - LPPROCESSENTRY32 entry) { +BOOL MSWindowsSession::nextProcessEntry( + HANDLE snapshot, LPPROCESSENTRY32 entry) { // TODO: issue S3-2021 // resetting the error state here is acceptable, but having to do so indicates // that a different win32 function call has failed beforehand. we should diff --git a/src/lib/platform/MSWindowsUtil.cpp b/src/lib/platform/MSWindowsUtil.cpp index 3a6bdf102..1518241ae 100644 --- a/src/lib/platform/MSWindowsUtil.cpp +++ b/src/lib/platform/MSWindowsUtil.cpp @@ -37,17 +37,17 @@ String MSWindowsUtil::getString(HINSTANCE instance, DWORD id) { return String(msg, n); } -String MSWindowsUtil::getErrorString(HINSTANCE hinstance, DWORD error, - DWORD id) { +String +MSWindowsUtil::getErrorString(HINSTANCE hinstance, DWORD error, DWORD id) { char *buffer; - if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_IGNORE_INSERTS | - FORMAT_MESSAGE_FROM_SYSTEM, - 0, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&buffer, 0, NULL) == 0) { + if (FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | + FORMAT_MESSAGE_FROM_SYSTEM, + 0, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&buffer, + 0, NULL) == 0) { String errorString = synergy::string::sprintf("%d", error); - return synergy::string::format(getString(hinstance, id).c_str(), - errorString.c_str()); + return synergy::string::format( + getString(hinstance, id).c_str(), errorString.c_str()); } else { String result(buffer); LocalFree(buffer); diff --git a/src/lib/platform/MSWindowsWatchdog.cpp b/src/lib/platform/MSWindowsWatchdog.cpp index 7d1a90d53..c8652c1c8 100644 --- a/src/lib/platform/MSWindowsWatchdog.cpp +++ b/src/lib/platform/MSWindowsWatchdog.cpp @@ -78,16 +78,24 @@ typedef VOID(WINAPI *SendSas)(BOOL asUser); const char g_activeDesktop[] = {"activeDesktop:"}; -MSWindowsWatchdog::MSWindowsWatchdog(bool autoDetectCommand, - IpcServer &ipcServer, - IpcLogOutputter &ipcLogOutputter, - bool foreground) - : m_thread(NULL), m_autoDetectCommand(autoDetectCommand), - m_monitoring(true), m_commandChanged(false), m_stdOutWrite(NULL), - m_stdOutRead(NULL), m_ipcServer(ipcServer), - m_ipcLogOutputter(ipcLogOutputter), m_elevateProcess(false), - m_processFailures(0), m_processRunning(false), m_fileLogOutputter(NULL), - m_autoElevated(false), m_ready(false), m_foreground(foreground) { +MSWindowsWatchdog::MSWindowsWatchdog( + bool autoDetectCommand, IpcServer &ipcServer, + IpcLogOutputter &ipcLogOutputter, bool foreground) + : m_thread(NULL), + m_autoDetectCommand(autoDetectCommand), + m_monitoring(true), + m_commandChanged(false), + m_stdOutWrite(NULL), + m_stdOutRead(NULL), + m_ipcServer(ipcServer), + m_ipcLogOutputter(ipcLogOutputter), + m_elevateProcess(false), + m_processFailures(0), + m_processRunning(false), + m_fileLogOutputter(NULL), + m_autoElevated(false), + m_ready(false), + m_foreground(foreground) { m_mutex = ARCH->newMutex(); m_condVar = ARCH->newCondVar(); } @@ -121,8 +129,8 @@ void MSWindowsWatchdog::stop() { } HANDLE -MSWindowsWatchdog::duplicateProcessToken(HANDLE process, - LPSECURITY_ATTRIBUTES security) { +MSWindowsWatchdog::duplicateProcessToken( + HANDLE process, LPSECURITY_ATTRIBUTES security) { HANDLE sourceToken; BOOL tokenRet = OpenProcessToken( @@ -158,7 +166,8 @@ MSWindowsWatchdog::getUserToken(LPSECURITY_ATTRIBUTES security) { if (m_elevateProcess || m_autoElevated || m_session.isProcessInSession("logonui.exe", NULL)) { - LOG((CLOG_DEBUG "getting elevated token, %s", + LOG( + (CLOG_DEBUG "getting elevated token, %s", (m_elevateProcess ? "elevation required" : "at login screen"))); HANDLE process; @@ -209,7 +218,8 @@ void MSWindowsWatchdog::mainLoop(void *) { // increasing backoff period, maximum of 10 seconds. int timeout = (m_processFailures * 2) < 10 ? (m_processFailures * 2) : 10; - LOG((CLOG_INFO "backing off, wait=%ds, failures=%d", timeout, + LOG( + (CLOG_INFO "backing off, wait=%ds, failures=%d", timeout, m_processFailures)); ARCH->sleep(timeout); } @@ -235,7 +245,8 @@ void MSWindowsWatchdog::mainLoop(void *) { m_processFailures++; m_processRunning = false; - LOG((CLOG_WARN "detected application not running, pid=%d", + LOG( + (CLOG_WARN "detected application not running, pid=%d", m_processInfo.dwProcessId)); } @@ -352,7 +363,8 @@ void MSWindowsWatchdog::startProcess() { m_processFailures = 0; LOG((CLOG_DEBUG "started core process from daemon")); - LOG((CLOG_DEBUG2 "process info, session=%i, elevated: %s, command=%s", + LOG( + (CLOG_DEBUG2 "process info, session=%i, elevated: %s, command=%s", m_session.getActiveSessionId(), m_elevateProcess ? "yes" : "no", m_command.c_str())); } @@ -379,16 +391,17 @@ BOOL MSWindowsWatchdog::startProcessInForeground(String &command) { si.dwFlags |= STARTF_USESHOWWINDOW; si.wShowWindow = SW_MINIMIZE; - BOOL result = CreateProcess(NULL, LPSTR(command.c_str()), NULL, NULL, TRUE, 0, - NULL, NULL, &si, &m_processInfo); + BOOL result = CreateProcess( + NULL, LPSTR(command.c_str()), NULL, NULL, TRUE, 0, NULL, NULL, &si, + &m_processInfo); m_children.insert(std::make_pair(m_processInfo.dwProcessId, m_processInfo)); return result; } -BOOL MSWindowsWatchdog::startProcessAsUser(String &command, HANDLE userToken, - LPSECURITY_ATTRIBUTES sa) { +BOOL MSWindowsWatchdog::startProcessAsUser( + String &command, HANDLE userToken, LPSECURITY_ATTRIBUTES sa) { // clear, as we're reusing process info struct ZeroMemory(&m_processInfo, sizeof(PROCESS_INFORMATION)); @@ -407,9 +420,9 @@ BOOL MSWindowsWatchdog::startProcessAsUser(String &command, HANDLE userToken, // re-launch in current active user session LOG((CLOG_INFO "starting new process")); - BOOL createRet = CreateProcessAsUser(userToken, NULL, LPSTR(command.c_str()), - sa, NULL, TRUE, creationFlags, - environment, NULL, &si, &m_processInfo); + BOOL createRet = CreateProcessAsUser( + userToken, NULL, LPSTR(command.c_str()), sa, NULL, TRUE, creationFlags, + environment, NULL, &si, &m_processInfo); m_children.insert(std::make_pair(m_processInfo.dwProcessId, m_processInfo)); @@ -516,7 +529,8 @@ void MSWindowsWatchdog::shutdownProcess(HANDLE handle, DWORD pid, int timeout) { // calling TerminateProcess on synergy is very bad! // it causes the hook DLL to stay loaded in some apps, // making it impossible to start synergy again. - LOG((CLOG_WARN + LOG( + (CLOG_WARN "shutdown timed out after %d secs, forcefully terminating", (int)elapsed)); TerminateProcess(handle, kExitSuccess); @@ -646,8 +660,8 @@ void MSWindowsWatchdog::testOutput(String buffer) { } } -void MSWindowsWatchdog::closeProcessHandles(unsigned long pid, - bool removeFromMap) { +void MSWindowsWatchdog::closeProcessHandles( + unsigned long pid, bool removeFromMap) { auto processInfo = m_children.find(pid); if (processInfo != m_children.end()) { CloseHandle(processInfo->second.hProcess); diff --git a/src/lib/platform/MSWindowsWatchdog.h b/src/lib/platform/MSWindowsWatchdog.h index 5be658b99..4e4bfa60e 100644 --- a/src/lib/platform/MSWindowsWatchdog.h +++ b/src/lib/platform/MSWindowsWatchdog.h @@ -35,8 +35,9 @@ class FileLogOutputter; class MSWindowsWatchdog { public: - MSWindowsWatchdog(bool autoDetectCommand, IpcServer &ipcServer, - IpcLogOutputter &ipcLogOutputter, bool foreground); + MSWindowsWatchdog( + bool autoDetectCommand, IpcServer &ipcServer, + IpcLogOutputter &ipcLogOutputter, bool foreground); virtual ~MSWindowsWatchdog(); void startAsync(); @@ -54,8 +55,8 @@ private: HANDLE duplicateProcessToken(HANDLE process, LPSECURITY_ATTRIBUTES security); HANDLE getUserToken(LPSECURITY_ATTRIBUTES security); void startProcess(); - BOOL startProcessAsUser(String &command, HANDLE userToken, - LPSECURITY_ATTRIBUTES sa); + BOOL startProcessAsUser( + String &command, HANDLE userToken, LPSECURITY_ATTRIBUTES sa); BOOL startProcessInForeground(String &command); void sendSas(); void getActiveDesktop(LPSECURITY_ATTRIBUTES security); diff --git a/src/lib/platform/OSXClipboard.cpp b/src/lib/platform/OSXClipboard.cpp index dbdb9f07b..5802ef609 100644 --- a/src/lib/platform/OSXClipboard.cpp +++ b/src/lib/platform/OSXClipboard.cpp @@ -40,9 +40,11 @@ OSXClipboard::OSXClipboard() : m_time(0), m_pboard(NULL) { OSStatus createErr = PasteboardCreate(kPasteboardClipboard, &m_pboard); if (createErr != noErr) { - LOG((CLOG_DEBUG "failed to create clipboard reference: error %i", + LOG( + (CLOG_DEBUG "failed to create clipboard reference: error %i", createErr)); - LOG((CLOG_ERR "unable to connect to pasteboard, clipboard sharing disabled", + LOG( + (CLOG_ERR "unable to connect to pasteboard, clipboard sharing disabled", createErr)); m_pboard = NULL; return; @@ -105,16 +107,17 @@ void OSXClipboard::add(EFormat format, const String &data) { if (converter->getFormat() == format) { String osXData = converter->fromIClipboard(data); CFStringRef flavorType = converter->getOSXFormat(); - CFDataRef dataRef = CFDataCreate(kCFAllocatorDefault, - (UInt8 *)osXData.data(), osXData.size()); + CFDataRef dataRef = CFDataCreate( + kCFAllocatorDefault, (UInt8 *)osXData.data(), osXData.size()); PasteboardItemID itemID = 0; if (dataRef) { - PasteboardPutItemFlavor(m_pboard, itemID, flavorType, dataRef, - kPasteboardFlavorNoFlags); + PasteboardPutItemFlavor( + m_pboard, itemID, flavorType, dataRef, kPasteboardFlavorNoFlags); CFRelease(dataRef); - LOG((CLOG_DEBUG "added %d bytes to clipboard format: %d", data.size(), + LOG( + (CLOG_DEBUG "added %d bytes to clipboard format: %d", data.size(), format)); } } @@ -206,8 +209,8 @@ String OSXClipboard::get(EFormat format) const { result = String((char *)CFDataGetBytePtr(buffer), CFDataGetLength(buffer)); } catch (OSStatus err) { - LOG((CLOG_DEBUG "exception thrown in OSXClipboard::get MacError (%d)", - err)); + LOG(( + CLOG_DEBUG "exception thrown in OSXClipboard::get MacError (%d)", err)); } catch (...) { LOG((CLOG_DEBUG "unknown exception in OSXClipboard::get")); RETHROW_XTHREAD diff --git a/src/lib/platform/OSXClipboardBMPConverter.h b/src/lib/platform/OSXClipboardBMPConverter.h index 249cec868..e559a401a 100644 --- a/src/lib/platform/OSXClipboardBMPConverter.h +++ b/src/lib/platform/OSXClipboardBMPConverter.h @@ -36,6 +36,7 @@ public: virtual String toIClipboard(const String &) const; // generic encoding converter - static String convertString(const String &data, CFStringEncoding fromEncoding, - CFStringEncoding toEncoding); + static String convertString( + const String &data, CFStringEncoding fromEncoding, + CFStringEncoding toEncoding); }; diff --git a/src/lib/platform/OSXClipboardHTMLConverter.cpp b/src/lib/platform/OSXClipboardHTMLConverter.cpp index 972354aff..8b07f7720 100644 --- a/src/lib/platform/OSXClipboardHTMLConverter.cpp +++ b/src/lib/platform/OSXClipboardHTMLConverter.cpp @@ -36,11 +36,11 @@ CFStringRef OSXClipboardHTMLConverter::getOSXFormat() const { return CFSTR("public.html"); } -String OSXClipboardHTMLConverter::convertString(const String &data, - CFStringEncoding fromEncoding, - CFStringEncoding toEncoding) { - CFStringRef stringRef = CFStringCreateWithCString(kCFAllocatorDefault, - data.c_str(), fromEncoding); +String OSXClipboardHTMLConverter::convertString( + const String &data, CFStringEncoding fromEncoding, + CFStringEncoding toEncoding) { + CFStringRef stringRef = CFStringCreateWithCString( + kCFAllocatorDefault, data.c_str(), fromEncoding); if (stringRef == NULL) { return String(); @@ -49,8 +49,8 @@ String OSXClipboardHTMLConverter::convertString(const String &data, CFIndex buffSize; CFRange entireString = CFRangeMake(0, CFStringGetLength(stringRef)); - CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, NULL, 0, - &buffSize); + CFStringGetBytes( + stringRef, entireString, toEncoding, 0, false, NULL, 0, &buffSize); char *buffer = new char[buffSize]; @@ -59,8 +59,9 @@ String OSXClipboardHTMLConverter::convertString(const String &data, return String(); } - CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, - (UInt8 *)buffer, buffSize, NULL); + CFStringGetBytes( + stringRef, entireString, toEncoding, 0, false, (UInt8 *)buffer, buffSize, + NULL); String result(buffer, buffSize); @@ -78,7 +79,7 @@ String OSXClipboardHTMLConverter::doToIClipboard(const String &data) const { if (Unicode::isUTF8(data)) { return data; } else { - return convertString(data, CFStringGetSystemEncoding(), - kCFStringEncodingUTF8); + return convertString( + data, CFStringGetSystemEncoding(), kCFStringEncodingUTF8); } } diff --git a/src/lib/platform/OSXClipboardHTMLConverter.h b/src/lib/platform/OSXClipboardHTMLConverter.h index d3df617f1..fed24defb 100644 --- a/src/lib/platform/OSXClipboardHTMLConverter.h +++ b/src/lib/platform/OSXClipboardHTMLConverter.h @@ -37,6 +37,7 @@ protected: virtual String doToIClipboard(const String &) const; // generic encoding converter - static String convertString(const String &data, CFStringEncoding fromEncoding, - CFStringEncoding toEncoding); + static String convertString( + const String &data, CFStringEncoding fromEncoding, + CFStringEncoding toEncoding); }; diff --git a/src/lib/platform/OSXClipboardTextConverter.cpp b/src/lib/platform/OSXClipboardTextConverter.cpp index 4b3bd804e..f3d1e5518 100644 --- a/src/lib/platform/OSXClipboardTextConverter.cpp +++ b/src/lib/platform/OSXClipboardTextConverter.cpp @@ -36,11 +36,11 @@ CFStringRef OSXClipboardTextConverter::getOSXFormat() const { return CFSTR("public.plain-text"); } -String OSXClipboardTextConverter::convertString(const String &data, - CFStringEncoding fromEncoding, - CFStringEncoding toEncoding) { - CFStringRef stringRef = CFStringCreateWithCString(kCFAllocatorDefault, - data.c_str(), fromEncoding); +String OSXClipboardTextConverter::convertString( + const String &data, CFStringEncoding fromEncoding, + CFStringEncoding toEncoding) { + CFStringRef stringRef = CFStringCreateWithCString( + kCFAllocatorDefault, data.c_str(), fromEncoding); if (stringRef == NULL) { return String(); @@ -49,8 +49,8 @@ String OSXClipboardTextConverter::convertString(const String &data, CFIndex buffSize; CFRange entireString = CFRangeMake(0, CFStringGetLength(stringRef)); - CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, NULL, 0, - &buffSize); + CFStringGetBytes( + stringRef, entireString, toEncoding, 0, false, NULL, 0, &buffSize); char *buffer = new char[buffSize]; @@ -59,8 +59,9 @@ String OSXClipboardTextConverter::convertString(const String &data, return String(); } - CFStringGetBytes(stringRef, entireString, toEncoding, 0, false, - (UInt8 *)buffer, buffSize, NULL); + CFStringGetBytes( + stringRef, entireString, toEncoding, 0, false, (UInt8 *)buffer, buffSize, + NULL); String result(buffer, buffSize); @@ -71,11 +72,11 @@ String OSXClipboardTextConverter::convertString(const String &data, } String OSXClipboardTextConverter::doFromIClipboard(const String &data) const { - return convertString(data, kCFStringEncodingUTF8, - CFStringGetSystemEncoding()); + return convertString( + data, kCFStringEncodingUTF8, CFStringGetSystemEncoding()); } String OSXClipboardTextConverter::doToIClipboard(const String &data) const { - return convertString(data, CFStringGetSystemEncoding(), - kCFStringEncodingUTF8); + return convertString( + data, CFStringGetSystemEncoding(), kCFStringEncodingUTF8); } diff --git a/src/lib/platform/OSXClipboardTextConverter.h b/src/lib/platform/OSXClipboardTextConverter.h index d4adc6560..2227e9e69 100644 --- a/src/lib/platform/OSXClipboardTextConverter.h +++ b/src/lib/platform/OSXClipboardTextConverter.h @@ -35,6 +35,7 @@ protected: virtual String doToIClipboard(const String &) const; // generic encoding converter - static String convertString(const String &data, CFStringEncoding fromEncoding, - CFStringEncoding toEncoding); + static String convertString( + const String &data, CFStringEncoding fromEncoding, + CFStringEncoding toEncoding); }; diff --git a/src/lib/platform/OSXEventQueueBuffer.cpp b/src/lib/platform/OSXEventQueueBuffer.cpp index 3452c4371..33501030d 100644 --- a/src/lib/platform/OSXEventQueueBuffer.cpp +++ b/src/lib/platform/OSXEventQueueBuffer.cpp @@ -32,7 +32,9 @@ class EventQueueTimer {}; // OSXEventQueueBuffer::OSXEventQueueBuffer(IEventQueue *events) - : m_event(NULL), m_eventQueue(events), m_carbonEventQueue(NULL) { + : m_event(NULL), + m_eventQueue(events), + m_carbonEventQueue(NULL) { // do nothing } @@ -52,8 +54,8 @@ void OSXEventQueueBuffer::waitForEvent(double timeout) { ReceiveNextEvent(0, NULL, timeout, false, &event); } -IEventQueueBuffer::Type OSXEventQueueBuffer::getEvent(Event &event, - UInt32 &dataID) { +IEventQueueBuffer::Type +OSXEventQueueBuffer::getEvent(Event &event, UInt32 &dataID) { // release the previous event if (m_event != NULL) { ReleaseEvent(m_event); @@ -85,8 +87,8 @@ IEventQueueBuffer::Type OSXEventQueueBuffer::getEvent(Event &event, bool OSXEventQueueBuffer::addEvent(UInt32 dataID) { EventRef event; - OSStatus error = CreateEvent(kCFAllocatorDefault, 'Syne', dataID, 0, - kEventAttributeNone, &event); + OSStatus error = CreateEvent( + kCFAllocatorDefault, 'Syne', dataID, 0, kEventAttributeNone, &event); if (error == noErr) { diff --git a/src/lib/platform/OSXKeyState.cpp b/src/lib/platform/OSXKeyState.cpp index d20c5f6da..31d2b063d 100644 --- a/src/lib/platform/OSXKeyState.cpp +++ b/src/lib/platform/OSXKeyState.cpp @@ -138,8 +138,8 @@ io_connect_t getService(io_iterator_t iter) { auto nextIterator = IOIteratorNext(iter); if (nextIterator) { - IOServiceOpen(nextIterator, mach_task_self(), kIOHIDParamConnectType, - &service); + IOServiceOpen( + nextIterator, mach_task_self(), kIOHIDParamConnectType, &service); IOObjectRelease(nextIterator); } @@ -172,8 +172,8 @@ io_connect_t getEventDriver() { } bool isModifier(UInt8 virtualKey) { - static std::set modifiers{s_shiftVK, s_superVK, s_altVK, s_controlVK, - s_capsLockVK}; + static std::set modifiers{ + s_shiftVK, s_superVK, s_altVK, s_controlVK, s_capsLockVK}; return (modifiers.find(virtualKey) != modifiers.end()); } @@ -184,14 +184,15 @@ bool isModifier(UInt8 virtualKey) { // OSXKeyState // -OSXKeyState::OSXKeyState(IEventQueue *events, std::vector layouts, - bool isLangSyncEnabled) +OSXKeyState::OSXKeyState( + IEventQueue *events, std::vector layouts, bool isLangSyncEnabled) : KeyState(events, std::move(layouts), isLangSyncEnabled) { init(); } -OSXKeyState::OSXKeyState(IEventQueue *events, synergy::KeyMap &keyMap, - std::vector layouts, bool isLangSyncEnabled) +OSXKeyState::OSXKeyState( + IEventQueue *events, synergy::KeyMap &keyMap, std::vector layouts, + bool isLangSyncEnabled) : KeyState(events, keyMap, std::move(layouts), isLangSyncEnabled) { init(); } @@ -263,8 +264,8 @@ KeyModifierMask OSXKeyState::mapModifiersToCarbon(UInt32 mask) const { return outMask; } -KeyButton OSXKeyState::mapKeyFromEvent(KeyIDs &ids, KeyModifierMask *maskOut, - CGEventRef event) const { +KeyButton OSXKeyState::mapKeyFromEvent( + KeyIDs &ids, KeyModifierMask *maskOut, CGEventRef event) const { ids.clear(); // map modifier key @@ -323,8 +324,8 @@ KeyButton OSXKeyState::mapKeyFromEvent(KeyIDs &ids, KeyModifierMask *maskOut, UInt16 action; if (eventKind == kCGEventKeyDown) { action = kUCKeyActionDown; - } else if (CGEventGetIntegerValueField(event, kCGKeyboardEventAutorepeat) == - 1) { + } else if ( + CGEventGetIntegerValueField(event, kCGKeyboardEventAutorepeat) == 1) { action = kUCKeyActionAutoKey; } else { return 0; @@ -342,10 +343,10 @@ KeyButton OSXKeyState::mapKeyFromEvent(KeyIDs &ids, KeyModifierMask *maskOut, UniCharCount count; UniChar chars[2]; LOG((CLOG_DEBUG2 "modifiers: %08x", modifiers & 0xffu)); - OSStatus status = - UCKeyTranslate(layout, vkCode & 0xffu, action, (modifiers >> 8) & 0xffu, - LMGetKbdType(), 0, &m_deadKeyState, - sizeof(chars) / sizeof(chars[0]), &count, chars); + OSStatus status = UCKeyTranslate( + layout, vkCode & 0xffu, action, (modifiers >> 8) & 0xffu, + LMGetKbdType(), 0, &m_deadKeyState, sizeof(chars) / sizeof(chars[0]), + &count, chars); // get the characters if (status == 0) { @@ -568,14 +569,14 @@ kern_return_t OSXKeyState::postHIDVirtualKey(UInt8 virtualKey, bool postDown) { if (driver) { if (isModifier(virtualKey)) { - result = - IOHIDPostEvent(driver, NX_FLAGSCHANGED, {0, 0}, &event, - kNXEventDataVersion, getKeyboardEventFlags(), true); + result = IOHIDPostEvent( + driver, NX_FLAGSCHANGED, {0, 0}, &event, kNXEventDataVersion, + getKeyboardEventFlags(), true); } else { event.key.keyCode = virtualKey; const auto eventType = postDown ? NX_KEYDOWN : NX_KEYUP; - result = IOHIDPostEvent(driver, eventType, {0, 0}, &event, - kNXEventDataVersion, 0, false); + result = IOHIDPostEvent( + driver, eventType, {0, 0}, &event, kNXEventDataVersion, 0, false); } } @@ -601,7 +602,8 @@ void OSXKeyState::fakeKey(const Keystroke &keystroke) { KeyButton button = keystroke.m_data.m_button.m_button; CGKeyCode virtualKey = mapKeyButtonToVirtualKey(button); - LOG((CLOG_DEBUG1 + LOG( + (CLOG_DEBUG1 " button=0x%04x virtualKey=0x%04x keyDown=%s client=0x%04x", button, virtualKey, keyDown ? "down" : "up", client)); @@ -634,8 +636,8 @@ void OSXKeyState::fakeKey(const Keystroke &keystroke) { } } -void OSXKeyState::getKeyMapForSpecialKeys(synergy::KeyMap &keyMap, - SInt32 group) const { +void OSXKeyState::getKeyMapForSpecialKeys( + synergy::KeyMap &keyMap, SInt32 group) const { // special keys are insensitive to modifers and none are dead keys synergy::KeyMap::KeyItem item; for (size_t i = 0; i < sizeof(s_controlKeys) / sizeof(s_controlKeys[0]); @@ -664,8 +666,8 @@ void OSXKeyState::getKeyMapForSpecialKeys(synergy::KeyMap &keyMap, // anyway. } -bool OSXKeyState::getKeyMap(synergy::KeyMap &keyMap, SInt32 group, - const IOSXKeyResource &r) const { +bool OSXKeyState::getKeyMap( + synergy::KeyMap &keyMap, SInt32 group, const IOSXKeyResource &r) const { if (!r.isValid()) { return false; } @@ -778,9 +780,9 @@ bool OSXKeyState::getKeyMap(synergy::KeyMap &keyMap, SInt32 group, return true; } -bool OSXKeyState::mapSynergyHotKeyToMac(KeyID key, KeyModifierMask mask, - UInt32 &macVirtualKey, - UInt32 &macModifierMask) const { +bool OSXKeyState::mapSynergyHotKeyToMac( + KeyID key, KeyModifierMask mask, UInt32 &macVirtualKey, + UInt32 &macModifierMask) const { // look up button for key KeyButton button = getButton(key, pollActiveGroup()); if (button == 0 && key != kKeyNone) { @@ -812,40 +814,46 @@ bool OSXKeyState::mapSynergyHotKeyToMac(KeyID key, KeyModifierMask mask, return true; } -void OSXKeyState::handleModifierKeys(void *target, KeyModifierMask oldMask, - KeyModifierMask newMask) { +void OSXKeyState::handleModifierKeys( + void *target, KeyModifierMask oldMask, KeyModifierMask newMask) { // compute changed modifiers KeyModifierMask changed = (oldMask ^ newMask); // synthesize changed modifier keys if ((changed & KeyModifierShift) != 0) { - handleModifierKey(target, s_shiftVK, kKeyShift_L, - (newMask & KeyModifierShift) != 0, newMask); + handleModifierKey( + target, s_shiftVK, kKeyShift_L, (newMask & KeyModifierShift) != 0, + newMask); } if ((changed & KeyModifierControl) != 0) { - handleModifierKey(target, s_controlVK, kKeyControl_L, - (newMask & KeyModifierControl) != 0, newMask); + handleModifierKey( + target, s_controlVK, kKeyControl_L, (newMask & KeyModifierControl) != 0, + newMask); } if ((changed & KeyModifierAlt) != 0) { - handleModifierKey(target, s_altVK, kKeyAlt_L, - (newMask & KeyModifierAlt) != 0, newMask); + handleModifierKey( + target, s_altVK, kKeyAlt_L, (newMask & KeyModifierAlt) != 0, newMask); } if ((changed & KeyModifierSuper) != 0) { - handleModifierKey(target, s_superVK, kKeySuper_L, - (newMask & KeyModifierSuper) != 0, newMask); + handleModifierKey( + target, s_superVK, kKeySuper_L, (newMask & KeyModifierSuper) != 0, + newMask); } if ((changed & KeyModifierCapsLock) != 0) { - handleModifierKey(target, s_capsLockVK, kKeyCapsLock, - (newMask & KeyModifierCapsLock) != 0, newMask); + handleModifierKey( + target, s_capsLockVK, kKeyCapsLock, + (newMask & KeyModifierCapsLock) != 0, newMask); } if ((changed & KeyModifierNumLock) != 0) { - handleModifierKey(target, s_numLockVK, kKeyNumLock, - (newMask & KeyModifierNumLock) != 0, newMask); + handleModifierKey( + target, s_numLockVK, kKeyNumLock, (newMask & KeyModifierNumLock) != 0, + newMask); } } -void OSXKeyState::handleModifierKey(void *target, UInt32 virtualKey, KeyID id, - bool down, KeyModifierMask newMask) { +void OSXKeyState::handleModifierKey( + void *target, UInt32 virtualKey, KeyID id, bool down, + KeyModifierMask newMask) { KeyButton button = mapVirtualKeyToKeyButton(virtualKey); onKey(button, down, newMask); sendKeyEvent(target, down, false, id, newMask, 0, button); @@ -855,10 +863,10 @@ bool OSXKeyState::getGroups(AutoCFArray &groups) const { // get number of layouts CFStringRef keys[] = {kTISPropertyInputSourceCategory}; CFStringRef values[] = {kTISCategoryKeyboardInputSource}; - AutoCFDictionary dict(CFDictionaryCreate(NULL, (const void **)keys, - (const void **)values, 1, NULL, - NULL), - CFRelease); + AutoCFDictionary dict( + CFDictionaryCreate( + NULL, (const void **)keys, (const void **)values, 1, NULL, NULL), + CFRelease); AutoCFArray kbds(TISCreateInputSourceList(dict.get(), false), CFRelease); if (CFArrayGetCount(kbds.get()) > 0) { @@ -902,8 +910,8 @@ void OSXKeyState::setGroup(SInt32 group) { ARCH->sleep(.01); } -void OSXKeyState::adjustAltGrModifier(const KeyIDs &ids, KeyModifierMask *mask, - bool isCommand) const { +void OSXKeyState::adjustAltGrModifier( + const KeyIDs &ids, KeyModifierMask *mask, bool isCommand) const { if (!isCommand) { for (KeyIDs::const_iterator i = ids.begin(); i != ids.end(); ++i) { KeyID id = *i; diff --git a/src/lib/platform/OSXKeyState.h b/src/lib/platform/OSXKeyState.h index b395a0cc1..4dc0aecd5 100644 --- a/src/lib/platform/OSXKeyState.h +++ b/src/lib/platform/OSXKeyState.h @@ -36,10 +36,11 @@ class OSXKeyState : public KeyState { public: typedef std::vector KeyIDs; - OSXKeyState(IEventQueue *events, std::vector layouts, - bool isLangSyncEnabled); - OSXKeyState(IEventQueue *events, synergy::KeyMap &keyMap, - std::vector layouts, bool isLangSyncEnabled); + OSXKeyState( + IEventQueue *events, std::vector layouts, bool isLangSyncEnabled); + OSXKeyState( + IEventQueue *events, synergy::KeyMap &keyMap, std::vector layouts, + bool isLangSyncEnabled); virtual ~OSXKeyState(); //! @name modifiers @@ -50,8 +51,8 @@ public: 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); + void handleModifierKeys( + void *target, KeyModifierMask oldMask, KeyModifierMask newMask); //@} //! @name accessors @@ -78,17 +79,17 @@ public: 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; + 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 mapSynergyHotKeyToMac(KeyID key, KeyModifierMask mask, - UInt32 &macVirtualKey, - UInt32 &macModifierMask) const; + bool mapSynergyHotKeyToMac( + KeyID key, KeyModifierMask mask, UInt32 &macVirtualKey, + UInt32 &macModifierMask) const; //@} @@ -113,8 +114,8 @@ private: void getKeyMapForSpecialKeys(synergy::KeyMap &keyMap, SInt32 group) const; // Convert keyboard resource to a key map - bool getKeyMap(synergy::KeyMap &keyMap, SInt32 group, - const IOSXKeyResource &r) const; + bool getKeyMap( + synergy::KeyMap &keyMap, SInt32 group, const IOSXKeyResource &r) const; // Get the available keyboard groups bool getGroups(AutoCFArray &) const; @@ -123,8 +124,9 @@ private: void setGroup(SInt32 group); // Send an event for the given modifier key - void handleModifierKey(void *target, UInt32 virtualKey, KeyID id, bool down, - KeyModifierMask newMask); + 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 @@ -132,8 +134,8 @@ private: // 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; + 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. diff --git a/src/lib/platform/OSXMediaKeySupport.h b/src/lib/platform/OSXMediaKeySupport.h index 8971cbbc8..808ee991a 100644 --- a/src/lib/platform/OSXMediaKeySupport.h +++ b/src/lib/platform/OSXMediaKeySupport.h @@ -27,8 +27,8 @@ extern "C" { #endif bool fakeNativeMediaKey(KeyID id); bool isMediaKeyEvent(CGEventRef event); -bool getMediaKeyEventInfo(CGEventRef event, KeyID *keyId, bool *down, - bool *isRepeat); +bool getMediaKeyEventInfo( + CGEventRef event, KeyID *keyId, bool *down, bool *isRepeat); #if defined(__cplusplus) } #endif diff --git a/src/lib/platform/OSXScreen.h b/src/lib/platform/OSXScreen.h index c7a1a7d95..adde71eff 100644 --- a/src/lib/platform/OSXScreen.h +++ b/src/lib/platform/OSXScreen.h @@ -36,8 +36,9 @@ extern "C" { typedef int CGSConnectionID; -CGError CGSSetConnectionProperty(CGSConnectionID cid, CGSConnectionID targetCID, - CFStringRef key, CFTypeRef value); +CGError CGSSetConnectionProperty( + CGSConnectionID cid, CGSConnectionID targetCID, CFStringRef key, + CFTypeRef value); int _CGSDefaultConnection(); } @@ -53,9 +54,10 @@ class Mutex; //! Implementation of IPlatformScreen for OS X class OSXScreen : public PlatformScreen { public: - OSXScreen(IEventQueue *events, bool isPrimary, bool enableLangSync = false, - lib::synergy::ClientScrollDirection scrollDirection = - lib::synergy::ClientScrollDirection::SERVER); + OSXScreen( + IEventQueue *events, bool isPrimary, bool enableLangSync = false, + lib::synergy::ClientScrollDirection scrollDirection = + lib::synergy::ClientScrollDirection::SERVER); virtual ~OSXScreen(); @@ -64,8 +66,8 @@ public: // 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 + getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const override; void getCursorPos(SInt32 &x, SInt32 &y) const override; // IPrimaryScreen overrides @@ -114,8 +116,8 @@ protected: private: bool updateScreenShape(); - bool updateScreenShape(const CGDirectDisplayID, - const CGDisplayChangeSummaryFlags); + bool + updateScreenShape(const CGDirectDisplayID, const CGDisplayChangeSummaryFlags); void postMouseEvent(CGPoint &) const; // convenience function to send events @@ -167,20 +169,19 @@ private: void handleClipboardCheck(const Event &, void *); // Resolution switch callback - static void displayReconfigurationCallback(CGDirectDisplayID, - CGDisplayChangeSummaryFlags, - void *); + static void displayReconfigurationCallback( + CGDirectDisplayID, CGDisplayChangeSummaryFlags, void *); // fast user switch callback - static pascal OSStatus userSwitchCallback(EventHandlerCallRef nextHandler, - EventRef theEvent, - void *inUserData); + 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); + 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 *); @@ -191,11 +192,10 @@ private: 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); + 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); diff --git a/src/lib/platform/OSXScreenSaver.cpp b/src/lib/platform/OSXScreenSaver.cpp index ec43589f3..3377c4845 100644 --- a/src/lib/platform/OSXScreenSaver.cpp +++ b/src/lib/platform/OSXScreenSaver.cpp @@ -35,7 +35,9 @@ bool isScreenSaverEngine(const ProcessSerialNumber &psn); // OSXScreenSaver::OSXScreenSaver(IEventQueue *events, void *eventTarget) - : m_eventTarget(eventTarget), m_enabled(true), m_events(events) { + : m_eventTarget(eventTarget), + m_enabled(true), + m_events(events) { m_autoReleasePool = screenSaverUtilCreatePool(); m_screenSaverController = screenSaverUtilCreateController(); @@ -48,9 +50,9 @@ OSXScreenSaver::OSXScreenSaver(IEventQueue *events, void *eventTarget) EventHandlerUPP launchTerminationEventHandler = NewEventHandlerUPP(launchTerminationCallback); - InstallApplicationEventHandler(launchTerminationEventHandler, 2, - launchEventTypes, this, - &m_launchTerminationEventHandlerRef); + InstallApplicationEventHandler( + launchTerminationEventHandler, 2, launchEventTypes, this, + &m_launchTerminationEventHandlerRef); DisposeEventHandlerUPP(launchTerminationEventHandler); m_screenSaverPSN.highLongOfPSN = 0; @@ -105,9 +107,9 @@ void OSXScreenSaver::processTerminated(ProcessSerialNumber psn) { m_screenSaverPSN.lowLongOfPSN == psn.lowLongOfPSN) { LOG((CLOG_DEBUG1 "screen saver engine terminated, enabled=%d", m_enabled)); if (m_enabled) { - m_events->addEvent( - Event(m_events->forIPrimaryScreen().screensaverDeactivated(), - m_eventTarget)); + m_events->addEvent(Event( + m_events->forIPrimaryScreen().screensaverDeactivated(), + m_eventTarget)); } m_screenSaverPSN.highLongOfPSN = 0; @@ -122,9 +124,9 @@ pascal OSStatus OSXScreenSaver::launchTerminationCallback( EventParamType actualType; ByteCount actualSize; - result = - GetEventParameter(theEvent, kEventParamProcessID, typeProcessSerialNumber, - &actualType, sizeof(psn), &actualSize, &psn); + result = GetEventParameter( + theEvent, kEventParamProcessID, typeProcessSerialNumber, &actualType, + sizeof(psn), &actualSize, &psn); if ((result == noErr) && (actualSize > 0) && (actualType == typeProcessSerialNumber)) { diff --git a/src/lib/platform/OSXUchrKeyResource.cpp b/src/lib/platform/OSXUchrKeyResource.cpp index baf0350ba..5f8ad7497 100644 --- a/src/lib/platform/OSXUchrKeyResource.cpp +++ b/src/lib/platform/OSXUchrKeyResource.cpp @@ -23,9 +23,13 @@ // OSXUchrKeyResource // -OSXUchrKeyResource::OSXUchrKeyResource(const void *resource, - UInt32 keyboardType) - : m_m(NULL), m_cti(NULL), m_sdi(NULL), m_sri(NULL), m_st(NULL) { +OSXUchrKeyResource::OSXUchrKeyResource( + const void *resource, UInt32 keyboardType) + : m_m(NULL), + m_cti(NULL), + m_sdi(NULL), + m_sri(NULL), + m_st(NULL) { m_resource = static_cast(resource); if (m_resource == NULL) { return; @@ -182,8 +186,8 @@ bool OSXUchrKeyResource::getDeadKey(KeySequence &keys, UInt16 index) const { return true; } -bool OSXUchrKeyResource::getKeyRecord(KeySequence &keys, UInt16 index, - UInt16 &state) const { +bool OSXUchrKeyResource::getKeyRecord( + KeySequence &keys, UInt16 index, UInt16 &state) const { const UInt8 *const base = reinterpret_cast(m_resource); const UCKeyStateRecord *sr = reinterpret_cast( base + m_sri->keyStateRecordOffsets[index]); diff --git a/src/lib/platform/XWindowsClipboard.cpp b/src/lib/platform/XWindowsClipboard.cpp index e085cff5b..7c72d2c30 100644 --- a/src/lib/platform/XWindowsClipboard.cpp +++ b/src/lib/platform/XWindowsClipboard.cpp @@ -39,10 +39,16 @@ // XWindowsClipboard // -XWindowsClipboard::XWindowsClipboard(Display *display, Window window, - ClipboardID id) - : m_display(display), m_window(window), m_id(id), m_open(false), m_time(0), - m_owner(false), m_timeOwned(0), m_timeLost(0) { +XWindowsClipboard::XWindowsClipboard( + Display *display, Window window, ClipboardID id) + : m_display(display), + m_window(window), + m_id(id), + m_open(false), + m_time(0), + m_owner(false), + m_timeOwned(0), + m_timeLost(0) { // get some atoms m_atomTargets = XInternAtom(m_display, "TARGETS", False); m_atomMultiple = XInternAtom(m_display, "MULTIPLE", False); @@ -108,13 +114,14 @@ void XWindowsClipboard::lost(Time time) { } } -void XWindowsClipboard::addRequest(Window owner, Window requestor, Atom target, - ::Time time, Atom property) { +void XWindowsClipboard::addRequest( + Window owner, Window requestor, Atom target, ::Time time, Atom property) { // must be for our window and we must have owned the selection // at the given time. bool success = false; if (owner == m_window) { - LOG((CLOG_DEBUG1 + LOG( + (CLOG_DEBUG1 "request for clipboard %d, target %s by 0x%08x (property=%s)", m_selection, XWindowsUtil::atomToString(m_display, target).c_str(), requestor, XWindowsUtil::atomToString(m_display, property).c_str())); @@ -144,8 +151,8 @@ void XWindowsClipboard::addRequest(Window owner, Window requestor, Atom target, pushReplies(); } -bool XWindowsClipboard::addSimpleRequest(Window requestor, Atom target, - ::Time time, Atom property) { +bool XWindowsClipboard::addSimpleRequest( + Window requestor, Atom target, ::Time time, Atom property) { // obsolete requestors may supply a None property. in // that case we use the target as the property to store // the conversion. @@ -192,14 +199,15 @@ bool XWindowsClipboard::addSimpleRequest(Window requestor, Atom target, } } -bool XWindowsClipboard::processRequest(Window requestor, ::Time /*time*/, - Atom property) { +bool XWindowsClipboard::processRequest( + Window requestor, ::Time /*time*/, Atom property) { ReplyMap::iterator index = m_replies.find(requestor); if (index == m_replies.end()) { // unknown requestor window return false; } - LOG((CLOG_DEBUG1 "received property %s delete from 0x08%x", + LOG( + (CLOG_DEBUG1 "received property %s delete from 0x08%x", XWindowsUtil::atomToString(m_display, property).c_str(), requestor)); // find the property in the known requests. it should be the @@ -275,7 +283,8 @@ void XWindowsClipboard::add(EFormat format, const String &data) { assert(m_open); assert(m_owner); - LOG((CLOG_DEBUG "add %d bytes to clipboard %d format: %d", data.size(), m_id, + LOG( + (CLOG_DEBUG "add %d bytes to clipboard %d format: %d", data.size(), m_id, format)); m_data[format] = data; @@ -372,7 +381,8 @@ XWindowsClipboard::getConverter(Atom target, bool onlyIfNotAdded) const { } } if (converter == nullptr) { - LOG((CLOG_DEBUG1 " no converter for target %s", + LOG( + (CLOG_DEBUG1 " no converter for target %s", XWindowsUtil::atomToString(m_display, target).c_str())); return nullptr; } @@ -464,7 +474,8 @@ void XWindowsClipboard::icccmFillCache() { auto targets = static_cast(static_cast(data.data())); const UInt32 numTargets = data.size() / sizeof(Atom); - LOG((CLOG_DEBUG " available targets: %s", + LOG( + (CLOG_DEBUG " available targets: %s", XWindowsUtil::atomsToString(m_display, targets, numTargets).c_str())); // try each converter in order (because they're in order of @@ -500,7 +511,8 @@ void XWindowsClipboard::icccmFillCache() { Atom actualTarget; String targetData; if (!icccmGetSelection(target, &actualTarget, &targetData)) { - LOG((CLOG_DEBUG1 " no data for target %s", + LOG( + (CLOG_DEBUG1 " no data for target %s", XWindowsUtil::atomToString(m_display, target).c_str())); continue; } @@ -509,27 +521,30 @@ void XWindowsClipboard::icccmFillCache() { IClipboard::EFormat format = converter->getFormat(); m_data[format] = converter->toIClipboard(targetData); m_added[format] = true; - LOG((CLOG_DEBUG "added format %d for target %s (%u %s)", format, + LOG( + (CLOG_DEBUG "added format %d for target %s (%u %s)", format, XWindowsUtil::atomToString(m_display, target).c_str(), targetData.size(), targetData.size() == 1 ? "byte" : "bytes")); } } -bool XWindowsClipboard::icccmGetSelection(Atom target, Atom *actualTarget, - String *data) const { +bool XWindowsClipboard::icccmGetSelection( + Atom target, Atom *actualTarget, String *data) const { assert(actualTarget != nullptr); assert(data != nullptr); // request data conversion CICCCMGetClipboard getter(m_window, m_time, m_atomData); - if (!getter.readClipboard(m_display, m_selection, target, actualTarget, - data)) { - LOG((CLOG_DEBUG1 "can't get data for selection target %s", + if (!getter.readClipboard( + m_display, m_selection, target, actualTarget, data)) { + LOG( + (CLOG_DEBUG1 "can't get data for selection target %s", XWindowsUtil::atomToString(m_display, target).c_str())); LOGC(getter.m_error, (CLOG_WARN "icccm violation by clipboard owner")); return false; } else if (*actualTarget == None) { - LOG((CLOG_DEBUG1 "selection conversion failed for target %s", + LOG( + (CLOG_DEBUG1 "selection conversion failed for target %s", XWindowsUtil::atomToString(m_display, target).c_str())); return false; } @@ -605,8 +620,9 @@ bool XWindowsClipboard::motifOwnsClipboard() const { SInt32 format; String data; Window root = RootWindow(m_display, DefaultScreen(m_display)); - if (!XWindowsUtil::getWindowProperty(m_display, root, m_atomMotifClipHeader, - &data, &target, &format, False)) { + if (!XWindowsUtil::getWindowProperty( + m_display, root, m_atomMotifClipHeader, &data, &target, &format, + False)) { return false; } @@ -631,8 +647,9 @@ void XWindowsClipboard::motifFillCache() { SInt32 format; String data; Window root = RootWindow(m_display, DefaultScreen(m_display)); - if (!XWindowsUtil::getWindowProperty(m_display, root, m_atomMotifClipHeader, - &data, &target, &format, False)) { + if (!XWindowsUtil::getWindowProperty( + m_display, root, m_atomMotifClipHeader, &data, &target, &format, + False)) { return; } @@ -651,8 +668,8 @@ void XWindowsClipboard::motifFillCache() { snprintf(name, buffer_size, "_MOTIF_CLIP_ITEM_%d", header.m_item); Atom atomItem = XInternAtom(m_display, name, False); data = ""; - if (!XWindowsUtil::getWindowProperty(m_display, root, atomItem, &data, - &target, &format, False)) { + if (!XWindowsUtil::getWindowProperty( + m_display, root, atomItem, &data, &target, &format, False)) { return; } @@ -679,8 +696,8 @@ void XWindowsClipboard::motifFillCache() { snprintf(name, buffer_size, "_MOTIF_CLIP_ITEM_%d", formats[i]); Atom atomFormat = XInternAtom(m_display, name, False); String data; - if (!XWindowsUtil::getWindowProperty(m_display, root, atomFormat, &data, - &target, &format, False)) { + if (!XWindowsUtil::getWindowProperty( + m_display, root, atomFormat, &data, &target, &format, False)) { continue; } @@ -727,7 +744,8 @@ void XWindowsClipboard::motifFillCache() { Atom actualTarget; String targetData; if (!motifGetSelection(&motifFormat, &actualTarget, &targetData)) { - LOG((CLOG_DEBUG1 " no data for target %s", + LOG( + (CLOG_DEBUG1 " no data for target %s", XWindowsUtil::atomToString(m_display, target).c_str())); continue; } @@ -736,14 +754,14 @@ void XWindowsClipboard::motifFillCache() { IClipboard::EFormat format = converter->getFormat(); m_data[format] = converter->toIClipboard(targetData); m_added[format] = true; - LOG((CLOG_DEBUG "added format %d for target %s", format, + LOG( + (CLOG_DEBUG "added format %d for target %s", format, XWindowsUtil::atomToString(m_display, target).c_str())); } } -bool XWindowsClipboard::motifGetSelection(const MotifClipFormat *format, - Atom *actualTarget, - String *data) const { +bool XWindowsClipboard::motifGetSelection( + const MotifClipFormat *format, Atom *actualTarget, String *data) const { // if the current clipboard owner and the owner indicated by the // motif clip header are the same then transfer via a property on // the root window, otherwise transfer as a normal ICCCM client. @@ -761,22 +779,22 @@ bool XWindowsClipboard::motifGetSelection(const MotifClipFormat *format, snprintf(name, buffer_size, "_MOTIF_CLIP_ITEM_%d", format->m_data); Atom target = XInternAtom(m_display, name, False); Window root = RootWindow(m_display, DefaultScreen(m_display)); - return XWindowsUtil::getWindowProperty(m_display, root, target, data, - actualTarget, nullptr, False); + return XWindowsUtil::getWindowProperty( + m_display, root, target, data, actualTarget, nullptr, False); } IClipboard::Time XWindowsClipboard::motifGetTime() const { return icccmGetTime(); } -bool XWindowsClipboard::insertMultipleReply(Window requestor, ::Time time, - Atom property) { +bool XWindowsClipboard::insertMultipleReply( + Window requestor, ::Time time, Atom property) { // get the requested targets Atom target; SInt32 format; String data; - if (!XWindowsUtil::getWindowProperty(m_display, requestor, property, &data, - &target, &format, False)) { + if (!XWindowsUtil::getWindowProperty( + m_display, requestor, property, &data, &target, &format, False)) { // can't get the requested targets return false; } @@ -806,8 +824,9 @@ bool XWindowsClipboard::insertMultipleReply(Window requestor, ::Time time, // update the targets property if we changed it if (changed) { - XWindowsUtil::setWindowProperty(m_display, requestor, property, data.data(), - data.size(), target, format); + XWindowsUtil::setWindowProperty( + m_display, requestor, property, data.data(), data.size(), target, + format); } // add reply for MULTIPLE request @@ -851,9 +870,9 @@ void XWindowsClipboard::insertReply(Reply *reply) { m_eventMasks[reply->m_requestor] = attr.your_event_mask; // add the events we want - XSelectInput(m_display, reply->m_requestor, - attr.your_event_mask | StructureNotifyMask | - PropertyChangeMask); + XSelectInput( + m_display, reply->m_requestor, + attr.your_event_mask | StructureNotifyMask | PropertyChangeMask); } // if we failed then the window has already been destroyed @@ -884,9 +903,9 @@ void XWindowsClipboard::pushReplies() { } } -void XWindowsClipboard::pushReplies(ReplyMap::iterator &mapIndex, - ReplyList &replies, - ReplyList::iterator index) { +void XWindowsClipboard::pushReplies( + ReplyMap::iterator &mapIndex, ReplyList &replies, + ReplyList::iterator index) { Reply *reply = *index; while (sendReply(reply)) { // reply is complete. discard it and send the next reply, @@ -917,7 +936,8 @@ bool XWindowsClipboard::sendReply(Reply *reply) { // bail out immediately if reply is done if (reply->m_done) { - LOG((CLOG_DEBUG1 "clipboard: finished reply to 0x%08x,%d,%d", + LOG( + (CLOG_DEBUG1 "clipboard: finished reply to 0x%08x,%d,%d", reply->m_requestor, reply->m_target, reply->m_property)); return true; } @@ -925,7 +945,8 @@ bool XWindowsClipboard::sendReply(Reply *reply) { // start in failed state if property is None bool failed = (reply->m_property == None); if (!failed) { - LOG((CLOG_DEBUG1 "clipboard: setting property on 0x%08x,%d,%d", + LOG( + (CLOG_DEBUG1 "clipboard: setting property on 0x%08x,%d,%d", reply->m_requestor, reply->m_target, reply->m_property)); // send using INCR if already sending incrementally or if reply @@ -936,9 +957,9 @@ bool XWindowsClipboard::sendReply(Reply *reply) { // send INCR reply if incremental and we haven't replied yet if (useINCR && !reply->m_replied) { UInt32 size = reply->m_data.size(); - if (!XWindowsUtil::setWindowProperty(m_display, reply->m_requestor, - reply->m_property, &size, 4, - m_atomINCR, 32)) { + if (!XWindowsUtil::setWindowProperty( + m_display, reply->m_requestor, reply->m_property, &size, 4, + m_atomINCR, 32)) { failed = true; } } @@ -973,7 +994,8 @@ bool XWindowsClipboard::sendReply(Reply *reply) { // the final zero-length property. // FIXME -- how do you gracefully cancel an incremental transfer? if (failed) { - LOG((CLOG_DEBUG1 "clipboard: sending failure to 0x%08x,%d,%d", + LOG( + (CLOG_DEBUG1 "clipboard: sending failure to 0x%08x,%d,%d", reply->m_requestor, reply->m_target, reply->m_property)); reply->m_done = true; if (reply->m_property != None) { @@ -982,16 +1004,17 @@ bool XWindowsClipboard::sendReply(Reply *reply) { } if (!reply->m_replied) { - sendNotify(reply->m_requestor, m_selection, reply->m_target, None, - reply->m_time); + sendNotify( + reply->m_requestor, m_selection, reply->m_target, None, + reply->m_time); // don't wait for any reply (because we're not expecting one) return true; } else { static const char dummy = 0; - XWindowsUtil::setWindowProperty(m_display, reply->m_requestor, - reply->m_property, &dummy, 0, - reply->m_type, reply->m_format); + XWindowsUtil::setWindowProperty( + m_display, reply->m_requestor, reply->m_property, &dummy, 0, + reply->m_type, reply->m_format); // wait for delete notify return false; @@ -1003,14 +1026,16 @@ bool XWindowsClipboard::sendReply(Reply *reply) { return false; } - LOG((CLOG_DEBUG1 "clipboard: sending notify to 0x%08x,%d,%d", + LOG( + (CLOG_DEBUG1 "clipboard: sending notify to 0x%08x,%d,%d", reply->m_requestor, reply->m_target, reply->m_property)); reply->m_replied = true; // nothing to log if (CLOG->getFilter() < kDEBUG2) { - sendNotify(reply->m_requestor, m_selection, reply->m_target, - reply->m_property, static_cast(reply->m_time)); + sendNotify( + reply->m_requestor, m_selection, reply->m_target, reply->m_property, + static_cast(reply->m_time)); // wait for delete notify return false; @@ -1028,9 +1053,9 @@ bool XWindowsClipboard::sendReply(Reply *reply) { Atom target; String data; char *name = XGetAtomName(m_display, props[i]); - if (!XWindowsUtil::getWindowProperty(m_display, reply->m_requestor, - props[i], &data, &target, nullptr, - False)) { + if (!XWindowsUtil::getWindowProperty( + m_display, reply->m_requestor, props[i], &data, &target, nullptr, + False)) { LOG((CLOG_DEBUG2 " %s: ", name)); } else { // convert to hex if contains non ascii symbols @@ -1040,12 +1065,13 @@ bool XWindowsClipboard::sendReply(Reply *reply) { const String hex_digits = "0123456789abcdef"; String tmp; tmp.reserve(data.length() * 3); - std::for_each(data.begin(), data.end(), - [hex_digits, &tmp](const unsigned char &c) { - tmp += hex_digits[c >> 16]; - tmp += hex_digits[c & 15]; - tmp += ' '; - }); + std::for_each( + data.begin(), data.end(), + [hex_digits, &tmp](const unsigned char &c) { + tmp += hex_digits[c >> 16]; + tmp += hex_digits[c & 15]; + tmp += ' '; + }); data = tmp; } char *type = XGetAtomName(m_display, target); @@ -1062,8 +1088,9 @@ bool XWindowsClipboard::sendReply(Reply *reply) { XFree(props); } - sendNotify(reply->m_requestor, m_selection, reply->m_target, - reply->m_property, reply->m_time); + sendNotify( + reply->m_requestor, m_selection, reply->m_target, reply->m_property, + reply->m_time); // wait for delete notify return false; @@ -1086,8 +1113,8 @@ void XWindowsClipboard::clearReplies(ReplyList &replies) { replies.clear(); } -void XWindowsClipboard::sendNotify(Window requestor, Atom selection, - Atom target, Atom property, Time time) { +void XWindowsClipboard::sendNotify( + Window requestor, Atom selection, Atom target, Atom property, Time time) { XEvent event; event.xselection.type = SelectionNotify; event.xselection.display = m_display; @@ -1166,11 +1193,16 @@ Atom XWindowsClipboard::getTimestampData(String &data, int *format) const { // XWindowsClipboard::CICCCMGetClipboard // -XWindowsClipboard::CICCCMGetClipboard::CICCCMGetClipboard(Window requestor, - Time time, - Atom property) - : m_requestor(requestor), m_time(time), m_property(property), m_incr(false), - m_failed(false), m_done(false), m_reading(false), m_error(false) { +XWindowsClipboard::CICCCMGetClipboard::CICCCMGetClipboard( + Window requestor, Time time, Atom property) + : m_requestor(requestor), + m_time(time), + m_property(property), + m_incr(false), + m_failed(false), + m_done(false), + m_reading(false), + m_error(false) { // do nothing } @@ -1178,15 +1210,14 @@ XWindowsClipboard::CICCCMGetClipboard::~CICCCMGetClipboard() { // do nothing } -bool XWindowsClipboard::CICCCMGetClipboard::readClipboard(Display *display, - Atom selection, - Atom target, - Atom *actualTarget, - String *data) { +bool XWindowsClipboard::CICCCMGetClipboard::readClipboard( + Display *display, Atom selection, Atom target, Atom *actualTarget, + String *data) { assert(actualTarget != nullptr); assert(data != nullptr); - LOG((CLOG_DEBUG1 "request selection=%s, target=%s, window=%x", + LOG( + (CLOG_DEBUG1 "request selection=%s, target=%s, window=%x", XWindowsUtil::atomToString(display, selection).c_str(), XWindowsUtil::atomToString(display, target).c_str(), m_requestor)); @@ -1210,8 +1241,8 @@ bool XWindowsClipboard::CICCCMGetClipboard::readClipboard(Display *display, XSelectInput(display, m_requestor, attr.your_event_mask | PropertyChangeMask); // request data conversion - XConvertSelection(display, selection, target, m_property, m_requestor, - m_time); + XConvertSelection( + display, selection, target, m_property, m_requestor, m_time); // synchronize with server before we start following timeout countdown XSync(display, False); @@ -1271,13 +1302,14 @@ bool XWindowsClipboard::CICCCMGetClipboard::readClipboard(Display *display, XSelectInput(display, m_requestor, attr.your_event_mask); // return success or failure - LOG((CLOG_DEBUG1 "request %s after %fs", m_failed ? "failed" : "succeeded", + LOG( + (CLOG_DEBUG1 "request %s after %fs", m_failed ? "failed" : "succeeded", timeout.getTime())); return !m_failed; } -bool XWindowsClipboard::CICCCMGetClipboard::processEvent(Display *display, - XEvent *xevent) { +bool XWindowsClipboard::CICCCMGetClipboard::processEvent( + Display *display, XEvent *xevent) { // process event switch (xevent->type) { case DestroyNotify: @@ -1331,8 +1363,8 @@ bool XWindowsClipboard::CICCCMGetClipboard::processEvent(Display *display, // get the data from the property Atom target; const String::size_type oldSize = m_data->size(); - if (!XWindowsUtil::getWindowProperty(display, m_requestor, m_property, m_data, - &target, nullptr, True)) { + if (!XWindowsUtil::getWindowProperty( + display, m_requestor, m_property, m_data, &target, nullptr, True)) { // unable to read property m_failed = true; return true; @@ -1357,7 +1389,8 @@ bool XWindowsClipboard::CICCCMGetClipboard::processEvent(Display *display, else if (m_incr) { // if first incremental chunk then save target if (oldSize == 0) { - LOG((CLOG_DEBUG1 " INCR first chunk, target %s", + LOG( + (CLOG_DEBUG1 " INCR first chunk, target %s", XWindowsUtil::atomToString(display, target).c_str())); *m_actualTarget = target; } @@ -1380,7 +1413,8 @@ bool XWindowsClipboard::CICCCMGetClipboard::processEvent(Display *display, // not incremental; save the target. else { - LOG((CLOG_DEBUG1 " target %s", + LOG( + (CLOG_DEBUG1 " target %s", XWindowsUtil::atomToString(display, target).c_str())); *m_actualTarget = target; m_done = true; @@ -1396,17 +1430,31 @@ bool XWindowsClipboard::CICCCMGetClipboard::processEvent(Display *display, // XWindowsClipboard::Reply::Reply(Window requestor, Atom target, ::Time time) - : m_requestor(requestor), m_target(target), m_time(time), m_property(None), - m_replied(false), m_done(false), m_data(), m_type(None), m_format(32), + : m_requestor(requestor), + m_target(target), + m_time(time), + m_property(None), + m_replied(false), + m_done(false), + m_data(), + m_type(None), + m_format(32), m_ptr(0) { // do nothing } -XWindowsClipboard::Reply::Reply(Window requestor, Atom target, ::Time time, - Atom property, const String &data, Atom type, - int format) - : m_requestor(requestor), m_target(target), m_time(time), - m_property(property), m_replied(false), m_done(false), m_data(data), - m_type(type), m_format(format), m_ptr(0) { +XWindowsClipboard::Reply::Reply( + Window requestor, Atom target, ::Time time, Atom property, + const String &data, Atom type, int format) + : m_requestor(requestor), + m_target(target), + m_time(time), + m_property(property), + m_replied(false), + m_done(false), + m_data(data), + m_type(type), + m_format(format), + m_ptr(0) { // do nothing } diff --git a/src/lib/platform/XWindowsClipboard.h b/src/lib/platform/XWindowsClipboard.h index c67d446df..bb4ba96ea 100644 --- a/src/lib/platform/XWindowsClipboard.h +++ b/src/lib/platform/XWindowsClipboard.h @@ -59,8 +59,8 @@ public: 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); + void addRequest( + Window owner, Window requestor, Atom target, ::Time time, Atom property); //! Process clipboard request /*! @@ -106,8 +106,8 @@ private: // 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; + IXWindowsClipboardConverter * + getConverter(Atom target, bool onlyIfNotAdded = false) const; // convert target atom to clipboard format EFormat getFormat(Atom target) const; @@ -116,8 +116,8 @@ private: // 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); + 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. @@ -145,8 +145,9 @@ private: // 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); + bool readClipboard( + Display *display, Atom selection, Atom target, Atom *actualTarget, + String *data); private: bool processEvent(Display *display, XEvent *event); @@ -222,8 +223,9 @@ private: class Reply { public: Reply(Window, Atom target, ::Time); - Reply(Window, Atom target, ::Time, Atom property, const String &data, - Atom type, int format); + Reply( + Window, Atom target, ::Time, Atom property, const String &data, + Atom type, int format); public: // information about the request @@ -260,8 +262,8 @@ private: void motifUnlockClipboard() const; bool motifOwnsClipboard() const; void motifFillCache(); - bool motifGetSelection(const MotifClipFormat *, Atom *actualTarget, - String *data) const; + bool motifGetSelection( + const MotifClipFormat *, Atom *actualTarget, String *data) const; Time motifGetTime() const; // reply methods @@ -272,8 +274,8 @@ private: bool sendReply(Reply *); void clearReplies(); void clearReplies(ReplyList &); - void sendNotify(Window requestor, Atom selection, Atom target, Atom property, - Time time); + void sendNotify( + Window requestor, Atom selection, Atom target, Atom property, Time time); bool wasOwnedAtTime(::Time) const; // data conversion methods diff --git a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp index 431147fcd..f2c91df5f 100644 --- a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp +++ b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.cpp @@ -63,10 +63,10 @@ static inline UInt16 fromLEU16(const UInt8 *data) { } static inline SInt32 fromLES32(const UInt8 *data) { - return static_cast(static_cast(data[0]) | - (static_cast(data[1]) << 8) | - (static_cast(data[2]) << 16) | - (static_cast(data[3]) << 24)); + return static_cast( + static_cast(data[0]) | (static_cast(data[1]) << 8) | + (static_cast(data[2]) << 16) | + (static_cast(data[3]) << 24)); } static inline UInt32 fromLEU32(const UInt8 *data) { @@ -121,11 +121,11 @@ XWindowsClipboardAnyBitmapConverter::fromIClipboard(const String &bmp) const { // convert to image format const UInt8 *rawBMPPixels = rawBMPInfoHeader + 40; if (infoHeader.biBitCount == 24) { - return doBGRFromIClipboard(rawBMPPixels, infoHeader.biWidth, - infoHeader.biHeight); + return doBGRFromIClipboard( + rawBMPPixels, infoHeader.biWidth, infoHeader.biHeight); } else { - return doBGRAFromIClipboard(rawBMPPixels, infoHeader.biWidth, - infoHeader.biHeight); + return doBGRAFromIClipboard( + rawBMPPixels, infoHeader.biWidth, infoHeader.biHeight); } } @@ -154,7 +154,7 @@ XWindowsClipboardAnyBitmapConverter::toIClipboard(const String &image) const { toLE(dst, static_cast(0)); // construct image - return String(reinterpret_cast(infoHeader), - sizeof(infoHeader)) + + return String( + reinterpret_cast(infoHeader), sizeof(infoHeader)) + rawBMP; } diff --git a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h index 8fa072def..84da45688 100644 --- a/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h +++ b/src/lib/platform/XWindowsClipboardAnyBitmapConverter.h @@ -38,21 +38,21 @@ protected: /*! Convert raw BGR pixel data to another image format. */ - virtual String doBGRFromIClipboard(const UInt8 *bgrData, UInt32 w, - UInt32 h) const = 0; + 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; + 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; + virtual String + doToIClipboard(const String &, UInt32 &w, UInt32 &h, UInt32 &depth) const = 0; }; diff --git a/src/lib/platform/XWindowsClipboardHTMLConverter.cpp b/src/lib/platform/XWindowsClipboardHTMLConverter.cpp index 7cb074759..0393e65ff 100644 --- a/src/lib/platform/XWindowsClipboardHTMLConverter.cpp +++ b/src/lib/platform/XWindowsClipboardHTMLConverter.cpp @@ -24,8 +24,8 @@ // XWindowsClipboardHTMLConverter // -XWindowsClipboardHTMLConverter::XWindowsClipboardHTMLConverter(Display *display, - const char *name) +XWindowsClipboardHTMLConverter::XWindowsClipboardHTMLConverter( + Display *display, const char *name) : m_atom(XInternAtom(display, name, False)) { // do nothing } diff --git a/src/lib/platform/XWindowsClipboardTextConverter.cpp b/src/lib/platform/XWindowsClipboardTextConverter.cpp index dedfd714b..ebeb28861 100644 --- a/src/lib/platform/XWindowsClipboardTextConverter.cpp +++ b/src/lib/platform/XWindowsClipboardTextConverter.cpp @@ -24,8 +24,8 @@ // XWindowsClipboardTextConverter // -XWindowsClipboardTextConverter::XWindowsClipboardTextConverter(Display *display, - const char *name) +XWindowsClipboardTextConverter::XWindowsClipboardTextConverter( + Display *display, const char *name) : m_atom(XInternAtom(display, name, False)) { // do nothing } diff --git a/src/lib/platform/XWindowsClipboardUCS2Converter.cpp b/src/lib/platform/XWindowsClipboardUCS2Converter.cpp index 73bdd7e39..236122480 100644 --- a/src/lib/platform/XWindowsClipboardUCS2Converter.cpp +++ b/src/lib/platform/XWindowsClipboardUCS2Converter.cpp @@ -24,8 +24,8 @@ // XWindowsClipboardUCS2Converter // -XWindowsClipboardUCS2Converter::XWindowsClipboardUCS2Converter(Display *display, - const char *name) +XWindowsClipboardUCS2Converter::XWindowsClipboardUCS2Converter( + Display *display, const char *name) : m_atom(XInternAtom(display, name, False)) { // do nothing } diff --git a/src/lib/platform/XWindowsClipboardUTF8Converter.cpp b/src/lib/platform/XWindowsClipboardUTF8Converter.cpp index db5582539..3d6c6ce94 100644 --- a/src/lib/platform/XWindowsClipboardUTF8Converter.cpp +++ b/src/lib/platform/XWindowsClipboardUTF8Converter.cpp @@ -24,10 +24,10 @@ // XWindowsClipboardUTF8Converter // -XWindowsClipboardUTF8Converter::XWindowsClipboardUTF8Converter(Display *display, - const char *name, - bool normalize) - : m_atom(XInternAtom(display, name, False)), m_normalize(normalize) { +XWindowsClipboardUTF8Converter::XWindowsClipboardUTF8Converter( + Display *display, const char *name, bool normalize) + : m_atom(XInternAtom(display, name, False)), + m_normalize(normalize) { // do nothing } diff --git a/src/lib/platform/XWindowsClipboardUTF8Converter.h b/src/lib/platform/XWindowsClipboardUTF8Converter.h index ea45fd929..922907943 100644 --- a/src/lib/platform/XWindowsClipboardUTF8Converter.h +++ b/src/lib/platform/XWindowsClipboardUTF8Converter.h @@ -26,8 +26,8 @@ public: /*! \c name is converted to an atom and that is reported by getAtom(). */ - XWindowsClipboardUTF8Converter(Display *display, const char *name, - bool normalize = false); + XWindowsClipboardUTF8Converter( + Display *display, const char *name, bool normalize = false); virtual ~XWindowsClipboardUTF8Converter(); // IXWindowsClipboardConverter overrides diff --git a/src/lib/platform/XWindowsEventQueueBuffer.cpp b/src/lib/platform/XWindowsEventQueueBuffer.cpp index 932e06166..bef9a6472 100644 --- a/src/lib/platform/XWindowsEventQueueBuffer.cpp +++ b/src/lib/platform/XWindowsEventQueueBuffer.cpp @@ -51,10 +51,12 @@ class EventQueueTimer {}; // XWindowsEventQueueBuffer // -XWindowsEventQueueBuffer::XWindowsEventQueueBuffer(Display *display, - Window window, - IEventQueue *events) - : m_events(events), m_display(display), m_window(window), m_waiting(false) { +XWindowsEventQueueBuffer::XWindowsEventQueueBuffer( + Display *display, Window window, IEventQueue *events) + : m_events(events), + m_display(display), + m_window(window), + m_waiting(false) { assert(m_display != NULL); assert(m_window != None); @@ -169,8 +171,9 @@ void XWindowsEventQueueBuffer::waitForEvent(double dtimeout) { } } #else - retval = select(nfds, SELECT_TYPE_ARG234 & rfds, SELECT_TYPE_ARG234 NULL, - SELECT_TYPE_ARG234 NULL, SELECT_TYPE_ARG5 TIMEOUT_DELAY); + retval = select( + nfds, SELECT_TYPE_ARG234 & rfds, SELECT_TYPE_ARG234 NULL, + SELECT_TYPE_ARG234 NULL, SELECT_TYPE_ARG5 TIMEOUT_DELAY); if (FD_SET(m_pipefd[0], &rfds)) { read(m_pipefd[0], buf, 15); } @@ -187,8 +190,8 @@ void XWindowsEventQueueBuffer::waitForEvent(double dtimeout) { Thread::testCancel(); } -IEventQueueBuffer::Type XWindowsEventQueueBuffer::getEvent(Event &event, - UInt32 &dataID) { +IEventQueueBuffer::Type +XWindowsEventQueueBuffer::getEvent(Event &event, UInt32 &dataID) { Lock lock(&m_mutex); // push out pending events diff --git a/src/lib/platform/XWindowsKeyState.cpp b/src/lib/platform/XWindowsKeyState.cpp index f254720a7..c896ca5ff 100644 --- a/src/lib/platform/XWindowsKeyState.cpp +++ b/src/lib/platform/XWindowsKeyState.cpp @@ -47,19 +47,23 @@ static const size_t ModifiersFromXDefaultSize = 32; -XWindowsKeyState::XWindowsKeyState(Display *display, bool useXKB, - IEventQueue *events) - : KeyState(events, AppUtil::instance().getKeyboardLayoutList(), - ClientApp::instance().args().m_enableLangSync), - m_display(display), m_modifierFromX(ModifiersFromXDefaultSize) { +XWindowsKeyState::XWindowsKeyState( + Display *display, bool useXKB, IEventQueue *events) + : KeyState( + events, AppUtil::instance().getKeyboardLayoutList(), + ClientApp::instance().args().m_enableLangSync), + m_display(display), + m_modifierFromX(ModifiersFromXDefaultSize) { init(display, useXKB); } -XWindowsKeyState::XWindowsKeyState(Display *display, bool useXKB, - IEventQueue *events, synergy::KeyMap &keyMap) - : KeyState(events, keyMap, AppUtil::instance().getKeyboardLayoutList(), - ClientApp::instance().args().m_enableLangSync), - m_display(display), m_modifierFromX(ModifiersFromXDefaultSize) { +XWindowsKeyState::XWindowsKeyState( + Display *display, bool useXKB, IEventQueue *events, synergy::KeyMap &keyMap) + : KeyState( + events, keyMap, AppUtil::instance().getKeyboardLayoutList(), + ClientApp::instance().args().m_enableLangSync), + m_display(display), + m_modifierFromX(ModifiersFromXDefaultSize) { init(display, useXKB); } @@ -75,10 +79,10 @@ void XWindowsKeyState::init(Display *display, bool useXKB) { XGetKeyboardControl(m_display, &m_keyboardState); #if HAVE_XKB_EXTENSION if (useXKB) { - m_xkb = XkbGetMap(m_display, - XkbKeyActionsMask | XkbKeyBehaviorsMask | - XkbAllClientInfoMask, - XkbUseCoreKbd); + m_xkb = XkbGetMap( + m_display, + XkbKeyActionsMask | XkbKeyBehaviorsMask | XkbAllClientInfoMask, + XkbUseCoreKbd); } else { m_xkb = NULL; } @@ -112,7 +116,8 @@ KeyModifierMask XWindowsKeyState::mapModifiersFromX(unsigned int state) const { if ((state & (1u << i)) != 0) { LOG((CLOG_DEBUG2 "|= modifier: %i", offset + i)); if (offset + i >= m_modifierFromX.size()) { - LOG((CLOG_ERR "m_modifierFromX is too small (%d) for the " + LOG( + (CLOG_ERR "m_modifierFromX is too small (%d) for the " "requested offset (%d)", m_modifierFromX.size(), offset + i)); } else { @@ -123,8 +128,8 @@ KeyModifierMask XWindowsKeyState::mapModifiersFromX(unsigned int state) const { return mask; } -bool XWindowsKeyState::mapModifiersToX(KeyModifierMask mask, - unsigned int &modifiers) const { +bool XWindowsKeyState::mapModifiersToX( + KeyModifierMask mask, unsigned int &modifiers) const { modifiers = 0; for (SInt32 i = 0; i < kKeyModifierNumBits; ++i) { @@ -142,8 +147,8 @@ bool XWindowsKeyState::mapModifiersToX(KeyModifierMask mask, return true; } -void XWindowsKeyState::mapKeyToKeycodes(KeyID key, - KeycodeList &keycodes) const { +void XWindowsKeyState::mapKeyToKeycodes( + KeyID key, KeycodeList &keycodes) const { keycodes.clear(); std::pair range = m_keyCodeFromKey.equal_range(key); @@ -162,8 +167,9 @@ KeyModifierMask XWindowsKeyState::pollActiveModifiers() const { Window root = DefaultRootWindow(m_display), window; int xRoot, yRoot, xWindow, yWindow; unsigned int state = 0; - if (XQueryPointer(m_display, root, &root, &window, &xRoot, &yRoot, &xWindow, - &yWindow, &state) == False) { + if (XQueryPointer( + m_display, root, &root, &window, &xRoot, &yRoot, &xWindow, &yWindow, + &state) == False) { state = 0; } return mapModifiersFromX(state); @@ -210,10 +216,10 @@ void XWindowsKeyState::getKeyMap(synergy::KeyMap &keyMap) { #if HAVE_XKB_EXTENSION if (m_xkb != NULL) { - if (XkbGetUpdatedMap(m_display, - XkbKeyActionsMask | XkbKeyBehaviorsMask | - XkbAllClientInfoMask, - m_xkb) == Success) { + if (XkbGetUpdatedMap( + m_display, + XkbKeyActionsMask | XkbKeyBehaviorsMask | XkbAllClientInfoMask, + m_xkb) == Success) { updateKeysymMapXKB(keyMap); return; } @@ -247,7 +253,8 @@ bool XWindowsKeyState::setCurrentLanguageWithDBus(SInt32 group) const { if (!reply.isValid()) { auto qerror = reply.error(); - LOG((CLOG_WARN "keyboard layout fail %s : %s", + LOG( + (CLOG_WARN "keyboard layout fail %s : %s", qerror.name().toStdString().c_str(), qerror.message().toStdString().c_str())); return true; @@ -280,9 +287,9 @@ void XWindowsKeyState::fakeKey(const Keystroke &keystroke) { break; } } - XTestFakeKeyEvent(m_display, keystroke.m_data.m_button.m_button, - keystroke.m_data.m_button.m_press ? True : False, - CurrentTime); + XTestFakeKeyEvent( + m_display, keystroke.m_data.m_button.m_button, + keystroke.m_data.m_button.m_press ? True : False, CurrentTime); break; case Keystroke::kGroup: @@ -299,8 +306,9 @@ void XWindowsKeyState::fakeKey(const Keystroke &keystroke) { #endif #if HAVE_XKB_EXTENSION if (m_xkb != NULL) { - if (XkbLockGroup(m_display, XkbUseCoreKbd, - keystroke.m_data.m_group.m_group) == False) { + if (XkbLockGroup( + m_display, XkbUseCoreKbd, keystroke.m_data.m_group.m_group) == + False) { LOG((CLOG_DEBUG1 "xkb lock group request not sent")); } } else @@ -317,9 +325,10 @@ void XWindowsKeyState::fakeKey(const Keystroke &keystroke) { #endif #if HAVE_XKB_EXTENSION if (m_xkb != NULL) { - if (XkbLockGroup(m_display, XkbUseCoreKbd, - getEffectiveGroup(pollActiveGroup(), - keystroke.m_data.m_group.m_group)) == + if (XkbLockGroup( + m_display, XkbUseCoreKbd, + getEffectiveGroup( + pollActiveGroup(), keystroke.m_data.m_group.m_group)) == False) { LOG((CLOG_DEBUG1 "xkb lock group request not sent")); } @@ -362,8 +371,8 @@ void XWindowsKeyState::updateKeysymMap(synergy::KeyMap &keyMap) { // get the keyboard mapping for all keys int keysymsPerKeycode; - KeySym *allKeysyms = XGetKeyboardMapping(m_display, minKeycode, numKeycodes, - &keysymsPerKeycode); + KeySym *allKeysyms = XGetKeyboardMapping( + m_display, minKeycode, numKeycodes, &keysymsPerKeycode); // it's more convenient to always have maxKeysyms KeySyms per key { @@ -474,10 +483,11 @@ void XWindowsKeyState::updateKeysymMap(synergy::KeyMap &keyMap) { // if it's sensitive to caps-lock. if ((item.m_sensitive & KeyModifierCapsLock) != 0) { item.m_sensitive |= KeyModifierShift; - } else if ((keysyms[0] != NoSymbol && keysyms[1] != NoSymbol && - keysyms[0] != keysyms[1]) || - (keysyms[2] != NoSymbol && keysyms[3] != NoSymbol && - keysyms[2] != keysyms[3])) { + } else if ( + (keysyms[0] != NoSymbol && keysyms[1] != NoSymbol && + keysyms[0] != keysyms[1]) || + (keysyms[2] != NoSymbol && keysyms[3] != NoSymbol && + keysyms[2] != keysyms[3])) { item.m_sensitive |= KeyModifierShift; } @@ -570,13 +580,14 @@ void XWindowsKeyState::updateKeysymMap(synergy::KeyMap &keyMap) { #if HAVE_XKB_EXTENSION void XWindowsKeyState::updateKeysymMapXKB(synergy::KeyMap &keyMap) { - static const XkbKTMapEntryRec defMapEntry = {True, // active - 0, // level - { - 0, // mods.mask - 0, // mods.real_mods - 0 // mods.vmods - }}; + static const XkbKTMapEntryRec defMapEntry = { + True, // active + 0, // level + { + 0, // mods.mask + 0, // mods.real_mods + 0 // mods.vmods + }}; LOG((CLOG_DEBUG1 "xkb mapping")); @@ -683,9 +694,10 @@ void XWindowsKeyState::updateKeysymMapXKB(synergy::KeyMap &keyMap) { if ((action->mods.flags & XkbSA_UseModMapMods) == 0) { modifierMask = action->mods.mask; } - } else if (action->type == XkbSA_SetGroup || - action->type == XkbSA_LatchGroup || - action->type == XkbSA_LockGroup) { + } else if ( + action->type == XkbSA_SetGroup || + action->type == XkbSA_LatchGroup || + action->type == XkbSA_LockGroup) { // ignore group change key continue; } @@ -796,9 +808,8 @@ void XWindowsKeyState::updateKeysymMapXKB(synergy::KeyMap &keyMap) { } #endif -void XWindowsKeyState::remapKeyModifiers(KeyID id, SInt32 group, - synergy::KeyMap::KeyItem &item, - void *vself) { +void XWindowsKeyState::remapKeyModifiers( + KeyID id, SInt32 group, synergy::KeyMap::KeyItem &item, void *vself) { XWindowsKeyState *self = static_cast(vself); item.m_required = self->mapModifiersFromX(XkbBuildCoreState(item.m_required, group)); diff --git a/src/lib/platform/XWindowsKeyState.h b/src/lib/platform/XWindowsKeyState.h index a16c2da4a..1b4d77d4c 100644 --- a/src/lib/platform/XWindowsKeyState.h +++ b/src/lib/platform/XWindowsKeyState.h @@ -48,8 +48,8 @@ public: enum { kGroupPoll = -1, kGroupPollAndSet = -2 }; XWindowsKeyState(Display *, bool useXKB, IEventQueue *events); - XWindowsKeyState(Display *, bool useXKB, IEventQueue *events, - synergy::KeyMap &keyMap); + XWindowsKeyState( + Display *, bool useXKB, IEventQueue *events, synergy::KeyMap &keyMap); ~XWindowsKeyState(); //! @name modifiers @@ -124,8 +124,8 @@ private: */ bool setCurrentLanguageWithDBus(SInt32 group) const; - static void remapKeyModifiers(KeyID, SInt32, synergy::KeyMap::KeyItem &, - void *); + static void + remapKeyModifiers(KeyID, SInt32, synergy::KeyMap::KeyItem &, void *); private: struct XKBModifierInfo { diff --git a/src/lib/platform/XWindowsPowerManager.cpp b/src/lib/platform/XWindowsPowerManager.cpp index 697749aad..01d9808c2 100644 --- a/src/lib/platform/XWindowsPowerManager.cpp +++ b/src/lib/platform/XWindowsPowerManager.cpp @@ -21,8 +21,8 @@ namespace { -bool sleepInhibitCall(bool state, - ArchSystemUnix::InhibitScreenServices serviceID) { +bool sleepInhibitCall( + bool state, ArchSystemUnix::InhibitScreenServices serviceID) { std::string error; if (!ArchSystemUnix::DBusInhibitScreenCall(serviceID, state, error)) { @@ -38,8 +38,8 @@ bool sleepInhibitCall(bool state, XWindowsPowerManager::~XWindowsPowerManager() { enableSleep(); } void XWindowsPowerManager::disableSleep() const { - if (!sleepInhibitCall(true, - ArchSystemUnix::InhibitScreenServices::kScreenSaver) && + if (!sleepInhibitCall( + true, ArchSystemUnix::InhibitScreenServices::kScreenSaver) && !sleepInhibitCall( true, ArchSystemUnix::InhibitScreenServices::kSessionManager)) { LOG((CLOG_INFO "failed to prevent system from going to sleep")); @@ -47,8 +47,8 @@ void XWindowsPowerManager::disableSleep() const { } void XWindowsPowerManager::enableSleep() const { - if (!sleepInhibitCall(false, - ArchSystemUnix::InhibitScreenServices::kScreenSaver) && + if (!sleepInhibitCall( + false, ArchSystemUnix::InhibitScreenServices::kScreenSaver) && !sleepInhibitCall( false, ArchSystemUnix::InhibitScreenServices::kSessionManager)) { LOG((CLOG_INFO "failed to enable system idle sleep")); diff --git a/src/lib/platform/XWindowsScreen.cpp b/src/lib/platform/XWindowsScreen.cpp index fd3b8cb15..89392b31f 100644 --- a/src/lib/platform/XWindowsScreen.cpp +++ b/src/lib/platform/XWindowsScreen.cpp @@ -99,15 +99,36 @@ XWindowsScreen::XWindowsScreen( const char *displayName, bool isPrimary, bool disableXInitThreads, int mouseScrollDelta, IEventQueue *events, lib::synergy::ClientScrollDirection scrollDirection) - : PlatformScreen(events, scrollDirection), m_isPrimary(isPrimary), - m_mouseScrollDelta(mouseScrollDelta), m_display(NULL), m_root(None), - m_window(None), m_isOnScreen(m_isPrimary), m_x(0), m_y(0), m_w(0), m_h(0), - m_xCenter(0), m_yCenter(0), m_xCursor(0), m_yCursor(0), m_keyState(NULL), - m_lastFocus(None), m_lastFocusRevert(RevertToNone), m_im(NULL), - m_ic(NULL), m_lastKeycode(0), m_sequenceNumber(0), m_screensaver(NULL), - m_screensaverNotify(false), m_xtestIsXineramaUnaware(true), - m_preserveFocus(false), m_xkb(false), m_xi2detected(false), - m_xrandr(false), m_events(events) { + : PlatformScreen(events, scrollDirection), + m_isPrimary(isPrimary), + m_mouseScrollDelta(mouseScrollDelta), + m_display(NULL), + m_root(None), + m_window(None), + m_isOnScreen(m_isPrimary), + m_x(0), + m_y(0), + m_w(0), + m_h(0), + m_xCenter(0), + m_yCenter(0), + m_xCursor(0), + m_yCursor(0), + m_keyState(NULL), + m_lastFocus(None), + m_lastFocusRevert(RevertToNone), + m_im(NULL), + m_ic(NULL), + m_lastKeycode(0), + m_sequenceNumber(0), + m_screensaver(NULL), + m_screensaverNotify(false), + m_xtestIsXineramaUnaware(true), + m_preserveFocus(false), + m_xkb(false), + m_xi2detected(false), + m_xrandr(false), + m_events(events) { assert(s_screen == NULL); if (mouseScrollDelta == 0) @@ -133,7 +154,8 @@ XWindowsScreen::XWindowsScreen( m_screensaver = new XWindowsScreenSaver(m_display, m_window, getEventTarget(), events); m_keyState = new XWindowsKeyState(m_display, m_xkb, events, m_keyMap); - LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, + LOG( + (CLOG_DEBUG "screen shape: %d,%d %dx%d %s", m_x, m_y, m_w, m_h, m_xinerama ? "(xinerama)" : "")); LOG((CLOG_DEBUG "window is 0x%08x", m_window)); } catch (...) { @@ -174,9 +196,10 @@ XWindowsScreen::XWindowsScreen( } // install event handlers - m_events->adoptHandler(Event::kSystem, m_events->getSystemTarget(), - new TMethodEventJob( - this, &XWindowsScreen::handleSystemEvent)); + m_events->adoptHandler( + Event::kSystem, m_events->getSystemTarget(), + new TMethodEventJob( + this, &XWindowsScreen::handleSystemEvent)); // install the platform event queue m_events->adoptBuffer( @@ -415,11 +438,13 @@ void XWindowsScreen::setOptions(const OptionsList &options) { for (UInt32 i = 0, n = options.size(); i < n; i += 2) { if (options[i] == kOptionXTestXineramaUnaware) { m_xtestIsXineramaUnaware = (options[i + 1] != 0); - LOG((CLOG_DEBUG1 "library, XTest is Xinerama unaware %s", + LOG( + (CLOG_DEBUG1 "library, XTest is Xinerama unaware %s", m_xtestIsXineramaUnaware ? "true" : "false")); } else if (options[i] == kOptionScreenPreserveFocus) { m_preserveFocus = (options[i + 1] != 0); - LOG((CLOG_DEBUG1 "preserve focus: %s", + LOG( + (CLOG_DEBUG1 "preserve focus: %s", m_preserveFocus ? "true" : "false")); } } @@ -456,8 +481,8 @@ bool XWindowsScreen::getClipboard(ClipboardID id, IClipboard *clipboard) const { return Clipboard::copy(clipboard, m_clipboard[id], timestamp); } -void XWindowsScreen::getShape(SInt32 &x, SInt32 &y, SInt32 &w, - SInt32 &h) const { +void XWindowsScreen::getShape( + SInt32 &x, SInt32 &y, SInt32 &w, SInt32 &h) const { x = m_x; y = m_y; w = m_w; @@ -468,8 +493,9 @@ void XWindowsScreen::getCursorPos(SInt32 &x, SInt32 &y) const { Window root, window; int mx, my, xWindow, yWindow; unsigned int mask; - if (XQueryPointer(m_display, m_root, &root, &window, &mx, &my, &xWindow, - &yWindow, &mask)) { + if (XQueryPointer( + m_display, m_root, &root, &window, &mx, &my, &xWindow, &yWindow, + &mask)) { x = mx; y = my; } else { @@ -488,11 +514,11 @@ void XWindowsScreen::warpCursor(SInt32 x, SInt32 y) { // remove all input events before and including warp XEvent event; - while (XCheckMaskEvent(m_display, - PointerMotionMask | ButtonPressMask | - ButtonReleaseMask | KeyPressMask | KeyReleaseMask | - KeymapStateMask, - &event)) { + while (XCheckMaskEvent( + m_display, + PointerMotionMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | + KeyReleaseMask | KeymapStateMask, + &event)) { // do nothing } @@ -614,8 +640,9 @@ UInt32 XWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask) { for (int k = 0; k < modKeymap->max_keypermod && !err; ++k) { KeyCode code = modifiermap[k]; if (modifiermap[k] != 0) { - XGrabKey(m_display, code, modifiers2, m_root, False, GrabModeAsync, - GrabModeAsync); + XGrabKey( + m_display, code, modifiers2, m_root, False, GrabModeAsync, + GrabModeAsync); if (!err) { hotKeys.push_back(std::make_pair(code, modifiers2)); m_hotKeyToIDMap[HotKeyItem(code, modifiers2)] = id; @@ -660,8 +687,9 @@ UInt32 XWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask) { } // add grab - XGrabKey(m_display, *j, tmpModifiers, m_root, False, GrabModeAsync, - GrabModeAsync); + XGrabKey( + m_display, *j, tmpModifiers, m_root, False, GrabModeAsync, + GrabModeAsync); if (!err) { hotKeys.push_back(std::make_pair(*j, tmpModifiers)); m_hotKeyToIDMap[HotKeyItem(*j, tmpModifiers)] = id; @@ -680,12 +708,14 @@ UInt32 XWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask) { m_oldHotKeyIDs.push_back(id); m_hotKeys.erase(id); - LOG((CLOG_WARN "failed to register hotkey %s (id=%04x mask=%04x)", + LOG( + (CLOG_WARN "failed to register hotkey %s (id=%04x mask=%04x)", synergy::KeyMap::formatKey(key, mask).c_str(), key, mask)); return 0; } - LOG((CLOG_DEBUG "registered hotkey %s (id=%04x mask=%04x) as id=%d", + LOG( + (CLOG_DEBUG "registered hotkey %s (id=%04x mask=%04x) as id=%d", synergy::KeyMap::formatKey(key, mask).c_str(), key, mask, id)); return id; } @@ -733,10 +763,12 @@ bool XWindowsScreen::isAnyMouseButtonDown(UInt32 &buttonID) const { Window root, window; int xRoot, yRoot, xWindow, yWindow; unsigned int state; - if (XQueryPointer(m_display, m_root, &root, &window, &xRoot, &yRoot, &xWindow, - &yWindow, &state)) { - return ((state & (Button1Mask | Button2Mask | Button3Mask | Button4Mask | - Button5Mask)) != 0); + if (XQueryPointer( + m_display, m_root, &root, &window, &xRoot, &yRoot, &xWindow, &yWindow, + &state)) { + return ( + (state & (Button1Mask | Button2Mask | Button3Mask | Button4Mask | + Button5Mask)) != 0); } return false; @@ -759,8 +791,8 @@ void XWindowsScreen::fakeMouseMove(SInt32 x, SInt32 y) { if (m_xinerama && m_xtestIsXineramaUnaware) { XWarpPointer(m_display, None, m_root, 0, 0, 0, 0, x, y); } else { - XTestFakeMotionEvent(m_display, DefaultScreen(m_display), x, y, - CurrentTime); + XTestFakeMotionEvent( + m_display, DefaultScreen(m_display), x, y, CurrentTime); } XFlush(m_display); } @@ -805,7 +837,8 @@ void XWindowsScreen::fakeMouseWheel(SInt32, SInt32 yDelta) const { } if (yDelta < m_mouseScrollDelta) { - LOG((CLOG_WARN "wheel scroll delta (%d) smaller than threshold (%d)", + LOG( + (CLOG_WARN "wheel scroll delta (%d) smaller than threshold (%d)", yDelta, m_mouseScrollDelta)); } @@ -836,8 +869,9 @@ Display *XWindowsScreen::openDisplay(const char *displayName) { // verify the availability of the XTest extension if (!m_isPrimary) { int majorOpcode, firstEvent, firstError; - if (!XQueryExtension(display, XTestExtensionName, &majorOpcode, &firstEvent, - &firstError)) { + if (!XQueryExtension( + display, XTestExtensionName, &majorOpcode, &firstEvent, + &firstError)) { LOG((CLOG_ERR "the XTest extension is not available")); XCloseDisplay(display); throw XScreenOpenFailure(); @@ -850,13 +884,14 @@ Display *XWindowsScreen::openDisplay(const char *displayName) { int major = XkbMajorVersion, minor = XkbMinorVersion; if (XkbLibraryVersion(&major, &minor)) { int opcode, firstError; - if (XkbQueryExtension(display, &opcode, &m_xkbEventBase, &firstError, - &major, &minor)) { + if (XkbQueryExtension( + display, &opcode, &m_xkbEventBase, &firstError, &major, &minor)) { m_xkb = true; - XkbSelectEvents(display, XkbUseCoreKbd, XkbMapNotifyMask, - XkbMapNotifyMask); - XkbSelectEventDetails(display, XkbUseCoreKbd, XkbStateNotifyMask, - XkbGroupStateMask, XkbGroupStateMask); + XkbSelectEvents( + display, XkbUseCoreKbd, XkbMapNotifyMask, XkbMapNotifyMask); + XkbSelectEventDetails( + display, XkbUseCoreKbd, XkbStateNotifyMask, XkbGroupStateMask, + XkbGroupStateMask); } } } @@ -868,8 +903,9 @@ Display *XWindowsScreen::openDisplay(const char *displayName) { m_xrandr = XRRQueryExtension(display, &m_xrandrEventBase, &dummyError); if (m_xrandr) { // enable XRRScreenChangeNotifyEvent - XRRSelectInput(display, DefaultRootWindow(display), - RRScreenChangeNotifyMask | RRCrtcChangeNotifyMask); + XRRSelectInput( + display, DefaultRootWindow(display), + RRScreenChangeNotifyMask | RRCrtcChangeNotifyMask); } #endif @@ -1118,8 +1154,9 @@ void XWindowsScreen::handleSystemEvent(const Event &event, void *) { filter.m_keycode = xevent->xkey.keycode; XEvent xevent2; isRepeat = - (XCheckIfEvent(m_display, &xevent2, &XWindowsScreen::findKeyEvent, - (XPointer)&filter) == True); + (XCheckIfEvent( + m_display, &xevent2, &XWindowsScreen::findKeyEvent, + (XPointer)&filter) == True); } if (xevent->type == KeyPress || xevent->type == KeyRelease) { @@ -1153,8 +1190,8 @@ void XWindowsScreen::handleSystemEvent(const Event &event, void *) { // KeyRelease) so we have a keycode for a synthesized KeyPress. if (xevent->type == KeyPress && xevent->xkey.keycode != 0) { m_lastKeycode = xevent->xkey.keycode; - } else if (xevent->type == KeyRelease && - xevent->xkey.keycode == m_lastKeycode) { + } else if ( + xevent->type == KeyRelease && xevent->xkey.keycode == m_lastKeycode) { m_lastKeycode = 0; } @@ -1169,8 +1206,9 @@ void XWindowsScreen::handleSystemEvent(const Event &event, void *) { // discard matching key releases for key presses that were // filtered and remove them from our filtered list. - else if (xevent->type == KeyRelease && - m_filtered.count(xevent->xkey.keycode) > 0) { + else if ( + xevent->type == KeyRelease && + m_filtered.count(xevent->xkey.keycode) > 0) { m_filtered.erase(xevent->xkey.keycode); return; } @@ -1248,8 +1286,8 @@ void XWindowsScreen::handleSystemEvent(const Event &event, void *) { // retrieval methods. we'll just delete the property // with the data (satisfying the usual ICCCM protocol). if (xevent->xselection.property != None) { - XDeleteProperty(m_display, xevent->xselection.requestor, - xevent->xselection.property); + XDeleteProperty( + m_display, xevent->xselection.requestor, xevent->xselection.property); } break; @@ -1268,8 +1306,9 @@ void XWindowsScreen::handleSystemEvent(const Event &event, void *) { case PropertyNotify: // property delete may be part of a selection conversion if (xevent->xproperty.state == PropertyDelete) { - processClipboardRequest(xevent->xproperty.window, xevent->xproperty.time, - xevent->xproperty.atom); + processClipboardRequest( + xevent->xproperty.window, xevent->xproperty.time, + xevent->xproperty.atom); } break; @@ -1368,7 +1407,8 @@ void XWindowsScreen::handleSystemEvent(const Event &event, void *) { } void XWindowsScreen::onKeyPress(XKeyEvent &xkey) { - LOG((CLOG_DEBUG1 "event: KeyPress code=%d, state=0x%04x", xkey.keycode, + LOG( + (CLOG_DEBUG1 "event: KeyPress code=%d, state=0x%04x", xkey.keycode, xkey.state)); const KeyModifierMask mask = m_keyState->mapModifiersFromX(xkey.state); KeyID key = mapKeyFromX(&xkey); @@ -1397,13 +1437,13 @@ void XWindowsScreen::onKeyPress(XKeyEvent &xkey) { } // handle key - m_keyState->sendKeyEvent(getEventTarget(), true, false, key, mask, 1, - keycode); + m_keyState->sendKeyEvent( + getEventTarget(), true, false, key, mask, 1, keycode); // do fake release if this is a fake press if (isFake) { - m_keyState->sendKeyEvent(getEventTarget(), false, false, key, mask, 1, - keycode); + m_keyState->sendKeyEvent( + getEventTarget(), false, false, key, mask, 1, keycode); } } else { LOG((CLOG_DEBUG1 "can't map keycode to key id")); @@ -1427,19 +1467,21 @@ void XWindowsScreen::onKeyRelease(XKeyEvent &xkey, bool isRepeat) { KeyButton keycode = static_cast(xkey.keycode); if (!isRepeat) { // no press event follows so it's a plain release - LOG((CLOG_DEBUG1 "event: KeyRelease code=%d, state=0x%04x", keycode, + LOG( + (CLOG_DEBUG1 "event: KeyRelease code=%d, state=0x%04x", keycode, xkey.state)); - m_keyState->sendKeyEvent(getEventTarget(), false, false, key, mask, 1, - keycode); + m_keyState->sendKeyEvent( + getEventTarget(), false, false, key, mask, 1, keycode); } else { // found a press event following so it's a repeat. // we could attempt to count the already queued // repeats but we'll just send a repeat of 1. // note that we discard the press event. - LOG((CLOG_DEBUG1 "event: repeat code=%d, state=0x%04x", keycode, + LOG( + (CLOG_DEBUG1 "event: repeat code=%d, state=0x%04x", keycode, xkey.state)); - m_keyState->sendKeyEvent(getEventTarget(), false, true, key, mask, 1, - keycode); + m_keyState->sendKeyEvent( + getEventTarget(), false, true, key, mask, 1, keycode); } } } @@ -1475,8 +1517,9 @@ void XWindowsScreen::onMousePress(const XButtonEvent &xbutton) { ButtonID button = mapButtonFromX(&xbutton); KeyModifierMask mask = m_keyState->mapModifiersFromX(xbutton.state); if (button != kButtonNone) { - sendEvent(m_events->forIPrimaryScreen().buttonDown(), - ButtonInfo::alloc(button, mask)); + sendEvent( + m_events->forIPrimaryScreen().buttonDown(), + ButtonInfo::alloc(button, mask)); } } @@ -1485,8 +1528,9 @@ void XWindowsScreen::onMouseRelease(const XButtonEvent &xbutton) { ButtonID button = mapButtonFromX(&xbutton); KeyModifierMask mask = m_keyState->mapModifiersFromX(xbutton.state); if (button != kButtonNone) { - sendEvent(m_events->forIPrimaryScreen().buttonUp(), - ButtonInfo::alloc(button, mask)); + sendEvent( + m_events->forIPrimaryScreen().buttonUp(), + ButtonInfo::alloc(button, mask)); } else if (xbutton.button == 4) { // wheel forward (away from user) sendEvent(m_events->forIPrimaryScreen().wheel(), WheelInfo::alloc(0, 120)); @@ -1498,8 +1542,8 @@ void XWindowsScreen::onMouseRelease(const XButtonEvent &xbutton) { } void XWindowsScreen::onMouseMove(const XMotionEvent &xmotion) { - LOG((CLOG_DEBUG2 "event: MotionNotify %d,%d", xmotion.x_root, - xmotion.y_root)); + LOG(( + CLOG_DEBUG2 "event: MotionNotify %d,%d", xmotion.x_root, xmotion.y_root)); // compute motion delta (relative to the last known // mouse position) @@ -1528,8 +1572,9 @@ void XWindowsScreen::onMouseMove(const XMotionEvent &xmotion) { cntr = 0; } else if (m_isOnScreen) { // motion on primary screen - sendEvent(m_events->forIPrimaryScreen().motionOnPrimary(), - MotionInfo::alloc(m_xCursor, m_yCursor)); + sendEvent( + m_events->forIPrimaryScreen().motionOnPrimary(), + MotionInfo::alloc(m_xCursor, m_yCursor)); } else { // motion on secondary screen. warp mouse back to // center. @@ -1558,8 +1603,9 @@ void XWindowsScreen::onMouseMove(const XMotionEvent &xmotion) { // warping to the primary screen's enter position, // effectively overriding it. if (x != 0 || y != 0) { - sendEvent(m_events->forIPrimaryScreen().motionOnSecondary(), - MotionInfo::alloc(x, y)); + sendEvent( + m_events->forIPrimaryScreen().motionOnSecondary(), + MotionInfo::alloc(x, y)); } } } @@ -1610,8 +1656,8 @@ ClipboardID XWindowsScreen::getClipboardID(Atom selection) const { return kClipboardEnd; } -void XWindowsScreen::processClipboardRequest(Window requestor, Time time, - Atom property) { +void XWindowsScreen::processClipboardRequest( + Window requestor, Time time, Atom property) { // check every clipboard until one returns success for (ClipboardID id = 0; id < kClipboardEnd; ++id) { if (m_clipboard[id] != NULL && @@ -1880,8 +1926,8 @@ bool XWindowsScreen::grabMouseAndKeyboard() { do { // keyboard first do { - result = XGrabKeyboard(m_display, m_window, True, GrabModeAsync, - GrabModeAsync, CurrentTime); + result = XGrabKeyboard( + m_display, m_window, True, GrabModeAsync, GrabModeAsync, CurrentTime); assert(result != GrabNotViewable); if (result != GrabSuccess) { LOG((CLOG_DEBUG2 "waiting to grab keyboard")); @@ -1895,8 +1941,9 @@ bool XWindowsScreen::grabMouseAndKeyboard() { LOG((CLOG_DEBUG2 "grabbed keyboard")); // now the mouse --- use event_mask to get EnterNotify, LeaveNotify events - result = XGrabPointer(m_display, m_window, False, event_mask, GrabModeAsync, - GrabModeAsync, m_window, None, CurrentTime); + result = XGrabPointer( + m_display, m_window, False, event_mask, GrabModeAsync, GrabModeAsync, + m_window, None, CurrentTime); assert(result != GrabNotViewable); if (result != GrabSuccess) { // back off to avoid grab deadlock @@ -1944,19 +1991,21 @@ void XWindowsScreen::refreshKeyboard(XEvent *event) { // XWindowsScreen::HotKeyItem::HotKeyItem(int keycode, unsigned int mask) - : m_keycode(keycode), m_mask(mask) { + : m_keycode(keycode), + m_mask(mask) { // do nothing } bool XWindowsScreen::HotKeyItem::operator<(const HotKeyItem &x) const { - return (m_keycode < x.m_keycode || - (m_keycode == x.m_keycode && m_mask < x.m_mask)); + return ( + m_keycode < x.m_keycode || + (m_keycode == x.m_keycode && m_mask < x.m_mask)); } bool XWindowsScreen::detectXI2() { int event, error; - return XQueryExtension(m_display, "XInputExtension", &xi_opcode, &event, - &error); + return XQueryExtension( + m_display, "XInputExtension", &xi_opcode, &event, &error); } #ifdef HAVE_XI2 diff --git a/src/lib/platform/XWindowsScreen.h b/src/lib/platform/XWindowsScreen.h index 4c7a3b2c1..1dae62c08 100644 --- a/src/lib/platform/XWindowsScreen.h +++ b/src/lib/platform/XWindowsScreen.h @@ -39,11 +39,11 @@ class XWindowsScreenSaver; //! Implementation of IPlatformScreen for X11 class XWindowsScreen : public PlatformScreen { public: - XWindowsScreen(const char *displayName, bool isPrimary, - bool disableXInitThreads, int mouseScrollDelta, - IEventQueue *events, - lib::synergy::ClientScrollDirection m_clientScrollDirection = - lib::synergy::ClientScrollDirection::SERVER); + XWindowsScreen( + const char *displayName, bool isPrimary, bool disableXInitThreads, + int mouseScrollDelta, IEventQueue *events, + lib::synergy::ClientScrollDirection m_clientScrollDirection = + lib::synergy::ClientScrollDirection::SERVER); virtual ~XWindowsScreen(); //! @name manipulators @@ -54,8 +54,8 @@ public: // 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 + getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const; virtual void getCursorPos(SInt32 &x, SInt32 &y) const; // IPrimaryScreen overrides diff --git a/src/lib/platform/XWindowsScreenSaver.cpp b/src/lib/platform/XWindowsScreenSaver.cpp index 07f03db9c..3680b6d76 100644 --- a/src/lib/platform/XWindowsScreenSaver.cpp +++ b/src/lib/platform/XWindowsScreenSaver.cpp @@ -58,12 +58,18 @@ extern Status DPMSInfo(Display *, CARD16 *, BOOL *); // XWindowsScreenSaver // -XWindowsScreenSaver::XWindowsScreenSaver(Display *display, Window window, - void *eventTarget, IEventQueue *events) - : m_display(display), m_xscreensaverSink(window), - m_eventTarget(eventTarget), m_xscreensaver(None), - m_xscreensaverActive(false), m_dpms(false), m_disabled(false), - m_suppressDisable(false), m_disableTimer(NULL), m_disablePos(0), +XWindowsScreenSaver::XWindowsScreenSaver( + Display *display, Window window, void *eventTarget, IEventQueue *events) + : m_display(display), + m_xscreensaverSink(window), + m_eventTarget(eventTarget), + m_xscreensaver(None), + m_xscreensaverActive(false), + m_dpms(false), + m_disabled(false), + m_suppressDisable(false), + m_disableTimer(NULL), + m_disablePos(0), m_events(events) { // get atoms m_atomScreenSaver = XInternAtom(m_display, "SCREENSAVER", False); @@ -100,8 +106,8 @@ XWindowsScreenSaver::XWindowsScreenSaver(Display *display, Window window, } // get the built-in settings - XGetScreenSaver(m_display, &m_timeout, &m_interval, &m_preferBlanking, - &m_allowExposures); + XGetScreenSaver( + m_display, &m_timeout, &m_interval, &m_preferBlanking, &m_allowExposures); // get the DPMS settings m_dpmsEnabled = isDPMSEnabled(); @@ -112,9 +118,10 @@ XWindowsScreenSaver::XWindowsScreenSaver(Display *display, Window window, } // install disable timer event handler - m_events->adoptHandler(Event::kTimer, this, - new TMethodEventJob( - this, &XWindowsScreenSaver::handleDisableTimer)); + m_events->adoptHandler( + Event::kTimer, this, + new TMethodEventJob( + this, &XWindowsScreenSaver::handleDisableTimer)); } XWindowsScreenSaver::~XWindowsScreenSaver() { @@ -126,8 +133,8 @@ XWindowsScreenSaver::~XWindowsScreenSaver() { if (m_display != NULL) { enableDPMS(m_dpmsEnabled); - XSetScreenSaver(m_display, m_timeout, m_interval, m_preferBlanking, - m_allowExposures); + XSetScreenSaver( + m_display, m_timeout, m_interval, m_preferBlanking, m_allowExposures); clearWatchForXScreenSaver(); XWindowsUtil::ErrorLock lock(m_display); XSelectInput(m_display, DefaultRootWindow(m_display), m_rootEventMask); @@ -203,8 +210,8 @@ void XWindowsScreenSaver::enable() { updateDisableTimer(); // for built-in X screen saver - XSetScreenSaver(m_display, m_timeout, m_interval, m_preferBlanking, - m_allowExposures); + XSetScreenSaver( + m_display, m_timeout, m_interval, m_preferBlanking, m_allowExposures); // for DPMS enableDPMS(m_dpmsEnabled); @@ -216,8 +223,8 @@ void XWindowsScreenSaver::disable() { updateDisableTimer(); // use built-in X screen saver - XGetScreenSaver(m_display, &m_timeout, &m_interval, &m_preferBlanking, - &m_allowExposures); + XGetScreenSaver( + m_display, &m_timeout, &m_interval, &m_preferBlanking, &m_allowExposures); XSetScreenSaver(m_display, 0, m_interval, m_preferBlanking, m_allowExposures); // for DPMS @@ -344,15 +351,16 @@ void XWindowsScreenSaver::setXScreenSaver(Window window) { bool XWindowsScreenSaver::isXScreenSaver(Window w) const { // check for m_atomScreenSaverVersion string property Atom type; - return (XWindowsUtil::getWindowProperty(m_display, w, - m_atomScreenSaverVersion, NULL, &type, - NULL, False) && - type == XA_STRING); + return ( + XWindowsUtil::getWindowProperty( + m_display, w, m_atomScreenSaverVersion, NULL, &type, NULL, False) && + type == XA_STRING); } void XWindowsScreenSaver::setXScreenSaverActive(bool activated) { if (m_xscreensaverActive != activated) { - LOG((CLOG_DEBUG "xscreensaver %s on window 0x%08x", + LOG( + (CLOG_DEBUG "xscreensaver %s on window 0x%08x", activated ? "activated" : "deactivated", m_xscreensaver)); m_xscreensaverActive = activated; @@ -367,15 +375,15 @@ void XWindowsScreenSaver::setXScreenSaverActive(bool activated) { m_events->addEvent(Event( m_events->forIPrimaryScreen().screensaverActivated(), m_eventTarget)); } else { - m_events->addEvent( - Event(m_events->forIPrimaryScreen().screensaverDeactivated(), - m_eventTarget)); + m_events->addEvent(Event( + m_events->forIPrimaryScreen().screensaverDeactivated(), + m_eventTarget)); } } } -void XWindowsScreenSaver::sendXScreenSaverCommand(Atom cmd, long arg1, - long arg2) { +void XWindowsScreenSaver::sendXScreenSaverCommand( + Atom cmd, long arg1, long arg2) { XEvent event; event.xclient.type = ClientMessage; event.xclient.display = m_display; @@ -388,8 +396,8 @@ void XWindowsScreenSaver::sendXScreenSaverCommand(Atom cmd, long arg1, event.xclient.data.l[3] = 0; event.xclient.data.l[4] = 0; - LOG((CLOG_DEBUG "send xscreensaver command: %d %d %d", (long)cmd, arg1, - arg2)); + LOG(( + CLOG_DEBUG "send xscreensaver command: %d %d %d", (long)cmd, arg1, arg2)); bool error = false; { XWindowsUtil::ErrorLock lock(m_display, &error); @@ -448,8 +456,8 @@ void XWindowsScreenSaver::addWatchXScreenSaver(Window window) { error = false; { XWindowsUtil::ErrorLock lock(m_display, &error); - XSelectInput(m_display, window, - attr.your_event_mask | PropertyChangeMask); + XSelectInput( + m_display, window, attr.your_event_mask | PropertyChangeMask); } if (!error) { // if successful then add the window to our list diff --git a/src/lib/platform/XWindowsScreenSaver.h b/src/lib/platform/XWindowsScreenSaver.h index 4c05d30c1..e39e19d14 100644 --- a/src/lib/platform/XWindowsScreenSaver.h +++ b/src/lib/platform/XWindowsScreenSaver.h @@ -34,8 +34,8 @@ class EventQueueTimer; //! X11 screen saver implementation class XWindowsScreenSaver : public IScreenSaver { public: - XWindowsScreenSaver(Display *, Window, void *eventTarget, - IEventQueue *events); + XWindowsScreenSaver( + Display *, Window, void *eventTarget, IEventQueue *events); XWindowsScreenSaver(XWindowsScreenSaver const &) = delete; XWindowsScreenSaver(XWindowsScreenSaver &&) = delete; virtual ~XWindowsScreenSaver(); diff --git a/src/lib/platform/XWindowsUtil.cpp b/src/lib/platform/XWindowsUtil.cpp index ceb412439..d4e09b726 100644 --- a/src/lib/platform/XWindowsUtil.cpp +++ b/src/lib/platform/XWindowsUtil.cpp @@ -1533,9 +1533,9 @@ static const KeySym s_map1008FF[] = { XWindowsUtil::KeySymMap XWindowsUtil::s_keySymToUCS4; -bool XWindowsUtil::getWindowProperty(Display *display, Window window, - Atom property, String *data, Atom *type, - SInt32 *format, bool deleteProperty) { +bool XWindowsUtil::getWindowProperty( + Display *display, Window window, Atom property, String *data, Atom *type, + SInt32 *format, bool deleteProperty) { assert(display != NULL); Atom actualType; @@ -1553,9 +1553,10 @@ bool XWindowsUtil::getWindowProperty(Display *display, Window window, // get more data unsigned long numItems; unsigned char *rawData; - if (XGetWindowProperty(display, window, property, offset, length, False, - AnyPropertyType, &actualType, &actualDatumSize, - &numItems, &bytesLeft, &rawData) != Success || + if (XGetWindowProperty( + display, window, property, offset, length, False, AnyPropertyType, + &actualType, &actualDatumSize, &numItems, &bytesLeft, + &rawData) != Success || actualType == None || actualDatumSize == 0) { // failed okay = false; @@ -1608,19 +1609,21 @@ bool XWindowsUtil::getWindowProperty(Display *display, Window window, } if (okay) { - LOG((CLOG_DEBUG2 "read property %d on window 0x%08x: bytes=%d", property, + LOG( + (CLOG_DEBUG2 "read property %d on window 0x%08x: bytes=%d", property, window, (data == NULL) ? 0 : data->size())); return true; } else { - LOG((CLOG_DEBUG2 "can't read property %d on window 0x%08x", property, + LOG( + (CLOG_DEBUG2 "can't read property %d on window 0x%08x", property, window)); return false; } } -bool XWindowsUtil::setWindowProperty(Display *display, Window window, - Atom property, const void *vdata, - UInt32 size, Atom type, SInt32 format) { +bool XWindowsUtil::setWindowProperty( + Display *display, Window window, Atom property, const void *vdata, + UInt32 size, Atom type, SInt32 format) { const UInt32 length = 4 * XMaxRequestSize(display); const unsigned char *data = static_cast(vdata); UInt32 datumSize = static_cast(format / 8); @@ -1640,8 +1643,9 @@ bool XWindowsUtil::setWindowProperty(Display *display, Window window, } // send first chunk - XChangeProperty(display, window, property, type, format, PropModeReplace, - data, chunkSize / datumSize); + XChangeProperty( + display, window, property, type, format, PropModeReplace, data, + chunkSize / datumSize); // append remaining chunks data += chunkSize; @@ -1651,8 +1655,9 @@ bool XWindowsUtil::setWindowProperty(Display *display, Window window, if (chunkSize > length) { chunkSize = length; } - XChangeProperty(display, window, property, type, format, PropModeAppend, - data, chunkSize / datumSize); + XChangeProperty( + display, window, property, type, format, PropModeAppend, data, + chunkSize / datumSize); data += chunkSize; size -= chunkSize; } @@ -1672,8 +1677,8 @@ Time XWindowsUtil::getCurrentTime(Display *display, Window window) { // do a zero-length append to get the current time unsigned char dummy; - XChangeProperty(display, window, atom, XA_INTEGER, 8, PropModeAppend, &dummy, - 0); + XChangeProperty( + display, window, atom, XA_INTEGER, 8, PropModeAppend, &dummy, 0); // look for property notify events with the following PropertyNotifyPredicateInfo filter; @@ -1682,8 +1687,9 @@ Time XWindowsUtil::getCurrentTime(Display *display, Window window) { // wait for reply XEvent xevent; - XIfEvent(display, &xevent, &XWindowsUtil::propertyNotifyPredicate, - (XPointer)&filter); + XIfEvent( + display, &xevent, &XWindowsUtil::propertyNotifyPredicate, + (XPointer)&filter); assert(xevent.type == PropertyNotify); assert(xevent.xproperty.window == window); assert(xevent.xproperty.atom == atom); @@ -1851,8 +1857,8 @@ String XWindowsUtil::atomToString(Display *display, Atom atom) { } } -String XWindowsUtil::atomsToString(Display *display, const Atom *atom, - UInt32 num) { +String +XWindowsUtil::atomsToString(Display *display, const Atom *atom, UInt32 num) { char **names = new char *[num]; bool error = false; XWindowsUtil::ErrorLock lock(display, &error); @@ -1893,16 +1899,17 @@ void XWindowsUtil::appendAtomData(String &data, Atom atom) { } void XWindowsUtil::replaceAtomData(String &data, UInt32 index, Atom atom) { - data.replace(index * sizeof(Atom), sizeof(Atom), - reinterpret_cast(&atom), sizeof(Atom)); + data.replace( + index * sizeof(Atom), sizeof(Atom), reinterpret_cast(&atom), + sizeof(Atom)); } void XWindowsUtil::appendTimeData(String &data, Time time) { data.append(reinterpret_cast(&time), sizeof(Time)); } -Bool XWindowsUtil::propertyNotifyPredicate(Display *, XEvent *xevent, - XPointer arg) { +Bool XWindowsUtil::propertyNotifyPredicate( + Display *, XEvent *xevent, XPointer arg) { PropertyNotifyPredicateInfo *filter = reinterpret_cast(arg); return (xevent->type == PropertyNotify && @@ -1936,8 +1943,8 @@ XWindowsUtil::ErrorLock::ErrorLock(Display *display, bool *flag) install(&XWindowsUtil::ErrorLock::saveHandler, flag); } -XWindowsUtil::ErrorLock::ErrorLock(Display *display, ErrorHandler handler, - void *data) +XWindowsUtil::ErrorLock::ErrorLock( + Display *display, ErrorHandler handler, void *data) : m_display(display) { install(handler, data); } @@ -1967,8 +1974,8 @@ void XWindowsUtil::ErrorLock::install(ErrorHandler handler, void *data) { s_top = this; } -int XWindowsUtil::ErrorLock::internalHandler(Display *display, - XErrorEvent *event) { +int XWindowsUtil::ErrorLock::internalHandler( + Display *display, XErrorEvent *event) { if (s_top != NULL && s_top->m_handler != NULL) { s_top->m_handler(display, event, s_top->m_userData); } @@ -1979,8 +1986,8 @@ void XWindowsUtil::ErrorLock::ignoreHandler(Display *, XErrorEvent *e, void *) { LOG((CLOG_DEBUG1 "ignoring X error: %d", e->error_code)); } -void XWindowsUtil::ErrorLock::saveHandler(Display *display, XErrorEvent *e, - void *flag) { +void XWindowsUtil::ErrorLock::saveHandler( + Display *display, XErrorEvent *e, void *flag) { char errtxt[1024]; XGetErrorText(display, e->error_code, errtxt, 1023); LOG((CLOG_DEBUG1 "flagging X error: %d - %.1023s", e->error_code, errtxt)); diff --git a/src/lib/platform/XWindowsUtil.h b/src/lib/platform/XWindowsUtil.h index 47a1ff8a4..b5591dcb4 100644 --- a/src/lib/platform/XWindowsUtil.h +++ b/src/lib/platform/XWindowsUtil.h @@ -42,18 +42,18 @@ public: 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); + 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); + static bool setWindowProperty( + Display *, Window window, Atom property, const void *data, UInt32 size, + Atom type, SInt32 format); //! Get X server time /*! diff --git a/src/lib/server/BaseClientProxy.cpp b/src/lib/server/BaseClientProxy.cpp index 20f65fa0c..a1c18f8ed 100644 --- a/src/lib/server/BaseClientProxy.cpp +++ b/src/lib/server/BaseClientProxy.cpp @@ -23,7 +23,9 @@ // BaseClientProxy::BaseClientProxy(const String &name) - : m_name(name), m_x(0), m_y(0) { + : m_name(name), + m_x(0), + m_y(0) { // do nothing } diff --git a/src/lib/server/BaseClientProxy.h b/src/lib/server/BaseClientProxy.h index 7a703b89e..a64ab19b1 100644 --- a/src/lib/server/BaseClientProxy.h +++ b/src/lib/server/BaseClientProxy.h @@ -64,20 +64,21 @@ public: // 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 + 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 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 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; @@ -87,8 +88,8 @@ public: 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 + 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; diff --git a/src/lib/server/ClientListener.cpp b/src/lib/server/ClientListener.cpp index c2148d96e..af0709011 100644 --- a/src/lib/server/ClientListener.cpp +++ b/src/lib/server/ClientListener.cpp @@ -34,11 +34,14 @@ // ClientListener // -ClientListener::ClientListener(const NetworkAddress &address, - ISocketFactory *socketFactory, - IEventQueue *events, bool enableCrypto) - : m_socketFactory(socketFactory), m_server(NULL), m_events(events), - m_useSecureNetwork(enableCrypto), m_address(address) { +ClientListener::ClientListener( + const NetworkAddress &address, ISocketFactory *socketFactory, + IEventQueue *events, bool enableCrypto) + : m_socketFactory(socketFactory), + m_server(NULL), + m_events(events), + m_useSecureNetwork(enableCrypto), + m_address(address) { assert(m_socketFactory != NULL); try { @@ -80,9 +83,10 @@ void ClientListener::start() { m_useSecureNetwork, ARCH->getAddrFamily(m_address.getAddress())); // setup event handler - m_events->adoptHandler(m_events->forIListenSocket().connecting(), m_listen, - new TMethodEventJob( - this, &ClientListener::handleClientConnecting)); + m_events->adoptHandler( + m_events->forIListenSocket().connecting(), m_listen, + new TMethodEventJob( + this, &ClientListener::handleClientConnecting)); // bind listen address LOG((CLOG_DEBUG1 "binding listen socket")); @@ -96,10 +100,10 @@ void ClientListener::stop() { for (NewClients::iterator index = m_newClients.begin(); index != m_newClients.end(); ++index) { ClientProxyUnknown *client = *index; - m_events->removeHandler(m_events->forClientProxyUnknown().success(), - client); - m_events->removeHandler(m_events->forClientProxyUnknown().failure(), - client); + m_events->removeHandler( + m_events->forClientProxyUnknown().success(), client); + m_events->removeHandler( + m_events->forClientProxyUnknown().failure(), client); m_events->removeHandler(m_events->forClientProxy().disconnected(), client); delete client; } @@ -118,10 +122,10 @@ void ClientListener::stop() { void ClientListener::removeUnknownClient(ClientProxyUnknown *unknownClient) { if (unknownClient) { - m_events->removeHandler(m_events->forClientProxyUnknown().success(), - unknownClient); - m_events->removeHandler(m_events->forClientProxyUnknown().failure(), - unknownClient); + m_events->removeHandler( + m_events->forClientProxyUnknown().success(), unknownClient); + m_events->removeHandler( + m_events->forClientProxyUnknown().failure(), unknownClient); m_newClients.erase(unknownClient); delete unknownClient; } @@ -152,8 +156,8 @@ void ClientListener::handleClientConnecting(const Event &, void *) { // When using non SSL, server accepts clients immediately, while SSL // has to call secure accept which may require retry if (!m_useSecureNetwork) { - m_events->addEvent(Event(m_events->forClientListener().accepted(), - socket->getEventTarget())); + m_events->addEvent(Event( + m_events->forClientListener().accepted(), socket->getEventTarget())); } } @@ -222,8 +226,8 @@ void ClientListener::handleClientDisconnected(const Event &, void *vclient) { i != n; ++i) { if (*i == client) { m_waitingClients.erase(i); - m_events->removeHandler(m_events->forClientProxy().disconnected(), - client); + m_events->removeHandler( + m_events->forClientProxy().disconnected(), client); // pull out the socket before deleting the client so // we know which socket we no longer need diff --git a/src/lib/server/ClientListener.h b/src/lib/server/ClientListener.h index 8d93e646d..f3ae2b0aa 100644 --- a/src/lib/server/ClientListener.h +++ b/src/lib/server/ClientListener.h @@ -36,8 +36,9 @@ class IDataSocket; class ClientListener { public: // The factories are adopted. - ClientListener(const NetworkAddress &, ISocketFactory *, IEventQueue *events, - bool enableCrypto); + ClientListener( + const NetworkAddress &, ISocketFactory *, IEventQueue *events, + bool enableCrypto); ClientListener(ClientListener const &) = delete; ClientListener(ClientListener &&) = delete; ~ClientListener(); diff --git a/src/lib/server/ClientProxy.cpp b/src/lib/server/ClientProxy.cpp index b6644b073..26d24420f 100644 --- a/src/lib/server/ClientProxy.cpp +++ b/src/lib/server/ClientProxy.cpp @@ -28,7 +28,8 @@ // ClientProxy::ClientProxy(const String &name, synergy::IStream *stream) - : BaseClientProxy(name), m_stream(stream) {} + : BaseClientProxy(name), + m_stream(stream) {} ClientProxy::~ClientProxy() { delete m_stream; } diff --git a/src/lib/server/ClientProxy.h b/src/lib/server/ClientProxy.h index 4dfa3181c..bc2e93d96 100644 --- a/src/lib/server/ClientProxy.h +++ b/src/lib/server/ClientProxy.h @@ -65,20 +65,22 @@ public: // 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 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; + 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 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; @@ -88,8 +90,8 @@ public: 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 + 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; diff --git a/src/lib/server/ClientProxy1_0.cpp b/src/lib/server/ClientProxy1_0.cpp index 50b3c78d4..6f722fcb8 100644 --- a/src/lib/server/ClientProxy1_0.cpp +++ b/src/lib/server/ClientProxy1_0.cpp @@ -31,30 +31,33 @@ // ClientProxy1_0 // -ClientProxy1_0::ClientProxy1_0(const String &name, synergy::IStream *stream, - IEventQueue *events) - : ClientProxy(name, stream), m_heartbeatTimer(NULL), - m_parser(&ClientProxy1_0::parseHandshakeMessage), m_events(events) { +ClientProxy1_0::ClientProxy1_0( + const String &name, synergy::IStream *stream, IEventQueue *events) + : ClientProxy(name, stream), + m_heartbeatTimer(NULL), + m_parser(&ClientProxy1_0::parseHandshakeMessage), + m_events(events) { // install event handlers - m_events->adoptHandler(m_events->forIStream().inputReady(), - stream->getEventTarget(), - new TMethodEventJob( - this, &ClientProxy1_0::handleData, NULL)); - m_events->adoptHandler(m_events->forIStream().outputError(), - stream->getEventTarget(), - new TMethodEventJob( - this, &ClientProxy1_0::handleWriteError, NULL)); - m_events->adoptHandler(m_events->forIStream().inputShutdown(), - stream->getEventTarget(), - new TMethodEventJob( - this, &ClientProxy1_0::handleDisconnect, NULL)); - m_events->adoptHandler(m_events->forIStream().outputShutdown(), - stream->getEventTarget(), - new TMethodEventJob( - this, &ClientProxy1_0::handleWriteError, NULL)); - m_events->adoptHandler(Event::kTimer, this, - new TMethodEventJob( - this, &ClientProxy1_0::handleFlatline, NULL)); + m_events->adoptHandler( + m_events->forIStream().inputReady(), stream->getEventTarget(), + new TMethodEventJob( + this, &ClientProxy1_0::handleData, NULL)); + m_events->adoptHandler( + m_events->forIStream().outputError(), stream->getEventTarget(), + new TMethodEventJob( + this, &ClientProxy1_0::handleWriteError, NULL)); + m_events->adoptHandler( + m_events->forIStream().inputShutdown(), stream->getEventTarget(), + new TMethodEventJob( + this, &ClientProxy1_0::handleDisconnect, NULL)); + m_events->adoptHandler( + m_events->forIStream().outputShutdown(), stream->getEventTarget(), + new TMethodEventJob( + this, &ClientProxy1_0::handleWriteError, NULL)); + m_events->adoptHandler( + Event::kTimer, this, + new TMethodEventJob( + this, &ClientProxy1_0::handleFlatline, NULL)); setHeartbeatRate(kHeartRate, kHeartRate * kHeartBeatsUntilDeath); @@ -73,14 +76,14 @@ void ClientProxy1_0::disconnect() { void ClientProxy1_0::removeHandlers() { // uninstall event handlers - m_events->removeHandler(m_events->forIStream().inputReady(), - getStream()->getEventTarget()); - m_events->removeHandler(m_events->forIStream().outputError(), - getStream()->getEventTarget()); - m_events->removeHandler(m_events->forIStream().inputShutdown(), - getStream()->getEventTarget()); - m_events->removeHandler(m_events->forIStream().outputShutdown(), - getStream()->getEventTarget()); + m_events->removeHandler( + m_events->forIStream().inputReady(), getStream()->getEventTarget()); + m_events->removeHandler( + m_events->forIStream().outputError(), getStream()->getEventTarget()); + m_events->removeHandler( + m_events->forIStream().inputShutdown(), getStream()->getEventTarget()); + m_events->removeHandler( + m_events->forIStream().outputShutdown(), getStream()->getEventTarget()); m_events->removeHandler(Event::kTimer, this); // remove timer @@ -121,17 +124,20 @@ void ClientProxy1_0::handleData(const Event &, void *) { while (n != 0) { // verify we got an entire code if (n != 4) { - LOG((CLOG_ERR "incomplete message from \"%s\": %d bytes", + LOG( + (CLOG_ERR "incomplete message from \"%s\": %d bytes", getName().c_str(), n)); disconnect(); return; } // parse message - LOG((CLOG_DEBUG2 "msg from \"%s\": %c%c%c%c", getName().c_str(), code[0], + LOG( + (CLOG_DEBUG2 "msg from \"%s\": %c%c%c%c", getName().c_str(), code[0], code[1], code[2], code[3])); if (!(this->*m_parser)(code)) { - LOG((CLOG_ERR "invalid message from client \"%s\": %c%c%c%c", + LOG( + (CLOG_ERR "invalid message from client \"%s\": %c%c%c%c", getName().c_str(), code[0], code[1], code[2], code[3])); // not possible to determine message boundaries // read the whole stream to discard unkonwn data @@ -206,8 +212,8 @@ bool ClientProxy1_0::getClipboard(ClipboardID id, IClipboard *clipboard) const { return true; } -void ClientProxy1_0::getShape(SInt32 &x, SInt32 &y, SInt32 &w, - SInt32 &h) const { +void ClientProxy1_0::getShape( + SInt32 &x, SInt32 &y, SInt32 &w, SInt32 &h) const { x = m_info.m_x; y = m_info.m_y; w = m_info.m_w; @@ -220,9 +226,10 @@ void ClientProxy1_0::getCursorPos(SInt32 &x, SInt32 &y) const { y = m_info.m_my; } -void ClientProxy1_0::enter(SInt32 xAbs, SInt32 yAbs, UInt32 seqNum, - KeyModifierMask mask, bool) { - LOG((CLOG_DEBUG1 "send enter to \"%s\", %d,%d %d %04x", getName().c_str(), +void ClientProxy1_0::enter( + SInt32 xAbs, SInt32 yAbs, UInt32 seqNum, KeyModifierMask mask, bool) { + LOG( + (CLOG_DEBUG1 "send enter to \"%s\", %d,%d %d %04x", getName().c_str(), xAbs, yAbs, seqNum, mask)); ProtocolUtil::writef(getStream(), kMsgCEnter, xAbs, yAbs, seqNum, mask); } @@ -251,28 +258,32 @@ void ClientProxy1_0::setClipboardDirty(ClipboardID id, bool dirty) { m_clipboard[id].m_dirty = dirty; } -void ClientProxy1_0::keyDown(KeyID key, KeyModifierMask mask, KeyButton, - const String &) { - LOG((CLOG_DEBUG1 "send key down to \"%s\" id=%d, mask=0x%04x", +void ClientProxy1_0::keyDown( + KeyID key, KeyModifierMask mask, KeyButton, const String &) { + LOG( + (CLOG_DEBUG1 "send key down to \"%s\" id=%d, mask=0x%04x", getName().c_str(), key, mask)); ProtocolUtil::writef(getStream(), kMsgDKeyDown1_0, key, mask); } -void ClientProxy1_0::keyRepeat(KeyID key, KeyModifierMask mask, SInt32 count, - KeyButton, const String &) { - LOG((CLOG_DEBUG1 "send key repeat to \"%s\" id=%d, mask=0x%04x, count=%d", +void ClientProxy1_0::keyRepeat( + KeyID key, KeyModifierMask mask, SInt32 count, KeyButton, const String &) { + LOG( + (CLOG_DEBUG1 "send key repeat to \"%s\" id=%d, mask=0x%04x, count=%d", getName().c_str(), key, mask, count)); ProtocolUtil::writef(getStream(), kMsgDKeyRepeat1_0, key, mask, count); } void ClientProxy1_0::keyUp(KeyID key, KeyModifierMask mask, KeyButton) { - LOG((CLOG_DEBUG1 "send key up to \"%s\" id=%d, mask=0x%04x", + LOG( + (CLOG_DEBUG1 "send key up to \"%s\" id=%d, mask=0x%04x", getName().c_str(), key, mask)); ProtocolUtil::writef(getStream(), kMsgDKeyUp1_0, key, mask); } void ClientProxy1_0::mouseDown(ButtonID button) { - LOG((CLOG_DEBUG1 "send mouse down to \"%s\" id=%d", getName().c_str(), + LOG( + (CLOG_DEBUG1 "send mouse down to \"%s\" id=%d", getName().c_str(), button)); ProtocolUtil::writef(getStream(), kMsgDMouseDown, button); } @@ -283,7 +294,8 @@ void ClientProxy1_0::mouseUp(ButtonID button) { } void ClientProxy1_0::mouseMove(SInt32 xAbs, SInt32 yAbs) { - LOG((CLOG_DEBUG2 "send mouse move to \"%s\" %d,%d", getName().c_str(), xAbs, + LOG( + (CLOG_DEBUG2 "send mouse move to \"%s\" %d,%d", getName().c_str(), xAbs, yAbs)); ProtocolUtil::writef(getStream(), kMsgDMouseMove, xAbs, yAbs); } @@ -294,13 +306,13 @@ void ClientProxy1_0::mouseRelativeMove(SInt32, SInt32) { void ClientProxy1_0::mouseWheel(SInt32, SInt32 yDelta) { // clients prior to 1.3 only support the y axis - LOG((CLOG_DEBUG2 "send mouse wheel to \"%s\" %+d", getName().c_str(), - yDelta)); + LOG(( + CLOG_DEBUG2 "send mouse wheel to \"%s\" %+d", getName().c_str(), yDelta)); ProtocolUtil::writef(getStream(), kMsgDMouseWheel1_0, yDelta); } -void ClientProxy1_0::sendDragInfo(UInt32 fileCount, const char *info, - size_t size) { +void ClientProxy1_0::sendDragInfo( + UInt32 fileCount, const char *info, size_t size) { // ignore -- not supported in protocol 1.0 LOG((CLOG_DEBUG "draggingInfoSending not supported")); } @@ -322,7 +334,8 @@ void ClientProxy1_0::secureInputNotification(const String &app) const { } void ClientProxy1_0::screensaver(bool on) { - LOG((CLOG_DEBUG1 "send screen saver to \"%s\" on=%d", getName().c_str(), + LOG( + (CLOG_DEBUG1 "send screen saver to \"%s\" on=%d", getName().c_str(), on ? 1 : 0)); ProtocolUtil::writef(getStream(), kMsgCScreenSaver, on ? 1 : 0); } @@ -338,7 +351,8 @@ void ClientProxy1_0::resetOptions() { } void ClientProxy1_0::setOptions(const OptionsList &options) { - LOG((CLOG_DEBUG1 "send set options to \"%s\" size=%d", getName().c_str(), + LOG( + (CLOG_DEBUG1 "send set options to \"%s\" size=%d", getName().c_str(), options.size())); ProtocolUtil::writef(getStream(), kMsgDSetOptions, &options); @@ -359,11 +373,12 @@ void ClientProxy1_0::setOptions(const OptionsList &options) { bool ClientProxy1_0::recvInfo() { // parse the message SInt16 x, y, w, h, dummy1, mx, my; - if (!ProtocolUtil::readf(getStream(), kMsgDInfo + 4, &x, &y, &w, &h, &dummy1, - &mx, &my)) { + if (!ProtocolUtil::readf( + getStream(), kMsgDInfo + 4, &x, &y, &w, &h, &dummy1, &mx, &my)) { return false; } - LOG((CLOG_DEBUG "received client \"%s\" info shape=%d,%d %dx%d at %d,%d", + LOG( + (CLOG_DEBUG "received client \"%s\" info shape=%d,%d %dx%d at %d,%d", getName().c_str(), x, y, w, h, mx, my)); // validate @@ -401,7 +416,8 @@ bool ClientProxy1_0::recvGrabClipboard() { if (!ProtocolUtil::readf(getStream(), kMsgCClipboard + 4, &id, &seqNum)) { return false; } - LOG((CLOG_DEBUG "received client \"%s\" grabbed clipboard %d seqnum=%d", + LOG( + (CLOG_DEBUG "received client \"%s\" grabbed clipboard %d seqnum=%d", getName().c_str(), id, seqNum)); // validate @@ -413,8 +429,8 @@ bool ClientProxy1_0::recvGrabClipboard() { ClipboardInfo *info = new ClipboardInfo; info->m_id = id; info->m_sequenceNumber = seqNum; - m_events->addEvent(Event(m_events->forClipboard().clipboardGrabbed(), - getEventTarget(), info)); + m_events->addEvent(Event( + m_events->forClipboard().clipboardGrabbed(), getEventTarget(), info)); return true; } @@ -424,6 +440,8 @@ bool ClientProxy1_0::recvGrabClipboard() { // ClientProxy1_0::ClientClipboard::ClientClipboard() - : m_clipboard(), m_sequenceNumber(0), m_dirty(true) { + : m_clipboard(), + m_sequenceNumber(0), + m_dirty(true) { // do nothing } diff --git a/src/lib/server/ClientProxy1_0.h b/src/lib/server/ClientProxy1_0.h index 5c189b45f..7b327ea70 100644 --- a/src/lib/server/ClientProxy1_0.h +++ b/src/lib/server/ClientProxy1_0.h @@ -29,8 +29,8 @@ class IEventQueue; //! Proxy for client implementing protocol version 1.0 class ClientProxy1_0 : public ClientProxy { public: - ClientProxy1_0(const String &name, synergy::IStream *adoptedStream, - IEventQueue *events); + ClientProxy1_0( + const String &name, synergy::IStream *adoptedStream, IEventQueue *events); ClientProxy1_0(ClientProxy1_0 const &) = delete; ClientProxy1_0(ClientProxy1_0 &&) = delete; ~ClientProxy1_0(); @@ -40,20 +40,21 @@ public: // IScreen bool getClipboard(ClipboardID id, IClipboard *) const override; - void getShape(SInt32 &x, SInt32 &y, SInt32 &width, - SInt32 &height) 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; + 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 keyRepeat( + KeyID, KeyModifierMask, SInt32 count, KeyButton, const String &) override; void keyUp(KeyID, KeyModifierMask, KeyButton) override; void mouseDown(ButtonID) override; void mouseUp(ButtonID) override; diff --git a/src/lib/server/ClientProxy1_1.cpp b/src/lib/server/ClientProxy1_1.cpp index f1ea0d30a..c942b0628 100644 --- a/src/lib/server/ClientProxy1_1.cpp +++ b/src/lib/server/ClientProxy1_1.cpp @@ -28,8 +28,8 @@ // ClientProxy1_1 // -ClientProxy1_1::ClientProxy1_1(const String &name, synergy::IStream *stream, - IEventQueue *events) +ClientProxy1_1::ClientProxy1_1( + const String &name, synergy::IStream *stream, IEventQueue *events) : ClientProxy1_0(name, stream, events) { // do nothing } @@ -38,24 +38,28 @@ ClientProxy1_1::~ClientProxy1_1() { // do nothing } -void ClientProxy1_1::keyDown(KeyID key, KeyModifierMask mask, KeyButton button, - const String &) { - LOG((CLOG_DEBUG1 "send key down to \"%s\" id=%d, mask=0x%04x, button=0x%04x", +void ClientProxy1_1::keyDown( + KeyID key, KeyModifierMask mask, KeyButton button, const String &) { + LOG( + (CLOG_DEBUG1 "send key down to \"%s\" id=%d, mask=0x%04x, button=0x%04x", getName().c_str(), key, mask, button)); ProtocolUtil::writef(getStream(), kMsgDKeyDown, key, mask, button); } -void ClientProxy1_1::keyRepeat(KeyID key, KeyModifierMask mask, SInt32 count, - KeyButton button, const String &lang) { - LOG((CLOG_DEBUG1 "send key repeat to \"%s\" id=%d, mask=0x%04x, count=%d, " +void ClientProxy1_1::keyRepeat( + KeyID key, KeyModifierMask mask, SInt32 count, KeyButton button, + const String &lang) { + LOG( + (CLOG_DEBUG1 "send key repeat to \"%s\" id=%d, mask=0x%04x, count=%d, " "button=0x%04x, lang=\"%s\"", getName().c_str(), key, mask, count, button, lang.c_str())); - ProtocolUtil::writef(getStream(), kMsgDKeyRepeat, key, mask, count, button, - &lang); + ProtocolUtil::writef( + getStream(), kMsgDKeyRepeat, key, mask, count, button, &lang); } void ClientProxy1_1::keyUp(KeyID key, KeyModifierMask mask, KeyButton button) { - LOG((CLOG_DEBUG1 "send key up to \"%s\" id=%d, mask=0x%04x, button=0x%04x", + LOG( + (CLOG_DEBUG1 "send key up to \"%s\" id=%d, mask=0x%04x, button=0x%04x", getName().c_str(), key, mask, button)); ProtocolUtil::writef(getStream(), kMsgDKeyUp, key, mask, button); } diff --git a/src/lib/server/ClientProxy1_1.h b/src/lib/server/ClientProxy1_1.h index 9c07f5ff7..7fc334c11 100644 --- a/src/lib/server/ClientProxy1_1.h +++ b/src/lib/server/ClientProxy1_1.h @@ -23,13 +23,13 @@ //! Proxy for client implementing protocol version 1.1 class ClientProxy1_1 : public ClientProxy1_0 { public: - ClientProxy1_1(const String &name, synergy::IStream *adoptedStream, - IEventQueue *events); + ClientProxy1_1( + const String &name, synergy::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 + keyRepeat(KeyID, KeyModifierMask, SInt32 count, KeyButton, const String &); virtual void keyUp(KeyID, KeyModifierMask, KeyButton); }; diff --git a/src/lib/server/ClientProxy1_2.cpp b/src/lib/server/ClientProxy1_2.cpp index 24bedc684..84c9071e5 100644 --- a/src/lib/server/ClientProxy1_2.cpp +++ b/src/lib/server/ClientProxy1_2.cpp @@ -25,8 +25,8 @@ // ClientProxy1_1 // -ClientProxy1_2::ClientProxy1_2(const String &name, synergy::IStream *stream, - IEventQueue *events) +ClientProxy1_2::ClientProxy1_2( + const String &name, synergy::IStream *stream, IEventQueue *events) : ClientProxy1_1(name, stream, events) { // do nothing } @@ -36,7 +36,8 @@ ClientProxy1_2::~ClientProxy1_2() { } void ClientProxy1_2::mouseRelativeMove(SInt32 xRel, SInt32 yRel) { - LOG((CLOG_DEBUG2 "send mouse relative move to \"%s\" %d,%d", + LOG( + (CLOG_DEBUG2 "send mouse relative move to \"%s\" %d,%d", getName().c_str(), xRel, yRel)); ProtocolUtil::writef(getStream(), kMsgDMouseRelMove, xRel, yRel); } diff --git a/src/lib/server/ClientProxy1_2.h b/src/lib/server/ClientProxy1_2.h index 6e7dcef40..68501c183 100644 --- a/src/lib/server/ClientProxy1_2.h +++ b/src/lib/server/ClientProxy1_2.h @@ -25,8 +25,8 @@ class IEventQueue; //! Proxy for client implementing protocol version 1.2 class ClientProxy1_2 : public ClientProxy1_1 { public: - ClientProxy1_2(const String &name, synergy::IStream *adoptedStream, - IEventQueue *events); + ClientProxy1_2( + const String &name, synergy::IStream *adoptedStream, IEventQueue *events); ~ClientProxy1_2(); // IClient overrides diff --git a/src/lib/server/ClientProxy1_3.cpp b/src/lib/server/ClientProxy1_3.cpp index dc383bed4..aab0b0092 100644 --- a/src/lib/server/ClientProxy1_3.cpp +++ b/src/lib/server/ClientProxy1_3.cpp @@ -30,10 +30,12 @@ // ClientProxy1_3 // -ClientProxy1_3::ClientProxy1_3(const String &name, synergy::IStream *stream, - IEventQueue *events) - : ClientProxy1_2(name, stream, events), m_keepAliveRate(kKeepAliveRate), - m_keepAliveTimer(NULL), m_events(events) { +ClientProxy1_3::ClientProxy1_3( + const String &name, synergy::IStream *stream, IEventQueue *events) + : ClientProxy1_2(name, stream, events), + m_keepAliveRate(kKeepAliveRate), + m_keepAliveTimer(NULL), + m_events(events) { setHeartbeatRate(kKeepAliveRate, kKeepAliveRate * kKeepAlivesUntilDeath); } @@ -43,7 +45,8 @@ ClientProxy1_3::~ClientProxy1_3() { } void ClientProxy1_3::mouseWheel(SInt32 xDelta, SInt32 yDelta) { - LOG((CLOG_DEBUG2 "send mouse wheel to \"%s\" %+d,%+d", getName().c_str(), + LOG( + (CLOG_DEBUG2 "send mouse wheel to \"%s\" %+d,%+d", getName().c_str(), xDelta, yDelta)); ProtocolUtil::writef(getStream(), kMsgDMouseWheel, xDelta, yDelta); } @@ -78,9 +81,10 @@ void ClientProxy1_3::addHeartbeatTimer() { // create and install a timer to periodically send keep alives if (m_keepAliveRate > 0.0) { m_keepAliveTimer = m_events->newTimer(m_keepAliveRate, NULL); - m_events->adoptHandler(Event::kTimer, m_keepAliveTimer, - new TMethodEventJob( - this, &ClientProxy1_3::handleKeepAlive, NULL)); + m_events->adoptHandler( + Event::kTimer, m_keepAliveTimer, + new TMethodEventJob( + this, &ClientProxy1_3::handleKeepAlive, NULL)); } // superclass does the alarm diff --git a/src/lib/server/ClientProxy1_3.h b/src/lib/server/ClientProxy1_3.h index 69a778905..e5a6e8aeb 100644 --- a/src/lib/server/ClientProxy1_3.h +++ b/src/lib/server/ClientProxy1_3.h @@ -23,8 +23,8 @@ //! Proxy for client implementing protocol version 1.3 class ClientProxy1_3 : public ClientProxy1_2 { public: - ClientProxy1_3(const String &name, synergy::IStream *adoptedStream, - IEventQueue *events); + ClientProxy1_3( + const String &name, synergy::IStream *adoptedStream, IEventQueue *events); ClientProxy1_3(ClientProxy1_3 const &) = delete; ClientProxy1_3(ClientProxy1_3 &&) = delete; ~ClientProxy1_3(); diff --git a/src/lib/server/ClientProxy1_4.cpp b/src/lib/server/ClientProxy1_4.cpp index c4e9d1bad..dc640cee3 100644 --- a/src/lib/server/ClientProxy1_4.cpp +++ b/src/lib/server/ClientProxy1_4.cpp @@ -31,21 +31,24 @@ // ClientProxy1_4 // -ClientProxy1_4::ClientProxy1_4(const String &name, synergy::IStream *stream, - Server *server, IEventQueue *events) - : ClientProxy1_3(name, stream, events), m_server(server) { +ClientProxy1_4::ClientProxy1_4( + const String &name, synergy::IStream *stream, Server *server, + IEventQueue *events) + : ClientProxy1_3(name, stream, events), + m_server(server) { assert(m_server != NULL); } ClientProxy1_4::~ClientProxy1_4() {} -void ClientProxy1_4::keyDown(KeyID key, KeyModifierMask mask, KeyButton button, - const String &lang) { +void ClientProxy1_4::keyDown( + KeyID key, KeyModifierMask mask, KeyButton button, const String &lang) { ClientProxy1_3::keyDown(key, mask, button, lang); } -void ClientProxy1_4::keyRepeat(KeyID key, KeyModifierMask mask, SInt32 count, - KeyButton button, const String &lang) { +void ClientProxy1_4::keyRepeat( + KeyID key, KeyModifierMask mask, SInt32 count, KeyButton button, + const String &lang) { ClientProxy1_3::keyRepeat(key, mask, count, button, lang); } diff --git a/src/lib/server/ClientProxy1_4.h b/src/lib/server/ClientProxy1_4.h index 7fb120d7c..96502ae2a 100644 --- a/src/lib/server/ClientProxy1_4.h +++ b/src/lib/server/ClientProxy1_4.h @@ -25,8 +25,9 @@ class Server; //! Proxy for client implementing protocol version 1.4 class ClientProxy1_4 : public ClientProxy1_3 { public: - ClientProxy1_4(const String &name, synergy::IStream *adoptedStream, - Server *server, IEventQueue *events); + ClientProxy1_4( + const String &name, synergy::IStream *adoptedStream, Server *server, + IEventQueue *events); ~ClientProxy1_4(); //! @name accessors @@ -38,10 +39,11 @@ public: //@} // 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 + 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(); diff --git a/src/lib/server/ClientProxy1_5.cpp b/src/lib/server/ClientProxy1_5.cpp index 912f29434..963c26ada 100644 --- a/src/lib/server/ClientProxy1_5.cpp +++ b/src/lib/server/ClientProxy1_5.cpp @@ -31,21 +31,24 @@ // ClientProxy1_5 // -ClientProxy1_5::ClientProxy1_5(const String &name, synergy::IStream *stream, - Server *server, IEventQueue *events) - : ClientProxy1_4(name, stream, server, events), m_events(events) { +ClientProxy1_5::ClientProxy1_5( + const String &name, synergy::IStream *stream, Server *server, + IEventQueue *events) + : ClientProxy1_4(name, stream, server, events), + m_events(events) { - m_events->adoptHandler(m_events->forFile().keepAlive(), this, - new TMethodEventJob( - this, &ClientProxy1_3::handleKeepAlive, NULL)); + m_events->adoptHandler( + m_events->forFile().keepAlive(), this, + new TMethodEventJob( + this, &ClientProxy1_3::handleKeepAlive, NULL)); } ClientProxy1_5::~ClientProxy1_5() { m_events->removeHandler(m_events->forFile().keepAlive(), this); } -void ClientProxy1_5::sendDragInfo(UInt32 fileCount, const char *info, - size_t size) { +void ClientProxy1_5::sendDragInfo( + UInt32 fileCount, const char *info, size_t size) { String data(info, size); ProtocolUtil::writef(getStream(), kMsgDDragInfo, fileCount, &data); @@ -69,8 +72,9 @@ bool ClientProxy1_5::parseMessage(const UInt8 *code) { void ClientProxy1_5::fileChunkReceived() { Server *server = getServer(); - int result = FileChunk::assemble(getStream(), server->getReceivedFileData(), - server->getExpectedFileSize()); + int result = FileChunk::assemble( + getStream(), server->getReceivedFileData(), + server->getExpectedFileSize()); if (result == kFinish) { m_events->addEvent( diff --git a/src/lib/server/ClientProxy1_5.h b/src/lib/server/ClientProxy1_5.h index 587ab0f9e..9080e108f 100644 --- a/src/lib/server/ClientProxy1_5.h +++ b/src/lib/server/ClientProxy1_5.h @@ -27,8 +27,9 @@ class IEventQueue; //! Proxy for client implementing protocol version 1.5 class ClientProxy1_5 : public ClientProxy1_4 { public: - ClientProxy1_5(const String &name, synergy::IStream *adoptedStream, - Server *server, IEventQueue *events); + ClientProxy1_5( + const String &name, synergy::IStream *adoptedStream, Server *server, + IEventQueue *events); ClientProxy1_5(ClientProxy1_5 const &) = delete; ClientProxy1_5(ClientProxy1_5 &&) = delete; ~ClientProxy1_5(); diff --git a/src/lib/server/ClientProxy1_6.cpp b/src/lib/server/ClientProxy1_6.cpp index 805d90fb1..62445c04d 100644 --- a/src/lib/server/ClientProxy1_6.cpp +++ b/src/lib/server/ClientProxy1_6.cpp @@ -29,9 +29,11 @@ // ClientProxy1_6 // -ClientProxy1_6::ClientProxy1_6(const String &name, synergy::IStream *stream, - Server *server, IEventQueue *events) - : ClientProxy1_5(name, stream, server, events), m_events(events) { +ClientProxy1_6::ClientProxy1_6( + const String &name, synergy::IStream *stream, Server *server, + IEventQueue *events) + : ClientProxy1_5(name, stream, server, events), + m_events(events) { m_events->adoptHandler( m_events->forClipboard().clipboardSending(), this, new TMethodEventJob( @@ -72,7 +74,8 @@ bool ClientProxy1_6::recvClipboard() { size_t size = ClipboardChunk::getExpectedSize(); LOG((CLOG_DEBUG "receiving clipboard %d size=%d", id, size)); } else if (r == kFinish) { - LOG((CLOG_DEBUG "received client \"%s\" clipboard %d seqnum=%d, size=%d", + LOG( + (CLOG_DEBUG "received client \"%s\" clipboard %d seqnum=%d, size=%d", getName().c_str(), id, seq, dataCached.size())); // save clipboard m_clipboard[id].m_clipboard.unmarshall(dataCached, 0); @@ -82,8 +85,8 @@ bool ClientProxy1_6::recvClipboard() { ClipboardInfo *info = new ClipboardInfo; info->m_id = id; info->m_sequenceNumber = seq; - m_events->addEvent(Event(m_events->forClipboard().clipboardChanged(), - getEventTarget(), info)); + m_events->addEvent(Event( + m_events->forClipboard().clipboardChanged(), getEventTarget(), info)); } return true; diff --git a/src/lib/server/ClientProxy1_6.h b/src/lib/server/ClientProxy1_6.h index 5e11a20f3..2b3e26802 100644 --- a/src/lib/server/ClientProxy1_6.h +++ b/src/lib/server/ClientProxy1_6.h @@ -25,8 +25,9 @@ class IEventQueue; //! Proxy for client implementing protocol version 1.6 class ClientProxy1_6 : public ClientProxy1_5 { public: - ClientProxy1_6(const String &name, synergy::IStream *adoptedStream, - Server *server, IEventQueue *events); + ClientProxy1_6( + const String &name, synergy::IStream *adoptedStream, Server *server, + IEventQueue *events); ~ClientProxy1_6(); virtual void setClipboard(ClipboardID id, const IClipboard *clipboard); diff --git a/src/lib/server/ClientProxy1_7.cpp b/src/lib/server/ClientProxy1_7.cpp index 445473a94..da3121f44 100644 --- a/src/lib/server/ClientProxy1_7.cpp +++ b/src/lib/server/ClientProxy1_7.cpp @@ -26,12 +26,15 @@ // ClientProxy1_7 // -ClientProxy1_7::ClientProxy1_7(const String &name, synergy::IStream *stream, - Server *server, IEventQueue *events) - : ClientProxy1_6(name, stream, server, events), m_events(events) {} +ClientProxy1_7::ClientProxy1_7( + const String &name, synergy::IStream *stream, Server *server, + IEventQueue *events) + : ClientProxy1_6(name, stream, server, events), + m_events(events) {} void ClientProxy1_7::secureInputNotification(const String &app) const { - LOG((CLOG_DEBUG2 "send secure input notification to \"%s\" %s", + LOG( + (CLOG_DEBUG2 "send secure input notification to \"%s\" %s", getName().c_str(), app.c_str())); ProtocolUtil::writef(getStream(), kMsgDSecureInputNotification, &app); } diff --git a/src/lib/server/ClientProxy1_7.h b/src/lib/server/ClientProxy1_7.h index f525dcc5f..0c1ee81ca 100644 --- a/src/lib/server/ClientProxy1_7.h +++ b/src/lib/server/ClientProxy1_7.h @@ -22,8 +22,9 @@ //! Proxy for client implementing protocol version 1.7 class ClientProxy1_7 : public ClientProxy1_6 { public: - ClientProxy1_7(const String &name, synergy::IStream *adoptedStream, - Server *server, IEventQueue *events); + ClientProxy1_7( + const String &name, synergy::IStream *adoptedStream, Server *server, + IEventQueue *events); ~ClientProxy1_7() override = default; void secureInputNotification(const String &app) const override; diff --git a/src/lib/server/ClientProxy1_8.cpp b/src/lib/server/ClientProxy1_8.cpp index 4a8496d12..473cfdff1 100644 --- a/src/lib/server/ClientProxy1_8.cpp +++ b/src/lib/server/ClientProxy1_8.cpp @@ -20,9 +20,9 @@ #include "ClientProxy1_8.h" -ClientProxy1_8::ClientProxy1_8(const String &name, - synergy::IStream *adoptedStream, Server *server, - IEventQueue *events) +ClientProxy1_8::ClientProxy1_8( + const String &name, synergy::IStream *adoptedStream, Server *server, + IEventQueue *events) : ClientProxy1_7(name, adoptedStream, server, events) { synchronizeLanguages(); } @@ -31,20 +31,22 @@ void ClientProxy1_8::synchronizeLanguages() const { synergy::languages::LanguageManager languageManager; auto localLanguages = languageManager.getSerializedLocalLanguages(); if (!localLanguages.empty()) { - LOG((CLOG_DEBUG1 "send server languages to the client: %s", + LOG( + (CLOG_DEBUG1 "send server languages to the client: %s", localLanguages.c_str())); - ProtocolUtil::writef(getStream(), kMsgDLanguageSynchronisation, - &localLanguages); + ProtocolUtil::writef( + getStream(), kMsgDLanguageSynchronisation, &localLanguages); } else { LOG((CLOG_ERR "failed to read server languages")); } } -void ClientProxy1_8::keyDown(KeyID key, KeyModifierMask mask, KeyButton button, - const String &language) { - LOG((CLOG_DEBUG1 +void ClientProxy1_8::keyDown( + KeyID key, KeyModifierMask mask, KeyButton button, const String &language) { + LOG( + (CLOG_DEBUG1 "send key down to \"%s\" id=%d, mask=0x%04x, button=0x%04x, language=%s", getName().c_str(), key, mask, button, language.c_str())); - ProtocolUtil::writef(getStream(), kMsgDKeyDownLang, key, mask, button, - &language); + ProtocolUtil::writef( + getStream(), kMsgDKeyDownLang, key, mask, button, &language); } diff --git a/src/lib/server/ClientProxy1_8.h b/src/lib/server/ClientProxy1_8.h index 2777b90e2..77bb727d1 100644 --- a/src/lib/server/ClientProxy1_8.h +++ b/src/lib/server/ClientProxy1_8.h @@ -21,8 +21,9 @@ class ClientProxy1_8 : public ClientProxy1_7 { public: - ClientProxy1_8(const String &name, synergy::IStream *adoptedStream, - Server *server, IEventQueue *events); + ClientProxy1_8( + const String &name, synergy::IStream *adoptedStream, Server *server, + IEventQueue *events); ~ClientProxy1_8() override = default; void keyDown(KeyID, KeyModifierMask, KeyButton, const String &) override; diff --git a/src/lib/server/ClientProxyUnknown.cpp b/src/lib/server/ClientProxyUnknown.cpp index 809264b9d..2b5642be2 100644 --- a/src/lib/server/ClientProxyUnknown.cpp +++ b/src/lib/server/ClientProxyUnknown.cpp @@ -45,21 +45,26 @@ // ClientProxyUnknown // -ClientProxyUnknown::ClientProxyUnknown(synergy::IStream *stream, double timeout, - Server *server, IEventQueue *events) - : m_stream(stream), m_proxy(NULL), m_ready(false), m_server(server), +ClientProxyUnknown::ClientProxyUnknown( + synergy::IStream *stream, double timeout, Server *server, + IEventQueue *events) + : m_stream(stream), + m_proxy(NULL), + m_ready(false), + m_server(server), m_events(events) { assert(m_server != NULL); - m_events->adoptHandler(Event::kTimer, this, - new TMethodEventJob( - this, &ClientProxyUnknown::handleTimeout, NULL)); + m_events->adoptHandler( + Event::kTimer, this, + new TMethodEventJob( + this, &ClientProxyUnknown::handleTimeout, NULL)); m_timer = m_events->newOneShotTimer(timeout, this); addStreamHandlers(); LOG((CLOG_DEBUG1 "saying hello")); - ProtocolUtil::writef(m_stream, kMsgHello, kProtocolMajorVersion, - kProtocolMinorVersion); + ProtocolUtil::writef( + m_stream, kMsgHello, kProtocolMajorVersion, kProtocolMinorVersion); } ClientProxyUnknown::~ClientProxyUnknown() { @@ -98,45 +103,47 @@ void ClientProxyUnknown::sendFailure() { void ClientProxyUnknown::addStreamHandlers() { assert(m_stream != NULL); - m_events->adoptHandler(m_events->forIStream().inputReady(), - m_stream->getEventTarget(), - new TMethodEventJob( - this, &ClientProxyUnknown::handleData)); - m_events->adoptHandler(m_events->forIStream().outputError(), - m_stream->getEventTarget(), - new TMethodEventJob( - this, &ClientProxyUnknown::handleWriteError)); - m_events->adoptHandler(m_events->forIStream().inputShutdown(), - m_stream->getEventTarget(), - new TMethodEventJob( - this, &ClientProxyUnknown::handleDisconnect)); - m_events->adoptHandler(m_events->forIStream().outputShutdown(), - m_stream->getEventTarget(), - new TMethodEventJob( - this, &ClientProxyUnknown::handleWriteError)); + m_events->adoptHandler( + m_events->forIStream().inputReady(), m_stream->getEventTarget(), + new TMethodEventJob( + this, &ClientProxyUnknown::handleData)); + m_events->adoptHandler( + m_events->forIStream().outputError(), m_stream->getEventTarget(), + new TMethodEventJob( + this, &ClientProxyUnknown::handleWriteError)); + m_events->adoptHandler( + m_events->forIStream().inputShutdown(), m_stream->getEventTarget(), + new TMethodEventJob( + this, &ClientProxyUnknown::handleDisconnect)); + m_events->adoptHandler( + m_events->forIStream().outputShutdown(), m_stream->getEventTarget(), + new TMethodEventJob( + this, &ClientProxyUnknown::handleWriteError)); } void ClientProxyUnknown::addProxyHandlers() { assert(m_proxy != NULL); - m_events->adoptHandler(m_events->forClientProxy().ready(), m_proxy, - new TMethodEventJob( - this, &ClientProxyUnknown::handleReady)); - m_events->adoptHandler(m_events->forClientProxy().disconnected(), m_proxy, - new TMethodEventJob( - this, &ClientProxyUnknown::handleDisconnect)); + m_events->adoptHandler( + m_events->forClientProxy().ready(), m_proxy, + new TMethodEventJob( + this, &ClientProxyUnknown::handleReady)); + m_events->adoptHandler( + m_events->forClientProxy().disconnected(), m_proxy, + new TMethodEventJob( + this, &ClientProxyUnknown::handleDisconnect)); } void ClientProxyUnknown::removeHandlers() { if (m_stream != NULL) { - m_events->removeHandler(m_events->forIStream().inputReady(), - m_stream->getEventTarget()); - m_events->removeHandler(m_events->forIStream().outputError(), - m_stream->getEventTarget()); - m_events->removeHandler(m_events->forIStream().inputShutdown(), - m_stream->getEventTarget()); - m_events->removeHandler(m_events->forIStream().outputShutdown(), - m_stream->getEventTarget()); + m_events->removeHandler( + m_events->forIStream().inputReady(), m_stream->getEventTarget()); + m_events->removeHandler( + m_events->forIStream().outputError(), m_stream->getEventTarget()); + m_events->removeHandler( + m_events->forIStream().inputShutdown(), m_stream->getEventTarget()); + m_events->removeHandler( + m_events->forIStream().outputShutdown(), m_stream->getEventTarget()); } if (m_proxy != NULL) { m_events->removeHandler(m_events->forClientProxy().ready(), m_proxy); @@ -232,7 +239,8 @@ void ClientProxyUnknown::handleData(const Event &, void *) { initProxy(name, major, minor); // the proxy is created and now proxy now owns the stream - LOG((CLOG_DEBUG1 "created proxy for client \"%s\" version %d.%d", + LOG( + (CLOG_DEBUG1 "created proxy for client \"%s\" version %d.%d", name.c_str(), major, minor)); m_stream = NULL; @@ -241,17 +249,20 @@ void ClientProxyUnknown::handleData(const Event &, void *) { return; } catch (XIncompatibleClient &e) { // client is incompatible - LOG((CLOG_WARN "client \"%s\" has incompatible version %d.%d)", + LOG( + (CLOG_WARN "client \"%s\" has incompatible version %d.%d)", name.c_str(), e.getMajor(), e.getMinor())); - ProtocolUtil::writef(m_stream, kMsgEIncompatible, kProtocolMajorVersion, - kProtocolMinorVersion); + ProtocolUtil::writef( + m_stream, kMsgEIncompatible, kProtocolMajorVersion, + kProtocolMinorVersion); } catch (XBadClient &) { // client not behaving LOG((CLOG_WARN "protocol error from client \"%s\"", name.c_str())); ProtocolUtil::writef(m_stream, kMsgEBad); } catch (XBase &e) { // misc error - LOG((CLOG_WARN "error communicating with client \"%s\": %s", name.c_str(), + LOG( + (CLOG_WARN "error communicating with client \"%s\": %s", name.c_str(), e.what())); } sendFailure(); diff --git a/src/lib/server/ClientProxyUnknown.h b/src/lib/server/ClientProxyUnknown.h index 452d674f9..0c8cf046e 100644 --- a/src/lib/server/ClientProxyUnknown.h +++ b/src/lib/server/ClientProxyUnknown.h @@ -32,8 +32,9 @@ class IEventQueue; class ClientProxyUnknown { public: - ClientProxyUnknown(synergy::IStream *stream, double timeout, Server *server, - IEventQueue *events); + ClientProxyUnknown( + synergy::IStream *stream, double timeout, Server *server, + IEventQueue *events); ClientProxyUnknown(ClientProxyUnknown const &) = delete; ClientProxyUnknown(ClientProxyUnknown &&) = delete; ~ClientProxyUnknown(); diff --git a/src/lib/server/Config.cpp b/src/lib/server/Config.cpp index 5610b99a0..2ce3edddf 100644 --- a/src/lib/server/Config.cpp +++ b/src/lib/server/Config.cpp @@ -35,7 +35,9 @@ using namespace synergy::string; // Config::Config(IEventQueue *events) - : m_inputFilter(events), m_hasLockToScreenAction(false), m_events(events) { + : m_inputFilter(events), + m_hasLockToScreenAction(false), + m_events(events) { // do nothing } @@ -198,9 +200,9 @@ void Config::removeAllAliases() { } } -bool Config::connect(const String &srcName, EDirection srcSide, float srcStart, - float srcEnd, const String &dstName, float dstStart, - float dstEnd) { +bool Config::connect( + const String &srcName, EDirection srcSide, float srcStart, float srcEnd, + const String &dstName, float dstStart, float dstEnd) { assert(srcSide >= kFirstDirection && srcSide <= kLastDirection); // find source cell @@ -230,8 +232,8 @@ bool Config::disconnect(const String &srcName, EDirection srcSide) { return true; } -bool Config::disconnect(const String &srcName, EDirection srcSide, - float position) { +bool Config::disconnect( + const String &srcName, EDirection srcSide, float position) { assert(srcSide >= kFirstDirection && srcSide <= kLastDirection); // find source cell @@ -399,8 +401,9 @@ String Config::getCanonicalName(const String &name) const { } } -String Config::getNeighbor(const String &srcName, EDirection srcSide, - float position, float *positionOut) const { +String Config::getNeighbor( + const String &srcName, EDirection srcSide, float position, + float *positionOut) const { assert(srcSide >= kFirstDirection && srcSide <= kLastDirection); // find source cell @@ -429,8 +432,8 @@ bool Config::hasNeighbor(const String &srcName, EDirection srcSide) const { return hasNeighbor(srcName, srcSide, 0.0f, 1.0f); } -bool Config::hasNeighbor(const String &srcName, EDirection srcSide, float start, - float end) const { +bool Config::hasNeighbor( + const String &srcName, EDirection srcSide, float start, float end) const { assert(srcSide >= kFirstDirection && srcSide <= kLastDirection); // find source cell @@ -550,8 +553,9 @@ String Config::formatInterval(const Interval &x) { if (x.first == 0.0f && x.second == 1.0f) { return ""; } - return synergy::string::sprintf("(%d,%d)", (int)(x.first * 100.0f + 0.5f), - (int)(x.second * 100.0f + 0.5f)); + return synergy::string::sprintf( + "(%d,%d)", (int)(x.first * 100.0f + 0.5f), + (int)(x.second * 100.0f + 0.5f)); } String Config::getClientAddress() const { return m_clientAddress; } @@ -759,21 +763,21 @@ void Config::readSectionScreens(ConfigReadContext &s) { } else if (name == "halfDuplexScrollLock") { addOption(screen, kOptionHalfDuplexScrollLock, s.parseBoolean(value)); } else if (name == "shift") { - addOption(screen, kOptionModifierMapForShift, - s.parseModifierKey(value)); + addOption( + screen, kOptionModifierMapForShift, s.parseModifierKey(value)); } else if (name == "ctrl") { - addOption(screen, kOptionModifierMapForControl, - s.parseModifierKey(value)); + addOption( + screen, kOptionModifierMapForControl, s.parseModifierKey(value)); } else if (name == "alt") { addOption(screen, kOptionModifierMapForAlt, s.parseModifierKey(value)); } else if (name == "altgr") { - addOption(screen, kOptionModifierMapForAltGr, - s.parseModifierKey(value)); + addOption( + screen, kOptionModifierMapForAltGr, s.parseModifierKey(value)); } else if (name == "meta") { addOption(screen, kOptionModifierMapForMeta, s.parseModifierKey(value)); } else if (name == "super") { - addOption(screen, kOptionModifierMapForSuper, - s.parseModifierKey(value)); + addOption( + screen, kOptionModifierMapForSuper, s.parseModifierKey(value)); } else if (name == "xtestIsXineramaUnaware") { addOption(screen, kOptionXTestXineramaUnaware, s.parseBoolean(value)); } else if (name == "switchCorners") { @@ -845,8 +849,9 @@ void Config::readSectionLinks(ConfigReadContext &s) { if (!isScreen(dstScreen)) { throw XConfigRead(s, "unknown screen name \"%{1}\"", dstScreen); } - if (!connect(screen, dir, srcInterval.first, srcInterval.second, - dstScreen, dstInterval.first, dstInterval.second)) { + if (!connect( + screen, dir, srcInterval.first, srcInterval.second, dstScreen, + dstInterval.first, dstInterval.second)) { throw XConfigRead(s, "overlapping range"); } } @@ -892,9 +897,8 @@ void Config::readSectionAliases(ConfigReadContext &s) { throw XConfigRead(s, "unexpected end of aliases section"); } -InputFilter::Condition * -Config::parseCondition(ConfigReadContext &s, const String &name, - const std::vector &args) { +InputFilter::Condition *Config::parseCondition( + ConfigReadContext &s, const String &name, const std::vector &args) { if (name == "keystroke") { if (args.size() != 1) { throw XConfigRead(s, "syntax for condition: keystroke(modifiers+key)"); @@ -907,8 +911,8 @@ Config::parseCondition(ConfigReadContext &s, const String &name, if (name == "mousebutton") { if (args.size() != 1) { - throw XConfigRead(s, - "syntax for condition: mousebutton(modifiers+button)"); + throw XConfigRead( + s, "syntax for condition: mousebutton(modifiers+button)"); } IPlatformScreen::ButtonInfo *mouseInfo = s.parseMouse(args[0]); @@ -934,9 +938,9 @@ Config::parseCondition(ConfigReadContext &s, const String &name, throw XConfigRead(s, "unknown argument \"%{1}\"", name); } -void Config::parseAction(ConfigReadContext &s, const String &name, - const std::vector &args, - InputFilter::Rule &rule, bool activate) { +void Config::parseAction( + ConfigReadContext &s, const String &name, const std::vector &args, + InputFilter::Rule &rule, bool activate) { InputFilter::Action *action; if (name == "keystroke" || name == "keyDown" || name == "keyUp") { @@ -1032,8 +1036,8 @@ void Config::parseAction(ConfigReadContext &s, const String &name, } else if (args[0] == "down") { direction = kBottom; } else { - throw XConfigRead(s, "unknown direction \"%{1}\" in switchToScreen", - args[0]); + throw XConfigRead( + s, "unknown direction \"%{1}\" in switchToScreen", args[0]); } action = new InputFilter::SwitchInDirectionAction(m_events, direction); @@ -1102,8 +1106,9 @@ void Config::parseAction(ConfigReadContext &s, const String &name, } else if (args[0] == "toggle") { mode = InputFilter::KeyboardBroadcastAction::kToggle; } else { - throw XConfigRead(s, "syntax for action: " - "keyboardBroadcast([{off|on|toggle}[,screens]])"); + throw XConfigRead( + s, "syntax for action: " + "keyboardBroadcast([{off|on|toggle}[,screens]])"); } } @@ -1122,8 +1127,8 @@ void Config::parseAction(ConfigReadContext &s, const String &name, rule.adoptAction(action, activate); } -void Config::parseScreens(ConfigReadContext &c, const String &s, - std::set &screens) const { +void Config::parseScreens( + ConfigReadContext &c, const String &s, std::set &screens) const { screens.clear(); String::size_type i = 0; @@ -1299,7 +1304,8 @@ String Config::getOptionValue(OptionID id, OptionValue value) { // Config::Name::Name(Config *config, const String &name) - : m_config(config), m_name(config->getCanonicalName(name)) { + : m_config(config), + m_name(config->getCanonicalName(name)) { // do nothing } @@ -1324,8 +1330,8 @@ Config::CellEdge::CellEdge(EDirection side, const Interval &interval) { init("", side, interval); } -Config::CellEdge::CellEdge(const String &name, EDirection side, - const Interval &interval) { +Config::CellEdge::CellEdge( + const String &name, EDirection side, const Interval &interval) { assert(interval.first >= 0.0f); assert(interval.second <= 1.0f); assert(interval.first < interval.second); @@ -1337,8 +1343,8 @@ Config::CellEdge::~CellEdge() { // do nothing } -void Config::CellEdge::init(const String &name, EDirection side, - const Interval &interval) { +void Config::CellEdge::init( + const String &name, EDirection side, const Interval &interval) { assert(side != kNoDirection); m_name = name; @@ -1466,8 +1472,9 @@ bool Config::Cell::overlaps(const CellEdge &edge) const { return false; } -bool Config::Cell::getLink(EDirection side, float position, - const CellEdge *&src, const CellEdge *&dst) const { +bool Config::Cell::getLink( + EDirection side, float position, const CellEdge *&src, + const CellEdge *&dst) const { CellEdge edge(side, position); EdgeLinks::const_iterator i = m_neighbors.upper_bound(edge); if (i == m_neighbors.begin()) { @@ -1504,8 +1511,8 @@ bool Config::Cell::operator==(const Cell &x) const { // operator== doesn't compare names. only compare destination // names. - if (!CaselessCmp::equal(index1.second.getName(), - index2neighbors->second.getName())) { + if (!CaselessCmp::equal( + index1.second.getName(), index2neighbors->second.getName())) { return false; } ++index2neighbors; @@ -1627,7 +1634,8 @@ std::ostream &operator<<(std::ostream &s, const Config &config) { // ConfigReadContext::ConfigReadContext(std::istream &s, SInt32 firstLine) - : m_stream(s), m_line(firstLine - 1) { + : m_stream(s), + m_line(firstLine - 1) { // do nothing } @@ -1659,8 +1667,9 @@ bool ConfigReadContext::readLine(String &line) { // make sure there are no invalid characters for (i = 0; i < line.length(); ++i) { if (!isgraph(line[i]) && line[i] != ' ' && line[i] != '\t') { - throw XConfigRead(*this, "invalid character %{1}", - synergy::string::sprintf("%#2x", line[i])); + throw XConfigRead( + *this, "invalid character %{1}", + synergy::string::sprintf("%#2x", line[i])); } } @@ -1774,8 +1783,9 @@ OptionValue ConfigReadContext::parseCorners(const String &args) const { } else if (args[i] == '+') { add = true; } else { - throw XConfigRead(*this, "invalid corner operator \"%{1}\"", - String(args.c_str() + i, 1)); + throw XConfigRead( + *this, "invalid corner operator \"%{1}\"", + String(args.c_str() + i, 1)); } // get next corner token @@ -1825,11 +1835,9 @@ Config::Interval ConfigReadContext::parseInterval(const ArgList &args) const { return Config::Interval(startInterval, endInterval); } -void ConfigReadContext::parseNameWithArgs(const String &type, - const String &line, - const String &delim, - String::size_type &index, - String &name, ArgList &args) const { +void ConfigReadContext::parseNameWithArgs( + const String &type, const String &line, const String &delim, + String::size_type &index, String &name, ArgList &args) const { // skip leading whitespace String::size_type i = line.find_first_not_of(" \t", index); if (i == String::npos) { @@ -1935,9 +1943,8 @@ ConfigReadContext::parseKeystroke(const String &keystroke) const { return parseKeystroke(keystroke, std::set()); } -IPlatformScreen::KeyInfo * -ConfigReadContext::parseKeystroke(const String &keystroke, - const std::set &screens) const { +IPlatformScreen::KeyInfo *ConfigReadContext::parseKeystroke( + const String &keystroke, const std::set &screens) const { String s = keystroke; KeyModifierMask mask; @@ -2011,15 +2018,16 @@ String ConfigReadContext::concatArgs(const ArgList &args) { // XConfigRead::XConfigRead(const ConfigReadContext &context, const String &error) - : m_error(synergy::string::sprintf("line %d: %s", context.getLineNumber(), - error.c_str())) { + : m_error(synergy::string::sprintf( + "line %d: %s", context.getLineNumber(), error.c_str())) { // do nothing } -XConfigRead::XConfigRead(const ConfigReadContext &context, const char *errorFmt, - const String &arg) - : m_error(synergy::string::sprintf("line %d: ", context.getLineNumber()) + - synergy::string::format(errorFmt, arg.c_str())) { +XConfigRead::XConfigRead( + const ConfigReadContext &context, const char *errorFmt, const String &arg) + : m_error( + synergy::string::sprintf("line %d: ", context.getLineNumber()) + + synergy::string::format(errorFmt, arg.c_str())) { // do nothing } diff --git a/src/lib/server/Config.h b/src/lib/server/Config.h index 0919815d5..bee6692e1 100644 --- a/src/lib/server/Config.h +++ b/src/lib/server/Config.h @@ -123,8 +123,9 @@ private: bool hasEdge(const CellEdge &) const; bool overlaps(const CellEdge &) const; - bool getLink(EDirection side, float position, const CellEdge *&src, - const CellEdge *&dst) const; + bool getLink( + EDirection side, float position, const CellEdge *&src, + const CellEdge *&dst) const; bool operator==(const Cell &) const; bool operator!=(const Cell &) const; @@ -258,9 +259,9 @@ public: 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); + bool connect( + const String &srcName, EDirection srcSide, float srcStart, float srcEnd, + const String &dstName, float dstStart, float dstEnd); //! Disconnect screens /*! @@ -361,8 +362,8 @@ public: 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; + String getNeighbor( + const String &, EDirection, float position, float *positionOut) const; //! Check for neighbor /*! @@ -458,15 +459,15 @@ private: void readSectionLinks(ConfigReadContext &); void readSectionAliases(ConfigReadContext &); - InputFilter::Condition *parseCondition(ConfigReadContext &, - const String &condition, - const std::vector &args); - void parseAction(ConfigReadContext &, const String &action, - const std::vector &args, InputFilter::Rule &, - bool activate); + InputFilter::Condition *parseCondition( + ConfigReadContext &, const String &condition, + const std::vector &args); + void parseAction( + ConfigReadContext &, const String &action, + const std::vector &args, InputFilter::Rule &, bool activate); - void parseScreens(ConfigReadContext &, const String &, - std::set &screens) const; + void parseScreens( + ConfigReadContext &, const String &, std::set &screens) const; static const char *getOptionName(OptionID); static String getOptionValue(OptionID, OptionValue); @@ -503,13 +504,12 @@ public: OptionValue parseCorner(const String &) const; OptionValue parseCorners(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; + 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 &screens) const; + IPlatformScreen::KeyInfo *parseKeystroke( + const String &keystroke, const std::set &screens) const; IPlatformScreen::ButtonInfo *parseMouse(const String &mouse) const; KeyModifierMask parseModifier(const String &modifiers) const; std::istream &getStream() const { return m_stream; }; @@ -532,8 +532,9 @@ 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); + XConfigRead( + const ConfigReadContext &context, const char *errorFmt, + const String &arg); virtual ~XConfigRead() _NOEXCEPT; protected: diff --git a/src/lib/server/InputFilter.cpp b/src/lib/server/InputFilter.cpp index 99af5fc31..52f31275a 100644 --- a/src/lib/server/InputFilter.cpp +++ b/src/lib/server/InputFilter.cpp @@ -48,14 +48,19 @@ void InputFilter::Condition::disablePrimary(PrimaryClient *) { InputFilter::KeystrokeCondition::KeystrokeCondition( IEventQueue *events, IPlatformScreen::KeyInfo *info) - : m_id(0), m_key(info->m_key), m_mask(info->m_mask), m_events(events) { + : m_id(0), + m_key(info->m_key), + m_mask(info->m_mask), + m_events(events) { free(info); } -InputFilter::KeystrokeCondition::KeystrokeCondition(IEventQueue *events, - KeyID key, - KeyModifierMask mask) - : m_id(0), m_key(key), m_mask(mask), m_events(events) { +InputFilter::KeystrokeCondition::KeystrokeCondition( + IEventQueue *events, KeyID key, KeyModifierMask mask) + : m_id(0), + m_key(key), + m_mask(mask), + m_events(events) { // do nothing } @@ -113,14 +118,17 @@ void InputFilter::KeystrokeCondition::disablePrimary(PrimaryClient *primary) { InputFilter::MouseButtonCondition::MouseButtonCondition( IEventQueue *events, IPlatformScreen::ButtonInfo *info) - : m_button(info->m_button), m_mask(info->m_mask), m_events(events) { + : m_button(info->m_button), + m_mask(info->m_mask), + m_events(events) { free(info); } -InputFilter::MouseButtonCondition::MouseButtonCondition(IEventQueue *events, - ButtonID button, - KeyModifierMask mask) - : m_button(button), m_mask(mask), m_events(events) { +InputFilter::MouseButtonCondition::MouseButtonCondition( + IEventQueue *events, ButtonID button, KeyModifierMask mask) + : m_button(button), + m_mask(mask), + m_events(events) { // do nothing } @@ -180,7 +188,8 @@ InputFilter::MouseButtonCondition::match(const Event &event) { InputFilter::ScreenConnectedCondition::ScreenConnectedCondition( IEventQueue *events, const String &screen) - : m_screen(screen), m_events(events) { + : m_screen(screen), + m_events(events) { // do nothing } @@ -222,7 +231,8 @@ InputFilter::Action::~Action() { InputFilter::LockCursorToScreenAction::LockCursorToScreenAction( IEventQueue *events, Mode mode) - : m_mode(mode), m_events(events) { + : m_mode(mode), + m_events(events) { // do nothing } @@ -249,13 +259,14 @@ void InputFilter::LockCursorToScreenAction::perform(const Event &event) { // send event Server::LockCursorToScreenInfo *info = Server::LockCursorToScreenInfo::alloc(s_state[m_mode]); - m_events->addEvent(Event(m_events->forServer().lockCursorToScreen(), - event.getTarget(), info, - Event::kDeliverImmediately)); + m_events->addEvent(Event( + m_events->forServer().lockCursorToScreen(), event.getTarget(), info, + Event::kDeliverImmediately)); } InputFilter::RestartServer::RestartServer(IEventQueue *events, Mode mode) - : m_mode(mode), m_events(events) { + : m_mode(mode), + m_events(events) { // do nothing } @@ -278,9 +289,10 @@ void InputFilter::RestartServer::perform(const Event &event) { exit(0); } -InputFilter::SwitchToScreenAction::SwitchToScreenAction(IEventQueue *events, - const String &screen) - : m_screen(screen), m_events(events) { +InputFilter::SwitchToScreenAction::SwitchToScreenAction( + IEventQueue *events, const String &screen) + : m_screen(screen), + m_events(events) { // do nothing } @@ -306,14 +318,15 @@ void InputFilter::SwitchToScreenAction::perform(const Event &event) { // send event Server::SwitchToScreenInfo *info = Server::SwitchToScreenInfo::alloc(screen); - m_events->addEvent(Event(m_events->forServer().switchToScreen(), - event.getTarget(), info, - Event::kDeliverImmediately)); + m_events->addEvent(Event( + m_events->forServer().switchToScreen(), event.getTarget(), info, + Event::kDeliverImmediately)); } InputFilter::SwitchInDirectionAction::SwitchInDirectionAction( IEventQueue *events, EDirection direction) - : m_direction(direction), m_events(events) { + : m_direction(direction), + m_events(events) { // do nothing } @@ -328,27 +341,29 @@ InputFilter::Action *InputFilter::SwitchInDirectionAction::clone() const { String InputFilter::SwitchInDirectionAction::format() const { static const char *s_names[] = {"", "left", "right", "up", "down"}; - return synergy::string::sprintf("switchInDirection(%s)", - s_names[m_direction]); + return synergy::string::sprintf( + "switchInDirection(%s)", s_names[m_direction]); } void InputFilter::SwitchInDirectionAction::perform(const Event &event) { Server::SwitchInDirectionInfo *info = Server::SwitchInDirectionInfo::alloc(m_direction); - m_events->addEvent(Event(m_events->forServer().switchInDirection(), - event.getTarget(), info, - Event::kDeliverImmediately)); + m_events->addEvent(Event( + m_events->forServer().switchInDirection(), event.getTarget(), info, + Event::kDeliverImmediately)); } InputFilter::KeyboardBroadcastAction::KeyboardBroadcastAction( IEventQueue *events, Mode mode) - : m_mode(mode), m_events(events) { + : m_mode(mode), + m_events(events) { // do nothing } InputFilter::KeyboardBroadcastAction::KeyboardBroadcastAction( IEventQueue *events, Mode mode, const std::set &screens) - : m_mode(mode), m_screens(IKeyState::KeyInfo::join(screens)), + : m_mode(mode), + m_screens(IKeyState::KeyInfo::join(screens)), m_events(events) { // do nothing } @@ -390,15 +405,16 @@ void InputFilter::KeyboardBroadcastAction::perform(const Event &event) { // send event Server::KeyboardBroadcastInfo *info = Server::KeyboardBroadcastInfo::alloc(s_state[m_mode], m_screens); - m_events->addEvent(Event(m_events->forServer().keyboardBroadcast(), - event.getTarget(), info, - Event::kDeliverImmediately)); + m_events->addEvent(Event( + m_events->forServer().keyboardBroadcast(), event.getTarget(), info, + Event::kDeliverImmediately)); } -InputFilter::KeystrokeAction::KeystrokeAction(IEventQueue *events, - IPlatformScreen::KeyInfo *info, - bool press) - : m_keyInfo(info), m_press(press), m_events(events) { +InputFilter::KeystrokeAction::KeystrokeAction( + IEventQueue *events, IPlatformScreen::KeyInfo *info, bool press) + : m_keyInfo(info), + m_press(press), + m_events(events) { // do nothing } @@ -446,14 +462,15 @@ void 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)); - m_events->addEvent(Event(type, event.getTarget(), m_keyInfo, - Event::kDeliverImmediately | Event::kDontFreeData)); - m_events->addEvent(Event(m_events->forIPrimaryScreen().fakeInputEnd(), - event.getTarget(), NULL, - Event::kDeliverImmediately)); + m_events->addEvent(Event( + m_events->forIPrimaryScreen().fakeInputBegin(), event.getTarget(), NULL, + Event::kDeliverImmediately)); + m_events->addEvent(Event( + type, event.getTarget(), m_keyInfo, + Event::kDeliverImmediately | Event::kDontFreeData)); + m_events->addEvent(Event( + m_events->forIPrimaryScreen().fakeInputEnd(), event.getTarget(), NULL, + Event::kDeliverImmediately)); } const char *InputFilter::KeystrokeAction::formatName() const { @@ -462,7 +479,9 @@ const char *InputFilter::KeystrokeAction::formatName() const { InputFilter::MouseButtonAction::MouseButtonAction( IEventQueue *events, IPlatformScreen::ButtonInfo *info, bool press) - : m_buttonInfo(info), m_press(press), m_events(events) { + : m_buttonInfo(info), + m_press(press), + m_events(events) { // do nothing } @@ -485,9 +504,9 @@ String InputFilter::MouseButtonAction::format() const { const char *type = formatName(); String key = synergy::KeyMap::formatKey(kKeyNone, m_buttonInfo->m_mask); - return synergy::string::sprintf("%s(%s%s%d)", type, key.c_str(), - key.empty() ? "" : "+", - m_buttonInfo->m_button); + return synergy::string::sprintf( + "%s(%s%s%d)", type, key.c_str(), key.empty() ? "" : "+", + m_buttonInfo->m_button); } void InputFilter::MouseButtonAction::perform(const Event &event) @@ -498,16 +517,17 @@ void InputFilter::MouseButtonAction::perform(const Event &event) if (m_buttonInfo->m_mask != 0) { KeyID key = m_press ? kKeySetModifiers : kKeyClearModifiers; modifierInfo = IKeyState::KeyInfo::alloc(key, m_buttonInfo->m_mask, 0, 1); - m_events->addEvent(Event(m_events->forIKeyState().keyDown(), - event.getTarget(), modifierInfo, - Event::kDeliverImmediately)); + m_events->addEvent(Event( + m_events->forIKeyState().keyDown(), event.getTarget(), modifierInfo, + Event::kDeliverImmediately)); } // send button Event::Type type = m_press ? m_events->forIPrimaryScreen().buttonDown() : m_events->forIPrimaryScreen().buttonUp(); - m_events->addEvent(Event(type, event.getTarget(), m_buttonInfo, - Event::kDeliverImmediately | Event::kDontFreeData)); + m_events->addEvent(Event( + type, event.getTarget(), m_buttonInfo, + Event::kDeliverImmediately | Event::kDontFreeData)); } const char *InputFilter::MouseButtonAction::formatName() const { @@ -594,8 +614,8 @@ void InputFilter::Rule::removeAction(bool onActivation, UInt32 index) { } } -void InputFilter::Rule::replaceAction(Action *adopted, bool onActivation, - UInt32 index) { +void InputFilter::Rule::replaceAction( + Action *adopted, bool onActivation, UInt32 index) { if (adopted == NULL) { removeAction(onActivation, index); } else if (onActivation) { @@ -698,8 +718,8 @@ UInt32 InputFilter::Rule::getNumActions(bool onActivation) const { } } -const InputFilter::Action &InputFilter::Rule::getAction(bool onActivation, - UInt32 index) const { +const InputFilter::Action & +InputFilter::Rule::getAction(bool onActivation, UInt32 index) const { if (onActivation) { return *m_activateActions[index]; } else { @@ -711,12 +731,15 @@ const InputFilter::Action &InputFilter::Rule::getAction(bool onActivation, // Input Filter Class // ----------------------------------------------------------------------------- InputFilter::InputFilter(IEventQueue *events) - : m_primaryClient(NULL), m_events(events) { + : m_primaryClient(NULL), + m_events(events) { // do nothing } InputFilter::InputFilter(const InputFilter &x) - : m_ruleList(x.m_ruleList), m_primaryClient(NULL), m_events(x.m_events) { + : m_ruleList(x.m_ruleList), + m_primaryClient(NULL), + m_events(x.m_events) { setPrimaryClient(x.m_primaryClient); } @@ -763,22 +786,27 @@ void InputFilter::setPrimaryClient(PrimaryClient *client) { rule->disable(m_primaryClient); } - m_events->removeHandler(m_events->forIKeyState().keyDown(), - m_primaryClient->getEventTarget()); - m_events->removeHandler(m_events->forIKeyState().keyUp(), - m_primaryClient->getEventTarget()); - m_events->removeHandler(m_events->forIKeyState().keyRepeat(), - m_primaryClient->getEventTarget()); - m_events->removeHandler(m_events->forIPrimaryScreen().buttonDown(), - m_primaryClient->getEventTarget()); - m_events->removeHandler(m_events->forIPrimaryScreen().buttonUp(), - m_primaryClient->getEventTarget()); - m_events->removeHandler(m_events->forIPrimaryScreen().hotKeyDown(), - m_primaryClient->getEventTarget()); - m_events->removeHandler(m_events->forIPrimaryScreen().hotKeyUp(), - m_primaryClient->getEventTarget()); - m_events->removeHandler(m_events->forServer().connected(), - m_primaryClient->getEventTarget()); + m_events->removeHandler( + m_events->forIKeyState().keyDown(), m_primaryClient->getEventTarget()); + m_events->removeHandler( + m_events->forIKeyState().keyUp(), m_primaryClient->getEventTarget()); + m_events->removeHandler( + m_events->forIKeyState().keyRepeat(), + m_primaryClient->getEventTarget()); + m_events->removeHandler( + m_events->forIPrimaryScreen().buttonDown(), + m_primaryClient->getEventTarget()); + m_events->removeHandler( + m_events->forIPrimaryScreen().buttonUp(), + m_primaryClient->getEventTarget()); + m_events->removeHandler( + m_events->forIPrimaryScreen().hotKeyDown(), + m_primaryClient->getEventTarget()); + m_events->removeHandler( + m_events->forIPrimaryScreen().hotKeyUp(), + m_primaryClient->getEventTarget()); + m_events->removeHandler( + m_events->forServer().connected(), m_primaryClient->getEventTarget()); } m_primaryClient = client; @@ -863,9 +891,9 @@ bool InputFilter::operator!=(const InputFilter &x) const { void InputFilter::handleEvent(const Event &event, void *) { // copy event and adjust target - Event myEvent(event.getType(), this, event.getData(), - event.getFlags() | Event::kDontFreeData | - Event::kDeliverImmediately); + Event myEvent( + event.getType(), this, event.getData(), + event.getFlags() | Event::kDontFreeData | Event::kDeliverImmediately); // let each rule try to match the event until one does for (RuleList::iterator rule = m_ruleList.begin(); rule != m_ruleList.end(); diff --git a/src/lib/server/InputFilter.h b/src/lib/server/InputFilter.h index 2de5566ba..203977dd3 100644 --- a/src/lib/server/InputFilter.h +++ b/src/lib/server/InputFilter.h @@ -204,8 +204,8 @@ public: enum Mode { kOff, kOn, kToggle }; KeyboardBroadcastAction(IEventQueue *events, Mode = kToggle); - KeyboardBroadcastAction(IEventQueue *events, Mode, - const std::set &screens); + KeyboardBroadcastAction( + IEventQueue *events, Mode, const std::set &screens); Mode getMode() const; std::set getScreens() const; @@ -224,8 +224,8 @@ public: // KeystrokeAction class KeystrokeAction : public Action { public: - KeystrokeAction(IEventQueue *events, IPlatformScreen::KeyInfo *adoptedInfo, - bool press); + KeystrokeAction( + IEventQueue *events, IPlatformScreen::KeyInfo *adoptedInfo, bool press); KeystrokeAction(KeystrokeAction const &) = delete; KeystrokeAction(KeystrokeAction &&) = delete; ~KeystrokeAction(); @@ -254,8 +254,9 @@ public: // MouseButtonAction -- modifier combinations not implemented yet class MouseButtonAction : public Action { public: - MouseButtonAction(IEventQueue *events, - IPlatformScreen::ButtonInfo *adoptedInfo, bool press); + MouseButtonAction( + IEventQueue *events, IPlatformScreen::ButtonInfo *adoptedInfo, + bool press); MouseButtonAction(MouseButtonAction const &) = delete; MouseButtonAction(MouseButtonAction &&) = delete; ~MouseButtonAction(); diff --git a/src/lib/server/PrimaryClient.cpp b/src/lib/server/PrimaryClient.cpp index 8e5841d28..c63cec4ba 100644 --- a/src/lib/server/PrimaryClient.cpp +++ b/src/lib/server/PrimaryClient.cpp @@ -27,7 +27,9 @@ // PrimaryClient::PrimaryClient(const String &name, synergy::Screen *screen) - : BaseClientProxy(name), m_screen(screen), m_fakeInputCount(0) { + : BaseClientProxy(name), + m_screen(screen), + m_fakeInputCount(0) { // all clipboards are clean for (UInt32 i = 0; i < kClipboardEnd; ++i) { m_clipboardDirty[i] = false; @@ -86,8 +88,8 @@ bool PrimaryClient::getClipboard(ClipboardID id, IClipboard *clipboard) const { return m_screen->getClipboard(id, clipboard); } -void PrimaryClient::getShape(SInt32 &x, SInt32 &y, SInt32 &width, - SInt32 &height) const { +void PrimaryClient::getShape( + SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const { m_screen->getShape(x, y, width, height); } @@ -99,8 +101,9 @@ void PrimaryClient::enable() { m_screen->enable(); } void PrimaryClient::disable() { m_screen->disable(); } -void PrimaryClient::enter(SInt32 xAbs, SInt32 yAbs, UInt32 seqNum, - KeyModifierMask mask, bool screensaver) { +void PrimaryClient::enter( + SInt32 xAbs, SInt32 yAbs, UInt32 seqNum, KeyModifierMask mask, + bool screensaver) { m_screen->setSequenceNumber(seqNum); if (!screensaver) { m_screen->warpCursor(xAbs, yAbs); @@ -133,8 +136,8 @@ void PrimaryClient::setClipboardDirty(ClipboardID id, bool dirty) { m_clipboardDirty[id] = dirty; } -void PrimaryClient::keyDown(KeyID key, KeyModifierMask mask, KeyButton button, - const String &) { +void PrimaryClient::keyDown( + KeyID key, KeyModifierMask mask, KeyButton button, const String &) { if (m_fakeInputCount > 0) { // XXX -- don't forward keystrokes to primary screen for now (void)key; @@ -144,8 +147,8 @@ void PrimaryClient::keyDown(KeyID key, KeyModifierMask mask, KeyButton button, } } -void PrimaryClient::keyRepeat(KeyID, KeyModifierMask, SInt32, KeyButton, - const String &) { +void PrimaryClient::keyRepeat( + KeyID, KeyModifierMask, SInt32, KeyButton, const String &) { // ignore } @@ -183,8 +186,8 @@ void PrimaryClient::screensaver(bool) { // ignore } -void PrimaryClient::sendDragInfo(UInt32 fileCount, const char *info, - size_t size) { +void PrimaryClient::sendDragInfo( + UInt32 fileCount, const char *info, size_t size) { // ignore } diff --git a/src/lib/server/PrimaryClient.h b/src/lib/server/PrimaryClient.h index 3bcb38006..2a849d0bf 100644 --- a/src/lib/server/PrimaryClient.h +++ b/src/lib/server/PrimaryClient.h @@ -120,20 +120,21 @@ public: // 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 + 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; + 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 keyRepeat( + KeyID, KeyModifierMask, SInt32 count, KeyButton, const String &) override; void keyUp(KeyID, KeyModifierMask, KeyButton) override; void mouseDown(ButtonID) override; void mouseUp(ButtonID) override; diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index b65a64917..875db9822 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -58,23 +58,45 @@ // Server // -Server::Server(Config &config, PrimaryClient *primaryClient, - synergy::Screen *screen, IEventQueue *events, - lib::synergy::ServerArgs const &args) - : m_mock(false), m_primaryClient(primaryClient), m_active(primaryClient), - m_seqNum(0), m_xDelta(0), m_yDelta(0), m_xDelta2(0), m_yDelta2(0), - m_config(&config), m_inputFilter(config.getInputFilter()), - m_activeSaver(NULL), m_switchDir(kNoDirection), m_switchScreen(NULL), - m_switchWaitDelay(0.0), m_switchWaitTimer(NULL), m_switchTwoTapDelay(0.0), - m_switchTwoTapEngaged(false), m_switchTwoTapArmed(false), - m_switchTwoTapZone(3), m_switchNeedsShift(false), - m_switchNeedsControl(false), m_switchNeedsAlt(false), - m_relativeMoves(false), m_keyboardBroadcasting(false), - m_lockedToScreen(false), m_screen(screen), m_events(events), - m_sendFileThread(nullptr), m_writeToDropDirThread(nullptr), - m_ignoreFileTransfer(false), m_disableLockToScreen(false), - m_enableClipboard(true), m_maximumClipboardSize(INT_MAX), - m_sendDragInfoThread(nullptr), m_waitDragInfoThread(true), m_args(args) { +Server::Server( + Config &config, PrimaryClient *primaryClient, synergy::Screen *screen, + IEventQueue *events, lib::synergy::ServerArgs const &args) + : m_mock(false), + m_primaryClient(primaryClient), + m_active(primaryClient), + m_seqNum(0), + m_xDelta(0), + m_yDelta(0), + m_xDelta2(0), + m_yDelta2(0), + m_config(&config), + m_inputFilter(config.getInputFilter()), + m_activeSaver(NULL), + m_switchDir(kNoDirection), + m_switchScreen(NULL), + m_switchWaitDelay(0.0), + m_switchWaitTimer(NULL), + m_switchTwoTapDelay(0.0), + m_switchTwoTapEngaged(false), + m_switchTwoTapArmed(false), + m_switchTwoTapZone(3), + m_switchNeedsShift(false), + m_switchNeedsControl(false), + m_switchNeedsAlt(false), + m_relativeMoves(false), + m_keyboardBroadcasting(false), + m_lockedToScreen(false), + m_screen(screen), + m_events(events), + m_sendFileThread(nullptr), + m_writeToDropDirThread(nullptr), + m_ignoreFileTransfer(false), + m_disableLockToScreen(false), + m_enableClipboard(true), + m_maximumClipboardSize(INT_MAX), + m_sendDragInfoThread(nullptr), + m_waitDragInfoThread(true), + m_args(args) { // must have a primary client and it must have a canonical name assert(m_primaryClient != NULL); assert(config.isScreen(primaryClient->getName())); @@ -124,14 +146,16 @@ Server::Server(Config &config, PrimaryClient *primaryClient, m_events->adoptHandler( m_events->forIPrimaryScreen().wheel(), m_primaryClient->getEventTarget(), new TMethodEventJob(this, &Server::handleWheelEvent)); - m_events->adoptHandler(m_events->forIPrimaryScreen().screensaverActivated(), - m_primaryClient->getEventTarget(), - new TMethodEventJob( - this, &Server::handleScreensaverActivatedEvent)); - m_events->adoptHandler(m_events->forIPrimaryScreen().screensaverDeactivated(), - m_primaryClient->getEventTarget(), - new TMethodEventJob( - this, &Server::handleScreensaverDeactivatedEvent)); + m_events->adoptHandler( + m_events->forIPrimaryScreen().screensaverActivated(), + m_primaryClient->getEventTarget(), + new TMethodEventJob( + this, &Server::handleScreensaverActivatedEvent)); + m_events->adoptHandler( + m_events->forIPrimaryScreen().screensaverDeactivated(), + m_primaryClient->getEventTarget(), + new TMethodEventJob( + this, &Server::handleScreensaverDeactivatedEvent)); m_events->adoptHandler( m_events->forServer().switchToScreen(), m_inputFilter, new TMethodEventJob(this, &Server::handleSwitchToScreenEvent)); @@ -141,10 +165,10 @@ Server::Server(Config &config, PrimaryClient *primaryClient, m_events->adoptHandler( m_events->forServer().keyboardBroadcast(), m_inputFilter, new TMethodEventJob(this, &Server::handleKeyboardBroadcastEvent)); - m_events->adoptHandler(m_events->forServer().lockCursorToScreen(), - m_inputFilter, - new TMethodEventJob( - this, &Server::handleLockCursorToScreenEvent)); + m_events->adoptHandler( + m_events->forServer().lockCursorToScreen(), m_inputFilter, + new TMethodEventJob( + this, &Server::handleLockCursorToScreenEvent)); m_events->adoptHandler( m_events->forIPrimaryScreen().fakeInputBegin(), m_inputFilter, new TMethodEventJob(this, &Server::handleFakeInputBeginEvent)); @@ -153,12 +177,14 @@ Server::Server(Config &config, PrimaryClient *primaryClient, new TMethodEventJob(this, &Server::handleFakeInputEndEvent)); if (m_args.m_enableDragDrop) { - m_events->adoptHandler(m_events->forFile().fileChunkSending(), this, - new TMethodEventJob( - this, &Server::handleFileChunkSendingEvent)); - m_events->adoptHandler(m_events->forFile().fileRecieveCompleted(), this, - new TMethodEventJob( - this, &Server::handleFileRecieveCompletedEvent)); + m_events->adoptHandler( + m_events->forFile().fileChunkSending(), this, + new TMethodEventJob( + this, &Server::handleFileChunkSendingEvent)); + m_events->adoptHandler( + m_events->forFile().fileRecieveCompleted(), this, + new TMethodEventJob( + this, &Server::handleFileRecieveCompletedEvent)); } // add connection @@ -188,25 +214,28 @@ Server::~Server() { m_events->removeHandler(m_events->forIKeyState().keyDown(), m_inputFilter); m_events->removeHandler(m_events->forIKeyState().keyUp(), m_inputFilter); m_events->removeHandler(m_events->forIKeyState().keyRepeat(), m_inputFilter); - m_events->removeHandler(m_events->forIPrimaryScreen().buttonDown(), - m_inputFilter); - m_events->removeHandler(m_events->forIPrimaryScreen().buttonUp(), - m_inputFilter); - m_events->removeHandler(m_events->forIPrimaryScreen().motionOnPrimary(), - m_primaryClient->getEventTarget()); - m_events->removeHandler(m_events->forIPrimaryScreen().motionOnSecondary(), - m_primaryClient->getEventTarget()); - m_events->removeHandler(m_events->forIPrimaryScreen().wheel(), - m_primaryClient->getEventTarget()); - m_events->removeHandler(m_events->forIPrimaryScreen().screensaverActivated(), - m_primaryClient->getEventTarget()); + m_events->removeHandler( + m_events->forIPrimaryScreen().buttonDown(), m_inputFilter); + m_events->removeHandler( + m_events->forIPrimaryScreen().buttonUp(), m_inputFilter); + m_events->removeHandler( + m_events->forIPrimaryScreen().motionOnPrimary(), + m_primaryClient->getEventTarget()); + m_events->removeHandler( + m_events->forIPrimaryScreen().motionOnSecondary(), + m_primaryClient->getEventTarget()); + m_events->removeHandler( + m_events->forIPrimaryScreen().wheel(), m_primaryClient->getEventTarget()); + m_events->removeHandler( + m_events->forIPrimaryScreen().screensaverActivated(), + m_primaryClient->getEventTarget()); m_events->removeHandler( m_events->forIPrimaryScreen().screensaverDeactivated(), m_primaryClient->getEventTarget()); - m_events->removeHandler(m_events->forIPrimaryScreen().fakeInputBegin(), - m_inputFilter); - m_events->removeHandler(m_events->forIPrimaryScreen().fakeInputEnd(), - m_inputFilter); + m_events->removeHandler( + m_events->forIPrimaryScreen().fakeInputBegin(), m_inputFilter); + m_events->removeHandler( + m_events->forIPrimaryScreen().fakeInputEnd(), m_inputFilter); m_events->removeHandler(Event::kTimer, this); stopSwitch(); @@ -274,13 +303,15 @@ void Server::adoptClient(BaseClientProxy *client) { assert(client != NULL); // watch for client disconnection - m_events->adoptHandler(m_events->forClientProxy().disconnected(), client, - new TMethodEventJob( - this, &Server::handleClientDisconnected, client)); + m_events->adoptHandler( + m_events->forClientProxy().disconnected(), client, + new TMethodEventJob( + this, &Server::handleClientDisconnected, client)); // name must be in our configuration if (!m_config->isScreen(client->getName())) { - LOG((CLOG_WARN "unrecognised client name \"%s\", check server config", + LOG( + (CLOG_WARN "unrecognised client name \"%s\", check server config", client->getName().c_str())); closeClient(client, kMsgEUnknown); return; @@ -289,7 +320,8 @@ void Server::adoptClient(BaseClientProxy *client) { // add client to client list if (!addClient(client)) { // can only have one screen with a given name at any given time - LOG((CLOG_WARN "a client with name \"%s\" is already connected", + LOG( + (CLOG_WARN "a client with name \"%s\" is already connected", getName(client).c_str())); closeClient(client, kMsgEBusy); return; @@ -307,8 +339,9 @@ void Server::adoptClient(BaseClientProxy *client) { // send notification Server::ScreenConnectedInfo *info = new Server::ScreenConnectedInfo(getName(client)); - m_events->addEvent(Event(m_events->forServer().connected(), - m_primaryClient->getEventTarget(), info)); + m_events->addEvent(Event( + m_events->forServer().connected(), m_primaryClient->getEventTarget(), + info)); } void Server::disconnect() { @@ -391,8 +424,8 @@ SInt32 Server::getJumpZoneSize(BaseClientProxy *client) const { } } -void Server::switchScreen(BaseClientProxy *dst, SInt32 x, SInt32 y, - bool forScreensaver) { +void Server::switchScreen( + BaseClientProxy *dst, SInt32 x, SInt32 y, bool forScreensaver) { assert(dst != NULL); // if trial is expired, exit the process @@ -410,7 +443,8 @@ void Server::switchScreen(BaseClientProxy *dst, SInt32 x, SInt32 y, #endif assert(m_active != NULL); - LOG((CLOG_INFO "switch from \"%s\" to \"%s\" at %d,%d", + LOG( + (CLOG_INFO "switch from \"%s\" to \"%s\" at %d,%d", getName(m_active).c_str(), getName(dst).c_str(), x, y)); // stop waiting to switch @@ -465,8 +499,8 @@ void Server::switchScreen(BaseClientProxy *dst, SInt32 x, SInt32 y, ++m_seqNum; // enter new screen - m_active->enter(x, y, m_seqNum, m_primaryClient->getToggleMask(), - forScreensaver); + m_active->enter( + x, y, m_seqNum, m_primaryClient->getToggleMask(), forScreensaver); if (m_enableClipboard) { // send the clipboard data to new active screen @@ -502,8 +536,8 @@ void Server::jumpToScreen(BaseClientProxy *newScreen) { switchScreen(newScreen, x, y, false); } -float Server::mapToFraction(BaseClientProxy *client, EDirection dir, SInt32 x, - SInt32 y) const { +float Server::mapToFraction( + BaseClientProxy *client, EDirection dir, SInt32 x, SInt32 y) const { SInt32 sx, sy, sw, sh; client->getShape(sx, sy, sw, sh); switch (dir) { @@ -522,8 +556,9 @@ float Server::mapToFraction(BaseClientProxy *client, EDirection dir, SInt32 x, return 0.0f; } -void Server::mapToPixel(BaseClientProxy *client, EDirection dir, float f, - SInt32 &x, SInt32 &y) const { +void Server::mapToPixel( + BaseClientProxy *client, EDirection dir, float f, SInt32 &x, + SInt32 &y) const { SInt32 sx, sy, sw, sh; client->getShape(sx, sy, sw, sh); switch (dir) { @@ -549,8 +584,8 @@ bool Server::hasAnyNeighbor(BaseClientProxy *client, EDirection dir) const { return m_config->hasNeighbor(getName(client), dir); } -BaseClientProxy *Server::getNeighbor(BaseClientProxy *src, EDirection dir, - SInt32 &x, SInt32 &y) const { +BaseClientProxy *Server::getNeighbor( + BaseClientProxy *src, EDirection dir, SInt32 &x, SInt32 &y) const { // note -- must be locked on entry assert(src != NULL); @@ -558,7 +593,8 @@ BaseClientProxy *Server::getNeighbor(BaseClientProxy *src, EDirection dir, // get source screen name String srcName = getName(src); assert(!srcName.empty()); - LOG((CLOG_DEBUG2 "find neighbor on %s of \"%s\"", Config::dirName(dir), + LOG( + (CLOG_DEBUG2 "find neighbor on %s of \"%s\"", Config::dirName(dir), srcName.c_str())); // convert position to fraction @@ -574,7 +610,8 @@ BaseClientProxy *Server::getNeighbor(BaseClientProxy *src, EDirection dir, // progress in this direction. since we haven't found a // connected neighbor we return NULL. if (dstName.empty()) { - LOG((CLOG_DEBUG2 "no neighbor on %s of \"%s\"", Config::dirName(dir), + LOG( + (CLOG_DEBUG2 "no neighbor on %s of \"%s\"", Config::dirName(dir), srcName.c_str())); return NULL; } @@ -583,14 +620,16 @@ BaseClientProxy *Server::getNeighbor(BaseClientProxy *src, EDirection dir, // ready then we can stop. ClientList::const_iterator index = m_clients.find(dstName); if (index != m_clients.end()) { - LOG((CLOG_DEBUG2 "\"%s\" is on %s of \"%s\" at %f", dstName.c_str(), + LOG( + (CLOG_DEBUG2 "\"%s\" is on %s of \"%s\" at %f", dstName.c_str(), Config::dirName(dir), srcName.c_str(), t)); mapToPixel(index->second, dir, tTmp, x, y); return index->second; } // skip over unconnected screen - LOG((CLOG_DEBUG2 "ignored \"%s\" on %s of \"%s\"", dstName.c_str(), + LOG( + (CLOG_DEBUG2 "ignored \"%s\" on %s of \"%s\"", dstName.c_str(), Config::dirName(dir), srcName.c_str())); srcName = dstName; @@ -599,8 +638,8 @@ BaseClientProxy *Server::getNeighbor(BaseClientProxy *src, EDirection dir, } } -BaseClientProxy *Server::mapToNeighbor(BaseClientProxy *src, EDirection srcSide, - SInt32 &x, SInt32 &y) const { +BaseClientProxy *Server::mapToNeighbor( + BaseClientProxy *src, EDirection srcSide, SInt32 &x, SInt32 &y) const { // note -- must be locked on entry assert(src != NULL); @@ -704,8 +743,8 @@ BaseClientProxy *Server::mapToNeighbor(BaseClientProxy *src, EDirection srcSide, return dst; } -void Server::avoidJumpZone(BaseClientProxy *dst, EDirection dir, SInt32 &x, - SInt32 &y) const { +void Server::avoidJumpZone( + BaseClientProxy *dst, EDirection dir, SInt32 &x, SInt32 &y) const { // we only need to avoid jump zones on the primary screen if (dst != m_primaryClient) { return; @@ -748,9 +787,11 @@ void Server::avoidJumpZone(BaseClientProxy *dst, EDirection dir, SInt32 &x, } } -bool Server::isSwitchOkay(BaseClientProxy *newScreen, EDirection dir, SInt32 x, - SInt32 y, SInt32 xActive, SInt32 yActive) { - LOG((CLOG_DEBUG1 "try to leave \"%s\" on %s", getName(m_active).c_str(), +bool Server::isSwitchOkay( + BaseClientProxy *newScreen, EDirection dir, SInt32 x, SInt32 y, + SInt32 xActive, SInt32 yActive) { + LOG( + (CLOG_DEBUG1 "try to leave \"%s\" on %s", getName(m_active).c_str(), Config::dirName(dir))); // is there a neighbor? @@ -922,8 +963,9 @@ bool Server::isSwitchTwoTapStarted() const { return m_switchTwoTapEngaged; } bool Server::shouldSwitchTwoTap() const { // this is the second tap if two-tap is armed and this tap // came fast enough - return (m_switchTwoTapArmed && - m_switchTwoTapTimer.getTime() <= m_switchTwoTapDelay); + return ( + m_switchTwoTapArmed && + m_switchTwoTapTimer.getTime() <= m_switchTwoTapDelay); } void Server::startSwitchWait(SInt32 x, SInt32 y) { @@ -943,8 +985,8 @@ void Server::stopSwitchWait() { bool Server::isSwitchWaitStarted() const { return (m_switchWaitTimer != NULL); } -UInt32 Server::getCorner(BaseClientProxy *client, SInt32 x, SInt32 y, - SInt32 size) const { +UInt32 Server::getCorner( + BaseClientProxy *client, SInt32 x, SInt32 y, SInt32 size) const { assert(client != NULL); // get client screen shape @@ -1003,7 +1045,8 @@ void Server::stopRelativeMoves() { m_yDelta = 0; m_xDelta2 = 0; m_yDelta2 = 0; - LOG((CLOG_DEBUG2 "synchronize move on %s by %d,%d", + LOG( + (CLOG_DEBUG2 "synchronize move on %s by %d,%d", getName(m_active).c_str(), m_x, m_y)); m_active->mouseMove(m_x, m_y); } @@ -1147,13 +1190,15 @@ void Server::handleClipboardGrabbed(const Event &event, void *vclient) { ClipboardInfo &clipboard = m_clipboards[info->m_id]; if (grabber != m_primaryClient && info->m_sequenceNumber < clipboard.m_clipboardSeqNum) { - LOG((CLOG_INFO "ignored screen \"%s\" grab of clipboard %d", + LOG( + (CLOG_INFO "ignored screen \"%s\" grab of clipboard %d", getName(grabber).c_str(), info->m_id)); return; } // mark screen as owning clipboard - LOG((CLOG_INFO "screen \"%s\" grabbed clipboard %d from \"%s\"", + LOG( + (CLOG_INFO "screen \"%s\" grabbed clipboard %d from \"%s\"", getName(grabber).c_str(), info->m_id, clipboard.m_clipboardOwner.c_str())); clipboard.m_clipboardOwner = getName(grabber); @@ -1182,8 +1227,8 @@ void Server::handleClipboardGrabbed(const Event &event, void *vclient) { LOG((CLOG_INFO "clipboard grabbed, but we are already changed active " "screen. Resend clipboard data")); for (ClipboardID id = 0; id < kClipboardEnd; ++id) { - onClipboardChanged(m_primaryClient, id, - m_clipboards[id].m_clipboardSeqNum); + onClipboardChanged( + m_primaryClient, id, m_clipboards[id].m_clipboardSeqNum); } } } @@ -1283,7 +1328,8 @@ void Server::handleClientDisconnected(const Event &, void *vclient) { void Server::handleClientCloseTimeout(const Event &, void *vclient) { // client took too long to disconnect. just dump it. BaseClientProxy *client = static_cast(vclient); - LOG((CLOG_NOTE "forced disconnection of client \"%s\"", + LOG( + (CLOG_NOTE "forced disconnection of client \"%s\"", getName(client).c_str())); removeOldClient(client); @@ -1340,7 +1386,8 @@ void Server::handleKeyboardBroadcastEvent(const Event &event, void *) { info->m_screens != m_keyboardBroadcastingScreens) { m_keyboardBroadcasting = newState; m_keyboardBroadcastingScreens = info->m_screens; - LOG((CLOG_DEBUG "keyboard broadcasting %s: %s", + LOG( + (CLOG_DEBUG "keyboard broadcasting %s: %s", m_keyboardBroadcasting ? "on" : "off", m_keyboardBroadcastingScreens.c_str())); } @@ -1369,7 +1416,8 @@ void Server::handleLockCursorToScreenEvent(const Event &event, void *) { // enter new state if (newState != m_lockedToScreen) { m_lockedToScreen = newState; - LOG((CLOG_NOTE "cursor %s current screen", + LOG( + (CLOG_NOTE "cursor %s current screen", m_lockedToScreen ? "locked to" : "unlocked from")); m_primaryClient->reconfigure(getActivePrimarySides()); @@ -1395,15 +1443,15 @@ void Server::handleFileRecieveCompletedEvent(const Event &event, void *) { onFileRecieveCompleted(); } -void Server::onClipboardChanged(BaseClientProxy *sender, ClipboardID id, - UInt32 seqNum) { +void Server::onClipboardChanged( + BaseClientProxy *sender, ClipboardID id, UInt32 seqNum) { ClipboardInfo &clipboard = m_clipboards[id]; // ignore update if sequence number is old if (seqNum < clipboard.m_clipboardSeqNum) { - LOG((CLOG_INFO - "ignored screen \"%s\" update of clipboard %d (missequenced)", - getName(sender).c_str(), id)); + LOG(( + CLOG_INFO "ignored screen \"%s\" update of clipboard %d (missequenced)", + getName(sender).c_str(), id)); return; } @@ -1415,7 +1463,8 @@ void Server::onClipboardChanged(BaseClientProxy *sender, ClipboardID id, String data = clipboard.m_clipboard.marshall(); if (data.size() > m_maximumClipboardSize * 1024) { - LOG((CLOG_NOTE "not updating clipboard because it's over the size limit " + LOG( + (CLOG_NOTE "not updating clipboard because it's over the size limit " "(%i KB) configured by the server", m_maximumClipboardSize)); return; @@ -1423,13 +1472,15 @@ void Server::onClipboardChanged(BaseClientProxy *sender, ClipboardID id, // ignore if data hasn't changed if (data == clipboard.m_clipboardData) { - LOG((CLOG_DEBUG "ignored screen \"%s\" update of clipboard %d (unchanged)", + LOG( + (CLOG_DEBUG "ignored screen \"%s\" update of clipboard %d (unchanged)", clipboard.m_clipboardOwner.c_str(), id)); return; } // got new data - LOG((CLOG_INFO "screen \"%s\" updated clipboard %d", + LOG( + (CLOG_INFO "screen \"%s\" updated clipboard %d", clipboard.m_clipboardOwner.c_str(), id)); clipboard.m_clipboardData = data; @@ -1494,9 +1545,11 @@ void Server::onScreensaver(bool activated) { } } -void Server::onKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, - const String &lang, const char *screens) { - LOG((CLOG_DEBUG1 "onKeyDown id=%d mask=0x%04x button=0x%04x lang=%s", id, +void Server::onKeyDown( + KeyID id, KeyModifierMask mask, KeyButton button, const String &lang, + const char *screens) { + LOG( + (CLOG_DEBUG1 "onKeyDown id=%d mask=0x%04x button=0x%04x lang=%s", id, mask, button, lang.c_str())); assert(m_active != NULL); @@ -1519,10 +1572,10 @@ void Server::onKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, } } -void Server::onKeyUp(KeyID id, KeyModifierMask mask, KeyButton button, - const char *screens) { - LOG((CLOG_DEBUG1 "onKeyUp id=%d mask=0x%04x button=0x%04x", id, mask, - button)); +void Server::onKeyUp( + KeyID id, KeyModifierMask mask, KeyButton button, const char *screens) { + LOG(( + CLOG_DEBUG1 "onKeyUp id=%d mask=0x%04x button=0x%04x", id, mask, button)); assert(m_active != NULL); // relay @@ -1544,9 +1597,11 @@ void Server::onKeyUp(KeyID id, KeyModifierMask mask, KeyButton button, } } -void Server::onKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, - KeyButton button, const String &lang) { - LOG((CLOG_DEBUG1 +void Server::onKeyRepeat( + KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, + const String &lang) { + LOG( + (CLOG_DEBUG1 "onKeyRepeat id=%d mask=0x%04x count=%d button=0x%04x lang=\"%s\"", id, mask, count, button, lang.c_str())); assert(m_active != NULL); @@ -1747,7 +1802,8 @@ void Server::onMouseMoveSecondary(SInt32 dx, SInt32 dy) { // program on the secondary screen to warp the mouse on us, so we // have no idea where it really is. if (m_relativeMoves && isLockedToScreenServer()) { - LOG((CLOG_DEBUG2 "relative move on %s by %d,%d", getName(m_active).c_str(), + LOG( + (CLOG_DEBUG2 "relative move on %s by %d,%d", getName(m_active).c_str(), dx, dy)); m_active->mouseRelativeMove(dx, dy); return; @@ -1883,7 +1939,8 @@ void Server::onMouseMoveSecondary(SInt32 dx, SInt32 dy) { // warp cursor if it moved. if (m_x != xOld || m_y != yOld) { - LOG((CLOG_DEBUG2 "move on %s to %d,%d", getName(m_active).c_str(), m_x, + LOG( + (CLOG_DEBUG2 "move on %s to %d,%d", getName(m_active).c_str(), m_x, m_y)); m_active->mouseMove(m_x, m_y); } @@ -1905,8 +1962,8 @@ void Server::onFileChunkSending(const void *data) { assert(m_active != NULL); // relay - m_active->fileChunkSending(chunk->m_chunk[0], &chunk->m_chunk[1], - chunk->m_dataSize); + m_active->fileChunkSending( + chunk->m_chunk[0], &chunk->m_chunk[1], chunk->m_dataSize); } void Server::onFileRecieveCompleted() { @@ -1923,8 +1980,8 @@ void Server::writeToDropDirThread(void *) { ARCH->sleep(.1f); } - DropHelper::writeToDir(m_screen->getDropTarget(), m_fakeDragFileList, - m_receivedFileData); + DropHelper::writeToDir( + m_screen->getDropTarget(), m_fakeDragFileList, m_receivedFileData); } bool Server::addClient(BaseClientProxy *client) { @@ -1937,14 +1994,14 @@ bool Server::addClient(BaseClientProxy *client) { m_events->adoptHandler( m_events->forIScreen().shapeChanged(), client->getEventTarget(), new TMethodEventJob(this, &Server::handleShapeChanged, client)); - m_events->adoptHandler(m_events->forClipboard().clipboardGrabbed(), - client->getEventTarget(), - new TMethodEventJob( - this, &Server::handleClipboardGrabbed, client)); - m_events->adoptHandler(m_events->forClipboard().clipboardChanged(), - client->getEventTarget(), - new TMethodEventJob( - this, &Server::handleClipboardChanged, client)); + m_events->adoptHandler( + m_events->forClipboard().clipboardGrabbed(), client->getEventTarget(), + new TMethodEventJob( + this, &Server::handleClipboardGrabbed, client)); + m_events->adoptHandler( + m_events->forClipboard().clipboardChanged(), client->getEventTarget(), + new TMethodEventJob( + this, &Server::handleClipboardChanged, client)); // add to list m_clientSet.insert(client); @@ -1969,12 +2026,12 @@ bool Server::removeClient(BaseClientProxy *client) { } // remove event handlers - m_events->removeHandler(m_events->forIScreen().shapeChanged(), - client->getEventTarget()); - m_events->removeHandler(m_events->forClipboard().clipboardGrabbed(), - client->getEventTarget()); - m_events->removeHandler(m_events->forClipboard().clipboardChanged(), - client->getEventTarget()); + m_events->removeHandler( + m_events->forIScreen().shapeChanged(), client->getEventTarget()); + m_events->removeHandler( + m_events->forClipboard().clipboardGrabbed(), client->getEventTarget()); + m_events->removeHandler( + m_events->forClipboard().clipboardChanged(), client->getEventTarget()); // remove from list m_clients.erase(getName(client)); @@ -2004,9 +2061,10 @@ void Server::closeClient(BaseClientProxy *client, const char *msg) { // install timer. wait timeout seconds for client to close. double timeout = 5.0; EventQueueTimer *timer = m_events->newOneShotTimer(timeout, NULL); - m_events->adoptHandler(Event::kTimer, timer, - new TMethodEventJob( - this, &Server::handleClientCloseTimeout, client)); + m_events->adoptHandler( + Event::kTimer, timer, + new TMethodEventJob( + this, &Server::handleClientCloseTimeout, client)); // move client to closing list removeClient(client); @@ -2076,7 +2134,8 @@ void Server::forceLeaveClient(BaseClientProxy *client) { // don't notify active screen since it has probably already // disconnected. - LOG((CLOG_INFO "jump from \"%s\" to \"%s\" at %d,%d", + LOG( + (CLOG_INFO "jump from \"%s\" to \"%s\" at %d,%d", getName(active).c_str(), getName(m_primaryClient).c_str(), m_x, m_y)); // cut over @@ -2085,8 +2144,8 @@ void Server::forceLeaveClient(BaseClientProxy *client) { // enter new screen (unless we already have because of the // screen saver) if (m_activeSaver == NULL) { - m_primaryClient->enter(m_x, m_y, m_seqNum, - m_primaryClient->getToggleMask(), false); + m_primaryClient->enter( + m_x, m_y, m_seqNum, m_primaryClient->getToggleMask(), false); } } @@ -2106,7 +2165,9 @@ void Server::forceLeaveClient(BaseClientProxy *client) { // Server::ClipboardInfo::ClipboardInfo() - : m_clipboard(), m_clipboardData(), m_clipboardOwner(), + : m_clipboard(), + m_clipboardData(), + m_clipboardOwner(), m_clipboardSeqNum(0) { // do nothing } @@ -2165,8 +2226,8 @@ Server::KeyboardBroadcastInfo::alloc(State state, const String &screens) { KeyboardBroadcastInfo *info = (KeyboardBroadcastInfo *)malloc( sizeof(KeyboardBroadcastInfo) + screens.size()); info->m_state = state; - std::copy(screens.c_str(), screens.c_str() + screens.size() + 1, - info->m_screens); + std::copy( + screens.c_str(), screens.c_str() + screens.size() + 1, info->m_screens); return info; } diff --git a/src/lib/server/Server.h b/src/lib/server/Server.h index 20852af78..bb3d2ab37 100644 --- a/src/lib/server/Server.h +++ b/src/lib/server/Server.h @@ -109,8 +109,9 @@ public: client (local screen) \p primaryClient. The client retains ownership of \p primaryClient. */ - Server(Config &config, PrimaryClient *primaryClient, synergy::Screen *screen, - IEventQueue *events, lib::synergy::ServerArgs const &args); + Server( + Config &config, PrimaryClient *primaryClient, synergy::Screen *screen, + IEventQueue *events, lib::synergy::ServerArgs const &args); Server(Server const &) = delete; Server(Server &&) = delete; ~Server(); @@ -223,8 +224,8 @@ private: // 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; + 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. @@ -232,16 +233,16 @@ private: // 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; + 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; + 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. @@ -250,8 +251,9 @@ private: // 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); + 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. @@ -324,11 +326,11 @@ private: void handleFileRecieveCompletedEvent(const Event &, void *); // event processing - void onClipboardChanged(BaseClientProxy *sender, ClipboardID id, - UInt32 seqNum); + void + onClipboardChanged(BaseClientProxy *sender, ClipboardID id, UInt32 seqNum); void onScreensaver(bool activated); - void onKeyDown(KeyID, KeyModifierMask, KeyButton, const String &, - const char *screens); + 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); diff --git a/src/lib/shared/SerialKeyEdition.h b/src/lib/shared/SerialKeyEdition.h index 76d3fb039..703b1f614 100644 --- a/src/lib/shared/SerialKeyEdition.h +++ b/src/lib/shared/SerialKeyEdition.h @@ -21,8 +21,8 @@ #include class SerialKeyEdition { - friend bool operator==(SerialKeyEdition const &, - SerialKeyEdition const &) = default; + friend bool + operator==(SerialKeyEdition const &, SerialKeyEdition const &) = default; public: SerialKeyEdition() = default; diff --git a/src/lib/shared/SerialKeyParser.cpp b/src/lib/shared/SerialKeyParser.cpp index 01d887879..c94dcf145 100644 --- a/src/lib/shared/SerialKeyParser.cpp +++ b/src/lib/shared/SerialKeyParser.cpp @@ -28,8 +28,9 @@ void SerialKeyParser::setEdition(const std::string &edition) { if (m_data.keyType.isMaintenance() && m_data.edition.getType() == Edition::kBasic) { m_data.edition.setType(kLite); - } else if (m_data.keyType.isMaintenance() && - m_data.edition.getType() == Edition::kPro) { + } else if ( + m_data.keyType.isMaintenance() && + m_data.edition.getType() == Edition::kPro) { m_data.edition.setType(kUltimate); } } @@ -78,8 +79,8 @@ bool SerialKeyParser::parse(const std::string &plainSerial) { setKey(plainSerial); parseV1(parts); valid = true; - } else if ((parts.size() == 9) && - (parts.at(0).find("v2") != std::string::npos)) { + } else if ( + (parts.size() == 9) && (parts.at(0).find("v2") != std::string::npos)) { setKey(plainSerial); parseV2(parts); valid = true; diff --git a/src/lib/synergy/App.cpp b/src/lib/synergy/App.cpp index dd9999c89..4e1ae33d7 100644 --- a/src/lib/synergy/App.cpp +++ b/src/lib/synergy/App.cpp @@ -58,12 +58,19 @@ App *App::s_instance = nullptr; // App // -App::App(IEventQueue *events, CreateTaskBarReceiverFunc createTaskBarReceiver, - lib::synergy::ArgsBase *args) - : m_bye(&exit), m_taskBarReceiver(NULL), m_suspended(false), - m_events(events), m_args(args), m_fileLog(nullptr), - m_createTaskBarReceiver(createTaskBarReceiver), m_appUtil(events), - m_ipcClient(nullptr), m_socketMultiplexer(nullptr) { +App::App( + IEventQueue *events, CreateTaskBarReceiverFunc createTaskBarReceiver, + lib::synergy::ArgsBase *args) + : m_bye(&exit), + m_taskBarReceiver(NULL), + m_suspended(false), + m_events(events), + m_args(args), + m_fileLog(nullptr), + m_createTaskBarReceiver(createTaskBarReceiver), + m_appUtil(events), + m_ipcClient(nullptr), + m_socketMultiplexer(nullptr) { assert(s_instance == nullptr); s_instance = this; } @@ -87,9 +94,10 @@ void App::version() { #endif char buffer[buffer_size]; - snprintf(buffer, buffer_size, "%s %s, protocol version %d.%d\n%s", - argsBase().m_pname, version.str().c_str(), kProtocolMajorVersion, - kProtocolMinorVersion, copyrightBuffer); + snprintf( + buffer, buffer_size, "%s %s, protocol version %d.%d\n%s", + argsBase().m_pname, version.str().c_str(), kProtocolMajorVersion, + kProtocolMinorVersion, copyrightBuffer); std::cout << buffer << std::endl; } @@ -121,7 +129,8 @@ int App::run(int argc, char **argv) { // using the exit(int) function! result = e.getCode(); } catch (DisplayInvalidException &die) { - LOG((CLOG_CRIT "a display invalid exception error occurred: %s\n", + LOG( + (CLOG_CRIT "a display invalid exception error occurred: %s\n", die.what())); // display invalid exceptions can occur when going to sleep. When this // process exits, the UI will restart us instantly. We don't really want @@ -160,7 +169,8 @@ void App::setupFileLogging() { void App::loggingFilterWarning() { if (CLOG->getFilter() > CLOG->getConsoleMaxLevel()) { if (argsBase().m_logFile == NULL) { - LOG((CLOG_WARN + LOG( + (CLOG_WARN "log messages above %s are NOT sent to console (use file logging)", CLOG->getFilterName(CLOG->getConsoleMaxLevel()))); } @@ -176,7 +186,8 @@ void App::initApp(int argc, const char **argv) { // set log filter if (!CLOG->setFilter(argsBase().m_logFilter)) { - LOG((CLOG_CRIT "%s: unrecognized log level `%s'" BYE, argsBase().m_pname, + LOG( + (CLOG_CRIT "%s: unrecognized log level `%s'" BYE, argsBase().m_pname, argsBase().m_logFilter, argsBase().m_pname)); m_bye(kExitArgs); } @@ -212,8 +223,8 @@ void App::initIpcClient() { void App::cleanupIpcClient() { m_ipcClient->disconnect(); - m_events->removeHandler(m_events->forIpcClient().messageReceived(), - m_ipcClient); + m_events->removeHandler( + m_events->forIpcClient().messageReceived(), m_ipcClient); delete m_ipcClient; } @@ -248,8 +259,8 @@ MinimalApp::~MinimalApp() {} int MinimalApp::standardStartup(int argc, char **argv) { return 0; } -int MinimalApp::runInner(int argc, char **argv, ILogOutputter *outputter, - StartupFunc startup) { +int MinimalApp::runInner( + int argc, char **argv, ILogOutputter *outputter, StartupFunc startup) { return 0; } diff --git a/src/lib/synergy/App.h b/src/lib/synergy/App.h index c5cfd63ab..31493054e 100644 --- a/src/lib/synergy/App.h +++ b/src/lib/synergy/App.h @@ -145,8 +145,8 @@ public: // IApp overrides virtual int standardStartup(int argc, char **argv); - virtual int runInner(int argc, char **argv, ILogOutputter *outputter, - StartupFunc startup); + virtual int runInner( + int argc, char **argv, ILogOutputter *outputter, StartupFunc startup); virtual void startNode(); virtual int mainLoop(); virtual int foregroundStartup(int argc, char **argv); diff --git a/src/lib/synergy/ArgParser.cpp b/src/lib/synergy/ArgParser.cpp index 7e1816736..0ad625d3e 100644 --- a/src/lib/synergy/ArgParser.cpp +++ b/src/lib/synergy/ArgParser.cpp @@ -34,8 +34,8 @@ lib::synergy::ArgsBase *ArgParser::m_argsBase = NULL; ArgParser::ArgParser(App *app) : m_app(app) {} -bool ArgParser::parseServerArgs(lib::synergy::ServerArgs &args, int argc, - const char *const *argv) { +bool ArgParser::parseServerArgs( + lib::synergy::ServerArgs &args, int argc, const char *const *argv) { setArgsBase(args); updateCommonArgs(argv); int i = 1; @@ -58,7 +58,8 @@ bool ArgParser::parseServerArgs(lib::synergy::ServerArgs &args, int argc, ++i; continue; } else { - LOG((CLOG_CRIT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], + LOG( + (CLOG_CRIT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname)); return false; } @@ -72,8 +73,8 @@ bool ArgParser::parseServerArgs(lib::synergy::ServerArgs &args, int argc, return true; } -bool ArgParser::parseClientArgs(lib::synergy::ClientArgs &args, int argc, - const char *const *argv) { +bool ArgParser::parseClientArgs( + lib::synergy::ClientArgs &args, int argc, const char *const *argv) { setArgsBase(args); updateCommonArgs(argv); @@ -111,7 +112,8 @@ bool ArgParser::parseClientArgs(lib::synergy::ClientArgs &args, int argc, return true; } - LOG((CLOG_CRIT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], + LOG( + (CLOG_CRIT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname)); return false; } @@ -120,7 +122,8 @@ bool ArgParser::parseClientArgs(lib::synergy::ClientArgs &args, int argc, // exactly one non-option argument (server-address) if (i == argc && !args.m_shouldExitFail && !args.m_shouldExitOk) { - LOG((CLOG_CRIT "%s: a server address or name is required" BYE, args.m_pname, + LOG( + (CLOG_CRIT "%s: a server address or name is required" BYE, args.m_pname, args.m_pname)); return false; } @@ -132,9 +135,9 @@ bool ArgParser::parseClientArgs(lib::synergy::ClientArgs &args, int argc, return true; } -bool ArgParser::parsePlatformArg(lib::synergy::ArgsBase &argsBase, - const int &argc, const char *const *argv, - int &i) { +bool ArgParser::parsePlatformArg( + lib::synergy::ArgsBase &argsBase, const int &argc, const char *const *argv, + int &i) { #if WINAPI_MSWINDOWS if (isArg(i, argc, argv, nullptr, "--service")) { LOG((CLOG_WARN "obsolete argument --service, use synergyd instead.")); @@ -171,8 +174,8 @@ bool ArgParser::parsePlatformArg(lib::synergy::ArgsBase &argsBase, #endif } -bool ArgParser::parseToolArgs(ToolArgs &args, int argc, - const char *const *argv) { +bool ArgParser::parseToolArgs( + ToolArgs &args, int argc, const char *const *argv) { // We support exactly one argument at a fix position static const int only_index{1}; if (isArg(only_index, argc, argv, nullptr, "--get-active-desktop", 0)) { @@ -289,14 +292,15 @@ bool ArgParser::parseDeprecatedArgs(int argc, const char *const *argv, int &i) { return false; } -bool ArgParser::isArg(int argi, int argc, const char *const *argv, - const char *name1, const char *name2, - int minRequiredParameters) { +bool ArgParser::isArg( + int argi, int argc, const char *const *argv, const char *name1, + const char *name2, int minRequiredParameters) { if ((name1 != nullptr && strcmp(argv[argi], name1) == 0) || (name2 != nullptr && strcmp(argv[argi], name2) == 0)) { // match. check args left. if (argi + minRequiredParameters >= argc) { - LOG((CLOG_PRINT "%s: missing arguments for `%s'" BYE, argsBase().m_pname, + LOG( + (CLOG_PRINT "%s: missing arguments for `%s'" BYE, argsBase().m_pname, argv[argi], argsBase().m_pname)); argsBase().m_shouldExitFail = true; return false; @@ -327,8 +331,8 @@ void ArgParser::splitCommandString(String &command, std::vector &argv) { if (space > leftDoubleQuote && space < rightDoubleQuote) { ignoreThisSpace = true; } else if (space > rightDoubleQuote) { - searchDoubleQuotes(command, leftDoubleQuote, rightDoubleQuote, - rightDoubleQuote + 1); + searchDoubleQuotes( + command, leftDoubleQuote, rightDoubleQuote, rightDoubleQuote + 1); } if (!ignoreThisSpace) { @@ -352,8 +356,8 @@ void ArgParser::splitCommandString(String &command, std::vector &argv) { argv.push_back(subString); } -bool ArgParser::searchDoubleQuotes(String &command, size_t &left, size_t &right, - size_t startPos) { +bool ArgParser::searchDoubleQuotes( + String &command, size_t &left, size_t &right, size_t startPos) { bool result = false; left = String::npos; right = String::npos; @@ -397,8 +401,8 @@ const char **ArgParser::getArgv(std::vector &argsArray) { return argv; } -String ArgParser::assembleCommand(std::vector &argsArray, - String ignoreArg, int parametersRequired) { +String ArgParser::assembleCommand( + std::vector &argsArray, String ignoreArg, int parametersRequired) { String result; for (std::vector::iterator it = argsArray.begin(); @@ -438,7 +442,8 @@ bool ArgParser::checkUnexpectedArgs() { // service, process should automatically detect that it should run in // daemon mode. if (argsBase().m_daemon) { - LOG((CLOG_ERR "the --daemon argument is not supported on windows. " + LOG( + (CLOG_ERR "the --daemon argument is not supported on windows. " "instead, install %s as a service (--service install)", argsBase().m_pname)); return true; diff --git a/src/lib/synergy/ArgParser.h b/src/lib/synergy/ArgParser.h index b4bfc817e..f73e49a58 100644 --- a/src/lib/synergy/ArgParser.h +++ b/src/lib/synergy/ArgParser.h @@ -36,28 +36,29 @@ class ArgParser { public: ArgParser(App *app); - bool parseServerArgs(lib::synergy::ServerArgs &args, int argc, - const char *const *argv); - bool parseClientArgs(lib::synergy::ClientArgs &args, int argc, - const char *const *argv); - bool parsePlatformArg(lib::synergy::ArgsBase &argsBase, const int &argc, - const char *const *argv, int &i); + bool parseServerArgs( + lib::synergy::ServerArgs &args, int argc, const char *const *argv); + bool parseClientArgs( + lib::synergy::ClientArgs &args, int argc, const char *const *argv); + bool parsePlatformArg( + lib::synergy::ArgsBase &argsBase, const int &argc, + const char *const *argv, int &i); bool parseToolArgs(ToolArgs &args, int argc, const char *const *argv); bool parseGenericArgs(int argc, const char *const *argv, int &i); bool parseDeprecatedArgs(int argc, const char *const *argv, int &i); void setArgsBase(lib::synergy::ArgsBase &argsBase) { m_argsBase = &argsBase; } - static bool isArg(int argi, int argc, const char *const *argv, - const char *name1, const char *name2, - int minRequiredParameters = 0); + static bool isArg( + int argi, int argc, const char *const *argv, const char *name1, + const char *name2, int minRequiredParameters = 0); static void splitCommandString(String &command, std::vector &argv); - static bool searchDoubleQuotes(String &command, size_t &left, size_t &right, - size_t startPos = 0); + static bool searchDoubleQuotes( + String &command, size_t &left, size_t &right, size_t startPos = 0); static void removeDoubleQuotes(String &arg); static const char **getArgv(std::vector &argsArray); - static String assembleCommand(std::vector &argsArray, - String ignoreArg = "", - int parametersRequired = 0); + static String assembleCommand( + std::vector &argsArray, String ignoreArg = "", + int parametersRequired = 0); static lib::synergy::ArgsBase &argsBase() { return *m_argsBase; } diff --git a/src/lib/synergy/ClientApp.cpp b/src/lib/synergy/ClientApp.cpp index c6a1d0bdb..ce9c7ab0e 100644 --- a/src/lib/synergy/ClientApp.cpp +++ b/src/lib/synergy/ClientApp.cpp @@ -64,10 +64,12 @@ #define RETRY_TIME 1.0 -ClientApp::ClientApp(IEventQueue *events, - CreateTaskBarReceiverFunc createTaskBarReceiver) +ClientApp::ClientApp( + IEventQueue *events, CreateTaskBarReceiverFunc createTaskBarReceiver) : App(events, createTaskBarReceiver, new lib::synergy::ClientArgs()), - m_client(NULL), m_clientScreen(NULL), m_serverAddress(NULL) {} + m_client(NULL), + m_clientScreen(NULL), + m_serverAddress(NULL) {} ClientApp::~ClientApp() {} @@ -93,7 +95,8 @@ void ClientApp::parseArgs(int argc, const char *const *argv) { // server. a bad port will never get better. patch by Brent // Priddy. if (!args().m_restartable || e.getError() == XSocketAddress::kBadPort) { - LOG((CLOG_CRIT "%s: %s" BYE, args().m_pname, e.what(), + LOG( + (CLOG_CRIT "%s: %s" BYE, args().m_pname, e.what(), args().m_pname)); m_bye(kExitFailed); } @@ -165,21 +168,22 @@ const char *ClientApp::daemonInfo() const { synergy::Screen *ClientApp::createScreen() { #if WINAPI_MSWINDOWS return new synergy::Screen( - new MSWindowsScreen(false, args().m_noHooks, args().m_stopOnDeskSwitch, - m_events, args().m_enableLangSync, - args().m_clientScrollDirection), + new MSWindowsScreen( + false, args().m_noHooks, args().m_stopOnDeskSwitch, m_events, + args().m_enableLangSync, args().m_clientScrollDirection), m_events); #elif WINAPI_XWINDOWS - return new synergy::Screen(new XWindowsScreen(args().m_display, false, - args().m_disableXInitThreads, - args().m_yscroll, m_events, - args().m_clientScrollDirection), - m_events); + return new synergy::Screen( + new XWindowsScreen( + args().m_display, false, args().m_disableXInitThreads, + args().m_yscroll, m_events, args().m_clientScrollDirection), + m_events); #elif WINAPI_CARBON - return new synergy::Screen(new OSXScreen(m_events, false, - args().m_enableLangSync, - args().m_clientScrollDirection), - m_events); + return new synergy::Screen( + new OSXScreen( + m_events, false, args().m_enableLangSync, + args().m_clientScrollDirection), + m_events); #endif } @@ -232,8 +236,8 @@ synergy::Screen *ClientApp::openClientScreen() { void ClientApp::closeClientScreen(synergy::Screen *screen) { if (screen != NULL) { - m_events->removeHandler(m_events->forIScreen().error(), - screen->getEventTarget()); + m_events->removeHandler( + m_events->forIScreen().error(), screen->getEventTarget()); delete screen; } } @@ -252,9 +256,10 @@ void ClientApp::scheduleClientRestart(double retryTime) { // install a timer and handler to retry later LOG((CLOG_DEBUG "retry in %.0f seconds", retryTime)); EventQueueTimer *timer = m_events->newOneShotTimer(retryTime, NULL); - m_events->adoptHandler(Event::kTimer, timer, - new TMethodEventJob( - this, &ClientApp::handleClientRestart, timer)); + m_events->adoptHandler( + Event::kTimer, timer, + new TMethodEventJob( + this, &ClientApp::handleClientRestart, timer)); } void ClientApp::handleClientConnected(const Event &, void *) { @@ -269,9 +274,11 @@ void ClientApp::handleClientFailed(const Event &e, void *) { std::unique_ptr info( static_cast(e.getData())); - updateStatus(String("Failed to connect to server: ") + info->m_what + - " Trying next address..."); - LOG((CLOG_NOTE "failed to connect to server=%s, trying next address", + updateStatus( + String("Failed to connect to server: ") + info->m_what + + " Trying next address..."); + LOG( + (CLOG_NOTE "failed to connect to server=%s, trying next address", info->m_what.c_str())); if (!m_suspended) { scheduleClientRestart(nextRestartTimeout()); @@ -308,16 +315,17 @@ void ClientApp::handleClientDisconnected(const Event &, void *) { updateStatus(); } -Client *ClientApp::openClient(const String &name, const NetworkAddress &address, - synergy::Screen *screen) { +Client *ClientApp::openClient( + const String &name, const NetworkAddress &address, + synergy::Screen *screen) { Client *client = new Client(m_events, name, address, getSocketFactory(), screen, args()); try { - m_events->adoptHandler(m_events->forClient().connected(), - client->getEventTarget(), - new TMethodEventJob( - this, &ClientApp::handleClientConnected)); + m_events->adoptHandler( + m_events->forClient().connected(), client->getEventTarget(), + new TMethodEventJob( + this, &ClientApp::handleClientConnected)); m_events->adoptHandler( m_events->forClient().connectionFailed(), client->getEventTarget(), @@ -327,10 +335,10 @@ Client *ClientApp::openClient(const String &name, const NetworkAddress &address, m_events->forClient().connectionRefused(), client->getEventTarget(), new TMethodEventJob(this, &ClientApp::handleClientRefused)); - m_events->adoptHandler(m_events->forClient().disconnected(), - client->getEventTarget(), - new TMethodEventJob( - this, &ClientApp::handleClientDisconnected)); + m_events->adoptHandler( + m_events->forClient().disconnected(), client->getEventTarget(), + new TMethodEventJob( + this, &ClientApp::handleClientDisconnected)); } catch (std::bad_alloc &ba) { delete client; @@ -470,8 +478,8 @@ int ClientApp::standardStartup(int argc, char **argv) { } } -int ClientApp::runInner(int argc, char **argv, ILogOutputter *outputter, - StartupFunc startup) { +int ClientApp::runInner( + int argc, char **argv, ILogOutputter *outputter, StartupFunc startup) { // general initialization m_serverAddress = new NetworkAddress; args().m_pname = ARCH->getBasename(argv[0]); diff --git a/src/lib/synergy/ClientApp.h b/src/lib/synergy/ClientApp.h index 6229b84e9..b987d77de 100644 --- a/src/lib/synergy/ClientApp.h +++ b/src/lib/synergy/ClientApp.h @@ -36,8 +36,8 @@ class ClientArgs; class ClientApp : public App { public: - ClientApp(IEventQueue *events, - CreateTaskBarReceiverFunc createTaskBarReceiver); + ClientApp( + IEventQueue *events, CreateTaskBarReceiverFunc createTaskBarReceiver); virtual ~ClientApp(); // Parse client specific command line arguments. @@ -60,8 +60,8 @@ public: int foregroundStartup(int argc, char **argv); int standardStartup(int argc, char **argv); - int runInner(int argc, char **argv, ILogOutputter *outputter, - StartupFunc startup); + int runInner( + int argc, char **argv, ILogOutputter *outputter, StartupFunc startup); synergy::Screen *createScreen(); void updateStatus(); void updateStatus(const String &msg); @@ -76,8 +76,9 @@ public: void handleClientFailed(const Event &e, void *); void handleClientRefused(const Event &e, void *); void handleClientDisconnected(const Event &, void *); - Client *openClient(const String &name, const NetworkAddress &address, - synergy::Screen *screen); + Client *openClient( + const String &name, const NetworkAddress &address, + synergy::Screen *screen); void closeClient(Client *client); bool startClient(); void stopClient(); diff --git a/src/lib/synergy/ClientTaskBarReceiver.cpp b/src/lib/synergy/ClientTaskBarReceiver.cpp index ecbaae628..dc77cf8fd 100644 --- a/src/lib/synergy/ClientTaskBarReceiver.cpp +++ b/src/lib/synergy/ClientTaskBarReceiver.cpp @@ -29,7 +29,8 @@ // ClientTaskBarReceiver::ClientTaskBarReceiver(IEventQueue *events) - : m_state(kNotRunning), m_events(events) { + : m_state(kNotRunning), + m_events(events) { // do nothing } @@ -37,8 +38,8 @@ ClientTaskBarReceiver::~ClientTaskBarReceiver() { // do nothing } -void ClientTaskBarReceiver::updateStatus(Client *client, - const String &errorMsg) { +void ClientTaskBarReceiver::updateStatus( + Client *client, const String &errorMsg) { { // update our status m_errorMessage = errorMsg; @@ -96,20 +97,20 @@ std::string ClientTaskBarReceiver::getToolTip() const { return synergy::string::sprintf("%s: Not running", kAppVersion); case kNotWorking: - return synergy::string::sprintf("%s: %s", kAppVersion, - m_errorMessage.c_str()); + return synergy::string::sprintf( + "%s: %s", kAppVersion, m_errorMessage.c_str()); case kNotConnected: - return synergy::string::sprintf("%s: Not connected: %s", kAppVersion, - m_errorMessage.c_str()); + return synergy::string::sprintf( + "%s: Not connected: %s", kAppVersion, m_errorMessage.c_str()); case kConnecting: - return synergy::string::sprintf("%s: Connecting to %s...", kAppVersion, - m_server.c_str()); + return synergy::string::sprintf( + "%s: Connecting to %s...", kAppVersion, m_server.c_str()); case kConnected: - return synergy::string::sprintf("%s: Connected to %s", kAppVersion, - m_server.c_str()); + return synergy::string::sprintf( + "%s: Connected to %s", kAppVersion, m_server.c_str()); default: return ""; diff --git a/src/lib/synergy/ClientTaskBarReceiver.h b/src/lib/synergy/ClientTaskBarReceiver.h index 5e1d8b62d..b2277990a 100644 --- a/src/lib/synergy/ClientTaskBarReceiver.h +++ b/src/lib/synergy/ClientTaskBarReceiver.h @@ -92,8 +92,7 @@ private: IEventQueue *m_events; }; -IArchTaskBarReceiver * -createTaskBarReceiver(const BufferedLogOutputter *logBuffer, - IEventQueue *events); +IArchTaskBarReceiver *createTaskBarReceiver( + const BufferedLogOutputter *logBuffer, IEventQueue *events); #endif diff --git a/src/lib/synergy/ClipboardChunk.cpp b/src/lib/synergy/ClipboardChunk.cpp index c812f04f2..008c5c518 100644 --- a/src/lib/synergy/ClipboardChunk.cpp +++ b/src/lib/synergy/ClipboardChunk.cpp @@ -29,8 +29,8 @@ ClipboardChunk::ClipboardChunk(size_t size) : Chunk(size) { m_dataSize = size - CLIPBOARD_CHUNK_META_SIZE; } -ClipboardChunk *ClipboardChunk::start(ClipboardID id, UInt32 sequence, - const String &size) { +ClipboardChunk * +ClipboardChunk::start(ClipboardID id, UInt32 sequence, const String &size) { size_t sizeLength = size.size(); ClipboardChunk *start = new ClipboardChunk(sizeLength + CLIPBOARD_CHUNK_META_SIZE); @@ -45,8 +45,8 @@ ClipboardChunk *ClipboardChunk::start(ClipboardID id, UInt32 sequence, return start; } -ClipboardChunk *ClipboardChunk::data(ClipboardID id, UInt32 sequence, - const String &data) { +ClipboardChunk * +ClipboardChunk::data(ClipboardID id, UInt32 sequence, const String &data) { size_t dataSize = data.size(); ClipboardChunk *chunk = new ClipboardChunk(dataSize + CLIPBOARD_CHUNK_META_SIZE); @@ -73,13 +73,14 @@ ClipboardChunk *ClipboardChunk::end(ClipboardID id, UInt32 sequence) { return end; } -int ClipboardChunk::assemble(synergy::IStream *stream, String &dataCached, - ClipboardID &id, UInt32 &sequence) { +int ClipboardChunk::assemble( + synergy::IStream *stream, String &dataCached, ClipboardID &id, + UInt32 &sequence) { UInt8 mark; String data; - if (!ProtocolUtil::readf(stream, kMsgDClipboard + 4, &id, &sequence, &mark, - &data)) { + if (!ProtocolUtil::readf( + stream, kMsgDClipboard + 4, &id, &sequence, &mark, &data)) { return kError; } @@ -96,7 +97,8 @@ int ClipboardChunk::assemble(synergy::IStream *stream, String &dataCached, if (id >= kClipboardEnd) { return kError; } else if (s_expectedSize != dataCached.size()) { - LOG((CLOG_ERR "corrupted clipboard data, expected size=%d actual size=%d", + LOG( + (CLOG_ERR "corrupted clipboard data, expected size=%d actual size=%d", s_expectedSize, dataCached.size())); return kError; } @@ -121,13 +123,14 @@ void ClipboardChunk::send(synergy::IStream *stream, void *data) { switch (mark) { case kDataStart: - LOG((CLOG_DEBUG2 "sending clipboard chunk start: size=%s", + LOG( + (CLOG_DEBUG2 "sending clipboard chunk start: size=%s", dataChunk.c_str())); break; case kDataChunk: - LOG((CLOG_DEBUG2 "sending clipboard chunk data: size=%i", - dataChunk.size())); + LOG(( + CLOG_DEBUG2 "sending clipboard chunk data: size=%i", dataChunk.size())); break; case kDataEnd: diff --git a/src/lib/synergy/ClipboardChunk.h b/src/lib/synergy/ClipboardChunk.h index b7e99b6e2..38f3ae265 100644 --- a/src/lib/synergy/ClipboardChunk.h +++ b/src/lib/synergy/ClipboardChunk.h @@ -32,14 +32,15 @@ class ClipboardChunk : public Chunk { public: ClipboardChunk(size_t size); - static ClipboardChunk *start(ClipboardID id, UInt32 sequence, - const String &size); - static ClipboardChunk *data(ClipboardID id, UInt32 sequence, - const String &data); + static ClipboardChunk * + start(ClipboardID id, UInt32 sequence, const String &size); + static ClipboardChunk * + data(ClipboardID id, UInt32 sequence, const String &data); static ClipboardChunk *end(ClipboardID id, UInt32 sequence); - static int assemble(synergy::IStream *stream, String &dataCached, - ClipboardID &id, UInt32 &sequence); + static int assemble( + synergy::IStream *stream, String &dataCached, ClipboardID &id, + UInt32 &sequence); static void send(synergy::IStream *stream, void *data); diff --git a/src/lib/synergy/DaemonApp.cpp b/src/lib/synergy/DaemonApp.cpp index 29f8aa760..8fe7f8d85 100644 --- a/src/lib/synergy/DaemonApp.cpp +++ b/src/lib/synergy/DaemonApp.cpp @@ -100,11 +100,13 @@ int winMainLoopStatic(int, const char **) { #endif DaemonApp::DaemonApp() - : m_ipcServer(nullptr), m_ipcLogOutputter(nullptr), + : m_ipcServer(nullptr), + m_ipcLogOutputter(nullptr), #if SYSAPI_WIN32 m_watchdog(nullptr), #endif - m_events(nullptr), m_fileLogOutputter(nullptr) { + m_events(nullptr), + m_fileLogOutputter(nullptr) { s_instance = this; } @@ -224,8 +226,8 @@ void DaemonApp::mainLoop(bool logToFile, bool foreground) { CLOG->insert(m_ipcLogOutputter); #if SYSAPI_WIN32 - m_watchdog = new MSWindowsWatchdog(false, *m_ipcServer, *m_ipcLogOutputter, - foreground); + m_watchdog = new MSWindowsWatchdog( + false, *m_ipcServer, *m_ipcLogOutputter, foreground); m_watchdog->setFileLogOutputter(m_fileLogOutputter); #endif @@ -256,8 +258,8 @@ void DaemonApp::mainLoop(bool logToFile, bool foreground) { delete m_watchdog; #endif - m_events->removeHandler(m_events->forIpcServer().messageReceived(), - m_ipcServer); + m_events->removeHandler( + m_events->forIpcServer().messageReceived(), m_ipcServer); CLOG->remove(m_ipcLogOutputter); delete m_ipcLogOutputter; @@ -305,7 +307,8 @@ void DaemonApp::handleIpcMessage(const Event &e, void *) { if (!command.empty()) { LOG((CLOG_DEBUG "daemon got new core command")); - LOG((CLOG_DEBUG2 "new command, elevate=%d command=%s", cm->elevate(), + LOG( + (CLOG_DEBUG2 "new command, elevate=%d command=%s", cm->elevate(), command.c_str())); std::vector argsArray; diff --git a/src/lib/synergy/DragInformation.cpp b/src/lib/synergy/DragInformation.cpp index 0782252ca..ed72bd146 100644 --- a/src/lib/synergy/DragInformation.cpp +++ b/src/lib/synergy/DragInformation.cpp @@ -26,8 +26,8 @@ using namespace std; DragInformation::DragInformation() : m_filename(), m_filesize(0) {} -void DragInformation::parseDragInfo(DragFileList &dragFileList, UInt32 fileNum, - String data) { +void DragInformation::parseDragInfo( + DragFileList &dragFileList, UInt32 fileNum, String data) { size_t startPos = 0; size_t findResult1 = 0; size_t findResult2 = 0; @@ -70,11 +70,13 @@ void DragInformation::parseDragInfo(DragFileList &dragFileList, UInt32 fileNum, ++index; } - LOG((CLOG_DEBUG "drag info received, total drag file number: %i", + LOG( + (CLOG_DEBUG "drag info received, total drag file number: %i", dragFileList.size())); for (size_t i = 0; i < dragFileList.size(); ++i) { - LOG((CLOG_DEBUG "dragging file %i name: %s", i + 1, + LOG( + (CLOG_DEBUG "dragging file %i name: %s", i + 1, dragFileList.at(i).getFilename().c_str())); } } diff --git a/src/lib/synergy/DragInformation.h b/src/lib/synergy/DragInformation.h index 35034de77..d25f98c70 100644 --- a/src/lib/synergy/DragInformation.h +++ b/src/lib/synergy/DragInformation.h @@ -34,8 +34,8 @@ public: size_t getFilesize() { return m_filesize; } void setFilesize(size_t size) { m_filesize = size; } - static void parseDragInfo(DragFileList &dragFileList, UInt32 fileNum, - String data); + static void + parseDragInfo(DragFileList &dragFileList, UInt32 fileNum, String data); static String getDragFileExtension(String filename); // helper function to setup drag info // example: filename1,filesize1,filename2,filesize2, diff --git a/src/lib/synergy/DropHelper.cpp b/src/lib/synergy/DropHelper.cpp index 24216485b..272851c90 100644 --- a/src/lib/synergy/DropHelper.cpp +++ b/src/lib/synergy/DropHelper.cpp @@ -21,9 +21,10 @@ #include -void DropHelper::writeToDir(const String &destination, DragFileList &fileList, - String &data) { - LOG((CLOG_DEBUG "dropping file, files=%i target=%s", fileList.size(), +void DropHelper::writeToDir( + const String &destination, DragFileList &fileList, String &data) { + LOG( + (CLOG_DEBUG "dropping file, files=%i target=%s", fileList.size(), destination.c_str())); if (!destination.empty() && fileList.size() > 0) { @@ -43,7 +44,8 @@ void DropHelper::writeToDir(const String &destination, DragFileList &fileList, file.write(data.c_str(), data.size()); file.close(); - LOG((CLOG_DEBUG "%s is saved to %s", fileList.at(0).getFilename().c_str(), + LOG( + (CLOG_DEBUG "%s is saved to %s", fileList.at(0).getFilename().c_str(), destination.c_str())); fileList.clear(); diff --git a/src/lib/synergy/DropHelper.h b/src/lib/synergy/DropHelper.h index dff840c94..d232f3f07 100644 --- a/src/lib/synergy/DropHelper.h +++ b/src/lib/synergy/DropHelper.h @@ -22,6 +22,6 @@ class DropHelper { public: - static void writeToDir(const String &destination, DragFileList &fileList, - String &data); + static void + writeToDir(const String &destination, DragFileList &fileList, String &data); }; diff --git a/src/lib/synergy/FileChunk.cpp b/src/lib/synergy/FileChunk.cpp index beec6a390..f291bd64d 100644 --- a/src/lib/synergy/FileChunk.cpp +++ b/src/lib/synergy/FileChunk.cpp @@ -59,8 +59,8 @@ FileChunk *FileChunk::end() { return end; } -int FileChunk::assemble(synergy::IStream *stream, String &dataReceived, - size_t &expectedSize) { +int FileChunk::assemble( + synergy::IStream *stream, String &dataReceived, size_t &expectedSize) { // parse UInt8 mark = 0; String content; @@ -106,7 +106,8 @@ int FileChunk::assemble(synergy::IStream *stream, String &dataReceived, case kDataEnd: if (expectedSize != dataReceived.size()) { - LOG((CLOG_ERR "corrupted clipboard data, expected size=%d actual size=%d", + LOG( + (CLOG_ERR "corrupted clipboard data, expected size=%d actual size=%d", expectedSize, dataReceived.size())); return kError; } @@ -115,11 +116,14 @@ int FileChunk::assemble(synergy::IStream *stream, String &dataReceived, LOG((CLOG_DEBUG2 "file transfer finished")); elapsedTime += stopwatch.getTime(); double averageSpeed = expectedSize / elapsedTime / 1000; - LOG((CLOG_DEBUG2 "file transfer finished: total time consumed=%f s", + LOG( + (CLOG_DEBUG2 "file transfer finished: total time consumed=%f s", elapsedTime)); - LOG((CLOG_DEBUG2 "file transfer finished: total data received=%i kb", + LOG( + (CLOG_DEBUG2 "file transfer finished: total data received=%i kb", expectedSize / 1000)); - LOG((CLOG_DEBUG2 "file transfer finished: total average speed=%f kb/s", + LOG( + (CLOG_DEBUG2 "file transfer finished: total average speed=%f kb/s", averageSpeed)); } return kFinish; @@ -128,8 +132,8 @@ int FileChunk::assemble(synergy::IStream *stream, String &dataReceived, return kError; } -void FileChunk::send(synergy::IStream *stream, UInt8 mark, char *data, - size_t dataSize) { +void FileChunk::send( + synergy::IStream *stream, UInt8 mark, char *data, size_t dataSize) { String chunk(data, dataSize); switch (mark) { diff --git a/src/lib/synergy/FileChunk.h b/src/lib/synergy/FileChunk.h index 574b79b84..95ad18d30 100644 --- a/src/lib/synergy/FileChunk.h +++ b/src/lib/synergy/FileChunk.h @@ -34,8 +34,8 @@ public: static FileChunk *start(const String &size); static FileChunk *data(UInt8 *data, size_t dataSize); static FileChunk *end(); - static int assemble(synergy::IStream *stream, String &dataCached, - size_t &expectedSize); - static void send(synergy::IStream *stream, UInt8 mark, char *data, - size_t dataSize); + static int + assemble(synergy::IStream *stream, String &dataCached, size_t &expectedSize); + static void + send(synergy::IStream *stream, UInt8 mark, char *data, size_t dataSize); }; diff --git a/src/lib/synergy/IApp.h b/src/lib/synergy/IApp.h index 441edea9c..520b2e9db 100644 --- a/src/lib/synergy/IApp.h +++ b/src/lib/synergy/IApp.h @@ -40,8 +40,8 @@ public: virtual void setByeFunc(void (*bye)(int)) = 0; virtual lib::synergy::ArgsBase &argsBase() const = 0; virtual int standardStartup(int argc, char **argv) = 0; - virtual int runInner(int argc, char **argv, ILogOutputter *outputter, - StartupFunc startup) = 0; + virtual int runInner( + int argc, char **argv, ILogOutputter *outputter, StartupFunc startup) = 0; virtual void startNode() = 0; virtual IArchTaskBarReceiver *taskBarReceiver() const = 0; virtual void bye(int error) = 0; diff --git a/src/lib/synergy/IAppUtil.h b/src/lib/synergy/IAppUtil.h index d2be8014b..a4cbd4ed5 100644 --- a/src/lib/synergy/IAppUtil.h +++ b/src/lib/synergy/IAppUtil.h @@ -31,6 +31,6 @@ public: virtual void startNode() = 0; virtual std::vector getKeyboardLayoutList() = 0; virtual String getCurrentLanguageCode() = 0; - virtual void showNotification(const String &title, - const String &text) const = 0; + virtual void + showNotification(const String &title, const String &text) const = 0; }; diff --git a/src/lib/synergy/IClient.h b/src/lib/synergy/IClient.h index a4a31afd9..727ff195b 100644 --- a/src/lib/synergy/IClient.h +++ b/src/lib/synergy/IClient.h @@ -43,8 +43,9 @@ public: screen is being entered because the screen saver is starting. Subsequent clipboard events should report \p seqNum. */ - virtual void enter(SInt32 xAbs, SInt32 yAbs, UInt32 seqNum, - KeyModifierMask mask, bool forScreensaver) = 0; + virtual void enter( + SInt32 xAbs, SInt32 yAbs, UInt32 seqNum, KeyModifierMask mask, + bool forScreensaver) = 0; //! Leave screen /*! @@ -86,16 +87,17 @@ public: synthesize an up or repeat for the same client key synthesized by keyDown(). */ - virtual void keyDown(KeyID id, KeyModifierMask, KeyButton, - const String &) = 0; + virtual void + keyDown(KeyID id, KeyModifierMask, KeyButton, const String &) = 0; //! Notify of key repeat /*! Synthesize key events to generate a press and release of key \c id \c count times. If possible match the given modifier mask. */ - virtual void keyRepeat(KeyID id, KeyModifierMask, SInt32 count, KeyButton, - const String &lang) = 0; + virtual void keyRepeat( + KeyID id, KeyModifierMask, SInt32 count, KeyButton, + const String &lang) = 0; //! Notify of key release /*! @@ -170,7 +172,7 @@ public: // IScreen overrides 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 + getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const = 0; virtual void getCursorPos(SInt32 &x, SInt32 &y) const = 0; }; diff --git a/src/lib/synergy/IClipboard.cpp b/src/lib/synergy/IClipboard.cpp index 264f5f7d3..62774ba94 100644 --- a/src/lib/synergy/IClipboard.cpp +++ b/src/lib/synergy/IClipboard.cpp @@ -23,8 +23,8 @@ // IClipboard // -void IClipboard::unmarshall(IClipboard *clipboard, const String &data, - Time time) { +void IClipboard::unmarshall( + IClipboard *clipboard, const String &data, Time time) { assert(clipboard != NULL); const char *index = data.data(); diff --git a/src/lib/synergy/IKeyState.cpp b/src/lib/synergy/IKeyState.cpp index c4faeb808..415b9adcd 100644 --- a/src/lib/synergy/IKeyState.cpp +++ b/src/lib/synergy/IKeyState.cpp @@ -32,8 +32,8 @@ IKeyState::IKeyState(IEventQueue *events) {} // IKeyState::KeyInfo // -IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(KeyID id, KeyModifierMask mask, - KeyButton button, SInt32 count) { +IKeyState::KeyInfo *IKeyState::KeyInfo::alloc( + KeyID id, KeyModifierMask mask, KeyButton button, SInt32 count) { KeyInfo *info = (KeyInfo *)malloc(sizeof(KeyInfo)); info->m_key = id; info->m_mask = mask; @@ -44,9 +44,9 @@ IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(KeyID id, KeyModifierMask mask, return info; } -IKeyState::KeyInfo * -IKeyState::KeyInfo::alloc(KeyID id, KeyModifierMask mask, KeyButton button, - SInt32 count, const std::set &destinations) { +IKeyState::KeyInfo *IKeyState::KeyInfo::alloc( + KeyID id, KeyModifierMask mask, KeyButton button, SInt32 count, + const std::set &destinations) { String screens = join(destinations); const char *buffer = screens.c_str(); @@ -96,9 +96,10 @@ bool IKeyState::KeyInfo::contains(const char *screens, const String &name) { } bool IKeyState::KeyInfo::equal(const KeyInfo *a, const KeyInfo *b) { - return (a->m_key == b->m_key && a->m_mask == b->m_mask && - a->m_button == b->m_button && a->m_count == b->m_count && - strcmp(a->m_screensBuffer, b->m_screensBuffer) == 0); + return ( + a->m_key == b->m_key && a->m_mask == b->m_mask && + a->m_button == b->m_button && a->m_count == b->m_count && + strcmp(a->m_screensBuffer, b->m_screensBuffer) == 0); } String IKeyState::KeyInfo::join(const std::set &destinations) { diff --git a/src/lib/synergy/IKeyState.h b/src/lib/synergy/IKeyState.h index d56150ceb..f1988cad6 100644 --- a/src/lib/synergy/IKeyState.h +++ b/src/lib/synergy/IKeyState.h @@ -41,8 +41,9 @@ public: class KeyInfo { public: static KeyInfo *alloc(KeyID, KeyModifierMask, KeyButton, SInt32 count); - static KeyInfo *alloc(KeyID, KeyModifierMask, KeyButton, SInt32 count, - const std::set &destinations); + static KeyInfo *alloc( + KeyID, KeyModifierMask, KeyButton, SInt32 count, + const std::set &destinations); static KeyInfo *alloc(const KeyInfo &); static bool isDefault(const char *screens); @@ -91,15 +92,16 @@ public: /*! Synthesizes a key press event and updates the key state. */ - virtual void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, - const String &lang) = 0; + virtual void fakeKeyDown( + KeyID id, KeyModifierMask mask, KeyButton button, const String &lang) = 0; //! Fake a key repeat /*! Synthesizes a key repeat event and updates the key state. */ - virtual bool fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, - KeyButton button, const String &lang) = 0; + virtual bool fakeKeyRepeat( + KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, + const String &lang) = 0; //! Fake a key release /*! diff --git a/src/lib/synergy/IPlatformScreen.h b/src/lib/synergy/IPlatformScreen.h index 47a7c2fd9..a74016967 100644 --- a/src/lib/synergy/IPlatformScreen.h +++ b/src/lib/synergy/IPlatformScreen.h @@ -156,8 +156,8 @@ public: // IScreen overrides 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 + getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const = 0; virtual void getCursorPos(SInt32 &x, SInt32 &y) const = 0; // IPrimaryScreen overrides @@ -181,10 +181,11 @@ public: virtual void updateKeyMap() = 0; virtual void updateKeyState() = 0; virtual void setHalfDuplexMask(KeyModifierMask) = 0; - virtual void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, - const String &lang) = 0; - virtual bool fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, - KeyButton button, const String &lang) = 0; + virtual void fakeKeyDown( + KeyID id, KeyModifierMask mask, KeyButton button, const String &lang) = 0; + virtual bool fakeKeyRepeat( + KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, + const String &lang) = 0; virtual bool fakeKeyUp(KeyButton button) = 0; virtual void fakeAllKeysUp() = 0; virtual bool fakeCtrlAltDel() = 0; diff --git a/src/lib/synergy/IPrimaryScreen.cpp b/src/lib/synergy/IPrimaryScreen.cpp index 2aec3dadc..82b756477 100644 --- a/src/lib/synergy/IPrimaryScreen.cpp +++ b/src/lib/synergy/IPrimaryScreen.cpp @@ -41,8 +41,8 @@ IPrimaryScreen::ButtonInfo::alloc(const ButtonInfo &x) { return info; } -bool IPrimaryScreen::ButtonInfo::equal(const ButtonInfo *a, - const ButtonInfo *b) { +bool IPrimaryScreen::ButtonInfo::equal( + const ButtonInfo *a, const ButtonInfo *b) { return (a->m_button == b->m_button && a->m_mask == b->m_mask); } @@ -50,8 +50,8 @@ bool IPrimaryScreen::ButtonInfo::equal(const ButtonInfo *a, // IPrimaryScreen::MotionInfo // -IPrimaryScreen::MotionInfo *IPrimaryScreen::MotionInfo::alloc(SInt32 x, - SInt32 y) { +IPrimaryScreen::MotionInfo * +IPrimaryScreen::MotionInfo::alloc(SInt32 x, SInt32 y) { MotionInfo *info = (MotionInfo *)malloc(sizeof(MotionInfo)); info->m_x = x; info->m_y = y; @@ -62,8 +62,8 @@ IPrimaryScreen::MotionInfo *IPrimaryScreen::MotionInfo::alloc(SInt32 x, // IPrimaryScreen::WheelInfo // -IPrimaryScreen::WheelInfo *IPrimaryScreen::WheelInfo::alloc(SInt32 xDelta, - SInt32 yDelta) { +IPrimaryScreen::WheelInfo * +IPrimaryScreen::WheelInfo::alloc(SInt32 xDelta, SInt32 yDelta) { WheelInfo *info = (WheelInfo *)malloc(sizeof(WheelInfo)); info->m_xDelta = xDelta; info->m_yDelta = yDelta; diff --git a/src/lib/synergy/IScreen.h b/src/lib/synergy/IScreen.h index 9943c8983..a4b10aa2b 100644 --- a/src/lib/synergy/IScreen.h +++ b/src/lib/synergy/IScreen.h @@ -58,8 +58,8 @@ public: Return the position of the upper-left corner of the screen in \c x and \c y and the size of the screen in \c width and \c height. */ - virtual void getShape(SInt32 &x, SInt32 &y, SInt32 &width, - SInt32 &height) const = 0; + virtual void + getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const = 0; //! Get cursor position /*! diff --git a/src/lib/synergy/KeyMap.cpp b/src/lib/synergy/KeyMap.cpp index fc5518673..8113b82ec 100644 --- a/src/lib/synergy/KeyMap.cpp +++ b/src/lib/synergy/KeyMap.cpp @@ -99,17 +99,16 @@ void KeyMap::addKeyEntry(const KeyItem &item) { // add item list entries.push_back(items); - LOG((CLOG_DEBUG5 "add key: %04x %d %03x %04x (%04x %04x %04x)%s", - newItem.m_id, newItem.m_group, newItem.m_button, newItem.m_client, - newItem.m_required, newItem.m_sensitive, newItem.m_generates, - newItem.m_dead ? " dead" : "")); + LOG(( + CLOG_DEBUG5 "add key: %04x %d %03x %04x (%04x %04x %04x)%s", newItem.m_id, + newItem.m_group, newItem.m_button, newItem.m_client, newItem.m_required, + newItem.m_sensitive, newItem.m_generates, newItem.m_dead ? " dead" : "")); } -void KeyMap::addKeyAliasEntry(KeyID targetID, SInt32 group, - KeyModifierMask targetRequired, - KeyModifierMask targetSensitive, KeyID sourceID, - KeyModifierMask sourceRequired, - KeyModifierMask sourceSensitive) { +void KeyMap::addKeyAliasEntry( + KeyID targetID, SInt32 group, KeyModifierMask targetRequired, + KeyModifierMask targetSensitive, KeyID sourceID, + KeyModifierMask sourceRequired, KeyModifierMask sourceSensitive) { // if we can already generate the target as desired then we're done. if (findCompatibleKey(targetID, group, targetRequired, targetSensitive) != NULL) { @@ -131,8 +130,8 @@ void KeyMap::addKeyAliasEntry(KeyID targetID, SInt32 group, } } -bool KeyMap::addKeyCombinationEntry(KeyID id, SInt32 group, const KeyID *keys, - UInt32 numKeys) { +bool KeyMap::addKeyCombinationEntry( + KeyID id, SInt32 group, const KeyID *keys, UInt32 numKeys) { // disallow kKeyNone if (id == kKeyNone) { return false; @@ -227,13 +226,12 @@ void KeyMap::foreachKey(ForeachKeyCallback cb, void *userData) { } } -const KeyMap::KeyItem *KeyMap::mapKey(Keystrokes &keys, KeyID id, SInt32 group, - ModifierToKeys &activeModifiers, - KeyModifierMask ¤tState, - KeyModifierMask desiredMask, - bool isAutoRepeat, - const String &lang) const { - LOG((CLOG_DEBUG1 +const KeyMap::KeyItem *KeyMap::mapKey( + Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, + KeyModifierMask ¤tState, KeyModifierMask desiredMask, + bool isAutoRepeat, const String &lang) const { + LOG( + (CLOG_DEBUG1 "mapKey %04x (%d) with mask %04x, start state: %04x, group: %d", id, id, desiredMask, currentState, group)); @@ -262,22 +260,24 @@ const KeyMap::KeyItem *KeyMap::mapKey(Keystrokes &keys, KeyID id, SInt32 group, case kKeyCapsLock: case kKeyNumLock: case kKeyScrollLock: - item = mapModifierKey(keys, id, group, activeModifiers, currentState, - desiredMask, isAutoRepeat, lang); + item = mapModifierKey( + keys, id, group, activeModifiers, currentState, desiredMask, + isAutoRepeat, lang); break; case kKeySetModifiers: - if (!keysForModifierState(0, group, activeModifiers, currentState, - desiredMask, desiredMask, 0, keys)) { + if (!keysForModifierState( + 0, group, activeModifiers, currentState, desiredMask, desiredMask, + 0, keys)) { LOG((CLOG_DEBUG1 "unable to set modifiers %04x", desiredMask)); return NULL; } return &m_modifierKeyItem; case kKeyClearModifiers: - if (!keysForModifierState(0, group, activeModifiers, currentState, - currentState & ~desiredMask, desiredMask, 0, - keys)) { + if (!keysForModifierState( + 0, group, activeModifiers, currentState, + currentState & ~desiredMask, desiredMask, 0, keys)) { LOG((CLOG_DEBUG1 "unable to clear modifiers %04x", desiredMask)); return NULL; } @@ -285,17 +285,20 @@ const KeyMap::KeyItem *KeyMap::mapKey(Keystrokes &keys, KeyID id, SInt32 group, default: if (isCommand(desiredMask)) { - item = mapCommandKey(keys, id, group, activeModifiers, currentState, - desiredMask, isAutoRepeat, lang); + item = mapCommandKey( + keys, id, group, activeModifiers, currentState, desiredMask, + isAutoRepeat, lang); } else { - item = mapCharacterKey(keys, id, group, activeModifiers, currentState, - desiredMask, isAutoRepeat, lang); + item = mapCharacterKey( + keys, id, group, activeModifiers, currentState, desiredMask, + isAutoRepeat, lang); } break; } if (item != NULL) { - LOG((CLOG_DEBUG1 "mapped to %03x, new state %04x", item->m_button, + LOG( + (CLOG_DEBUG1 "mapped to %03x, new state %04x", item->m_button, currentState)); } return item; @@ -325,9 +328,9 @@ SInt32 KeyMap::getEffectiveGroup(SInt32 group, SInt32 offset) const { return (group + offset + getNumGroups()) % getNumGroups(); } -const KeyMap::KeyItemList * -KeyMap::findCompatibleKey(KeyID id, SInt32 group, KeyModifierMask required, - KeyModifierMask sensitive) const { +const KeyMap::KeyItemList *KeyMap::findCompatibleKey( + KeyID id, SInt32 group, KeyModifierMask required, + KeyModifierMask sensitive) const { assert(group >= 0 && group < getNumGroups()); KeyIDMap::const_iterator i = m_keyIDMap.find(id); @@ -532,16 +535,17 @@ const KeyMap::KeyItem *KeyMap::mapCommandKey( (currentState & KeyModifierCapsLock); // add the key - if (!keysForKeyItem(*keyItem, newGroup, newModifiers, newState, desiredMask, - s_overrideModifiers, isAutoRepeat, keys, lang)) { + if (!keysForKeyItem( + *keyItem, newGroup, newModifiers, newState, desiredMask, + s_overrideModifiers, isAutoRepeat, keys, lang)) { LOG((CLOG_DEBUG1 "can't map key")); keys.clear(); return NULL; } // add keystrokes to restore modifier keys - if (!keysToRestoreModifiers(*keyItem, group, newModifiers, newState, - activeModifiers, keys)) { + if (!keysToRestoreModifiers( + *keyItem, group, newModifiers, newState, activeModifiers, keys)) { LOG((CLOG_DEBUG1 "failed to restore modifiers")); keys.clear(); return NULL; @@ -554,9 +558,9 @@ const KeyMap::KeyItem *KeyMap::mapCommandKey( return keyItem; } -const KeyMap::KeyItemList * -KeyMap::getKeyItemList(const KeyMap::KeyGroupTable &keyGroupTable, SInt32 group, - KeyModifierMask desiredMask) const { +const KeyMap::KeyItemList *KeyMap::getKeyItemList( + const KeyMap::KeyGroupTable &keyGroupTable, SInt32 group, + KeyModifierMask desiredMask) const { const KeyItemList *itemList = nullptr; // find best key in any group, starting with the active group @@ -604,8 +608,9 @@ const KeyMap::KeyItem *KeyMap::mapCharacterKey( // add each key for (size_t j = 0; j < itemList->size(); ++j) { - if (!keysForKeyItem(itemList->at(j), newGroup, newModifiers, newState, - desiredMask, 0, isAutoRepeat, keys, lang)) { + if (!keysForKeyItem( + itemList->at(j), newGroup, newModifiers, newState, desiredMask, 0, + isAutoRepeat, keys, lang)) { LOG((CLOG_DEBUG1 "can't map key")); keys.clear(); return NULL; @@ -613,8 +618,8 @@ const KeyMap::KeyItem *KeyMap::mapCharacterKey( } // add keystrokes to restore modifier keys - if (!keysToRestoreModifiers(keyItem, group, newModifiers, newState, - activeModifiers, keys)) { + if (!keysToRestoreModifiers( + keyItem, group, newModifiers, newState, activeModifiers, keys)) { LOG((CLOG_DEBUG1 "failed to restore modifiers")); keys.clear(); return NULL; @@ -627,8 +632,8 @@ const KeyMap::KeyItem *KeyMap::mapCharacterKey( return &keyItem; } -void KeyMap::addGroupToKeystroke(Keystrokes &keys, SInt32 &group, - const String &lang) const { +void KeyMap::addGroupToKeystroke( + Keystrokes &keys, SInt32 &group, const String &lang) const { group = getLanguageGroupID(group, lang); keys.push_back(Keystroke(group, true, false)); } @@ -637,18 +642,20 @@ const KeyMap::KeyItem *KeyMap::mapModifierKey( Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState, KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang) const { - return mapCharacterKey(keys, id, group, activeModifiers, currentState, - desiredMask, isAutoRepeat, lang); + return mapCharacterKey( + keys, id, group, activeModifiers, currentState, desiredMask, isAutoRepeat, + lang); } -SInt32 KeyMap::findBestKey(const KeyEntryList &entryList, - KeyModifierMask desiredState) const { +SInt32 KeyMap::findBestKey( + const KeyEntryList &entryList, KeyModifierMask desiredState) const { // check for an item that can accommodate the desiredState exactly for (SInt32 i = 0; i < (SInt32)entryList.size(); ++i) { const KeyItem &item = entryList[i].back(); if ((item.m_required & desiredState) == item.m_required && (item.m_required & desiredState) == (item.m_sensitive & desiredState)) { - LOG((CLOG_DEBUG1 "best key index %d of %d (exact)", i + 1, + LOG( + (CLOG_DEBUG1 "best key index %d of %d (exact)", i + 1, entryList.size())); return i; } @@ -668,15 +675,16 @@ SInt32 KeyMap::findBestKey(const KeyEntryList &entryList, } } if (bestIndex != -1) { - LOG((CLOG_DEBUG1 "best key index %d of %d (%d modifiers)", bestIndex + 1, + LOG( + (CLOG_DEBUG1 "best key index %d of %d (%d modifiers)", bestIndex + 1, entryList.size(), bestCount)); } return bestIndex; } -const KeyMap::KeyItem *KeyMap::keyForModifier(KeyButton button, SInt32 group, - SInt32 modifierBit) const { +const KeyMap::KeyItem *KeyMap::keyForModifier( + KeyButton button, SInt32 group, SInt32 modifierBit) const { assert(modifierBit >= 0 && modifierBit < kKeyModifierNumBits); assert(group >= 0 && group < getNumGroups()); @@ -696,13 +704,11 @@ const KeyMap::KeyItem *KeyMap::keyForModifier(KeyButton button, SInt32 group, return NULL; } -bool KeyMap::keysForKeyItem(const KeyItem &keyItem, SInt32 &group, - ModifierToKeys &activeModifiers, - KeyModifierMask ¤tState, - KeyModifierMask desiredState, - KeyModifierMask overrideModifiers, - bool isAutoRepeat, Keystrokes &keystrokes, - const String &lang) const { +bool KeyMap::keysForKeyItem( + const KeyItem &keyItem, SInt32 &group, ModifierToKeys &activeModifiers, + KeyModifierMask ¤tState, KeyModifierMask desiredState, + KeyModifierMask overrideModifiers, bool isAutoRepeat, + Keystrokes &keystrokes, const String &lang) const { static const KeyModifierMask s_notRequiredMask = KeyModifierAltGr | KeyModifierNumLock | KeyModifierScrollLock; @@ -715,10 +721,11 @@ bool KeyMap::keysForKeyItem(const KeyItem &keyItem, SInt32 &group, EKeystroke type; if (keyItem.m_dead) { // adjust modifiers for dead key - if (!keysForModifierState(keyItem.m_button, group, activeModifiers, - currentState, keyItem.m_required, - keyItem.m_sensitive, 0, keystrokes)) { - LOG((CLOG_DEBUG1 "unable to match modifier state for dead key %d", + if (!keysForModifierState( + keyItem.m_button, group, activeModifiers, currentState, + keyItem.m_required, keyItem.m_sensitive, 0, keystrokes)) { + LOG( + (CLOG_DEBUG1 "unable to match modifier state for dead key %d", keyItem.m_button)); return false; } @@ -737,12 +744,14 @@ bool KeyMap::keysForKeyItem(const KeyItem &keyItem, SInt32 &group, // button (any other button) mapped to the shift modifier and then // the Shift_L button. // match key's required state - LOG((CLOG_DEBUG1 "state: %04x,%04x,%04x", currentState, keyItem.m_required, + LOG( + (CLOG_DEBUG1 "state: %04x,%04x,%04x", currentState, keyItem.m_required, sensitive)); - if (!keysForModifierState(keyItem.m_button, group, activeModifiers, - currentState, keyItem.m_required, sensitive, 0, - keystrokes)) { - LOG((CLOG_DEBUG1 "unable to match modifier state (%04x,%04x) for key %d", + if (!keysForModifierState( + keyItem.m_button, group, activeModifiers, currentState, + keyItem.m_required, sensitive, 0, keystrokes)) { + LOG( + (CLOG_DEBUG1 "unable to match modifier state (%04x,%04x) for key %d", keyItem.m_required, keyItem.m_sensitive, keyItem.m_button)); return false; } @@ -750,13 +759,15 @@ bool KeyMap::keysForKeyItem(const KeyItem &keyItem, SInt32 &group, // match desiredState as closely as possible. we must not // change any modifiers in keyItem.m_sensitive. and if the key // is a modifier, we don't want to change that modifier. - LOG((CLOG_DEBUG1 "desired state: %04x %04x,%04x,%04x", desiredState, + LOG( + (CLOG_DEBUG1 "desired state: %04x %04x,%04x,%04x", desiredState, currentState, keyItem.m_required, keyItem.m_sensitive)); - if (!keysForModifierState(keyItem.m_button, group, activeModifiers, - currentState, desiredState, - ~(sensitive | keyItem.m_generates), - s_notRequiredMask, keystrokes)) { - LOG((CLOG_DEBUG1 + if (!keysForModifierState( + keyItem.m_button, group, activeModifiers, currentState, + desiredState, ~(sensitive | keyItem.m_generates), s_notRequiredMask, + keystrokes)) { + LOG( + (CLOG_DEBUG1 "unable to match desired modifier state (%04x,%04x) for key %d", desiredState, ~keyItem.m_sensitive & 0xffffu, keyItem.m_button)); return false; @@ -770,11 +781,10 @@ bool KeyMap::keysForKeyItem(const KeyItem &keyItem, SInt32 &group, return true; } -bool KeyMap::keysToRestoreModifiers(const KeyItem &keyItem, SInt32, - ModifierToKeys &activeModifiers, - KeyModifierMask ¤tState, - const ModifierToKeys &desiredModifiers, - Keystrokes &keystrokes) const { +bool KeyMap::keysToRestoreModifiers( + const KeyItem &keyItem, SInt32, ModifierToKeys &activeModifiers, + KeyModifierMask ¤tState, const ModifierToKeys &desiredModifiers, + Keystrokes &keystrokes) const { // XXX -- we're not considering modified modifiers here ModifierToKeys oldModifiers = activeModifiers; @@ -813,13 +823,11 @@ bool KeyMap::keysToRestoreModifiers(const KeyItem &keyItem, SInt32, return true; } -bool KeyMap::keysForModifierState(KeyButton button, SInt32 group, - ModifierToKeys &activeModifiers, - KeyModifierMask ¤tState, - KeyModifierMask requiredState, - KeyModifierMask sensitiveMask, - KeyModifierMask notRequiredMask, - Keystrokes &keystrokes) const { +bool KeyMap::keysForModifierState( + KeyButton button, SInt32 group, ModifierToKeys &activeModifiers, + KeyModifierMask ¤tState, KeyModifierMask requiredState, + KeyModifierMask sensitiveMask, KeyModifierMask notRequiredMask, + Keystrokes &keystrokes) const { // compute which modifiers need changing KeyModifierMask flipMask = ((currentState ^ requiredState) & sensitiveMask); // if a modifier is not required then don't even try to match it. if @@ -828,7 +836,8 @@ bool KeyMap::keysForModifierState(KeyButton button, SInt32 group, // to work if the key itself is a modifier (the numlock toggle can // interfere) so we don't try to match at all. flipMask &= ~notRequiredMask; - LOG((CLOG_DEBUG1 "flip: %04x (%04x vs %04x in %04x - %04x)", flipMask, + LOG( + (CLOG_DEBUG1 "flip: %04x (%04x vs %04x in %04x - %04x)", flipMask, currentState, requiredState, sensitiveMask & 0xffffu, notRequiredMask & 0xffffu)); if (flipMask == 0) { @@ -880,9 +889,9 @@ bool KeyMap::keysForModifierState(KeyButton button, SInt32 group, return false; } if (active && - !keysForModifierState(button, group, activeModifiers, currentState, - keyItem->m_required, sensitive, notRequiredMask, - keystrokes)) { + !keysForModifierState( + button, group, activeModifiers, currentState, keyItem->m_required, + sensitive, notRequiredMask, keystrokes)) { return false; } else if (!active) { // release the modifier @@ -895,7 +904,8 @@ bool KeyMap::keysForModifierState(KeyButton button, SInt32 group, // current state should match required state if ((currentState & sensitive) != (keyItem->m_required & sensitive)) { - LOG((CLOG_DEBUG1 "unable to match modifier state for modifier %04x (%04x " + LOG( + (CLOG_DEBUG1 "unable to match modifier state for modifier %04x (%04x " "vs %04x in %04x)", mask, currentState, keyItem->m_required, sensitive)); return false; @@ -909,10 +919,9 @@ bool KeyMap::keysForModifierState(KeyButton button, SInt32 group, return true; } -void KeyMap::addKeystrokes(EKeystroke type, const KeyItem &keyItem, - ModifierToKeys &activeModifiers, - KeyModifierMask ¤tState, - Keystrokes &keystrokes) const { +void KeyMap::addKeystrokes( + EKeystroke type, const KeyItem &keyItem, ModifierToKeys &activeModifiers, + KeyModifierMask ¤tState, Keystrokes &keystrokes) const { KeyButton button = keyItem.m_button; UInt32 data = keyItem.m_client; switch (type) { @@ -1217,18 +1226,19 @@ void KeyMap::initKeyNameMaps() { // bool KeyMap::KeyItem::operator==(const KeyItem &x) const { - return (m_id == x.m_id && m_group == x.m_group && m_button == x.m_button && - m_required == x.m_required && m_sensitive == x.m_sensitive && - m_generates == x.m_generates && m_dead == x.m_dead && - m_lock == x.m_lock && m_client == x.m_client); + return ( + m_id == x.m_id && m_group == x.m_group && m_button == x.m_button && + m_required == x.m_required && m_sensitive == x.m_sensitive && + m_generates == x.m_generates && m_dead == x.m_dead && + m_lock == x.m_lock && m_client == x.m_client); } // // KeyMap::Keystroke // -KeyMap::Keystroke::Keystroke(KeyButton button, bool press, bool repeat, - UInt32 data) +KeyMap::Keystroke::Keystroke( + KeyButton button, bool press, bool repeat, UInt32 data) : m_type(kButton) { m_data.m_button.m_button = button; m_data.m_button.m_press = press; diff --git a/src/lib/synergy/KeyMap.h b/src/lib/synergy/KeyMap.h index ee8101c56..b0e5b0b99 100644 --- a/src/lib/synergy/KeyMap.h +++ b/src/lib/synergy/KeyMap.h @@ -121,8 +121,8 @@ public: typedef std::map ButtonToKeyMap; //! Callback type for \c foreachKey - typedef void (*ForeachKeyCallback)(KeyID, SInt32 group, KeyItem &, - void *userData); + typedef void (*ForeachKeyCallback)( + KeyID, SInt32 group, KeyItem &, void *userData); //! @name manipulators //@{ @@ -147,11 +147,10 @@ public: effectively makes the \p sourceID an alias for \p targetID (i.e. we can generate \p targetID using \p sourceID). */ - void addKeyAliasEntry(KeyID targetID, SInt32 group, - KeyModifierMask targetRequired, - KeyModifierMask targetSensitive, KeyID sourceID, - KeyModifierMask sourceRequired, - KeyModifierMask sourceSensitive); + void addKeyAliasEntry( + KeyID targetID, SInt32 group, KeyModifierMask targetRequired, + KeyModifierMask targetSensitive, KeyID sourceID, + KeyModifierMask sourceRequired, KeyModifierMask sourceSensitive); //! Add a key sequence entry /*! @@ -163,8 +162,8 @@ public: least one key in \p keys is not in the map then nothing is added and this returns \c false, otherwise it returns \c true. */ - bool addKeyCombinationEntry(KeyID id, SInt32 group, const KeyID *keys, - UInt32 numKeys); + bool addKeyCombinationEntry( + KeyID id, SInt32 group, const KeyID *keys, UInt32 numKeys); //! Enable composition across groups /*! @@ -219,11 +218,10 @@ public: event in \p keys. It returns the \c KeyItem of the key being pressed/repeated, or NULL if the key cannot be mapped. */ - virtual const KeyItem *mapKey(Keystrokes &keys, KeyID id, SInt32 group, - ModifierToKeys &activeModifiers, - KeyModifierMask ¤tState, - KeyModifierMask desiredMask, bool isAutoRepeat, - const String &lang) const; + virtual const KeyItem *mapKey( + Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, + KeyModifierMask ¤tState, KeyModifierMask desiredMask, + bool isAutoRepeat, const String &lang) const; void setLanguageData(std::vector layouts); @@ -248,9 +246,9 @@ public: it requires the modifiers to be in the state indicated by \p required for every modifier indicated by \p sensitive. */ - const KeyItemList *findCompatibleKey(KeyID id, SInt32 group, - KeyModifierMask required, - KeyModifierMask sensitive) const; + const KeyItemList *findCompatibleKey( + KeyID id, SInt32 group, KeyModifierMask required, + KeyModifierMask sensitive) const; //! Test if modifier is half-duplex /*! @@ -281,8 +279,8 @@ public: /*! Put all the keys in \p modifiers into \p keys. */ - static void collectButtons(const ModifierToKeys &modifiers, - ButtonToKeyMap &keys); + static void + collectButtons(const ModifierToKeys &modifiers, ButtonToKeyMap &keys); //! Set modifier key state /*! @@ -332,15 +330,17 @@ public: #ifdef TEST_ENV private: FRIEND_TEST(KeyMapTests, findBestKey_requiredDown_matchExactFirstItem); - FRIEND_TEST(KeyMapTests, - findBestKey_requiredAndExtraSensitiveDown_matchExactFirstItem); - FRIEND_TEST(KeyMapTests, - findBestKey_requiredAndExtraSensitiveDown_matchExactSecondItem); + FRIEND_TEST( + KeyMapTests, + findBestKey_requiredAndExtraSensitiveDown_matchExactFirstItem); + FRIEND_TEST( + KeyMapTests, + findBestKey_requiredAndExtraSensitiveDown_matchExactSecondItem); FRIEND_TEST(KeyMapTests, findBestKey_extraSensitiveDown_matchExactSecondItem); - FRIEND_TEST(KeyMapTests, - findBestKey_noRequiredDown_matchOneRequiredChangeItem); - FRIEND_TEST(KeyMapTests, - findBestKey_onlyOneRequiredDown_matchTwoRequiredChangesItem); + FRIEND_TEST( + KeyMapTests, findBestKey_noRequiredDown_matchOneRequiredChangeItem); + FRIEND_TEST( + KeyMapTests, findBestKey_onlyOneRequiredDown_matchTwoRequiredChangesItem); FRIEND_TEST(KeyMapTests, findBestKey_noRequiredDown_cannotMatch); #endif private: @@ -369,80 +369,72 @@ private: // right button and synthesize the requested modifiers without regard // to what character they would synthesize. we disallow multikey // entries since they don't make sense as hotkeys. - const KeyItem *mapCommandKey(Keystrokes &keys, KeyID id, SInt32 group, - ModifierToKeys &activeModifiers, - KeyModifierMask ¤tState, - KeyModifierMask desiredMask, bool isAutoRepeat, - const String &lang) const; + const KeyItem *mapCommandKey( + Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, + KeyModifierMask ¤tState, KeyModifierMask desiredMask, + bool isAutoRepeat, const String &lang) const; // maps a character key. a character key is trying to synthesize a // particular KeyID and isn't entirely concerned with the modifiers // used to do it. - const KeyItem *mapCharacterKey(Keystrokes &keys, KeyID id, SInt32 group, - ModifierToKeys &activeModifiers, - KeyModifierMask ¤tState, - KeyModifierMask desiredMask, bool isAutoRepeat, - const String &lang) const; + const KeyItem *mapCharacterKey( + Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, + KeyModifierMask ¤tState, KeyModifierMask desiredMask, + bool isAutoRepeat, const String &lang) const; // maps a modifier key - const KeyItem *mapModifierKey(Keystrokes &keys, KeyID id, SInt32 group, - ModifierToKeys &activeModifiers, - KeyModifierMask ¤tState, - KeyModifierMask desiredMask, bool isAutoRepeat, - const String &lang) const; + const KeyItem *mapModifierKey( + Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, + KeyModifierMask ¤tState, KeyModifierMask desiredMask, + bool isAutoRepeat, const String &lang) const; // returns the index into \p entryList of the KeyItemList requiring // the fewest modifier changes between \p currentState and // \p desiredState. - SInt32 findBestKey(const KeyEntryList &entryList, - KeyModifierMask desiredState) const; + SInt32 findBestKey( + const KeyEntryList &entryList, KeyModifierMask desiredState) const; // gets the \c KeyItem used to synthesize the modifier who's bit is // given by \p modifierBit in group \p group and does not synthesize // the key \p button. - const KeyItem *keyForModifier(KeyButton button, SInt32 group, - SInt32 modifierBit) const; + const KeyItem * + keyForModifier(KeyButton button, SInt32 group, SInt32 modifierBit) const; // fills \p keystrokes with the keys to synthesize the key in // \p keyItem taking the modifiers into account. returns \c true // iff successful and sets \p currentState to the // resulting modifier state. - bool keysForKeyItem(const KeyItem &keyItem, SInt32 &group, - ModifierToKeys &activeModifiers, - KeyModifierMask ¤tState, - KeyModifierMask desiredState, - KeyModifierMask overrideModifiers, bool isAutoRepeat, - Keystrokes &keystrokes, const String &lang) const; + bool keysForKeyItem( + const KeyItem &keyItem, SInt32 &group, ModifierToKeys &activeModifiers, + KeyModifierMask ¤tState, KeyModifierMask desiredState, + KeyModifierMask overrideModifiers, bool isAutoRepeat, + Keystrokes &keystrokes, const String &lang) const; // fills \p keystrokes with the keys to synthesize the modifiers // in \p desiredModifiers from the active modifiers listed in // \p activeModifiers not including the key in \p keyItem. // returns \c true iff successful. - bool keysToRestoreModifiers(const KeyItem &keyItem, SInt32 group, - ModifierToKeys &activeModifiers, - KeyModifierMask ¤tState, - const ModifierToKeys &desiredModifiers, - Keystrokes &keystrokes) const; + bool keysToRestoreModifiers( + const KeyItem &keyItem, SInt32 group, ModifierToKeys &activeModifiers, + KeyModifierMask ¤tState, const ModifierToKeys &desiredModifiers, + Keystrokes &keystrokes) const; // fills \p keystrokes and \p undo with the keys to change the // current modifier state in \p currentState to match the state in // \p requiredState for each modifier indicated in \p sensitiveMask. // returns \c true iff successful and sets \p currentState to the // resulting modifier state. - bool keysForModifierState(KeyButton button, SInt32 group, - ModifierToKeys &activeModifiers, - KeyModifierMask ¤tState, - KeyModifierMask requiredState, - KeyModifierMask sensitiveMask, - KeyModifierMask notRequiredMask, - Keystrokes &keystrokes) const; + bool keysForModifierState( + KeyButton button, SInt32 group, ModifierToKeys &activeModifiers, + KeyModifierMask ¤tState, KeyModifierMask requiredState, + KeyModifierMask sensitiveMask, KeyModifierMask notRequiredMask, + Keystrokes &keystrokes) const; // Adds keystrokes to synthesize key \p keyItem in mode \p type to // \p keystrokes and to undo the synthesis to \p undo. - void addKeystrokes(EKeystroke type, const KeyItem &keyItem, - ModifierToKeys &activeModifiers, - KeyModifierMask ¤tState, - Keystrokes &keystrokes) const; + void addKeystrokes( + EKeystroke type, const KeyItem &keyItem, ModifierToKeys &activeModifiers, + KeyModifierMask ¤tState, Keystrokes &keystrokes) const; // Returns the number of modifiers indicated in \p state. static SInt32 getNumModifiers(KeyModifierMask state); @@ -453,13 +445,13 @@ private: // Ways to synthesize a KeyID over multiple keyboard groups typedef std::vector KeyGroupTable; - void addGroupToKeystroke(Keystrokes &keys, SInt32 &group, - const String &lang) const; + void addGroupToKeystroke( + Keystrokes &keys, SInt32 &group, const String &lang) const; SInt32 getLanguageGroupID(SInt32 group, const String &lang) const; - const KeyItemList *getKeyItemList(const KeyGroupTable &keyGroupTable, - SInt32 group, - KeyModifierMask desiredMask) const; + const KeyItemList *getKeyItemList( + const KeyGroupTable &keyGroupTable, SInt32 group, + KeyModifierMask desiredMask) const; // not implemented KeyMap(const KeyMap &); diff --git a/src/lib/synergy/KeyState.cpp b/src/lib/synergy/KeyState.cpp index 1cabe9c0c..8232ed5b8 100644 --- a/src/lib/synergy/KeyState.cpp +++ b/src/lib/synergy/KeyState.cpp @@ -30,320 +30,608 @@ static const KeyButton kButtonMask = (KeyButton)(IKeyState::kNumButtons - 1); static const KeyID s_decomposeTable[] = { // spacing version of dead keys - 0x0060, 0x0300, 0x0020, 0, // grave, dead_grave, space - 0x00b4, 0x0301, 0x0020, 0, // acute, dead_acute, space - 0x005e, 0x0302, 0x0020, 0, // asciicircum, dead_circumflex, space - 0x007e, 0x0303, 0x0020, 0, // asciitilde, dead_tilde, space - 0x00a8, 0x0308, 0x0020, 0, // diaeresis, dead_diaeresis, space - 0x00b0, 0x030a, 0x0020, 0, // degree, dead_abovering, space - 0x00b8, 0x0327, 0x0020, 0, // cedilla, dead_cedilla, space - 0x02db, 0x0328, 0x0020, 0, // ogonek, dead_ogonek, space - 0x02c7, 0x030c, 0x0020, 0, // caron, dead_caron, space - 0x02d9, 0x0307, 0x0020, 0, // abovedot, dead_abovedot, space - 0x02dd, 0x030b, 0x0020, 0, // doubleacute, dead_doubleacute, space - 0x02d8, 0x0306, 0x0020, 0, // breve, dead_breve, space - 0x00af, 0x0304, 0x0020, 0, // macron, dead_macron, space + 0x0060, 0x0300, 0x0020, + 0, // grave, dead_grave, space + 0x00b4, 0x0301, 0x0020, + 0, // acute, dead_acute, space + 0x005e, 0x0302, 0x0020, + 0, // asciicircum, dead_circumflex, space + 0x007e, 0x0303, 0x0020, + 0, // asciitilde, dead_tilde, space + 0x00a8, 0x0308, 0x0020, + 0, // diaeresis, dead_diaeresis, space + 0x00b0, 0x030a, 0x0020, + 0, // degree, dead_abovering, space + 0x00b8, 0x0327, 0x0020, + 0, // cedilla, dead_cedilla, space + 0x02db, 0x0328, 0x0020, + 0, // ogonek, dead_ogonek, space + 0x02c7, 0x030c, 0x0020, + 0, // caron, dead_caron, space + 0x02d9, 0x0307, 0x0020, + 0, // abovedot, dead_abovedot, space + 0x02dd, 0x030b, 0x0020, + 0, // doubleacute, dead_doubleacute, space + 0x02d8, 0x0306, 0x0020, + 0, // breve, dead_breve, space + 0x00af, 0x0304, 0x0020, + 0, // macron, dead_macron, space // Latin-1 (ISO 8859-1) - 0x00c0, 0x0300, 0x0041, 0, // Agrave, dead_grave, A - 0x00c1, 0x0301, 0x0041, 0, // Aacute, dead_acute, A - 0x00c2, 0x0302, 0x0041, 0, // Acircumflex, dead_circumflex, A - 0x00c3, 0x0303, 0x0041, 0, // Atilde, dead_tilde, A - 0x00c4, 0x0308, 0x0041, 0, // Adiaeresis, dead_diaeresis, A - 0x00c5, 0x030a, 0x0041, 0, // Aring, dead_abovering, A - 0x00c7, 0x0327, 0x0043, 0, // Ccedilla, dead_cedilla, C - 0x00c8, 0x0300, 0x0045, 0, // Egrave, dead_grave, E - 0x00c9, 0x0301, 0x0045, 0, // Eacute, dead_acute, E - 0x00ca, 0x0302, 0x0045, 0, // Ecircumflex, dead_circumflex, E - 0x00cb, 0x0308, 0x0045, 0, // Ediaeresis, dead_diaeresis, E - 0x00cc, 0x0300, 0x0049, 0, // Igrave, dead_grave, I - 0x00cd, 0x0301, 0x0049, 0, // Iacute, dead_acute, I - 0x00ce, 0x0302, 0x0049, 0, // Icircumflex, dead_circumflex, I - 0x00cf, 0x0308, 0x0049, 0, // Idiaeresis, dead_diaeresis, I - 0x00d1, 0x0303, 0x004e, 0, // Ntilde, dead_tilde, N - 0x00d2, 0x0300, 0x004f, 0, // Ograve, dead_grave, O - 0x00d3, 0x0301, 0x004f, 0, // Oacute, dead_acute, O - 0x00d4, 0x0302, 0x004f, 0, // Ocircumflex, dead_circumflex, O - 0x00d5, 0x0303, 0x004f, 0, // Otilde, dead_tilde, O - 0x00d6, 0x0308, 0x004f, 0, // Odiaeresis, dead_diaeresis, O - 0x00d9, 0x0300, 0x0055, 0, // Ugrave, dead_grave, U - 0x00da, 0x0301, 0x0055, 0, // Uacute, dead_acute, U - 0x00db, 0x0302, 0x0055, 0, // Ucircumflex, dead_circumflex, U - 0x00dc, 0x0308, 0x0055, 0, // Udiaeresis, dead_diaeresis, U - 0x00dd, 0x0301, 0x0059, 0, // Yacute, dead_acute, Y - 0x00e0, 0x0300, 0x0061, 0, // agrave, dead_grave, a - 0x00e1, 0x0301, 0x0061, 0, // aacute, dead_acute, a - 0x00e2, 0x0302, 0x0061, 0, // acircumflex, dead_circumflex, a - 0x00e3, 0x0303, 0x0061, 0, // atilde, dead_tilde, a - 0x00e4, 0x0308, 0x0061, 0, // adiaeresis, dead_diaeresis, a - 0x00e5, 0x030a, 0x0061, 0, // aring, dead_abovering, a - 0x00e7, 0x0327, 0x0063, 0, // ccedilla, dead_cedilla, c - 0x00e8, 0x0300, 0x0065, 0, // egrave, dead_grave, e - 0x00e9, 0x0301, 0x0065, 0, // eacute, dead_acute, e - 0x00ea, 0x0302, 0x0065, 0, // ecircumflex, dead_circumflex, e - 0x00eb, 0x0308, 0x0065, 0, // ediaeresis, dead_diaeresis, e - 0x00ec, 0x0300, 0x0069, 0, // igrave, dead_grave, i - 0x00ed, 0x0301, 0x0069, 0, // iacute, dead_acute, i - 0x00ee, 0x0302, 0x0069, 0, // icircumflex, dead_circumflex, i - 0x00ef, 0x0308, 0x0069, 0, // idiaeresis, dead_diaeresis, i - 0x00f1, 0x0303, 0x006e, 0, // ntilde, dead_tilde, n - 0x00f2, 0x0300, 0x006f, 0, // ograve, dead_grave, o - 0x00f3, 0x0301, 0x006f, 0, // oacute, dead_acute, o - 0x00f4, 0x0302, 0x006f, 0, // ocircumflex, dead_circumflex, o - 0x00f5, 0x0303, 0x006f, 0, // otilde, dead_tilde, o - 0x00f6, 0x0308, 0x006f, 0, // odiaeresis, dead_diaeresis, o - 0x00f9, 0x0300, 0x0075, 0, // ugrave, dead_grave, u - 0x00fa, 0x0301, 0x0075, 0, // uacute, dead_acute, u - 0x00fb, 0x0302, 0x0075, 0, // ucircumflex, dead_circumflex, u - 0x00fc, 0x0308, 0x0075, 0, // udiaeresis, dead_diaeresis, u - 0x00fd, 0x0301, 0x0079, 0, // yacute, dead_acute, y - 0x00ff, 0x0308, 0x0079, 0, // ydiaeresis, dead_diaeresis, y + 0x00c0, 0x0300, 0x0041, + 0, // Agrave, dead_grave, A + 0x00c1, 0x0301, 0x0041, + 0, // Aacute, dead_acute, A + 0x00c2, 0x0302, 0x0041, + 0, // Acircumflex, dead_circumflex, A + 0x00c3, 0x0303, 0x0041, + 0, // Atilde, dead_tilde, A + 0x00c4, 0x0308, 0x0041, + 0, // Adiaeresis, dead_diaeresis, A + 0x00c5, 0x030a, 0x0041, + 0, // Aring, dead_abovering, A + 0x00c7, 0x0327, 0x0043, + 0, // Ccedilla, dead_cedilla, C + 0x00c8, 0x0300, 0x0045, + 0, // Egrave, dead_grave, E + 0x00c9, 0x0301, 0x0045, + 0, // Eacute, dead_acute, E + 0x00ca, 0x0302, 0x0045, + 0, // Ecircumflex, dead_circumflex, E + 0x00cb, 0x0308, 0x0045, + 0, // Ediaeresis, dead_diaeresis, E + 0x00cc, 0x0300, 0x0049, + 0, // Igrave, dead_grave, I + 0x00cd, 0x0301, 0x0049, + 0, // Iacute, dead_acute, I + 0x00ce, 0x0302, 0x0049, + 0, // Icircumflex, dead_circumflex, I + 0x00cf, 0x0308, 0x0049, + 0, // Idiaeresis, dead_diaeresis, I + 0x00d1, 0x0303, 0x004e, + 0, // Ntilde, dead_tilde, N + 0x00d2, 0x0300, 0x004f, + 0, // Ograve, dead_grave, O + 0x00d3, 0x0301, 0x004f, + 0, // Oacute, dead_acute, O + 0x00d4, 0x0302, 0x004f, + 0, // Ocircumflex, dead_circumflex, O + 0x00d5, 0x0303, 0x004f, + 0, // Otilde, dead_tilde, O + 0x00d6, 0x0308, 0x004f, + 0, // Odiaeresis, dead_diaeresis, O + 0x00d9, 0x0300, 0x0055, + 0, // Ugrave, dead_grave, U + 0x00da, 0x0301, 0x0055, + 0, // Uacute, dead_acute, U + 0x00db, 0x0302, 0x0055, + 0, // Ucircumflex, dead_circumflex, U + 0x00dc, 0x0308, 0x0055, + 0, // Udiaeresis, dead_diaeresis, U + 0x00dd, 0x0301, 0x0059, + 0, // Yacute, dead_acute, Y + 0x00e0, 0x0300, 0x0061, + 0, // agrave, dead_grave, a + 0x00e1, 0x0301, 0x0061, + 0, // aacute, dead_acute, a + 0x00e2, 0x0302, 0x0061, + 0, // acircumflex, dead_circumflex, a + 0x00e3, 0x0303, 0x0061, + 0, // atilde, dead_tilde, a + 0x00e4, 0x0308, 0x0061, + 0, // adiaeresis, dead_diaeresis, a + 0x00e5, 0x030a, 0x0061, + 0, // aring, dead_abovering, a + 0x00e7, 0x0327, 0x0063, + 0, // ccedilla, dead_cedilla, c + 0x00e8, 0x0300, 0x0065, + 0, // egrave, dead_grave, e + 0x00e9, 0x0301, 0x0065, + 0, // eacute, dead_acute, e + 0x00ea, 0x0302, 0x0065, + 0, // ecircumflex, dead_circumflex, e + 0x00eb, 0x0308, 0x0065, + 0, // ediaeresis, dead_diaeresis, e + 0x00ec, 0x0300, 0x0069, + 0, // igrave, dead_grave, i + 0x00ed, 0x0301, 0x0069, + 0, // iacute, dead_acute, i + 0x00ee, 0x0302, 0x0069, + 0, // icircumflex, dead_circumflex, i + 0x00ef, 0x0308, 0x0069, + 0, // idiaeresis, dead_diaeresis, i + 0x00f1, 0x0303, 0x006e, + 0, // ntilde, dead_tilde, n + 0x00f2, 0x0300, 0x006f, + 0, // ograve, dead_grave, o + 0x00f3, 0x0301, 0x006f, + 0, // oacute, dead_acute, o + 0x00f4, 0x0302, 0x006f, + 0, // ocircumflex, dead_circumflex, o + 0x00f5, 0x0303, 0x006f, + 0, // otilde, dead_tilde, o + 0x00f6, 0x0308, 0x006f, + 0, // odiaeresis, dead_diaeresis, o + 0x00f9, 0x0300, 0x0075, + 0, // ugrave, dead_grave, u + 0x00fa, 0x0301, 0x0075, + 0, // uacute, dead_acute, u + 0x00fb, 0x0302, 0x0075, + 0, // ucircumflex, dead_circumflex, u + 0x00fc, 0x0308, 0x0075, + 0, // udiaeresis, dead_diaeresis, u + 0x00fd, 0x0301, 0x0079, + 0, // yacute, dead_acute, y + 0x00ff, 0x0308, 0x0079, + 0, // ydiaeresis, dead_diaeresis, y // Latin-2 (ISO 8859-2) - 0x0104, 0x0328, 0x0041, 0, // Aogonek, dead_ogonek, A - 0x013d, 0x030c, 0x004c, 0, // Lcaron, dead_caron, L - 0x015a, 0x0301, 0x0053, 0, // Sacute, dead_acute, S - 0x0160, 0x030c, 0x0053, 0, // Scaron, dead_caron, S - 0x015e, 0x0327, 0x0053, 0, // Scedilla, dead_cedilla, S - 0x0164, 0x030c, 0x0054, 0, // Tcaron, dead_caron, T - 0x0179, 0x0301, 0x005a, 0, // Zacute, dead_acute, Z - 0x017d, 0x030c, 0x005a, 0, // Zcaron, dead_caron, Z - 0x017b, 0x0307, 0x005a, 0, // Zabovedot, dead_abovedot, Z - 0x0105, 0x0328, 0x0061, 0, // aogonek, dead_ogonek, a - 0x013e, 0x030c, 0x006c, 0, // lcaron, dead_caron, l - 0x015b, 0x0301, 0x0073, 0, // sacute, dead_acute, s - 0x0161, 0x030c, 0x0073, 0, // scaron, dead_caron, s - 0x015f, 0x0327, 0x0073, 0, // scedilla, dead_cedilla, s - 0x0165, 0x030c, 0x0074, 0, // tcaron, dead_caron, t - 0x017a, 0x0301, 0x007a, 0, // zacute, dead_acute, z - 0x017e, 0x030c, 0x007a, 0, // zcaron, dead_caron, z - 0x017c, 0x0307, 0x007a, 0, // zabovedot, dead_abovedot, z - 0x0154, 0x0301, 0x0052, 0, // Racute, dead_acute, R - 0x0102, 0x0306, 0x0041, 0, // Abreve, dead_breve, A - 0x0139, 0x0301, 0x004c, 0, // Lacute, dead_acute, L - 0x0106, 0x0301, 0x0043, 0, // Cacute, dead_acute, C - 0x010c, 0x030c, 0x0043, 0, // Ccaron, dead_caron, C - 0x0118, 0x0328, 0x0045, 0, // Eogonek, dead_ogonek, E - 0x011a, 0x030c, 0x0045, 0, // Ecaron, dead_caron, E - 0x010e, 0x030c, 0x0044, 0, // Dcaron, dead_caron, D - 0x0143, 0x0301, 0x004e, 0, // Nacute, dead_acute, N - 0x0147, 0x030c, 0x004e, 0, // Ncaron, dead_caron, N - 0x0150, 0x030b, 0x004f, 0, // Odoubleacute, dead_doubleacute, O - 0x0158, 0x030c, 0x0052, 0, // Rcaron, dead_caron, R - 0x016e, 0x030a, 0x0055, 0, // Uring, dead_abovering, U - 0x0170, 0x030b, 0x0055, 0, // Udoubleacute, dead_doubleacute, U - 0x0162, 0x0327, 0x0054, 0, // Tcedilla, dead_cedilla, T - 0x0155, 0x0301, 0x0072, 0, // racute, dead_acute, r - 0x0103, 0x0306, 0x0061, 0, // abreve, dead_breve, a - 0x013a, 0x0301, 0x006c, 0, // lacute, dead_acute, l - 0x0107, 0x0301, 0x0063, 0, // cacute, dead_acute, c - 0x010d, 0x030c, 0x0063, 0, // ccaron, dead_caron, c - 0x0119, 0x0328, 0x0065, 0, // eogonek, dead_ogonek, e - 0x011b, 0x030c, 0x0065, 0, // ecaron, dead_caron, e - 0x010f, 0x030c, 0x0064, 0, // dcaron, dead_caron, d - 0x0144, 0x0301, 0x006e, 0, // nacute, dead_acute, n - 0x0148, 0x030c, 0x006e, 0, // ncaron, dead_caron, n - 0x0151, 0x030b, 0x006f, 0, // odoubleacute, dead_doubleacute, o - 0x0159, 0x030c, 0x0072, 0, // rcaron, dead_caron, r - 0x016f, 0x030a, 0x0075, 0, // uring, dead_abovering, u - 0x0171, 0x030b, 0x0075, 0, // udoubleacute, dead_doubleacute, u - 0x0163, 0x0327, 0x0074, 0, // tcedilla, dead_cedilla, t + 0x0104, 0x0328, 0x0041, + 0, // Aogonek, dead_ogonek, A + 0x013d, 0x030c, 0x004c, + 0, // Lcaron, dead_caron, L + 0x015a, 0x0301, 0x0053, + 0, // Sacute, dead_acute, S + 0x0160, 0x030c, 0x0053, + 0, // Scaron, dead_caron, S + 0x015e, 0x0327, 0x0053, + 0, // Scedilla, dead_cedilla, S + 0x0164, 0x030c, 0x0054, + 0, // Tcaron, dead_caron, T + 0x0179, 0x0301, 0x005a, + 0, // Zacute, dead_acute, Z + 0x017d, 0x030c, 0x005a, + 0, // Zcaron, dead_caron, Z + 0x017b, 0x0307, 0x005a, + 0, // Zabovedot, dead_abovedot, Z + 0x0105, 0x0328, 0x0061, + 0, // aogonek, dead_ogonek, a + 0x013e, 0x030c, 0x006c, + 0, // lcaron, dead_caron, l + 0x015b, 0x0301, 0x0073, + 0, // sacute, dead_acute, s + 0x0161, 0x030c, 0x0073, + 0, // scaron, dead_caron, s + 0x015f, 0x0327, 0x0073, + 0, // scedilla, dead_cedilla, s + 0x0165, 0x030c, 0x0074, + 0, // tcaron, dead_caron, t + 0x017a, 0x0301, 0x007a, + 0, // zacute, dead_acute, z + 0x017e, 0x030c, 0x007a, + 0, // zcaron, dead_caron, z + 0x017c, 0x0307, 0x007a, + 0, // zabovedot, dead_abovedot, z + 0x0154, 0x0301, 0x0052, + 0, // Racute, dead_acute, R + 0x0102, 0x0306, 0x0041, + 0, // Abreve, dead_breve, A + 0x0139, 0x0301, 0x004c, + 0, // Lacute, dead_acute, L + 0x0106, 0x0301, 0x0043, + 0, // Cacute, dead_acute, C + 0x010c, 0x030c, 0x0043, + 0, // Ccaron, dead_caron, C + 0x0118, 0x0328, 0x0045, + 0, // Eogonek, dead_ogonek, E + 0x011a, 0x030c, 0x0045, + 0, // Ecaron, dead_caron, E + 0x010e, 0x030c, 0x0044, + 0, // Dcaron, dead_caron, D + 0x0143, 0x0301, 0x004e, + 0, // Nacute, dead_acute, N + 0x0147, 0x030c, 0x004e, + 0, // Ncaron, dead_caron, N + 0x0150, 0x030b, 0x004f, + 0, // Odoubleacute, dead_doubleacute, O + 0x0158, 0x030c, 0x0052, + 0, // Rcaron, dead_caron, R + 0x016e, 0x030a, 0x0055, + 0, // Uring, dead_abovering, U + 0x0170, 0x030b, 0x0055, + 0, // Udoubleacute, dead_doubleacute, U + 0x0162, 0x0327, 0x0054, + 0, // Tcedilla, dead_cedilla, T + 0x0155, 0x0301, 0x0072, + 0, // racute, dead_acute, r + 0x0103, 0x0306, 0x0061, + 0, // abreve, dead_breve, a + 0x013a, 0x0301, 0x006c, + 0, // lacute, dead_acute, l + 0x0107, 0x0301, 0x0063, + 0, // cacute, dead_acute, c + 0x010d, 0x030c, 0x0063, + 0, // ccaron, dead_caron, c + 0x0119, 0x0328, 0x0065, + 0, // eogonek, dead_ogonek, e + 0x011b, 0x030c, 0x0065, + 0, // ecaron, dead_caron, e + 0x010f, 0x030c, 0x0064, + 0, // dcaron, dead_caron, d + 0x0144, 0x0301, 0x006e, + 0, // nacute, dead_acute, n + 0x0148, 0x030c, 0x006e, + 0, // ncaron, dead_caron, n + 0x0151, 0x030b, 0x006f, + 0, // odoubleacute, dead_doubleacute, o + 0x0159, 0x030c, 0x0072, + 0, // rcaron, dead_caron, r + 0x016f, 0x030a, 0x0075, + 0, // uring, dead_abovering, u + 0x0171, 0x030b, 0x0075, + 0, // udoubleacute, dead_doubleacute, u + 0x0163, 0x0327, 0x0074, + 0, // tcedilla, dead_cedilla, t // Latin-3 (ISO 8859-3) - 0x0124, 0x0302, 0x0048, 0, // Hcircumflex, dead_circumflex, H - 0x0130, 0x0307, 0x0049, 0, // Iabovedot, dead_abovedot, I - 0x011e, 0x0306, 0x0047, 0, // Gbreve, dead_breve, G - 0x0134, 0x0302, 0x004a, 0, // Jcircumflex, dead_circumflex, J - 0x0125, 0x0302, 0x0068, 0, // hcircumflex, dead_circumflex, h - 0x011f, 0x0306, 0x0067, 0, // gbreve, dead_breve, g - 0x0135, 0x0302, 0x006a, 0, // jcircumflex, dead_circumflex, j - 0x010a, 0x0307, 0x0043, 0, // Cabovedot, dead_abovedot, C - 0x0108, 0x0302, 0x0043, 0, // Ccircumflex, dead_circumflex, C - 0x0120, 0x0307, 0x0047, 0, // Gabovedot, dead_abovedot, G - 0x011c, 0x0302, 0x0047, 0, // Gcircumflex, dead_circumflex, G - 0x016c, 0x0306, 0x0055, 0, // Ubreve, dead_breve, U - 0x015c, 0x0302, 0x0053, 0, // Scircumflex, dead_circumflex, S - 0x010b, 0x0307, 0x0063, 0, // cabovedot, dead_abovedot, c - 0x0109, 0x0302, 0x0063, 0, // ccircumflex, dead_circumflex, c - 0x0121, 0x0307, 0x0067, 0, // gabovedot, dead_abovedot, g - 0x011d, 0x0302, 0x0067, 0, // gcircumflex, dead_circumflex, g - 0x016d, 0x0306, 0x0075, 0, // ubreve, dead_breve, u - 0x015d, 0x0302, 0x0073, 0, // scircumflex, dead_circumflex, s + 0x0124, 0x0302, 0x0048, + 0, // Hcircumflex, dead_circumflex, H + 0x0130, 0x0307, 0x0049, + 0, // Iabovedot, dead_abovedot, I + 0x011e, 0x0306, 0x0047, + 0, // Gbreve, dead_breve, G + 0x0134, 0x0302, 0x004a, + 0, // Jcircumflex, dead_circumflex, J + 0x0125, 0x0302, 0x0068, + 0, // hcircumflex, dead_circumflex, h + 0x011f, 0x0306, 0x0067, + 0, // gbreve, dead_breve, g + 0x0135, 0x0302, 0x006a, + 0, // jcircumflex, dead_circumflex, j + 0x010a, 0x0307, 0x0043, + 0, // Cabovedot, dead_abovedot, C + 0x0108, 0x0302, 0x0043, + 0, // Ccircumflex, dead_circumflex, C + 0x0120, 0x0307, 0x0047, + 0, // Gabovedot, dead_abovedot, G + 0x011c, 0x0302, 0x0047, + 0, // Gcircumflex, dead_circumflex, G + 0x016c, 0x0306, 0x0055, + 0, // Ubreve, dead_breve, U + 0x015c, 0x0302, 0x0053, + 0, // Scircumflex, dead_circumflex, S + 0x010b, 0x0307, 0x0063, + 0, // cabovedot, dead_abovedot, c + 0x0109, 0x0302, 0x0063, + 0, // ccircumflex, dead_circumflex, c + 0x0121, 0x0307, 0x0067, + 0, // gabovedot, dead_abovedot, g + 0x011d, 0x0302, 0x0067, + 0, // gcircumflex, dead_circumflex, g + 0x016d, 0x0306, 0x0075, + 0, // ubreve, dead_breve, u + 0x015d, 0x0302, 0x0073, + 0, // scircumflex, dead_circumflex, s // Latin-4 (ISO 8859-4) - 0x0156, 0x0327, 0x0052, 0, // Rcedilla, dead_cedilla, R - 0x0128, 0x0303, 0x0049, 0, // Itilde, dead_tilde, I - 0x013b, 0x0327, 0x004c, 0, // Lcedilla, dead_cedilla, L - 0x0112, 0x0304, 0x0045, 0, // Emacron, dead_macron, E - 0x0122, 0x0327, 0x0047, 0, // Gcedilla, dead_cedilla, G - 0x0157, 0x0327, 0x0072, 0, // rcedilla, dead_cedilla, r - 0x0129, 0x0303, 0x0069, 0, // itilde, dead_tilde, i - 0x013c, 0x0327, 0x006c, 0, // lcedilla, dead_cedilla, l - 0x0113, 0x0304, 0x0065, 0, // emacron, dead_macron, e - 0x0123, 0x0327, 0x0067, 0, // gcedilla, dead_cedilla, g - 0x0100, 0x0304, 0x0041, 0, // Amacron, dead_macron, A - 0x012e, 0x0328, 0x0049, 0, // Iogonek, dead_ogonek, I - 0x0116, 0x0307, 0x0045, 0, // Eabovedot, dead_abovedot, E - 0x012a, 0x0304, 0x0049, 0, // Imacron, dead_macron, I - 0x0145, 0x0327, 0x004e, 0, // Ncedilla, dead_cedilla, N - 0x014c, 0x0304, 0x004f, 0, // Omacron, dead_macron, O - 0x0136, 0x0327, 0x004b, 0, // Kcedilla, dead_cedilla, K - 0x0172, 0x0328, 0x0055, 0, // Uogonek, dead_ogonek, U - 0x0168, 0x0303, 0x0055, 0, // Utilde, dead_tilde, U - 0x016a, 0x0304, 0x0055, 0, // Umacron, dead_macron, U - 0x0101, 0x0304, 0x0061, 0, // amacron, dead_macron, a - 0x012f, 0x0328, 0x0069, 0, // iogonek, dead_ogonek, i - 0x0117, 0x0307, 0x0065, 0, // eabovedot, dead_abovedot, e - 0x012b, 0x0304, 0x0069, 0, // imacron, dead_macron, i - 0x0146, 0x0327, 0x006e, 0, // ncedilla, dead_cedilla, n - 0x014d, 0x0304, 0x006f, 0, // omacron, dead_macron, o - 0x0137, 0x0327, 0x006b, 0, // kcedilla, dead_cedilla, k - 0x0173, 0x0328, 0x0075, 0, // uogonek, dead_ogonek, u - 0x0169, 0x0303, 0x0075, 0, // utilde, dead_tilde, u - 0x016b, 0x0304, 0x0075, 0, // umacron, dead_macron, u + 0x0156, 0x0327, 0x0052, + 0, // Rcedilla, dead_cedilla, R + 0x0128, 0x0303, 0x0049, + 0, // Itilde, dead_tilde, I + 0x013b, 0x0327, 0x004c, + 0, // Lcedilla, dead_cedilla, L + 0x0112, 0x0304, 0x0045, + 0, // Emacron, dead_macron, E + 0x0122, 0x0327, 0x0047, + 0, // Gcedilla, dead_cedilla, G + 0x0157, 0x0327, 0x0072, + 0, // rcedilla, dead_cedilla, r + 0x0129, 0x0303, 0x0069, + 0, // itilde, dead_tilde, i + 0x013c, 0x0327, 0x006c, + 0, // lcedilla, dead_cedilla, l + 0x0113, 0x0304, 0x0065, + 0, // emacron, dead_macron, e + 0x0123, 0x0327, 0x0067, + 0, // gcedilla, dead_cedilla, g + 0x0100, 0x0304, 0x0041, + 0, // Amacron, dead_macron, A + 0x012e, 0x0328, 0x0049, + 0, // Iogonek, dead_ogonek, I + 0x0116, 0x0307, 0x0045, + 0, // Eabovedot, dead_abovedot, E + 0x012a, 0x0304, 0x0049, + 0, // Imacron, dead_macron, I + 0x0145, 0x0327, 0x004e, + 0, // Ncedilla, dead_cedilla, N + 0x014c, 0x0304, 0x004f, + 0, // Omacron, dead_macron, O + 0x0136, 0x0327, 0x004b, + 0, // Kcedilla, dead_cedilla, K + 0x0172, 0x0328, 0x0055, + 0, // Uogonek, dead_ogonek, U + 0x0168, 0x0303, 0x0055, + 0, // Utilde, dead_tilde, U + 0x016a, 0x0304, 0x0055, + 0, // Umacron, dead_macron, U + 0x0101, 0x0304, 0x0061, + 0, // amacron, dead_macron, a + 0x012f, 0x0328, 0x0069, + 0, // iogonek, dead_ogonek, i + 0x0117, 0x0307, 0x0065, + 0, // eabovedot, dead_abovedot, e + 0x012b, 0x0304, 0x0069, + 0, // imacron, dead_macron, i + 0x0146, 0x0327, 0x006e, + 0, // ncedilla, dead_cedilla, n + 0x014d, 0x0304, 0x006f, + 0, // omacron, dead_macron, o + 0x0137, 0x0327, 0x006b, + 0, // kcedilla, dead_cedilla, k + 0x0173, 0x0328, 0x0075, + 0, // uogonek, dead_ogonek, u + 0x0169, 0x0303, 0x0075, + 0, // utilde, dead_tilde, u + 0x016b, 0x0304, 0x0075, + 0, // umacron, dead_macron, u // Latin-8 (ISO 8859-14) - 0x1e02, 0x0307, 0x0042, 0, // Babovedot, dead_abovedot, B - 0x1e03, 0x0307, 0x0062, 0, // babovedot, dead_abovedot, b - 0x1e0a, 0x0307, 0x0044, 0, // Dabovedot, dead_abovedot, D - 0x1e80, 0x0300, 0x0057, 0, // Wgrave, dead_grave, W - 0x1e82, 0x0301, 0x0057, 0, // Wacute, dead_acute, W - 0x1e0b, 0x0307, 0x0064, 0, // dabovedot, dead_abovedot, d - 0x1ef2, 0x0300, 0x0059, 0, // Ygrave, dead_grave, Y - 0x1e1e, 0x0307, 0x0046, 0, // Fabovedot, dead_abovedot, F - 0x1e1f, 0x0307, 0x0066, 0, // fabovedot, dead_abovedot, f - 0x1e40, 0x0307, 0x004d, 0, // Mabovedot, dead_abovedot, M - 0x1e41, 0x0307, 0x006d, 0, // mabovedot, dead_abovedot, m - 0x1e56, 0x0307, 0x0050, 0, // Pabovedot, dead_abovedot, P - 0x1e81, 0x0300, 0x0077, 0, // wgrave, dead_grave, w - 0x1e57, 0x0307, 0x0070, 0, // pabovedot, dead_abovedot, p - 0x1e83, 0x0301, 0x0077, 0, // wacute, dead_acute, w - 0x1e60, 0x0307, 0x0053, 0, // Sabovedot, dead_abovedot, S - 0x1ef3, 0x0300, 0x0079, 0, // ygrave, dead_grave, y - 0x1e84, 0x0308, 0x0057, 0, // Wdiaeresis, dead_diaeresis, W - 0x1e85, 0x0308, 0x0077, 0, // wdiaeresis, dead_diaeresis, w - 0x1e61, 0x0307, 0x0073, 0, // sabovedot, dead_abovedot, s - 0x0174, 0x0302, 0x0057, 0, // Wcircumflex, dead_circumflex, W - 0x1e6a, 0x0307, 0x0054, 0, // Tabovedot, dead_abovedot, T - 0x0176, 0x0302, 0x0059, 0, // Ycircumflex, dead_circumflex, Y - 0x0175, 0x0302, 0x0077, 0, // wcircumflex, dead_circumflex, w - 0x1e6b, 0x0307, 0x0074, 0, // tabovedot, dead_abovedot, t - 0x0177, 0x0302, 0x0079, 0, // ycircumflex, dead_circumflex, y + 0x1e02, 0x0307, 0x0042, + 0, // Babovedot, dead_abovedot, B + 0x1e03, 0x0307, 0x0062, + 0, // babovedot, dead_abovedot, b + 0x1e0a, 0x0307, 0x0044, + 0, // Dabovedot, dead_abovedot, D + 0x1e80, 0x0300, 0x0057, + 0, // Wgrave, dead_grave, W + 0x1e82, 0x0301, 0x0057, + 0, // Wacute, dead_acute, W + 0x1e0b, 0x0307, 0x0064, + 0, // dabovedot, dead_abovedot, d + 0x1ef2, 0x0300, 0x0059, + 0, // Ygrave, dead_grave, Y + 0x1e1e, 0x0307, 0x0046, + 0, // Fabovedot, dead_abovedot, F + 0x1e1f, 0x0307, 0x0066, + 0, // fabovedot, dead_abovedot, f + 0x1e40, 0x0307, 0x004d, + 0, // Mabovedot, dead_abovedot, M + 0x1e41, 0x0307, 0x006d, + 0, // mabovedot, dead_abovedot, m + 0x1e56, 0x0307, 0x0050, + 0, // Pabovedot, dead_abovedot, P + 0x1e81, 0x0300, 0x0077, + 0, // wgrave, dead_grave, w + 0x1e57, 0x0307, 0x0070, + 0, // pabovedot, dead_abovedot, p + 0x1e83, 0x0301, 0x0077, + 0, // wacute, dead_acute, w + 0x1e60, 0x0307, 0x0053, + 0, // Sabovedot, dead_abovedot, S + 0x1ef3, 0x0300, 0x0079, + 0, // ygrave, dead_grave, y + 0x1e84, 0x0308, 0x0057, + 0, // Wdiaeresis, dead_diaeresis, W + 0x1e85, 0x0308, 0x0077, + 0, // wdiaeresis, dead_diaeresis, w + 0x1e61, 0x0307, 0x0073, + 0, // sabovedot, dead_abovedot, s + 0x0174, 0x0302, 0x0057, + 0, // Wcircumflex, dead_circumflex, W + 0x1e6a, 0x0307, 0x0054, + 0, // Tabovedot, dead_abovedot, T + 0x0176, 0x0302, 0x0059, + 0, // Ycircumflex, dead_circumflex, Y + 0x0175, 0x0302, 0x0077, + 0, // wcircumflex, dead_circumflex, w + 0x1e6b, 0x0307, 0x0074, + 0, // tabovedot, dead_abovedot, t + 0x0177, 0x0302, 0x0079, + 0, // ycircumflex, dead_circumflex, y // Latin-9 (ISO 8859-15) - 0x0178, 0x0308, 0x0059, 0, // Ydiaeresis, dead_diaeresis, Y + 0x0178, 0x0308, 0x0059, + 0, // Ydiaeresis, dead_diaeresis, Y // Compose key sequences - 0x00c6, kKeyCompose, 0x0041, 0x0045, 0, // AE, A, E - 0x00c1, kKeyCompose, 0x0041, 0x0027, 0, // Aacute, A, apostrophe - 0x00c2, kKeyCompose, 0x0041, 0x0053, 0, // Acircumflex, A, asciicircum - 0x00c3, kKeyCompose, 0x0041, 0x0022, 0, // Adiaeresis, A, quotedbl - 0x00c0, kKeyCompose, 0x0041, 0x0060, 0, // Agrave, A, grave - 0x00c5, kKeyCompose, 0x0041, 0x002a, 0, // Aring, A, asterisk - 0x00c3, kKeyCompose, 0x0041, 0x007e, 0, // Atilde, A, asciitilde - 0x00c7, kKeyCompose, 0x0043, 0x002c, 0, // Ccedilla, C, comma - 0x00d0, kKeyCompose, 0x0044, 0x002d, 0, // ETH, D, minus - 0x00c9, kKeyCompose, 0x0045, 0x0027, 0, // Eacute, E, apostrophe - 0x00ca, kKeyCompose, 0x0045, 0x0053, 0, // Ecircumflex, E, asciicircum - 0x00cb, kKeyCompose, 0x0045, 0x0022, 0, // Ediaeresis, E, quotedbl - 0x00c8, kKeyCompose, 0x0045, 0x0060, 0, // Egrave, E, grave - 0x00cd, kKeyCompose, 0x0049, 0x0027, 0, // Iacute, I, apostrophe - 0x00ce, kKeyCompose, 0x0049, 0x0053, 0, // Icircumflex, I, asciicircum - 0x00cf, kKeyCompose, 0x0049, 0x0022, 0, // Idiaeresis, I, quotedbl - 0x00cc, kKeyCompose, 0x0049, 0x0060, 0, // Igrave, I, grave - 0x00d1, kKeyCompose, 0x004e, 0x007e, 0, // Ntilde, N, asciitilde - 0x00d3, kKeyCompose, 0x004f, 0x0027, 0, // Oacute, O, apostrophe - 0x00d4, kKeyCompose, 0x004f, 0x0053, 0, // Ocircumflex, O, asciicircum - 0x00d6, kKeyCompose, 0x004f, 0x0022, 0, // Odiaeresis, O, quotedbl - 0x00d2, kKeyCompose, 0x004f, 0x0060, 0, // Ograve, O, grave - 0x00d8, kKeyCompose, 0x004f, 0x002f, 0, // Ooblique, O, slash - 0x00d5, kKeyCompose, 0x004f, 0x007e, 0, // Otilde, O, asciitilde - 0x00de, kKeyCompose, 0x0054, 0x0048, 0, // THORN, T, H - 0x00da, kKeyCompose, 0x0055, 0x0027, 0, // Uacute, U, apostrophe - 0x00db, kKeyCompose, 0x0055, 0x0053, 0, // Ucircumflex, U, asciicircum - 0x00dc, kKeyCompose, 0x0055, 0x0022, 0, // Udiaeresis, U, quotedbl - 0x00d9, kKeyCompose, 0x0055, 0x0060, 0, // Ugrave, U, grave - 0x00dd, kKeyCompose, 0x0059, 0x0027, 0, // Yacute, Y, apostrophe - 0x00e1, kKeyCompose, 0x0061, 0x0027, 0, // aacute, a, apostrophe - 0x00e2, kKeyCompose, 0x0061, 0x0053, 0, // acircumflex, a, asciicircum + 0x00c6, kKeyCompose, 0x0041, 0x0045, + 0, // AE, A, E + 0x00c1, kKeyCompose, 0x0041, 0x0027, + 0, // Aacute, A, apostrophe + 0x00c2, kKeyCompose, 0x0041, 0x0053, + 0, // Acircumflex, A, asciicircum + 0x00c3, kKeyCompose, 0x0041, 0x0022, + 0, // Adiaeresis, A, quotedbl + 0x00c0, kKeyCompose, 0x0041, 0x0060, + 0, // Agrave, A, grave + 0x00c5, kKeyCompose, 0x0041, 0x002a, + 0, // Aring, A, asterisk + 0x00c3, kKeyCompose, 0x0041, 0x007e, + 0, // Atilde, A, asciitilde + 0x00c7, kKeyCompose, 0x0043, 0x002c, + 0, // Ccedilla, C, comma + 0x00d0, kKeyCompose, 0x0044, 0x002d, + 0, // ETH, D, minus + 0x00c9, kKeyCompose, 0x0045, 0x0027, + 0, // Eacute, E, apostrophe + 0x00ca, kKeyCompose, 0x0045, 0x0053, + 0, // Ecircumflex, E, asciicircum + 0x00cb, kKeyCompose, 0x0045, 0x0022, + 0, // Ediaeresis, E, quotedbl + 0x00c8, kKeyCompose, 0x0045, 0x0060, + 0, // Egrave, E, grave + 0x00cd, kKeyCompose, 0x0049, 0x0027, + 0, // Iacute, I, apostrophe + 0x00ce, kKeyCompose, 0x0049, 0x0053, + 0, // Icircumflex, I, asciicircum + 0x00cf, kKeyCompose, 0x0049, 0x0022, + 0, // Idiaeresis, I, quotedbl + 0x00cc, kKeyCompose, 0x0049, 0x0060, + 0, // Igrave, I, grave + 0x00d1, kKeyCompose, 0x004e, 0x007e, + 0, // Ntilde, N, asciitilde + 0x00d3, kKeyCompose, 0x004f, 0x0027, + 0, // Oacute, O, apostrophe + 0x00d4, kKeyCompose, 0x004f, 0x0053, + 0, // Ocircumflex, O, asciicircum + 0x00d6, kKeyCompose, 0x004f, 0x0022, + 0, // Odiaeresis, O, quotedbl + 0x00d2, kKeyCompose, 0x004f, 0x0060, + 0, // Ograve, O, grave + 0x00d8, kKeyCompose, 0x004f, 0x002f, + 0, // Ooblique, O, slash + 0x00d5, kKeyCompose, 0x004f, 0x007e, + 0, // Otilde, O, asciitilde + 0x00de, kKeyCompose, 0x0054, 0x0048, + 0, // THORN, T, H + 0x00da, kKeyCompose, 0x0055, 0x0027, + 0, // Uacute, U, apostrophe + 0x00db, kKeyCompose, 0x0055, 0x0053, + 0, // Ucircumflex, U, asciicircum + 0x00dc, kKeyCompose, 0x0055, 0x0022, + 0, // Udiaeresis, U, quotedbl + 0x00d9, kKeyCompose, 0x0055, 0x0060, + 0, // Ugrave, U, grave + 0x00dd, kKeyCompose, 0x0059, 0x0027, + 0, // Yacute, Y, apostrophe + 0x00e1, kKeyCompose, 0x0061, 0x0027, + 0, // aacute, a, apostrophe + 0x00e2, kKeyCompose, 0x0061, 0x0053, + 0, // acircumflex, a, asciicircum 0x00b4, kKeyCompose, 0x0027, 0x0027, 0, // acute, apostrophe, apostrophe - 0x00e4, kKeyCompose, 0x0061, 0x0022, 0, // adiaeresis, a, quotedbl - 0x00e6, kKeyCompose, 0x0061, 0x0065, 0, // ae, a, e - 0x00e0, kKeyCompose, 0x0061, 0x0060, 0, // agrave, a, grave - 0x00e5, kKeyCompose, 0x0061, 0x002a, 0, // aring, a, asterisk - 0x0040, kKeyCompose, 0x0041, 0x0054, 0, // at, A, T - 0x00e3, kKeyCompose, 0x0061, 0x007e, 0, // atilde, a, asciitilde - 0x005c, kKeyCompose, 0x002f, 0x002f, 0, // backslash, slash, slash - 0x007c, kKeyCompose, 0x004c, 0x0056, 0, // bar, L, V - 0x007b, kKeyCompose, 0x0028, 0x002d, 0, // braceleft, parenleft, minus - 0x007d, kKeyCompose, 0x0029, 0x002d, 0, // braceright, parenright, minus + 0x00e4, kKeyCompose, 0x0061, 0x0022, + 0, // adiaeresis, a, quotedbl + 0x00e6, kKeyCompose, 0x0061, 0x0065, + 0, // ae, a, e + 0x00e0, kKeyCompose, 0x0061, 0x0060, + 0, // agrave, a, grave + 0x00e5, kKeyCompose, 0x0061, 0x002a, + 0, // aring, a, asterisk + 0x0040, kKeyCompose, 0x0041, 0x0054, + 0, // at, A, T + 0x00e3, kKeyCompose, 0x0061, 0x007e, + 0, // atilde, a, asciitilde + 0x005c, kKeyCompose, 0x002f, 0x002f, + 0, // backslash, slash, slash + 0x007c, kKeyCompose, 0x004c, 0x0056, + 0, // bar, L, V + 0x007b, kKeyCompose, 0x0028, 0x002d, + 0, // braceleft, parenleft, minus + 0x007d, kKeyCompose, 0x0029, 0x002d, + 0, // braceright, parenright, minus 0x005b, kKeyCompose, 0x0028, 0x0028, 0, // bracketleft, parenleft, parenleft 0x005d, kKeyCompose, 0x0029, 0x0029, 0, // bracketright, parenright, parenright - 0x00a6, kKeyCompose, 0x0042, 0x0056, 0, // brokenbar, B, V - 0x00e7, kKeyCompose, 0x0063, 0x002c, 0, // ccedilla, c, comma - 0x00b8, kKeyCompose, 0x002c, 0x002c, 0, // cedilla, comma, comma - 0x00a2, kKeyCompose, 0x0063, 0x002f, 0, // cent, c, slash - 0x00a9, kKeyCompose, 0x0028, 0x0063, 0, // copyright, parenleft, c - 0x00a4, kKeyCompose, 0x006f, 0x0078, 0, // currency, o, x - 0x00b0, kKeyCompose, 0x0030, 0x0053, 0, // degree, 0, asciicircum + 0x00a6, kKeyCompose, 0x0042, 0x0056, + 0, // brokenbar, B, V + 0x00e7, kKeyCompose, 0x0063, 0x002c, + 0, // ccedilla, c, comma + 0x00b8, kKeyCompose, 0x002c, 0x002c, + 0, // cedilla, comma, comma + 0x00a2, kKeyCompose, 0x0063, 0x002f, + 0, // cent, c, slash + 0x00a9, kKeyCompose, 0x0028, 0x0063, + 0, // copyright, parenleft, c + 0x00a4, kKeyCompose, 0x006f, 0x0078, + 0, // currency, o, x + 0x00b0, kKeyCompose, 0x0030, 0x0053, + 0, // degree, 0, asciicircum 0x00a8, kKeyCompose, 0x0022, 0x0022, 0, // diaeresis, quotedbl, quotedbl - 0x00f7, kKeyCompose, 0x003a, 0x002d, 0, // division, colon, minus - 0x00e9, kKeyCompose, 0x0065, 0x0027, 0, // eacute, e, apostrophe - 0x00ea, kKeyCompose, 0x0065, 0x0053, 0, // ecircumflex, e, asciicircum - 0x00eb, kKeyCompose, 0x0065, 0x0022, 0, // ediaeresis, e, quotedbl - 0x00e8, kKeyCompose, 0x0065, 0x0060, 0, // egrave, e, grave - 0x00f0, kKeyCompose, 0x0064, 0x002d, 0, // eth, d, minus - 0x00a1, kKeyCompose, 0x0021, 0x0021, 0, // exclamdown, exclam, exclam - 0x00ab, kKeyCompose, 0x003c, 0x003c, 0, // guillemotleft, less, less - 0x00bb, kKeyCompose, 0x003e, 0x003e, 0, // guillemotright, greater, greater - 0x0023, kKeyCompose, 0x002b, 0x002b, 0, // numbersign, plus, plus - 0x00ad, kKeyCompose, 0x002d, 0x002d, 0, // hyphen, minus, minus - 0x00ed, kKeyCompose, 0x0069, 0x0027, 0, // iacute, i, apostrophe - 0x00ee, kKeyCompose, 0x0069, 0x0053, 0, // icircumflex, i, asciicircum - 0x00ef, kKeyCompose, 0x0069, 0x0022, 0, // idiaeresis, i, quotedbl - 0x00ec, kKeyCompose, 0x0069, 0x0060, 0, // igrave, i, grave + 0x00f7, kKeyCompose, 0x003a, 0x002d, + 0, // division, colon, minus + 0x00e9, kKeyCompose, 0x0065, 0x0027, + 0, // eacute, e, apostrophe + 0x00ea, kKeyCompose, 0x0065, 0x0053, + 0, // ecircumflex, e, asciicircum + 0x00eb, kKeyCompose, 0x0065, 0x0022, + 0, // ediaeresis, e, quotedbl + 0x00e8, kKeyCompose, 0x0065, 0x0060, + 0, // egrave, e, grave + 0x00f0, kKeyCompose, 0x0064, 0x002d, + 0, // eth, d, minus + 0x00a1, kKeyCompose, 0x0021, 0x0021, + 0, // exclamdown, exclam, exclam + 0x00ab, kKeyCompose, 0x003c, 0x003c, + 0, // guillemotleft, less, less + 0x00bb, kKeyCompose, 0x003e, 0x003e, + 0, // guillemotright, greater, greater + 0x0023, kKeyCompose, 0x002b, 0x002b, + 0, // numbersign, plus, plus + 0x00ad, kKeyCompose, 0x002d, 0x002d, + 0, // hyphen, minus, minus + 0x00ed, kKeyCompose, 0x0069, 0x0027, + 0, // iacute, i, apostrophe + 0x00ee, kKeyCompose, 0x0069, 0x0053, + 0, // icircumflex, i, asciicircum + 0x00ef, kKeyCompose, 0x0069, 0x0022, + 0, // idiaeresis, i, quotedbl + 0x00ec, kKeyCompose, 0x0069, 0x0060, + 0, // igrave, i, grave 0x00af, kKeyCompose, 0x002d, 0x0053, 0, // macron, minus, asciicircum - 0x00ba, kKeyCompose, 0x006f, 0x005f, 0, // masculine, o, underscore - 0x00b5, kKeyCompose, 0x0075, 0x002f, 0, // mu, u, slash - 0x00d7, kKeyCompose, 0x0078, 0x0078, 0, // multiply, x, x - 0x00a0, kKeyCompose, 0x0020, 0x0020, 0, // nobreakspace, space, space - 0x00ac, kKeyCompose, 0x002c, 0x002d, 0, // notsign, comma, minus - 0x00f1, kKeyCompose, 0x006e, 0x007e, 0, // ntilde, n, asciitilde - 0x00f3, kKeyCompose, 0x006f, 0x0027, 0, // oacute, o, apostrophe - 0x00f4, kKeyCompose, 0x006f, 0x0053, 0, // ocircumflex, o, asciicircum - 0x00f6, kKeyCompose, 0x006f, 0x0022, 0, // odiaeresis, o, quotedbl - 0x00f2, kKeyCompose, 0x006f, 0x0060, 0, // ograve, o, grave - 0x00bd, kKeyCompose, 0x0031, 0x0032, 0, // onehalf, 1, 2 - 0x00bc, kKeyCompose, 0x0031, 0x0034, 0, // onequarter, 1, 4 - 0x00b9, kKeyCompose, 0x0031, 0x0053, 0, // onesuperior, 1, asciicircum - 0x00aa, kKeyCompose, 0x0061, 0x005f, 0, // ordfeminine, a, underscore - 0x00f8, kKeyCompose, 0x006f, 0x002f, 0, // oslash, o, slash - 0x00f5, kKeyCompose, 0x006f, 0x007e, 0, // otilde, o, asciitilde - 0x00b6, kKeyCompose, 0x0070, 0x0021, 0, // paragraph, p, exclam - 0x00b7, kKeyCompose, 0x002e, 0x002e, 0, // periodcentered, period, period - 0x00b1, kKeyCompose, 0x002b, 0x002d, 0, // plusminus, plus, minus + 0x00ba, kKeyCompose, 0x006f, 0x005f, + 0, // masculine, o, underscore + 0x00b5, kKeyCompose, 0x0075, 0x002f, + 0, // mu, u, slash + 0x00d7, kKeyCompose, 0x0078, 0x0078, + 0, // multiply, x, x + 0x00a0, kKeyCompose, 0x0020, 0x0020, + 0, // nobreakspace, space, space + 0x00ac, kKeyCompose, 0x002c, 0x002d, + 0, // notsign, comma, minus + 0x00f1, kKeyCompose, 0x006e, 0x007e, + 0, // ntilde, n, asciitilde + 0x00f3, kKeyCompose, 0x006f, 0x0027, + 0, // oacute, o, apostrophe + 0x00f4, kKeyCompose, 0x006f, 0x0053, + 0, // ocircumflex, o, asciicircum + 0x00f6, kKeyCompose, 0x006f, 0x0022, + 0, // odiaeresis, o, quotedbl + 0x00f2, kKeyCompose, 0x006f, 0x0060, + 0, // ograve, o, grave + 0x00bd, kKeyCompose, 0x0031, 0x0032, + 0, // onehalf, 1, 2 + 0x00bc, kKeyCompose, 0x0031, 0x0034, + 0, // onequarter, 1, 4 + 0x00b9, kKeyCompose, 0x0031, 0x0053, + 0, // onesuperior, 1, asciicircum + 0x00aa, kKeyCompose, 0x0061, 0x005f, + 0, // ordfeminine, a, underscore + 0x00f8, kKeyCompose, 0x006f, 0x002f, + 0, // oslash, o, slash + 0x00f5, kKeyCompose, 0x006f, 0x007e, + 0, // otilde, o, asciitilde + 0x00b6, kKeyCompose, 0x0070, 0x0021, + 0, // paragraph, p, exclam + 0x00b7, kKeyCompose, 0x002e, 0x002e, + 0, // periodcentered, period, period + 0x00b1, kKeyCompose, 0x002b, 0x002d, + 0, // plusminus, plus, minus 0x00bf, kKeyCompose, 0x003f, 0x003f, 0, // questiondown, question, question - 0x00ae, kKeyCompose, 0x0028, 0x0072, 0, // registered, parenleft, r - 0x00a7, kKeyCompose, 0x0073, 0x006f, 0, // section, s, o - 0x00df, kKeyCompose, 0x0073, 0x0073, 0, // ssharp, s, s - 0x00a3, kKeyCompose, 0x004c, 0x002d, 0, // sterling, L, minus - 0x00fe, kKeyCompose, 0x0074, 0x0068, 0, // thorn, t, h - 0x00be, kKeyCompose, 0x0033, 0x0034, 0, // threequarters, 3, 4 - 0x00b3, kKeyCompose, 0x0033, 0x0053, 0, // threesuperior, 3, asciicircum - 0x00b2, kKeyCompose, 0x0032, 0x0053, 0, // twosuperior, 2, asciicircum - 0x00fa, kKeyCompose, 0x0075, 0x0027, 0, // uacute, u, apostrophe - 0x00fb, kKeyCompose, 0x0075, 0x0053, 0, // ucircumflex, u, asciicircum - 0x00fc, kKeyCompose, 0x0075, 0x0022, 0, // udiaeresis, u, quotedbl - 0x00f9, kKeyCompose, 0x0075, 0x0060, 0, // ugrave, u, grave - 0x00fd, kKeyCompose, 0x0079, 0x0027, 0, // yacute, y, apostrophe - 0x00ff, kKeyCompose, 0x0079, 0x0022, 0, // ydiaeresis, y, quotedbl - 0x00a5, kKeyCompose, 0x0079, 0x003d, 0, // yen, y, equal + 0x00ae, kKeyCompose, 0x0028, 0x0072, + 0, // registered, parenleft, r + 0x00a7, kKeyCompose, 0x0073, 0x006f, + 0, // section, s, o + 0x00df, kKeyCompose, 0x0073, 0x0073, + 0, // ssharp, s, s + 0x00a3, kKeyCompose, 0x004c, 0x002d, + 0, // sterling, L, minus + 0x00fe, kKeyCompose, 0x0074, 0x0068, + 0, // thorn, t, h + 0x00be, kKeyCompose, 0x0033, 0x0034, + 0, // threequarters, 3, 4 + 0x00b3, kKeyCompose, 0x0033, 0x0053, + 0, // threesuperior, 3, asciicircum + 0x00b2, kKeyCompose, 0x0032, 0x0053, + 0, // twosuperior, 2, asciicircum + 0x00fa, kKeyCompose, 0x0075, 0x0027, + 0, // uacute, u, apostrophe + 0x00fb, kKeyCompose, 0x0075, 0x0053, + 0, // ucircumflex, u, asciicircum + 0x00fc, kKeyCompose, 0x0075, 0x0022, + 0, // udiaeresis, u, quotedbl + 0x00f9, kKeyCompose, 0x0075, 0x0060, + 0, // ugrave, u, grave + 0x00fd, kKeyCompose, 0x0079, 0x0027, + 0, // yacute, y, apostrophe + 0x00ff, kKeyCompose, 0x0079, 0x0022, + 0, // ydiaeresis, y, quotedbl + 0x00a5, kKeyCompose, 0x0079, 0x003d, + 0, // yen, y, equal // end of table 0}; @@ -372,19 +660,27 @@ static const KeyID s_numpadTable[] = { // KeyState // -KeyState::KeyState(IEventQueue *events, std::vector layouts, - bool isLangSyncEnabled) - : IKeyState(events), m_keyMapPtr(new synergy::KeyMap()), - m_keyMap(*m_keyMapPtr), m_mask(0), m_events(events), +KeyState::KeyState( + IEventQueue *events, std::vector layouts, bool isLangSyncEnabled) + : IKeyState(events), + m_keyMapPtr(new synergy::KeyMap()), + m_keyMap(*m_keyMapPtr), + m_mask(0), + m_events(events), m_isLangSyncEnabled(isLangSyncEnabled) { m_keyMap.setLanguageData(std::move(layouts)); init(); } -KeyState::KeyState(IEventQueue *events, synergy::KeyMap &keyMap, - std::vector layouts, bool isLangSyncEnabled) - : IKeyState(events), m_keyMapPtr(0), m_keyMap(keyMap), m_mask(0), - m_events(events), m_isLangSyncEnabled(isLangSyncEnabled) { +KeyState::KeyState( + IEventQueue *events, synergy::KeyMap &keyMap, std::vector layouts, + bool isLangSyncEnabled) + : IKeyState(events), + m_keyMapPtr(0), + m_keyMap(keyMap), + m_mask(0), + m_events(events), + m_isLangSyncEnabled(isLangSyncEnabled) { m_keyMap.setLanguageData(std::move(layouts)); init(); } @@ -422,28 +718,33 @@ void KeyState::onKey(KeyButton button, bool down, KeyModifierMask newState) { } } -void KeyState::sendKeyEvent(void *target, bool press, bool isAutoRepeat, - KeyID key, KeyModifierMask mask, SInt32 count, - KeyButton button) { +void KeyState::sendKeyEvent( + void *target, bool press, bool isAutoRepeat, KeyID key, + KeyModifierMask mask, SInt32 count, KeyButton button) { if (m_keyMap.isHalfDuplex(key, button)) { if (isAutoRepeat) { // ignore auto-repeat on half-duplex keys } else { - m_events->addEvent(Event(m_events->forIKeyState().keyDown(), target, - KeyInfo::alloc(key, mask, button, 1))); - m_events->addEvent(Event(m_events->forIKeyState().keyUp(), target, - KeyInfo::alloc(key, mask, button, 1))); + m_events->addEvent(Event( + m_events->forIKeyState().keyDown(), target, + KeyInfo::alloc(key, mask, button, 1))); + m_events->addEvent(Event( + m_events->forIKeyState().keyUp(), target, + KeyInfo::alloc(key, mask, button, 1))); } } else { if (isAutoRepeat) { - m_events->addEvent(Event(m_events->forIKeyState().keyRepeat(), target, - KeyInfo::alloc(key, mask, button, count))); + m_events->addEvent(Event( + m_events->forIKeyState().keyRepeat(), target, + KeyInfo::alloc(key, mask, button, count))); } else if (press) { - m_events->addEvent(Event(m_events->forIKeyState().keyDown(), target, - KeyInfo::alloc(key, mask, button, 1))); + m_events->addEvent(Event( + m_events->forIKeyState().keyDown(), target, + KeyInfo::alloc(key, mask, button, 1))); } else { - m_events->addEvent(Event(m_events->forIKeyState().keyUp(), target, - KeyInfo::alloc(key, mask, button, 1))); + m_events->addEvent(Event( + m_events->forIKeyState().keyUp(), target, + KeyInfo::alloc(key, mask, button, 1))); } } } @@ -485,16 +786,15 @@ void KeyState::updateKeyState() { m_mask = pollActiveModifiers(); // set active modifiers - AddActiveModifierContext addModifierContext(pollActiveGroup(), m_mask, - m_activeModifiers); + AddActiveModifierContext addModifierContext( + pollActiveGroup(), m_mask, m_activeModifiers); m_keyMap.foreachKey(&KeyState::addActiveModifierCB, &addModifierContext); LOG((CLOG_DEBUG1 "modifiers on update: 0x%04x", m_mask)); } -void KeyState::addActiveModifierCB(KeyID, SInt32 group, - synergy::KeyMap::KeyItem &keyItem, - void *vcontext) { +void KeyState::addActiveModifierCB( + KeyID, SInt32 group, synergy::KeyMap::KeyItem &keyItem, void *vcontext) { AddActiveModifierContext *context = static_cast(vcontext); if (group == context->m_activeGroup && @@ -517,8 +817,8 @@ void KeyState::setHalfDuplexMask(KeyModifierMask mask) { } } -void KeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton serverID, - const String &lang) { +void KeyState::fakeKeyDown( + KeyID id, KeyModifierMask mask, KeyButton serverID, const String &lang) { // if this server key is already down then this is probably a // mis-reported autorepeat. serverID &= kButtonMask; @@ -535,9 +835,9 @@ void KeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton serverID, Keystrokes keys; ModifierToKeys oldActiveModifiers = m_activeModifiers; - const synergy::KeyMap::KeyItem *keyItem = - m_keyMap.mapKey(keys, id, pollActiveGroup(), m_activeModifiers, - getActiveModifiersRValue(), mask, false, lang); + const synergy::KeyMap::KeyItem *keyItem = m_keyMap.mapKey( + keys, id, pollActiveGroup(), m_activeModifiers, + getActiveModifiersRValue(), mask, false, lang); if (keyItem == nullptr) { // a media key won't be mapped on mac, so we need to fake it in a @@ -566,8 +866,9 @@ void KeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton serverID, fakeKeys(keys, 1); } -bool KeyState::fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, - KeyButton serverID, const String &lang) { +bool KeyState::fakeKeyRepeat( + KeyID id, KeyModifierMask mask, SInt32 count, KeyButton serverID, + const String &lang) { LOG((CLOG_DEBUG2 "fakeKeyRepeat")); serverID &= kButtonMask; @@ -580,9 +881,9 @@ bool KeyState::fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, // get keys for key repeat Keystrokes keys; ModifierToKeys oldActiveModifiers = m_activeModifiers; - const synergy::KeyMap::KeyItem *keyItem = - m_keyMap.mapKey(keys, id, pollActiveGroup(), m_activeModifiers, - getActiveModifiersRValue(), mask, true, lang); + const synergy::KeyMap::KeyItem *keyItem = m_keyMap.mapKey( + keys, id, pollActiveGroup(), m_activeModifiers, + getActiveModifiersRValue(), mask, true, lang); if (keyItem == NULL) { return false; } @@ -724,13 +1025,15 @@ void KeyState::addAliasEntries() { // if we can't shift any kKeyTab key in a particular group but we can // shift kKeyLeftTab then add a shifted kKeyTab entry that matches a // shifted kKeyLeftTab entry. - m_keyMap.addKeyAliasEntry(kKeyTab, g, KeyModifierShift, KeyModifierShift, - kKeyLeftTab, KeyModifierShift, KeyModifierShift); + m_keyMap.addKeyAliasEntry( + kKeyTab, g, KeyModifierShift, KeyModifierShift, kKeyLeftTab, + KeyModifierShift, KeyModifierShift); // if we have no kKeyLeftTab but we do have a kKeyTab that can be // shifted then add kKeyLeftTab that matches a kKeyTab. - m_keyMap.addKeyAliasEntry(kKeyLeftTab, g, KeyModifierShift, - KeyModifierShift, kKeyTab, 0, KeyModifierShift); + m_keyMap.addKeyAliasEntry( + kKeyLeftTab, g, KeyModifierShift, KeyModifierShift, kKeyTab, 0, + KeyModifierShift); // map non-breaking space to space m_keyMap.addKeyAliasEntry(0x20, g, 0, 0, 0xa0, 0, 0); @@ -743,8 +1046,8 @@ void KeyState::addKeypadEntries() { for (SInt32 g = 0, n = m_keyMap.getNumGroups(); g < n; ++g) { for (size_t i = 0; i < sizeof(s_numpadTable) / sizeof(s_numpadTable[0]); i += 2) { - m_keyMap.addKeyCombinationEntry(s_numpadTable[i], g, - s_numpadTable + i + 1, 1); + m_keyMap.addKeyCombinationEntry( + s_numpadTable[i], g, s_numpadTable + i + 1, 1); } } } @@ -795,8 +1098,9 @@ void KeyState::fakeKeys(const Keystrokes &keys, UInt32 count) { // note -- k is now on the first non-repeat key after the // repeat keys, exactly where we'd like to continue from. - } else if (k->m_type != Keystroke::kGroup || - (!k->m_data.m_group.m_restore && m_isLangSyncEnabled)) { + } else if ( + k->m_type != Keystroke::kGroup || + (!k->m_data.m_group.m_restore && m_isLangSyncEnabled)) { // send event fakeKey(*k); @@ -809,9 +1113,9 @@ void KeyState::fakeKeys(const Keystrokes &keys, UInt32 count) { } } -void KeyState::updateModifierKeyState(KeyButton button, - const ModifierToKeys &oldModifiers, - const ModifierToKeys &newModifiers) { +void KeyState::updateModifierKeyState( + KeyButton button, const ModifierToKeys &oldModifiers, + const ModifierToKeys &newModifiers) { // get the pressed modifier buttons before and after synergy::KeyMap::ButtonToKeyMap oldKeys, newKeys; for (ModifierToKeys::const_iterator i = oldModifiers.begin(); @@ -825,12 +1129,12 @@ void KeyState::updateModifierKeyState(KeyButton button, // get the modifier buttons that were pressed or released synergy::KeyMap::ButtonToKeyMap pressed, released; - std::set_difference(oldKeys.begin(), oldKeys.end(), newKeys.begin(), - newKeys.end(), std::inserter(released, released.end()), - ButtonToKeyLess()); - std::set_difference(newKeys.begin(), newKeys.end(), oldKeys.begin(), - oldKeys.end(), std::inserter(pressed, pressed.end()), - ButtonToKeyLess()); + std::set_difference( + oldKeys.begin(), oldKeys.end(), newKeys.begin(), newKeys.end(), + std::inserter(released, released.end()), ButtonToKeyLess()); + std::set_difference( + newKeys.begin(), newKeys.end(), oldKeys.begin(), oldKeys.end(), + std::inserter(pressed, pressed.end()), ButtonToKeyLess()); // update state for (synergy::KeyMap::ButtonToKeyMap::const_iterator i = released.begin(); @@ -856,6 +1160,8 @@ void KeyState::updateModifierKeyState(KeyButton button, KeyState::AddActiveModifierContext::AddActiveModifierContext( SInt32 group, KeyModifierMask mask, ModifierToKeys &activeModifiers) - : m_activeGroup(group), m_mask(mask), m_activeModifiers(activeModifiers) { + : m_activeGroup(group), + m_mask(mask), + m_activeModifiers(activeModifiers) { // do nothing } diff --git a/src/lib/synergy/KeyState.h b/src/lib/synergy/KeyState.h index dfb7b3226..e693bfa59 100644 --- a/src/lib/synergy/KeyState.h +++ b/src/lib/synergy/KeyState.h @@ -28,10 +28,11 @@ platform specific methods. */ class KeyState : public IKeyState { public: - KeyState(IEventQueue *events, std::vector layouts, - bool isLangSyncEnabled); - KeyState(IEventQueue *events, synergy::KeyMap &keyMap, - std::vector layouts, bool isLangSyncEnabled); + KeyState( + IEventQueue *events, std::vector layouts, bool isLangSyncEnabled); + KeyState( + IEventQueue *events, synergy::KeyMap &keyMap, std::vector layouts, + bool isLangSyncEnabled); virtual ~KeyState(); //! @name manipulators @@ -52,9 +53,9 @@ public: events in some circumstances. If this is overridden it must forward to the superclass. */ - virtual void sendKeyEvent(void *target, bool press, bool isAutoRepeat, - KeyID key, KeyModifierMask mask, SInt32 count, - KeyButton button); + virtual void sendKeyEvent( + void *target, bool press, bool isAutoRepeat, KeyID key, + KeyModifierMask mask, SInt32 count, KeyButton button); //@} //! @name accessors @@ -67,10 +68,12 @@ public: void updateKeyMap() override { this->updateKeyMap(nullptr); } void updateKeyState() override; void setHalfDuplexMask(KeyModifierMask) override; - void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, - const String &lang) override; - bool fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, - KeyButton button, const String &lang) override; + void fakeKeyDown( + KeyID id, KeyModifierMask mask, KeyButton button, + const String &lang) override; + bool fakeKeyRepeat( + KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, + const String &lang) override; bool fakeKeyUp(KeyButton button) override; void fakeAllKeysUp() override; bool fakeMediaKey(KeyID id) override; @@ -143,8 +146,8 @@ private: public: struct AddActiveModifierContext { public: - AddActiveModifierContext(SInt32 group, KeyModifierMask mask, - ModifierToKeys &activeModifiers); + AddActiveModifierContext( + SInt32 group, KeyModifierMask mask, ModifierToKeys &activeModifiers); public: SInt32 m_activeGroup; @@ -160,8 +163,9 @@ public: private: class ButtonToKeyLess { public: - bool operator()(const synergy::KeyMap::ButtonToKeyMap::value_type &a, - const synergy::KeyMap::ButtonToKeyMap::value_type b) const { + bool operator()( + const synergy::KeyMap::ButtonToKeyMap::value_type &a, + const synergy::KeyMap::ButtonToKeyMap::value_type b) const { return (a.first < b.first); } }; @@ -188,14 +192,14 @@ private: void fakeKeys(const Keystrokes &, UInt32 count); // update key state to match changes to modifiers - void updateModifierKeyState(KeyButton button, - const ModifierToKeys &oldModifiers, - const ModifierToKeys &newModifiers); + void updateModifierKeyState( + KeyButton button, const ModifierToKeys &oldModifiers, + const ModifierToKeys &newModifiers); // active modifiers collection callback - static void addActiveModifierCB(KeyID id, SInt32 group, - synergy::KeyMap::KeyItem &keyItem, - void *vcontext); + static void addActiveModifierCB( + KeyID id, SInt32 group, synergy::KeyMap::KeyItem &keyItem, + void *vcontext); private: // must be declared before m_keyMap. used when this class owns the key map. diff --git a/src/lib/synergy/PacketStreamFilter.cpp b/src/lib/synergy/PacketStreamFilter.cpp index c71920a87..73909cee1 100644 --- a/src/lib/synergy/PacketStreamFilter.cpp +++ b/src/lib/synergy/PacketStreamFilter.cpp @@ -28,11 +28,12 @@ // PacketStreamFilter // -PacketStreamFilter::PacketStreamFilter(IEventQueue *events, - synergy::IStream *stream, - bool adoptStream) - : StreamFilter(events, stream, adoptStream), m_size(0), - m_inputShutdown(false), m_events(events) { +PacketStreamFilter::PacketStreamFilter( + IEventQueue *events, synergy::IStream *stream, bool adoptStream) + : StreamFilter(events, stream, adoptStream), + m_size(0), + m_inputShutdown(false), + m_events(events) { // do nothing } diff --git a/src/lib/synergy/PacketStreamFilter.h b/src/lib/synergy/PacketStreamFilter.h index c90bc98c8..bf307e83a 100644 --- a/src/lib/synergy/PacketStreamFilter.h +++ b/src/lib/synergy/PacketStreamFilter.h @@ -30,8 +30,8 @@ Filters a stream to read and write packets. */ class PacketStreamFilter : public StreamFilter { public: - PacketStreamFilter(IEventQueue *events, synergy::IStream *stream, - bool adoptStream = true); + PacketStreamFilter( + IEventQueue *events, synergy::IStream *stream, bool adoptStream = true); ~PacketStreamFilter(); // IStream overrides diff --git a/src/lib/synergy/PlatformScreen.cpp b/src/lib/synergy/PlatformScreen.cpp index 0aca14a29..dcc1e5730 100644 --- a/src/lib/synergy/PlatformScreen.cpp +++ b/src/lib/synergy/PlatformScreen.cpp @@ -22,8 +22,10 @@ PlatformScreen::PlatformScreen( IEventQueue *events, lib::synergy::ClientScrollDirection scrollDirection) - : IPlatformScreen(events), m_draggingStarted(false), - m_fakeDraggingStarted(false), m_clientScrollDirection(scrollDirection) {} + : IPlatformScreen(events), + m_draggingStarted(false), + m_fakeDraggingStarted(false), + m_clientScrollDirection(scrollDirection) {} PlatformScreen::~PlatformScreen() { // do nothing @@ -40,13 +42,14 @@ void PlatformScreen::setHalfDuplexMask(KeyModifierMask mask) { getKeyState()->setHalfDuplexMask(mask); } -void PlatformScreen::fakeKeyDown(KeyID id, KeyModifierMask mask, - KeyButton button, const String &lang) { +void PlatformScreen::fakeKeyDown( + KeyID id, KeyModifierMask mask, KeyButton button, const String &lang) { getKeyState()->fakeKeyDown(id, mask, button, lang); } -bool PlatformScreen::fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, - KeyButton button, const String &lang) { +bool PlatformScreen::fakeKeyRepeat( + KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, + const String &lang) { return getKeyState()->fakeKeyRepeat(id, mask, count, button, lang); } diff --git a/src/lib/synergy/PlatformScreen.h b/src/lib/synergy/PlatformScreen.h index 724a420ec..b2abf6006 100644 --- a/src/lib/synergy/PlatformScreen.h +++ b/src/lib/synergy/PlatformScreen.h @@ -31,16 +31,16 @@ subclasses to implement the rest. */ class PlatformScreen : public IPlatformScreen { public: - PlatformScreen(IEventQueue *events, - lib::synergy::ClientScrollDirection scrollDirection = - lib::synergy::ClientScrollDirection::SERVER); + PlatformScreen( + IEventQueue *events, lib::synergy::ClientScrollDirection scrollDirection = + lib::synergy::ClientScrollDirection::SERVER); virtual ~PlatformScreen(); // IScreen overrides 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 + getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const = 0; virtual void getCursorPos(SInt32 &x, SInt32 &y) const = 0; // IPrimaryScreen overrides @@ -64,10 +64,11 @@ public: virtual void updateKeyMap(); virtual void updateKeyState(); virtual void setHalfDuplexMask(KeyModifierMask); - virtual void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, - const String &); - virtual bool fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, - KeyButton button, const String &lang); + virtual void + fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const String &); + virtual bool fakeKeyRepeat( + KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, + const String &lang); virtual bool fakeKeyUp(KeyButton button); virtual void fakeAllKeysUp(); virtual bool fakeCtrlAltDel(); diff --git a/src/lib/synergy/ProtocolUtil.cpp b/src/lib/synergy/ProtocolUtil.cpp index a81406c35..2147a391a 100644 --- a/src/lib/synergy/ProtocolUtil.cpp +++ b/src/lib/synergy/ProtocolUtil.cpp @@ -54,8 +54,8 @@ void writeInt(UInt32 Value, UInt32 Length, std::vector &Buffer) { } template -void writeVectorInt(const std::vector *VectorData, - std::vector &Buffer) { +void writeVectorInt( + const std::vector *VectorData, std::vector &Buffer) { if (VectorData) { const std::vector &Vector = *VectorData; writeInt((UInt32)Vector.size(), sizeof(UInt32), Buffer); @@ -69,8 +69,8 @@ void writeString(const String *StringData, std::vector &Buffer) { const UInt32 len = (StringData != NULL) ? (UInt32)StringData->size() : 0; writeInt(len, sizeof(len), Buffer); if (len != 0) { - std::copy(StringData->begin(), StringData->end(), - std::back_inserter(Buffer)); + std::copy( + StringData->begin(), StringData->end(), std::back_inserter(Buffer)); } } @@ -111,8 +111,8 @@ bool ProtocolUtil::readf(synergy::IStream *stream, const char *fmt, ...) { return result; } -void ProtocolUtil::vwritef(synergy::IStream *stream, const char *fmt, - UInt32 size, va_list args) { +void ProtocolUtil::vwritef( + synergy::IStream *stream, const char *fmt, UInt32 size, va_list args) { assert(stream != NULL); assert(fmt != NULL); @@ -130,14 +130,15 @@ void ProtocolUtil::vwritef(synergy::IStream *stream, const char *fmt, stream->write(Buffer.data(), size); LOG((CLOG_DEBUG2 "wrote %d bytes", size)); } catch (const XBase &exception) { - LOG((CLOG_DEBUG2 "exception <%s> during wrote %d bytes into stream", + LOG( + (CLOG_DEBUG2 "exception <%s> during wrote %d bytes into stream", exception.what(), size)); throw; } } -void ProtocolUtil::vreadf(synergy::IStream *stream, const char *fmt, - va_list args) { +void ProtocolUtil::vreadf( + synergy::IStream *stream, const char *fmt, va_list args) { assert(stream != NULL); assert(fmt != NULL); @@ -165,7 +166,8 @@ void ProtocolUtil::vreadf(synergy::IStream *stream, const char *fmt, break; default: // the length is wrong - LOG((CLOG_ERR + LOG( + (CLOG_ERR "read: length to be read is wrong: '%d' should be 1,2, or 4", len)); assert(false); // assert for debugging @@ -179,22 +181,23 @@ void ProtocolUtil::vreadf(synergy::IStream *stream, const char *fmt, switch (len) { case 1: // 1 byte integer - readVector1ByteInt(stream, - *static_cast *>(destination)); + readVector1ByteInt( + stream, *static_cast *>(destination)); break; case 2: // 2 byte integer - readVector2BytesInt(stream, - *static_cast *>(destination)); + readVector2BytesInt( + stream, *static_cast *>(destination)); break; case 4: // 4 byte integer - readVector4BytesInt(stream, - *static_cast *>(destination)); + readVector4BytesInt( + stream, *static_cast *>(destination)); break; default: // the length is wrong - LOG((CLOG_ERR + LOG( + (CLOG_ERR "read: length to be read is wrong: '%d' should be 1,2, or 4", len)); assert(false); // assert for debugging @@ -297,8 +300,8 @@ UInt32 ProtocolUtil::getLength(const char *fmt, va_list args) { return n; } -void ProtocolUtil::writef(std::vector &buffer, const char *fmt, - va_list args) { +void ProtocolUtil::writef( + std::vector &buffer, const char *fmt, va_list args) { while (*fmt) { if (*fmt == '%') { // format specifier. determine argument size. @@ -434,7 +437,8 @@ void ProtocolUtil::read(synergy::IStream *stream, void *vbuffer, UInt32 count) { // bail if stream has hungup if (n == 0) { - LOG((CLOG_DEBUG2 "unexpected disconnect in readf(), %d bytes left", + LOG( + (CLOG_DEBUG2 "unexpected disconnect in readf(), %d bytes left", count)); throw XIOEndOfStream(); } @@ -461,8 +465,8 @@ UInt16 ProtocolUtil::read2BytesInt(synergy::IStream *stream) { std::array buffer = {}; read(stream, buffer.data(), BufferSize); - UInt16 Result = static_cast((static_cast(buffer[0]) << 8) | - static_cast(buffer[1])); + UInt16 Result = static_cast( + (static_cast(buffer[0]) << 8) | static_cast(buffer[1])); LOG((CLOG_DEBUG2 "readf: read 2 byte integer: %d (0x%x)", Result, Result)); return Result; @@ -483,32 +487,32 @@ UInt32 ProtocolUtil::read4BytesInt(synergy::IStream *stream) { return Result; } -void ProtocolUtil::readVector1ByteInt(synergy::IStream *stream, - std::vector &destination) { +void ProtocolUtil::readVector1ByteInt( + synergy::IStream *stream, std::vector &destination) { UInt32 size = read4BytesInt(stream); for (UInt32 i = 0; i < size; ++i) { destination.push_back(read1ByteInt(stream)); } } -void ProtocolUtil::readVector2BytesInt(synergy::IStream *stream, - std::vector &destination) { +void ProtocolUtil::readVector2BytesInt( + synergy::IStream *stream, std::vector &destination) { UInt32 size = read4BytesInt(stream); for (UInt32 i = 0; i < size; ++i) { destination.push_back(read2BytesInt(stream)); } } -void ProtocolUtil::readVector4BytesInt(synergy::IStream *stream, - std::vector &destination) { +void ProtocolUtil::readVector4BytesInt( + synergy::IStream *stream, std::vector &destination) { UInt32 size = read4BytesInt(stream); for (UInt32 i = 0; i < size; ++i) { destination.push_back(read4BytesInt(stream)); } } -void ProtocolUtil::readBytes(synergy::IStream *stream, UInt32 len, - String *destination) { +void ProtocolUtil::readBytes( + synergy::IStream *stream, UInt32 len, String *destination) { assert(len == 0); // read the string length diff --git a/src/lib/synergy/ProtocolUtil.h b/src/lib/synergy/ProtocolUtil.h index 95dbcc265..d81dbc3a0 100644 --- a/src/lib/synergy/ProtocolUtil.h +++ b/src/lib/synergy/ProtocolUtil.h @@ -73,8 +73,8 @@ public: static bool readf(synergy::IStream *, const char *fmt, ...); private: - static void vwritef(synergy::IStream *, const char *fmt, UInt32 size, - va_list); + static void + vwritef(synergy::IStream *, const char *fmt, UInt32 size, va_list); static void vreadf(synergy::IStream *, const char *fmt, va_list); static UInt32 getLength(const char *fmt, va_list); diff --git a/src/lib/synergy/Screen.cpp b/src/lib/synergy/Screen.cpp index 7fe21ef34..af9869350 100644 --- a/src/lib/synergy/Screen.cpp +++ b/src/lib/synergy/Screen.cpp @@ -31,9 +31,14 @@ namespace synergy { // Screen::Screen(IPlatformScreen *platformScreen, IEventQueue *events) - : m_screen(platformScreen), m_isPrimary(platformScreen->isPrimary()), - m_enabled(false), m_entered(m_isPrimary), m_fakeInput(false), - m_events(events), m_mock(false), m_enableDragDrop(false) { + : m_screen(platformScreen), + m_isPrimary(platformScreen->isPrimary()), + m_enabled(false), + m_entered(m_isPrimary), + m_fakeInput(false), + m_events(events), + m_mock(false), + m_enableDragDrop(false) { assert(m_screen != NULL); // reset options @@ -148,8 +153,8 @@ void Screen::screensaver(bool) const { // do nothing } -void Screen::keyDown(KeyID id, KeyModifierMask mask, KeyButton button, - const String &lang) { +void Screen::keyDown( + KeyID id, KeyModifierMask mask, KeyButton button, const String &lang) { // check for ctrl+alt+del emulation if (id == kKeyDelete && (mask & (KeyModifierControl | KeyModifierAlt)) == (KeyModifierControl | KeyModifierAlt)) { @@ -161,8 +166,9 @@ void Screen::keyDown(KeyID id, KeyModifierMask mask, KeyButton button, m_screen->fakeKeyDown(id, mask, button, lang); } -void Screen::keyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, - KeyButton button, const String &lang) { +void Screen::keyRepeat( + KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, + const String &lang) { assert(!m_isPrimary); m_screen->fakeKeyRepeat(id, mask, count, button, lang); } @@ -211,7 +217,8 @@ void Screen::setOptions(const OptionsList &options) { } else { m_halfDuplex &= ~KeyModifierCapsLock; } - LOG((CLOG_DEBUG1 "half-duplex caps-lock %s", + LOG( + (CLOG_DEBUG1 "half-duplex caps-lock %s", ((m_halfDuplex & KeyModifierCapsLock) != 0) ? "on" : "off")); } else if (options[i] == kOptionHalfDuplexNumLock) { if (options[i + 1] != 0) { @@ -219,7 +226,8 @@ void Screen::setOptions(const OptionsList &options) { } else { m_halfDuplex &= ~KeyModifierNumLock; } - LOG((CLOG_DEBUG1 "half-duplex num-lock %s", + LOG( + (CLOG_DEBUG1 "half-duplex num-lock %s", ((m_halfDuplex & KeyModifierNumLock) != 0) ? "on" : "off")); } else if (options[i] == kOptionHalfDuplexScrollLock) { if (options[i + 1] != 0) { @@ -227,7 +235,8 @@ void Screen::setOptions(const OptionsList &options) { } else { m_halfDuplex &= ~KeyModifierScrollLock; } - LOG((CLOG_DEBUG1 "half-duplex scroll-lock %s", + LOG( + (CLOG_DEBUG1 "half-duplex scroll-lock %s", ((m_halfDuplex & KeyModifierScrollLock) != 0) ? "on" : "off")); } } diff --git a/src/lib/synergy/Screen.h b/src/lib/synergy/Screen.h index 31b51c971..7c29c94eb 100644 --- a/src/lib/synergy/Screen.h +++ b/src/lib/synergy/Screen.h @@ -134,8 +134,8 @@ public: Synthesize key events to generate a press and release of key \c id \c count times. If possible match the given modifier mask. */ - void keyRepeat(KeyID id, KeyModifierMask, SInt32 count, KeyButton, - const String &lang); + void keyRepeat( + KeyID id, KeyModifierMask, SInt32 count, KeyButton, const String &lang); //! Notify of key release /*! @@ -309,8 +309,8 @@ public: // 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 + getShape(SInt32 &x, SInt32 &y, SInt32 &width, SInt32 &height) const; virtual void getCursorPos(SInt32 &x, SInt32 &y) const; IPlatformScreen *getPlatformScreen() { return m_screen; } diff --git a/src/lib/synergy/ServerApp.cpp b/src/lib/synergy/ServerApp.cpp index 0e38702e8..8c4e3f455 100644 --- a/src/lib/synergy/ServerApp.cpp +++ b/src/lib/synergy/ServerApp.cpp @@ -66,11 +66,15 @@ // ServerApp // -ServerApp::ServerApp(IEventQueue *events, - CreateTaskBarReceiverFunc createTaskBarReceiver) +ServerApp::ServerApp( + IEventQueue *events, CreateTaskBarReceiverFunc createTaskBarReceiver) : App(events, createTaskBarReceiver, new lib::synergy::ServerArgs()), - m_server(NULL), m_serverState(kUninitialized), m_serverScreen(NULL), - m_primaryClient(NULL), m_listener(NULL), m_timer(NULL), + m_server(NULL), + m_serverState(kUninitialized), + m_serverScreen(NULL), + m_primaryClient(NULL), + m_listener(NULL), + m_timer(NULL), m_synergyAddress(NULL) {} ServerApp::~ServerApp() {} @@ -216,7 +220,8 @@ bool ServerApp::loadConfig(const String &pathname) { return true; } catch (XConfigRead &e) { // report error in configuration file - LOG((CLOG_ERR "cannot read configuration \"%s\": %s", pathname.c_str(), + LOG( + (CLOG_ERR "cannot read configuration \"%s\": %s", pathname.c_str(), e.what())); } return false; @@ -252,12 +257,14 @@ void ServerApp::closeServer(Server *server) { // wait for clients to disconnect for up to timeout seconds double timeout = 3.0; EventQueueTimer *timer = m_events->newOneShotTimer(timeout, NULL); - m_events->adoptHandler(Event::kTimer, timer, - new TMethodEventJob( - this, &ServerApp::handleClientsDisconnected)); - m_events->adoptHandler(m_events->forServer().disconnected(), server, - new TMethodEventJob( - this, &ServerApp::handleClientsDisconnected)); + m_events->adoptHandler( + Event::kTimer, timer, + new TMethodEventJob( + this, &ServerApp::handleClientsDisconnected)); + m_events->adoptHandler( + m_events->forServer().disconnected(), server, + new TMethodEventJob( + this, &ServerApp::handleClientsDisconnected)); m_events->loop(); @@ -313,12 +320,12 @@ void ServerApp::closePrimaryClient(PrimaryClient *primaryClient) { void ServerApp::closeServerScreen(synergy::Screen *screen) { if (screen != NULL) { - m_events->removeHandler(m_events->forIScreen().error(), - screen->getEventTarget()); - m_events->removeHandler(m_events->forIScreen().suspend(), - screen->getEventTarget()); - m_events->removeHandler(m_events->forIScreen().resume(), - screen->getEventTarget()); + m_events->removeHandler( + m_events->forIScreen().error(), screen->getEventTarget()); + m_events->removeHandler( + m_events->forIScreen().suspend(), screen->getEventTarget()); + m_events->removeHandler( + m_events->forIScreen().resume(), screen->getEventTarget()); delete screen; } } @@ -331,8 +338,8 @@ void ServerApp::cleanupServer() { m_primaryClient = NULL; m_serverScreen = NULL; m_serverState = kUninitialized; - } else if (m_serverState == kInitializing || - m_serverState == kInitializingToStart) { + } else if ( + m_serverState == kInitializing || m_serverState == kInitializingToStart) { stopRetryTimer(); m_serverState = kUninitialized; } @@ -516,22 +523,22 @@ bool ServerApp::startServer() { synergy::Screen *ServerApp::createScreen() { #if WINAPI_MSWINDOWS - return new synergy::Screen(new MSWindowsScreen(true, args().m_noHooks, - args().m_stopOnDeskSwitch, - m_events), - m_events); + return new synergy::Screen( + new MSWindowsScreen( + true, args().m_noHooks, args().m_stopOnDeskSwitch, m_events), + m_events); #elif WINAPI_XWINDOWS - return new synergy::Screen(new XWindowsScreen(args().m_display, true, - args().m_disableXInitThreads, 0, - m_events), - m_events); + return new synergy::Screen( + new XWindowsScreen( + args().m_display, true, args().m_disableXInitThreads, 0, m_events), + m_events); #elif WINAPI_CARBON return new synergy::Screen(new OSXScreen(m_events, true), m_events); #endif } -PrimaryClient *ServerApp::openPrimaryClient(const String &name, - synergy::Screen *screen) { +PrimaryClient * +ServerApp::openPrimaryClient(const String &name, synergy::Screen *screen) { LOG((CLOG_DEBUG1 "creating primary screen")); return new PrimaryClient(name, screen); } @@ -561,9 +568,10 @@ ClientListener *ServerApp::openClientListener(const NetworkAddress &address) { ClientListener *listen = new ClientListener( getAddress(address), getSocketFactory(), m_events, args().m_enableCrypto); - m_events->adoptHandler(m_events->forClientListener().connected(), listen, - new TMethodEventJob( - this, &ServerApp::handleClientConnected, listen)); + m_events->adoptHandler( + m_events->forClientListener().connected(), listen, + new TMethodEventJob( + this, &ServerApp::handleClientConnected, listen)); return listen; } @@ -694,10 +702,10 @@ int ServerApp::mainLoop() { // close down LOG((CLOG_DEBUG1 "stopping server")); - m_events->removeHandler(m_events->forServerApp().forceReconnect(), - m_events->getSystemTarget()); - m_events->removeHandler(m_events->forServerApp().reloadConfig(), - m_events->getSystemTarget()); + m_events->removeHandler( + m_events->forServerApp().forceReconnect(), m_events->getSystemTarget()); + m_events->removeHandler( + m_events->forServerApp().reloadConfig(), m_events->getSystemTarget()); cleanupServer(); updateStatus(); LOG((CLOG_NOTE "stopped server")); @@ -716,8 +724,8 @@ void ServerApp::resetServer(const Event &, void *) { startServer(); } -int ServerApp::runInner(int argc, char **argv, ILogOutputter *outputter, - StartupFunc startup) { +int ServerApp::runInner( + int argc, char **argv, ILogOutputter *outputter, StartupFunc startup) { // general initialization m_synergyAddress = new NetworkAddress; args().m_config = std::make_shared(m_events); diff --git a/src/lib/synergy/ServerApp.h b/src/lib/synergy/ServerApp.h index 5db675fcf..8162610bb 100644 --- a/src/lib/synergy/ServerApp.h +++ b/src/lib/synergy/ServerApp.h @@ -55,8 +55,8 @@ class ServerArgs; class ServerApp : public App { public: - ServerApp(IEventQueue *events, - CreateTaskBarReceiverFunc createTaskBarReceiver); + ServerApp( + IEventQueue *events, CreateTaskBarReceiverFunc createTaskBarReceiver); virtual ~ServerApp(); // Parse server specific command line arguments. @@ -105,8 +105,8 @@ public: void handleNoClients(const Event &, void *); bool startServer(); int mainLoop(); - int runInner(int argc, char **argv, ILogOutputter *outputter, - StartupFunc startup); + int runInner( + int argc, char **argv, ILogOutputter *outputter, StartupFunc startup); int standardStartup(int argc, char **argv); int foregroundStartup(int argc, char **argv); void startNode(); diff --git a/src/lib/synergy/ServerTaskBarReceiver.cpp b/src/lib/synergy/ServerTaskBarReceiver.cpp index 884fb7e6d..a2f366183 100644 --- a/src/lib/synergy/ServerTaskBarReceiver.cpp +++ b/src/lib/synergy/ServerTaskBarReceiver.cpp @@ -29,7 +29,8 @@ // ServerTaskBarReceiver::ServerTaskBarReceiver(IEventQueue *events) - : m_state(kNotRunning), m_events(events) { + : m_state(kNotRunning), + m_events(events) { // do nothing } @@ -37,8 +38,8 @@ ServerTaskBarReceiver::~ServerTaskBarReceiver() { // do nothing } -void ServerTaskBarReceiver::updateStatus(Server *server, - const String &errorMsg) { +void ServerTaskBarReceiver::updateStatus( + Server *server, const String &errorMsg) { { // update our status m_errorMessage = errorMsg; @@ -99,8 +100,8 @@ std::string ServerTaskBarReceiver::getToolTip() const { return synergy::string::sprintf("%s: Not running", kAppVersion); case kNotWorking: - return synergy::string::sprintf("%s: %s", kAppVersion, - m_errorMessage.c_str()); + return synergy::string::sprintf( + "%s: %s", kAppVersion, m_errorMessage.c_str()); case kNotConnected: return synergy::string::sprintf("%s: Waiting for clients", kAppVersion); diff --git a/src/lib/synergy/ServerTaskBarReceiver.h b/src/lib/synergy/ServerTaskBarReceiver.h index 0db53efe2..ba009a86d 100644 --- a/src/lib/synergy/ServerTaskBarReceiver.h +++ b/src/lib/synergy/ServerTaskBarReceiver.h @@ -97,6 +97,5 @@ private: IEventQueue *m_events; }; -IArchTaskBarReceiver * -createTaskBarReceiver(const BufferedLogOutputter *logBuffer, - IEventQueue *events); +IArchTaskBarReceiver *createTaskBarReceiver( + const BufferedLogOutputter *logBuffer, IEventQueue *events); diff --git a/src/lib/synergy/StreamChunker.cpp b/src/lib/synergy/StreamChunker.cpp index 52c313a3a..eae8d7cab 100644 --- a/src/lib/synergy/StreamChunker.cpp +++ b/src/lib/synergy/StreamChunker.cpp @@ -40,12 +40,12 @@ bool StreamChunker::s_isChunkingFile = false; bool StreamChunker::s_interruptFile = false; Mutex *StreamChunker::s_interruptMutex = NULL; -void StreamChunker::sendFile(char *filename, IEventQueue *events, - void *eventTarget) { +void StreamChunker::sendFile( + char *filename, IEventQueue *events, void *eventTarget) { s_isChunkingFile = true; - std::fstream file(static_cast(filename), - std::ios::in | std::ios::binary); + std::fstream file( + static_cast(filename), std::ios::in | std::ios::binary); if (!file.is_open()) { throw runtime_error("failed to open file"); @@ -109,15 +109,15 @@ void StreamChunker::sendFile(char *filename, IEventQueue *events, s_isChunkingFile = false; } -void StreamChunker::sendClipboard(String &data, size_t size, ClipboardID id, - UInt32 sequence, IEventQueue *events, - void *eventTarget) { +void StreamChunker::sendClipboard( + String &data, size_t size, ClipboardID id, UInt32 sequence, + IEventQueue *events, void *eventTarget) { // send first message (data size) String dataSize = synergy::string::sizeTypeToString(size); ClipboardChunk *sizeMessage = ClipboardChunk::start(id, sequence, dataSize); - events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, - sizeMessage)); + events->addEvent(Event( + events->forClipboard().clipboardSending(), eventTarget, sizeMessage)); // send clipboard chunk with a fixed size size_t sentLength = 0; @@ -134,8 +134,8 @@ void StreamChunker::sendClipboard(String &data, size_t size, ClipboardID id, String chunk(data.substr(sentLength, chunkSize).c_str(), chunkSize); ClipboardChunk *dataChunk = ClipboardChunk::data(id, sequence, chunk); - events->addEvent(Event(events->forClipboard().clipboardSending(), - eventTarget, dataChunk)); + events->addEvent(Event( + events->forClipboard().clipboardSending(), eventTarget, dataChunk)); sentLength += chunkSize; if (sentLength == size) { diff --git a/src/lib/synergy/StreamChunker.h b/src/lib/synergy/StreamChunker.h index 5160842b8..e9615ed5c 100644 --- a/src/lib/synergy/StreamChunker.h +++ b/src/lib/synergy/StreamChunker.h @@ -26,9 +26,9 @@ class Mutex; class StreamChunker { public: static void sendFile(char *filename, IEventQueue *events, void *eventTarget); - static void sendClipboard(String &data, size_t size, ClipboardID id, - UInt32 sequence, IEventQueue *events, - void *eventTarget); + static void sendClipboard( + String &data, size_t size, ClipboardID id, UInt32 sequence, + IEventQueue *events, void *eventTarget); static void interruptFile(); private: diff --git a/src/lib/synergy/ToolArgs.cpp b/src/lib/synergy/ToolArgs.cpp index 48ae3071d..70a8f50b8 100644 --- a/src/lib/synergy/ToolArgs.cpp +++ b/src/lib/synergy/ToolArgs.cpp @@ -18,5 +18,7 @@ #include "synergy/ToolArgs.h" ToolArgs::ToolArgs() - : m_printActiveDesktopName(false), m_getInstalledDir(false), - m_getProfileDir(false), m_getArch(false) {} + : m_printActiveDesktopName(false), + m_getInstalledDir(false), + m_getProfileDir(false), + m_getArch(false) {} diff --git a/src/lib/synergy/XSynergy.cpp b/src/lib/synergy/XSynergy.cpp index 883e0201d..c236e69fa 100644 --- a/src/lib/synergy/XSynergy.cpp +++ b/src/lib/synergy/XSynergy.cpp @@ -30,7 +30,8 @@ String XBadClient::getWhat() const throw() { return "XBadClient"; } // XIncompatibleClient::XIncompatibleClient(int major, int minor) - : m_major(major), m_minor(minor) { + : m_major(major), + m_minor(minor) { // do nothing } @@ -39,9 +40,10 @@ int XIncompatibleClient::getMajor() const throw() { return m_major; } int XIncompatibleClient::getMinor() const throw() { return m_minor; } String XIncompatibleClient::getWhat() const throw() { - return format("XIncompatibleClient", "incompatible client %{1}.%{2}", - synergy::string::sprintf("%d", m_major).c_str(), - synergy::string::sprintf("%d", m_minor).c_str()); + return format( + "XIncompatibleClient", "incompatible client %{1}.%{2}", + synergy::string::sprintf("%d", m_major).c_str(), + synergy::string::sprintf("%d", m_minor).c_str()); } // @@ -83,6 +85,7 @@ XExitApp::XExitApp(int code) : m_code(code) { int XExitApp::getCode() const throw() { return m_code; } String XExitApp::getWhat() const throw() { - return format("XExitApp", "exiting with code %{1}", - synergy::string::sprintf("%d", m_code).c_str()); + return format( + "XExitApp", "exiting with code %{1}", + synergy::string::sprintf("%d", m_code).c_str()); } diff --git a/src/lib/synergy/languages/LanguageManager.cpp b/src/lib/synergy/languages/LanguageManager.cpp index 161faa76f..c5296cc3c 100644 --- a/src/lib/synergy/languages/LanguageManager.cpp +++ b/src/lib/synergy/languages/LanguageManager.cpp @@ -21,8 +21,8 @@ namespace { -String vectorToString(const std::vector &vector, - const String &delimiter = "") { +String vectorToString( + const std::vector &vector, const String &delimiter = "") { String string; for (const auto &item : vector) { if (&item != &vector[0]) { @@ -41,7 +41,8 @@ namespace languages { LanguageManager::LanguageManager(const std::vector &localLanguages) : m_localLanguages(localLanguages) { - LOG((CLOG_INFO "local languages: %s", + LOG( + (CLOG_INFO "local languages: %s", vectorToString(m_localLanguages, ", ").c_str())); } @@ -52,7 +53,8 @@ void LanguageManager::setRemoteLanguages(const String &remoteLanguages) { m_remoteLanguages.push_back(remoteLanguages.substr(i, 2)); } } - LOG((CLOG_INFO "remote languages: %s", + LOG( + (CLOG_INFO "remote languages: %s", vectorToString(m_remoteLanguages, ", ").c_str())); } @@ -87,8 +89,10 @@ bool LanguageManager::isLanguageInstalled(const String &language) const { bool isInstalled = true; if (!m_localLanguages.empty()) { - isInstalled = (std::find(m_localLanguages.begin(), m_localLanguages.end(), - language) != m_localLanguages.end()); + isInstalled = + (std::find( + m_localLanguages.begin(), m_localLanguages.end(), language) != + m_localLanguages.end()); } return isInstalled; diff --git a/src/lib/synergy/languages/LanguageManager.h b/src/lib/synergy/languages/LanguageManager.h index bc4b4906e..4163cdb71 100644 --- a/src/lib/synergy/languages/LanguageManager.h +++ b/src/lib/synergy/languages/LanguageManager.h @@ -30,8 +30,9 @@ class LanguageManager { std::vector m_localLanguages; public: - explicit LanguageManager(const std::vector &localLanguages = - AppUtil::instance().getKeyboardLayoutList()); + explicit LanguageManager( + const std::vector &localLanguages = + AppUtil::instance().getKeyboardLayoutList()); /** * @brief setRemoteLanguages sets remote languages diff --git a/src/lib/synergy/unix/AppUtilUnix.cpp b/src/lib/synergy/unix/AppUtilUnix.cpp index 7d0272c73..4b4ecc45c 100644 --- a/src/lib/synergy/unix/AppUtilUnix.cpp +++ b/src/lib/synergy/unix/AppUtilUnix.cpp @@ -59,10 +59,10 @@ std::vector AppUtilUnix::getKeyboardLayoutList() { #elif WINAPI_CARBON CFStringRef keys[] = {kTISPropertyInputSourceCategory}; CFStringRef values[] = {kTISCategoryKeyboardInputSource}; - AutoCFDictionary dict(CFDictionaryCreate(NULL, (const void **)keys, - (const void **)values, 1, NULL, - NULL), - CFRelease); + AutoCFDictionary dict( + CFDictionaryCreate( + NULL, (const void **)keys, (const void **)values, 1, NULL, NULL), + CFRelease); AutoCFArray kbds(TISCreateInputSourceList(dict.get(), false), CFRelease); for (CFIndex i = 0; i < CFArrayGetCount(kbds.get()); ++i) { @@ -75,8 +75,9 @@ std::vector AppUtilUnix::getKeyboardLayoutList() { index < CFArrayGetCount(layoutLanguages) && layoutLanguages; index++) { auto languageCode = (CFStringRef)CFArrayGetValueAtIndex(layoutLanguages, index); - if (!languageCode || !CFStringGetCString(languageCode, temporaryCString, - 128, kCFStringEncodingUTF8)) { + if (!languageCode || + !CFStringGetCString( + languageCode, temporaryCString, 128, kCFStringEncodingUTF8)) { continue; } @@ -157,8 +158,9 @@ String AppUtilUnix::getCurrentLanguageCode() { index < CFArrayGetCount(layoutLanguages) && layoutLanguages; index++) { auto languageCode = (CFStringRef)CFArrayGetValueAtIndex(layoutLanguages, index); - if (!languageCode || !CFStringGetCString(languageCode, temporaryCString, - 128, kCFStringEncodingUTF8)) { + if (!languageCode || + !CFStringGetCString( + languageCode, temporaryCString, 128, kCFStringEncodingUTF8)) { continue; } @@ -169,10 +171,11 @@ String AppUtilUnix::getCurrentLanguageCode() { return result; } -void AppUtilUnix::showNotification(const String &title, - const String &text) const { +void AppUtilUnix::showNotification( + const String &title, const String &text) const { #if WINAPI_XWINDOWS - LOG((CLOG_INFO "showing notification, title=\"%s\", text=\"%s\"", + LOG( + (CLOG_INFO "showing notification, title=\"%s\", text=\"%s\"", title.c_str(), text.c_str())); if (!notify_init("Synergy")) { LOG((CLOG_INFO "failed to initialize libnotify")); diff --git a/src/lib/synergy/unix/X11LayoutsParser.cpp b/src/lib/synergy/unix/X11LayoutsParser.cpp index eced99f70..2711f1851 100644 --- a/src/lib/synergy/unix/X11LayoutsParser.cpp +++ b/src/lib/synergy/unix/X11LayoutsParser.cpp @@ -39,8 +39,8 @@ void splitLine(std::vector &parts, const String &line, char delimiter) { } // namespace -bool X11LayoutsParser::readXMLConfigItemElem(const pugi::xml_node *root, - std::vector &langList) { +bool X11LayoutsParser::readXMLConfigItemElem( + const pugi::xml_node *root, std::vector &langList) { auto configItemElem = root->child("configItem"); if (!configItemElem) { LOG((CLOG_WARN "failed to read \"configItem\" in xml file")); @@ -75,7 +75,8 @@ X11LayoutsParser::getAllLanguageData(const String &pathToEvdevFile) { auto xkbConfigElem = doc.child("xkbConfigRegistry"); if (!xkbConfigElem) { - LOG((CLOG_WARN "failed to read xkbConfigRegistry in %s", + LOG( + (CLOG_WARN "failed to read xkbConfigRegistry in %s", pathToEvdevFile.c_str())); return allCodes; } @@ -102,8 +103,8 @@ X11LayoutsParser::getAllLanguageData(const String &pathToEvdevFile) { return allCodes; } -void X11LayoutsParser::appendVectorUniq(const std::vector &source, - std::vector &dst) { +void X11LayoutsParser::appendVectorUniq( + const std::vector &source, std::vector &dst) { for (const auto &elem : source) { if (std::find_if(dst.begin(), dst.end(), [elem](const String &s) { return s == elem; @@ -147,7 +148,8 @@ void X11LayoutsParser::convertLayoutToISO639_2( langIter->variants.begin(), langIter->variants.end(), [&variantName](const Lang &l) { return l.name == variantName; }); if (langVariantIter == langIter->variants.end()) { - LOG((CLOG_WARN "variant \"%s\" of language \"%s\" is unknown", + LOG( + (CLOG_WARN "variant \"%s\" of language \"%s\" is unknown", layoutVariantNames[i].c_str(), layoutNames[i].c_str())); continue; } @@ -176,19 +178,21 @@ X11LayoutsParser::getX11LanguageList(const String &pathToEvdevFile) { std::vector iso639_2Codes; iso639_2Codes.reserve(layoutNames.size()); - convertLayoutToISO639_2(pathToEvdevFile, true, layoutNames, - layoutVariantNames, iso639_2Codes); + convertLayoutToISO639_2( + pathToEvdevFile, true, layoutNames, layoutVariantNames, iso639_2Codes); return convertISO639_2ToISO639_1(iso639_2Codes); } -String X11LayoutsParser::convertLayotToISO(const String &pathToEvdevFile, - const String &layoutLangCode, - bool needToReloadFiles) { +String X11LayoutsParser::convertLayotToISO( + const String &pathToEvdevFile, const String &layoutLangCode, + bool needToReloadFiles) { std::vector iso639_2Codes; - convertLayoutToISO639_2(pathToEvdevFile, needToReloadFiles, {layoutLangCode}, - {""}, iso639_2Codes); + convertLayoutToISO639_2( + pathToEvdevFile, needToReloadFiles, {layoutLangCode}, {""}, + iso639_2Codes); if (iso639_2Codes.empty()) { - LOG((CLOG_WARN "failed to convert layout lang code: \"%s\"", + LOG( + (CLOG_WARN "failed to convert layout lang code: \"%s\"", layoutLangCode.c_str())); return ""; } @@ -206,13 +210,14 @@ std::vector X11LayoutsParser::convertISO639_2ToISO639_1( const std::vector &iso639_2Codes) { std::vector result; for (const auto &isoCode : iso639_2Codes) { - const auto &tableIter = - std::find_if(ISO_Table.begin(), ISO_Table.end(), - [&isoCode](const std::pair &c) { - return c.first == isoCode; - }); + const auto &tableIter = std::find_if( + ISO_Table.begin(), ISO_Table.end(), + [&isoCode](const std::pair &c) { + return c.first == isoCode; + }); if (tableIter == ISO_Table.end()) { - LOG((CLOG_WARN "the ISO 639-2 code \"%s\" is missed in table", + LOG( + (CLOG_WARN "the ISO 639-2 code \"%s\" is missed in table", isoCode.c_str())); continue; } diff --git a/src/lib/synergy/unix/X11LayoutsParser.h b/src/lib/synergy/unix/X11LayoutsParser.h index 83472ec8b..abb2639a8 100644 --- a/src/lib/synergy/unix/X11LayoutsParser.h +++ b/src/lib/synergy/unix/X11LayoutsParser.h @@ -27,9 +27,9 @@ class xml_node; class X11LayoutsParser { public: static std::vector getX11LanguageList(const String &pathToEvdevFile); - static String convertLayotToISO(const String &pathToEvdevFile, - const String &layoutLangCode, - bool needToReloadFiles = false); + static String convertLayotToISO( + const String &pathToEvdevFile, const String &layoutLangCode, + bool needToReloadFiles = false); private: struct Lang { @@ -38,19 +38,19 @@ private: std::vector variants; }; - static bool readXMLConfigItemElem(const pugi::xml_node *root, - std::vector &langList); + static bool readXMLConfigItemElem( + const pugi::xml_node *root, std::vector &langList); static std::vector getAllLanguageData(const String &pathToEvdevFile); - static void appendVectorUniq(const std::vector &source, - std::vector &dst); - static void - convertLayoutToISO639_2(const String &pathToEvdevFile, bool needToReloadEvdev, - const std::vector &layoutNames, - const std::vector &layoutVariantNames, - std::vector &iso639_2Codes); + appendVectorUniq(const std::vector &source, std::vector &dst); + + static void convertLayoutToISO639_2( + const String &pathToEvdevFile, bool needToReloadEvdev, + const std::vector &layoutNames, + const std::vector &layoutVariantNames, + std::vector &iso639_2Codes); static std::vector convertISO639_2ToISO639_1(const std::vector &iso639_2Codes); diff --git a/src/lib/synergy/win32/AppUtilWindows.cpp b/src/lib/synergy/win32/AppUtilWindows.cpp index 82e42f705..e209bce28 100644 --- a/src/lib/synergy/win32/AppUtilWindows.cpp +++ b/src/lib/synergy/win32/AppUtilWindows.cpp @@ -42,7 +42,8 @@ #include AppUtilWindows::AppUtilWindows(IEventQueue *events) - : m_events(events), m_exitMode(kExitModeNormal) { + : m_events(events), + m_exitMode(kExitModeNormal) { if (SetConsoleCtrlHandler((PHANDLER_ROUTINE)consoleHandler, TRUE) == FALSE) { throw XArch(new XArchEvalWindows()); } @@ -156,8 +157,9 @@ std::vector AppUtilWindows::getKeyboardLayoutList() { for (int i = 0; i < uLayouts; ++i) { String code("", 2); - GetLocaleInfoA(MAKELCID(((UINT)lpList[i] & 0xffffffff), SORT_DEFAULT), - LOCALE_SISO639LANGNAME, &code[0], code.size()); + GetLocaleInfoA( + MAKELCID(((UINT)lpList[i] & 0xffffffff), SORT_DEFAULT), + LOCALE_SISO639LANGNAME, &code[0], code.size()); layoutLangCodes.push_back(code); } @@ -174,8 +176,8 @@ String AppUtilWindows::getCurrentLanguageCode() { auto hklLayout = getCurrentKeyboardLayout(); if (hklLayout) { auto localLayoutID = MAKELCID(LOWORD(hklLayout), SORT_DEFAULT); - GetLocaleInfoA(localLayoutID, LOCALE_SISO639LANGNAME, &code[0], - code.size()); + GetLocaleInfoA( + localLayoutID, LOCALE_SISO639LANGNAME, &code[0], code.size()); } return code; @@ -204,9 +206,10 @@ public: void toastFailed() const override {} }; -void AppUtilWindows::showNotification(const String &title, - const String &text) const { - LOG((CLOG_INFO "showing notification, title=\"%s\", text=\"%s\"", +void AppUtilWindows::showNotification( + const String &title, const String &text) const { + LOG( + (CLOG_INFO "showing notification, title=\"%s\", text=\"%s\"", title.c_str(), text.c_str())); if (!WinToastLib::WinToast::isCompatible()) { LOG((CLOG_INFO "this system does not support toast notifications")); @@ -228,16 +231,18 @@ void AppUtilWindows::showNotification(const String &title, auto handler = std::make_unique(); WinToastLib::WinToastTemplate templ = WinToastLib::WinToastTemplate(WinToastLib::WinToastTemplate::Text02); - templ.setTextField(std::wstring(title.begin(), title.end()), - WinToastLib::WinToastTemplate::FirstLine); - templ.setTextField(std::wstring(text.begin(), text.end()), - WinToastLib::WinToastTemplate::SecondLine); + templ.setTextField( + std::wstring(title.begin(), title.end()), + WinToastLib::WinToastTemplate::FirstLine); + templ.setTextField( + std::wstring(text.begin(), text.end()), + WinToastLib::WinToastTemplate::SecondLine); const bool launched = WinToastLib::WinToast::instance()->showToast( templ, handler.get(), &error); if (!launched) { - LOG((CLOG_DEBUG "failed to show toast notification, error code: %d", - error)); + LOG(( + CLOG_DEBUG "failed to show toast notification, error code: %d", error)); return; } } diff --git a/src/test/global/TestEventQueue.cpp b/src/test/global/TestEventQueue.cpp index ab61af41e..96c5a6c8f 100644 --- a/src/test/global/TestEventQueue.cpp +++ b/src/test/global/TestEventQueue.cpp @@ -27,9 +27,10 @@ void TestEventQueue::raiseQuitEvent() { addEvent(Event(Event::kQuit)); } void TestEventQueue::initQuitTimeout(double timeout) { assert(m_quitTimeoutTimer == nullptr); m_quitTimeoutTimer = newOneShotTimer(timeout, NULL); - adoptHandler(Event::kTimer, m_quitTimeoutTimer, - new TMethodEventJob( - this, &TestEventQueue::handleQuitTimeout)); + adoptHandler( + Event::kTimer, m_quitTimeoutTimer, + new TMethodEventJob( + this, &TestEventQueue::handleQuitTimeout)); } void TestEventQueue::cleanupQuitTimeout() { diff --git a/src/test/integtests/ipc/IpcTests.cpp b/src/test/integtests/ipc/IpcTests.cpp index d23aa3e8b..fa585c1d9 100644 --- a/src/test/integtests/ipc/IpcTests.cpp +++ b/src/test/integtests/ipc/IpcTests.cpp @@ -140,7 +140,8 @@ TEST_F(IpcTests, sendMessageToClient) { IpcTests::IpcTests() : m_connectToServer_helloMessageReceived(false), - m_connectToServer_hasClientNode(false), m_connectToServer_server(nullptr), + m_connectToServer_hasClientNode(false), + m_connectToServer_server(nullptr), m_sendMessageToClient_server(nullptr), m_sendMessageToServer_client(nullptr) {} @@ -156,8 +157,8 @@ void IpcTests::connectToServer_handleMessageReceived(const Event &e, void *) { } } -void IpcTests::sendMessageToServer_serverHandleMessageReceived(const Event &e, - void *) { +void IpcTests::sendMessageToServer_serverHandleMessageReceived( + const Event &e, void *) { IpcMessage *m = static_cast(e.getDataObject()); if (m->type() == kIpcHello) { LOG((CLOG_DEBUG "client said hello, sending test to server")); @@ -171,8 +172,8 @@ void IpcTests::sendMessageToServer_serverHandleMessageReceived(const Event &e, } } -void IpcTests::sendMessageToClient_serverHandleClientConnected(const Event &e, - void *) { +void IpcTests::sendMessageToClient_serverHandleClientConnected( + const Event &e, void *) { IpcMessage *m = static_cast(e.getDataObject()); if (m->type() == kIpcHello) { LOG((CLOG_DEBUG "client said hello, sending test to client")); @@ -181,8 +182,8 @@ void IpcTests::sendMessageToClient_serverHandleClientConnected(const Event &e, } } -void IpcTests::sendMessageToClient_clientHandleMessageReceived(const Event &e, - void *) { +void IpcTests::sendMessageToClient_clientHandleMessageReceived( + const Event &e, void *) { IpcMessage *m = static_cast(e.getDataObject()); if (m->type() == kIpcLogLine) { IpcLogLineMessage *llm = static_cast(m); diff --git a/src/test/integtests/net/NetworkTests.cpp b/src/test/integtests/net/NetworkTests.cpp index 63b12bdfd..d7438d310 100644 --- a/src/test/integtests/net/NetworkTests.cpp +++ b/src/test/integtests/net/NetworkTests.cpp @@ -78,20 +78,20 @@ public: void sendMockData(void *eventTarget); - void sendToClient_mockData_handleClientConnected(const Event &, - void *vlistener); + void + sendToClient_mockData_handleClientConnected(const Event &, void *vlistener); void sendToClient_mockData_fileRecieveCompleted(const Event &, void *); - void sendToClient_mockFile_handleClientConnected(const Event &, - void *vlistener); + void + sendToClient_mockFile_handleClientConnected(const Event &, void *vlistener); void sendToClient_mockFile_fileRecieveCompleted(const Event &event, void *); - void sendToServer_mockData_handleClientConnected(const Event &, - void *vlistener); + void + sendToServer_mockData_handleClientConnected(const Event &, void *vlistener); void sendToServer_mockData_fileRecieveCompleted(const Event &event, void *); - void sendToServer_mockFile_handleClientConnected(const Event &, - void *vlistener); + void + sendToServer_mockFile_handleClientConnected(const Event &, void *vlistener); void sendToServer_mockFile_fileRecieveCompleted(const Event &event, void *); public: @@ -130,8 +130,8 @@ TEST_F(NetworkTests, sendToClient_mockData) { lib::synergy::ServerArgs serverArgs; serverArgs.m_enableDragDrop = true; - Server server(serverConfig, &primaryClient, &serverScreen, &m_events, - serverArgs); + Server server( + serverConfig, &primaryClient, &serverScreen, &m_events, serverArgs); server.m_mock = true; listener.setServer(&server); @@ -148,8 +148,9 @@ TEST_F(NetworkTests, sendToClient_mockData) { lib::synergy::ClientArgs clientArgs; clientArgs.m_enableDragDrop = true; clientArgs.m_enableCrypto = false; - Client client(&m_events, "stub", serverAddress, clientSocketFactory, - &clientScreen, clientArgs); + Client client( + &m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, + clientArgs); m_events.adoptHandler( m_events.forFile().fileRecieveCompleted(), &client, @@ -193,8 +194,8 @@ TEST_F(NetworkTests, sendToClient_mockFile) { lib::synergy::ServerArgs serverArgs; serverArgs.m_enableDragDrop = true; - Server server(serverConfig, &primaryClient, &serverScreen, &m_events, - serverArgs); + Server server( + serverConfig, &primaryClient, &serverScreen, &m_events, serverArgs); server.m_mock = true; listener.setServer(&server); @@ -211,8 +212,9 @@ TEST_F(NetworkTests, sendToClient_mockFile) { lib::synergy::ClientArgs clientArgs; clientArgs.m_enableDragDrop = true; clientArgs.m_enableCrypto = false; - Client client(&m_events, "stub", serverAddress, clientSocketFactory, - &clientScreen, clientArgs); + Client client( + &m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, + clientArgs); m_events.adoptHandler( m_events.forFile().fileRecieveCompleted(), &client, @@ -249,8 +251,8 @@ TEST_F(NetworkTests, sendToServer_mockData) { lib::synergy::ServerArgs serverArgs; serverArgs.m_enableDragDrop = true; - Server server(serverConfig, &primaryClient, &serverScreen, &m_events, - serverArgs); + Server server( + serverConfig, &primaryClient, &serverScreen, &m_events, serverArgs); server.m_mock = true; listener.setServer(&server); @@ -267,8 +269,9 @@ TEST_F(NetworkTests, sendToServer_mockData) { lib::synergy::ClientArgs clientArgs; clientArgs.m_enableDragDrop = true; clientArgs.m_enableCrypto = false; - Client client(&m_events, "stub", serverAddress, clientSocketFactory, - &clientScreen, clientArgs); + Client client( + &m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, + clientArgs); m_events.adoptHandler( m_events.forClientListener().connected(), &listener, @@ -312,8 +315,8 @@ TEST_F(NetworkTests, sendToServer_mockFile) { lib::synergy::ServerArgs serverArgs; serverArgs.m_enableDragDrop = true; - Server server(serverConfig, &primaryClient, &serverScreen, &m_events, - serverArgs); + Server server( + serverConfig, &primaryClient, &serverScreen, &m_events, serverArgs); server.m_mock = true; listener.setServer(&server); @@ -330,8 +333,9 @@ TEST_F(NetworkTests, sendToServer_mockFile) { lib::synergy::ClientArgs clientArgs; clientArgs.m_enableDragDrop = true; clientArgs.m_enableCrypto = false; - Client client(&m_events, "stub", serverAddress, clientSocketFactory, - &clientScreen, clientArgs); + Client client( + &m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, + clientArgs); m_events.adoptHandler( m_events.forClientListener().connected(), &listener, @@ -403,8 +407,8 @@ void NetworkTests::sendToClient_mockFile_fileRecieveCompleted( m_events.raiseQuitEvent(); } -void NetworkTests::sendToServer_mockData_handleClientConnected(const Event &, - void *vclient) { +void NetworkTests::sendToServer_mockData_handleClientConnected( + const Event &, void *vclient) { Client *client = static_cast(vclient); sendMockData(client); } @@ -417,8 +421,8 @@ void NetworkTests::sendToServer_mockData_fileRecieveCompleted( m_events.raiseQuitEvent(); } -void NetworkTests::sendToServer_mockFile_handleClientConnected(const Event &, - void *vclient) { +void NetworkTests::sendToServer_mockFile_handleClientConnected( + const Event &, void *vclient) { Client *client = static_cast(vclient); client->sendFileToServer(kMockFilename); } @@ -465,8 +469,8 @@ void NetworkTests::sendMockData(void *eventTarget) { // send last message FileChunk *transferFinished = FileChunk::end(); - m_events.addEvent(Event(m_events.forFile().fileChunkSending(), eventTarget, - transferFinished)); + m_events.addEvent(Event( + m_events.forFile().fileChunkSending(), eventTarget, transferFinished)); } UInt8 *newMockData(size_t size) { diff --git a/src/test/integtests/platform/MSWindowsKeyStateTests.cpp b/src/test/integtests/platform/MSWindowsKeyStateTests.cpp index 39659b7ec..6e7f55dba 100644 --- a/src/test/integtests/platform/MSWindowsKeyStateTests.cpp +++ b/src/test/integtests/platform/MSWindowsKeyStateTests.cpp @@ -45,10 +45,11 @@ protected: virtual void TearDown() { delete m_screensaver; } MSWindowsDesks *newDesks(IEventQueue *eventQueue) { - return new MSWindowsDesks(true, false, m_screensaver, eventQueue, - new TMethodJob( - this, &MSWindowsKeyStateTests::updateKeysCB), - false); + return new MSWindowsDesks( + true, false, m_screensaver, eventQueue, + new TMethodJob( + this, &MSWindowsKeyStateTests::updateKeysCB), + false); } void *getEventTarget() const { @@ -65,8 +66,8 @@ TEST_F(MSWindowsKeyStateTests, disable_eventQueueNotUsed) { NiceMock eventQueue; MSWindowsDesks *desks = newDesks(&eventQueue); MockKeyMap keyMap; - MSWindowsKeyState keyState(desks, getEventTarget(), &eventQueue, keyMap, - {"en"}, true); + MSWindowsKeyState keyState( + desks, getEventTarget(), &eventQueue, keyMap, {"en"}, true); EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(0); @@ -74,13 +75,14 @@ TEST_F(MSWindowsKeyStateTests, disable_eventQueueNotUsed) { delete desks; } -TEST_F(MSWindowsKeyStateTests, - testAutoRepeat_noRepeatAndButtonIsZero_resultIsTrue) { +TEST_F( + MSWindowsKeyStateTests, + testAutoRepeat_noRepeatAndButtonIsZero_resultIsTrue) { NiceMock eventQueue; MSWindowsDesks *desks = newDesks(&eventQueue); MockKeyMap keyMap; - MSWindowsKeyState keyState(desks, getEventTarget(), &eventQueue, keyMap, - {"en"}, true); + MSWindowsKeyState keyState( + desks, getEventTarget(), &eventQueue, keyMap, {"en"}, true); keyState.setLastDown(1); bool actual = keyState.testAutoRepeat(true, false, 1); @@ -93,8 +95,8 @@ TEST_F(MSWindowsKeyStateTests, testAutoRepeat_pressFalse_lastDownIsZero) { NiceMock eventQueue; MSWindowsDesks *desks = newDesks(&eventQueue); MockKeyMap keyMap; - MSWindowsKeyState keyState(desks, getEventTarget(), &eventQueue, keyMap, - {"en"}, true); + MSWindowsKeyState keyState( + desks, getEventTarget(), &eventQueue, keyMap, {"en"}, true); keyState.setLastDown(1); keyState.testAutoRepeat(false, false, 1); @@ -107,8 +109,8 @@ TEST_F(MSWindowsKeyStateTests, saveModifiers_noModifiers_savedModifiers0) { NiceMock eventQueue; MSWindowsDesks *desks = newDesks(&eventQueue); MockKeyMap keyMap; - MSWindowsKeyState keyState(desks, getEventTarget(), &eventQueue, keyMap, - {"en"}, true); + MSWindowsKeyState keyState( + desks, getEventTarget(), &eventQueue, keyMap, {"en"}, true); keyState.saveModifiers(); @@ -116,23 +118,23 @@ TEST_F(MSWindowsKeyStateTests, saveModifiers_noModifiers_savedModifiers0) { delete desks; } -TEST_F(MSWindowsKeyStateTests, - testKoreanLocale_inputModeKey_resultCorrectKeyID) { +TEST_F( + MSWindowsKeyStateTests, testKoreanLocale_inputModeKey_resultCorrectKeyID) { NiceMock eventQueue; MSWindowsDesks *desks = newDesks(&eventQueue); MockKeyMap keyMap; - MSWindowsKeyState keyState(desks, getEventTarget(), &eventQueue, keyMap, - {"en"}, true); + MSWindowsKeyState keyState( + desks, getEventTarget(), &eventQueue, keyMap, {"en"}, true); keyState.setKeyLayout((HKL)0x00000412u); // for ko-KR local ID - ASSERT_EQ(0xEF31, - keyState.getKeyID(0x15u, 0x1f2u)); // VK_HANGUL from Hangul key - ASSERT_EQ(0xEF34, - keyState.getKeyID(0x19u, 0x1f1u)); // VK_HANJA from Hanja key - ASSERT_EQ(0xEF31, - keyState.getKeyID(0x15u, 0x11du)); // VK_HANGUL from R-Alt key - ASSERT_EQ(0xEF34, - keyState.getKeyID(0x19u, 0x138u)); // VK_HANJA from R-Ctrl key + ASSERT_EQ( + 0xEF31, keyState.getKeyID(0x15u, 0x1f2u)); // VK_HANGUL from Hangul key + ASSERT_EQ( + 0xEF34, keyState.getKeyID(0x19u, 0x1f1u)); // VK_HANJA from Hanja key + ASSERT_EQ( + 0xEF31, keyState.getKeyID(0x15u, 0x11du)); // VK_HANGUL from R-Alt key + ASSERT_EQ( + 0xEF34, keyState.getKeyID(0x19u, 0x138u)); // VK_HANJA from R-Ctrl key keyState.setKeyLayout((HKL)0x00000411); // for ja-jp locale ID ASSERT_EQ(0xEF26, keyState.getKeyID(0x15u, 0x1du)); // VK_KANA diff --git a/src/test/integtests/platform/OSXKeyStateTests.cpp b/src/test/integtests/platform/OSXKeyStateTests.cpp index c79990134..5748e054b 100644 --- a/src/test/integtests/platform/OSXKeyStateTests.cpp +++ b/src/test/integtests/platform/OSXKeyStateTests.cpp @@ -93,8 +93,8 @@ TEST_F(OSXKeyStateTests, fakeAndPoll_charKeyAndModifier) { keyState.fakeKeyUp(2); } -bool OSXKeyStateTests::isKeyPressed(const OSXKeyState &keyState, - KeyButton button) { +bool OSXKeyStateTests::isKeyPressed( + const OSXKeyState &keyState, KeyButton button) { // HACK: allow os to realize key state changes. ARCH->sleep(.2); diff --git a/src/test/mock/ipc/MockIpcServer.h b/src/test/mock/ipc/MockIpcServer.h index b55ded623..abe7bf1e9 100644 --- a/src/test/mock/ipc/MockIpcServer.h +++ b/src/test/mock/ipc/MockIpcServer.h @@ -31,7 +31,8 @@ class IEventQueue; class MockIpcServer : public IpcServer { public: MockIpcServer() - : m_sendCond(ARCH->newCondVar()), m_sendMutex(ARCH->newMutex()) {} + : m_sendCond(ARCH->newCondVar()), + m_sendMutex(ARCH->newMutex()) {} ~MockIpcServer() { if (m_sendCond != NULL) { diff --git a/src/test/mock/synergy/MockApp.h b/src/test/mock/synergy/MockApp.h index f02f6853a..c134ab673 100644 --- a/src/test/mock/synergy/MockApp.h +++ b/src/test/mock/synergy/MockApp.h @@ -35,8 +35,8 @@ public: MOCK_METHOD(void, parseArgs, (int, const char *const *), (override)); MOCK_METHOD(void, version, (), (override)); MOCK_METHOD(int, standardStartup, (int, char **), (override)); - MOCK_METHOD(int, runInner, (int, char **, ILogOutputter *, StartupFunc), - (override)); + MOCK_METHOD( + int, runInner, (int, char **, ILogOutputter *, StartupFunc), (override)); MOCK_METHOD(void, startNode, (), (override)); MOCK_METHOD(int, mainLoop, (), (override)); MOCK_METHOD(int, foregroundStartup, (int, char **), (override)); diff --git a/src/test/mock/synergy/MockEventQueue.h b/src/test/mock/synergy/MockEventQueue.h index 7b13c2833..826016547 100644 --- a/src/test/mock/synergy/MockEventQueue.h +++ b/src/test/mock/synergy/MockEventQueue.h @@ -29,22 +29,22 @@ public: MOCK_METHOD(EventQueueTimer *, newTimer, (double, void *), (override)); MOCK_METHOD(bool, getEvent, (Event &, double), (override)); MOCK_METHOD(void, adoptBuffer, (IEventQueueBuffer *), (override)); - MOCK_METHOD(Event::Type, registerTypeOnce, (Event::Type &, const char *), - (override)); + MOCK_METHOD( + Event::Type, registerTypeOnce, (Event::Type &, const char *), (override)); MOCK_METHOD(void, removeHandlers, (void *), (override)); MOCK_METHOD(Event::Type, registerType, (const char *)); MOCK_METHOD(bool, isEmpty, (), (const, override)); - MOCK_METHOD(void, adoptHandler, (Event::Type, void *, IEventJob *), - (override)); + MOCK_METHOD( + void, adoptHandler, (Event::Type, void *, IEventJob *), (override)); MOCK_METHOD(const char *, getTypeName, (Event::Type), (override)); MOCK_METHOD(void, addEvent, (const Event &), (override)); MOCK_METHOD(void, removeHandler, (Event::Type, void *), (override)); MOCK_METHOD(bool, dispatchEvent, (const Event &), (override)); - MOCK_METHOD(IEventJob *, getHandler, (Event::Type, void *), - (const, override)); + MOCK_METHOD( + IEventJob *, getHandler, (Event::Type, void *), (const, override)); MOCK_METHOD(void, deleteTimer, (EventQueueTimer *), (override)); - MOCK_METHOD(Event::Type, getRegisteredType, (const String &), - (const, override)); + MOCK_METHOD( + Event::Type, getRegisteredType, (const String &), (const, override)); MOCK_METHOD(void *, getSystemTarget, (), (override)); MOCK_METHOD(ClientEvents &, forClient, (), (override)); MOCK_METHOD(IStreamEvents &, forIStream, (), (override)); @@ -58,8 +58,8 @@ public: MOCK_METHOD(OSXScreenEvents &, forOSXScreen, (), (override)); MOCK_METHOD(ClientListenerEvents &, forClientListener, (), (override)); MOCK_METHOD(ClientProxyEvents &, forClientProxy, (), (override)); - MOCK_METHOD(ClientProxyUnknownEvents &, forClientProxyUnknown, (), - (override)); + MOCK_METHOD( + ClientProxyUnknownEvents &, forClientProxyUnknown, (), (override)); MOCK_METHOD(ServerEvents &, forServer, (), (override)); MOCK_METHOD(ServerAppEvents &, forServerApp, (), (override)); MOCK_METHOD(IKeyStateEvents &, forIKeyState, (), (override)); diff --git a/src/test/mock/synergy/MockKeyMap.h b/src/test/mock/synergy/MockKeyMap.h index 3b56df226..9d53ee076 100644 --- a/src/test/mock/synergy/MockKeyMap.h +++ b/src/test/mock/synergy/MockKeyMap.h @@ -29,8 +29,9 @@ public: MOCK_METHOD(void, foreachKey, (ForeachKeyCallback, void *), (override)); MOCK_METHOD(void, addHalfDuplexModifier, (KeyID), (override)); MOCK_METHOD(bool, isHalfDuplex, (KeyID, KeyButton), (const, override)); - MOCK_METHOD(const KeyMap::KeyItem *, mapKey, - (Keystrokes &, KeyID, SInt32, ModifierToKeys &, KeyModifierMask &, - KeyModifierMask, bool, const String &), - (const, override)); + MOCK_METHOD( + const KeyMap::KeyItem *, mapKey, + (Keystrokes &, KeyID, SInt32, ModifierToKeys &, KeyModifierMask &, + KeyModifierMask, bool, const String &), + (const, override)); }; diff --git a/src/test/mock/synergy/MockKeyState.h b/src/test/mock/synergy/MockKeyState.h index 95c372d32..5f3999d94 100644 --- a/src/test/mock/synergy/MockKeyState.h +++ b/src/test/mock/synergy/MockKeyState.h @@ -33,8 +33,9 @@ public: : KeyState((IEventQueue *)&eventQueue, {"en"}, true) {} MockKeyState(const MockEventQueue &eventQueue, const synergy::KeyMap &keyMap) - : KeyState((IEventQueue *)&eventQueue, (synergy::KeyMap &)keyMap, {"en"}, - true) {} + : KeyState( + (IEventQueue *)&eventQueue, (synergy::KeyMap &)keyMap, {"en"}, + true) {} MOCK_METHOD(SInt32, pollActiveGroup, (), (const, override)); MOCK_METHOD(KeyModifierMask, pollActiveModifiers, (), (const, override)); @@ -49,5 +50,5 @@ typedef ::testing::NiceMock KeyStateImpl; typedef UInt32 KeyID; -typedef void (*ForeachKeyCallback)(KeyID, SInt32 group, - synergy::KeyMap::KeyItem &, void *userData); +typedef void (*ForeachKeyCallback)( + KeyID, SInt32 group, synergy::KeyMap::KeyItem &, void *userData); diff --git a/src/test/mock/synergy/MockScreen.h b/src/test/mock/synergy/MockScreen.h index d4a9f4e74..641e48b33 100644 --- a/src/test/mock/synergy/MockScreen.h +++ b/src/test/mock/synergy/MockScreen.h @@ -27,8 +27,9 @@ class MockScreen : public synergy::Screen { public: MockScreen() : synergy::Screen() {} MOCK_METHOD(void, disable, (), (override)); - MOCK_METHOD(void, getShape, (SInt32 &, SInt32 &, SInt32 &, SInt32 &), - (const, override)); + MOCK_METHOD( + void, getShape, (SInt32 &, SInt32 &, SInt32 &, SInt32 &), + (const, override)); MOCK_METHOD(void, getCursorPos, (SInt32 &, SInt32 &), (const, override)); MOCK_METHOD(void, resetOptions, (), (override)); MOCK_METHOD(void, setOptions, (const OptionsList &), (override)); diff --git a/src/test/unittests/arch/IArchStringTests.cpp b/src/test/unittests/arch/IArchStringTests.cpp index c2db4c00f..fe1ed1339 100644 --- a/src/test/unittests/arch/IArchStringTests.cpp +++ b/src/test/unittests/arch/IArchStringTests.cpp @@ -34,8 +34,9 @@ TEST(IArchStringTests, convStringWCToMB_will_work_do_simple_conversions) { EXPECT_EQ(errors, false); } -TEST(IArchStringTests, - convStringWCToMB_will_work_do_simple_conversions_noresult) { +TEST( + IArchStringTests, + convStringWCToMB_will_work_do_simple_conversions_noresult) { SampleIArchString as; bool errors; auto converted = as.convStringWCToMB(nullptr, L"Hello", 6, &errors); diff --git a/src/test/unittests/base/LogTests.cpp b/src/test/unittests/base/LogTests.cpp index 5b1711721..8925a4a9b 100644 --- a/src/test/unittests/base/LogTests.cpp +++ b/src/test/unittests/base/LogTests.cpp @@ -76,8 +76,8 @@ TEST(LogTests, print_infoWithFileAndLine_outputIsValid) { log.print("test file", 123, LEVEL_INFO "test message"); - EXPECT_THAT(GetCapturedStdout(), - EndsWith("INFO: test message\n\ttest file:123\n")); + EXPECT_THAT( + GetCapturedStdout(), EndsWith("INFO: test message\n\ttest file:123\n")); } TEST(LogTests, print_errorWithFileAndLine_outputIsValid) { @@ -86,6 +86,6 @@ TEST(LogTests, print_errorWithFileAndLine_outputIsValid) { log.print("test file", 123, LEVEL_ERR "test message"); - EXPECT_THAT(GetCapturedStderr(), - EndsWith("ERROR: test message\n\ttest file:123\n")); + EXPECT_THAT( + GetCapturedStderr(), EndsWith("ERROR: test message\n\ttest file:123\n")); } diff --git a/src/test/unittests/gui/MainWindowTests.cpp b/src/test/unittests/gui/MainWindowTests.cpp index 0000a1753..2c1fdfb8a 100644 --- a/src/test/unittests/gui/MainWindowTests.cpp +++ b/src/test/unittests/gui/MainWindowTests.cpp @@ -8,8 +8,8 @@ public: class MainWindowProxy : public MainWindow { public: #ifdef SYNERGY_ENABLE_LICENSING - explicit MainWindowProxy(AppConfig &appConfig, - LicenseManager &licenseManager) + explicit MainWindowProxy( + AppConfig &appConfig, LicenseManager &licenseManager) : MainWindow(appConfig, licenseManager) {} #else explicit MainWindowProxy(AppConfig &appConfig) : MainWindow(appConfig) {} diff --git a/src/test/unittests/synergy/ArgParserTests.cpp b/src/test/unittests/synergy/ArgParserTests.cpp index e8f834414..adf1330d2 100644 --- a/src/test/unittests/synergy/ArgParserTests.cpp +++ b/src/test/unittests/synergy/ArgParserTests.cpp @@ -175,8 +175,9 @@ TEST(ArgParserTests, assembleCommand_ignoreSecondArg_returnCommand) { EXPECT_EQ("stub1", command); } -TEST(ArgParserTests, - assembleCommand_ignoreSecondArgWithOneParameter_returnCommand) { +TEST( + ArgParserTests, + assembleCommand_ignoreSecondArgWithOneParameter_returnCommand) { std::vector argArray; argArray.push_back("stub1"); argArray.push_back("stub2"); @@ -223,16 +224,17 @@ TEST(ArgParserTests, parseServerArgs_parses_each_category) { ArgParser parser(nullptr); lib::synergy::ServerArgs args; args.m_daemon = false; - char const *argv[] = {"synergy", "--help" + char const *argv[] = { + "synergy", "--help" #if WINAPI_MSWINDOWS - , - "--exit-pause" + , + "--exit-pause" #elif WINAPI_XWINDOWS - , - "--no-xinitthreads" + , + "--no-xinitthreads" #endif - , - "--res-w", "888"}; + , + "--res-w", "888"}; EXPECT_TRUE( parser.parseServerArgs(args, sizeof(argv) / sizeof(argv[0]), argv)); EXPECT_EQ(args.m_shouldExitOk, true); @@ -242,19 +244,20 @@ TEST(ArgParserTests, parseClientArgs_parses_single_help) { ArgParser parser(nullptr); lib::synergy::ClientArgs args; args.m_daemon = false; - char const *argv[] = {"synergy", - "--help" + char const *argv[] = { + "synergy", + "--help" #if WINAPI_MSWINDOWS - , - "--exit-pause" + , + "--exit-pause" #elif WINAPI_XWINDOWS - , - "--no-xinitthreads" + , + "--no-xinitthreads" #endif - , - "--res-w", - "888", - "127.0.0.1"}; + , + "--res-w", + "888", + "127.0.0.1"}; EXPECT_TRUE( parser.parseClientArgs(args, sizeof(argv) / sizeof(argv[0]), argv)); EXPECT_EQ(args.m_shouldExitOk, true); diff --git a/src/test/unittests/synergy/ClientArgsParsingTests.cpp b/src/test/unittests/synergy/ClientArgsParsingTests.cpp index 08a5456d0..42621b476 100644 --- a/src/test/unittests/synergy/ClientArgsParsingTests.cpp +++ b/src/test/unittests/synergy/ClientArgsParsingTests.cpp @@ -71,8 +71,9 @@ TEST(ClientArgsParsingTests, parseClientArgs_setInvertScroll) { std::array kLangCmd = {"stub", "--invert-scroll"}; argParser.parseClientArgs(clientArgs, argc, kLangCmd.data()); - EXPECT_EQ(clientArgs.m_clientScrollDirection, - lib::synergy::ClientScrollDirection::INVERT_SERVER); + EXPECT_EQ( + clientArgs.m_clientScrollDirection, + lib::synergy::ClientScrollDirection::INVERT_SERVER); } TEST(ClientArgsParsingTests, parseClientArgs_setCommonArgs) { diff --git a/src/test/unittests/synergy/GenericArgsParsingTests.cpp b/src/test/unittests/synergy/GenericArgsParsingTests.cpp index 9c9be7ab8..59fa0fa98 100644 --- a/src/test/unittests/synergy/GenericArgsParsingTests.cpp +++ b/src/test/unittests/synergy/GenericArgsParsingTests.cpp @@ -72,8 +72,9 @@ TEST_F(GenericArgsParsingTests, parseGenericArgs_logFileCmd_saveLogFilename) { EXPECT_EQ(2, i); } -TEST_F(GenericArgsParsingTests, - parseGenericArgs_logFileCmdWithSpace_saveLogFilename) { +TEST_F( + GenericArgsParsingTests, + parseGenericArgs_logFileCmdWithSpace_saveLogFilename) { int i = 1; const int argc = 3; const char *kLogFileCmdWithSpace[argc] = {"stub", "--log", "mo ck_filename"}; @@ -217,8 +218,9 @@ TEST_F(GenericArgsParsingTests, parseGenericArgs_ipcCmd_enableIpcTrue) { } #ifndef WINAPI_XWINDOWS -TEST_F(GenericArgsParsingTests, - parseGenericArgs_dragDropCmdOnNonLinux_enableDragDropTrue) { +TEST_F( + GenericArgsParsingTests, + parseGenericArgs_dragDropCmdOnNonLinux_enableDragDropTrue) { int i = 1; const int argc = 2; const char *kDragDropCmd[argc] = {"stub", "--enable-drag-drop"}; @@ -231,8 +233,9 @@ TEST_F(GenericArgsParsingTests, #endif #ifdef WINAPI_XWINDOWS -TEST_F(GenericArgsParsingTests, - parseGenericArgs_dragDropCmdOnLinux_enableDragDropFalse) { +TEST_F( + GenericArgsParsingTests, + parseGenericArgs_dragDropCmdOnLinux_enableDragDropFalse) { int i = 1; const int argc = 2; const char *kDragDropCmd[argc] = {"stub", "--enable-drag-drop"}; diff --git a/src/test/unittests/synergy/KeyMapTests.cpp b/src/test/unittests/synergy/KeyMapTests.cpp index 320b19c64..4db3beb06 100644 --- a/src/test/unittests/synergy/KeyMapTests.cpp +++ b/src/test/unittests/synergy/KeyMapTests.cpp @@ -45,8 +45,9 @@ TEST(KeyMapTests, findBestKey_requiredDown_matchExactFirstItem) { EXPECT_EQ(0, keyMap.findBestKey(entryList, desiredState)); } -TEST(KeyMapTests, - findBestKey_requiredAndExtraSensitiveDown_matchExactFirstItem) { +TEST( + KeyMapTests, + findBestKey_requiredAndExtraSensitiveDown_matchExactFirstItem) { KeyMap keyMap; KeyMap::KeyEntryList entryList; KeyMap::KeyItemList itemList; @@ -60,8 +61,9 @@ TEST(KeyMapTests, EXPECT_EQ(0, keyMap.findBestKey(entryList, desiredState)); } -TEST(KeyMapTests, - findBestKey_requiredAndExtraSensitiveDown_matchExactSecondItem) { +TEST( + KeyMapTests, + findBestKey_requiredAndExtraSensitiveDown_matchExactSecondItem) { KeyMap keyMap; KeyMap::KeyEntryList entryList; KeyMap::KeyItemList itemList1; @@ -210,12 +212,14 @@ TEST(KeyMapTests, mapkey_handles_setmodifier_with_no_mapped) { KeyMap::ModifierToKeys activeModifiers{}; KeyModifierMask currentState{}; KeyModifierMask desiredMask{}; - auto result = keyMap.mapKey(strokes, kKeySetModifiers, 1, activeModifiers, - currentState, desiredMask, false, "en"); + auto result = keyMap.mapKey( + strokes, kKeySetModifiers, 1, activeModifiers, currentState, desiredMask, + false, "en"); EXPECT_FALSE(result == nullptr); desiredMask = KeyModifierControl; - result = keyMap.mapKey(strokes, kKeySetModifiers, 1, activeModifiers, - currentState, desiredMask, false, "en"); + result = keyMap.mapKey( + strokes, kKeySetModifiers, 1, activeModifiers, currentState, desiredMask, + false, "en"); EXPECT_TRUE(result == nullptr); } diff --git a/src/test/unittests/synergy/KeyStateTests.cpp b/src/test/unittests/synergy/KeyStateTests.cpp index 366dfd7eb..43e04760a 100644 --- a/src/test/unittests/synergy/KeyStateTests.cpp +++ b/src/test/unittests/synergy/KeyStateTests.cpp @@ -34,11 +34,11 @@ void stubPollPressedKeys(IKeyState::KeyButtonSet &pressedKeys); void assertMaskIsOne(ForeachKeyCallback cb, void *userData); -const synergy::KeyMap::KeyItem * -stubMapKey(synergy::KeyMap::Keystrokes &keys, KeyID id, SInt32 group, - synergy::KeyMap::ModifierToKeys &activeModifiers, - KeyModifierMask ¤tState, KeyModifierMask desiredMask, - bool isAutoRepeat, const String &lang); +const synergy::KeyMap::KeyItem *stubMapKey( + synergy::KeyMap::Keystrokes &keys, KeyID id, SInt32 group, + synergy::KeyMap::ModifierToKeys &activeModifiers, + KeyModifierMask ¤tState, KeyModifierMask desiredMask, + bool isAutoRepeat, const String &lang); synergy::KeyMap::Keystroke s_stubKeystroke(1, false, false); synergy::KeyMap::KeyItem s_stubKeyItem; @@ -466,11 +466,10 @@ void assertMaskIsOne(ForeachKeyCallback cb, void *userData) { ASSERT_EQ(1, ((KeyState::AddActiveModifierContext *)userData)->m_mask); } -const synergy::KeyMap::KeyItem *stubMapKey(synergy::KeyMap::Keystrokes &keys, - KeyID, SInt32, - synergy::KeyMap::ModifierToKeys &, - KeyModifierMask &, KeyModifierMask, - bool, const String &) { +const synergy::KeyMap::KeyItem *stubMapKey( + synergy::KeyMap::Keystrokes &keys, KeyID, SInt32, + synergy::KeyMap::ModifierToKeys &, KeyModifierMask &, KeyModifierMask, bool, + const String &) { keys.push_back(s_stubKeystroke); return &s_stubKeyItem; } diff --git a/src/test/unittests/synergy/ServerAppTests.cpp b/src/test/unittests/synergy/ServerAppTests.cpp index f24219c9b..cb37df5c7 100644 --- a/src/test/unittests/synergy/ServerAppTests.cpp +++ b/src/test/unittests/synergy/ServerAppTests.cpp @@ -41,8 +41,8 @@ TEST(ServerAppTests, runInner_will_handle_configuration_lifetime) { EXPECT_FALSE(app.args().m_config); const char *argv[]{"synergyc"}; - app.runInner(1, const_cast(argv), nullptr, - [](int, char **) { return 0; }); + app.runInner( + 1, const_cast(argv), nullptr, [](int, char **) { return 0; }); EXPECT_TRUE(app.args().m_config); } diff --git a/src/test/unittests/synergy/X11LayoutParserTests.cpp b/src/test/unittests/synergy/X11LayoutParserTests.cpp index a317f1351..32076baca 100644 --- a/src/test/unittests/synergy/X11LayoutParserTests.cpp +++ b/src/test/unittests/synergy/X11LayoutParserTests.cpp @@ -165,15 +165,18 @@ TEST(X11LayoutsParsingTests, xmlParsingIncorrectEvdevFileTest) { } TEST(X11LayoutsParsingTests, layoutConvertTest) { - EXPECT_EQ(X11LayoutsParser::convertLayotToISO(testDir + "/correctEvdev.xml", - "us", true), - "en"); - EXPECT_EQ(X11LayoutsParser::convertLayotToISO( - testDir + "/incorrectEvdev1.xml", "us", true), - ""); - EXPECT_EQ(X11LayoutsParser::convertLayotToISO( - testDir + "/evdevFromFuture.xml", "us", true), - ""); + EXPECT_EQ( + X11LayoutsParser::convertLayotToISO( + testDir + "/correctEvdev.xml", "us", true), + "en"); + EXPECT_EQ( + X11LayoutsParser::convertLayotToISO( + testDir + "/incorrectEvdev1.xml", "us", true), + ""); + EXPECT_EQ( + X11LayoutsParser::convertLayotToISO( + testDir + "/evdevFromFuture.xml", "us", true), + ""); } #endif diff --git a/src/test/unittests/synergy/languages/LanguageManagerTests.cpp b/src/test/unittests/synergy/languages/LanguageManagerTests.cpp index 2b57e33df..cfcc80039 100644 --- a/src/test/unittests/synergy/languages/LanguageManagerTests.cpp +++ b/src/test/unittests/synergy/languages/LanguageManagerTests.cpp @@ -24,8 +24,9 @@ TEST(LanguageManager, RemoteLanguagesTest) { synergy::languages::LanguageManager manager({"ru", "en", "uk"}); manager.setRemoteLanguages(remoteLanguages); - EXPECT_EQ((std::vector{"ru", "en", "uk"}), - manager.getRemoteLanguages()); + EXPECT_EQ( + (std::vector{"ru", "en", "uk"}), + manager.getRemoteLanguages()); manager.setRemoteLanguages(String()); EXPECT_TRUE(manager.getRemoteLanguages().empty()); @@ -35,8 +36,9 @@ TEST(LanguageManager, LocalLanguagesTest) { std::vector localLanguages = {"ru", "en", "uk"}; synergy::languages::LanguageManager manager(localLanguages); - EXPECT_EQ((std::vector{"ru", "en", "uk"}), - manager.getLocalLanguages()); + EXPECT_EQ( + (std::vector{"ru", "en", "uk"}), + manager.getLocalLanguages()); } TEST(LanguageManager, MissedLanguagesTest) {