From ae1bcc909da8d69c3e5c642715a4f57468fb5ddd Mon Sep 17 00:00:00 2001 From: Sebastian Ouellette Date: Sun, 19 Jun 2022 16:07:41 -0400 Subject: Invisible cursors are constrained to center This is a first version of my test to properly constrain cursors. This is mostly working in the buggy applications I had before, but I feel that the cursor needs to actually move around, instead of being locked to the center of the window. This may cause problems when locking to the edge, but yeah. --- src/managers/input/InputManager.cpp | 40 +++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 003535f7..ab8e3563 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -4,7 +4,7 @@ void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) { float sensitivity = g_pConfigManager->getFloat("general:sensitivity"); - const auto DELTA = g_pConfigManager->getInt("input:force_no_accel") == 1 ? Vector2D(e->unaccel_dx, e->unaccel_dy) : Vector2D(e->delta_x, e->delta_y); + const auto DELTA = g_pConfigManager->getInt("input:force_no_accel") != 1 ? Vector2D(e->unaccel_dx, e->unaccel_dy) : Vector2D(e->delta_x, e->delta_y); if (g_pConfigManager->getInt("general:apply_sens_to_raw") == 1) wlr_relative_pointer_manager_v1_send_relative_motion(g_pCompositor->m_sWLRRelPointerMgr, g_pCompositor->m_sSeat.seat, (uint64_t)e->time_msec * 1000, DELTA.x * sensitivity, DELTA.y * sensitivity, e->unaccel_dx * sensitivity, e->unaccel_dy * sensitivity); @@ -32,6 +32,12 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { return; } + // Update stuff + //updateDragIcon(); + + //g_pLayoutManager->getCurrentLayout()->onMouseMove(getMouseCoordsInternal()); + + Vector2D mouseCoords = getMouseCoordsInternal(); const auto PMONITOR = g_pCompositor->getMonitorFromCursor(); @@ -47,24 +53,28 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { } else { // Native Wayland apps know how 2 constrain themselves. // XWayland, we just have to accept them. Might cause issues, but thats XWayland for ya. - const auto CONSTRAINTPOS = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->x, CONSTRAINTWINDOW->m_uSurface.xwayland->y) : CONSTRAINTWINDOW->m_vRealPosition.vec(); - const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec(); + + const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec(); + const auto CONSTRAINTPOS = Vector2D((CONSTRAINTWINDOW->m_uSurface.xwayland->x + CONSTRAINTSIZE.x) / 2.0, (CONSTRAINTWINDOW->m_uSurface.xwayland->y + CONSTRAINTSIZE.y)); + - if (!VECINRECT(mouseCoords, CONSTRAINTPOS.x, CONSTRAINTPOS.y, CONSTRAINTPOS.x + CONSTRAINTSIZE.x, CONSTRAINTPOS.y + CONSTRAINTSIZE.y)) { + // I'm a worm and I added some code to override some annoying stuff :) + // CONSTRAINTSIZE = Vector2D(0.0, 0.0); + + if (!VECINRECT(mouseCoords, CONSTRAINTPOS.x, CONSTRAINTPOS.y, CONSTRAINTPOS.x/* + CONSTRAINTSIZE.x*/, CONSTRAINTPOS.y/* + CONSTRAINTSIZE.y*/)) { if (g_pCompositor->m_sSeat.mouse->constraintActive) { Vector2D deltaToFit; - if (mouseCoords.x < CONSTRAINTPOS.x) - deltaToFit.x = CONSTRAINTPOS.x - mouseCoords.x; - else if (mouseCoords.x > CONSTRAINTPOS.x + CONSTRAINTSIZE.x) - deltaToFit.x = CONSTRAINTPOS.x + CONSTRAINTSIZE.x - mouseCoords.x; - - if (mouseCoords.y < CONSTRAINTPOS.y) - deltaToFit.y = CONSTRAINTPOS.y - mouseCoords.y; - else if (mouseCoords.y > CONSTRAINTPOS.y + CONSTRAINTSIZE.y) - deltaToFit.y = CONSTRAINTPOS.y + CONSTRAINTSIZE.y - mouseCoords.y; - - wlr_cursor_move(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, deltaToFit.x, deltaToFit.y); + + deltaToFit.x = CONSTRAINTPOS.x - mouseCoords.x; + + + deltaToFit.y = CONSTRAINTPOS.y - mouseCoords.y; + + // Deadzone... necessary ig + if (deltaToFit.x * deltaToFit.x > 2 && deltaToFit.y * deltaToFit.y > 2) { + wlr_cursor_warp_closest(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, CONSTRAINTPOS.x, CONSTRAINTPOS.y); + } mouseCoords = mouseCoords + deltaToFit; } -- cgit v1.2.3 From 5058a74453148bb1b476c362ecc5ea27203c202a Mon Sep 17 00:00:00 2001 From: SebOuellette Date: Sun, 19 Jun 2022 16:23:49 -0400 Subject: Cleaned up some old debug --- src/managers/input/InputManager.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index ab8e3563..ff2cd503 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -4,7 +4,7 @@ void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) { float sensitivity = g_pConfigManager->getFloat("general:sensitivity"); - const auto DELTA = g_pConfigManager->getInt("input:force_no_accel") != 1 ? Vector2D(e->unaccel_dx, e->unaccel_dy) : Vector2D(e->delta_x, e->delta_y); + const auto DELTA = g_pConfigManager->getInt("input:force_no_accel") == 1 ? Vector2D(e->unaccel_dx, e->unaccel_dy) : Vector2D(e->delta_x, e->delta_y); if (g_pConfigManager->getInt("general:apply_sens_to_raw") == 1) wlr_relative_pointer_manager_v1_send_relative_motion(g_pCompositor->m_sWLRRelPointerMgr, g_pCompositor->m_sSeat.seat, (uint64_t)e->time_msec * 1000, DELTA.x * sensitivity, DELTA.y * sensitivity, e->unaccel_dx * sensitivity, e->unaccel_dy * sensitivity); @@ -29,15 +29,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { if (!g_pCompositor->m_sSeat.mouse) { Debug::log(ERR, "BUG THIS: Mouse move on mouse nullptr!"); - return; + return; } - // Update stuff - //updateDragIcon(); - - //g_pLayoutManager->getCurrentLayout()->onMouseMove(getMouseCoordsInternal()); - - Vector2D mouseCoords = getMouseCoordsInternal(); const auto PMONITOR = g_pCompositor->getMonitorFromCursor(); @@ -65,16 +59,14 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { if (g_pCompositor->m_sSeat.mouse->constraintActive) { Vector2D deltaToFit; - - deltaToFit.x = CONSTRAINTPOS.x - mouseCoords.x; - - + + // Instead of constraining the cursor to the entire window, like in the previous version, this keeps the cursor to the center of the window. + // This allows for maximum mouse movement to be captured by the application, while the mouse can still be freed and move around when it is supposed to be + deltaToFit.x = CONSTRAINTPOS.x - mouseCoords.x; deltaToFit.y = CONSTRAINTPOS.y - mouseCoords.y; - // Deadzone... necessary ig - if (deltaToFit.x * deltaToFit.x > 2 && deltaToFit.y * deltaToFit.y > 2) { - wlr_cursor_warp_closest(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, CONSTRAINTPOS.x, CONSTRAINTPOS.y); - } + + wlr_cursor_move(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, deltaToFit.x, deltaToFit.y); mouseCoords = mouseCoords + deltaToFit; } -- cgit v1.2.3 From 95e083dbd3baec094220848592e9258de8acf2cc Mon Sep 17 00:00:00 2001 From: Sebastian Ouellette Date: Sun, 19 Jun 2022 16:51:03 -0400 Subject: Converted tabs to spaces. Now ready for PR --- src/managers/input/InputManager.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index ff2cd503..d5bfd8fd 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -29,7 +29,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { if (!g_pCompositor->m_sSeat.mouse) { Debug::log(ERR, "BUG THIS: Mouse move on mouse nullptr!"); - return; + return; } Vector2D mouseCoords = getMouseCoordsInternal(); @@ -48,8 +48,8 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { // Native Wayland apps know how 2 constrain themselves. // XWayland, we just have to accept them. Might cause issues, but thats XWayland for ya. - const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec(); - const auto CONSTRAINTPOS = Vector2D((CONSTRAINTWINDOW->m_uSurface.xwayland->x + CONSTRAINTSIZE.x) / 2.0, (CONSTRAINTWINDOW->m_uSurface.xwayland->y + CONSTRAINTSIZE.y)); + const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec(); + const auto CONSTRAINTPOS = Vector2D((CONSTRAINTWINDOW->m_uSurface.xwayland->x + CONSTRAINTSIZE.x) / 2.0, (CONSTRAINTWINDOW->m_uSurface.xwayland->y + CONSTRAINTSIZE.y)); // I'm a worm and I added some code to override some annoying stuff :) @@ -63,10 +63,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { // Instead of constraining the cursor to the entire window, like in the previous version, this keeps the cursor to the center of the window. // This allows for maximum mouse movement to be captured by the application, while the mouse can still be freed and move around when it is supposed to be deltaToFit.x = CONSTRAINTPOS.x - mouseCoords.x; - deltaToFit.y = CONSTRAINTPOS.y - mouseCoords.y; + deltaToFit.y = CONSTRAINTPOS.y - mouseCoords.y; - wlr_cursor_move(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, deltaToFit.x, deltaToFit.y); + wlr_cursor_move(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, deltaToFit.x, deltaToFit.y); mouseCoords = mouseCoords + deltaToFit; } -- cgit v1.2.3 From dc849350597e9eaaa8badab46667dc06d802f650 Mon Sep 17 00:00:00 2001 From: Sebastian Ouellette Date: Sun, 19 Jun 2022 16:54:59 -0400 Subject: Set the constraint position to the window center (properly) Missed one expression, it was set to the bottom middle. I missed it because i don't have an extra monitor extending from the bottom of that screen. --- src/managers/input/InputManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index d5bfd8fd..139cafdb 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -49,7 +49,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { // XWayland, we just have to accept them. Might cause issues, but thats XWayland for ya. const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec(); - const auto CONSTRAINTPOS = Vector2D((CONSTRAINTWINDOW->m_uSurface.xwayland->x + CONSTRAINTSIZE.x) / 2.0, (CONSTRAINTWINDOW->m_uSurface.xwayland->y + CONSTRAINTSIZE.y)); + const auto CONSTRAINTPOS = Vector2D((CONSTRAINTWINDOW->m_uSurface.xwayland->x + CONSTRAINTSIZE.x) / 2.0, (CONSTRAINTWINDOW->m_uSurface.xwayland->y + CONSTRAINTSIZE.y) / 2.0); // I'm a worm and I added some code to override some annoying stuff :) -- cgit v1.2.3 From ee7900f819c8db0e9c2cc44c193707dfc9ce7957 Mon Sep 17 00:00:00 2001 From: SebOuellette Date: Mon, 20 Jun 2022 23:15:16 -0400 Subject: Mouse no longer removes focus from constraining window The window properly constrains the mouse now I do still notice a bug with moving the mouse in games, if you don't move the mouse fast enough, some games will not register the mouse movement. This doesn't happen in KDE so I know it's related somehow --- src/managers/input/InputManager.cpp | 38 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 139cafdb..a6dd6424 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -47,28 +47,26 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { } else { // Native Wayland apps know how 2 constrain themselves. // XWayland, we just have to accept them. Might cause issues, but thats XWayland for ya. - + const auto CONSTRAINTPOS = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->x, CONSTRAINTWINDOW->m_uSurface.xwayland->y) : CONSTRAINTWINDOW->m_vRealPosition.vec(); const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec(); - const auto CONSTRAINTPOS = Vector2D((CONSTRAINTWINDOW->m_uSurface.xwayland->x + CONSTRAINTSIZE.x) / 2.0, (CONSTRAINTWINDOW->m_uSurface.xwayland->y + CONSTRAINTSIZE.y) / 2.0); - - - // I'm a worm and I added some code to override some annoying stuff :) - // CONSTRAINTSIZE = Vector2D(0.0, 0.0); - if (!VECINRECT(mouseCoords, CONSTRAINTPOS.x, CONSTRAINTPOS.y, CONSTRAINTPOS.x/* + CONSTRAINTSIZE.x*/, CONSTRAINTPOS.y/* + CONSTRAINTSIZE.y*/)) { + if (!VECINRECT(mouseCoords, CONSTRAINTPOS.x, CONSTRAINTPOS.y, CONSTRAINTPOS.x + CONSTRAINTSIZE.x, CONSTRAINTPOS.y + CONSTRAINTSIZE.y)) { if (g_pCompositor->m_sSeat.mouse->constraintActive) { - Vector2D deltaToFit; - - - // Instead of constraining the cursor to the entire window, like in the previous version, this keeps the cursor to the center of the window. - // This allows for maximum mouse movement to be captured by the application, while the mouse can still be freed and move around when it is supposed to be - deltaToFit.x = CONSTRAINTPOS.x - mouseCoords.x; - deltaToFit.y = CONSTRAINTPOS.y - mouseCoords.y; - - - wlr_cursor_move(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, deltaToFit.x, deltaToFit.y); - - mouseCoords = mouseCoords + deltaToFit; + Vector2D newConstrainedCoords = mouseCoords; + + if (mouseCoords.x < CONSTRAINTPOS.x) + newConstrainedCoords.x = CONSTRAINTPOS.x; + else if (mouseCoords.x >= CONSTRAINTPOS.x + CONSTRAINTSIZE.x) + newConstrainedCoords.x = CONSTRAINTPOS.x + CONSTRAINTSIZE.x - 1.0; + + if (mouseCoords.y < CONSTRAINTPOS.y) + newConstrainedCoords.y = CONSTRAINTPOS.y; + else if (mouseCoords.y >= CONSTRAINTPOS.y + CONSTRAINTSIZE.y) + newConstrainedCoords.y = CONSTRAINTPOS.y + CONSTRAINTSIZE.y - 1.0; + + wlr_cursor_warp_closest(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, newConstrainedCoords.x, newConstrainedCoords.y); + + mouseCoords = newConstrainedCoords; } } else { if ((!CONSTRAINTWINDOW->m_bIsX11 && PMONITOR && CONSTRAINTWINDOW->m_iWorkspaceID == PMONITOR->activeWorkspace) || (CONSTRAINTWINDOW->m_bIsX11)) { @@ -543,4 +541,4 @@ void CInputManager::updateCapabilities(wlr_input_device* pDev) { } wlr_seat_set_capabilities(g_pCompositor->m_sSeat.seat, m_uiCapabilities); -} +} \ No newline at end of file -- cgit v1.2.3 From 3dc2277fd05cbb71b858698fed749070a63aa392 Mon Sep 17 00:00:00 2001 From: SebOuellette Date: Tue, 21 Jun 2022 02:23:57 -0400 Subject: Actually, mostly working. One failure case: When there is a fullscreen window directly to the right of a game, for example, in a multimonitor setup, then the cursor will bug out in between the monitors. sometimes it will get constrained to the border, but just outside the window (which is what this PR fixes, so it's unusual) and sometimes the cursor will just ignore the constraint entirely. However this is only in the one case. --- src/managers/input/InputManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index a6dd6424..a388fba9 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -50,7 +50,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { const auto CONSTRAINTPOS = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->x, CONSTRAINTWINDOW->m_uSurface.xwayland->y) : CONSTRAINTWINDOW->m_vRealPosition.vec(); const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec(); - if (!VECINRECT(mouseCoords, CONSTRAINTPOS.x, CONSTRAINTPOS.y, CONSTRAINTPOS.x + CONSTRAINTSIZE.x, CONSTRAINTPOS.y + CONSTRAINTSIZE.y)) { + if (!VECINRECT(mouseCoords, CONSTRAINTPOS.x, CONSTRAINTPOS.y, CONSTRAINTPOS.x + CONSTRAINTSIZE.x - 1.0, CONSTRAINTPOS.y + CONSTRAINTSIZE.y - 1.0)) { if (g_pCompositor->m_sSeat.mouse->constraintActive) { Vector2D newConstrainedCoords = mouseCoords; -- cgit v1.2.3 From ff49f2244069124d366e2eba5e5474398a14281a Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 21 Jun 2022 22:13:13 +0200 Subject: fix rapid blinking on launch --- src/events/Monitors.cpp | 9 +++++++-- src/helpers/Monitor.hpp | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index e5fa7c55..25756548 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -140,6 +140,8 @@ void Events::listener_newOutput(wl_listener* listener, void* data) { PNEWMONITOR->activeWorkspace = PNEWWORKSPACE->m_iID; PNEWMONITOR->scale = monitorRule.scale; + PNEWMONITOR->forceFullFrames = 3; // force 3 full frames to make sure there is no blinking due to double-buffering. + g_pCompositor->deactivateAllWLRWorkspaces(PNEWWORKSPACE->m_pWlrHandle); PNEWWORKSPACE->setActive(true); @@ -216,7 +218,7 @@ void Events::listener_monitorFrame(void* owner, void* data) { return; } - if (!hasChanged && *PDAMAGETRACKINGMODE != DAMAGE_TRACKING_NONE) { + if (!hasChanged && *PDAMAGETRACKINGMODE != DAMAGE_TRACKING_NONE && PMONITOR->forceFullFrames == 0) { pixman_region32_fini(&damage); wlr_output_rollback(PMONITOR->output); wlr_output_schedule_frame(PMONITOR->output); // we update shit at the monitor's Hz so we need to schedule frames because rollback wont @@ -224,7 +226,7 @@ void Events::listener_monitorFrame(void* owner, void* data) { } // if we have no tracking or full tracking, invalidate the entire monitor - if (*PDAMAGETRACKINGMODE == DAMAGE_TRACKING_NONE || *PDAMAGETRACKINGMODE == DAMAGE_TRACKING_MONITOR) { + if (*PDAMAGETRACKINGMODE == DAMAGE_TRACKING_NONE || *PDAMAGETRACKINGMODE == DAMAGE_TRACKING_MONITOR || PMONITOR->forceFullFrames > 0) { pixman_region32_union_rect(&damage, &damage, 0, 0, (int)PMONITOR->vecTransformedSize.x, (int)PMONITOR->vecTransformedSize.y); pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage); @@ -247,6 +249,9 @@ void Events::listener_monitorFrame(void* owner, void* data) { } } + if (PMONITOR->forceFullFrames > 0) + PMONITOR->forceFullFrames -= 1; + // TODO: this is getting called with extents being 0,0,0,0 should it be? // potentially can save on resources. diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 4767fd78..24e555f9 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -28,6 +28,7 @@ struct SMonitor { float refreshRate = 60; wlr_output_damage* damage = nullptr; int framesToSkip = 0; + int forceFullFrames = 0; bool noFrameSchedule = false; wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL; -- cgit v1.2.3 From 4a3f9ccba2cebaf62d6001c2b700367785a7179c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 21 Jun 2022 22:17:30 +0200 Subject: move ignore to eventmanager and fix double focus in changeworkspace --- src/managers/EventManager.cpp | 6 ++++++ src/managers/EventManager.hpp | 2 ++ src/managers/KeybindManager.cpp | 14 ++++---------- src/managers/KeybindManager.hpp | 2 -- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/managers/EventManager.cpp b/src/managers/EventManager.cpp index eed0e6e5..409fbd90 100644 --- a/src/managers/EventManager.cpp +++ b/src/managers/EventManager.cpp @@ -105,6 +105,12 @@ void CEventManager::startThread() { } void CEventManager::postEvent(const SHyprIPCEvent event) { + + if (m_bIgnoreEvents) { + Debug::log(WARN, "Suppressed (ignoreevents true) event of type %s, content: %s"); + return; + } + std::thread([&](const SHyprIPCEvent ev) { eventQueueMutex.lock(); m_dQueuedEvents.push_back(ev); diff --git a/src/managers/EventManager.hpp b/src/managers/EventManager.hpp index f8ec6afc..ae630ce8 100644 --- a/src/managers/EventManager.hpp +++ b/src/managers/EventManager.hpp @@ -19,6 +19,8 @@ public: void startThread(); + bool m_bIgnoreEvents = false; + private: std::mutex eventQueueMutex; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 123e560c..96d8ce60 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -280,9 +280,7 @@ void CKeybindManager::changeworkspace(std::string args) { // start anim on new workspace PWORKSPACETOCHANGETO->startAnim(true, ANIMTOLEFT); - // Event ONLY if workspace is actually "changed" and we arent just focusing - if (!m_bSuppressWorkspaceChangeEvents) - g_pEventManager->postEvent(SHyprIPCEvent("workspace", PWORKSPACETOCHANGETO->m_szName)); + g_pEventManager->postEvent(SHyprIPCEvent("workspace", PWORKSPACETOCHANGETO->m_szName)); } // If the monitor is not the one our cursor's at, warp to it. @@ -291,9 +289,6 @@ void CKeybindManager::changeworkspace(std::string args) { wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, middle.x, middle.y); } - // focus the first window - g_pCompositor->focusWindow(g_pCompositor->getFirstWindowOnWorkspace(workspaceToChangeTo)); - // set active and deactivate all other in wlr g_pCompositor->deactivateAllWLRWorkspaces(PWORKSPACETOCHANGETO->m_pWlrHandle); PWORKSPACETOCHANGETO->setActive(true); @@ -360,8 +355,7 @@ void CKeybindManager::changeworkspace(std::string args) { g_pInputManager->refocus(); // Event - if (!m_bSuppressWorkspaceChangeEvents) - g_pEventManager->postEvent(SHyprIPCEvent("workspace", PWORKSPACE->m_szName)); + g_pEventManager->postEvent(SHyprIPCEvent("workspace", PWORKSPACE->m_szName)); Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo); } @@ -491,7 +485,7 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) { const auto POLDWORKSPACEONMON = g_pCompositor->getWorkspaceByID(OLDWORKSPACEIDONMONITOR); const auto POLDWORKSPACEIDRETURN = g_pCompositor->getWorkspaceByID(OLDWORKSPACEIDRETURN); - m_bSuppressWorkspaceChangeEvents = true; + g_pEventManager->m_bIgnoreEvents = true; moveActiveToWorkspace(args); @@ -510,7 +504,7 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) { POLDWORKSPACEONMON->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0)); POLDWORKSPACEONMON->m_fAlpha.setValueAndWarp(255.f); - m_bSuppressWorkspaceChangeEvents = false; + g_pEventManager->m_bIgnoreEvents = false; g_pInputManager->refocus(); } diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index 782f2ead..cb99aa41 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -30,8 +30,6 @@ private: bool handleInternalKeybinds(xkb_keysym_t); - inline static bool m_bSuppressWorkspaceChangeEvents = false; - // -------------- Dispatchers -------------- // static void killActive(std::string); static void spawn(std::string); -- cgit v1.2.3 From 20ad9d3e7d8a6c8a6098a6fc77f9d0f27910c7d7 Mon Sep 17 00:00:00 2001 From: SebOuellette Date: Tue, 21 Jun 2022 16:25:40 -0400 Subject: Passes all constraint tests! So a summary of what's been done in this fork/PR. Instead of moving the cursor, we're warp_closest ing. warp_absolute didn't work, so warp closest has kindof an auto constrain feature so it works beautifully. I'm also contraining to the right side of the window - 1, because the cursors are treating that pixel as the next pixel over, so it was actually thinking it was on the next monitor (assuming fullscreen) when the cursor got to the right or bottom of the window. TL;DR rounding issue. This fix didn't work when you had a fullscreen video playing on a monitor beside, so I also fixed that by ignoring all focus changes or whatever when a constraint actually occured, we obviously just don't want to focus another monitor when constrained, so why not just *disable it when a constraint happened* The PR is now ready, I love Hyprland, and I can't wait to contribute more :) --- src/managers/input/InputManager.cpp | 166 +++++++++++++++++++----------------- 1 file changed, 86 insertions(+), 80 deletions(-) (limited to 'src') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index a388fba9..2f63ecfa 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -35,6 +35,8 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { Vector2D mouseCoords = getMouseCoordsInternal(); const auto PMONITOR = g_pCompositor->getMonitorFromCursor(); + bool didConstraintOnCursor = false; + // constraints // All constraints TODO: multiple mice? if (g_pCompositor->m_sSeat.mouse->currentConstraint) { @@ -67,6 +69,8 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { wlr_cursor_warp_closest(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, newConstrainedCoords.x, newConstrainedCoords.y); mouseCoords = newConstrainedCoords; + + didConstraintOnCursor = true; } } else { if ((!CONSTRAINTWINDOW->m_bIsX11 && PMONITOR && CONSTRAINTWINDOW->m_iWorkspaceID == PMONITOR->activeWorkspace) || (CONSTRAINTWINDOW->m_bIsX11)) { @@ -84,110 +88,112 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { // focus wlr_surface* foundSurface = nullptr; - if (PMONITOR && PMONITOR != g_pCompositor->m_pLastMonitor) { - g_pCompositor->m_pLastMonitor = PMONITOR; + if (!didConstraintOnCursor) { + if (PMONITOR && PMONITOR != g_pCompositor->m_pLastMonitor) { + g_pCompositor->m_pLastMonitor = PMONITOR; - // set active workspace and deactivate all other in wlr - const auto ACTIVEWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); - g_pCompositor->deactivateAllWLRWorkspaces(ACTIVEWORKSPACE->m_pWlrHandle); - ACTIVEWORKSPACE->setActive(true); + // set active workspace and deactivate all other in wlr + const auto ACTIVEWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); + g_pCompositor->deactivateAllWLRWorkspaces(ACTIVEWORKSPACE->m_pWlrHandle); + ACTIVEWORKSPACE->setActive(true); - // event - g_pEventManager->postEvent(SHyprIPCEvent("activemon", PMONITOR->szName + "," + ACTIVEWORKSPACE->m_szName)); - } + // event + g_pEventManager->postEvent(SHyprIPCEvent("activemon", PMONITOR->szName + "," + ACTIVEWORKSPACE->m_szName)); + } - Vector2D surfaceCoords; - Vector2D surfacePos = Vector2D(-1337, -1337); - CWindow* pFoundWindow = nullptr; - - // overlay is above fullscreen - if (!foundSurface) - foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &surfaceCoords); - - // then, we check if the workspace doesnt have a fullscreen window - const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); - if (PWORKSPACE->m_bHasFullscreenWindow && !foundSurface && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) { - pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); - foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow); - surfacePos = pFoundWindow->m_vRealPosition.vec(); - - // only check floating because tiled cant be over fullscreen - for (auto w = g_pCompositor->m_lWindows.rbegin(); w != g_pCompositor->m_lWindows.rend(); w++) { - wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y}; - if (((w->m_bIsFloating && w->m_bIsMapped && w->m_bCreatedOverFullscreen) || (w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && PMONITOR->specialWorkspaceOpen)) && wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible(w->m_iWorkspaceID) && !w->m_bHidden) { - pFoundWindow = &(*w); - + Vector2D surfaceCoords; + Vector2D surfacePos = Vector2D(-1337, -1337); + CWindow* pFoundWindow = nullptr; + + // overlay is above fullscreen + if (!foundSurface) + foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &surfaceCoords); + + // then, we check if the workspace doesnt have a fullscreen window + const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); + if (PWORKSPACE->m_bHasFullscreenWindow && !foundSurface && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) { + pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); + foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow); + surfacePos = pFoundWindow->m_vRealPosition.vec(); + + // only check floating because tiled cant be over fullscreen + for (auto w = g_pCompositor->m_lWindows.rbegin(); w != g_pCompositor->m_lWindows.rend(); w++) { + wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y}; + if (((w->m_bIsFloating && w->m_bIsMapped && w->m_bCreatedOverFullscreen) || (w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && PMONITOR->specialWorkspaceOpen)) && wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible(w->m_iWorkspaceID) && !w->m_bHidden) { + pFoundWindow = &(*w); + + if (!pFoundWindow->m_bIsX11) { + foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords); + } else { + foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow); + surfacePos = pFoundWindow->m_vRealPosition.vec(); + } + + break; + } + } + } + + if (!foundSurface) + foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords); + + // then windows + if (!foundSurface) { + pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords); + if (pFoundWindow) { if (!pFoundWindow->m_bIsX11) { foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords); } else { foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow); surfacePos = pFoundWindow->m_vRealPosition.vec(); } - - break; - } - } - } - - if (!foundSurface) - foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords); - - // then windows - if (!foundSurface) { - pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords); - if (pFoundWindow) { - if (!pFoundWindow->m_bIsX11) { - foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords); - } else { - foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow); - surfacePos = pFoundWindow->m_vRealPosition.vec(); } } - } - // then surfaces below - if (!foundSurface) - foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], &surfaceCoords); + // then surfaces below + if (!foundSurface) + foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], &surfaceCoords); - if (!foundSurface) - foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], &surfaceCoords); + if (!foundSurface) + foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], &surfaceCoords); - if (!foundSurface) { - wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor); + if (!foundSurface) { + wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor); - wlr_seat_pointer_clear_focus(g_pCompositor->m_sSeat.seat); + wlr_seat_pointer_clear_focus(g_pCompositor->m_sSeat.seat); - return; - } + return; + } - if (time) - wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat); + if (time) + wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat); - Vector2D surfaceLocal = surfacePos == Vector2D(-1337, -1337) ? surfaceCoords : mouseCoords - surfacePos; + Vector2D surfaceLocal = surfacePos == Vector2D(-1337, -1337) ? surfaceCoords : mouseCoords - surfacePos; - if (pFoundWindow) { - static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue; - if (*PFOLLOWMOUSE != 1 && !refocus) { - if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && (g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating)) { - // enter if change floating style + if (pFoundWindow) { + static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue; + if (*PFOLLOWMOUSE != 1 && !refocus) { + if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && (g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating)) { + // enter if change floating style + g_pCompositor->focusWindow(pFoundWindow, foundSurface); + wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); + } + else if (*PFOLLOWMOUSE == 2) { + wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); + } + wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y); + return; // don't enter any new surfaces + } else { g_pCompositor->focusWindow(pFoundWindow, foundSurface); - wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); } - else if (*PFOLLOWMOUSE == 2) { - wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); - } - wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y); - return; // don't enter any new surfaces - } else { - g_pCompositor->focusWindow(pFoundWindow, foundSurface); } - } - else - g_pCompositor->focusSurface(foundSurface); + else + g_pCompositor->focusSurface(foundSurface); - wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); - wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y); + wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); + wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y); + } } void CInputManager::onMouseButton(wlr_pointer_button_event* e) { -- cgit v1.2.3 From 84d6e640ff6e48c8161e1922349c7bce6b0b335f Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 21 Jun 2022 22:25:54 +0200 Subject: support all workspace types in workspace keyword --- src/config/ConfigManager.cpp | 4 ++-- src/config/ConfigManager.hpp | 2 +- src/events/Monitors.cpp | 17 ++++++++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index d511c05a..b76ab965 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -495,11 +495,11 @@ void CConfigManager::handleWindowRule(const std::string& command, const std::str void CConfigManager::handleDefaultWorkspace(const std::string& command, const std::string& value) { const auto DISPLAY = value.substr(0, value.find_first_of(',')); - const auto WORKSPACEID = stoi(value.substr(value.find_first_of(',') + 1)); + const auto WORKSPACE = value.substr(value.find_first_of(',') + 1); for (auto& mr : m_dMonitorRules) { if (mr.name == DISPLAY) { - mr.defaultWorkspaceID = WORKSPACEID; + mr.defaultWorkspace = WORKSPACE; break; } } diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 866b8b8e..0d4386c1 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -28,7 +28,7 @@ struct SMonitorRule { Vector2D offset = Vector2D(0,0); float scale = 1; float refreshRate = 60; - int defaultWorkspaceID = -1; + std::string defaultWorkspace = ""; bool disabled = false; wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL; }; diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index 25756548..afbc0745 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -114,7 +114,15 @@ void Events::listener_newOutput(wl_listener* listener, void* data) { wlr_ext_workspace_group_handle_v1_output_enter(PNEWMONITOR->pWLRWorkspaceGroupHandle, PNEWMONITOR->output); // Workspace - const auto WORKSPACEID = monitorRule.defaultWorkspaceID == -1 ? g_pCompositor->m_lWorkspaces.size() + 1 /* Cuz workspaces doesnt have the new one yet and we start with 1 */ : monitorRule.defaultWorkspaceID; + std::string newDefaultWorkspaceName = ""; + auto WORKSPACEID = monitorRule.defaultWorkspace == "" ? g_pCompositor->m_lWorkspaces.size() + 1 : getWorkspaceIDFromString(monitorRule.defaultWorkspace, newDefaultWorkspaceName); + + if (WORKSPACEID == INT_MAX || WORKSPACEID == (long unsigned int)SPECIAL_WORKSPACE_ID) { + WORKSPACEID = g_pCompositor->m_lWorkspaces.size() + 1; + newDefaultWorkspaceName = std::to_string(WORKSPACEID); + + Debug::log(LOG, "Invalid workspace= directive name in monitor parsing, workspace name \"%s\" is invalid.", monitorRule.defaultWorkspace); + } auto PNEWWORKSPACE = g_pCompositor->getWorkspaceByID(WORKSPACEID); @@ -127,14 +135,13 @@ void Events::listener_newOutput(wl_listener* listener, void* data) { g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PNEWMONITOR->ID); PNEWWORKSPACE->startAnim(true,true,true); } else { - g_pCompositor->m_lWorkspaces.emplace_back(newMonitor.ID); - PNEWWORKSPACE = &g_pCompositor->m_lWorkspaces.back(); + PNEWWORKSPACE = &g_pCompositor->m_lWorkspaces.emplace_back(newMonitor.ID); // We are required to set the name here immediately - wlr_ext_workspace_handle_v1_set_name(PNEWWORKSPACE->m_pWlrHandle, std::to_string(WORKSPACEID).c_str()); + wlr_ext_workspace_handle_v1_set_name(PNEWWORKSPACE->m_pWlrHandle, newDefaultWorkspaceName.c_str()); PNEWWORKSPACE->m_iID = WORKSPACEID; - PNEWWORKSPACE->m_szName = std::to_string(WORKSPACEID); + PNEWWORKSPACE->m_szName = newDefaultWorkspaceName; } PNEWMONITOR->activeWorkspace = PNEWWORKSPACE->m_iID; -- cgit v1.2.3 From 1810725a0c2b25710f147799a50233ec22506072 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 21 Jun 2022 22:29:11 +0200 Subject: cleaner code --- src/managers/input/InputManager.cpp | 156 ++++++++++++++++++------------------ 1 file changed, 77 insertions(+), 79 deletions(-) (limited to 'src') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 2f63ecfa..50a4dc5e 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -88,112 +88,110 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { // focus wlr_surface* foundSurface = nullptr; - if (!didConstraintOnCursor) { - if (PMONITOR && PMONITOR != g_pCompositor->m_pLastMonitor) { - g_pCompositor->m_pLastMonitor = PMONITOR; + if (didConstraintOnCursor) + return; // don't process when cursor constrained - // set active workspace and deactivate all other in wlr - const auto ACTIVEWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); - g_pCompositor->deactivateAllWLRWorkspaces(ACTIVEWORKSPACE->m_pWlrHandle); - ACTIVEWORKSPACE->setActive(true); + if (PMONITOR && PMONITOR != g_pCompositor->m_pLastMonitor) { + g_pCompositor->m_pLastMonitor = PMONITOR; - // event - g_pEventManager->postEvent(SHyprIPCEvent("activemon", PMONITOR->szName + "," + ACTIVEWORKSPACE->m_szName)); - } + // set active workspace and deactivate all other in wlr + const auto ACTIVEWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); + g_pCompositor->deactivateAllWLRWorkspaces(ACTIVEWORKSPACE->m_pWlrHandle); + ACTIVEWORKSPACE->setActive(true); - Vector2D surfaceCoords; - Vector2D surfacePos = Vector2D(-1337, -1337); - CWindow* pFoundWindow = nullptr; - - // overlay is above fullscreen - if (!foundSurface) - foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &surfaceCoords); - - // then, we check if the workspace doesnt have a fullscreen window - const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); - if (PWORKSPACE->m_bHasFullscreenWindow && !foundSurface && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) { - pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); - foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow); - surfacePos = pFoundWindow->m_vRealPosition.vec(); - - // only check floating because tiled cant be over fullscreen - for (auto w = g_pCompositor->m_lWindows.rbegin(); w != g_pCompositor->m_lWindows.rend(); w++) { - wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y}; - if (((w->m_bIsFloating && w->m_bIsMapped && w->m_bCreatedOverFullscreen) || (w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && PMONITOR->specialWorkspaceOpen)) && wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible(w->m_iWorkspaceID) && !w->m_bHidden) { - pFoundWindow = &(*w); - - if (!pFoundWindow->m_bIsX11) { - foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords); - } else { - foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow); - surfacePos = pFoundWindow->m_vRealPosition.vec(); - } + // event + g_pEventManager->postEvent(SHyprIPCEvent("activemon", PMONITOR->szName + "," + ACTIVEWORKSPACE->m_szName)); + } - break; - } - } - } + Vector2D surfaceCoords; + Vector2D surfacePos = Vector2D(-1337, -1337); + CWindow* pFoundWindow = nullptr; - if (!foundSurface) - foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords); + // overlay is above fullscreen + if (!foundSurface) + foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &surfaceCoords); + + // then, we check if the workspace doesnt have a fullscreen window + const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); + if (PWORKSPACE->m_bHasFullscreenWindow && !foundSurface && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) { + pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); + foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow); + surfacePos = pFoundWindow->m_vRealPosition.vec(); + + // only check floating because tiled cant be over fullscreen + for (auto w = g_pCompositor->m_lWindows.rbegin(); w != g_pCompositor->m_lWindows.rend(); w++) { + wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y}; + if (((w->m_bIsFloating && w->m_bIsMapped && w->m_bCreatedOverFullscreen) || (w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && PMONITOR->specialWorkspaceOpen)) && wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible(w->m_iWorkspaceID) && !w->m_bHidden) { + pFoundWindow = &(*w); - // then windows - if (!foundSurface) { - pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords); - if (pFoundWindow) { if (!pFoundWindow->m_bIsX11) { foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords); } else { foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow); surfacePos = pFoundWindow->m_vRealPosition.vec(); } + + break; } } + } - // then surfaces below - if (!foundSurface) - foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], &surfaceCoords); + if (!foundSurface) + foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords); - if (!foundSurface) - foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], &surfaceCoords); + // then windows + if (!foundSurface) { + pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords); + if (pFoundWindow) { + if (!pFoundWindow->m_bIsX11) { + foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords); + } else { + foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow); + surfacePos = pFoundWindow->m_vRealPosition.vec(); + } + } + } + // then surfaces below + if (!foundSurface) + foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], &surfaceCoords); - if (!foundSurface) { - wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor); + if (!foundSurface) + foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], &surfaceCoords); - wlr_seat_pointer_clear_focus(g_pCompositor->m_sSeat.seat); + if (!foundSurface) { + wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor); - return; - } + wlr_seat_pointer_clear_focus(g_pCompositor->m_sSeat.seat); - if (time) - wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat); + return; + } - Vector2D surfaceLocal = surfacePos == Vector2D(-1337, -1337) ? surfaceCoords : mouseCoords - surfacePos; + if (time) + wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat); - if (pFoundWindow) { - static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue; - if (*PFOLLOWMOUSE != 1 && !refocus) { - if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && (g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating)) { - // enter if change floating style - g_pCompositor->focusWindow(pFoundWindow, foundSurface); - wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); - } - else if (*PFOLLOWMOUSE == 2) { - wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); - } - wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y); - return; // don't enter any new surfaces - } else { + Vector2D surfaceLocal = surfacePos == Vector2D(-1337, -1337) ? surfaceCoords : mouseCoords - surfacePos; + + if (pFoundWindow) { + static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue; + if (*PFOLLOWMOUSE != 1 && !refocus) { + if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && (g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating)) { + // enter if change floating style g_pCompositor->focusWindow(pFoundWindow, foundSurface); + wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); + } else if (*PFOLLOWMOUSE == 2) { + wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); } + wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y); + return; // don't enter any new surfaces + } else { + g_pCompositor->focusWindow(pFoundWindow, foundSurface); } - else - g_pCompositor->focusSurface(foundSurface); + } else + g_pCompositor->focusSurface(foundSurface); - wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); - wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y); - } + wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); + wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y); } void CInputManager::onMouseButton(wlr_pointer_button_event* e) { -- cgit v1.2.3 From 33abb6a5bf6ea815c59a1ac2bcec0413c17e3f6d Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 21 Jun 2022 22:30:07 +0200 Subject: dang it autoformat --- src/managers/input/InputManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 50a4dc5e..63e2d970 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -173,7 +173,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { Vector2D surfaceLocal = surfacePos == Vector2D(-1337, -1337) ? surfaceCoords : mouseCoords - surfacePos; if (pFoundWindow) { - static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue; + static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue; if (*PFOLLOWMOUSE != 1 && !refocus) { if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && (g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating)) { // enter if change floating style -- cgit v1.2.3 From 48e33023afdd8e1683f275058d0a4148a41f5de4 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 21 Jun 2022 22:42:54 +0200 Subject: fix crash on number workspace with null mon --- src/helpers/MiscFunctions.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index 6f9b465e..55b0ec83 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -158,6 +158,12 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) { outName = WORKSPACENAME; } else { if (in[0] == 'm') { + if (!g_pCompositor->m_pLastMonitor) { + Debug::log(ERR, "Relative monitor workspace on monitor null!"); + result = INT_MAX; + return result; + } + // monitor relative result = (int)getPlusMinusKeywordResult(in.substr(1), 0); @@ -207,7 +213,14 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) { outName = g_pCompositor->getWorkspaceByID(currentID)->m_szName; } else { - result = std::clamp((int)getPlusMinusKeywordResult(in, g_pCompositor->m_pLastMonitor->activeWorkspace), 1, INT_MAX); + if (g_pCompositor->m_pLastMonitor) + result = std::clamp((int)getPlusMinusKeywordResult(in, g_pCompositor->m_pLastMonitor->activeWorkspace), 1, INT_MAX); + else if (isNumber(in)) + result = std::clamp(std::stoi(in), 1, INT_MAX); + else { + Debug::log(ERR, "Relative workspace on no mon!"); + result = INT_MAX; + } outName = std::to_string(result); } } -- cgit v1.2.3 From 5541098f2026daed21d87fdaa5c85d8329c8cfbc Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 21 Jun 2022 22:47:27 +0200 Subject: Added bindl --- src/config/ConfigManager.cpp | 5 +++-- src/config/ConfigManager.hpp | 2 +- src/managers/KeybindManager.cpp | 8 +++----- src/managers/KeybindManager.hpp | 1 + 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index b76ab965..2abbdcc4 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -415,7 +415,7 @@ void CConfigManager::handleAnimation(const std::string& command, const std::stri configSetValueSafe("animations:" + ANIMNAME + "_style", curitem); } -void CConfigManager::handleBind(const std::string& command, const std::string& value) { +void CConfigManager::handleBind(const std::string& command, const std::string& value, bool locked) { // example: // bind=SUPER,G,exec,dmenu_run @@ -448,7 +448,7 @@ void CConfigManager::handleBind(const std::string& command, const std::string& v } if (KEY != "") - g_pKeybindManager->addKeybind(SKeybind{KEY, MOD, HANDLER, COMMAND}); + g_pKeybindManager->addKeybind(SKeybind{KEY, MOD, HANDLER, COMMAND, locked}); } void CConfigManager::handleUnbind(const std::string& command, const std::string& value) { @@ -578,6 +578,7 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std:: } else if (COMMAND == "monitor") handleMonitor(COMMAND, VALUE); else if (COMMAND == "bind") handleBind(COMMAND, VALUE); + else if (COMMAND == "bindl") handleBind(COMMAND, VALUE, true); else if (COMMAND == "unbind") handleUnbind(COMMAND, VALUE); else if (COMMAND == "workspace") handleDefaultWorkspace(COMMAND, VALUE); else if (COMMAND == "windowrule") handleWindowRule(COMMAND, VALUE); diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 0d4386c1..407ccce4 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -106,7 +106,7 @@ private: void configSetValueSafe(const std::string&, const std::string&); void handleRawExec(const std::string&, const std::string&); void handleMonitor(const std::string&, const std::string&); - void handleBind(const std::string&, const std::string&); + void handleBind(const std::string&, const std::string&, bool locked = false); void handleUnbind(const std::string&, const std::string&); void handleWindowRule(const std::string&, const std::string&); void handleDefaultWorkspace(const std::string&, const std::string&); diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 96d8ce60..17c606b9 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -72,13 +72,11 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t if (handleInternalKeybinds(key)) return true; - if (g_pCompositor->m_sSeat.exclusiveClient){ - Debug::log(LOG, "Not handling keybinds due to there being an exclusive inhibited client."); - return false; - } + if (g_pCompositor->m_sSeat.exclusiveClient) + Debug::log(LOG, "Keybind handling only locked (inhibitor)"); for (auto& k : m_lKeybinds) { - if (modmask != k.modmask) + if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked)) continue; // oMg such performance hit!!11! diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index cb99aa41..a3dbb8dd 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -11,6 +11,7 @@ struct SKeybind { uint32_t modmask = 0; std::string handler = ""; std::string arg = ""; + bool locked = false; }; class CKeybindManager { -- cgit v1.2.3 From 0f1ad16aecfdf89dd5d83d38318de8518157e6ee Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 21 Jun 2022 22:54:41 +0200 Subject: added general:no_border_on_floating --- src/config/ConfigManager.cpp | 1 + src/render/Renderer.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 2abbdcc4..724adb21 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -28,6 +28,7 @@ void CConfigManager::setDefaultVars() { configValues["general:damage_tracking_internal"].intValue = DAMAGE_TRACKING_NONE; configValues["general:border_size"].intValue = 1; + configValues["general:no_border_on_floating"].intValue = 0; configValues["general:gaps_in"].intValue = 5; configValues["general:gaps_out"].intValue = 20; configValues["general:col.active_border"].intValue = 0xffffffff; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index eb29a65d..b760dac0 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -142,6 +142,8 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto REALPOS = pWindow->m_vRealPosition.vec() + PWORKSPACE->m_vRenderOffset.vec(); + static const auto PNOFLOATINGBORDERS = &g_pConfigManager->getConfigValuePtr("general:no_border_on_floating")->intValue; + SRenderData renderdata = {pMonitor->output, time, REALPOS.x, REALPOS.y}; renderdata.surface = g_pXWaylandManager->getWindowSurface(pWindow); renderdata.w = std::clamp(pWindow->m_vRealSize.vec().x, (double)5, (double)1337420); // clamp the size to min 5, @@ -149,7 +151,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* renderdata.dontRound = pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL; renderdata.fadeAlpha = pWindow->m_fAlpha.fl() * (PWORKSPACE->m_fAlpha.fl() / 255.f); renderdata.alpha = pWindow->m_bIsFullscreen ? g_pConfigManager->getFloat("decoration:fullscreen_opacity") : pWindow == g_pCompositor->m_pLastWindow ? g_pConfigManager->getFloat("decoration:active_opacity") : g_pConfigManager->getFloat("decoration:inactive_opacity"); - renderdata.decorate = decorate && !pWindow->m_bX11DoesntWantBorders; + renderdata.decorate = decorate && !pWindow->m_bX11DoesntWantBorders && (pWindow->m_bIsFloating ? *PNOFLOATINGBORDERS == 0 : true); renderdata.rounding = pWindow->m_sAdditionalConfigData.rounding; // apply window special data -- cgit v1.2.3 From 4c2459861b9e61b13443efebde5125d5c68221b0 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 21 Jun 2022 23:09:20 +0200 Subject: fix borders sometimes disappearing on certain windows --- src/render/OpenGL.cpp | 40 +++++++++++++++++++++++++++------------- src/render/OpenGL.hpp | 1 + 2 files changed, 28 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 6a82cb83..d8f64e0c 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -240,6 +240,10 @@ void CHyprOpenGLImpl::scissor(const int x, const int y, const int w, const int h } void CHyprOpenGLImpl::renderRect(wlr_box* box, const CColor& col, int round) { + renderRectWithDamage(box, col, m_RenderData.pDamage, round); +} + +void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixman_region32_t* damage, int round) { RASSERT((box->width > 0 && box->height > 0), "Tried to render rect with width/height < 0!"); RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!"); @@ -279,8 +283,8 @@ void CHyprOpenGLImpl::renderRect(wlr_box* box, const CColor& col, int round) { glEnableVertexAttribArray(m_shQUAD.posAttrib); glEnableVertexAttribArray(m_shQUAD.texAttrib); - if (pixman_region32_not_empty(m_RenderData.pDamage)) { - PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) { + if (pixman_region32_not_empty(damage)) { + PIXMAN_DAMAGE_FOREACH(damage) { const auto RECT = RECTSARR[i]; scissor(&RECT); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); @@ -341,6 +345,21 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b RASSERT(false, "tex.m_iTarget unsupported!"); } + // stencil for when we want a border + if (border) { + glClearStencil(0); + glClear(GL_STENCIL_BUFFER_BIT); + + glEnable(GL_STENCIL_TEST); + + glStencilFunc(GL_ALWAYS, 1, -1); + glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); + + // hacky fix to fix broken borders. + // TODO: this is kinda slow... question mark? + renderRect(pBox, CColor(0, 0, 0, 0), round); + } + glActiveTexture(GL_TEXTURE0); glBindTexture(tex.m_iTarget, tex.m_iTexID); @@ -374,17 +393,6 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b glEnableVertexAttribArray(shader->posAttrib); glEnableVertexAttribArray(shader->texAttrib); - // stencil for when we want a border - if (border) { - glClearStencil(0); - glClear(GL_STENCIL_BUFFER_BIT); - - glEnable(GL_STENCIL_TEST); - - glStencilFunc(GL_ALWAYS, 1, -1); - glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); - } - if (pixman_region32_not_empty(m_RenderData.pDamage)) { PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) { const auto RECT = RECTSARR[i]; @@ -609,6 +617,12 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, glStencilFunc(GL_ALWAYS, 1, -1); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + if (border) { + // hacky fix to fix broken borders. + // TODO: this is kinda slow... question mark? + renderRectWithDamage(pBox, CColor(0,0,0,0), &damage, round); + } + renderTextureInternalWithDamage(tex, pBox, a, &damage, round, false, false, true); // then stop diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp index 9a8084db..76de6311 100644 --- a/src/render/OpenGL.hpp +++ b/src/render/OpenGL.hpp @@ -53,6 +53,7 @@ public: void end(); void renderRect(wlr_box*, const CColor&, int round = 0); + void renderRectWithDamage(wlr_box*, const CColor&, pixman_region32_t* damage, int round = 0); void renderTexture(wlr_texture*, wlr_box*, float a, int round = 0); void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardOpaque = false, bool border = false); void renderTextureWithBlur(const CTexture&, wlr_box*, float a, wlr_surface* pSurface, int round = 0, bool border = false); -- cgit v1.2.3 From b9f542a60fd066944659e5b553d341e6b1d34206 Mon Sep 17 00:00:00 2001 From: taylor85345 <36456160+taylor85345@users.noreply.github.com> Date: Tue, 21 Jun 2022 16:13:05 -0700 Subject: Fixed crash on movetoworkspacesilent --- src/managers/EventManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/managers/EventManager.cpp b/src/managers/EventManager.cpp index 409fbd90..e42e87c2 100644 --- a/src/managers/EventManager.cpp +++ b/src/managers/EventManager.cpp @@ -107,7 +107,7 @@ void CEventManager::startThread() { void CEventManager::postEvent(const SHyprIPCEvent event) { if (m_bIgnoreEvents) { - Debug::log(WARN, "Suppressed (ignoreevents true) event of type %s, content: %s"); + Debug::log(WARN, "Suppressed (ignoreevents true) event of type %s, content: %s",event.event.c_str(), event.data.c_str()); return; } @@ -116,4 +116,4 @@ void CEventManager::postEvent(const SHyprIPCEvent event) { m_dQueuedEvents.push_back(ev); eventQueueMutex.unlock(); }, event).detach(); -} \ No newline at end of file +} -- cgit v1.2.3 From 499d2e41bfbc76525c3f03e1fb0a057b910c0c4b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 22 Jun 2022 13:01:59 +0200 Subject: default apply_sens_to_raw to 0 --- src/config/ConfigManager.cpp | 2 +- src/config/defaultConfig.hpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 724adb21..aba0b1ff 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -20,7 +20,7 @@ CConfigManager::CConfigManager() { void CConfigManager::setDefaultVars() { configValues["general:max_fps"].intValue = 240; configValues["general:sensitivity"].floatValue = 0.25f; - configValues["general:apply_sens_to_raw"].intValue = 1; + configValues["general:apply_sens_to_raw"].intValue = 0; configValues["general:main_mod"].strValue = "SUPER"; // exposed to the user for easier configuring configValues["general:main_mod_internal"].intValue = g_pKeybindManager->stringToModMask("SUPER"); // actually used and automatically calculated diff --git a/src/config/defaultConfig.hpp b/src/config/defaultConfig.hpp index 30ef5009..fbf3981d 100644 --- a/src/config/defaultConfig.hpp +++ b/src/config/defaultConfig.hpp @@ -34,6 +34,8 @@ general { col.active_border=0x66ee1111 col.inactive_border=0x66333333 + apply_sens_to_raw=0 # do not apply the sensitivity to raw input (e.g. used by games where you aim) + damage_tracking=full # leave it on full unless you hate your GPU and want to make it suffer } -- cgit v1.2.3 From 770bada5d541e737ae17744f70eb019494471a29 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 22 Jun 2022 15:45:56 +0200 Subject: Fixed oversized apps' incorrect layout --- src/Compositor.cpp | 9 ++++++++- src/config/ConfigManager.cpp | 1 + src/events/Windows.cpp | 8 ++++++++ src/managers/XWaylandManager.cpp | 10 ++-------- src/managers/input/InputManager.cpp | 8 ++++++++ src/render/OpenGL.cpp | 40 +++++++++++++++++++++++++++---------- src/render/OpenGL.hpp | 8 ++++++-- src/render/Renderer.cpp | 28 +++++++++++++++++++++++++- 8 files changed, 90 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 32ffab34..a5339948 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -443,7 +443,11 @@ wlr_surface* CCompositor::vectorWindowToSurface(const Vector2D& pos, CWindow* pW double subx, suby; - const auto PFOUND = wlr_xdg_surface_surface_at(PSURFACE, pos.x - pWindow->m_vRealPosition.vec().x, pos.y - pWindow->m_vRealPosition.vec().y, &subx, &suby); + // calc for oversized windows... fucking bullshit, again. + wlr_box geom; + wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, &geom); + + const auto PFOUND = wlr_xdg_surface_surface_at(PSURFACE, pos.x - pWindow->m_vRealPosition.vec().x + geom.x, pos.y - pWindow->m_vRealPosition.vec().y + geom.y, &subx, &suby); if (PFOUND) { sl.x = subx; @@ -454,6 +458,9 @@ wlr_surface* CCompositor::vectorWindowToSurface(const Vector2D& pos, CWindow* pW sl.x = pos.x - pWindow->m_vRealPosition.vec().x; sl.y = pos.y - pWindow->m_vRealPosition.vec().y; + sl.x += geom.x; + sl.y += geom.y; + return PSURFACE->surface; } diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index aba0b1ff..d95f5a05 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -47,6 +47,7 @@ void CConfigManager::setDefaultVars() { configValues["decoration:inactive_opacity"].floatValue = 1; configValues["decoration:fullscreen_opacity"].floatValue = 1; configValues["decoration:multisample_edges"].intValue = 0; + configValues["decoration:no_blur_on_oversized"].intValue = 1; configValues["dwindle:pseudotile"].intValue = 0; configValues["dwindle:col.group_border"].intValue = 0x66777700; diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index b84b9d2d..48571892 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -19,6 +19,14 @@ void addViewCoords(void* pWindow, int* x, int* y) { const auto PWINDOW = (CWindow*)pWindow; *x += PWINDOW->m_vRealPosition.goalv().x; *y += PWINDOW->m_vRealPosition.goalv().y; + + if (!PWINDOW->m_bIsX11) { + wlr_box geom; + wlr_xdg_surface_get_geometry(PWINDOW->m_uSurface.xdg, &geom); + + *x -= geom.x; + *y -= geom.y; + } } void Events::listener_mapWindow(void* owner, void* data) { diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index 5927274e..65f5ddd8 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -124,14 +124,8 @@ void CHyprXWaylandManager::sendCloseWindow(CWindow* pWindow) { void CHyprXWaylandManager::setWindowSize(CWindow* pWindow, const Vector2D& size) { if (pWindow->m_bIsX11) wlr_xwayland_surface_configure(pWindow->m_uSurface.xwayland, pWindow->m_vRealPosition.vec().x, pWindow->m_vRealPosition.vec().y, size.x, size.y); - else { - // I don't know if this is fucking correct, but the fucking idea of putting shadows into a window's surface is borderline criminal. - - const auto XDELTA = pWindow->m_uSurface.xdg->current.geometry.width && pWindow->m_uSurface.xdg->current.geometry.height ? pWindow->m_uSurface.xdg->surface->current.width - pWindow->m_uSurface.xdg->current.geometry.width : 0; - const auto YDELTA = pWindow->m_uSurface.xdg->current.geometry.width && pWindow->m_uSurface.xdg->current.geometry.height ? pWindow->m_uSurface.xdg->surface->current.height - pWindow->m_uSurface.xdg->current.geometry.height : 0; - - wlr_xdg_toplevel_set_size(pWindow->m_uSurface.xdg->toplevel, size.x - XDELTA, size.y - YDELTA); - } + else + wlr_xdg_toplevel_set_size(pWindow->m_uSurface.xdg->toplevel, size.x, size.y); } void CHyprXWaylandManager::setWindowStyleTiled(CWindow* pWindow, uint32_t edgez) { diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 63e2d970..6bc59472 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -172,6 +172,14 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { Vector2D surfaceLocal = surfacePos == Vector2D(-1337, -1337) ? surfaceCoords : mouseCoords - surfacePos; + if (pFoundWindow && !pFoundWindow->m_bIsX11 && surfacePos != Vector2D(-1337, -1337)) { + // calc for oversized windows... fucking bullshit. + wlr_box geom; + wlr_xdg_surface_get_geometry(pFoundWindow->m_uSurface.xdg, &geom); + + surfaceLocal = mouseCoords - surfacePos + Vector2D(geom.x, geom.y); + } + if (pFoundWindow) { static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue; if (*PFOLLOWMOUSE != 1 && !refocus) { diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index d8f64e0c..c503cb64 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -303,15 +303,15 @@ void CHyprOpenGLImpl::renderTexture(wlr_texture* tex, wlr_box* pBox, float alpha renderTexture(CTexture(tex), pBox, alpha, round); } -void CHyprOpenGLImpl::renderTexture(const CTexture& tex, wlr_box* pBox, float alpha, int round, bool discardopaque, bool border) { +void CHyprOpenGLImpl::renderTexture(const CTexture& tex, wlr_box* pBox, float alpha, int round, bool discardopaque, bool border, bool allowPrimary) { RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!"); - renderTextureInternalWithDamage(tex, pBox, alpha, m_RenderData.pDamage, round, discardopaque, border); + renderTextureInternalWithDamage(tex, pBox, alpha, m_RenderData.pDamage, round, discardopaque, border, false, allowPrimary); scissor((wlr_box*)nullptr); } -void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_box* pBox, float alpha, pixman_region32_t* damage, int round, bool discardOpaque, bool border, bool noAA) { +void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_box* pBox, float alpha, pixman_region32_t* damage, int round, bool discardOpaque, bool border, bool noAA, bool allowPrimary) { RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!"); RASSERT((tex.m_iTexID > 0), "Attempted to draw NULL texture!"); @@ -358,6 +358,8 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b // hacky fix to fix broken borders. // TODO: this is kinda slow... question mark? renderRect(pBox, CColor(0, 0, 0, 0), round); + + glDisable(GL_STENCIL_TEST); } glActiveTexture(GL_TEXTURE0); @@ -388,7 +390,19 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b glUniform1i(glGetUniformLocation(shader->program, "primitiveMultisample"), (int)(*PMULTISAMPLEEDGES == 1 && round != 0 && !border && !noAA)); glVertexAttribPointer(shader->posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts); - glVertexAttribPointer(shader->texAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts); + + if (allowPrimary && m_RenderData.renderingPrimarySurface && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) { + const float verts[] = { + m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVTopLeft.y, // top right + m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVTopLeft.y, // top left + m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom right + m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom left + }; + + glVertexAttribPointer(shader->texAttrib, 2, GL_FLOAT, GL_FALSE, 0, verts); + } else { + glVertexAttribPointer(shader->texAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts); + } glEnableVertexAttribArray(shader->posAttrib); glEnableVertexAttribArray(shader->texAttrib); @@ -402,6 +416,8 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b } if (border) { + glEnable(GL_STENCIL_TEST); + glStencilFunc(GL_EQUAL, 1, -1); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); } @@ -548,9 +564,10 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, RASSERT(m_RenderData.pMonitor, "Tried to render texture with blur without begin()!"); static auto *const PBLURENABLED = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue; + static auto* const PNOBLUROVERSIZED = &g_pConfigManager->getConfigValuePtr("decoration:no_blur_on_oversized")->intValue; - if (*PBLURENABLED == 0) { - renderTexture(tex, pBox, a, round, false, border); + if (*PBLURENABLED == 0 || (*PNOBLUROVERSIZED && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1))) { + renderTexture(tex, pBox, a, round, false, border, true); return; } @@ -607,13 +624,18 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, if (pixman_region32_not_empty(&damage)) { // render our great blurred FB static auto *const PBLURIGNOREOPACITY = &g_pConfigManager->getConfigValuePtr("decoration:blur_ignore_opacity")->intValue; - renderTextureInternalWithDamage(POUTFB->m_cTex, &MONITORBOX, *PBLURIGNOREOPACITY ? 255.f : a, &damage); + renderTextureInternalWithDamage(POUTFB->m_cTex, &MONITORBOX, *PBLURIGNOREOPACITY ? 255.f : a, &damage, 0, false, false, false, true); // render the window, but clear stencil glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT); - // and write to it + // draw window + glDisable(GL_STENCIL_TEST); + renderTextureInternalWithDamage(tex, pBox, a, &damage, round, false, false, true, true); + glEnable(GL_STENCIL_TEST); + + // prep stencil for border glStencilFunc(GL_ALWAYS, 1, -1); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); @@ -623,8 +645,6 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, renderRectWithDamage(pBox, CColor(0,0,0,0), &damage, round); } - renderTextureInternalWithDamage(tex, pBox, a, &damage, round, false, false, true); - // then stop glStencilFunc(GL_EQUAL, 1, -1); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp index 76de6311..0648e73a 100644 --- a/src/render/OpenGL.hpp +++ b/src/render/OpenGL.hpp @@ -34,6 +34,10 @@ struct SCurrentRenderData { float projection[9]; pixman_region32_t* pDamage = nullptr; + + bool renderingPrimarySurface = false; + Vector2D primarySurfaceUVTopLeft = Vector2D(-1, -1); + Vector2D primarySurfaceUVBottomRight = Vector2D(-1, -1); }; struct SMonitorRenderData { @@ -55,7 +59,7 @@ public: void renderRect(wlr_box*, const CColor&, int round = 0); void renderRectWithDamage(wlr_box*, const CColor&, pixman_region32_t* damage, int round = 0); void renderTexture(wlr_texture*, wlr_box*, float a, int round = 0); - void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardOpaque = false, bool border = false); + void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardOpaque = false, bool border = false, bool allowPrimary = false); void renderTextureWithBlur(const CTexture&, wlr_box*, float a, wlr_surface* pSurface, int round = 0, bool border = false); void makeWindowSnapshot(CWindow*); @@ -111,7 +115,7 @@ private: // returns the out FB, can be either Mirror or MirrorSwap CFramebuffer* blurMainFramebufferWithDamage(float a, wlr_box* pBox, pixman_region32_t* damage); - void renderTextureInternalWithDamage(const CTexture&, wlr_box* pBox, float a, pixman_region32_t* damage, int round = 0, bool discardOpaque = false, bool border = false, bool noAA = false); + void renderTextureInternalWithDamage(const CTexture&, wlr_box* pBox, float a, pixman_region32_t* damage, int round = 0, bool discardOpaque = false, bool border = false, bool noAA = false, bool allowPrimary = false); void renderBorder(wlr_box*, const CColor&, int thick = 1, int round = 0); }; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index b760dac0..8118af48 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -23,8 +23,12 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) { float rounding = RDATA->dontRound ? 0 : RDATA->rounding == -1 ? *PROUNDING : RDATA->rounding; - if (RDATA->surface && surface == RDATA->surface) + g_pHyprOpenGL->m_RenderData.renderingPrimarySurface = false; + + if (RDATA->surface && surface == RDATA->surface) { + g_pHyprOpenGL->m_RenderData.renderingPrimarySurface = true; g_pHyprOpenGL->renderTextureWithBlur(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, surface, rounding, RDATA->decorate); + } else g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, false, false); @@ -166,8 +170,30 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* for (auto& wd : pWindow->m_dWindowDecorations) wd->draw(pMonitor); + if (!pWindow->m_bIsX11) { + + // To everyone who makes apps with improperly aligned surfaces, + // For example chromium, or GTK devs who allow shadows on windows, + // a sincere FUCK YOU. + + wlr_box geom; + wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, &geom); + + g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D((double)geom.x / (double)pWindow->m_uSurface.xdg->surface->current.width, (double)geom.y / (double)pWindow->m_uSurface.xdg->surface->current.height); + g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D((double)(geom.width + geom.x) / (double)pWindow->m_uSurface.xdg->surface->current.width, (double)(geom.y + geom.height) / (double)pWindow->m_uSurface.xdg->surface->current.height); + + if (g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft == Vector2D() && g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight == Vector2D(1, 1)) { + // No special UV mods needed + g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1); + g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1); + } + } + wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(pWindow), renderSurface, &renderdata); + g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1); + g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1); + if (pWindow->m_bIsX11) { if (pWindow->m_uSurface.xwayland->surface) { wlr_surface_for_each_surface(pWindow->m_uSurface.xwayland->surface, renderSurface, &renderdata); -- cgit v1.2.3 From 19d94b87ab639a0b22ea03809502316470de0f7a Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 22 Jun 2022 20:23:20 +0200 Subject: Added keybind submaps --- src/config/ConfigManager.cpp | 10 +++++++++- src/config/ConfigManager.hpp | 3 +++ src/managers/KeybindManager.cpp | 21 ++++++++++++++++++++- src/managers/KeybindManager.hpp | 4 ++++ 4 files changed, 36 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index d95f5a05..d742070a 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -450,7 +450,7 @@ void CConfigManager::handleBind(const std::string& command, const std::string& v } if (KEY != "") - g_pKeybindManager->addKeybind(SKeybind{KEY, MOD, HANDLER, COMMAND, locked}); + g_pKeybindManager->addKeybind(SKeybind{KEY, MOD, HANDLER, COMMAND, locked, m_szCurrentSubmap}); } void CConfigManager::handleUnbind(const std::string& command, const std::string& value) { @@ -507,6 +507,13 @@ void CConfigManager::handleDefaultWorkspace(const std::string& command, const st } } +void CConfigManager::handleSubmap(const std::string& command, const std::string& submap) { + if (submap == "reset") + m_szCurrentSubmap = ""; + else + m_szCurrentSubmap = submap; +} + void CConfigManager::handleSource(const std::string& command, const std::string& rawpath) { static const char* const ENVHOME = getenv("HOME"); @@ -587,6 +594,7 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std:: else if (COMMAND == "bezier") handleBezier(COMMAND, VALUE); else if (COMMAND == "animation") handleAnimation(COMMAND, VALUE); else if (COMMAND == "source") handleSource(COMMAND, VALUE); + else if (COMMAND == "submap") handleSubmap(COMMAND, VALUE); else configSetValueSafe(currentCategory + (currentCategory == "" ? "" : ":") + COMMAND, VALUE); diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 407ccce4..8c0bd857 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -88,6 +88,8 @@ private: std::string parseError = ""; // For storing a parse error to display later + std::string m_szCurrentSubmap = ""; // For storing the current keybind submap + bool isFirstLaunch = true; // For exec-once std::deque m_dMonitorRules; @@ -113,6 +115,7 @@ private: void handleBezier(const std::string&, const std::string&); void handleAnimation(const std::string&, const std::string&); void handleSource(const std::string&, const std::string&); + void handleSubmap(const std::string&, const std::string&); }; inline std::unique_ptr g_pConfigManager; \ No newline at end of file diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 17c606b9..06075554 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -30,6 +30,7 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["resizeactive"] = resizeActive; m_mDispatchers["cyclenext"] = circleNext; m_mDispatchers["focuswindowbyclass"] = focusWindowByClass; + m_mDispatchers["submap"] = setSubmap; } void CKeybindManager::addKeybind(SKeybind kb) { @@ -76,7 +77,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t Debug::log(LOG, "Keybind handling only locked (inhibitor)"); for (auto& k : m_lKeybinds) { - if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked)) + if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap) continue; // oMg such performance hit!!11! @@ -935,3 +936,21 @@ void CKeybindManager::focusWindowByClass(std::string clazz) { break; } } + +void CKeybindManager::setSubmap(std::string submap) { + if (submap == "reset" || submap == "") { + m_szCurrentSelectedSubmap = ""; + Debug::log(LOG, "Reset active submap to the default one."); + return; + } + + for (auto& k : g_pKeybindManager->m_lKeybinds) { + if (k.submap == submap) { + m_szCurrentSelectedSubmap = submap; + Debug::log(LOG, "Changed keybind submap to %s", submap.c_str()); + return; + } + } + + Debug::log(ERR, "Cannot set submap %s, submap doesn't exist (wasn't registered!)", submap.c_str()); +} diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index a3dbb8dd..4ebf94a3 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -12,6 +12,7 @@ struct SKeybind { std::string handler = ""; std::string arg = ""; bool locked = false; + std::string submap = ""; }; class CKeybindManager { @@ -29,6 +30,8 @@ public: private: std::list m_lKeybinds; + inline static std::string m_szCurrentSelectedSubmap = ""; + bool handleInternalKeybinds(xkb_keysym_t); // -------------- Dispatchers -------------- // @@ -57,6 +60,7 @@ private: static void resizeActive(std::string); static void circleNext(std::string); static void focusWindowByClass(std::string); + static void setSubmap(std::string); friend class CCompositor; }; -- cgit v1.2.3 From f9745b0d3b85c447c3c8d3421db638f1087a1e91 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 23 Jun 2022 09:56:16 +0200 Subject: allow getWindowInDirection to scan other mons --- src/Compositor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Compositor.cpp b/src/Compositor.cpp index a5339948..1861e5aa 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -777,7 +777,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) { CWindow* longestIntersectWindow = nullptr; for (auto& w : m_lWindows) { - if (&w == pWindow || !windowValidMapped(&w) || w.m_bIsFloating || w.m_iWorkspaceID != pWindow->m_iWorkspaceID) + if (&w == pWindow || !windowValidMapped(&w) || w.m_bIsFloating || !isWorkspaceVisible(w.m_iWorkspaceID)) continue; const auto POSB = w.m_vPosition; -- cgit v1.2.3 From 31dc70a41a605b09e31bb7394fc0e339a1b82418 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 23 Jun 2022 10:14:59 +0200 Subject: Added exact to resizeActive and added moveactive --- src/layout/DwindleLayout.cpp | 22 ++++++++--- src/layout/DwindleLayout.hpp | 1 + src/layout/IHyprLayout.hpp | 6 +++ src/managers/KeybindManager.cpp | 81 +++++++++++++++++++++++++++++++++++++++++ src/managers/KeybindManager.hpp | 1 + 5 files changed, 106 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index ce63ace6..ed8da473 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -545,11 +545,7 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow* const auto PNODE = getNodeFromWindow(PWINDOW); if (!PNODE) { - PWINDOW->m_vRealSize.setValueAndWarp(PWINDOW->m_vRealSize.goalv() + pixResize); - PWINDOW->m_vRealSize.setValueAndWarp(Vector2D(std::clamp(PWINDOW->m_vRealSize.vec().x, (double)20, (double)999999), std::clamp(PWINDOW->m_vRealSize.vec().y, (double)20, (double)999999))); - - g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv()); - + PWINDOW->m_vRealSize = Vector2D(std::clamp((PWINDOW->m_vRealSize.goalv() + pixResize).x, (double)20, (double)999999), std::clamp((PWINDOW->m_vRealSize.goalv() + pixResize).y, (double)20, (double)999999)); return; } @@ -992,4 +988,20 @@ void CHyprDwindleLayout::toggleSplit(CWindow* pWindow) { std::string CHyprDwindleLayout::getLayoutName() { return "dwindle"; +} + +void CHyprDwindleLayout::moveActiveWindow(const Vector2D& delta, CWindow* pWindow) { + const auto PWINDOW = pWindow ? pWindow : g_pCompositor->m_pLastWindow; + + if (!g_pCompositor->windowValidMapped(PWINDOW)) + return; + + if (!PWINDOW->m_bIsFloating) { + Debug::log(LOG, "Dwindle cannot move a tiled window in moveActiveWindow!"); + return; + } + + PWINDOW->m_vRealPosition = PWINDOW->m_vRealPosition.goalv() + delta; + + g_pHyprRenderer->damageWindow(PWINDOW); } \ No newline at end of file diff --git a/src/layout/DwindleLayout.hpp b/src/layout/DwindleLayout.hpp index 766e9f6a..55c123ae 100644 --- a/src/layout/DwindleLayout.hpp +++ b/src/layout/DwindleLayout.hpp @@ -49,6 +49,7 @@ public: virtual void changeWindowFloatingMode(CWindow*); virtual void onBeginDragWindow(); virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr); + virtual void moveActiveWindow(const Vector2D&, CWindow* pWindow = nullptr); virtual void onEndDragWindow(); virtual void onMouseMove(const Vector2D&); virtual void onWindowCreatedFloating(CWindow*); diff --git a/src/layout/IHyprLayout.hpp b/src/layout/IHyprLayout.hpp index 8052fe42..a7268301 100644 --- a/src/layout/IHyprLayout.hpp +++ b/src/layout/IHyprLayout.hpp @@ -55,6 +55,12 @@ public: Optional pWindow for a specific window */ virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr) = 0; + /* + Called when a user requests a move of the current window by a vec + Vector2D holds pixel values + Optional pWindow for a specific window + */ + virtual void moveActiveWindow(const Vector2D&, CWindow* pWindow = nullptr) = 0; /* Called when a window is ended being dragged (mouse up) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 06075554..85fb3919 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -28,6 +28,7 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["togglespecialworkspace"] = toggleSpecialWorkspace; m_mDispatchers["forcerendererreload"] = forceRendererReload; m_mDispatchers["resizeactive"] = resizeActive; + m_mDispatchers["moveactive"] = moveActive; m_mDispatchers["cyclenext"] = circleNext; m_mDispatchers["focuswindowbyclass"] = focusWindowByClass; m_mDispatchers["submap"] = setSubmap; @@ -892,6 +893,37 @@ void CKeybindManager::resizeActive(std::string args) { std::string x = args.substr(0, args.find_first_of(' ')); std::string y = args.substr(args.find_first_of(' ') + 1); + if (x == "exact") { + std::string newX = y.substr(0, y.find_first_of(' ')); + std::string newY = y.substr(y.find_first_of(' ') + 1); + + if (!isNumber(newX) || !isNumber(newY)) { + Debug::log(ERR, "resizeTiledWindow: exact args not numbers"); + return; + } + + const int X = std::stoi(newX); + const int Y = std::stoi(newY); + + if (X < 10 || Y < 10) { + Debug::log(ERR, "resizeTiledWindow: exact args cannot be < 10"); + return; + } + + // calc the delta + if (!g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow)) + return; // ignore + + const auto PWINDOW = g_pCompositor->m_pLastWindow; + + const int DX = X - PWINDOW->m_vRealSize.goalv().x; + const int DY = Y - PWINDOW->m_vRealSize.goalv().y; + + g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(Vector2D(DX, DY)); + + return; + } + if (!isNumber(x) || !isNumber(y)) { Debug::log(ERR, "resizeTiledWindow: args not numbers"); return; @@ -903,6 +935,55 @@ void CKeybindManager::resizeActive(std::string args) { g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(Vector2D(X, Y)); } +void CKeybindManager::moveActive(std::string args) { + if (args.find_first_of(' ') == std::string::npos) + return; + + std::string x = args.substr(0, args.find_first_of(' ')); + std::string y = args.substr(args.find_first_of(' ') + 1); + + if (x == "exact") { + std::string newX = y.substr(0, y.find_first_of(' ')); + std::string newY = y.substr(y.find_first_of(' ') + 1); + + if (!isNumber(newX) || !isNumber(newY)) { + Debug::log(ERR, "moveActive: exact args not numbers"); + return; + } + + const int X = std::stoi(newX); + const int Y = std::stoi(newY); + + if (X < 10 || Y < 10) { + Debug::log(ERR, "moveActive: exact args cannot be < 10"); + return; + } + + // calc the delta + if (!g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow)) + return; // ignore + + const auto PWINDOW = g_pCompositor->m_pLastWindow; + + const int DX = X - PWINDOW->m_vRealPosition.goalv().x; + const int DY = Y - PWINDOW->m_vRealPosition.goalv().y; + + g_pLayoutManager->getCurrentLayout()->moveActiveWindow(Vector2D(DX, DY)); + + return; + } + + if (!isNumber(x) || !isNumber(y)) { + Debug::log(ERR, "moveActive: args not numbers"); + return; + } + + const int X = std::stoi(x); + const int Y = std::stoi(y); + + g_pLayoutManager->getCurrentLayout()->moveActiveWindow(Vector2D(X, Y)); +} + void CKeybindManager::circleNext(std::string) { if (!g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow)) return; diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index 4ebf94a3..c9132a11 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -58,6 +58,7 @@ private: static void toggleSpecialWorkspace(std::string); static void forceRendererReload(std::string); static void resizeActive(std::string); + static void moveActive(std::string); static void circleNext(std::string); static void focusWindowByClass(std::string); static void setSubmap(std::string); -- cgit v1.2.3 From 4945c5887d516fafc84d53e041b2aa901c7c94ee Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 23 Jun 2022 15:48:31 +0200 Subject: reload all keyboards and not only the active --- src/managers/input/InputManager.cpp | 38 +++++++++++++++++-------------------- src/managers/input/InputManager.hpp | 4 +++- 2 files changed, 20 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 6bc59472..fb4b50ef 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -274,20 +274,26 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) { } void CInputManager::setKeyboardLayout() { + for (auto& k : m_lKeyboards) + applyConfigToKeyboard(&k); +} + +void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { + + ASSERT(pKeyboard); - const auto RULES = g_pConfigManager->getString("input:kb_rules"); - const auto MODEL = g_pConfigManager->getString("input:kb_model"); - const auto LAYOUT = g_pConfigManager->getString("input:kb_layout"); - const auto VARIANT = g_pConfigManager->getString("input:kb_variant"); - const auto OPTIONS = g_pConfigManager->getString("input:kb_options"); + const auto RULES = g_pConfigManager->getString("input:kb_rules"); + const auto MODEL = g_pConfigManager->getString("input:kb_model"); + const auto LAYOUT = g_pConfigManager->getString("input:kb_layout"); + const auto VARIANT = g_pConfigManager->getString("input:kb_variant"); + const auto OPTIONS = g_pConfigManager->getString("input:kb_options"); xkb_rule_names rules = { .rules = RULES.c_str(), .model = MODEL.c_str(), .layout = LAYOUT.c_str(), .variant = VARIANT.c_str(), - .options = OPTIONS.c_str() - }; + .options = OPTIONS.c_str()}; const auto CONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS); const auto KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS); @@ -298,17 +304,7 @@ void CInputManager::setKeyboardLayout() { return; } - const auto PLASTKEEB = m_pActiveKeyboard->keyboard->keyboard; - - if (!PLASTKEEB) { - xkb_keymap_unref(KEYMAP); - xkb_context_unref(CONTEXT); - - Debug::log(ERR, "No Seat Keyboard???"); - return; - } - - wlr_keyboard_set_keymap(PLASTKEEB, KEYMAP); + wlr_keyboard_set_keymap(pKeyboard->keyboard->keyboard, KEYMAP); wlr_keyboard_modifiers wlrMods = {0}; @@ -321,14 +317,14 @@ void CInputManager::setKeyboardLayout() { } if (wlrMods.locked != 0) { - wlr_keyboard_notify_modifiers(g_pInputManager->m_pActiveKeyboard->keyboard->keyboard, 0, 0, wlrMods.locked, 0); + wlr_keyboard_notify_modifiers(pKeyboard->keyboard->keyboard, 0, 0, wlrMods.locked, 0); } xkb_keymap_unref(KEYMAP); xkb_context_unref(CONTEXT); - Debug::log(LOG, "Set the keyboard layout to %s and variant to %s", rules.layout, rules.variant); -} + Debug::log(LOG, "Set the keyboard layout to %s and variant to %s for keyboard \"%s\"", rules.layout, rules.variant, pKeyboard->keyboard->name); +} void CInputManager::newMouse(wlr_input_device* mouse) { m_lMice.emplace_back(); diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 18d9857e..ef962bdd 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -52,13 +52,15 @@ public: SKeyboard* m_pActiveKeyboard = nullptr; - private: +private: uint32_t m_uiCapabilities = 0; void mouseMoveUnified(uint32_t, bool refocus = false); STabletTool* ensureTabletToolPresent(wlr_tablet_tool*); + + void applyConfigToKeyboard(SKeyboard*); }; inline std::unique_ptr g_pInputManager; \ No newline at end of file -- cgit v1.2.3 From b25bafda0834f58acf50f472bfa0534f5714f30a Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 23 Jun 2022 18:52:05 +0200 Subject: guard null context in applyConfigToKeyboard --- src/managers/input/InputManager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index fb4b50ef..79a13369 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -296,6 +296,12 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { .options = OPTIONS.c_str()}; const auto CONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS); + + if (!CONTEXT) { + Debug::log(ERR, "applyConfigToKeyboard: CONTEXT null??"); + return; + } + const auto KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS); if (!KEYMAP) { -- cgit v1.2.3 From ae6007522600c969b5fe45b3888be5f12f343d1c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 23 Jun 2022 19:32:00 +0200 Subject: fix calculating damage offset for oversized popups --- src/events/Popups.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/events/Popups.cpp b/src/events/Popups.cpp index 0b075295..7e619632 100644 --- a/src/events/Popups.cpp +++ b/src/events/Popups.cpp @@ -26,6 +26,14 @@ void addPopupGlobalCoords(void* pPopup, int* x, int* y) { px += curPopup->popup->current.geometry.x; py += curPopup->popup->current.geometry.y; + // fix oversized fucking popups + // kill me + if (curPopup->pSurfaceTree && curPopup->pSurfaceTree->pSurface && !curPopup->parentPopup) { + const auto EXTENTSSURFACE = pixman_region32_extents(&curPopup->pSurfaceTree->pSurface->input_region); + px -= EXTENTSSURFACE->x1; + py -= EXTENTSSURFACE->y1; + } + if (curPopup->parentPopup) { curPopup = curPopup->parentPopup; } else { -- cgit v1.2.3 From f76b9c485246849bc3af838503fedbadf68023f5 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 23 Jun 2022 20:39:48 +0200 Subject: fix: ignore reserved in getWindowInDirection --- src/Compositor.cpp | 14 ++++++++++---- src/Window.cpp | 25 +++++++++++++++++++++++++ src/Window.hpp | 1 + 3 files changed, 36 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 1861e5aa..be94c093 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -770,8 +770,11 @@ void CCompositor::cleanupFadingOut() { } CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) { - const auto POSA = pWindow->m_vPosition; - const auto SIZEA = pWindow->m_vSize; + + const auto WINDOWIDEALBB = pWindow->getWindowIdealBoundingBoxIgnoreReserved(); + + const auto POSA = Vector2D(WINDOWIDEALBB.x, WINDOWIDEALBB.y); + const auto SIZEA = Vector2D(WINDOWIDEALBB.width, WINDOWIDEALBB.height); auto longestIntersect = -1; CWindow* longestIntersectWindow = nullptr; @@ -780,8 +783,11 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) { if (&w == pWindow || !windowValidMapped(&w) || w.m_bIsFloating || !isWorkspaceVisible(w.m_iWorkspaceID)) continue; - const auto POSB = w.m_vPosition; - const auto SIZEB = w.m_vSize; + const auto BWINDOWIDEALBB = w.getWindowIdealBoundingBoxIgnoreReserved(); + + const auto POSB = Vector2D(BWINDOWIDEALBB.x, BWINDOWIDEALBB.y); + const auto SIZEB = Vector2D(BWINDOWIDEALBB.width, BWINDOWIDEALBB.height); + switch (dir) { case 'l': if (STICKS(POSA.x, POSB.x + SIZEB.x)) { diff --git a/src/Window.cpp b/src/Window.cpp index 2182d47c..8476360a 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -43,4 +43,29 @@ wlr_box CWindow::getFullWindowBoundingBox() { m_vRealSize.vec().y + maxExtents.topLeft.y + maxExtents.bottomRight.y}; return finalBox; +} + +wlr_box CWindow::getWindowIdealBoundingBoxIgnoreReserved() { + + const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); + + auto POS = m_vPosition; + auto SIZE = m_vSize; + + if (DELTALESSTHAN(POS.y - PMONITOR->vecPosition.y, PMONITOR->vecReservedTopLeft.y, 1)) { + POS.y = PMONITOR->vecPosition.y; + SIZE.y += PMONITOR->vecReservedTopLeft.y; + } + if (DELTALESSTHAN(POS.x - PMONITOR->vecPosition.x, PMONITOR->vecReservedTopLeft.x, 1)) { + POS.x = PMONITOR->vecPosition.x; + SIZE.x += PMONITOR->vecReservedTopLeft.x; + } + if (DELTALESSTHAN(POS.x + SIZE.x - PMONITOR->vecPosition.x, PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x, 1)) { + SIZE.x += PMONITOR->vecReservedBottomRight.x; + } + if (DELTALESSTHAN(POS.y + SIZE.y - PMONITOR->vecPosition.y, PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y, 1)) { + SIZE.y += PMONITOR->vecReservedBottomRight.y; + } + + return wlr_box{(int)POS.x, (int)POS.y, (int)SIZE.x, (int)SIZE.y}; } \ No newline at end of file diff --git a/src/Window.hpp b/src/Window.hpp index 7d357292..06140303 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -108,5 +108,6 @@ public: // methods wlr_box getFullWindowBoundingBox(); + wlr_box getWindowIdealBoundingBoxIgnoreReserved(); }; \ No newline at end of file -- cgit v1.2.3 From e4e323a0df852305cd5ee0922e2142319dc92c1f Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 23 Jun 2022 20:51:01 +0200 Subject: dwindle: disallow swaps between workspaces --- src/layout/DwindleLayout.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index ed8da473..fb966153 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -902,6 +902,11 @@ void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) { if (!PNODE2 || !PNODE) return; + if (PNODE->workspaceID != PNODE2->workspaceID) { + Debug::log(ERR, "Dwindle: Rejecting a swap between workspaces"); + return; + } + // we will not delete the nodes, just fix the tree if (PNODE2->pParent == PNODE->pParent) { const auto PPARENT = PNODE->pParent; -- cgit v1.2.3 From 218675246f1a6b2292b8d4fb5672ba710e47ec9a Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 23 Jun 2022 21:46:36 +0200 Subject: guard pkeyboard in onMouseButton --- src/managers/input/InputManager.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 79a13369..46d6338e 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -207,6 +207,11 @@ void CInputManager::onMouseButton(wlr_pointer_button_event* e) { const auto PKEYBOARD = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat); + if (!PKEYBOARD) { // ??? + Debug::log(ERR, "No active keyboard in onMouseButton??"); + return; + } + switch (e->state) { case WLR_BUTTON_PRESSED: if (!g_pCompositor->m_sSeat.mouse->currentConstraint) -- cgit v1.2.3 From 81e36298bf23045b553b51201ace31d1a403ede2 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 24 Jun 2022 15:52:42 +0200 Subject: dont scale thick in border --- src/render/OpenGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index c503cb64..bc5d80ca 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -683,7 +683,7 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CColor& col, int thick, i box->width += 2 * thick; box->height += 2 * thick; - round += thick * m_RenderData.pMonitor->scale; // cuz yeah + round += thick; // cuz yeah // only draw on non-stencild. glStencilFunc(GL_NOTEQUAL, 1, -1); -- cgit v1.2.3 From 3e8842e1f8d50263d56b0df3ae37708b4be428d6 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 24 Jun 2022 15:59:59 +0200 Subject: fix janky pixel maths with scaled textures --- src/render/OpenGL.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index bc5d80ca..85dd29be 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -378,8 +378,8 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b // so we need to do some maf const auto TOPLEFT = Vector2D(round, round); - const auto BOTTOMRIGHT = Vector2D(tex.m_vSize.x - round, tex.m_vSize.y - round); - const auto FULLSIZE = tex.m_vSize; + const auto BOTTOMRIGHT = Vector2D(pBox->width - round, pBox->height - round); + const auto FULLSIZE = Vector2D(pBox->width, pBox->height); static auto *const PMULTISAMPLEEDGES = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue; // Rounded corners -- cgit v1.2.3 From e7467c60f9fe9e66c74dd8dc7c752a73ed4bc4db Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 24 Jun 2022 16:25:57 +0200 Subject: fix windowrule regex logic and add title: --- src/config/ConfigManager.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index d742070a..c3621847 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -911,15 +911,26 @@ std::vector CConfigManager::getMatchingRules(CWindow* pWindow) { std::string title = g_pXWaylandManager->getTitle(pWindow); std::string appidclass = g_pXWaylandManager->getAppIDClass(pWindow); + Debug::log(LOG, "Searching for matching rules for %s (title: %s)", appidclass.c_str(), title.c_str()); + for (auto& rule : m_dWindowRules) { // check if we have a matching rule try { - std::regex classCheck(rule.szValue); + if (rule.szValue.find("title:") == 0) { + // we have a title rule. + std::regex RULECHECK(rule.szValue.substr(6)); + + if (!std::regex_search(title, RULECHECK)) + continue; + } else { + std::regex classCheck(rule.szValue); - if (!std::regex_search(title, classCheck) && !std::regex_search(appidclass, classCheck)) - continue; + if (!std::regex_search(appidclass, classCheck)) + continue; + } } catch (...) { Debug::log(ERR, "Regex error at %s", rule.szValue.c_str()); + continue; } // applies. Read the rule and behave accordingly -- cgit v1.2.3