From fe12972e83f5457f3f184866845d82b9af1a9515 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Tue, 20 May 2025 22:00:50 -0400 Subject: [PATCH] chore: use const pointer / ref where possible --- src/lib/arch/unix/ArchMultithreadPosix.cpp | 2 +- src/lib/arch/unix/ArchMultithreadPosix.h | 2 +- src/lib/base/Log.cpp | 2 +- src/lib/base/Log.h | 2 +- src/lib/deskflow/ArgParser.cpp | 4 ++-- src/lib/deskflow/ArgParser.h | 4 ++-- src/lib/deskflow/IKeyState.cpp | 2 +- src/lib/deskflow/IKeyState.h | 2 +- src/lib/deskflow/IPlatformScreen.h | 2 +- src/lib/deskflow/StreamChunker.cpp | 2 +- src/lib/deskflow/StreamChunker.h | 3 ++- src/lib/deskflow/unix/AppUtilUnix.cpp | 2 +- src/lib/deskflow/unix/AppUtilUnix.h | 2 +- src/lib/net/IDataSocket.h | 2 +- src/lib/net/SecureSocket.cpp | 2 +- src/lib/net/SecureSocket.h | 2 +- src/lib/net/SecureUtils.cpp | 2 +- src/lib/net/SecureUtils.h | 2 +- src/lib/platform/EiEventQueueBuffer.cpp | 4 +++- src/lib/platform/EiEventQueueBuffer.h | 2 +- src/lib/platform/EiScreen.cpp | 4 ++-- src/lib/platform/EiScreen.h | 7 ++++--- src/lib/platform/PortalInputCapture.cpp | 12 ++++++++---- src/lib/platform/PortalInputCapture.h | 8 ++++---- src/lib/platform/XWindowsClipboard.cpp | 2 +- src/lib/platform/XWindowsClipboard.h | 2 +- src/lib/platform/XWindowsKeyState.cpp | 2 +- src/lib/platform/XWindowsKeyState.h | 2 +- src/lib/platform/XWindowsScreen.cpp | 2 +- src/lib/platform/XWindowsScreen.h | 2 +- src/lib/server/Config.cpp | 4 ++-- src/lib/server/Config.h | 4 ++-- src/lib/server/Server.cpp | 18 +++++++++--------- src/lib/server/Server.h | 18 +++++++++--------- 34 files changed, 71 insertions(+), 63 deletions(-) diff --git a/src/lib/arch/unix/ArchMultithreadPosix.cpp b/src/lib/arch/unix/ArchMultithreadPosix.cpp index b27fc93f4..543c20730 100644 --- a/src/lib/arch/unix/ArchMultithreadPosix.cpp +++ b/src/lib/arch/unix/ArchMultithreadPosix.cpp @@ -599,7 +599,7 @@ void ArchMultithreadPosix::insert(ArchThreadImpl *thread) m_threadList.push_back(thread); } -void ArchMultithreadPosix::erase(ArchThreadImpl *thread) +void ArchMultithreadPosix::erase(const ArchThreadImpl *thread) { for (auto index = m_threadList.begin(); index != m_threadList.end(); ++index) { if (*index == thread) { diff --git a/src/lib/arch/unix/ArchMultithreadPosix.h b/src/lib/arch/unix/ArchMultithreadPosix.h index 1a99b2c85..6fd153c5c 100644 --- a/src/lib/arch/unix/ArchMultithreadPosix.h +++ b/src/lib/arch/unix/ArchMultithreadPosix.h @@ -84,7 +84,7 @@ private: ArchThreadImpl *find(pthread_t thread); ArchThreadImpl *findNoRef(pthread_t thread); void insert(ArchThreadImpl *thread); - void erase(ArchThreadImpl *thread); + void erase(const ArchThreadImpl *thread); void refThread(ArchThreadImpl *rep); void testCancelThreadImpl(ArchThreadImpl *rep); diff --git a/src/lib/base/Log.cpp b/src/lib/base/Log.cpp index 87c8ea1ea..f46481ae7 100644 --- a/src/lib/base/Log.cpp +++ b/src/lib/base/Log.cpp @@ -265,7 +265,7 @@ int Log::getFilter() const return m_maxPriority; } -void Log::output(ELevel priority, char *msg) +void Log::output(ELevel priority, const char *msg) { assert(priority >= -1 && priority < g_numPriority); assert(msg != nullptr); diff --git a/src/lib/base/Log.h b/src/lib/base/Log.h index 9ce2d51fd..d0b5277e1 100644 --- a/src/lib/base/Log.h +++ b/src/lib/base/Log.h @@ -121,7 +121,7 @@ public: //@} private: - void output(ELevel priority, char *msg); + void output(ELevel priority, const char *msg); private: using OutputterList = std::list; diff --git a/src/lib/deskflow/ArgParser.cpp b/src/lib/deskflow/ArgParser.cpp index 307193083..1875e583d 100644 --- a/src/lib/deskflow/ArgParser.cpp +++ b/src/lib/deskflow/ArgParser.cpp @@ -232,7 +232,7 @@ bool ArgParser::isArg( return false; } -void ArgParser::splitCommandString(std::string &command, std::vector &argv) +void ArgParser::splitCommandString(const std::string &command, std::vector &argv) { if (command.empty()) { return; @@ -276,7 +276,7 @@ void ArgParser::splitCommandString(std::string &command, std::vector &argv); - static bool searchDoubleQuotes(std::string &command, size_t &left, size_t &right, size_t startPos = 0); + static void splitCommandString(const std::string &command, std::vector &argv); + static bool searchDoubleQuotes(const std::string &command, size_t &left, size_t &right, size_t startPos = 0); static void removeDoubleQuotes(std::string &arg); static const char **getArgv(std::vector &argsArray); static std::string diff --git a/src/lib/deskflow/IKeyState.cpp b/src/lib/deskflow/IKeyState.cpp index 02b428d85..00bdc7589 100644 --- a/src/lib/deskflow/IKeyState.cpp +++ b/src/lib/deskflow/IKeyState.cpp @@ -15,7 +15,7 @@ // IKeyState // -IKeyState::IKeyState(IEventQueue *events) +IKeyState::IKeyState(const IEventQueue *events) { // do nothing } diff --git a/src/lib/deskflow/IKeyState.h b/src/lib/deskflow/IKeyState.h index 2dfca19af..2b57cafc4 100644 --- a/src/lib/deskflow/IKeyState.h +++ b/src/lib/deskflow/IKeyState.h @@ -23,7 +23,7 @@ to synthesize key events. class IKeyState : public IInterface { public: - explicit IKeyState(IEventQueue *events); + explicit IKeyState(const IEventQueue *events); enum { diff --git a/src/lib/deskflow/IPlatformScreen.h b/src/lib/deskflow/IPlatformScreen.h index 5cdd9ac3e..be0d56ba9 100644 --- a/src/lib/deskflow/IPlatformScreen.h +++ b/src/lib/deskflow/IPlatformScreen.h @@ -28,7 +28,7 @@ public: //! @name manipulators //@{ - explicit IPlatformScreen(IEventQueue *events) : IKeyState(events) + explicit IPlatformScreen(const IEventQueue *events) : IKeyState(events) { // do nothing } diff --git a/src/lib/deskflow/StreamChunker.cpp b/src/lib/deskflow/StreamChunker.cpp index f54c447aa..b57354fc9 100644 --- a/src/lib/deskflow/StreamChunker.cpp +++ b/src/lib/deskflow/StreamChunker.cpp @@ -23,7 +23,7 @@ using namespace std; static const size_t g_chunkSize = 512 * 1024; // 512kb void StreamChunker::sendClipboard( - std::string &data, size_t size, ClipboardID id, uint32_t sequence, IEventQueue *events, void *eventTarget + const std::string &data, size_t size, ClipboardID id, uint32_t sequence, IEventQueue *events, void *eventTarget ) { // send first message (data size) diff --git a/src/lib/deskflow/StreamChunker.h b/src/lib/deskflow/StreamChunker.h index afaf468d4..b1ef45968 100644 --- a/src/lib/deskflow/StreamChunker.h +++ b/src/lib/deskflow/StreamChunker.h @@ -16,6 +16,7 @@ class StreamChunker { public: static void sendClipboard( - std::string &data, size_t size, ClipboardID id, uint32_t sequence, IEventQueue *events, void *eventTarget + const std::string_view &data, size_t size, ClipboardID id, uint32_t sequence, IEventQueue *events, + void *eventTarget ); }; diff --git a/src/lib/deskflow/unix/AppUtilUnix.cpp b/src/lib/deskflow/unix/AppUtilUnix.cpp index c4e3adb41..530597d43 100644 --- a/src/lib/deskflow/unix/AppUtilUnix.cpp +++ b/src/lib/deskflow/unix/AppUtilUnix.cpp @@ -23,7 +23,7 @@ #include "base/LogOutputters.h" #include "common/Constants.h" -AppUtilUnix::AppUtilUnix(IEventQueue *events) +AppUtilUnix::AppUtilUnix(const IEventQueue *events) { // do nothing } diff --git a/src/lib/deskflow/unix/AppUtilUnix.h b/src/lib/deskflow/unix/AppUtilUnix.h index e5a703c1a..d70d9a241 100644 --- a/src/lib/deskflow/unix/AppUtilUnix.h +++ b/src/lib/deskflow/unix/AppUtilUnix.h @@ -16,7 +16,7 @@ class IEventQueue; class AppUtilUnix : public AppUtil { public: - explicit AppUtilUnix(IEventQueue *events); + explicit AppUtilUnix(const IEventQueue *events); ~AppUtilUnix() override = default; int run(int argc, char **argv) override; diff --git a/src/lib/net/IDataSocket.h b/src/lib/net/IDataSocket.h index 19e762310..17668c001 100644 --- a/src/lib/net/IDataSocket.h +++ b/src/lib/net/IDataSocket.h @@ -29,7 +29,7 @@ public: std::string m_what; }; - explicit IDataSocket(IEventQueue *events) + explicit IDataSocket(const IEventQueue *events) { // do nothing } diff --git a/src/lib/net/SecureSocket.cpp b/src/lib/net/SecureSocket.cpp index a284f7edf..ac0838a24 100644 --- a/src/lib/net/SecureSocket.cpp +++ b/src/lib/net/SecureSocket.cpp @@ -305,7 +305,7 @@ void SecureSocket::initSsl(bool server) initContext(server); } -bool SecureSocket::loadCertificates(std::string &filename) +bool SecureSocket::loadCertificates(const std::string &filename) { std::lock_guard ssl_lock{ssl_mutex_}; diff --git a/src/lib/net/SecureSocket.h b/src/lib/net/SecureSocket.h index 22bbd6959..eb4fb884a 100644 --- a/src/lib/net/SecureSocket.h +++ b/src/lib/net/SecureSocket.h @@ -65,7 +65,7 @@ public: EJobResult doRead() override; EJobResult doWrite() override; void initSsl(bool server); - bool loadCertificates(std::string &CertFile); + bool loadCertificates(const std::string &CertFile); private: // SSL diff --git a/src/lib/net/SecureUtils.cpp b/src/lib/net/SecureUtils.cpp index c678b1a94..74f7a8c11 100644 --- a/src/lib/net/SecureUtils.cpp +++ b/src/lib/net/SecureUtils.cpp @@ -46,7 +46,7 @@ QString formatSSLFingerprint(const QByteArray &fingerprint, bool enableSeparator return fingerprint.toHex().toUpper(); } -Fingerprint sslCertFingerprint(X509 *cert, Fingerprint::Type type) +Fingerprint sslCertFingerprint(const X509 *cert, Fingerprint::Type type) { if (!cert) { throw std::runtime_error("certificate is null"); diff --git a/src/lib/net/SecureUtils.h b/src/lib/net/SecureUtils.h index a448d45d9..07ccb2d54 100644 --- a/src/lib/net/SecureUtils.h +++ b/src/lib/net/SecureUtils.h @@ -26,7 +26,7 @@ QString formatSSLFingerprint(const QByteArray &fingerprint, bool enableSeparator QString formatSSLFingerprintColumns(const QByteArray &fingerprint); -Fingerprint sslCertFingerprint(X509 *cert, Fingerprint::Type type); +Fingerprint sslCertFingerprint(const X509 *cert, Fingerprint::Type type); Fingerprint pemFileCertFingerprint(const std::string &path, Fingerprint::Type type); diff --git a/src/lib/platform/EiEventQueueBuffer.cpp b/src/lib/platform/EiEventQueueBuffer.cpp index 9d8719707..5242f29b6 100644 --- a/src/lib/platform/EiEventQueueBuffer.cpp +++ b/src/lib/platform/EiEventQueueBuffer.cpp @@ -25,7 +25,9 @@ class EventQueueTimer namespace deskflow { -EiEventQueueBuffer::EiEventQueueBuffer(EiScreen *screen, ei *ei, IEventQueue *events) : ei_(ei_ref(ei)), events_(events) +EiEventQueueBuffer::EiEventQueueBuffer(const EiScreen *screen, ei *ei, IEventQueue *events) + : ei_(ei_ref(ei)), + events_(events) { // We need a pipe to signal ourselves when addEvent() is called int pipefd[2]; diff --git a/src/lib/platform/EiEventQueueBuffer.h b/src/lib/platform/EiEventQueueBuffer.h index 554587151..7375bec2a 100644 --- a/src/lib/platform/EiEventQueueBuffer.h +++ b/src/lib/platform/EiEventQueueBuffer.h @@ -23,7 +23,7 @@ namespace deskflow { class EiEventQueueBuffer : public IEventQueueBuffer { public: - EiEventQueueBuffer(EiScreen *screen, ei *ei, IEventQueue *events); + EiEventQueueBuffer(const EiScreen *screen, ei *ei, IEventQueue *events); ~EiEventQueueBuffer() override; // IEventQueueBuffer overrides diff --git a/src/lib/platform/EiScreen.cpp b/src/lib/platform/EiScreen.cpp index 399d585ee..f9ddbcc11 100644 --- a/src/lib/platform/EiScreen.cpp +++ b/src/lib/platform/EiScreen.cpp @@ -91,7 +91,7 @@ EiScreen::~EiScreen() delete portal_input_capture_; } -void EiScreen::handle_ei_log_event(ei *ei, ei_log_priority priority, const char *message, ei_log_context *context) const +void EiScreen::handle_ei_log_event(ei_log_priority priority, const char *message) const { switch (priority) { case EI_LOG_PRIORITY_DEBUG: @@ -693,7 +693,7 @@ void EiScreen::on_motion_event(ei_event *event) } } -void EiScreen::on_abs_motion_event(ei_event *event) const +void EiScreen::on_abs_motion_event(const ei_event *event) const { assert(is_primary_); } diff --git a/src/lib/platform/EiScreen.h b/src/lib/platform/EiScreen.h index fa89cfc00..73e51b25f 100644 --- a/src/lib/platform/EiScreen.h +++ b/src/lib/platform/EiScreen.h @@ -96,16 +96,17 @@ private: void on_pointer_scroll_event(ei_event *event); void on_pointer_scroll_discrete_event(ei_event *event); void on_motion_event(ei_event *event); - void on_abs_motion_event(ei_event *event) const; + void on_abs_motion_event(const ei_event *event) const; bool on_hotkey(KeyID key, bool is_press, KeyModifierMask mask); - void handle_ei_log_event(ei *ei, ei_log_priority priority, const char *message, ei_log_context *context) const; + void handle_ei_log_event(ei_log_priority priority, const char *message) const; + void handle_connected_to_eis_event(const Event &event, void *); void handle_portal_session_closed(const Event &event, void *); static void cb_handle_ei_log_event(ei *ei, ei_log_priority priority, const char *message, ei_log_context *context) { auto screen = reinterpret_cast(ei_get_user_data(ei)); - screen->handle_ei_log_event(ei, priority, message, context); + screen->handle_ei_log_event(priority, message); } private: diff --git a/src/lib/platform/PortalInputCapture.cpp b/src/lib/platform/PortalInputCapture.cpp index 5cb6b4b02..c800e6395 100644 --- a/src/lib/platform/PortalInputCapture.cpp +++ b/src/lib/platform/PortalInputCapture.cpp @@ -161,7 +161,7 @@ void PortalInputCapture::cb_init_input_capture_session(GObject *object, GAsyncRe cb_zones_changed(session_, nullptr); } -void PortalInputCapture::cb_set_pointer_barriers(GObject *object, GAsyncResult *res) +void PortalInputCapture::cb_set_pointer_barriers(const GObject *object, GAsyncResult *res) { g_autoptr(GError) error = nullptr; @@ -244,7 +244,7 @@ void PortalInputCapture::release(double x, double y) is_active_ = false; } -void PortalInputCapture::cb_disabled(XdpInputCaptureSession *session, GVariant *option) +void PortalInputCapture::cb_disabled(const XdpInputCaptureSession *session, const GVariant *option) { LOG_DEBUG("portal cb disabled"); @@ -269,7 +269,9 @@ void PortalInputCapture::cb_disabled(XdpInputCaptureSession *session, GVariant * ); } -void PortalInputCapture::cb_activated(XdpInputCaptureSession *session, std::uint32_t activation_id, GVariant *options) +void PortalInputCapture::cb_activated( + const XdpInputCaptureSession *session, std::uint32_t activation_id, GVariant *options +) { LOG_DEBUG("portal cb activated, id=%d", activation_id); @@ -288,7 +290,9 @@ void PortalInputCapture::cb_activated(XdpInputCaptureSession *session, std::uint is_active_ = true; } -void PortalInputCapture::cb_deactivated(XdpInputCaptureSession *session, std::uint32_t activation_id, GVariant *options) +void PortalInputCapture::cb_deactivated( + const XdpInputCaptureSession *session, std::uint32_t activation_id, const GVariant *options +) { LOG_DEBUG("cb deactivated, id=%i", activation_id); is_active_ = false; diff --git a/src/lib/platform/PortalInputCapture.h b/src/lib/platform/PortalInputCapture.h index b01cc51ab..0fc84fac6 100644 --- a/src/lib/platform/PortalInputCapture.h +++ b/src/lib/platform/PortalInputCapture.h @@ -37,11 +37,11 @@ private: gboolean timeout_handler() const; gboolean init_input_capture_session(); void cb_init_input_capture_session(GObject *object, GAsyncResult *res); - void cb_set_pointer_barriers(GObject *object, GAsyncResult *res); + void cb_set_pointer_barriers(const GObject *object, GAsyncResult *res); void cb_session_closed(XdpSession *session); - void cb_disabled(XdpInputCaptureSession *session, GVariant *option); - void cb_activated(XdpInputCaptureSession *session, std::uint32_t activation_id, GVariant *options); - void cb_deactivated(XdpInputCaptureSession *session, std::uint32_t activation_id, GVariant *options); + void cb_disabled(const XdpInputCaptureSession *session, const GVariant *option); + void cb_activated(const XdpInputCaptureSession *session, std::uint32_t activation_id, GVariant *options); + void cb_deactivated(const XdpInputCaptureSession *session, std::uint32_t activation_id, const GVariant *options); void cb_zones_changed(XdpInputCaptureSession *session, GVariant *options); /// g_signal_connect callback wrapper diff --git a/src/lib/platform/XWindowsClipboard.cpp b/src/lib/platform/XWindowsClipboard.cpp index 1070129b1..8ced66459 100644 --- a/src/lib/platform/XWindowsClipboard.cpp +++ b/src/lib/platform/XWindowsClipboard.cpp @@ -1254,7 +1254,7 @@ bool XWindowsClipboard::CICCCMGetClipboard::readClipboard( return !m_failed; } -bool XWindowsClipboard::CICCCMGetClipboard::processEvent(Display *display, XEvent *xevent) +bool XWindowsClipboard::CICCCMGetClipboard::processEvent(Display *display, const XEvent *xevent) { // process event switch (xevent->type) { diff --git a/src/lib/platform/XWindowsClipboard.h b/src/lib/platform/XWindowsClipboard.h index 949e5a187..a7bafac17 100644 --- a/src/lib/platform/XWindowsClipboard.h +++ b/src/lib/platform/XWindowsClipboard.h @@ -138,7 +138,7 @@ protected: bool readClipboard(Display *display, Atom selection, Atom target, Atom *actualTarget, std::string *data); private: - bool processEvent(Display *display, XEvent *event); + bool processEvent(Display *display, const XEvent *event); private: Window m_requestor; diff --git a/src/lib/platform/XWindowsKeyState.cpp b/src/lib/platform/XWindowsKeyState.cpp index 88fd1812a..5e6f3b72f 100644 --- a/src/lib/platform/XWindowsKeyState.cpp +++ b/src/lib/platform/XWindowsKeyState.cpp @@ -65,7 +65,7 @@ XWindowsKeyState::~XWindowsKeyState() #endif } -void XWindowsKeyState::init(Display *display, bool useXKB) +void XWindowsKeyState::init(const Display *display, bool useXKB) { XGetKeyboardControl(m_display, &m_keyboardState); #if HAVE_XKB_EXTENSION diff --git a/src/lib/platform/XWindowsKeyState.h b/src/lib/platform/XWindowsKeyState.h index a7e9fb531..095369a7b 100644 --- a/src/lib/platform/XWindowsKeyState.h +++ b/src/lib/platform/XWindowsKeyState.h @@ -105,7 +105,7 @@ protected: void fakeKey(const Keystroke &keystroke) override; private: - void init(Display *display, bool useXKB); + void init(const Display *display, bool useXKB); void updateKeysymMap(deskflow::KeyMap &); void updateKeysymMapXKB(deskflow::KeyMap &); bool hasModifiersXKB() const; diff --git a/src/lib/platform/XWindowsScreen.cpp b/src/lib/platform/XWindowsScreen.cpp index c3efc68b6..020608cbe 100644 --- a/src/lib/platform/XWindowsScreen.cpp +++ b/src/lib/platform/XWindowsScreen.cpp @@ -1480,7 +1480,7 @@ void XWindowsScreen::onKeyRelease(XKeyEvent &xkey, bool isRepeat) } } -bool XWindowsScreen::onHotKey(XKeyEvent &xkey, bool isRepeat) +bool XWindowsScreen::onHotKey(const XKeyEvent &xkey, bool isRepeat) { // find the hot key id HotKeyToIDMap::const_iterator i = m_hotKeyToIDMap.find(HotKeyItem(xkey.keycode, xkey.state)); diff --git a/src/lib/platform/XWindowsScreen.h b/src/lib/platform/XWindowsScreen.h index a359c9dff..2ded3f631 100644 --- a/src/lib/platform/XWindowsScreen.h +++ b/src/lib/platform/XWindowsScreen.h @@ -128,7 +128,7 @@ private: bool grabMouseAndKeyboard(); void onKeyPress(XKeyEvent &); void onKeyRelease(XKeyEvent &, bool isRepeat); - bool onHotKey(XKeyEvent &, bool isRepeat); + bool onHotKey(const XKeyEvent &, bool isRepeat); void onMousePress(const XButtonEvent &); void onMouseRelease(const XButtonEvent &); void onMouseMove(const XMotionEvent &); diff --git a/src/lib/server/Config.cpp b/src/lib/server/Config.cpp index d8b90621d..aaf24324d 100644 --- a/src/lib/server/Config.cpp +++ b/src/lib/server/Config.cpp @@ -925,7 +925,7 @@ void Config::readSectionAliases(ConfigReadContext &s) } InputFilter::Condition * -Config::parseCondition(ConfigReadContext &s, const std::string &name, const std::vector &args) +Config::parseCondition(const ConfigReadContext &s, const std::string &name, const std::vector &args) { if (name == "keystroke") { if (args.size() != 1) { @@ -1147,7 +1147,7 @@ void Config::parseAction( rule.adoptAction(action, activate); } -void Config::parseScreens(ConfigReadContext &c, const std::string &s, std::set &screens) const +void Config::parseScreens(const ConfigReadContext &c, const std::string &s, std::set &screens) const { screens.clear(); diff --git a/src/lib/server/Config.h b/src/lib/server/Config.h index 1d9c4ee65..4fd8df886 100644 --- a/src/lib/server/Config.h +++ b/src/lib/server/Config.h @@ -468,13 +468,13 @@ private: void readSectionAliases(ConfigReadContext &); InputFilter::Condition * - parseCondition(ConfigReadContext &, const std::string &condition, const std::vector &args); + parseCondition(const ConfigReadContext &, const std::string &condition, const std::vector &args); void parseAction( ConfigReadContext &, const std::string &action, const std::vector &args, InputFilter::Rule &, bool activate ); - void parseScreens(ConfigReadContext &, const std::string &, std::set &screens) const; + void parseScreens(const ConfigReadContext &, const std::string &, std::set &screens) const; static const char *getOptionName(OptionID); static std::string getOptionValue(OptionID, OptionValue); diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index 9b934aa76..e931752d2 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -386,7 +386,7 @@ bool Server::isLockedToScreen() const return false; } -int32_t Server::getJumpZoneSize(BaseClientProxy *client) const +int32_t Server::getJumpZoneSize(const BaseClientProxy *client) const { if (client == m_primaryClient) { return m_primaryClient->getJumpZoneSize(); @@ -525,7 +525,7 @@ void Server::jumpToScreen(BaseClientProxy *newScreen) switchScreen(newScreen, x, y, false); } -float Server::mapToFraction(BaseClientProxy *client, EDirection dir, int32_t x, int32_t y) const +float Server::mapToFraction(const BaseClientProxy *client, EDirection dir, int32_t x, int32_t y) const { int32_t sx; int32_t sy; @@ -548,7 +548,7 @@ float Server::mapToFraction(BaseClientProxy *client, EDirection dir, int32_t x, return 0.0f; } -void Server::mapToPixel(BaseClientProxy *client, EDirection dir, float f, int32_t &x, int32_t &y) const +void Server::mapToPixel(const BaseClientProxy *client, EDirection dir, float f, int32_t &x, int32_t &y) const { int32_t sx; int32_t sy; @@ -572,14 +572,14 @@ void Server::mapToPixel(BaseClientProxy *client, EDirection dir, float f, int32_ } } -bool Server::hasAnyNeighbor(BaseClientProxy *client, EDirection dir) const +bool Server::hasAnyNeighbor(const BaseClientProxy *client, EDirection dir) const { assert(client != nullptr); return m_config->hasNeighbor(getName(client), dir); } -BaseClientProxy *Server::getNeighbor(BaseClientProxy *src, EDirection dir, int32_t &x, int32_t &y) const +BaseClientProxy *Server::getNeighbor(const BaseClientProxy *src, EDirection dir, int32_t &x, int32_t &y) const { // note -- must be locked on entry @@ -732,7 +732,7 @@ BaseClientProxy *Server::mapToNeighbor(BaseClientProxy *src, EDirection srcSide, return dst; } -void Server::avoidJumpZone(BaseClientProxy *dst, EDirection dir, int32_t &x, int32_t &y) const +void Server::avoidJumpZone(const BaseClientProxy *dst, EDirection dir, int32_t &x, int32_t &y) const { // we only need to avoid jump zones on the primary screen if (dst != m_primaryClient) { @@ -981,7 +981,7 @@ bool Server::isSwitchWaitStarted() const return (m_switchWaitTimer != nullptr); } -uint32_t Server::getCorner(BaseClientProxy *client, int32_t x, int32_t y, int32_t size) const +uint32_t Server::getCorner(const BaseClientProxy *client, int32_t x, int32_t y, int32_t size) const { assert(client != nullptr); @@ -1447,7 +1447,7 @@ void Server::handleFakeInputEndEvent(const Event &, void *) m_primaryClient->fakeInputEnd(); } -void Server::onClipboardChanged(BaseClientProxy *sender, ClipboardID id, uint32_t seqNum) +void Server::onClipboardChanged(const BaseClientProxy *sender, ClipboardID id, uint32_t seqNum) { ClipboardInfo &clipboard = m_clipboards[id]; @@ -2040,7 +2040,7 @@ void Server::removeOldClient(BaseClientProxy *client) } } -void Server::forceLeaveClient(BaseClientProxy *client) +void Server::forceLeaveClient(const BaseClientProxy *client) { if (BaseClientProxy *active = (m_activeSaver != nullptr) ? m_activeSaver : m_active; active == client) { // record new position (center of primary screen) diff --git a/src/lib/server/Server.h b/src/lib/server/Server.h index 1e959175a..6365c6148 100644 --- a/src/lib/server/Server.h +++ b/src/lib/server/Server.h @@ -204,7 +204,7 @@ private: bool isLockedToScreen() const; // returns the jump zone of the client - int32_t getJumpZoneSize(BaseClientProxy *) const; + int32_t getJumpZoneSize(const BaseClientProxy *) const; // change the active screen void switchScreen(BaseClientProxy *, int32_t x, int32_t y, bool forScreenSaver); @@ -214,19 +214,19 @@ private: // convert pixel position to fraction, using x or y depending on the // direction. - float mapToFraction(BaseClientProxy *, EDirection, int32_t x, int32_t y) const; + float mapToFraction(const BaseClientProxy *, EDirection, int32_t x, int32_t y) const; // convert fraction to pixel position, writing only x or y depending // on the direction. - void mapToPixel(BaseClientProxy *, EDirection, float f, int32_t &x, int32_t &y) const; + void mapToPixel(const BaseClientProxy *, EDirection, float f, int32_t &x, int32_t &y) const; // returns true if the client has a neighbor anywhere along the edge // indicated by the direction. - bool hasAnyNeighbor(BaseClientProxy *, EDirection) const; + bool hasAnyNeighbor(const BaseClientProxy *, EDirection) const; // lookup neighboring screen, mapping the coordinate independent of // the direction to the neighbor's coordinate space. - BaseClientProxy *getNeighbor(BaseClientProxy *, EDirection, int32_t &x, int32_t &y) const; + BaseClientProxy *getNeighbor(const BaseClientProxy *, EDirection, int32_t &x, int32_t &y) const; // lookup neighboring screen. given a position relative to the // source screen, find the screen we should move onto and where. @@ -237,7 +237,7 @@ private: // adjusts x and y or neither to avoid ending up in a jump zone // after entering the client in the given direction. - void avoidJumpZone(BaseClientProxy *, EDirection, int32_t &x, int32_t &y) const; + void avoidJumpZone(const BaseClientProxy *, EDirection, int32_t &x, int32_t &y) const; // test if a switch is permitted. this includes testing user // options like switch delay and tracking any state required to @@ -277,7 +277,7 @@ private: // returns the corner (EScreenSwitchCornerMasks) where x,y is on the // given client. corners have the given size. - uint32_t getCorner(BaseClientProxy *, int32_t x, int32_t y, int32_t size) const; + uint32_t getCorner(const BaseClientProxy *, int32_t x, int32_t y, int32_t size) const; // stop relative mouse moves void stopRelativeMoves(); @@ -313,7 +313,7 @@ private: void handleFakeInputEndEvent(const Event &, void *); // event processing - void onClipboardChanged(BaseClientProxy *sender, ClipboardID id, uint32_t seqNum); + void onClipboardChanged(const BaseClientProxy *sender, ClipboardID id, uint32_t seqNum); void onScreensaver(bool activated); void onKeyDown(KeyID, KeyModifierMask, KeyButton, const std::string &, const char *screens); void onKeyUp(KeyID, KeyModifierMask, KeyButton, const char *screens); @@ -345,7 +345,7 @@ private: void removeOldClient(BaseClientProxy *); // force the cursor off of \p client - void forceLeaveClient(BaseClientProxy *client); + void forceLeaveClient(const BaseClientProxy *client); private: class ClipboardInfo