finally fixed XWayland popups

This commit is contained in:
vaxerski 2022-03-22 21:28:57 +01:00
parent e6a848adc0
commit 2bc29f32ec
7 changed files with 33 additions and 6 deletions

View file

@ -321,7 +321,7 @@ void CCompositor::focusSurface(wlr_surface* pSurface) {
return; // Don't focus when already focused on this. return; // Don't focus when already focused on this.
// Unfocus last surface // Unfocus last surface
if (m_pLastFocus) if (m_pLastFocus && !wlr_surface_is_xwayland_surface(m_pLastFocus))
g_pXWaylandManager->activateSurface(m_pLastFocus, false); g_pXWaylandManager->activateSurface(m_pLastFocus, false);
const auto KEYBOARD = wlr_seat_get_keyboard(m_sSeat.seat); const auto KEYBOARD = wlr_seat_get_keyboard(m_sSeat.seat);

View file

@ -49,6 +49,7 @@ public:
bool m_bMappedX11 = false; bool m_bMappedX11 = false;
uint64_t m_iX11Type = 0; uint64_t m_iX11Type = 0;
bool m_bIsModal = false; bool m_bIsModal = false;
bool m_bX11DoesntWantBorders = false;
DYNLISTENER(activateX11); DYNLISTENER(activateX11);
DYNLISTENER(configureX11); DYNLISTENER(configureX11);
// //

View file

@ -24,6 +24,9 @@ void Events::listener_mapWindow(wl_listener* listener, void* data) {
PWINDOW->m_iWorkspaceID = PMONITOR->activeWorkspace; PWINDOW->m_iWorkspaceID = PMONITOR->activeWorkspace;
PWINDOW->m_bIsMapped = true; PWINDOW->m_bIsMapped = true;
// checks if the window wants borders and sets the appriopriate flag
g_pXWaylandManager->checkBorders(PWINDOW);
const auto PWINDOWSURFACE = g_pXWaylandManager->getWindowSurface(PWINDOW); const auto PWINDOWSURFACE = g_pXWaylandManager->getWindowSurface(PWINDOW);
if (!PWINDOWSURFACE) { if (!PWINDOWSURFACE) {

View file

@ -335,13 +335,13 @@ void CHyprDwindleLayout::onWindowCreatedFloating(CWindow* pWindow) {
// check if it's on the correct monitor! // check if it's on the correct monitor!
Vector2D middlePoint = Vector2D(desiredGeometry.x, desiredGeometry.y) + Vector2D(desiredGeometry.width, desiredGeometry.height) / 2.f; Vector2D middlePoint = Vector2D(desiredGeometry.x, desiredGeometry.y) + Vector2D(desiredGeometry.width, desiredGeometry.height) / 2.f;
if (g_pCompositor->getMonitorFromVector(middlePoint)->ID != pWindow->m_iMonitorID) { // TODO: detect a popup in a more consistent way.
if (g_pCompositor->getMonitorFromVector(middlePoint)->ID != pWindow->m_iMonitorID || (desiredGeometry.x == 0 && desiredGeometry.y == 0)) {
// if it's not, fall back to the center placement // if it's not, fall back to the center placement
pWindow->m_vRealPosition = PMONITOR->vecPosition + Vector2D((PMONITOR->vecSize.x - desiredGeometry.width) / 2.f, (PMONITOR->vecSize.y - desiredGeometry.height) / 2.f); pWindow->m_vRealPosition = PMONITOR->vecPosition + Vector2D((PMONITOR->vecSize.x - desiredGeometry.width) / 2.f, (PMONITOR->vecSize.y - desiredGeometry.height) / 2.f);
} else { } else {
// if it is, we respect where it wants to put itself. // if it is, we respect where it wants to put itself.
// most of these are popups // most of these are popups
// TODO: detect a popup in a more consistent way.
pWindow->m_vRealPosition = Vector2D(desiredGeometry.x, desiredGeometry.y); pWindow->m_vRealPosition = Vector2D(desiredGeometry.x, desiredGeometry.y);
} }
} }

View file

@ -109,7 +109,9 @@ bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow) {
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLBAR"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_UTILITY"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLBAR"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_UTILITY"] ||
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLTIP"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_POPUP_MENU"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLTIP"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_POPUP_MENU"] ||
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DOCK"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"]) pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DOCK"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"])
{
return true; return true;
}
if (pWindow->m_uSurface.xwayland->modal) { if (pWindow->m_uSurface.xwayland->modal) {
pWindow->m_bIsModal = true; pWindow->m_bIsModal = true;
@ -117,7 +119,7 @@ bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow) {
} }
const auto SIZEHINTS = pWindow->m_uSurface.xwayland->size_hints; const auto SIZEHINTS = pWindow->m_uSurface.xwayland->size_hints;
if (SIZEHINTS && SIZEHINTS->min_width > 0 && SIZEHINTS->min_height > 0 && (SIZEHINTS->max_width == SIZEHINTS->min_width || SIZEHINTS->max_height == SIZEHINTS->min_height)) if (SIZEHINTS && (pWindow->m_uSurface.xwayland->parent || ((SIZEHINTS->min_width == SIZEHINTS->max_width) && (SIZEHINTS->min_height == SIZEHINTS->max_height))))
return true; return true;
} else { } else {
const auto PSTATE = &pWindow->m_uSurface.xdg->toplevel->current; const auto PSTATE = &pWindow->m_uSurface.xdg->toplevel->current;
@ -134,3 +136,23 @@ void CHyprXWaylandManager::moveXWaylandWindow(CWindow* pWindow, const Vector2D&
wlr_xwayland_surface_configure(pWindow->m_uSurface.xwayland, pos.x, pos.y, pWindow->m_vRealSize.x, pWindow->m_vRealSize.y); wlr_xwayland_surface_configure(pWindow->m_uSurface.xwayland, pos.x, pos.y, pWindow->m_vRealSize.x, pWindow->m_vRealSize.y);
} }
} }
void CHyprXWaylandManager::checkBorders(CWindow* pWindow) {
if (!pWindow->m_bIsX11)
return;
for (size_t i = 0; i < pWindow->m_uSurface.xwayland->window_type_len; i++) {
if (pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_POPUP_MENU"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_NOTIFICATION"] ||
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_COMBO"] ||
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_MENU"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_SPLASH"] ||
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLTIP"]) {
pWindow->m_bX11DoesntWantBorders = true;
return;
}
}
if (pWindow->m_uSurface.xwayland->parent) {
pWindow->m_bX11DoesntWantBorders = true;
}
}

View file

@ -20,6 +20,7 @@ public:
wlr_surface* surfaceAt(CWindow*, const Vector2D&, Vector2D&); wlr_surface* surfaceAt(CWindow*, const Vector2D&, Vector2D&);
bool shouldBeFloated(CWindow*); bool shouldBeFloated(CWindow*);
void moveXWaylandWindow(CWindow*, const Vector2D&); void moveXWaylandWindow(CWindow*, const Vector2D&);
void checkBorders(CWindow*);
}; };
inline std::unique_ptr<CHyprXWaylandManager> g_pXWaylandManager; inline std::unique_ptr<CHyprXWaylandManager> g_pXWaylandManager;

View file

@ -61,7 +61,7 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(SMonitor* pMonitor, SWor
void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* time, bool decorate) { void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* time, bool decorate) {
// border // border
if (decorate) if (decorate && !pWindow->m_bX11DoesntWantBorders)
drawBorderForWindow(pWindow, pMonitor); drawBorderForWindow(pWindow, pMonitor);
SRenderData renderdata = {pMonitor->output, time, pWindow->m_vRealPosition.x, pWindow->m_vRealPosition.y}; SRenderData renderdata = {pMonitor->output, time, pWindow->m_vRealPosition.x, pWindow->m_vRealPosition.y};