From 00098aef4f55eb53763e663bf470c7359da302a1 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 18 Mar 2022 20:42:49 +0100 Subject: [PATCH] handle buttons --- src/Compositor.cpp | 2 ++ src/events/Events.cpp | 2 +- src/managers/InputManager.cpp | 26 ++++++++++++++++++++++++++ src/managers/InputManager.hpp | 1 + src/render/Renderer.cpp | 12 +++++++----- 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 8d81e1c9..4320bf9c 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -64,6 +64,8 @@ CCompositor::CCompositor() { m_sWLRPresentation = wlr_presentation_create(m_sWLDisplay, m_sWLRBackend); + m_sWLRIdle = wlr_idle_create(m_sWLDisplay); + // TODO: XWayland } diff --git a/src/events/Events.cpp b/src/events/Events.cpp index 7898caeb..31fe8fe3 100644 --- a/src/events/Events.cpp +++ b/src/events/Events.cpp @@ -191,7 +191,7 @@ void Events::listener_mouseAxis(wl_listener* listener, void* data) { } void Events::listener_mouseButton(wl_listener* listener, void* data) { - + g_pInputManager->onMouseButton((wlr_event_pointer_button*)data); } void Events::listener_keyboardDestroy(wl_listener* listener, void* data) { diff --git a/src/managers/InputManager.cpp b/src/managers/InputManager.cpp index e2e88b9e..db5e049a 100644 --- a/src/managers/InputManager.cpp +++ b/src/managers/InputManager.cpp @@ -14,10 +14,36 @@ void CInputManager::onMouseMoved(wlr_event_pointer_motion* e) { wlr_cursor_move(g_pCompositor->m_sWLRCursor, e->device, delta.floor().x, delta.floor().y); } + + + if (e->time_msec) + wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sWLRSeat); + + // todo: focus + // todo: pointer } void CInputManager::onMouseWarp(wlr_event_pointer_motion_absolute* e) { wlr_cursor_warp_absolute(g_pCompositor->m_sWLRCursor, e->device, e->x, e->y); + + if (e->time_msec) + wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sWLRSeat); +} + +void CInputManager::onMouseButton(wlr_event_pointer_button* e) { + wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sWLRSeat); + + switch (e->state) { + case WLR_BUTTON_PRESSED: + // todo: keybinds + break; + case WLR_BUTTON_RELEASED: + // todo: keybinds + break; + } + + // notify app if we didnt handle it + wlr_seat_pointer_notify_button(g_pCompositor->m_sWLRSeat, e->time_msec, e->button, e->state); } Vector2D CInputManager::getMouseCoordsInternal() { diff --git a/src/managers/InputManager.hpp b/src/managers/InputManager.hpp index b750ad4c..f6ab8c7b 100644 --- a/src/managers/InputManager.hpp +++ b/src/managers/InputManager.hpp @@ -9,6 +9,7 @@ public: void onMouseMoved(wlr_event_pointer_motion*); void onMouseWarp(wlr_event_pointer_motion_absolute*); + void onMouseButton(wlr_event_pointer_button*); void onKeyboardKey(wlr_event_keyboard_key*); void onKeyboardMod(void*); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 0fd783c1..43c9d48b 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -43,18 +43,17 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) { if (w.m_bIsX11) continue; - const wlr_box geom = { w.m_vPosition.x, w.m_vPosition.y, w.m_vSize.x, w.m_vSize.y }; + wlr_box geometry = { w.m_vPosition.x, w.m_vPosition.y, w.m_vSize.x, w.m_vSize.y }; - if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, PMONITOR->output, &geom)) + if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, PMONITOR->output, &geometry)) continue; // render the bad boy - wlr_output_layout_output_coords(g_pCompositor->m_sWLROutputLayout, PMONITOR->output, &w.m_vPosition.x, &w.m_vPosition.y); SRenderData renderdata = {PMONITOR->output, time, w.m_vSize.x, w.m_vSize.y}; - wlr_surface_for_each_surface(w.m_uSurface.xdg->surface, renderSurface, &renderdata); + wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(&w), renderSurface, &renderdata); wlr_xdg_surface_for_each_popup_surface(w.m_uSurface.xdg, renderSurface, &renderdata); } @@ -68,9 +67,12 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) { if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, PMONITOR->output, &geometry)) continue; + // render the bad boy + wlr_output_layout_output_coords(g_pCompositor->m_sWLROutputLayout, PMONITOR->output, &w.m_vPosition.x, &w.m_vPosition.y); + SRenderData renderdata = {PMONITOR->output, time, w.m_vSize.x, w.m_vSize.y}; if (w.m_uSurface.xwayland->surface) - wlr_surface_for_each_surface(w.m_uSurface.xwayland->surface, renderSurface, &renderdata); + wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(&w), renderSurface, &renderdata); } }