summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-03-20 19:14:17 +0100
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-03-20 19:14:17 +0100
commit23ec4793e18949f32c4954b46ff2e724dc1e6f31 (patch)
tree79c991a1d4a0b9aaeb3867c9c41d9eeb885be99c /src
parentf3d703335db50269c37819cd36712dc7c2e674cf (diff)
fix xwayland windows grabbing mouse when hidden
Diffstat (limited to 'src')
-rw-r--r--src/Compositor.cpp17
-rw-r--r--src/Compositor.hpp1
-rw-r--r--src/managers/KeybindManager.cpp16
-rw-r--r--src/managers/XWaylandManager.cpp8
-rw-r--r--src/managers/XWaylandManager.hpp1
5 files changed, 40 insertions, 3 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index d0b1f2e0..ca36cc5d 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -418,4 +418,21 @@ CWindow* CCompositor::getFirstWindowOnWorkspace(const int& id) {
}
return nullptr;
+}
+
+void CCompositor::fixXWaylandWindowsOnWorkspace(const int& id) {
+ const auto ISVISIBLE = isWorkspaceVisible(id);
+
+ for (auto& w : m_lWindows) {
+ if (w.m_iWorkspaceID == id) {
+
+ // moveXWaylandWindow only moves XWayland windows
+ // so there is no need to check here
+ // if the window is XWayland or not.
+ if (ISVISIBLE)
+ g_pXWaylandManager->moveXWaylandWindow(&w, w.m_vRealPosition);
+ else
+ g_pXWaylandManager->moveXWaylandWindow(&w, Vector2D(42069,42069));
+ }
+ }
} \ No newline at end of file
diff --git a/src/Compositor.hpp b/src/Compositor.hpp
index abd66935..fbc49cf4 100644
--- a/src/Compositor.hpp
+++ b/src/Compositor.hpp
@@ -84,6 +84,7 @@ public:
void sanityCheckWorkspaces();
int getWindowsOnWorkspace(const int&);
CWindow* getFirstWindowOnWorkspace(const int&);
+ void fixXWaylandWindowsOnWorkspace(const int&);
private:
void initAllSignals();
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 68f6dbc4..2dedf22c 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -100,9 +100,21 @@ void CKeybindManager::changeworkspace(std::string args) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(g_pCompositor->getWorkspaceByID(workspaceToChangeTo)->monitorID);
// if it's not visible, make it visible.
- if (!g_pCompositor->isWorkspaceVisible(workspaceToChangeTo))
+ if (!g_pCompositor->isWorkspaceVisible(workspaceToChangeTo)) {
+ const auto OLDWORKSPACEID = PMONITOR->activeWorkspace;
+
+ // change it
PMONITOR->activeWorkspace = workspaceToChangeTo;
+ // we need to move XWayland windows to narnia or otherwise they will still process our cursor and shit
+ // and that'd be annoying as hell
+ g_pCompositor->fixXWaylandWindowsOnWorkspace(OLDWORKSPACEID);
+
+ // and fix on the new workspace
+ g_pCompositor->fixXWaylandWindowsOnWorkspace(PMONITOR->activeWorkspace);
+ }
+
+
// If the monitor is not the one our cursor's at, warp to it.
if (PMONITOR != g_pCompositor->getMonitorFromCursor()) {
Vector2D middle = PMONITOR->vecPosition + PMONITOR->vecSize / 2.f;
@@ -111,7 +123,7 @@ void CKeybindManager::changeworkspace(std::string args) {
// focus the first window
g_pCompositor->focusWindow(g_pCompositor->getFirstWindowOnWorkspace(workspaceToChangeTo));
-
+
return;
}
diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp
index 50d12383..97d1ade2 100644
--- a/src/managers/XWaylandManager.cpp
+++ b/src/managers/XWaylandManager.cpp
@@ -68,7 +68,7 @@ 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_vEffectivePosition.x, pWindow->m_vEffectivePosition.y, size.x, size.y);
+ wlr_xwayland_surface_configure(pWindow->m_uSurface.xwayland, pWindow->m_vRealPosition.x, pWindow->m_vRealPosition.y, size.x, size.y);
else
wlr_xdg_toplevel_set_size(pWindow->m_uSurface.xdg->toplevel, size.x, size.y);
@@ -97,4 +97,10 @@ bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow) {
}
return false;
+}
+
+void CHyprXWaylandManager::moveXWaylandWindow(CWindow* pWindow, const Vector2D& pos) {
+ if (pWindow->m_bIsX11) {
+ wlr_xwayland_surface_configure(pWindow->m_uSurface.xwayland, pos.x, pos.y, pWindow->m_vRealSize.x, pWindow->m_vRealSize.y);
+ }
} \ No newline at end of file
diff --git a/src/managers/XWaylandManager.hpp b/src/managers/XWaylandManager.hpp
index 11f3ac92..f7456322 100644
--- a/src/managers/XWaylandManager.hpp
+++ b/src/managers/XWaylandManager.hpp
@@ -19,6 +19,7 @@ public:
void setWindowStyleTiled(CWindow*, uint32_t);
wlr_surface* surfaceAt(CWindow*, const Vector2D&, Vector2D&);
bool shouldBeFloated(CWindow*);
+ void moveXWaylandWindow(CWindow*, const Vector2D&);
};
inline std::unique_ptr<CHyprXWaylandManager> g_pXWaylandManager; \ No newline at end of file