mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-06-22 13:36:03 -04:00
feat(ipc): add 'get cursorpos' to mmsg
This commit is contained in:
parent
8e356692f6
commit
447bc67691
4 changed files with 17 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ description: Control mangowm programmatically using mmsg.
|
|||
| Command | Description |
|
||||
| :--- | :--- |
|
||||
| `get version` | Returns the current version of the compositor. |
|
||||
| `get cursorpos` | Returns the global pointer position (`x`, `y`) and the monitor under it. |
|
||||
| `get keymode` | Returns the current active keyboard mode (e.g., normal, insert). |
|
||||
| `get keyboardlayout` | Returns the active XKB layout (abbreviated). |
|
||||
| `get monitor <name>` | Returns full JSON details for a specific monitor. |
|
||||
|
|
@ -41,6 +42,7 @@ description: Control mangowm programmatically using mmsg.
|
|||
mmsg get monitor eDP-1
|
||||
mmsg get all-clients
|
||||
mmsg get all-monitors
|
||||
mmsg get cursorpos
|
||||
```
|
||||
|
||||
### WATCH (Event Subscription)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@ All \fBget\fR commands print a single JSON object and then close the connection.
|
|||
\fBget version\fR
|
||||
Return compositor version.
|
||||
.TP
|
||||
\fBget cursorpos\fR
|
||||
Return the global pointer position (\fBx\fR, \fBy\fR) and the monitor under it
|
||||
(\fBnull\fR if over no output).
|
||||
.TP
|
||||
\fBget keymode\fR
|
||||
Return current keymode.
|
||||
.TP
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ static void usage(void) {
|
|||
printf("One-shot queries (get):\n");
|
||||
printf(
|
||||
" get version Show compositor version\n");
|
||||
printf(" get cursorpos Show pointer position + "
|
||||
"monitor\n");
|
||||
printf(" get keymode Show current keymode\n");
|
||||
printf(" get keyboardlayout Show current keyboard "
|
||||
"layout\n");
|
||||
|
|
|
|||
|
|
@ -237,6 +237,15 @@ static void handle_command(int client_fd, const char *cmd_raw) {
|
|||
if (strcmp(cmd, "get version") == 0) {
|
||||
resp = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(resp, "version", VERSION);
|
||||
} else if (strcmp(cmd, "get cursorpos") == 0) {
|
||||
resp = cJSON_CreateObject();
|
||||
cJSON_AddNumberToObject(resp, "x", cursor->x);
|
||||
cJSON_AddNumberToObject(resp, "y", cursor->y);
|
||||
Monitor *m = xytomon(cursor->x, cursor->y);
|
||||
if (m)
|
||||
cJSON_AddStringToObject(resp, "monitor", m->wlr_output->name);
|
||||
else
|
||||
cJSON_AddNullToObject(resp, "monitor");
|
||||
} else if (strcmp(cmd, "get keymode") == 0) {
|
||||
resp = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(resp, "keymode", keymode.mode);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue