diff options
author | vaxerski <[email protected]> | 2022-05-29 11:24:42 +0200 |
---|---|---|
committer | vaxerski <[email protected]> | 2022-05-29 11:24:42 +0200 |
commit | fdb3f610e564c644ab0fc7fd154562258350084a (patch) | |
tree | 9073f6d178e12d075ed95ce69368ee41a3c2751c | |
parent | d2e1899f2644f0b5f62275c771d6e6be24025e4f (diff) | |
download | Hyprland-fdb3f610e564c644ab0fc7fd154562258350084a.tar.gz Hyprland-fdb3f610e564c644ab0fc7fd154562258350084a.zip |
Added wlr_foreign_toplevel_v1
-rw-r--r-- | src/Compositor.cpp | 8 | ||||
-rw-r--r-- | src/Compositor.hpp | 1 | ||||
-rw-r--r-- | src/Window.hpp | 3 | ||||
-rw-r--r-- | src/events/Windows.cpp | 12 | ||||
-rw-r--r-- | src/includes.hpp | 1 | ||||
-rw-r--r-- | src/managers/XWaylandManager.cpp | 3 |
6 files changed, 28 insertions, 0 deletions
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<std::unique_ptr<IHyprWindowDecoration>> 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 <wlr/types/wlr_input_inhibitor.h> #include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h> #include <wlr/types/wlr_virtual_pointer_v1.h> +#include <wlr/types/wlr_foreign_toplevel_management_v1.h> #include <wlr/util/log.h> #include <wlr/xwayland.h> #include <wlr/util/region.h> 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 |