diff --git a/patch.txt b/patch.txt new file mode 100644 index 00000000..6c79b0fb --- /dev/null +++ b/patch.txt @@ -0,0 +1,84 @@ +diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp +index 8b4ba0ee..e34aa54b 100644 +--- a/src/managers/PointerManager.cpp ++++ b/src/managers/PointerManager.cpp +@@ -4,6 +4,7 @@ + #include "../protocols/PointerGestures.hpp" + #include "../protocols/FractionalScale.hpp" + #include "../protocols/core/Compositor.hpp" ++#include "eventLoop/EventLoopManager.hpp" + #include "SeatManager.hpp" + #include + #include +@@ -139,8 +140,8 @@ CPointerManager::CPointerManager() { + + onMonitorLayoutChange(); + +- PMONITOR->events.modeChanged.registerStaticListener([this](void* owner, std::any data) { onMonitorLayoutChange(); }, nullptr); +- PMONITOR->events.disconnect.registerStaticListener([this](void* owner, std::any data) { onMonitorLayoutChange(); }, nullptr); ++ PMONITOR->events.modeChanged.registerStaticListener([this](void* owner, std::any data) { g_pEventLoopManager->doLater([this]() { onMonitorLayoutChange(); }); }, nullptr); ++ PMONITOR->events.disconnect.registerStaticListener([this](void* owner, std::any data) { g_pEventLoopManager->doLater([this]() { onMonitorLayoutChange(); }); }, nullptr); + PMONITOR->events.destroy.registerStaticListener( + [this](void* owner, std::any data) { + if (g_pCompositor && !g_pCompositor->m_bIsShuttingDown) +diff --git a/src/managers/eventLoop/EventLoopManager.cpp b/src/managers/eventLoop/EventLoopManager.cpp +index 1193ffb8..e2d72f22 100644 +--- a/src/managers/eventLoop/EventLoopManager.cpp ++++ b/src/managers/eventLoop/EventLoopManager.cpp +@@ -86,4 +86,25 @@ void CEventLoopManager::nudgeTimers() { + itimerspec ts = {.it_value = now}; + + timerfd_settime(m_sTimers.timerfd, TFD_TIMER_ABSTIME, &ts, nullptr); +-} +\ No newline at end of file ++} ++ ++void CEventLoopManager::doLater(const std::function& fn) { ++ m_sIdle.fns.emplace_back(fn); ++ ++ if (m_sIdle.eventSource) ++ return; ++ ++ m_sIdle.eventSource = wl_event_loop_add_idle( ++ m_sWayland.loop, ++ [](void* data) { ++ auto IDLE = (CEventLoopManager::SIdleData*)data; ++ auto cpy = IDLE->fns; ++ IDLE->fns.clear(); ++ IDLE->eventSource = nullptr; ++ for (auto& c : cpy) { ++ if (c) ++ c(); ++ } ++ }, ++ &m_sIdle); ++} +diff --git a/src/managers/eventLoop/EventLoopManager.hpp b/src/managers/eventLoop/EventLoopManager.hpp +index 7a4fa19e..77e57513 100644 +--- a/src/managers/eventLoop/EventLoopManager.hpp ++++ b/src/managers/eventLoop/EventLoopManager.hpp +@@ -23,6 +23,14 @@ class CEventLoopManager { + // recalculates timers + void nudgeTimers(); + ++ // schedules a function to run later, aka in a wayland idle event. ++ void doLater(const std::function& fn); ++ ++ struct SIdleData { ++ wl_event_source* eventSource = nullptr; ++ std::vector> fns; ++ }; ++ + private: + struct { + wl_event_loop* loop = nullptr; +@@ -34,6 +42,8 @@ class CEventLoopManager { + std::vector> timers; + int timerfd = -1; + } m_sTimers; ++ ++ SIdleData m_sIdle; + }; + + inline std::unique_ptr g_pEventLoopManager; +\ No newline at end of file diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 2784c173..e5617ded 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -318,6 +318,50 @@ void CCompositor::initAllSignals() { g_pInputManager->newSwitch(dev); }, nullptr); + + m_pAqBackend->events.newTablet.registerStaticListener( + [](void* data, std::any d) { + auto dev = std::any_cast>(d); + Debug::log(LOG, "New aquamarine tablet with name {}", dev->getName()); + g_pInputManager->newTablet(dev); + }, + nullptr); + + m_pAqBackend->events.newTabletPad.registerStaticListener( + [](void* data, std::any d) { + auto dev = std::any_cast>(d); + Debug::log(LOG, "New aquamarine tablet pad with name {}", dev->getName()); + g_pInputManager->newTabletPad(dev); + }, + nullptr); + + if (m_pAqBackend->hasSession()) { + m_pAqBackend->session->events.changeActive.registerStaticListener( + [this](void*, std::any) { + if (m_pAqBackend->session->active) { + Debug::log(LOG, "Session got activated!"); + + m_bSessionActive = true; + + for (auto& m : m_vMonitors) { + scheduleFrameForMonitor(m.get()); + g_pHyprRenderer->applyMonitorRule(m.get(), &m->activeMonitorRule, true); + } + + g_pConfigManager->m_bWantsMonitorReload = true; + } else { + Debug::log(LOG, "Session got deactivated!"); + + m_bSessionActive = false; + + for (auto& m : m_vMonitors) { + m->noFrameSchedule = true; + m->framesToSkip = 1; + } + } + }, + nullptr); + } } void CCompositor::removeAllSignals() { @@ -2293,9 +2337,8 @@ void CCompositor::updateWorkspaceSpecialRenderData(const int& id) { } void CCompositor::scheduleFrameForMonitor(CMonitor* pMonitor) { - // FIXME: - // if ((m_sWLRSession && !m_sWLRSession->active) || !m_bSessionActive) - // return; + if ((m_pAqBackend->hasSession() && !m_pAqBackend->session->active) || !m_bSessionActive) + return; if (!pMonitor->m_bEnabled) return; @@ -2858,7 +2901,7 @@ void CCompositor::onNewMonitor(SP output) { auto PNEWMONITOR = g_pCompositor->m_vRealMonitors.emplace_back(makeShared()); if (std::string("HEADLESS-1") == output->name) { g_pCompositor->m_pUnsafeOutput = PNEWMONITOR.get(); - output->name = "FALLBACK"; // we are allowed to do this :) + output->name = "FALLBACK"; // we are allowed to do this :) } Debug::log(LOG, "New output with name {}", output->name); diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index ebc5f6d1..3cd09b1b 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -597,9 +597,8 @@ std::string devicesRequest(eHyprCtlOutputFormat format, std::string request) { R"#( {{ "address": "0x{:x}", "type": "tabletTool", - "belongsTo": "0x{:x}" }},)#", - (uintptr_t)d.get(), d->wlr() ? (uintptr_t)d->wlr()->data : 0); + (uintptr_t)d.get()); } trimTrailingComma(result); @@ -659,11 +658,11 @@ std::string devicesRequest(eHyprCtlOutputFormat format, std::string request) { } for (auto& d : g_pInputManager->m_vTablets) { - result += std::format("\tTablet at {:x}:\n\t\t{}\n\t\t\tsize: {}x{}mm\n", (uintptr_t)d.get(), d->hlName, d->wlr()->width_mm, d->wlr()->height_mm); + result += std::format("\tTablet at {:x}:\n\t\t{}\n\t\t\tsize: {}x{}mm\n", (uintptr_t)d.get(), d->hlName, d->aq()->physicalSize.x, d->aq()->physicalSize.y); } for (auto& d : g_pInputManager->m_vTabletTools) { - result += std::format("\tTablet Tool at {:x} (belongs to {:x})\n", (uintptr_t)d.get(), d->wlr() ? (uintptr_t)d->wlr()->data : 0); + result += std::format("\tTablet Tool at {:x}\n", (uintptr_t)d.get()); } result += "\n\nTouch:\n"; @@ -1385,7 +1384,7 @@ std::string dispatchOutput(eHyprCtlOutputFormat format, std::string request) { const auto MODE = vars[1]; - bool added = false; + bool added = false; if (!vars[3].empty()) { for (auto& m : g_pCompositor->m_vRealMonitors) { diff --git a/src/devices/Tablet.cpp b/src/devices/Tablet.cpp index b5ab16c1..a1f642df 100644 --- a/src/devices/Tablet.cpp +++ b/src/devices/Tablet.cpp @@ -2,8 +2,9 @@ #include "../defines.hpp" #include "../protocols/Tablet.hpp" #include "../protocols/core/Compositor.hpp" +#include -SP CTablet::create(wlr_tablet* tablet) { +SP CTablet::create(SP tablet) { SP pTab = SP(new CTablet(tablet)); pTab->self = pTab; @@ -13,7 +14,7 @@ SP CTablet::create(wlr_tablet* tablet) { return pTab; } -SP CTabletTool::create(wlr_tablet_tool* tablet) { +SP CTabletTool::create(SP tablet) { SP pTab = SP(new CTabletTool(tablet)); pTab->self = pTab; @@ -23,7 +24,7 @@ SP CTabletTool::create(wlr_tablet_tool* tablet) { return pTab; } -SP CTabletPad::create(wlr_tablet_pad* tablet) { +SP CTabletPad::create(SP tablet) { SP pTab = SP(new CTabletPad(tablet)); pTab->self = pTab; @@ -33,33 +34,25 @@ SP CTabletPad::create(wlr_tablet_pad* tablet) { return pTab; } -SP CTabletTool::fromWlr(wlr_tablet_tool* tool) { - return ((CTabletTool*)tool->data)->self.lock(); -} - -SP CTablet::fromWlr(wlr_tablet* tablet) { - return ((CTablet*)tablet->data)->self.lock(); -} - -static uint32_t wlrUpdateToHl(uint32_t wlr) { +static uint32_t aqUpdateToHl(uint32_t aq) { uint32_t result = 0; - if (wlr & WLR_TABLET_TOOL_AXIS_X) + if (aq & Aquamarine::AQ_TABLET_TOOL_AXIS_X) result |= CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_X; - if (wlr & WLR_TABLET_TOOL_AXIS_Y) + if (aq & Aquamarine::AQ_TABLET_TOOL_AXIS_Y) result |= CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_Y; - if (wlr & WLR_TABLET_TOOL_AXIS_DISTANCE) + if (aq & Aquamarine::AQ_TABLET_TOOL_AXIS_DISTANCE) result |= CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_DISTANCE; - if (wlr & WLR_TABLET_TOOL_AXIS_PRESSURE) + if (aq & Aquamarine::AQ_TABLET_TOOL_AXIS_PRESSURE) result |= CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_PRESSURE; - if (wlr & WLR_TABLET_TOOL_AXIS_TILT_X) + if (aq & Aquamarine::AQ_TABLET_TOOL_AXIS_TILT_X) result |= CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_TILT_X; - if (wlr & WLR_TABLET_TOOL_AXIS_TILT_Y) + if (aq & Aquamarine::AQ_TABLET_TOOL_AXIS_TILT_Y) result |= CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_TILT_Y; - if (wlr & WLR_TABLET_TOOL_AXIS_ROTATION) + if (aq & Aquamarine::AQ_TABLET_TOOL_AXIS_ROTATION) result |= CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_ROTATION; - if (wlr & WLR_TABLET_TOOL_AXIS_SLIDER) + if (aq & Aquamarine::AQ_TABLET_TOOL_AXIS_SLIDER) result |= CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_SLIDER; - if (wlr & WLR_TABLET_TOOL_AXIS_WHEEL) + if (aq & Aquamarine::AQ_TABLET_TOOL_AXIS_WHEEL) result |= CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_WHEEL; return result; } @@ -68,97 +61,81 @@ uint32_t CTablet::getCapabilities() { return HID_INPUT_CAPABILITY_POINTER | HID_INPUT_CAPABILITY_TABLET; } -wlr_tablet* CTablet::wlr() { - return tablet; +SP CTablet::aq() { + return tablet.lock(); } -CTablet::CTablet(wlr_tablet* tablet_) : tablet(tablet_) { +CTablet::CTablet(SP tablet_) : tablet(tablet_) { if (!tablet) return; - tablet->data = this; - - // clang-format off - hyprListener_destroy.initCallback(&tablet->base.events.destroy, [this] (void* owner, void* data) { - tablet = nullptr; - disconnectCallbacks(); + listeners.destroy = tablet->events.destroy.registerListener([this](std::any d) { + tablet.reset(); events.destroy.emit(); - }, this, "CTablet"); + }); - hyprListener_axis.initCallback(&tablet->events.axis, [this] (void* owner, void* data) { - auto E = (wlr_tablet_tool_axis_event*)data; + listeners.axis = tablet->events.axis.registerListener([this](std::any d) { + auto E = std::any_cast(d); tabletEvents.axis.emit(SAxisEvent{ - .tool = E->tool, + .tool = E.tool, .tablet = self.lock(), - .timeMs = E->time_msec, - .updatedAxes = wlrUpdateToHl(E->updated_axes), - .axis = {E->x, E->y}, - .axisDelta = {E->dx, E->dy}, - .tilt = {E->tilt_x, E->tilt_y}, - .pressure = E->pressure, - .distance = E->distance, - .rotation = E->rotation, - .slider = E->slider, - .wheelDelta = E->wheel_delta, + .timeMs = E.timeMs, + .updatedAxes = aqUpdateToHl(E.updatedAxes), + .axis = E.absolute, + .axisDelta = E.delta, + .tilt = E.tilt, + .pressure = E.pressure, + .distance = E.distance, + .rotation = E.rotation, + .slider = E.slider, + .wheelDelta = E.wheelDelta, }); - }, this, "CTablet"); + }); - hyprListener_proximity.initCallback(&tablet->events.proximity, [this] (void* owner, void* data) { - auto E = (wlr_tablet_tool_proximity_event*)data; + listeners.proximity = tablet->events.proximity.registerListener([this](std::any d) { + auto E = std::any_cast(d); tabletEvents.proximity.emit(SProximityEvent{ - .tool = E->tool, + .tool = E.tool, .tablet = self.lock(), - .timeMs = E->time_msec, - .proximity = {E->x, E->y}, - .in = E->state == WLR_TABLET_TOOL_PROXIMITY_IN, + .timeMs = E.timeMs, + .proximity = E.absolute, + .in = E.in, }); - }, this, "CTablet"); + }); - hyprListener_tip.initCallback(&tablet->events.tip, [this] (void* owner, void* data) { - auto E = (wlr_tablet_tool_tip_event*)data; + listeners.tip = tablet->events.tip.registerListener([this](std::any d) { + auto E = std::any_cast(d); tabletEvents.tip.emit(STipEvent{ - .tool = E->tool, + .tool = E.tool, .tablet = self.lock(), - .timeMs = E->time_msec, - .tip = {E->x, E->y}, - .in = E->state == WLR_TABLET_TOOL_TIP_DOWN, + .timeMs = E.timeMs, + .tip = E.absolute, + .in = E.down, }); - }, this, "CTablet"); + }); - hyprListener_button.initCallback(&tablet->events.button, [this] (void* owner, void* data) { - auto E = (wlr_tablet_tool_button_event*)data; + listeners.button = tablet->events.button.registerListener([this](std::any d) { + auto E = std::any_cast(d); tabletEvents.button.emit(SButtonEvent{ - .tool = E->tool, + .tool = E.tool, .tablet = self.lock(), - .timeMs = E->time_msec, - .button = E->button, - .down = E->state == WLR_BUTTON_PRESSED, + .timeMs = E.timeMs, + .button = E.button, + .down = E.down, }); - }, this, "CTablet"); - // clang-format on + }); - deviceName = tablet->base.name ? tablet->base.name : "UNKNOWN"; + deviceName = tablet->getName(); } CTablet::~CTablet() { - if (tablet) - tablet->data = nullptr; - PROTO::tablet->recheckRegisteredDevices(); } -void CTablet::disconnectCallbacks() { - hyprListener_axis.removeCallback(); - hyprListener_button.removeCallback(); - hyprListener_destroy.removeCallback(); - hyprListener_proximity.removeCallback(); - hyprListener_tip.removeCallback(); -} - eHIDType CTablet::getType() { return HID_TYPE_TABLET; } @@ -167,138 +144,111 @@ uint32_t CTabletPad::getCapabilities() { return HID_INPUT_CAPABILITY_TABLET; } -wlr_tablet_pad* CTabletPad::wlr() { - return pad; +SP CTabletPad::aq() { + return pad.lock(); } eHIDType CTabletPad::getType() { return HID_TYPE_TABLET_PAD; } -CTabletPad::CTabletPad(wlr_tablet_pad* pad_) : pad(pad_) { +CTabletPad::CTabletPad(SP pad_) : pad(pad_) { if (!pad) return; - // clang-format off - hyprListener_destroy.initCallback(&pad->base.events.destroy, [this] (void* owner, void* data) { - pad = nullptr; - disconnectCallbacks(); + listeners.destroy = pad->events.destroy.registerListener([this](std::any d) { + pad.reset(); events.destroy.emit(); - }, this, "CTabletPad"); + }); - hyprListener_button.initCallback(&pad->events.button, [this] (void* owner, void* data) { - auto E = (wlr_tablet_pad_button_event*)data; + listeners.button = pad->events.button.registerListener([this](std::any d) { + auto E = std::any_cast(d); padEvents.button.emit(SButtonEvent{ - .timeMs = E->time_msec, - .button = E->button, - .down = E->state == WLR_BUTTON_PRESSED, - .mode = E->mode, - .group = E->group, + .timeMs = E.timeMs, + .button = E.button, + .down = E.down, + .mode = E.mode, + .group = E.group, }); - }, this, "CTabletPad"); + }); - hyprListener_ring.initCallback(&pad->events.ring, [this] (void* owner, void* data) { - auto E = (wlr_tablet_pad_ring_event*)data; + listeners.ring = pad->events.ring.registerListener([this](std::any d) { + auto E = std::any_cast(d); padEvents.ring.emit(SRingEvent{ - .timeMs = E->time_msec, - .finger = E->source == WLR_TABLET_PAD_RING_SOURCE_FINGER, - .ring = E->ring, - .position = E->position, - .mode = E->mode, + .timeMs = E.timeMs, + .finger = E.source == Aquamarine::ITabletPad::AQ_TABLET_PAD_RING_SOURCE_FINGER, + .ring = E.ring, + .position = E.pos, + .mode = E.mode, }); - }, this, "CTabletPad"); + }); - hyprListener_strip.initCallback(&pad->events.strip, [this] (void* owner, void* data) { - auto E = (wlr_tablet_pad_strip_event*)data; + listeners.strip = pad->events.strip.registerListener([this](std::any d) { + auto E = std::any_cast(d); padEvents.strip.emit(SStripEvent{ - .timeMs = E->time_msec, - .finger = E->source == WLR_TABLET_PAD_STRIP_SOURCE_FINGER, - .strip = E->strip, - .position = E->position, - .mode = E->mode, + .timeMs = E.timeMs, + .finger = E.source == Aquamarine::ITabletPad::AQ_TABLET_PAD_STRIP_SOURCE_FINGER, + .strip = E.strip, + .position = E.pos, + .mode = E.mode, }); - }, this, "CTabletPad"); + }); - hyprListener_attach.initCallback(&pad->events.attach_tablet, [this] (void* owner, void* data) { - if (!data) - return; - - padEvents.attach.emit(CTabletTool::fromWlr((wlr_tablet_tool*)data)); - }, this, "CTabletPad"); - // clang-format on + listeners.attach = pad->events.attach.registerListener([this](std::any d) { + ; // TODO: this doesn't do anything in aq atm + }); - deviceName = pad->base.name ? pad->base.name : "UNKNOWN"; + deviceName = pad->getName(); } CTabletPad::~CTabletPad() { PROTO::tablet->recheckRegisteredDevices(); } -void CTabletPad::disconnectCallbacks() { - hyprListener_ring.removeCallback(); - hyprListener_button.removeCallback(); - hyprListener_destroy.removeCallback(); - hyprListener_strip.removeCallback(); - hyprListener_attach.removeCallback(); -} - uint32_t CTabletTool::getCapabilities() { return HID_INPUT_CAPABILITY_POINTER | HID_INPUT_CAPABILITY_TABLET; } -wlr_tablet_tool* CTabletTool::wlr() { - return tool; +SP CTabletTool::aq() { + return tool.lock(); } eHIDType CTabletTool::getType() { return HID_TYPE_TABLET_TOOL; } -CTabletTool::CTabletTool(wlr_tablet_tool* tool_) : tool(tool_) { +CTabletTool::CTabletTool(SP tool_) : tool(tool_) { if (!tool) return; - // clang-format off - hyprListener_destroy.initCallback(&tool->events.destroy, [this] (void* owner, void* data) { - tool = nullptr; - disconnectCallbacks(); + listeners.destroyTool = tool->events.destroy.registerListener([this] (std::any d) { + tool.reset(); events.destroy.emit(); - }, this, "CTabletTool"); - // clang-format on + }); - if (tool->tilt) + if (tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_TILT) toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_TILT; - if (tool->pressure) + if (tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_PRESSURE) toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_PRESSURE; - if (tool->distance) + if (tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_DISTANCE) toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_DISTANCE; - if (tool->rotation) + if (tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_ROTATION) toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_ROTATION; - if (tool->slider) + if (tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_SLIDER) toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_SLIDER; - if (tool->wheel) + if (tool->capabilities & Aquamarine::ITabletTool::AQ_TABLET_TOOL_CAPABILITY_WHEEL) toolCapabilities |= HID_TABLET_TOOL_CAPABILITY_WHEEL; - tool->data = this; - - deviceName = std::to_string(tool->hardware_serial) + std::to_string(tool->hardware_wacom); + deviceName = std::format("{:x}-{:x}", tool->serial, tool->id); } CTabletTool::~CTabletTool() { - if (tool) - tool->data = nullptr; - PROTO::tablet->recheckRegisteredDevices(); } -void CTabletTool::disconnectCallbacks() { - hyprListener_destroy.removeCallback(); - listeners.destroySurface.reset(); -} - SP CTabletTool::getSurface() { return pSurface.lock(); } diff --git a/src/devices/Tablet.hpp b/src/devices/Tablet.hpp index ada2cf89..0efbe796 100644 --- a/src/devices/Tablet.hpp +++ b/src/devices/Tablet.hpp @@ -6,9 +6,9 @@ #include "../helpers/math/Math.hpp" #include "../helpers/math/Math.hpp" -struct wlr_tablet; -struct wlr_tablet_tool; -struct wlr_tablet_pad; +AQUAMARINE_FORWARD(ITablet); +AQUAMARINE_FORWARD(ITabletTool); +AQUAMARINE_FORWARD(ITabletPad); class CTabletTool; class CTabletPad; @@ -21,13 +21,12 @@ class CWLSurfaceResource; */ class CTablet : public IHID { public: - static SP create(wlr_tablet* tablet); - static SP fromWlr(wlr_tablet* tablet); + static SP create(SP tablet); ~CTablet(); - virtual uint32_t getCapabilities(); - virtual eHIDType getType(); - wlr_tablet* wlr(); + virtual uint32_t getCapabilities(); + virtual eHIDType getType(); + SP aq(); enum eTabletToolAxes { HID_TABLET_TOOL_AXIS_X = (1 << 0), @@ -42,46 +41,46 @@ class CTablet : public IHID { }; struct SAxisEvent { - wlr_tablet_tool* tool; - SP tablet; + SP tool; + SP tablet; - uint32_t timeMs = 0; - uint32_t updatedAxes = 0; // eTabletToolAxes - Vector2D axis; - Vector2D axisDelta; - Vector2D tilt; - double pressure = 0; - double distance = 0; - double rotation = 0; - double slider = 0; - double wheelDelta = 0; + uint32_t timeMs = 0; + uint32_t updatedAxes = 0; // eTabletToolAxes + Vector2D axis; + Vector2D axisDelta; + Vector2D tilt; + double pressure = 0; + double distance = 0; + double rotation = 0; + double slider = 0; + double wheelDelta = 0; }; struct SProximityEvent { - wlr_tablet_tool* tool; - SP tablet; + SP tool; + SP tablet; - uint32_t timeMs = 0; - Vector2D proximity; - bool in = false; + uint32_t timeMs = 0; + Vector2D proximity; + bool in = false; }; struct STipEvent { - wlr_tablet_tool* tool; - SP tablet; + SP tool; + SP tablet; - uint32_t timeMs = 0; - Vector2D tip; - bool in = false; + uint32_t timeMs = 0; + Vector2D tip; + bool in = false; }; struct SButtonEvent { - wlr_tablet_tool* tool; - SP tablet; + SP tool; + SP tablet; - uint32_t timeMs = 0; - uint32_t button; - bool down = false; + uint32_t timeMs = 0; + uint32_t button; + bool down = false; }; struct { @@ -100,27 +99,27 @@ class CTablet : public IHID { CBox boundBox; // output-local private: - CTablet(wlr_tablet* tablet); + CTablet(SP tablet); - void disconnectCallbacks(); + WP tablet; - wlr_tablet* tablet = nullptr; - - DYNLISTENER(destroy); - DYNLISTENER(axis); - DYNLISTENER(proximity); - DYNLISTENER(tip); - DYNLISTENER(button); + struct { + CHyprSignalListener destroy; + CHyprSignalListener axis; + CHyprSignalListener proximity; + CHyprSignalListener tip; + CHyprSignalListener button; + } listeners; }; class CTabletPad : public IHID { public: - static SP create(wlr_tablet_pad* pad); + static SP create(SP pad); ~CTabletPad(); - virtual uint32_t getCapabilities(); - virtual eHIDType getType(); - wlr_tablet_pad* wlr(); + virtual uint32_t getCapabilities(); + virtual eHIDType getType(); + SP aq(); struct SButtonEvent { uint32_t timeMs = 0; @@ -159,23 +158,22 @@ class CTabletPad : public IHID { std::string hlName; private: - CTabletPad(wlr_tablet_pad* pad); + CTabletPad(SP pad); - void disconnectCallbacks(); + WP pad; - wlr_tablet_pad* pad = nullptr; - - DYNLISTENER(destroy); - DYNLISTENER(ring); - DYNLISTENER(strip); - DYNLISTENER(button); - DYNLISTENER(attach); + struct { + CHyprSignalListener destroy; + CHyprSignalListener ring; + CHyprSignalListener strip; + CHyprSignalListener button; + CHyprSignalListener attach; + } listeners; }; class CTabletTool : public IHID { public: - static SP create(wlr_tablet_tool* tool); - static SP fromWlr(wlr_tablet_tool* tool); + static SP create(SP tool); ~CTabletTool(); enum eTabletToolType { @@ -198,35 +196,31 @@ class CTabletTool : public IHID { HID_TABLET_TOOL_CAPABILITY_WHEEL = (1 << 5), }; - virtual uint32_t getCapabilities(); - wlr_tablet_tool* wlr(); - virtual eHIDType getType(); - SP getSurface(); - void setSurface(SP); + virtual uint32_t getCapabilities(); + SP aq(); + virtual eHIDType getType(); + SP getSurface(); + void setSurface(SP); - WP self; - Vector2D tilt; - bool active = false; // true if in proximity - uint32_t toolCapabilities = 0; + WP self; + Vector2D tilt; + bool active = false; // true if in proximity + uint32_t toolCapabilities = 0; - bool isDown = false; - std::vector buttonsDown; - Vector2D absolutePos; // last known absolute position. + bool isDown = false; + std::vector buttonsDown; + Vector2D absolutePos; // last known absolute position. - std::string hlName; + std::string hlName; private: - CTabletTool(wlr_tablet_tool* tool); + CTabletTool(SP tool); - void disconnectCallbacks(); - - WP pSurface; - - wlr_tablet_tool* tool = nullptr; - - DYNLISTENER(destroy); + WP pSurface; + WP tool; struct { CHyprSignalListener destroySurface; + CHyprSignalListener destroyTool; } listeners; }; \ No newline at end of file diff --git a/src/events/Devices.cpp b/src/events/Devices.cpp deleted file mode 100644 index a7c5dd55..00000000 --- a/src/events/Devices.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "Events.hpp" - -#include "../Compositor.hpp" -#include "../helpers/WLClasses.hpp" -#include "../managers/input/InputManager.hpp" -#include "../render/Renderer.hpp" - -// ---------------------------------------------------- // -// _____ ________ _______ _____ ______ _____ // -// | __ \| ____\ \ / /_ _/ ____| ____|/ ____| // -// | | | | |__ \ \ / / | || | | |__ | (___ // -// | | | | __| \ \/ / | || | | __| \___ \ // -// | |__| | |____ \ / _| || |____| |____ ____) | // -// |_____/|______| \/ |_____\_____|______|_____/ // -// // -// ---------------------------------------------------- // - -void Events::listener_newInput(wl_listener* listener, void* data) { - const auto DEVICE = (wlr_input_device*)data; - - switch (DEVICE->type) { - case WLR_INPUT_DEVICE_KEYBOARD: - Debug::log(LOG, "Attached a keyboard with name {}", DEVICE->name); - //g_pInputManager->newKeyboard(DEVICE); - break; - case WLR_INPUT_DEVICE_POINTER: - Debug::log(LOG, "Attached a mouse with name {}", DEVICE->name); - //g_pInputManager->newMouse(DEVICE); - break; - case WLR_INPUT_DEVICE_TOUCH: - Debug::log(LOG, "Attached a touch device with name {}", DEVICE->name); - // g_pInputManager->newTouchDevice(DEVICE); - break; - case WLR_INPUT_DEVICE_TABLET: - Debug::log(LOG, "Attached a tablet with name {}", DEVICE->name); - g_pInputManager->newTablet(DEVICE); - break; - case WLR_INPUT_DEVICE_TABLET_PAD: - Debug::log(LOG, "Attached a tablet pad with name {}", DEVICE->name); - g_pInputManager->newTabletPad(DEVICE); - break; - case WLR_INPUT_DEVICE_SWITCH: - Debug::log(LOG, "Attached a switch device with name {}", DEVICE->name); - // g_pInputManager->newSwitch(DEVICE); - break; - default: Debug::log(WARN, "Unrecognized input device plugged in: {}", DEVICE->name); break; - } - - g_pInputManager->updateCapabilities(); -} diff --git a/src/events/Events.hpp b/src/events/Events.hpp index f8eb9d2f..8e73f54a 100644 --- a/src/events/Events.hpp +++ b/src/events/Events.hpp @@ -8,16 +8,6 @@ // namespace Events { - // Monitor events - LISTENER(change); - LISTENER(newOutput); - - // DRM events - LISTENER(leaseRequest); - - // Layer events - LISTENER(newLayerSurface); - // Window events DYNLISTENFUNC(commitWindow); DYNLISTENFUNC(mapWindow); @@ -35,15 +25,6 @@ namespace Events { DYNLISTENFUNC(setOverrideRedirect); DYNLISTENFUNC(ackConfigure); - LISTENER(newInput); - - // Virt Ptr - LISTENER(newVirtPtr); - - // Various - LISTENER(requestSetSel); - LISTENER(requestSetPrimarySel); - // Monitor part 2 the sequel DYNLISTENFUNC(monitorFrame); DYNLISTENFUNC(monitorDestroy); @@ -52,16 +33,4 @@ namespace Events { DYNLISTENFUNC(monitorNeedsFrame); DYNLISTENFUNC(monitorCommit); DYNLISTENFUNC(monitorBind); - - // XWayland - LISTENER(surfaceXWayland); - - // Renderer destroy - LISTENER(RendererDestroy); - - // session - LISTENER(sessionActive); - - // Session Lock - LISTENER(newSessionLock); }; diff --git a/src/events/Misc.cpp b/src/events/Misc.cpp deleted file mode 100644 index 82790ec5..00000000 --- a/src/events/Misc.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "Events.hpp" - -#include "../Compositor.hpp" -#include "../helpers/WLClasses.hpp" -#include "../managers/input/InputManager.hpp" -#include "../render/Renderer.hpp" -#include "../managers/CursorManager.hpp" - -// ------------------------------ // -// __ __ _____ _____ _____ // -// | \/ |_ _|/ ____|/ ____| // -// | \ / | | | | (___ | | // -// | |\/| | | | \___ \| | // -// | | | |_| |_ ____) | |____ // -// |_| |_|_____|_____/ \_____| // -// // -// ------------------------------ // - -void Events::listener_leaseRequest(wl_listener* listener, void* data) { - const auto REQUEST = (wlr_drm_lease_request_v1*)data; - struct wlr_drm_lease_v1* lease = wlr_drm_lease_request_v1_grant(REQUEST); - if (!lease) { - Debug::log(ERR, "Failed to grant lease request!"); - wlr_drm_lease_request_v1_reject(REQUEST); - } -} - -void Events::listener_RendererDestroy(wl_listener* listener, void* data) { - Debug::log(LOG, "!!Renderer destroyed!!"); -} - -void Events::listener_sessionActive(wl_listener* listener, void* data) { - if (g_pCompositor->m_pAqBackend->session->active) { - Debug::log(LOG, "Session got activated!"); - - g_pCompositor->m_bSessionActive = true; - - for (auto& m : g_pCompositor->m_vMonitors) { - g_pCompositor->scheduleFrameForMonitor(m.get()); - g_pHyprRenderer->applyMonitorRule(m.get(), &m->activeMonitorRule, true); - } - - g_pConfigManager->m_bWantsMonitorReload = true; - } else { - Debug::log(LOG, "Session got inactivated!"); - - g_pCompositor->m_bSessionActive = false; - - for (auto& m : g_pCompositor->m_vMonitors) { - m->noFrameSchedule = true; - m->framesToSkip = 1; - } - } -} diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index dd730b6d..ec5a5535 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -1495,9 +1495,9 @@ void CInputManager::setTouchDeviceConfigs(SP dev) { void CInputManager::setTabletConfigs() { for (auto& t : m_vTablets) { - if (wlr_input_device_is_libinput(&t->wlr()->base)) { + if (t->aq()->getLibinputHandle()) { const auto NAME = t->hlName; - const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(&t->wlr()->base); + const auto LIBINPUTDEV = t->aq()->getLibinputHandle(); const auto RELINPUT = g_pConfigManager->getDeviceInt(NAME, "relative_input", "input:tablet:relative_input"); t->relativeInput = RELINPUT; @@ -1525,8 +1525,8 @@ void CInputManager::setTabletConfigs() { const auto ACTIVE_AREA_SIZE = g_pConfigManager->getDeviceVec(NAME, "active_area_size", "input:tablet:active_area_size"); const auto ACTIVE_AREA_POS = g_pConfigManager->getDeviceVec(NAME, "active_area_position", "input:tablet:active_area_position"); if (ACTIVE_AREA_SIZE.x != 0 || ACTIVE_AREA_SIZE.y != 0) { - t->activeArea = CBox{ACTIVE_AREA_POS.x / t->wlr()->width_mm, ACTIVE_AREA_POS.y / t->wlr()->height_mm, (ACTIVE_AREA_POS.x + ACTIVE_AREA_SIZE.x) / t->wlr()->width_mm, - (ACTIVE_AREA_POS.y + ACTIVE_AREA_SIZE.y) / t->wlr()->height_mm}; + t->activeArea = CBox{ACTIVE_AREA_POS.x / t->aq()->physicalSize.x, ACTIVE_AREA_POS.y / t->aq()->physicalSize.y, + (ACTIVE_AREA_POS.x + ACTIVE_AREA_SIZE.x) / t->aq()->physicalSize.x, (ACTIVE_AREA_POS.y + ACTIVE_AREA_SIZE.y) / t->aq()->physicalSize.y}; } } } diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 29648eef..9b626d68 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -22,6 +22,9 @@ AQUAMARINE_FORWARD(IPointer); AQUAMARINE_FORWARD(IKeyboard); AQUAMARINE_FORWARD(ITouch); AQUAMARINE_FORWARD(ISwitch); +AQUAMARINE_FORWARD(ITablet); +AQUAMARINE_FORWARD(ITabletTool); +AQUAMARINE_FORWARD(ITabletPad); enum eClickBehaviorMode { CLICKMODE_DEFAULT = 0, @@ -93,9 +96,8 @@ class CInputManager { void newVirtualMouse(SP); void newTouchDevice(SP); void newSwitch(SP); - void newTabletTool(wlr_tablet_tool*); - void newTabletPad(wlr_input_device*); - void newTablet(wlr_input_device*); + void newTabletPad(SP); + void newTablet(SP); void destroyTouchDevice(SP); void destroyKeyboard(SP); void destroyPointer(SP); @@ -237,7 +239,7 @@ class CInputManager { void mouseMoveUnified(uint32_t, bool refocus = false); - SP ensureTabletToolPresent(wlr_tablet_tool*); + SP ensureTabletToolPresent(SP); void applyConfigToKeyboard(SP); diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp index f1157e4b..5e50e851 100644 --- a/src/managers/input/Tablets.cpp +++ b/src/managers/input/Tablets.cpp @@ -62,7 +62,7 @@ static void refocusTablet(SP tab, SP tool, bool motion = f if (!motion) return; - if (LASTHLSURFACE->constraint() && tool->wlr()->type != WLR_TABLET_TOOL_TYPE_MOUSE) { + if (LASTHLSURFACE->constraint() && tool->aq()->type != Aquamarine::ITabletTool::AQ_TABLET_TOOL_TYPE_MOUSE) { // cursor logic will completely break here as the cursor will be locked. // let's just "map" the desired position to the constraint area. @@ -102,7 +102,7 @@ void CInputManager::onTabletAxis(CTablet::SAxisEvent e) { Vector2D delta = {std::isnan(dx) ? 0.0 : dx, std::isnan(dy) ? 0.0 : dy}; switch (e.tool->type) { - case WLR_TABLET_TOOL_TYPE_MOUSE: { + case Aquamarine::ITabletTool::AQ_TABLET_TOOL_TYPE_MOUSE: { g_pPointerManager->move(delta); break; } @@ -205,12 +205,12 @@ void CInputManager::onTabletProximity(CTablet::SProximityEvent e) { PROTO::idle->onActivity(); } -void CInputManager::newTablet(wlr_input_device* pDevice) { - const auto PNEWTABLET = m_vTablets.emplace_back(CTablet::create(wlr_tablet_from_input_device(pDevice))); +void CInputManager::newTablet(SP pDevice) { + const auto PNEWTABLET = m_vTablets.emplace_back(CTablet::create(pDevice)); m_vHIDs.push_back(PNEWTABLET); try { - PNEWTABLET->hlName = deviceNameToInternalString(pDevice->name); + PNEWTABLET->hlName = deviceNameToInternalString(pDevice->getName()); } catch (std::exception& e) { Debug::log(ERR, "Tablet had no name???"); // logic error } @@ -227,28 +227,32 @@ void CInputManager::newTablet(wlr_input_device* pDevice) { setTabletConfigs(); } -SP CInputManager::ensureTabletToolPresent(wlr_tablet_tool* pTool) { - if (pTool->data == nullptr) { - const auto PTOOL = m_vTabletTools.emplace_back(CTabletTool::create(pTool)); - m_vHIDs.push_back(PTOOL); +SP CInputManager::ensureTabletToolPresent(SP pTool) { - PTOOL->events.destroy.registerStaticListener( - [this](void* owner, std::any d) { - auto TOOL = ((CTabletTool*)owner)->self; - destroyTabletTool(TOOL.lock()); - }, - PTOOL.get()); + for (auto& t : m_vTabletTools) { + if (t->aq() == pTool) + return t; } - return CTabletTool::fromWlr(pTool); + const auto PTOOL = m_vTabletTools.emplace_back(CTabletTool::create(pTool)); + m_vHIDs.push_back(PTOOL); + + PTOOL->events.destroy.registerStaticListener( + [this](void* owner, std::any d) { + auto TOOL = ((CTabletTool*)owner)->self; + destroyTabletTool(TOOL.lock()); + }, + PTOOL.get()); + + return PTOOL; } -void CInputManager::newTabletPad(wlr_input_device* pDevice) { - const auto PNEWPAD = m_vTabletPads.emplace_back(CTabletPad::create(wlr_tablet_pad_from_input_device(pDevice))); +void CInputManager::newTabletPad(SP pDevice) { + const auto PNEWPAD = m_vTabletPads.emplace_back(CTabletPad::create(pDevice)); m_vHIDs.push_back(PNEWPAD); try { - PNEWPAD->hlName = deviceNameToInternalString(pDevice->name); + PNEWPAD->hlName = deviceNameToInternalString(pDevice->getName()); } catch (std::exception& e) { Debug::log(ERR, "Pad had no name???"); // logic error } @@ -259,7 +263,7 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) { destroyTabletPad(PAD.lock()); }, PNEWPAD.get()); - PNEWPAD->padEvents.button.registerStaticListener([this](void* owner, std::any e) { + PNEWPAD->padEvents.button.registerStaticListener([](void* owner, std::any e) { const auto E = std::any_cast(e); const auto PPAD = ((CTabletPad*)owner)->self.lock(); @@ -267,26 +271,25 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) { PROTO::tablet->buttonPad(PPAD, E.button, E.timeMs, E.down); }, PNEWPAD.get()); - PNEWPAD->padEvents.strip.registerStaticListener([this](void* owner, std::any e) { + PNEWPAD->padEvents.strip.registerStaticListener([](void* owner, std::any e) { const auto E = std::any_cast(e); const auto PPAD = ((CTabletPad*)owner)->self.lock(); PROTO::tablet->strip(PPAD, E.strip, E.position, E.finger, E.timeMs); }, PNEWPAD.get()); - PNEWPAD->padEvents.ring.registerStaticListener([this](void* owner, std::any e) { + PNEWPAD->padEvents.ring.registerStaticListener([](void* owner, std::any e) { const auto E = std::any_cast(e); const auto PPAD = ((CTabletPad*)owner)->self.lock(); PROTO::tablet->ring(PPAD, E.ring, E.position, E.finger, E.timeMs); }, PNEWPAD.get()); - PNEWPAD->padEvents.attach.registerStaticListener([this](void* owner, std::any e) { + PNEWPAD->padEvents.attach.registerStaticListener([](void* owner, std::any e) { const auto PPAD = ((CTabletPad*)owner)->self.lock(); const auto TOOL = std::any_cast>(e); PPAD->parent = TOOL; }, PNEWPAD.get()); - // clang-format on } diff --git a/src/protocols/Tablet.cpp b/src/protocols/Tablet.cpp index 518ea5bd..67d02206 100644 --- a/src/protocols/Tablet.cpp +++ b/src/protocols/Tablet.cpp @@ -44,17 +44,17 @@ bool CTabletPadGroupV2Resource::good() { return resource->resource(); } -void CTabletPadGroupV2Resource::sendData(SP pad, wlr_tablet_pad_group* group) { - resource->sendModes(group->mode_count); +void CTabletPadGroupV2Resource::sendData(SP pad, SP group) { + resource->sendModes(group->modes); wl_array buttonArr; wl_array_init(&buttonArr); - wl_array_add(&buttonArr, group->button_count * sizeof(int)); - memcpy(buttonArr.data, group->buttons, group->button_count * sizeof(int)); + wl_array_add(&buttonArr, group->buttons.size() * sizeof(int)); + memcpy(buttonArr.data, group->buttons.data(), group->buttons.size() * sizeof(int)); resource->sendButtons(&buttonArr); wl_array_release(&buttonArr); - for (size_t i = 0; i < group->strip_count; ++i) { + for (size_t i = 0; i < group->strips.size(); ++i) { const auto RESOURCE = PROTO::tablet->m_vStrips.emplace_back(makeShared(makeShared(resource->client(), resource->version(), 0), i)); @@ -67,7 +67,7 @@ void CTabletPadGroupV2Resource::sendData(SP pad, wlr_tablet_pad_grou resource->sendStrip(RESOURCE->resource.get()); } - for (size_t i = 0; i < group->ring_count; ++i) { + for (size_t i = 0; i < group->rings.size(); ++i) { const auto RESOURCE = PROTO::tablet->m_vRings.emplace_back(makeShared(makeShared(resource->client(), resource->version(), 0), i)); @@ -97,23 +97,20 @@ bool CTabletPadV2Resource::good() { void CTabletPadV2Resource::sendData() { // this is dodgy as fuck. I hate wl_array. it's expanded wl_array_for_each because C++ would complain about the implicit casts - const char** path_ptr; - for (path_ptr = (const char**)(&pad->wlr()->paths)->data; (const char*)path_ptr < ((const char*)(&pad->wlr()->paths)->data + (&pad->wlr()->paths)->size); (path_ptr)++) { - resource->sendPath(*path_ptr); + for (auto& p : pad->aq()->paths) { + resource->sendPath(p.c_str()); } - resource->sendButtons(pad->wlr()->button_count); + resource->sendButtons(pad->aq()->buttons); - wlr_tablet_pad_group* group; - size_t i = 0; - wl_list_for_each(group, &pad->wlr()->groups, link) { - createGroup(group, i++); + for (size_t i = 0; i < pad->aq()->groups.size(); ++i) { + createGroup(pad->aq()->groups.at(i), i); } resource->sendDone(); } -void CTabletPadV2Resource::createGroup(wlr_tablet_pad_group* group, size_t idx) { +void CTabletPadV2Resource::createGroup(SP group, size_t idx) { const auto RESOURCE = PROTO::tablet->m_vGroups.emplace_back(makeShared(makeShared(resource->client(), resource->version(), 0), idx)); @@ -142,13 +139,10 @@ bool CTabletV2Resource::good() { void CTabletV2Resource::sendData() { resource->sendName(tablet->deviceName.c_str()); - resource->sendId(tablet->wlr()->usb_vendor_id, tablet->wlr()->usb_product_id); + resource->sendId(tablet->aq()->usbVendorID, tablet->aq()->usbProductID); - // this is dodgy as fuck. I hate wl_array. it's expanded wl_array_for_each because C++ would complain about the implicit casts - const char** path_ptr; - for (path_ptr = (const char**)(&tablet->wlr()->paths)->data; (const char*)path_ptr < ((const char*)(&tablet->wlr()->paths)->data + (&tablet->wlr()->paths)->size); - (path_ptr)++) { - resource->sendPath(*path_ptr); + for (auto& p : tablet->aq()->paths) { + resource->sendPath(p.c_str()); } resource->sendDone(); @@ -179,23 +173,23 @@ bool CTabletToolV2Resource::good() { } void CTabletToolV2Resource::sendData() { - static auto WLR_TYPE_TO_PROTO = [](uint32_t wlr) -> zwpTabletToolV2Type { - switch (wlr) { - case WLR_TABLET_TOOL_TYPE_PEN: return ZWP_TABLET_TOOL_V2_TYPE_PEN; - case WLR_TABLET_TOOL_TYPE_ERASER: return ZWP_TABLET_TOOL_V2_TYPE_ERASER; - case WLR_TABLET_TOOL_TYPE_BRUSH: return ZWP_TABLET_TOOL_V2_TYPE_BRUSH; - case WLR_TABLET_TOOL_TYPE_PENCIL: return ZWP_TABLET_TOOL_V2_TYPE_PENCIL; - case WLR_TABLET_TOOL_TYPE_AIRBRUSH: return ZWP_TABLET_TOOL_V2_TYPE_AIRBRUSH; - case WLR_TABLET_TOOL_TYPE_MOUSE: return ZWP_TABLET_TOOL_V2_TYPE_MOUSE; - case WLR_TABLET_TOOL_TYPE_LENS: return ZWP_TABLET_TOOL_V2_TYPE_LENS; + static auto AQ_TYPE_TO_PROTO = [](uint32_t aq) -> zwpTabletToolV2Type { + switch (aq) { + case Aquamarine::ITabletTool::AQ_TABLET_TOOL_TYPE_PEN: return ZWP_TABLET_TOOL_V2_TYPE_PEN; + case Aquamarine::ITabletTool::AQ_TABLET_TOOL_TYPE_ERASER: return ZWP_TABLET_TOOL_V2_TYPE_ERASER; + case Aquamarine::ITabletTool::AQ_TABLET_TOOL_TYPE_BRUSH: return ZWP_TABLET_TOOL_V2_TYPE_BRUSH; + case Aquamarine::ITabletTool::AQ_TABLET_TOOL_TYPE_PENCIL: return ZWP_TABLET_TOOL_V2_TYPE_PENCIL; + case Aquamarine::ITabletTool::AQ_TABLET_TOOL_TYPE_AIRBRUSH: return ZWP_TABLET_TOOL_V2_TYPE_AIRBRUSH; + case Aquamarine::ITabletTool::AQ_TABLET_TOOL_TYPE_MOUSE: return ZWP_TABLET_TOOL_V2_TYPE_MOUSE; + case Aquamarine::ITabletTool::AQ_TABLET_TOOL_TYPE_LENS: return ZWP_TABLET_TOOL_V2_TYPE_LENS; default: ASSERT(false); } UNREACHABLE(); }; - resource->sendType(WLR_TYPE_TO_PROTO(tool->wlr()->type)); - resource->sendHardwareSerial(tool->wlr()->hardware_serial >> 32, tool->wlr()->hardware_serial & 0xFFFFFFFF); - resource->sendHardwareIdWacom(tool->wlr()->hardware_wacom >> 32, tool->wlr()->hardware_wacom & 0xFFFFFFFF); + resource->sendType(AQ_TYPE_TO_PROTO(tool->aq()->type)); + resource->sendHardwareSerial(tool->aq()->serial >> 32, tool->aq()->serial & 0xFFFFFFFF); + resource->sendHardwareIdWacom(tool->aq()->id >> 32, tool->aq()->id & 0xFFFFFFFF); if (tool->toolCapabilities & CTabletTool::eTabletToolCapabilities::HID_TABLET_TOOL_CAPABILITY_DISTANCE) resource->sendCapability(zwpTabletToolV2Capability::ZWP_TABLET_TOOL_V2_CAPABILITY_DISTANCE); if (tool->toolCapabilities & CTabletTool::eTabletToolCapabilities::HID_TABLET_TOOL_CAPABILITY_PRESSURE) diff --git a/src/protocols/Tablet.hpp b/src/protocols/Tablet.hpp index 58f13c1a..1ebcb1e5 100644 --- a/src/protocols/Tablet.hpp +++ b/src/protocols/Tablet.hpp @@ -6,6 +6,7 @@ #include "WaylandProtocol.hpp" #include "tablet-v2.hpp" #include "../helpers/math/Math.hpp" +#include class CTablet; class CTabletTool; @@ -51,7 +52,7 @@ class CTabletPadGroupV2Resource { CTabletPadGroupV2Resource(SP resource_, size_t idx); bool good(); - void sendData(SP pad, wlr_tablet_pad_group* group); + void sendData(SP pad, SP group); std::vector> rings; std::vector> strips; @@ -83,7 +84,7 @@ class CTabletPadV2Resource { private: SP resource; - void createGroup(wlr_tablet_pad_group* group, size_t idx); + void createGroup(SP group, size_t idx); friend class CTabletSeat; friend class CTabletV2Protocol;