summaryrefslogtreecommitdiff
path: root/src/managers
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-05-10 23:28:33 +0100
committerVaxry <43317083+vaxerski@users.noreply.github.com>2024-05-14 23:02:24 +0100
commit0cfdde3d1acbfbf698af17f6986fbc4d644214da (patch)
tree579ac53bc228db6d0feb373448c8e5557d3285d4 /src/managers
parent121d3a72137d4780602cf245704615f63357ea22 (diff)
xdg-shell: move to new impl
Diffstat (limited to 'src/managers')
-rw-r--r--src/managers/ProtocolManager.cpp2
-rw-r--r--src/managers/XWaylandManager.cpp121
-rw-r--r--src/managers/XWaylandManager.hpp3
-rw-r--r--src/managers/input/InputManager.cpp6
4 files changed, 38 insertions, 94 deletions
diff --git a/src/managers/ProtocolManager.cpp b/src/managers/ProtocolManager.cpp
index f853e16f..e53eb111 100644
--- a/src/managers/ProtocolManager.cpp
+++ b/src/managers/ProtocolManager.cpp
@@ -29,6 +29,7 @@
#include "../protocols/LayerShell.hpp"
#include "../protocols/PresentationTime.hpp"
#include "../protocols/core/Seat.hpp"
+#include "../protocols/XDGShell.hpp"
CProtocolManager::CProtocolManager() {
@@ -64,6 +65,7 @@ CProtocolManager::CProtocolManager() {
PROTO::tablet = std::make_unique<CTabletV2Protocol>(&zwp_tablet_manager_v2_interface, 1, "TabletV2");
PROTO::layerShell = std::make_unique<CLayerShellProtocol>(&zwlr_layer_shell_v1_interface, 5, "LayerShell");
PROTO::presentation = std::make_unique<CPresentationProtocol>(&wp_presentation_interface, 1, "Presentation");
+ PROTO::xdgShell = std::make_unique<CXDGShellProtocol>(&xdg_wm_base_interface, 6, "XDGShell");
// Old protocol implementations.
// TODO: rewrite them to use hyprwayland-scanner.
diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp
index 423c45ca..390c6ece 100644
--- a/src/managers/XWaylandManager.cpp
+++ b/src/managers/XWaylandManager.cpp
@@ -2,6 +2,7 @@
#include "../Compositor.hpp"
#include "../events/Events.hpp"
#include "../config/ConfigValue.hpp"
+#include "../protocols/XDGShell.hpp"
#define OUTPUT_MANAGER_VERSION 3
#define OUTPUT_DONE_DEPRECATED_SINCE_VERSION 3
@@ -34,27 +35,32 @@ CHyprXWaylandManager::~CHyprXWaylandManager() {
}
wlr_surface* CHyprXWaylandManager::getWindowSurface(PHLWINDOW pWindow) {
- if (pWindow->m_bIsX11)
- return pWindow->m_uSurface.xwayland->surface;
-
- return pWindow->m_uSurface.xdg->surface;
+ return pWindow->m_pWLSurface.wlr();
}
void CHyprXWaylandManager::activateSurface(wlr_surface* pSurface, bool activate) {
if (!pSurface)
return;
- if (wlr_xdg_surface_try_from_wlr_surface(pSurface)) {
- if (const auto PSURF = wlr_xdg_surface_try_from_wlr_surface(pSurface); PSURF && PSURF->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL)
- wlr_xdg_toplevel_set_activated(PSURF->toplevel, activate);
-
- } else if (wlr_xwayland_surface_try_from_wlr_surface(pSurface)) {
+ if (wlr_xwayland_surface_try_from_wlr_surface(pSurface)) {
const auto XSURF = wlr_xwayland_surface_try_from_wlr_surface(pSurface);
wlr_xwayland_surface_activate(XSURF, activate);
if (activate && !XSURF->override_redirect)
wlr_xwayland_surface_restack(XSURF, nullptr, XCB_STACK_MODE_ABOVE);
}
+
+ // TODO:
+ // this cannot be nicely done until we rewrite wlr_surface
+ for (auto& w : g_pCompositor->m_vWindows) {
+ if (w->m_bIsX11 || !w->m_bIsMapped)
+ continue;
+
+ if (w->m_pWLSurface.wlr() != pSurface)
+ continue;
+
+ w->m_pXDGSurface->toplevel->setActive(activate);
+ }
}
void CHyprXWaylandManager::activateWindow(PHLWINDOW pWindow, bool activate) {
@@ -68,8 +74,8 @@ void CHyprXWaylandManager::activateWindow(PHLWINDOW pWindow, bool activate) {
}
wlr_xwayland_surface_activate(pWindow->m_uSurface.xwayland, activate);
- } else
- wlr_xdg_toplevel_set_activated(pWindow->m_uSurface.xdg->toplevel, activate);
+ } else if (pWindow->m_pXDGSurface && pWindow->m_pXDGSurface->toplevel)
+ pWindow->m_pXDGSurface->toplevel->setActive(activate);
if (activate) {
g_pCompositor->m_pLastFocus = getWindowSurface(pWindow);
@@ -95,64 +101,15 @@ void CHyprXWaylandManager::getGeometryForWindow(PHLWINDOW pWindow, CBox* pbox) {
pbox->width = pWindow->m_uSurface.xwayland->width;
pbox->height = pWindow->m_uSurface.xwayland->height;
}
- } else {
- wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, pbox->pWlr());
- pbox->applyFromWlr();
- }
-}
-
-std::string CHyprXWaylandManager::getTitle(PHLWINDOW pWindow) {
- try {
- if (pWindow->m_bIsX11) {
- if (!pWindow->m_bIsMapped)
- return "";
-
- if (pWindow->m_uSurface.xwayland && pWindow->m_uSurface.xwayland->title) {
- return std::string(pWindow->m_uSurface.xwayland->title);
- }
- } else if (pWindow->m_uSurface.xdg) {
- if (pWindow->m_bFadingOut || !pWindow->m_uSurface.xdg)
- return "";
-
- if (pWindow->m_uSurface.xdg->toplevel && pWindow->m_uSurface.xdg->toplevel->title) {
- return std::string(pWindow->m_uSurface.xdg->toplevel->title);
- }
- } else {
- return "";
- }
- } catch (...) { Debug::log(ERR, "Error in getTitle (probably null title)"); }
-
- return "";
-}
-
-std::string CHyprXWaylandManager::getAppIDClass(PHLWINDOW pWindow) {
- try {
- if (pWindow->m_bIsX11) {
- if (!pWindow->m_bIsMapped)
- return "";
-
- if (pWindow->m_uSurface.xwayland && pWindow->m_uSurface.xwayland->_class) {
- return std::string(pWindow->m_uSurface.xwayland->_class);
- }
- } else if (pWindow->m_uSurface.xdg) {
- if (pWindow->m_bFadingOut || !pWindow->m_uSurface.xdg)
- return "";
-
- if (pWindow->m_uSurface.xdg->toplevel && pWindow->m_uSurface.xdg->toplevel->app_id) {
- return std::string(pWindow->m_uSurface.xdg->toplevel->app_id);
- }
- } else
- return "";
- } catch (std::logic_error& e) { Debug::log(ERR, "Error in getAppIDClass: {}", e.what()); }
-
- return "";
+ } else if (pWindow->m_pXDGSurface)
+ *pbox = pWindow->m_pXDGSurface->current.geometry;
}
void CHyprXWaylandManager::sendCloseWindow(PHLWINDOW pWindow) {
if (pWindow->m_bIsX11)
wlr_xwayland_surface_close(pWindow->m_uSurface.xwayland);
- else
- wlr_xdg_toplevel_send_close(pWindow->m_uSurface.xdg->toplevel);
+ else if (pWindow->m_pXDGSurface && pWindow->m_pXDGSurface->toplevel)
+ pWindow->m_pXDGSurface->toplevel->close();
}
void CHyprXWaylandManager::setWindowSize(PHLWINDOW pWindow, Vector2D size, bool force) {
@@ -189,23 +146,12 @@ void CHyprXWaylandManager::setWindowSize(PHLWINDOW pWindow, Vector2D size, bool
if (pWindow->m_bIsX11)
wlr_xwayland_surface_configure(pWindow->m_uSurface.xwayland, windowPos.x, windowPos.y, size.x, size.y);
- else
- pWindow->m_vPendingSizeAcks.push_back(std::make_pair<>(wlr_xdg_toplevel_set_size(pWindow->m_uSurface.xdg->toplevel, size.x, size.y), size.floor()));
-}
-
-void CHyprXWaylandManager::setWindowStyleTiled(PHLWINDOW pWindow, uint32_t edgez) {
- if (pWindow->m_bIsX11)
- return;
-
- wlr_xdg_toplevel_set_tiled(pWindow->m_uSurface.xdg->toplevel, edgez);
- wlr_xdg_toplevel_set_maximized(pWindow->m_uSurface.xdg->toplevel, true);
+ else if (pWindow->m_pXDGSurface->toplevel)
+ pWindow->m_vPendingSizeAcks.push_back(std::make_pair<>(pWindow->m_pXDGSurface->toplevel->setSize(size), size.floor()));
}
wlr_surface* CHyprXWaylandManager::surfaceAt(PHLWINDOW pWindow, const Vector2D& client, Vector2D& surface) {
- if (pWindow->m_bIsX11)
- return wlr_surface_surface_at(pWindow->m_uSurface.xwayland->surface, client.x, client.y, &surface.x, &surface.y);
-
- return wlr_xdg_surface_surface_at(pWindow->m_uSurface.xdg, client.x, client.y, &surface.x, &surface.y);
+ return wlr_surface_surface_at(pWindow->m_pWLSurface.wlr(), client.x, client.y, &surface.x, &surface.y);
}
bool CHyprXWaylandManager::shouldBeFloated(PHLWINDOW pWindow, bool pending) {
@@ -251,10 +197,10 @@ bool CHyprXWaylandManager::shouldBeFloated(PHLWINDOW pWindow, bool pending) {
if (SIZEHINTS && (pWindow->m_uSurface.xwayland->parent || ((SIZEHINTS->min_width == SIZEHINTS->max_width) && (SIZEHINTS->min_height == SIZEHINTS->max_height))))
return true;
} else {
- const auto PSTATE = pending ? &pWindow->m_uSurface.xdg->toplevel->pending : &pWindow->m_uSurface.xdg->toplevel->current;
+ const auto PSTATE = pending ? &pWindow->m_pXDGSurface->toplevel->pending : &pWindow->m_pXDGSurface->toplevel->current;
- if ((PSTATE->min_width != 0 && PSTATE->min_height != 0 && (PSTATE->min_width == PSTATE->max_width || PSTATE->min_height == PSTATE->max_height)) ||
- pWindow->m_uSurface.xdg->toplevel->parent)
+ if (pWindow->m_pXDGSurface->toplevel->parent ||
+ (PSTATE->minSize.x != 0 && PSTATE->minSize.y != 0 && (PSTATE->minSize.x == PSTATE->maxSize.x || PSTATE->minSize.y == PSTATE->maxSize.y)))
return true;
}
@@ -297,20 +243,19 @@ void CHyprXWaylandManager::checkBorders(PHLWINDOW pWindow) {
void CHyprXWaylandManager::setWindowFullscreen(PHLWINDOW pWindow, bool fullscreen) {
if (pWindow->m_bIsX11)
wlr_xwayland_surface_set_fullscreen(pWindow->m_uSurface.xwayland, fullscreen);
- else
- wlr_xdg_toplevel_set_fullscreen(pWindow->m_uSurface.xdg->toplevel, fullscreen);
+ else if (pWindow->m_pXDGSurface && pWindow->m_pXDGSurface->toplevel)
+ pWindow->m_pXDGSurface->toplevel->setFullscreen(fullscreen);
}
Vector2D CHyprXWaylandManager::getMaxSizeForWindow(PHLWINDOW pWindow) {
if (!validMapped(pWindow))
return Vector2D(99999, 99999);
- if ((pWindow->m_bIsX11 && !pWindow->m_uSurface.xwayland->size_hints) || (!pWindow->m_bIsX11 && !pWindow->m_uSurface.xdg->toplevel) ||
- pWindow->m_sAdditionalConfigData.noMaxSize)
+ if ((pWindow->m_bIsX11 && !pWindow->m_uSurface.xwayland->size_hints) || (!pWindow->m_bIsX11 && !pWindow->m_pXDGSurface->toplevel) || pWindow->m_sAdditionalConfigData.noMaxSize)
return Vector2D(99999, 99999);
auto MAXSIZE = pWindow->m_bIsX11 ? Vector2D(pWindow->m_uSurface.xwayland->size_hints->max_width, pWindow->m_uSurface.xwayland->size_hints->max_height) :
- Vector2D(pWindow->m_uSurface.xdg->toplevel->current.max_width, pWindow->m_uSurface.xdg->toplevel->current.max_height);
+ pWindow->m_pXDGSurface->toplevel->current.maxSize;
if (MAXSIZE.x < 5)
MAXSIZE.x = 99999;
@@ -324,11 +269,11 @@ Vector2D CHyprXWaylandManager::getMinSizeForWindow(PHLWINDOW pWindow) {
if (!validMapped(pWindow))
return Vector2D(0, 0);
- if ((pWindow->m_bIsX11 && !pWindow->m_uSurface.xwayland->size_hints) || (!pWindow->m_bIsX11 && !pWindow->m_uSurface.xdg->toplevel))
+ if ((pWindow->m_bIsX11 && !pWindow->m_uSurface.xwayland->size_hints) || (!pWindow->m_bIsX11 && !pWindow->m_pXDGSurface->toplevel))
return Vector2D(0, 0);
auto MINSIZE = pWindow->m_bIsX11 ? Vector2D(pWindow->m_uSurface.xwayland->size_hints->min_width, pWindow->m_uSurface.xwayland->size_hints->min_height) :
- Vector2D(pWindow->m_uSurface.xdg->toplevel->current.min_width, pWindow->m_uSurface.xdg->toplevel->current.min_height);
+ pWindow->m_pXDGSurface->toplevel->current.minSize;
MINSIZE = MINSIZE.clamp({1, 1});
diff --git a/src/managers/XWaylandManager.hpp b/src/managers/XWaylandManager.hpp
index 6edadd71..8889eb61 100644
--- a/src/managers/XWaylandManager.hpp
+++ b/src/managers/XWaylandManager.hpp
@@ -17,11 +17,8 @@ class CHyprXWaylandManager {
void activateSurface(wlr_surface*, bool);
void activateWindow(PHLWINDOW, bool);
void getGeometryForWindow(PHLWINDOW, CBox*);
- std::string getTitle(PHLWINDOW);
- std::string getAppIDClass(PHLWINDOW);
void sendCloseWindow(PHLWINDOW);
void setWindowSize(PHLWINDOW, Vector2D, bool force = false);
- void setWindowStyleTiled(PHLWINDOW, uint32_t);
void setWindowFullscreen(PHLWINDOW, bool);
wlr_surface* surfaceAt(PHLWINDOW, const Vector2D&, Vector2D&);
bool shouldBeFloated(PHLWINDOW, bool pending = false);
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 62d9e687..bb0ab65a 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -15,6 +15,7 @@
#include "../../protocols/VirtualPointer.hpp"
#include "../../protocols/LayerShell.hpp"
#include "../../protocols/core/Seat.hpp"
+#include "../../protocols/XDGShell.hpp"
#include "../../devices/Mouse.hpp"
#include "../../devices/VirtualPointer.hpp"
@@ -387,10 +388,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
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);
+ CBox geom = pFoundWindow->m_pXDGSurface->current.geometry;
- surfaceLocal = mouseCoords - surfacePos + Vector2D(geom.x, geom.y);
+ surfaceLocal = mouseCoords - surfacePos + geom.pos();
}
if (pFoundWindow && pFoundWindow->m_bIsX11) // for x11 force scale zero