mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 13:25:58 +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
|
binds
|
||||||
clients
|
clients
|
||||||
cursorpos
|
cursorpos
|
||||||
|
decorations
|
||||||
devices
|
devices
|
||||||
dispatch
|
dispatch
|
||||||
getoption
|
getoption
|
||||||
|
@ -423,6 +424,8 @@ int main(int argc, char** argv) {
|
||||||
request(fullRequest, 1);
|
request(fullRequest, 1);
|
||||||
else if (fullRequest.contains("/keyword"))
|
else if (fullRequest.contains("/keyword"))
|
||||||
request(fullRequest, 2);
|
request(fullRequest, 2);
|
||||||
|
else if (fullRequest.contains("/decorations"))
|
||||||
|
request(fullRequest, 1);
|
||||||
else if (fullRequest.contains("/hyprpaper"))
|
else if (fullRequest.contains("/hyprpaper"))
|
||||||
requestHyprpaper(fullRequest);
|
requestHyprpaper(fullRequest);
|
||||||
else if (fullRequest.contains("/layouts"))
|
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) {
|
void createOutputIter(wlr_backend* backend, void* data) {
|
||||||
const auto DATA = (std::pair<std::string, bool>*)data;
|
const auto DATA = (std::pair<std::string, bool>*)data;
|
||||||
|
|
||||||
|
@ -1415,6 +1441,8 @@ std::string getReply(std::string request) {
|
||||||
return dispatchSetCursor(request);
|
return dispatchSetCursor(request);
|
||||||
else if (request.starts_with("getoption"))
|
else if (request.starts_with("getoption"))
|
||||||
return dispatchGetOption(request, format);
|
return dispatchGetOption(request, format);
|
||||||
|
else if (request.starts_with("decorations"))
|
||||||
|
return decorationRequest(request, format);
|
||||||
else if (request.starts_with("[[BATCH]]"))
|
else if (request.starts_with("[[BATCH]]"))
|
||||||
return dispatchBatch(request);
|
return dispatchBatch(request);
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,10 @@ uint64_t CHyprBorderDecoration::getDecorationFlags() {
|
||||||
return *PPARTOFWINDOW && !doesntWantBorders() ? DECORATION_PART_OF_MAIN_WINDOW : 0;
|
return *PPARTOFWINDOW && !doesntWantBorders() ? DECORATION_PART_OF_MAIN_WINDOW : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CHyprBorderDecoration::getDisplayName() {
|
||||||
|
return "Border";
|
||||||
|
}
|
||||||
|
|
||||||
bool CHyprBorderDecoration::doesntWantBorders() {
|
bool CHyprBorderDecoration::doesntWantBorders() {
|
||||||
return !m_pWindow->m_sSpecialRenderData.border || m_pWindow->m_bX11DoesntWantBorders;
|
return !m_pWindow->m_sSpecialRenderData.border || m_pWindow->m_bX11DoesntWantBorders;
|
||||||
}
|
}
|
|
@ -23,6 +23,8 @@ class CHyprBorderDecoration : public IHyprWindowDecoration {
|
||||||
|
|
||||||
virtual uint64_t getDecorationFlags();
|
virtual uint64_t getDecorationFlags();
|
||||||
|
|
||||||
|
virtual std::string getDisplayName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SWindowDecorationExtents m_seExtents;
|
SWindowDecorationExtents m_seExtents;
|
||||||
SWindowDecorationExtents m_seReportedExtents;
|
SWindowDecorationExtents m_seReportedExtents;
|
||||||
|
|
|
@ -30,6 +30,10 @@ uint64_t CHyprDropShadowDecoration::getDecorationFlags() {
|
||||||
return DECORATION_NON_SOLID;
|
return DECORATION_NON_SOLID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CHyprDropShadowDecoration::getDisplayName() {
|
||||||
|
return "Drop Shadow";
|
||||||
|
}
|
||||||
|
|
||||||
void CHyprDropShadowDecoration::damageEntire() {
|
void CHyprDropShadowDecoration::damageEntire() {
|
||||||
static auto* const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue;
|
static auto* const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@ class CHyprDropShadowDecoration : public IHyprWindowDecoration {
|
||||||
|
|
||||||
virtual uint64_t getDecorationFlags();
|
virtual uint64_t getDecorationFlags();
|
||||||
|
|
||||||
|
virtual std::string getDisplayName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SWindowDecorationExtents m_seExtents;
|
SWindowDecorationExtents m_seExtents;
|
||||||
SWindowDecorationExtents m_seReportedExtents;
|
SWindowDecorationExtents m_seReportedExtents;
|
||||||
|
|
|
@ -414,6 +414,10 @@ uint64_t CHyprGroupBarDecoration::getDecorationFlags() {
|
||||||
return DECORATION_ALLOWS_MOUSE_INPUT;
|
return DECORATION_ALLOWS_MOUSE_INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CHyprGroupBarDecoration::getDisplayName() {
|
||||||
|
return "GroupBar";
|
||||||
|
}
|
||||||
|
|
||||||
CBox CHyprGroupBarDecoration::assignedBoxGlobal() {
|
CBox CHyprGroupBarDecoration::assignedBoxGlobal() {
|
||||||
CBox box = m_bAssignedBox;
|
CBox box = m_bAssignedBox;
|
||||||
box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_TOP, m_pWindow));
|
box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_TOP, m_pWindow));
|
||||||
|
|
|
@ -45,6 +45,8 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration {
|
||||||
|
|
||||||
virtual uint64_t getDecorationFlags();
|
virtual uint64_t getDecorationFlags();
|
||||||
|
|
||||||
|
virtual std::string getDisplayName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SWindowDecorationExtents m_seExtents;
|
SWindowDecorationExtents m_seExtents;
|
||||||
|
|
||||||
|
|
|
@ -27,3 +27,7 @@ eDecorationLayer IHyprWindowDecoration::getDecorationLayer() {
|
||||||
uint64_t IHyprWindowDecoration::getDecorationFlags() {
|
uint64_t IHyprWindowDecoration::getDecorationFlags() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string IHyprWindowDecoration::getDisplayName() {
|
||||||
|
return "Unknown Decoration";
|
||||||
|
}
|
||||||
|
|
|
@ -56,6 +56,8 @@ class IHyprWindowDecoration {
|
||||||
|
|
||||||
virtual uint64_t getDecorationFlags();
|
virtual uint64_t getDecorationFlags();
|
||||||
|
|
||||||
|
virtual std::string getDisplayName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CWindow* m_pWindow = nullptr;
|
CWindow* m_pWindow = nullptr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue