Skip to content

Commit

Permalink
Merge pull request #160 from kalekundert/master
Browse files Browse the repository at this point in the history
Expose monitor dimensions via BERRY_WINDOW_STATUS
  • Loading branch information
JLErvin authored Feb 4, 2022
2 parents 2212ff2 + 21b095f commit 8a8857a
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions wm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2172,6 +2172,7 @@ client_set_status(struct client *c)
if (c == NULL)
return;
int size = 0;
int mon = 0;
char *str = NULL;
char *state, *decorated;

Expand All @@ -2193,18 +2194,29 @@ client_set_status(struct client *c)


if (conf.json_status) {
mon = ws_m_list[c->ws];
size = asprintf(&str,
"{"
"\"window\":\"0x%08x\","
"\"geom\":{"
"\"x\":%d,"
"\"y\":%d,"
"\"width\":%d,"
"\"height\":%d"
"},"
"\"state\":\"%s\","
"\"decorated\":\"%s\""
"}", (unsigned int)c->window, c->geom.x, c->geom.y, c->geom.width, c->geom.height, state, decorated);
"{"
"\"window\":\"0x%08x\","
"\"geom\":{"
"\"x\":%d,"
"\"y\":%d,"
"\"width\":%d,"
"\"height\":%d"
"},"
"\"monitor\":{"
"\"id\": %d,"
"\"x\":%d,"
"\"y\":%d,"
"\"width\":%d,"
"\"height\":%d"
"},"
"\"state\":\"%s\","
"\"decorated\":\"%s\""
"}",
(unsigned int)c->window, c->geom.x, c->geom.y, c->geom.width, c->geom.height,
mon, m_list[mon].x, m_list[mon].y, m_list[mon].width, m_list[mon].height,
state, decorated);
} else {
size = asprintf(&str,
"0x%08x, " // window id
Expand All @@ -2213,8 +2225,14 @@ client_set_status(struct client *c)
"%d, " // width
"%d, " // height
"%s, " // state
"%s", // decorated
(unsigned int)c->window, c->geom.x, c->geom.y, c->geom.width, c->geom.height, state, decorated);
"%s, " // decorated
"%d, " // monitor id
"%d, " // monitor x
"%d, " // monitor y
"%d, " // monitor width
"%d", // monitor height
(unsigned int)c->window, c->geom.x, c->geom.y, c->geom.width, c->geom.height, state, decorated,
mon, m_list[mon].x, m_list[mon].y, m_list[mon].width, m_list[mon].height);
}

if (size == -1) {
Expand Down

0 comments on commit 8a8857a

Please sign in to comment.