From 295a0c4a6904b639ae406df2f106eb35d71899ae Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 21 Mar 2022 19:18:33 +0100 Subject: Added fullscreen --- src/managers/InputManager.cpp | 25 ++++++++++++++++++++----- src/managers/KeybindManager.cpp | 10 ++++++++++ src/managers/KeybindManager.hpp | 1 + 3 files changed, 31 insertions(+), 5 deletions(-) (limited to 'src/managers') diff --git a/src/managers/InputManager.cpp b/src/managers/InputManager.cpp index 530e1fd9..af1a3856 100644 --- a/src/managers/InputManager.cpp +++ b/src/managers/InputManager.cpp @@ -20,15 +20,30 @@ void CInputManager::onMouseWarp(wlr_event_pointer_motion_absolute* e) { void CInputManager::mouseMoveUnified(uint32_t time) { - // first top layers wlr_surface* foundSurface = nullptr; Vector2D mouseCoords = getMouseCoordsInternal(); const auto PMONITOR = g_pCompositor->getMonitorFromCursor(); Vector2D surfacePos; - foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &surfacePos); + // first, we check if the workspace doesnt have a fullscreen window + const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); + if (PWORKSPACE->hasFullscreenWindow) { + const auto PFULLSCREENWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->ID); + + // should never ever happen but who knows + if (PFULLSCREENWINDOW) { + foundSurface = g_pXWaylandManager->getWindowSurface(PFULLSCREENWINDOW); + if (foundSurface) + surfacePos = PFULLSCREENWINDOW->m_vRealPosition; + } + } + + // then surfaces on top + if (!foundSurface) + foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &surfacePos); + if (!foundSurface) - foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfacePos); + foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfacePos); // then windows if (!foundSurface && g_pCompositor->vectorToWindowIdeal(mouseCoords)) { @@ -79,6 +94,8 @@ void CInputManager::onMouseButton(wlr_event_pointer_button* e) { dragButton = e->button; g_pLayoutManager->getCurrentLayout()->onBeginDragWindow(); + + return; } break; case WLR_BUTTON_RELEASED: @@ -87,8 +104,6 @@ void CInputManager::onMouseButton(wlr_event_pointer_button* e) { break; } - g_pCompositor->focusWindow(g_pCompositor->vectorToWindowIdeal(Vector2D(g_pCompositor->m_sWLRCursor->x, g_pCompositor->m_sWLRCursor->y))); - // notify app if we didnt handle it wlr_seat_pointer_notify_button(g_pCompositor->m_sWLRSeat, e->time_msec, e->button, e->state); } diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index befff4b8..a26a943b 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -44,6 +44,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t else if (k.handler == "killactive") { killActive(k.arg); } else if (k.handler == "togglefloating") { toggleActiveFloating(k.arg); } else if (k.handler == "workspace") { changeworkspace(k.arg); } + else if (k.handler == "fullscreen") { fullscreenActive(k.arg); } found = true; } @@ -143,4 +144,13 @@ void CKeybindManager::changeworkspace(std::string args) { // we need to move XWayland windows to narnia or otherwise they will still process our cursor and shit // and that'd be annoying as hell g_pCompositor->fixXWaylandWindowsOnWorkspace(OLDWORKSPACE); +} + +void CKeybindManager::fullscreenActive(std::string args) { + const auto PWINDOW = g_pCompositor->getWindowFromSurface(g_pCompositor->m_pLastFocus); + + if (!g_pCompositor->windowValidMapped(PWINDOW)) + return; + + g_pLayoutManager->getCurrentLayout()->fullscreenRequestForWindow(PWINDOW); } \ No newline at end of file diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index abff6b4b..817b34fb 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -27,6 +27,7 @@ private: void spawn(std::string); void toggleActiveFloating(std::string); void changeworkspace(std::string); + void fullscreenActive(std::string); }; inline std::unique_ptr g_pKeybindManager; \ No newline at end of file -- cgit v1.2.3