diff --git a/libinput/context.cpp b/libinput/context.cpp index 1e2e3f99c4..a5fd7ccb84 100644 --- a/libinput/context.cpp +++ b/libinput/context.cpp @@ -19,6 +19,7 @@ along with this program. If not, see . *********************************************************************/ #include "context.h" #include "events.h" +#include "libinput_logging.h" #include "../logind.h" #include "../udev.h" @@ -31,10 +32,33 @@ namespace KWin namespace LibInput { +static void libinputLogHandler(libinput *libinput, libinput_log_priority priority, const char *format, va_list args) +{ + Q_UNUSED(libinput) + char buf[1024]; + if (std::vsnprintf(buf, 1023, format, args) <= 0) { + return; + } + switch (priority) { + case LIBINPUT_LOG_PRIORITY_DEBUG: + qCDebug(KWIN_LIBINPUT) << "Libinput:" << buf; + break; + case LIBINPUT_LOG_PRIORITY_INFO: + qCInfo(KWIN_LIBINPUT) << "Libinput:" << buf; + break; + case LIBINPUT_LOG_PRIORITY_ERROR: + default: + qCCritical(KWIN_LIBINPUT) << "Libinput:" << buf; + break; + } +} + Context::Context(const Udev &udev) : m_libinput(libinput_udev_create_context(&Context::s_interface, this, udev)) , m_suspended(false) { + libinput_log_set_priority(m_libinput, LIBINPUT_LOG_PRIORITY_DEBUG); + libinput_log_set_handler(m_libinput, &libinputLogHandler); } Context::~Context()