hyprctl: add decorations (#4275)

* add hyprctl decorations

modified:   hyprctl/main.cpp
modified:   src/debug/HyprCtl.cpp
modified:   src/render/decorations/CHyprBorderDecoration.cpp
modified:   src/render/decorations/CHyprBorderDecoration.hpp
modified:   src/render/decorations/CHyprDropShadowDecoration.cpp
modified:   src/render/decorations/CHyprDropShadowDecoration.hpp
modified:   src/render/decorations/CHyprGroupBarDecoration.cpp
modified:   src/render/decorations/CHyprGroupBarDecoration.hpp
modified:   src/render/decorations/IHyprWindowDecoration.cpp
modified:   src/render/decorations/IHyprWindowDecoration.hpp

* fixes
modified:   hyprctl/main.cpp
modified:   src/render/decorations/IHyprWindowDecoration.cpp
This commit is contained in:
MightyPlaza 2023-12-28 15:38:16 +00:00 committed by GitHub
parent 6a93cee74e
commit 5f65946c84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 59 additions and 4 deletions

View file

@ -31,6 +31,7 @@ commands:
binds
clients
cursorpos
decorations
devices
dispatch
getoption
@ -423,6 +424,8 @@ int main(int argc, char** argv) {
request(fullRequest, 1);
else if (fullRequest.contains("/keyword"))
request(fullRequest, 2);
else if (fullRequest.contains("/decorations"))
request(fullRequest, 1);
else if (fullRequest.contains("/hyprpaper"))
requestHyprpaper(fullRequest);
else if (fullRequest.contains("/layouts"))

View file

@ -1174,6 +1174,32 @@ std::string dispatchGetOption(std::string request, HyprCtl::eHyprCtlOutputFormat
}
}
std::string decorationRequest(std::string request, HyprCtl::eHyprCtlOutputFormat format) {
CVarList vars(request, 0, ' ');
const auto PWINDOW = g_pCompositor->getWindowByRegex(vars[1]);
if (!PWINDOW)
return "none";
std::string result = "";
if (format == HyprCtl::FORMAT_JSON) {
result += "[";
for (auto& wd : PWINDOW->m_dWindowDecorations) {
result += "{\n\"decorationName\": \"" + wd->getDisplayName() + "\",\n\"priority\": " + std::to_string(wd->getPositioningInfo().priority) + "\n},";
}
trimTrailingComma(result);
result += "]";
} else {
result = +"Decoration\tPriority\n";
for (auto& wd : PWINDOW->m_dWindowDecorations) {
result += wd->getDisplayName() + "\t" + std::to_string(wd->getPositioningInfo().priority) + "\n";
}
}
return result;
}
void createOutputIter(wlr_backend* backend, void* data) {
const auto DATA = (std::pair<std::string, bool>*)data;
@ -1415,6 +1441,8 @@ std::string getReply(std::string request) {
return dispatchSetCursor(request);
else if (request.starts_with("getoption"))
return dispatchGetOption(request, format);
else if (request.starts_with("decorations"))
return decorationRequest(request, format);
else if (request.starts_with("[[BATCH]]"))
return dispatchBatch(request);

View file

@ -99,6 +99,10 @@ uint64_t CHyprBorderDecoration::getDecorationFlags() {
return *PPARTOFWINDOW && !doesntWantBorders() ? DECORATION_PART_OF_MAIN_WINDOW : 0;
}
std::string CHyprBorderDecoration::getDisplayName() {
return "Border";
}
bool CHyprBorderDecoration::doesntWantBorders() {
return !m_pWindow->m_sSpecialRenderData.border || m_pWindow->m_bX11DoesntWantBorders;
}
}

View file

@ -23,6 +23,8 @@ class CHyprBorderDecoration : public IHyprWindowDecoration {
virtual uint64_t getDecorationFlags();
virtual std::string getDisplayName();
private:
SWindowDecorationExtents m_seExtents;
SWindowDecorationExtents m_seReportedExtents;
@ -36,4 +38,4 @@ class CHyprBorderDecoration : public IHyprWindowDecoration {
CBox assignedBoxGlobal();
bool doesntWantBorders();
};
};

View file

@ -30,6 +30,10 @@ uint64_t CHyprDropShadowDecoration::getDecorationFlags() {
return DECORATION_NON_SOLID;
}
std::string CHyprDropShadowDecoration::getDisplayName() {
return "Drop Shadow";
}
void CHyprDropShadowDecoration::damageEntire() {
static auto* const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue;

View file

@ -23,6 +23,8 @@ class CHyprDropShadowDecoration : public IHyprWindowDecoration {
virtual uint64_t getDecorationFlags();
virtual std::string getDisplayName();
private:
SWindowDecorationExtents m_seExtents;
SWindowDecorationExtents m_seReportedExtents;
@ -34,4 +36,4 @@ class CHyprDropShadowDecoration : public IHyprWindowDecoration {
CBox m_bLastWindowBox = {0};
CBox m_bLastWindowBoxWithDecos = {0};
};
};

View file

@ -414,6 +414,10 @@ uint64_t CHyprGroupBarDecoration::getDecorationFlags() {
return DECORATION_ALLOWS_MOUSE_INPUT;
}
std::string CHyprGroupBarDecoration::getDisplayName() {
return "GroupBar";
}
CBox CHyprGroupBarDecoration::assignedBoxGlobal() {
CBox box = m_bAssignedBox;
box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_TOP, m_pWindow));

View file

@ -45,6 +45,8 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration {
virtual uint64_t getDecorationFlags();
virtual std::string getDisplayName();
private:
SWindowDecorationExtents m_seExtents;

View file

@ -26,4 +26,8 @@ eDecorationLayer IHyprWindowDecoration::getDecorationLayer() {
uint64_t IHyprWindowDecoration::getDecorationFlags() {
return 0;
}
}
std::string IHyprWindowDecoration::getDisplayName() {
return "Unknown Decoration";
}

View file

@ -56,6 +56,8 @@ class IHyprWindowDecoration {
virtual uint64_t getDecorationFlags();
virtual std::string getDisplayName();
private:
CWindow* m_pWindow = nullptr;