Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libinputactions/config/ConfigLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
#include <libinputactions/input/backends/LibevdevComplementaryInputBackend.h>
#include <libinputactions/input/devices/InputDeviceRule.h>
#include <libinputactions/interfaces/NotificationManager.h>
#include <libinputactions/scripting/ScriptingEngine.h>
#include <libinputactions/scripting/modules/core/Config.h>
#include <libinputactions/scripting/modules/core/CoreModule.h>
#include <libinputactions/scripting/ScriptingEngine.h>

namespace InputActions
{
Expand Down
6 changes: 6 additions & 0 deletions src/libinputactions/dbus/IntegratedDBusInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <libinputactions/config/ConfigIssueManager.h>
#include <libinputactions/config/ConfigLoader.h>
#include <libinputactions/input/StrokeRecorder.h>
#include <libinputactions/input/backends/InputBackend.h>
#include <libinputactions/interfaces/OnScreenMessageManager.h>
#include <libinputactions/triggers/core/StrokeTriggerCore.h>
#include <libinputactions/variables/VariableRegistry.h>
Expand Down Expand Up @@ -54,6 +55,11 @@ QString IntegratedDBusInterface::issues()

void IntegratedDBusInterface::recordStroke(const QDBusMessage &message)
{
if (!g_inputBackend->initialized()) {
sendErrorReply(QDBusError::Failed, "Stroke recording requires a valid configuration to be active.");
return;
}

g_onScreenMessageManager->showMessage("InputActions is recording input. Perform a stroke gesture by moving the mouse or any amount of fingers in the one "
"direction on a touchpad or a touchscreen. Recording will end after 250 ms of inactivity.");

Expand Down
5 changes: 4 additions & 1 deletion src/libinputactions/dbus/IntegratedDBusInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "DBusInterfaceBase.h"
#include <QDBusConnection>
#include <QDBusContext>
#include <QDBusMessage>
#include <QObject>

Expand All @@ -29,7 +30,9 @@ namespace InputActions
static const QString INPUTACTIONS_DBUS_SERVICE = "org.inputactions";
static const QString INPUTACTIONS_DBUS_PATH = "/";

class IntegratedDBusInterface : public DBusInterfaceBase
class IntegratedDBusInterface
: public DBusInterfaceBase
, protected QDBusContext
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.inputactions")
Expand Down
5 changes: 5 additions & 0 deletions src/libinputactions/input/StrokeRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "StrokeRecorder.h"
#include "events.h"
#include <libinputactions/input/backends/InputBackend.h>
#include <libinputactions/input/devices/InputDevice.h>
#include <libinputactions/triggers/core/StrokeTriggerCore.h>

Expand All @@ -36,6 +37,10 @@ StrokeRecorder::StrokeRecorder()

void StrokeRecorder::recordStroke(const std::function<void(const Stroke &stroke)> &callback)
{
if (!g_inputBackend->initialized()) {
return;
}

m_isRecordingStroke = true;
m_strokeCallback = callback;
}
Expand Down
3 changes: 2 additions & 1 deletion src/libinputactions/input/StrokeRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class StrokeRecorder

/**
* @param callback Will be called when the stroke has been recorded.
* @remark Calling this when a stroke is already being recorded will result in the previous callback never being called.
* @remark Calling this when a stroke is already being recorded will result in the previous callback never being called. If the input backend is not
* initialized, this method does nothing.
*/
void recordStroke(const std::function<void(const Stroke &stroke)> &callback);

Expand Down
7 changes: 7 additions & 0 deletions src/libinputactions/input/backends/InputBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,15 @@ void InputBackend::applyDeviceProperties(const InputDevice *device, InputDeviceP
}
}

void InputBackend::initialize()
{
doInitialize();
m_initialized = true;
}

void InputBackend::reset()
{
m_initialized = false;
m_deviceRules.clear();
m_keyboardTriggerHandler = {};
m_mouseTriggerHandler = {};
Expand Down
5 changes: 4 additions & 1 deletion src/libinputactions/input/backends/InputBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,15 @@ class InputBackend : public QObject
/**
* Detects and adds devices.
*/
virtual void initialize() {}
void initialize();

/**
* Evaluates device rules for the specified device and returns the properties without modifying the device's properties. Use this for devices that have not
* been added to the backend yet, otherwise use InputDevice::properties().
*/
InputDeviceProperties deviceProperties(const InputDevice *device);

bool initialized() const { return m_initialized; }
std::vector<InputDevice *> devices();
/**
* Use in case the device is not provided by the compositor for some reason.
Expand Down Expand Up @@ -158,6 +159,7 @@ class InputBackend : public QObject
void setEmergencyCombination(std::set<KeyboardKey> value) { m_emergencyCombination = value; }

protected:
virtual void doInitialize() {}
virtual void removeDevice(const InputDevice *device);
void createEventHandlerChain();

Expand All @@ -169,6 +171,7 @@ private slots:
private:
void applyDeviceProperties(const InputDevice *device, InputDeviceProperties &properties);

bool m_initialized{};
std::vector<InputEventHandler *> m_eventHandlerChain;
std::vector<InputDevice *> m_devices;
InputDevice *m_currentTouchscreen{};
Expand Down
2 changes: 1 addition & 1 deletion src/libinputactions/scripting/modules/core/CoreModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

#include "CoreModule.h"
#include "Config.h"
#include <QJSEngine>
#include <libinputactions/input/backends/InputBackend.h>
#include <libinputactions/variables/VariableRegistry.h>
#include <QJSEngine>

namespace InputActions
{
Expand Down