swaymsg: display render bit depth instead of format

This commit is contained in:
Ian Hattendorf 2023-08-21 13:07:14 -07:00
parent 1929112b23
commit ee75c1ec1c
No known key found for this signature in database
GPG key ID: BE8B1B445E06437D
5 changed files with 25 additions and 5 deletions

View file

@ -199,4 +199,6 @@ struct sway_output_non_desktop *output_non_desktop_create(struct wlr_output *wlr
const char *sway_render_format_to_string(uint32_t render_format); const char *sway_render_format_to_string(uint32_t render_format);
int sway_render_format_to_bit_depth(uint32_t render_format);
#endif #endif

View file

@ -377,6 +377,18 @@ static const uint32_t *bit_depth_preferences[] = {
}, },
}; };
int sway_render_format_to_bit_depth(uint32_t render_format) {
switch (render_format) {
case DRM_FORMAT_XRGB2101010:
case DRM_FORMAT_XBGR2101010:
return 10;
case DRM_FORMAT_XRGB8888:
return 8;
default:
return -1;
}
}
const char *sway_render_format_to_string(uint32_t render_format) { const char *sway_render_format_to_string(uint32_t render_format) {
switch (render_format) { switch (render_format) {
case DRM_FORMAT_XRGB2101010: case DRM_FORMAT_XRGB2101010:
@ -389,7 +401,7 @@ const char *sway_render_format_to_string(uint32_t render_format) {
return "INVALID"; return "INVALID";
default: default:
return "UNKNOWN"; return "UNKNOWN";
} }
} }
static void queue_output_config(struct output_config *oc, static void queue_output_config(struct output_config *oc,

View file

@ -693,6 +693,9 @@ void ipc_client_handle_command(struct ipc_client *client, uint32_t payload_lengt
const char *render_format = sway_render_format_to_string(output->wlr_output->render_format); const char *render_format = sway_render_format_to_string(output->wlr_output->render_format);
json_object_object_add(output_json, "render_format", json_object_new_string(render_format)); json_object_object_add(output_json, "render_format", json_object_new_string(render_format));
const int bit_depth = sway_render_format_to_bit_depth(output->wlr_output->render_format);
json_object_object_add(output_json, "render_bit_depth", json_object_new_int(bit_depth));
json_object_array_add(outputs, output_json); json_object_array_add(outputs, output_json);
} }
struct sway_output *output; struct sway_output *output;

View file

@ -226,6 +226,9 @@ following properties:
|- subpixel_hinting |- subpixel_hinting
: string : string
: The subpixel hinting currently in use on the output. This can be _rgb_, _bgr_, _vrgb_, _vbgr_, or _none_ : The subpixel hinting currently in use on the output. This can be _rgb_, _bgr_, _vrgb_, _vbgr_, or _none_
|- render_bit_depth
: integer
: The render bit depth currently in use on the output.
|- render_format |- render_format
: string : string
: The render format currently in use on the output. : The render format currently in use on the output.

View file

@ -194,14 +194,14 @@ static void pretty_print_output(json_object *o) {
json_object_object_get_ex(o, "current_workspace", &ws); json_object_object_get_ex(o, "current_workspace", &ws);
json_object_object_get_ex(o, "non_desktop", &non_desktop); json_object_object_get_ex(o, "non_desktop", &non_desktop);
json_object *make, *model, *serial, *scale, *scale_filter, *subpixel, json_object *make, *model, *serial, *scale, *scale_filter, *subpixel,
*render_format, *transform, *max_render_time, *adaptive_sync_status; *bit_depth, *transform, *max_render_time, *adaptive_sync_status;
json_object_object_get_ex(o, "make", &make); json_object_object_get_ex(o, "make", &make);
json_object_object_get_ex(o, "model", &model); json_object_object_get_ex(o, "model", &model);
json_object_object_get_ex(o, "serial", &serial); json_object_object_get_ex(o, "serial", &serial);
json_object_object_get_ex(o, "scale", &scale); json_object_object_get_ex(o, "scale", &scale);
json_object_object_get_ex(o, "scale_filter", &scale_filter); json_object_object_get_ex(o, "scale_filter", &scale_filter);
json_object_object_get_ex(o, "subpixel_hinting", &subpixel); json_object_object_get_ex(o, "subpixel_hinting", &subpixel);
json_object_object_get_ex(o, "render_format", &render_format); json_object_object_get_ex(o, "render_bit_depth", &bit_depth);
json_object_object_get_ex(o, "transform", &transform); json_object_object_get_ex(o, "transform", &transform);
json_object_object_get_ex(o, "max_render_time", &max_render_time); json_object_object_get_ex(o, "max_render_time", &max_render_time);
json_object_object_get_ex(o, "adaptive_sync_status", &adaptive_sync_status); json_object_object_get_ex(o, "adaptive_sync_status", &adaptive_sync_status);
@ -233,7 +233,7 @@ static void pretty_print_output(json_object *o) {
" Scale factor: %f\n" " Scale factor: %f\n"
" Scale filter: %s\n" " Scale filter: %s\n"
" Subpixel hinting: %s\n" " Subpixel hinting: %s\n"
" Render format: %s\n" " Render bit depth: %d\n"
" Transform: %s\n" " Transform: %s\n"
" Workspace: %s\n", " Workspace: %s\n",
json_object_get_string(name), json_object_get_string(name),
@ -249,7 +249,7 @@ static void pretty_print_output(json_object *o) {
json_object_get_double(scale), json_object_get_double(scale),
json_object_get_string(scale_filter), json_object_get_string(scale_filter),
json_object_get_string(subpixel), json_object_get_string(subpixel),
json_object_get_string(render_format), json_object_get_int(bit_depth),
json_object_get_string(transform), json_object_get_string(transform),
json_object_get_string(ws) json_object_get_string(ws)
); );