c->polkit_registry = bus_verify_polkit_async_registry_free(c->polkit_registry);
};
-static X11Context *context_get_x11_context(Context *c) {
+X11Context *context_get_x11_context(Context *c) {
assert(c);
if (!x11_context_isempty(&c->x11_from_vc))
if (!x11_context_isempty(&c->x11_from_xorg))
return &c->x11_from_xorg;
- return NULL;
-}
-
-X11Context *context_get_x11_context_safe(Context *c) {
- assert(c);
- return context_get_x11_context(c) ?: &c->x11_from_vc;
+ return &c->x11_from_vc;
}
int locale_read_data(Context *c, sd_bus_message *m) {
if (r < 0)
return r;
- r = strv_env_assign(&l, "XKBLAYOUT", xc ? empty_to_null(xc->layout) : NULL);
+ r = strv_env_assign(&l, "XKBLAYOUT", empty_to_null(xc->layout));
if (r < 0)
return r;
- r = strv_env_assign(&l, "XKBMODEL", xc ? empty_to_null(xc->model) : NULL);
+ r = strv_env_assign(&l, "XKBMODEL", empty_to_null(xc->model));
if (r < 0)
return r;
- r = strv_env_assign(&l, "XKBVARIANT", xc ? empty_to_null(xc->variant) : NULL);
+ r = strv_env_assign(&l, "XKBVARIANT", empty_to_null(xc->variant));
if (r < 0)
return r;
- r = strv_env_assign(&l, "XKBOPTIONS", xc ? empty_to_null(xc->options) : NULL);
+ r = strv_env_assign(&l, "XKBOPTIONS", empty_to_null(xc->options));
if (r < 0)
return r;
assert(c);
xc = context_get_x11_context(c);
- if (!xc) {
+ if (x11_context_isempty(xc)) {
if (unlink("/etc/X11/xorg.conf.d/00-keyboard.conf") < 0)
return errno == ENOENT ? 0 : -errno;
bool x11_context_equal(const X11Context *a, const X11Context *b);
int x11_context_copy(X11Context *dest, const X11Context *src);
-X11Context *context_get_x11_context_safe(Context *c);
+X11Context *context_get_x11_context(Context *c);
void vc_context_clear(VCContext *vc);
void vc_context_replace(VCContext *dest, VCContext *src);
if (r < 0)
return r;
- xc = context_get_x11_context_safe(c);
+ xc = context_get_x11_context(c);
if (streq(property, "X11Layout"))
return sd_bus_message_append_basic(reply, 's', xc->layout);
}
/* save the result of conversion to emit changed properties later. */
- xc = context_get_x11_context_safe(c);
+ xc = context_get_x11_context(c);
convert = !x11_context_equal(xc, &converted);
x11_context_replace(xc, &converted);
}
return sd_bus_error_set(error, SD_BUS_ERROR_FAILED, "Failed to read x11 keyboard layout data");
}
- xc = context_get_x11_context_safe(c);
+ xc = context_get_x11_context(c);
if (x11_context_equal(xc, &in))
return sd_bus_reply_method_return(m, NULL);