chore: use const pointer / ref where possible

This commit is contained in:
sithlord48 2025-05-20 22:00:50 -04:00 committed by Nick Bolton
parent 9bdb4252e5
commit fe12972e83
34 changed files with 71 additions and 63 deletions

View file

@ -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) {

View file

@ -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);

View file

@ -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);

View file

@ -121,7 +121,7 @@ public:
//@}
private:
void output(ELevel priority, char *msg);
void output(ELevel priority, const char *msg);
private:
using OutputterList = std::list<ILogOutputter *>;

View file

@ -232,7 +232,7 @@ bool ArgParser::isArg(
return false;
}
void ArgParser::splitCommandString(std::string &command, std::vector<std::string> &argv)
void ArgParser::splitCommandString(const std::string &command, std::vector<std::string> &argv)
{
if (command.empty()) {
return;
@ -276,7 +276,7 @@ void ArgParser::splitCommandString(std::string &command, std::vector<std::string
argv.push_back(subString);
}
bool ArgParser::searchDoubleQuotes(std::string &command, size_t &left, size_t &right, size_t startPos)
bool ArgParser::searchDoubleQuotes(const std::string &command, size_t &left, size_t &right, size_t startPos)
{
bool result = false;
left = std::string::npos;

View file

@ -36,8 +36,8 @@ public:
static bool isArg(
int argi, int argc, const char *const *argv, const char *name1, const char *name2, int minRequiredParameters = 0
);
static void splitCommandString(std::string &command, std::vector<std::string> &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<std::string> &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<std::string> &argsArray);
static std::string

View file

@ -15,7 +15,7 @@
// IKeyState
//
IKeyState::IKeyState(IEventQueue *events)
IKeyState::IKeyState(const IEventQueue *events)
{
// do nothing
}

View file

@ -23,7 +23,7 @@ to synthesize key events.
class IKeyState : public IInterface
{
public:
explicit IKeyState(IEventQueue *events);
explicit IKeyState(const IEventQueue *events);
enum
{

View file

@ -28,7 +28,7 @@ public:
//! @name manipulators
//@{
explicit IPlatformScreen(IEventQueue *events) : IKeyState(events)
explicit IPlatformScreen(const IEventQueue *events) : IKeyState(events)
{
// do nothing
}

View file

@ -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)

View file

@ -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
);
};

View file

@ -23,7 +23,7 @@
#include "base/LogOutputters.h"
#include "common/Constants.h"
AppUtilUnix::AppUtilUnix(IEventQueue *events)
AppUtilUnix::AppUtilUnix(const IEventQueue *events)
{
// do nothing
}

View file

@ -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;

View file

@ -29,7 +29,7 @@ public:
std::string m_what;
};
explicit IDataSocket(IEventQueue *events)
explicit IDataSocket(const IEventQueue *events)
{
// do nothing
}

View file

@ -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_};

View file

@ -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

View file

@ -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");

View file

@ -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);

View file

@ -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];

View file

@ -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

View file

@ -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_);
}

View file

@ -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<EiScreen *>(ei_get_user_data(ei));
screen->handle_ei_log_event(ei, priority, message, context);
screen->handle_ei_log_event(priority, message);
}
private:

View file

@ -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;

View file

@ -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

View file

@ -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) {

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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));

View file

@ -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 &);

View file

@ -925,7 +925,7 @@ void Config::readSectionAliases(ConfigReadContext &s)
}
InputFilter::Condition *
Config::parseCondition(ConfigReadContext &s, const std::string &name, const std::vector<std::string> &args)
Config::parseCondition(const ConfigReadContext &s, const std::string &name, const std::vector<std::string> &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<std::string> &screens) const
void Config::parseScreens(const ConfigReadContext &c, const std::string &s, std::set<std::string> &screens) const
{
screens.clear();

View file

@ -468,13 +468,13 @@ private:
void readSectionAliases(ConfigReadContext &);
InputFilter::Condition *
parseCondition(ConfigReadContext &, const std::string &condition, const std::vector<std::string> &args);
parseCondition(const ConfigReadContext &, const std::string &condition, const std::vector<std::string> &args);
void parseAction(
ConfigReadContext &, const std::string &action, const std::vector<std::string> &args, InputFilter::Rule &,
bool activate
);
void parseScreens(ConfigReadContext &, const std::string &, std::set<std::string> &screens) const;
void parseScreens(const ConfigReadContext &, const std::string &, std::set<std::string> &screens) const;
static const char *getOptionName(OptionID);
static std::string getOptionValue(OptionID, OptionValue);

View file

@ -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)

View file

@ -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