mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 20:25:59 +01:00
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:
parent
6a93cee74e
commit
5f65946c84
10 changed files with 59 additions and 4 deletions
|
@ -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"))
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -45,6 +45,8 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration {
|
|||
|
||||
virtual uint64_t getDecorationFlags();
|
||||
|
||||
virtual std::string getDisplayName();
|
||||
|
||||
private:
|
||||
SWindowDecorationExtents m_seExtents;
|
||||
|
||||
|
|
|
@ -26,4 +26,8 @@ eDecorationLayer IHyprWindowDecoration::getDecorationLayer() {
|
|||
|
||||
uint64_t IHyprWindowDecoration::getDecorationFlags() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::string IHyprWindowDecoration::getDisplayName() {
|
||||
return "Unknown Decoration";
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ class IHyprWindowDecoration {
|
|||
|
||||
virtual uint64_t getDecorationFlags();
|
||||
|
||||
virtual std::string getDisplayName();
|
||||
|
||||
private:
|
||||
CWindow* m_pWindow = nullptr;
|
||||
|
||||
|
|
Loading…
Reference in a new issue