Implement setting the WM_NAME of i3 container windows for debugging
This commit is contained in:
parent
e85bb09017
commit
945632ddcb
|
@ -65,4 +65,12 @@ void x_push_changes(Con *con);
|
||||||
*/
|
*/
|
||||||
void x_raise_con(Con *con);
|
void x_raise_con(Con *con);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the WM_NAME property (so, no UTF8, but used only for debugging anyways)
|
||||||
|
* of the given name. Used for properly tagging the windows for easily spotting
|
||||||
|
* i3 windows in xwininfo -root -all.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void x_set_name(Con *con, const char *name);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,7 +32,16 @@ void floating_enable(Con *con, bool automatic) {
|
||||||
/* 2: create a new container to render the decoration on, add
|
/* 2: create a new container to render the decoration on, add
|
||||||
* it as a floating window to the workspace */
|
* it as a floating window to the workspace */
|
||||||
Con *nc = con_new(NULL);
|
Con *nc = con_new(NULL);
|
||||||
|
/* we need to set the parent afterwards instead of passing it as an
|
||||||
|
* argument to con_new() because nc would be inserted into the tiling layer
|
||||||
|
* otherwise. */
|
||||||
nc->parent = con_get_workspace(con);
|
nc->parent = con_get_workspace(con);
|
||||||
|
|
||||||
|
char *name;
|
||||||
|
asprintf(&name, "[i3 con] floatingcon around %p", con);
|
||||||
|
x_set_name(nc, name);
|
||||||
|
free(name);
|
||||||
|
|
||||||
nc->rect = con->rect;
|
nc->rect = con->rect;
|
||||||
/* add pixels for the decoration */
|
/* add pixels for the decoration */
|
||||||
/* TODO: don’t add them when the user automatically puts new windows into
|
/* TODO: don’t add them when the user automatically puts new windows into
|
||||||
|
|
|
@ -185,6 +185,10 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
|
||||||
nc->window = cwindow;
|
nc->window = cwindow;
|
||||||
x_reinit(nc);
|
x_reinit(nc);
|
||||||
|
|
||||||
|
char *name;
|
||||||
|
asprintf(&name, "[i3 con] container around %p", cwindow);
|
||||||
|
x_set_name(nc, name);
|
||||||
|
free(name);
|
||||||
|
|
||||||
/* set floating if necessary */
|
/* set floating if necessary */
|
||||||
bool want_floating = false;
|
bool want_floating = false;
|
||||||
|
|
10
src/tree.c
10
src/tree.c
|
@ -70,11 +70,21 @@ void tree_init() {
|
||||||
oc->type = CT_OUTPUT;
|
oc->type = CT_OUTPUT;
|
||||||
oc->rect = output->rect;
|
oc->rect = output->rect;
|
||||||
|
|
||||||
|
char *name;
|
||||||
|
asprintf(&name, "[i3 con] output %s", oc->name);
|
||||||
|
x_set_name(oc, name);
|
||||||
|
free(name);
|
||||||
|
|
||||||
/* add a workspace to this output */
|
/* add a workspace to this output */
|
||||||
ws = con_new(oc);
|
ws = con_new(oc);
|
||||||
ws->type = CT_WORKSPACE;
|
ws->type = CT_WORKSPACE;
|
||||||
asprintf(&(ws->name), "%d", c);
|
asprintf(&(ws->name), "%d", c);
|
||||||
c++;
|
c++;
|
||||||
|
|
||||||
|
asprintf(&name, "[i3 con] workspace %s", ws->name);
|
||||||
|
x_set_name(ws, name);
|
||||||
|
free(name);
|
||||||
|
|
||||||
ws->fullscreen_mode = CF_OUTPUT;
|
ws->fullscreen_mode = CF_OUTPUT;
|
||||||
ws->orientation = HORIZ;
|
ws->orientation = HORIZ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,10 @@ Con *workspace_get(const char *num) {
|
||||||
output = con_get_output(focused);
|
output = con_get_output(focused);
|
||||||
LOG("got output %p\n", output);
|
LOG("got output %p\n", output);
|
||||||
workspace = con_new(output);
|
workspace = con_new(output);
|
||||||
|
char *name;
|
||||||
|
asprintf(&name, "[i3 con] workspace %s", num);
|
||||||
|
x_set_name(workspace, name);
|
||||||
|
free(name);
|
||||||
workspace->type = CT_WORKSPACE;
|
workspace->type = CT_WORKSPACE;
|
||||||
workspace->name = strdup(num);
|
workspace->name = strdup(num);
|
||||||
workspace->orientation = HORIZ;
|
workspace->orientation = HORIZ;
|
||||||
|
|
28
src/x.c
28
src/x.c
|
@ -30,6 +30,8 @@ typedef struct con_state {
|
||||||
|
|
||||||
bool initial;
|
bool initial;
|
||||||
|
|
||||||
|
char *name;
|
||||||
|
|
||||||
CIRCLEQ_ENTRY(con_state) state;
|
CIRCLEQ_ENTRY(con_state) state;
|
||||||
CIRCLEQ_ENTRY(con_state) old_state;
|
CIRCLEQ_ENTRY(con_state) old_state;
|
||||||
} con_state;
|
} con_state;
|
||||||
|
@ -374,6 +376,14 @@ static void x_push_node(Con *con) {
|
||||||
LOG("Pushing changes for node %p / %s\n", con, con->name);
|
LOG("Pushing changes for node %p / %s\n", con, con->name);
|
||||||
state = state_for_frame(con->frame);
|
state = state_for_frame(con->frame);
|
||||||
|
|
||||||
|
if (state->name != NULL) {
|
||||||
|
DLOG("pushing name %s\n", state->name);
|
||||||
|
|
||||||
|
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, con->frame,
|
||||||
|
WM_NAME, STRING, 8, strlen(state->name), state->name);
|
||||||
|
FREE(state->name);
|
||||||
|
}
|
||||||
|
|
||||||
/* reparent the child window (when the window was moved due to a sticky
|
/* reparent the child window (when the window was moved due to a sticky
|
||||||
* container) */
|
* container) */
|
||||||
if (state->need_reparent && con->window != NULL) {
|
if (state->need_reparent && con->window != NULL) {
|
||||||
|
@ -543,3 +553,21 @@ void x_raise_con(Con *con) {
|
||||||
CIRCLEQ_REMOVE(&state_head, state, state);
|
CIRCLEQ_REMOVE(&state_head, state, state);
|
||||||
CIRCLEQ_INSERT_HEAD(&state_head, state, state);
|
CIRCLEQ_INSERT_HEAD(&state_head, state, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets the WM_NAME property (so, no UTF8, but used only for debugging anyways)
|
||||||
|
* of the given name. Used for properly tagging the windows for easily spotting
|
||||||
|
* i3 windows in xwininfo -root -all.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void x_set_name(Con *con, const char *name) {
|
||||||
|
struct con_state *state;
|
||||||
|
|
||||||
|
if ((state = state_for_frame(con->frame)) == NULL) {
|
||||||
|
ELOG("window state not found\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FREE(state->name);
|
||||||
|
state->name = sstrdup(name);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue