Merge pull request #2069 from RyanDwyer/ipc-workspace-representation

Add tree representation to IPC workspace description
This commit is contained in:
Drew DeVault 2018-05-29 10:54:22 -04:00 committed by GitHub
commit 86b8d036d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 7 deletions

View File

@ -147,6 +147,8 @@ static void ipc_json_describe_workspace(struct sway_container *workspace,
json_object_new_string(workspace->parent->name) : NULL); json_object_new_string(workspace->parent->name) : NULL);
json_object_object_add(object, "type", json_object_new_string("workspace")); json_object_object_add(object, "type", json_object_new_string("workspace"));
json_object_object_add(object, "urgent", json_object_new_boolean(false)); json_object_object_add(object, "urgent", json_object_new_boolean(false));
json_object_object_add(object, "representation", workspace->formatted_title ?
json_object_new_string(workspace->formatted_title) : NULL);
const char *layout = ipc_json_layout_description(workspace->layout); const char *layout = ipc_json_layout_description(workspace->layout);
json_object_object_add(object, "layout", json_object_new_string(layout)); json_object_object_add(object, "layout", json_object_new_string(layout));

View File

@ -842,7 +842,7 @@ static size_t get_tree_representation(struct sway_container *parent, char *buffe
} }
void container_notify_subtree_changed(struct sway_container *container) { void container_notify_subtree_changed(struct sway_container *container) {
if (!container || container->type != C_CONTAINER) { if (!container || container->type < C_WORKSPACE) {
return; return;
} }
free(container->formatted_title); free(container->formatted_title);
@ -856,9 +856,11 @@ void container_notify_subtree_changed(struct sway_container *container) {
get_tree_representation(container, buffer); get_tree_representation(container, buffer);
container->formatted_title = buffer; container->formatted_title = buffer;
container_calculate_title_height(container); if (container->type != C_WORKSPACE) {
container_update_title_textures(container); container_calculate_title_height(container);
container_notify_subtree_changed(container->parent); container_update_title_textures(container);
container_notify_subtree_changed(container->parent);
}
} }
size_t container_titlebar_height() { size_t container_titlebar_height() {

View File

@ -53,24 +53,28 @@ static void pretty_print_cmd(json_object *r) {
} }
static void pretty_print_workspace(json_object *w) { static void pretty_print_workspace(json_object *w) {
json_object *name, *rect, *visible, *output, *urgent, *layout, *focused; json_object *name, *rect, *visible, *output, *urgent, *layout,
*representation, *focused;
json_object_object_get_ex(w, "name", &name); json_object_object_get_ex(w, "name", &name);
json_object_object_get_ex(w, "rect", &rect); json_object_object_get_ex(w, "rect", &rect);
json_object_object_get_ex(w, "visible", &visible); json_object_object_get_ex(w, "visible", &visible);
json_object_object_get_ex(w, "output", &output); json_object_object_get_ex(w, "output", &output);
json_object_object_get_ex(w, "urgent", &urgent); json_object_object_get_ex(w, "urgent", &urgent);
json_object_object_get_ex(w, "layout", &layout); json_object_object_get_ex(w, "layout", &layout);
json_object_object_get_ex(w, "representation", &representation);
json_object_object_get_ex(w, "focused", &focused); json_object_object_get_ex(w, "focused", &focused);
printf( printf(
"Workspace %s%s%s%s\n" "Workspace %s%s%s%s\n"
" Output: %s\n" " Output: %s\n"
" Layout: %s\n\n", " Layout: %s\n"
" Representation: %s\n\n",
json_object_get_string(name), json_object_get_string(name),
json_object_get_boolean(focused) ? " (focused)" : "", json_object_get_boolean(focused) ? " (focused)" : "",
!json_object_get_boolean(visible) ? " (off-screen)" : "", !json_object_get_boolean(visible) ? " (off-screen)" : "",
json_object_get_boolean(urgent) ? " (urgent)" : "", json_object_get_boolean(urgent) ? " (urgent)" : "",
json_object_get_string(output), json_object_get_string(output),
json_object_get_string(layout) json_object_get_string(layout),
json_object_get_string(representation)
); );
} }