mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 20:25:58 +01:00
stuff
This commit is contained in:
parent
93a2ac9de4
commit
66b8b80964
11 changed files with 99 additions and 34 deletions
|
@ -146,7 +146,7 @@ wlr_box CWindow::getWindowInputBox() {
|
|||
|
||||
for (auto& wd : m_dWindowDecorations) {
|
||||
|
||||
if (!wd->allowsInput())
|
||||
if (!(wd->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT))
|
||||
continue;
|
||||
|
||||
const auto EXTENTS = wd->getWindowDecorationExtents();
|
||||
|
|
|
@ -317,7 +317,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
|
|||
|
||||
if (!m_vOverrideFocalPoint && g_pInputManager->m_bWasDraggingWindow) {
|
||||
for (auto& wd : OPENINGON->pWindow->m_dWindowDecorations) {
|
||||
if (!wd->allowsInput())
|
||||
if (!(wd->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT))
|
||||
continue;
|
||||
|
||||
if (wd->getWindowDecorationRegion().containsPoint(MOUSECOORDS)) {
|
||||
|
|
|
@ -96,7 +96,7 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc
|
|||
|
||||
if (g_pInputManager->m_bWasDraggingWindow && OPENINGON) {
|
||||
for (auto& wd : OPENINGON->pWindow->m_dWindowDecorations) {
|
||||
if (!wd->allowsInput())
|
||||
if (!(wd->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT))
|
||||
continue;
|
||||
|
||||
if (wd->getWindowDecorationRegion().containsPoint(MOUSECOORDS)) {
|
||||
|
|
|
@ -1841,7 +1841,7 @@ void CKeybindManager::mouse(std::string args) {
|
|||
|
||||
if (pWindow && !pWindow->m_bIsFullscreen && !pWindow->hasPopupAt(mouseCoords)) {
|
||||
for (auto& wd : pWindow->m_dWindowDecorations) {
|
||||
if (!wd->allowsInput())
|
||||
if (!(wd->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT))
|
||||
continue;
|
||||
|
||||
if (wd->getWindowDecorationRegion().containsPoint(mouseCoords)) {
|
||||
|
|
|
@ -585,7 +585,7 @@ void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
|
|||
|
||||
if (w && !w->m_bIsFullscreen && !w->hasPopupAt(mouseCoords)) {
|
||||
for (auto& wd : w->m_dWindowDecorations) {
|
||||
if (!wd->allowsInput())
|
||||
if (!(wd->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT))
|
||||
continue;
|
||||
|
||||
if (wd->getWindowDecorationRegion().containsPoint(mouseCoords)) {
|
||||
|
@ -1634,11 +1634,11 @@ void CInputManager::setCursorIconOnBorder(CWindow* w) {
|
|||
|
||||
bool onDeco = false;
|
||||
|
||||
for (auto& d : w->m_dWindowDecorations) {
|
||||
if (!d->allowsInput())
|
||||
for (auto& wd : w->m_dWindowDecorations) {
|
||||
if (!(wd->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT))
|
||||
continue;
|
||||
|
||||
if (d->getWindowDecorationRegion().containsPoint(mouseCoords)) {
|
||||
if (wd->getWindowDecorationRegion().containsPoint(mouseCoords)) {
|
||||
onDeco = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,33 @@ void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) {
|
|||
m_vLastWindowSize = pWindow->m_vRealSize.vec();
|
||||
|
||||
damageEntire();
|
||||
|
||||
const auto BORDER = m_pWindow->getRealBorderSize();
|
||||
|
||||
// calculate extents of decos with the DECORATION_PART_OF_MAIN_WINDOW flag
|
||||
SWindowDecorationExtents maxExtents;
|
||||
|
||||
for (auto& wd : m_pWindow->m_dWindowDecorations) {
|
||||
// conveniently, this will also skip us.
|
||||
if (!(wd->getDecorationFlags() & DECORATION_PART_OF_MAIN_WINDOW))
|
||||
continue;
|
||||
|
||||
const auto EXTENTS = wd->getWindowDecorationExtents();
|
||||
|
||||
if (maxExtents.topLeft.x < EXTENTS.topLeft.x)
|
||||
maxExtents.topLeft.x = EXTENTS.topLeft.x;
|
||||
if (maxExtents.topLeft.y < EXTENTS.topLeft.y)
|
||||
maxExtents.topLeft.y = EXTENTS.topLeft.y;
|
||||
if (maxExtents.bottomRight.x < EXTENTS.bottomRight.x)
|
||||
maxExtents.bottomRight.x = EXTENTS.bottomRight.x;
|
||||
if (maxExtents.bottomRight.y < EXTENTS.bottomRight.y)
|
||||
maxExtents.bottomRight.y = EXTENTS.bottomRight.y;
|
||||
}
|
||||
|
||||
// +1 +1 -2 -2 is to avoid artifacts with AA. TODO: figure out a better method. Alpha blending? This same shit will happen on hyprbars.
|
||||
m_bLastWindowBox = {(int)(m_vLastWindowPos.x - maxExtents.topLeft.x - BORDER + 1), (int)(m_vLastWindowPos.y - maxExtents.topLeft.y - BORDER + 1),
|
||||
(int)(m_vLastWindowSize.x + maxExtents.topLeft.x + maxExtents.bottomRight.x + 2 * BORDER - 2),
|
||||
(int)(m_vLastWindowSize.y + maxExtents.topLeft.y + maxExtents.bottomRight.y + 2 * BORDER - 2)};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,12 +102,11 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
|
|||
if (*PSHADOWS != 1)
|
||||
return; // disabled
|
||||
|
||||
const auto ROUNDING = !m_pWindow->m_sSpecialRenderData.rounding ?
|
||||
0 :
|
||||
(m_pWindow->m_sAdditionalConfigData.rounding.toUnderlying() == -1 ? *PROUNDING : m_pWindow->m_sAdditionalConfigData.rounding.toUnderlying());
|
||||
const auto ROUNDING = m_pWindow->rounding() + m_pWindow->getRealBorderSize();
|
||||
|
||||
// draw the shadow
|
||||
wlr_box fullBox = {m_vLastWindowPos.x - *PSHADOWSIZE, m_vLastWindowPos.y - *PSHADOWSIZE, m_vLastWindowSize.x + 2.0 * *PSHADOWSIZE, m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE};
|
||||
wlr_box fullBox = {m_bLastWindowBox.x - *PSHADOWSIZE, m_bLastWindowBox.y - *PSHADOWSIZE, m_bLastWindowBox.width + 2.0 * *PSHADOWSIZE,
|
||||
m_bLastWindowBox.height + 2.0 * *PSHADOWSIZE};
|
||||
|
||||
fullBox.x -= pMonitor->vecPosition.x;
|
||||
fullBox.y -= pMonitor->vecPosition.y;
|
||||
|
@ -95,22 +121,22 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
|
|||
if (PSHADOWOFFSET->x < 0) {
|
||||
fullBox.x += PSHADOWOFFSET->x;
|
||||
} else if (PSHADOWOFFSET->x > 0) {
|
||||
fullBox.x = m_vLastWindowPos.x + m_vLastWindowSize.x - fullBox.width + (SHADOWSCALE * *PSHADOWSIZE) + PSHADOWOFFSET->x - pMonitor->vecPosition.x;
|
||||
fullBox.x = m_bLastWindowBox.x + m_bLastWindowBox.width - fullBox.width + (SHADOWSCALE * *PSHADOWSIZE) + PSHADOWOFFSET->x - pMonitor->vecPosition.x;
|
||||
} else {
|
||||
fullBox.x += ((m_vLastWindowSize.x + 2.0 * *PSHADOWSIZE) - NEWSIZE.x) / 2.0;
|
||||
fullBox.x += ((m_bLastWindowBox.width + 2.0 * *PSHADOWSIZE) - NEWSIZE.x) / 2.0;
|
||||
}
|
||||
|
||||
if (PSHADOWOFFSET->y < 0) {
|
||||
fullBox.y += PSHADOWOFFSET->y;
|
||||
} else if (PSHADOWOFFSET->y > 0) {
|
||||
fullBox.y = m_vLastWindowPos.y + m_vLastWindowSize.y - fullBox.height + (SHADOWSCALE * *PSHADOWSIZE) + PSHADOWOFFSET->y - pMonitor->vecPosition.y;
|
||||
fullBox.y = m_bLastWindowBox.y + m_bLastWindowBox.height - fullBox.height + (SHADOWSCALE * *PSHADOWSIZE) + PSHADOWOFFSET->y - pMonitor->vecPosition.y;
|
||||
} else {
|
||||
fullBox.y += ((m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE) - NEWSIZE.y) / 2.0;
|
||||
fullBox.y += ((m_bLastWindowBox.height + 2.0 * *PSHADOWSIZE) - NEWSIZE.y) / 2.0;
|
||||
}
|
||||
|
||||
m_seExtents = {{m_vLastWindowPos.x - fullBox.x - pMonitor->vecPosition.x + 2, m_vLastWindowPos.y - fullBox.y - pMonitor->vecPosition.y + 2},
|
||||
{fullBox.x + fullBox.width + pMonitor->vecPosition.x - m_vLastWindowPos.x - m_vLastWindowSize.x + 2,
|
||||
fullBox.y + fullBox.height + pMonitor->vecPosition.y - m_vLastWindowPos.y - m_vLastWindowSize.y + 2}};
|
||||
m_seExtents = {{m_bLastWindowBox.x - fullBox.x - pMonitor->vecPosition.x + 2, m_bLastWindowBox.y - fullBox.y - pMonitor->vecPosition.y + 2},
|
||||
{fullBox.x + fullBox.width + pMonitor->vecPosition.x - m_bLastWindowBox.x - m_bLastWindowBox.width + 2,
|
||||
fullBox.y + fullBox.height + pMonitor->vecPosition.y - m_bLastWindowBox.y - m_bLastWindowBox.height + 2}};
|
||||
|
||||
fullBox.x += offset.x;
|
||||
fullBox.y += offset.y;
|
||||
|
@ -129,7 +155,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
|
|||
glStencilFunc(GL_ALWAYS, 1, -1);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||
|
||||
wlr_box windowBox = {m_vLastWindowPos.x - pMonitor->vecPosition.x, m_vLastWindowPos.y - pMonitor->vecPosition.y, m_vLastWindowSize.x, m_vLastWindowSize.y};
|
||||
wlr_box windowBox = {m_bLastWindowBox.x - pMonitor->vecPosition.x, m_bLastWindowBox.y - pMonitor->vecPosition.y, m_bLastWindowBox.width, m_bLastWindowBox.height};
|
||||
|
||||
scaleBox(&windowBox, pMonitor->scale);
|
||||
|
||||
|
@ -156,3 +182,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
|
|||
glDisable(GL_STENCIL_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
eDecorationLayer CHyprDropShadowDecoration::getDecorationLayer() {
|
||||
return DECORATION_LAYER_BOTTOM;
|
||||
}
|
|
@ -17,6 +17,8 @@ class CHyprDropShadowDecoration : public IHyprWindowDecoration {
|
|||
|
||||
virtual void damageEntire();
|
||||
|
||||
virtual eDecorationLayer getDecorationLayer();
|
||||
|
||||
private:
|
||||
SWindowDecorationExtents m_seExtents;
|
||||
|
||||
|
@ -24,4 +26,6 @@ class CHyprDropShadowDecoration : public IHyprWindowDecoration {
|
|||
|
||||
Vector2D m_vLastWindowPos;
|
||||
Vector2D m_vLastWindowSize;
|
||||
|
||||
wlr_box m_bLastWindowBox = {0};
|
||||
};
|
|
@ -301,10 +301,6 @@ void CHyprGroupBarDecoration::refreshGradients() {
|
|||
renderGradientTo(m_tGradientInactive, ((CGradientValueData*)PCOLINACTIVE->get())->m_vColors[0]);
|
||||
}
|
||||
|
||||
bool CHyprGroupBarDecoration::allowsInput() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(CWindow* pDraggedWindow, const Vector2D& pos) {
|
||||
|
||||
if (!pDraggedWindow->canBeGroupedInto(m_pWindow))
|
||||
|
@ -407,3 +403,11 @@ void CHyprGroupBarDecoration::onBeginWindowDragOnDeco(const Vector2D& pos) {
|
|||
if (!g_pCompositor->isWindowActive(pWindow))
|
||||
g_pCompositor->focusWindow(pWindow);
|
||||
}
|
||||
|
||||
eDecorationLayer CHyprGroupBarDecoration::getDecorationLayer() {
|
||||
return DECORATION_LAYER_OVER;
|
||||
}
|
||||
|
||||
uint64_t CHyprGroupBarDecoration::getDecorationFlags() {
|
||||
return DECORATION_ALLOWS_MOUSE_INPUT;
|
||||
}
|
|
@ -33,14 +33,16 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration {
|
|||
|
||||
virtual SWindowDecorationExtents getWindowDecorationReservedArea();
|
||||
|
||||
virtual bool allowsInput();
|
||||
|
||||
virtual void onBeginWindowDragOnDeco(const Vector2D&);
|
||||
|
||||
virtual bool onEndWindowDragOnDeco(CWindow* pDraggedWindow, const Vector2D&);
|
||||
|
||||
virtual void onMouseButtonOnDeco(const Vector2D&, wlr_pointer_button_event*);
|
||||
|
||||
virtual eDecorationLayer getDecorationLayer();
|
||||
|
||||
virtual uint64_t getDecorationFlags();
|
||||
|
||||
private:
|
||||
SWindowDecorationExtents m_seExtents;
|
||||
|
||||
|
|
|
@ -25,14 +25,22 @@ CRegion IHyprWindowDecoration::getWindowDecorationRegion() {
|
|||
m_pWindow->m_vRealSize.vec().y + 2 * BORDERSIZE));
|
||||
}
|
||||
|
||||
bool IHyprWindowDecoration::allowsInput() {
|
||||
return false;
|
||||
void IHyprWindowDecoration::onBeginWindowDragOnDeco(const Vector2D&) {
|
||||
;
|
||||
}
|
||||
|
||||
void IHyprWindowDecoration::onBeginWindowDragOnDeco(const Vector2D&) {}
|
||||
|
||||
bool IHyprWindowDecoration::onEndWindowDragOnDeco(CWindow* pDraggedWindow, const Vector2D&) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void IHyprWindowDecoration::onMouseButtonOnDeco(const Vector2D&, wlr_pointer_button_event*) {}
|
||||
void IHyprWindowDecoration::onMouseButtonOnDeco(const Vector2D&, wlr_pointer_button_event*) {
|
||||
;
|
||||
}
|
||||
|
||||
eDecorationLayer IHyprWindowDecoration::getDecorationLayer() {
|
||||
return DECORATION_LAYER_UNDER;
|
||||
}
|
||||
|
||||
uint64_t IHyprWindowDecoration::getDecorationFlags() {
|
||||
return 0;
|
||||
}
|
|
@ -3,7 +3,8 @@
|
|||
#include "../../defines.hpp"
|
||||
#include "../../helpers/Region.hpp"
|
||||
|
||||
enum eDecorationType {
|
||||
enum eDecorationType
|
||||
{
|
||||
DECORATION_NONE = -1,
|
||||
DECORATION_GROUPBAR,
|
||||
DECORATION_SHADOW,
|
||||
|
@ -15,6 +16,20 @@ struct SWindowDecorationExtents {
|
|||
Vector2D bottomRight;
|
||||
};
|
||||
|
||||
enum eDecorationLayer
|
||||
{
|
||||
DECORATION_LAYER_BOTTOM = 0, /* lowest. */
|
||||
DECORATION_LAYER_UNDER, /* under the window, but above BOTTOM */
|
||||
DECORATION_LAYER_OVER, /* above the window, but below its popups */
|
||||
DECORATION_LAYER_OVERLAY /* above everything of the window, including popups */
|
||||
};
|
||||
|
||||
enum eDecorationFlags
|
||||
{
|
||||
DECORATION_ALLOWS_MOUSE_INPUT = 1 << 0, /* this decoration accepts mouse input */
|
||||
DECORATION_PART_OF_MAIN_WINDOW = 1 << 1, /* this decoration is a *seamless* part of the main window, so stuff like shadows will include it */
|
||||
};
|
||||
|
||||
class CWindow;
|
||||
class CMonitor;
|
||||
|
||||
|
@ -37,14 +52,16 @@ class IHyprWindowDecoration {
|
|||
|
||||
virtual CRegion getWindowDecorationRegion();
|
||||
|
||||
virtual bool allowsInput();
|
||||
|
||||
virtual void onBeginWindowDragOnDeco(const Vector2D&); // called when the user calls the "movewindow" mouse dispatcher on the deco
|
||||
|
||||
virtual bool onEndWindowDragOnDeco(CWindow* pDraggedWindow, const Vector2D&); // returns true if the window should be placed by the layout
|
||||
|
||||
virtual void onMouseButtonOnDeco(const Vector2D&, wlr_pointer_button_event*);
|
||||
|
||||
virtual eDecorationLayer getDecorationLayer();
|
||||
|
||||
virtual uint64_t getDecorationFlags();
|
||||
|
||||
private:
|
||||
CWindow* m_pWindow = nullptr;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue