Skip to content

Commit

Permalink
#119 include label in space queries
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Oct 16, 2019
1 parent e5deb0a commit ca5cc4a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/space_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ void space_manager_untile_window(struct space_manager *sm, struct view *view, st
}
}

struct space_label *space_manager_get_label_for_space(struct space_manager *sm, uint64_t sid)
{
for (int i = 0; i < buf_len(sm->labels); ++i) {
struct space_label *space_label = &sm->labels[i];
if (space_label->sid == sid) {
return space_label;
}
}

return NULL;
}

struct space_label *space_manager_get_space_for_label(struct space_manager *sm, struct token label)
{
for (int i = 0; i < buf_len(sm->labels); ++i) {
Expand Down
1 change: 1 addition & 0 deletions src/space_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ uint64_t space_manager_next_space(uint64_t sid);
uint64_t space_manager_first_space(void);
uint64_t space_manager_last_space(void);
uint64_t space_manager_active_space(void);
struct space_label *space_manager_get_label_for_space(struct space_manager *sm, uint64_t sid);
struct space_label *space_manager_get_space_for_label(struct space_manager *sm, struct token label);
void space_manager_set_label_for_space(struct space_manager *sm, uint64_t sid, char *label);
void space_manager_set_layout_for_space(struct space_manager *sm, uint64_t sid, enum view_type type);
Expand Down
3 changes: 3 additions & 0 deletions src/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,14 @@ void view_serialize(FILE *rsp, struct view *view)
if (buffer_size <= 0) break;
}

struct space_label *space_label = space_manager_get_label_for_space(&g_space_manager, view->sid);
struct window_node *first_leaf = window_node_find_first_leaf(view->root);
struct window_node *last_leaf = window_node_find_last_leaf(view->root);

fprintf(rsp,
"{\n"
"\t\"id\":%lld,\n"
"\t\"label\":\"%s\",\n"
"\t\"index\":%d,\n"
"\t\"display\":%d,\n"
"\t\"windows\":[%s],\n"
Expand All @@ -492,6 +494,7 @@ void view_serialize(FILE *rsp, struct view *view)
"\t\"last-window\":%d\n"
"}",
view->sid,
space_label ? space_label->label : "",
space_manager_mission_control_index(view->sid),
display_arrangement(space_display_id(view->sid)),
buffer,
Expand Down

0 comments on commit ca5cc4a

Please sign in to comment.