Handle NULL output make/model/serial

master
Simon Ser 3 years ago committed by Simon Zeni
parent f0d57da315
commit d0b9bf94a5

@ -27,8 +27,10 @@ int output_name_cmp(const void *item, const void *data) {
void output_get_identifier(char *identifier, size_t len, void output_get_identifier(char *identifier, size_t len,
struct sway_output *output) { struct sway_output *output) {
struct wlr_output *wlr_output = output->wlr_output; struct wlr_output *wlr_output = output->wlr_output;
snprintf(identifier, len, "%s %s %s", wlr_output->make, wlr_output->model, snprintf(identifier, len, "%s %s %s",
wlr_output->serial); wlr_output->make ? wlr_output->make : "Unknown",
wlr_output->model ? wlr_output->model : "Unknown",
wlr_output->serial ? wlr_output->serial : "Unknown");
} }
const char *sway_output_scale_filter_to_string(enum scale_filter_mode scale_filter) { const char *sway_output_scale_filter_to_string(enum scale_filter_mode scale_filter) {

@ -248,11 +248,11 @@ static void ipc_json_describe_output(struct sway_output *output,
json_object_object_add(object, "primary", json_object_new_boolean(false)); json_object_object_add(object, "primary", json_object_new_boolean(false));
json_object_object_add(object, "make", json_object_object_add(object, "make",
json_object_new_string(wlr_output->make)); json_object_new_string(wlr_output->make ? wlr_output->make : "Unknown"));
json_object_object_add(object, "model", json_object_object_add(object, "model",
json_object_new_string(wlr_output->model)); json_object_new_string(wlr_output->model ? wlr_output->model : "Unknown"));
json_object_object_add(object, "serial", json_object_object_add(object, "serial",
json_object_new_string(wlr_output->serial)); json_object_new_string(wlr_output->serial ? wlr_output->serial : "Unknown"));
json_object *modes_array = json_object_new_array(); json_object *modes_array = json_object_new_array();
struct wlr_output_mode *mode; struct wlr_output_mode *mode;

Loading…
Cancel
Save