From 96819c8ab9038fd38199fbc98b334dbd74453a91 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 10 May 2022 11:01:03 +0200 Subject: [PATCH] Fix GDK window extents mouse offset kind of...? Should work more or less --- src/Compositor.cpp | 8 +++++--- src/Compositor.hpp | 2 ++ src/events/Events.hpp | 3 +++ src/events/Windows.cpp | 5 +++++ src/managers/XWaylandManager.cpp | 4 ++-- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 3828e9e8..df6257dd 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -83,8 +83,9 @@ CCompositor::CCompositor() { m_sWLRLayerShell = wlr_layer_shell_v1_create(m_sWLDisplay); - wlr_server_decoration_manager_set_default_mode(wlr_server_decoration_manager_create(m_sWLDisplay), WLR_SERVER_DECORATION_MANAGER_MODE_SERVER); - wlr_xdg_decoration_manager_v1_create(m_sWLDisplay); + m_sWLRServerDecoMgr = wlr_server_decoration_manager_create(m_sWLDisplay); + m_sWLRXDGDecoMgr = wlr_xdg_decoration_manager_v1_create(m_sWLDisplay); + wlr_server_decoration_manager_set_default_mode(m_sWLRServerDecoMgr, WLR_SERVER_DECORATION_MANAGER_MODE_SERVER); wlr_xdg_output_manager_v1_create(m_sWLDisplay, m_sWLROutputLayout); m_sWLROutputMgr = wlr_output_manager_v1_create(m_sWLDisplay); @@ -130,6 +131,7 @@ void CCompositor::initAllSignals() { addWLSignal(&m_sWLRInhibitMgr->events.activate, &Events::listen_InhibitActivate, m_sWLRInhibitMgr, "InhibitMgr"); addWLSignal(&m_sWLRInhibitMgr->events.deactivate, &Events::listen_InhibitDeactivate, m_sWLRInhibitMgr, "InhibitMgr"); addWLSignal(&m_sWLRPointerConstraints->events.new_constraint, &Events::listen_newConstraint, m_sWLRPointerConstraints, "PointerConstraints"); + addWLSignal(&m_sWLRXDGDecoMgr->events.new_toplevel_decoration, &Events::listen_NewXDGDeco, m_sWLRXDGDecoMgr, "XDGDecoMgr"); signal(SIGINT, handleCritSignal); signal(SIGTERM, handleCritSignal); @@ -363,7 +365,7 @@ wlr_surface* CCompositor::vectorWindowToSurface(const Vector2D& pos, CWindow* pW RASSERT(!pWindow->m_bIsX11, "Cannot call vectorWindowToSurface on an X11 window!"); const auto PSURFACE = pWindow->m_uSurface.xdg; - + 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); diff --git a/src/Compositor.hpp b/src/Compositor.hpp index bc3b068c..99ef411f 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -53,6 +53,8 @@ public: wlr_linux_dmabuf_v1* m_sWLRDmabuf; wlr_pointer_constraints_v1* m_sWLRPointerConstraints; wlr_relative_pointer_manager_v1* m_sWLRRelPointerMgr; + wlr_server_decoration_manager* m_sWLRServerDecoMgr; + wlr_xdg_decoration_manager_v1* m_sWLRXDGDecoMgr; // ------------------------------------------------- // diff --git a/src/events/Events.hpp b/src/events/Events.hpp index ab910aee..67c91839 100644 --- a/src/events/Events.hpp +++ b/src/events/Events.hpp @@ -102,4 +102,7 @@ namespace Events { // Inhibit LISTENER(InhibitActivate); LISTENER(InhibitDeactivate); + + // Deco XDG + LISTENER(NewXDGDeco); }; \ No newline at end of file diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index e9e81ab3..88c1d897 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -352,3 +352,8 @@ void Events::listener_newXDGSurface(wl_listener* listener, void* data) { PNEWWINDOW->hyprListener_unmapWindow.initCallback(&XDGSURFACE->events.unmap, &Events::listener_unmapWindow, PNEWWINDOW, "XDG Window"); PNEWWINDOW->hyprListener_destroyWindow.initCallback(&XDGSURFACE->events.destroy, &Events::listener_destroyWindow, PNEWWINDOW, "XDG Window"); } + +void Events::listener_NewXDGDeco(wl_listener* listener, void* data) { + const auto WLRDECO = (wlr_xdg_toplevel_decoration_v1*)data; + wlr_xdg_toplevel_decoration_v1_set_mode(WLRDECO, WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); +} diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index 5e8e9680..13a60b7c 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -118,8 +118,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 - wlr_xdg_toplevel_set_size(pWindow->m_uSurface.xdg->toplevel, size.x, size.y); + else // vvvvv I don't know if this is fucking correct, but the fucking idea of putting shadows into a window's surface is borderline criminal. + wlr_xdg_toplevel_set_size(pWindow->m_uSurface.xdg->toplevel, size.x - pWindow->m_uSurface.xdg->current.geometry.x * 2, size.y - pWindow->m_uSurface.xdg->current.geometry.y * 2); } void CHyprXWaylandManager::setWindowStyleTiled(CWindow* pWindow, uint32_t edgez) {