summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hyprctl/main.cpp2
-rw-r--r--src/debug/HyprCtl.cpp19
2 files changed, 21 insertions, 0 deletions
diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp
index a216b1a0..bc0e8f01 100644
--- a/hyprctl/main.cpp
+++ b/hyprctl/main.cpp
@@ -36,6 +36,7 @@ commands:
reload
setcursor
getoption
+ cursorpos
flags:
-j -> output in JSON
@@ -278,6 +279,7 @@ int main(int argc, char** argv) {
else if (fullRequest.contains("/devices")) request(fullRequest);
else if (fullRequest.contains("/reload")) request(fullRequest);
else if (fullRequest.contains("/getoption")) request(fullRequest);
+ else if (fullRequest.contains("/cursorpos")) request(fullRequest);
else if (fullRequest.contains("/setcursor")) setcursorRequest(argc, argv);
else if (fullRequest.contains("/dispatch")) dispatchRequest(argc, argv);
else if (fullRequest.contains("/keyword")) keywordRequest(argc, argv);
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index bdfaad16..b43666fe 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -601,6 +601,23 @@ std::string splashRequest() {
return g_pCompositor->m_szCurrentSplash;
}
+std::string cursorPosRequest(HyprCtl::eHyprCtlOutputFormat format) {
+ const auto CURSORPOS = g_pInputManager->getMouseCoordsInternal().floor();
+
+ if (format == HyprCtl::FORMAT_NORMAL) {
+ return getFormat("%i, %i", (int)CURSORPOS.x, (int)CURSORPOS.y);
+ } else {
+ return getFormat(R"#(
+{
+ "x": %i,
+ "y": %i
+}
+)#", (int)CURSORPOS.x, (int)CURSORPOS.y);
+ }
+
+ return "error";
+}
+
std::string getReply(std::string);
std::string dispatchBatch(std::string request) {
@@ -767,6 +784,8 @@ std::string getReply(std::string request) {
return devicesRequest(format);
else if (request == "splash")
return splashRequest();
+ else if (request == "cursorpos")
+ return cursorPosRequest(format);
else if (request.find("dispatch") == 0)
return dispatchRequest(request);
else if (request.find("keyword") == 0)