ipc: expose mode picture aspect ratio

master
Simon Ser 2 years ago
parent b0fc83485d
commit f70d1e1b95

@ -116,6 +116,39 @@ static const char *ipc_json_output_adaptive_sync_status_description(
return NULL;
}
static const char *ipc_json_output_mode_aspect_ratio_description(
enum wlr_output_mode_aspect_ratio aspect_ratio) {
switch (aspect_ratio) {
case WLR_OUTPUT_MODE_ASPECT_RATIO_NONE:
return "none";
case WLR_OUTPUT_MODE_ASPECT_RATIO_4_3:
return "4:3";
case WLR_OUTPUT_MODE_ASPECT_RATIO_16_9:
return "16:9";
case WLR_OUTPUT_MODE_ASPECT_RATIO_64_27:
return "64:27";
case WLR_OUTPUT_MODE_ASPECT_RATIO_256_135:
return "256:135";
}
return NULL;
}
static json_object *ipc_json_output_mode_description(
const struct wlr_output_mode *mode) {
const char *pic_ar =
ipc_json_output_mode_aspect_ratio_description(mode->picture_aspect_ratio);
json_object *mode_object = json_object_new_object();
json_object_object_add(mode_object, "width",
json_object_new_int(mode->width));
json_object_object_add(mode_object, "height",
json_object_new_int(mode->height));
json_object_object_add(mode_object, "refresh",
json_object_new_int(mode->refresh));
json_object_object_add(mode_object, "picture_aspect_ratio",
json_object_new_string(pic_ar));
return mode_object;
}
#if HAVE_XWAYLAND
static const char *ipc_json_xwindow_type_description(struct sway_view *view) {
struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface;
@ -308,25 +341,26 @@ static void ipc_json_describe_enabled_output(struct sway_output *output,
json_object *modes_array = json_object_new_array();
struct wlr_output_mode *mode;
wl_list_for_each(mode, &wlr_output->modes, link) {
json_object *mode_object = json_object_new_object();
json_object_object_add(mode_object, "width",
json_object_new_int(mode->width));
json_object_object_add(mode_object, "height",
json_object_new_int(mode->height));
json_object_object_add(mode_object, "refresh",
json_object_new_int(mode->refresh));
json_object *mode_object =
ipc_json_output_mode_description(mode);
json_object_array_add(modes_array, mode_object);
}
json_object_object_add(object, "modes", modes_array);
json_object *current_mode_object = json_object_new_object();
json_object *current_mode_object;
if (wlr_output->current_mode != NULL) {
current_mode_object =
ipc_json_output_mode_description(wlr_output->current_mode);
} else {
current_mode_object = json_object_new_object();
json_object_object_add(current_mode_object, "width",
json_object_new_int(wlr_output->width));
json_object_object_add(current_mode_object, "height",
json_object_new_int(wlr_output->height));
json_object_object_add(current_mode_object, "refresh",
json_object_new_int(wlr_output->refresh));
}
json_object_object_add(object, "current_mode", current_mode_object);
struct sway_node *parent = node_get_parent(&output->node);

Loading…
Cancel
Save