Exemplo n.º 1
0
json_object *ipc_json_describe_container(swayc_t *c) {
	if (!(sway_assert(c, "Container must not be null."))) {
		return NULL;
	}

	json_object *object = json_object_new_object();

	json_object_object_add(object, "id", json_object_new_int((int)c->id));
	json_object_object_add(object, "name", (c->name) ? json_object_new_string(c->name) : NULL);
	json_object_object_add(object, "rect", ipc_json_create_rect(c));
	json_object_object_add(object, "visible", json_object_new_boolean(c->visible));
	json_object_object_add(object, "focused", json_object_new_boolean(c == current_focus));

	switch (c->type) {
	case C_ROOT:
		json_object_object_add(object, "type", json_object_new_string("root"));
		break;

	case C_OUTPUT:
		ipc_json_describe_output(c, object);
		break;

	case C_CONTAINER: // fallthrough
	case C_VIEW:
		ipc_json_describe_view(c, object);
		break;

	case C_WORKSPACE:
		ipc_json_describe_workspace(c, object);
		break;

	case C_TYPES: // fallthrough; this should never happen, I'm just trying to silence compiler warnings
	default:
		break;
	}

	return object;
}
Exemplo n.º 2
0
void ipc_get_outputs_callback(swayc_t *container, void *data) {
	if (container->type == C_OUTPUT) {
		json_object_array_add((json_object *)data, ipc_json_describe_output(container));
	}
}