mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 21:05:58 +01:00
backend/x11 & backend/wayland: make set_title NULL-safe
Set the default "wlroots - " title when the title argument to the set_title functions is NULL. Otherwise, for at least the Wayland backend, we'd crash because xdg_toplevel_set_title doesn't handle a NULL pointer.
This commit is contained in:
parent
4cb0697e57
commit
85d84a1a04
2 changed files with 19 additions and 8 deletions
|
@ -314,10 +314,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *wlr_backend) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
char title[32];
|
wlr_wl_output_set_title(wlr_output, NULL);
|
||||||
if (snprintf(title, sizeof(title), "wlroots - %s", wlr_output->name)) {
|
|
||||||
xdg_toplevel_set_title(output->xdg_toplevel, title);
|
|
||||||
}
|
|
||||||
|
|
||||||
xdg_toplevel_set_app_id(output->xdg_toplevel, "wlroots");
|
xdg_toplevel_set_app_id(output->xdg_toplevel, "wlroots");
|
||||||
xdg_surface_add_listener(output->xdg_surface,
|
xdg_surface_add_listener(output->xdg_surface,
|
||||||
|
@ -369,5 +366,14 @@ error:
|
||||||
|
|
||||||
void wlr_wl_output_set_title(struct wlr_output *output, const char *title) {
|
void wlr_wl_output_set_title(struct wlr_output *output, const char *title) {
|
||||||
struct wlr_wl_output *wl_output = get_wl_output_from_output(output);
|
struct wlr_wl_output *wl_output = get_wl_output_from_output(output);
|
||||||
|
|
||||||
|
char wl_title[32];
|
||||||
|
if (title == NULL) {
|
||||||
|
if (snprintf(wl_title, sizeof(wl_title), "wlroots - %s", output->name) <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
title = wl_title;
|
||||||
|
}
|
||||||
|
|
||||||
xdg_toplevel_set_title(wl_output->xdg_toplevel, title);
|
xdg_toplevel_set_title(wl_output->xdg_toplevel, title);
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,10 +185,7 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
|
||||||
x11->atoms.wm_protocols, XCB_ATOM_ATOM, 32, 1,
|
x11->atoms.wm_protocols, XCB_ATOM_ATOM, 32, 1,
|
||||||
&x11->atoms.wm_delete_window);
|
&x11->atoms.wm_delete_window);
|
||||||
|
|
||||||
char title[32];
|
wlr_x11_output_set_title(wlr_output, NULL);
|
||||||
if (snprintf(title, sizeof(title), "wlroots - %s", wlr_output->name)) {
|
|
||||||
wlr_x11_output_set_title(wlr_output, title);
|
|
||||||
}
|
|
||||||
|
|
||||||
xcb_map_window(x11->xcb, output->win);
|
xcb_map_window(x11->xcb, output->win);
|
||||||
xcb_flush(x11->xcb);
|
xcb_flush(x11->xcb);
|
||||||
|
@ -236,6 +233,14 @@ bool wlr_output_is_x11(struct wlr_output *wlr_output) {
|
||||||
void wlr_x11_output_set_title(struct wlr_output *output, const char *title) {
|
void wlr_x11_output_set_title(struct wlr_output *output, const char *title) {
|
||||||
struct wlr_x11_output *x11_output = get_x11_output_from_output(output);
|
struct wlr_x11_output *x11_output = get_x11_output_from_output(output);
|
||||||
|
|
||||||
|
char wl_title[32];
|
||||||
|
if (title == NULL) {
|
||||||
|
if (snprintf(wl_title, sizeof(wl_title), "wlroots - %s", output->name) <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
title = wl_title;
|
||||||
|
}
|
||||||
|
|
||||||
xcb_change_property(x11_output->x11->xcb, XCB_PROP_MODE_REPLACE, x11_output->win,
|
xcb_change_property(x11_output->x11->xcb, XCB_PROP_MODE_REPLACE, x11_output->win,
|
||||||
x11_output->x11->atoms.net_wm_name, x11_output->x11->atoms.utf8_string, 8,
|
x11_output->x11->atoms.net_wm_name, x11_output->x11->atoms.utf8_string, 8,
|
||||||
strlen(title), title);
|
strlen(title), title);
|
||||||
|
|
Loading…
Reference in a new issue