diff --git a/src/Compositor.cpp b/src/Compositor.cpp index eb2c9f92..49844286 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -102,6 +102,8 @@ CCompositor::CCompositor() { m_sWLRVKeyboardMgr = wlr_virtual_keyboard_manager_v1_create(m_sWLDisplay); m_sWLRVirtPtrMgr = wlr_virtual_pointer_manager_v1_create(m_sWLDisplay); + + m_sWLRToplevelMgr = wlr_foreign_toplevel_manager_v1_create(m_sWLDisplay); } CCompositor::~CCompositor() { @@ -442,6 +444,9 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) { wlr_seat_keyboard_notify_clear_focus(m_sSeat.seat); wlr_seat_pointer_clear_focus(m_sSeat.seat); } + + if (PLASTWINDOW->m_phForeignToplevel) + wlr_foreign_toplevel_handle_v1_set_activated(PLASTWINDOW->m_phForeignToplevel, false); } m_pLastWindow = PLASTWINDOW; @@ -460,6 +465,9 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) { // Send an event g_pEventManager->postEvent(SHyprIPCEvent("activewindow", g_pXWaylandManager->getAppIDClass(pWindow) + "," + pWindow->m_szTitle)); + + if (pWindow->m_phForeignToplevel) + wlr_foreign_toplevel_handle_v1_set_activated(pWindow->m_phForeignToplevel, true); } void CCompositor::focusSurface(wlr_surface* pSurface, CWindow* pWindowOwner) { diff --git a/src/Compositor.hpp b/src/Compositor.hpp index 5a3f55c4..870819fb 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -58,6 +58,7 @@ public: wlr_server_decoration_manager* m_sWLRServerDecoMgr; wlr_xdg_decoration_manager_v1* m_sWLRXDGDecoMgr; wlr_virtual_pointer_manager_v1* m_sWLRVirtPtrMgr; + wlr_foreign_toplevel_manager_v1* m_sWLRToplevelMgr; // ------------------------------------------------- // diff --git a/src/Window.hpp b/src/Window.hpp index 8977c7ff..e7861237 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -90,6 +90,9 @@ public: // For hidden windows and stuff bool m_bHidden = false; + // Foreign Toplevel proto + wlr_foreign_toplevel_handle_v1* m_phForeignToplevel = nullptr; + // Window decorations std::deque> m_dWindowDecorations; diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 377b3d78..9c74572a 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -35,6 +35,11 @@ void Events::listener_mapWindow(void* owner, void* data) { PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW); PWINDOW->m_fAlpha = 255.f; + // Foreign Toplevel + PWINDOW->m_phForeignToplevel = wlr_foreign_toplevel_handle_v1_create(g_pCompositor->m_sWLRToplevelMgr); + // TODO: handle foreign events (requests) + wlr_foreign_toplevel_handle_v1_set_app_id(PWINDOW->m_phForeignToplevel, g_pXWaylandManager->getAppIDClass(PWINDOW).c_str()); + // checks if the window wants borders and sets the appriopriate flag g_pXWaylandManager->checkBorders(PWINDOW); @@ -256,6 +261,10 @@ void Events::listener_unmapWindow(void* owner, void* data) { PWINDOW->m_vOriginalClosedSize = PWINDOW->m_vRealSize.vec(); PWINDOW->m_vRealPosition = PWINDOW->m_vRealPosition.vec() + Vector2D(0.01f, 0.01f); // it has to be animated, otherwise onWindowPostCreateClose will ignore it g_pAnimationManager->onWindowPostCreateClose(PWINDOW, true); + + // Destroy Foreign Toplevel + wlr_foreign_toplevel_handle_v1_destroy(PWINDOW->m_phForeignToplevel); + PWINDOW->m_phForeignToplevel = nullptr; } void Events::listener_commitWindow(void* owner, void* data) { @@ -303,6 +312,9 @@ void Events::listener_setTitleWindow(void* owner, void* data) { if (PWINDOW == g_pCompositor->m_pLastWindow) // if it's the active, let's post an event to update others g_pEventManager->postEvent(SHyprIPCEvent("activewindow", g_pXWaylandManager->getAppIDClass(PWINDOW) + "," + PWINDOW->m_szTitle)); + if (PWINDOW->m_phForeignToplevel) + wlr_foreign_toplevel_handle_v1_set_title(PWINDOW->m_phForeignToplevel, PWINDOW->m_szTitle.c_str()); + Debug::log(LOG, "Window %x set title to %s", PWINDOW, PWINDOW->m_szTitle.c_str()); } diff --git a/src/includes.hpp b/src/includes.hpp index abe90bfa..65f2d0f4 100644 --- a/src/includes.hpp +++ b/src/includes.hpp @@ -73,6 +73,7 @@ extern "C" { #include #include #include +#include #include #include #include diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index 9c402419..1a2c329b 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -222,5 +222,8 @@ void CHyprXWaylandManager::setWindowFullscreen(CWindow* pWindow, bool fullscreen wlr_xdg_toplevel_set_fullscreen(pWindow->m_uSurface.xdg->toplevel, fullscreen); } + if (pWindow->m_phForeignToplevel) + wlr_foreign_toplevel_handle_v1_set_fullscreen(pWindow->m_phForeignToplevel, fullscreen); + g_pEventManager->postEvent(SHyprIPCEvent("fullscreen", std::to_string((int)fullscreen))); } \ No newline at end of file