shared: Update all users of DATADIR

Replace every use of DATADIR to create a filename with a call to the new
function that allows overriding DATADIR with an env var at runtime.

No attention is paid to asprintf failure.

This restores make distcheck to a passing state after commit 6b58ea
began checking cairo surfaces for validity and exchanged undefined
behaviour we shouldn't have been dependent on for consistent test failure.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
[Pekka: split if-branches into two lines]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
Derek Foreman 2018-02-06 15:18:38 -06:00 committed by Pekka Paalanen
parent b7e3db6a76
commit e277276b85
4 changed files with 68 additions and 15 deletions

View File

@ -49,6 +49,7 @@
#include "shared/helpers.h" #include "shared/helpers.h"
#include "shared/xalloc.h" #include "shared/xalloc.h"
#include "shared/zalloc.h" #include "shared/zalloc.h"
#include "shared/file-util.h"
#include "weston-desktop-shell-client-protocol.h" #include "weston-desktop-shell-client-protocol.h"
@ -760,8 +761,12 @@ background_draw(struct widget *widget, void *data)
image = NULL; image = NULL;
if (background->image) if (background->image)
image = load_cairo_surface(background->image); image = load_cairo_surface(background->image);
else if (background->color == 0) else if (background->color == 0) {
image = load_cairo_surface(DATADIR "/weston/pattern.png"); char *name = file_name_with_datadir("pattern.png");
image = load_cairo_surface(name);
free(name);
}
if (image && background->type != -1) { if (image && background->type != -1) {
im_w = cairo_image_surface_get_width(image); im_w = cairo_image_surface_get_width(image);
@ -1351,10 +1356,13 @@ panel_add_launchers(struct panel *panel, struct desktop *desktop)
} }
if (count == 0) { if (count == 0) {
char *name = file_name_with_datadir("terminal.png");
/* add default launcher */ /* add default launcher */
panel_add_launcher(panel, panel_add_launcher(panel,
DATADIR "/weston/terminal.png", name,
BINDIR "/weston-terminal"); BINDIR "/weston-terminal");
free(name);
} }
} }

View File

@ -43,6 +43,7 @@
#include "shared/os-compatibility.h" #include "shared/os-compatibility.h"
#include "shared/xalloc.h" #include "shared/xalloc.h"
#include "shared/zalloc.h" #include "shared/zalloc.h"
#include "shared/file-util.h"
#include "ivi-application-client-protocol.h" #include "ivi-application-client-protocol.h"
#include "ivi-hmi-controller-client-protocol.h" #include "ivi-hmi-controller-client-protocol.h"
@ -1076,6 +1077,7 @@ hmi_homescreen_setting_create(void)
const char *name = NULL; const char *name = NULL;
uint32_t workspace_layer_id; uint32_t workspace_layer_id;
uint32_t icon_surface_id = 0; uint32_t icon_surface_id = 0;
char *filename;
wl_list_init(&setting->workspace_list); wl_list_init(&setting->workspace_list);
wl_list_init(&setting->launcher_list); wl_list_init(&setting->launcher_list);
@ -1095,51 +1097,65 @@ hmi_homescreen_setting_create(void)
weston_config_section_get_uint( weston_config_section_get_uint(
shellSection, "workspace-layer-id", &workspace_layer_id, 3000); shellSection, "workspace-layer-id", &workspace_layer_id, 3000);
filename = file_name_with_datadir("background.png");
weston_config_section_get_string( weston_config_section_get_string(
shellSection, "background-image", &setting->background.filePath, shellSection, "background-image", &setting->background.filePath,
DATADIR "/weston/background.png"); filename);
free(filename);
weston_config_section_get_uint( weston_config_section_get_uint(
shellSection, "background-id", &setting->background.id, 1001); shellSection, "background-id", &setting->background.id, 1001);
filename = file_name_with_datadir("panel.png");
weston_config_section_get_string( weston_config_section_get_string(
shellSection, "panel-image", &setting->panel.filePath, shellSection, "panel-image", &setting->panel.filePath,
DATADIR "/weston/panel.png"); filename);
free(filename);
weston_config_section_get_uint( weston_config_section_get_uint(
shellSection, "panel-id", &setting->panel.id, 1002); shellSection, "panel-id", &setting->panel.id, 1002);
filename = file_name_with_datadir("tiling.png");
weston_config_section_get_string( weston_config_section_get_string(
shellSection, "tiling-image", &setting->tiling.filePath, shellSection, "tiling-image", &setting->tiling.filePath,
DATADIR "/weston/tiling.png"); filename);
free(filename);
weston_config_section_get_uint( weston_config_section_get_uint(
shellSection, "tiling-id", &setting->tiling.id, 1003); shellSection, "tiling-id", &setting->tiling.id, 1003);
filename = file_name_with_datadir("sidebyside.png");
weston_config_section_get_string( weston_config_section_get_string(
shellSection, "sidebyside-image", &setting->sidebyside.filePath, shellSection, "sidebyside-image", &setting->sidebyside.filePath,
DATADIR "/weston/sidebyside.png"); filename);
free(filename);
weston_config_section_get_uint( weston_config_section_get_uint(
shellSection, "sidebyside-id", &setting->sidebyside.id, 1004); shellSection, "sidebyside-id", &setting->sidebyside.id, 1004);
filename = file_name_with_datadir("fullscreen.png");
weston_config_section_get_string( weston_config_section_get_string(
shellSection, "fullscreen-image", &setting->fullscreen.filePath, shellSection, "fullscreen-image", &setting->fullscreen.filePath,
DATADIR "/weston/fullscreen.png"); filename);
free(filename);
weston_config_section_get_uint( weston_config_section_get_uint(
shellSection, "fullscreen-id", &setting->fullscreen.id, 1005); shellSection, "fullscreen-id", &setting->fullscreen.id, 1005);
filename = file_name_with_datadir("random.png");
weston_config_section_get_string( weston_config_section_get_string(
shellSection, "random-image", &setting->random.filePath, shellSection, "random-image", &setting->random.filePath,
DATADIR "/weston/random.png"); filename);
free(filename);
weston_config_section_get_uint( weston_config_section_get_uint(
shellSection, "random-id", &setting->random.id, 1006); shellSection, "random-id", &setting->random.id, 1006);
filename = file_name_with_datadir("home.png");
weston_config_section_get_string( weston_config_section_get_string(
shellSection, "home-image", &setting->home.filePath, shellSection, "home-image", &setting->home.filePath,
DATADIR "/weston/home.png"); filename);
free(filename);
weston_config_section_get_uint( weston_config_section_get_uint(
shellSection, "home-id", &setting->home.id, 1007); shellSection, "home-id", &setting->home.id, 1007);

View File

@ -56,6 +56,7 @@
#include "shared/helpers.h" #include "shared/helpers.h"
#include "shared/image-loader.h" #include "shared/image-loader.h"
#include "shared/timespec-util.h" #include "shared/timespec-util.h"
#include "shared/file-util.h"
#include "gl-renderer.h" #include "gl-renderer.h"
#include "weston-egl-ext.h" #include "weston-egl-ext.h"
#include "pixman-renderer.h" #include "pixman-renderer.h"
@ -911,6 +912,7 @@ x11_output_enable(struct weston_output *base)
xcb_screen_t *screen; xcb_screen_t *screen;
struct wm_normal_hints normal_hints; struct wm_normal_hints normal_hints;
struct wl_event_loop *loop; struct wl_event_loop *loop;
char *icon_filename;
int ret; int ret;
uint32_t mask = XCB_CW_EVENT_MASK | XCB_CW_CURSOR; uint32_t mask = XCB_CW_EVENT_MASK | XCB_CW_CURSOR;
@ -991,7 +993,9 @@ x11_output_enable(struct weston_output *base)
b->atom.wm_class, b->atom.string, 8, b->atom.wm_class, b->atom.string, 8,
sizeof class, class); sizeof class, class);
x11_output_set_icon(b, output, DATADIR "/weston/wayland.png"); icon_filename = file_name_with_datadir("wayland.png");
x11_output_set_icon(b, output, icon_filename);
free(icon_filename);
x11_output_set_wm_protocols(b, output); x11_output_set_wm_protocols(b, output);

View File

@ -34,6 +34,7 @@
#include <linux/input.h> #include <linux/input.h>
#include "cairo-util.h" #include "cairo-util.h"
#include "shared/file-util.h"
enum frame_button_flags { enum frame_button_flags {
FRAME_BUTTON_ALIGN_RIGHT = 0x1, FRAME_BUTTON_ALIGN_RIGHT = 0x1,
@ -357,41 +358,65 @@ frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons,
FRAME_STATUS_MENU, FRAME_STATUS_MENU,
FRAME_BUTTON_CLICK_DOWN); FRAME_BUTTON_CLICK_DOWN);
} else { } else {
char *name = file_name_with_datadir("icon_window.png");
if (!name)
goto free_frame;
button = frame_button_create(frame, button = frame_button_create(frame,
DATADIR "/weston/icon_window.png", name,
FRAME_STATUS_MENU, FRAME_STATUS_MENU,
FRAME_BUTTON_CLICK_DOWN); FRAME_BUTTON_CLICK_DOWN);
free(name);
} }
if (!button) if (!button)
goto free_frame; goto free_frame;
} }
if (buttons & FRAME_BUTTON_CLOSE) { if (buttons & FRAME_BUTTON_CLOSE) {
char *name = file_name_with_datadir("sign_close.png");
if (!name)
goto free_frame;
button = frame_button_create(frame, button = frame_button_create(frame,
DATADIR "/weston/sign_close.png", name,
FRAME_STATUS_CLOSE, FRAME_STATUS_CLOSE,
FRAME_BUTTON_ALIGN_RIGHT | FRAME_BUTTON_ALIGN_RIGHT |
FRAME_BUTTON_DECORATED); FRAME_BUTTON_DECORATED);
free(name);
if (!button) if (!button)
goto free_frame; goto free_frame;
} }
if (buttons & FRAME_BUTTON_MAXIMIZE) { if (buttons & FRAME_BUTTON_MAXIMIZE) {
char *name = file_name_with_datadir("sign_maximize.png");
if (!name)
goto free_frame;
button = frame_button_create(frame, button = frame_button_create(frame,
DATADIR "/weston/sign_maximize.png", name,
FRAME_STATUS_MAXIMIZE, FRAME_STATUS_MAXIMIZE,
FRAME_BUTTON_ALIGN_RIGHT | FRAME_BUTTON_ALIGN_RIGHT |
FRAME_BUTTON_DECORATED); FRAME_BUTTON_DECORATED);
free(name);
if (!button) if (!button)
goto free_frame; goto free_frame;
} }
if (buttons & FRAME_BUTTON_MINIMIZE) { if (buttons & FRAME_BUTTON_MINIMIZE) {
char *name = file_name_with_datadir("sign_minimize.png");
if (!name)
goto free_frame;
button = frame_button_create(frame, button = frame_button_create(frame,
DATADIR "/weston/sign_minimize.png", name,
FRAME_STATUS_MINIMIZE, FRAME_STATUS_MINIMIZE,
FRAME_BUTTON_ALIGN_RIGHT | FRAME_BUTTON_ALIGN_RIGHT |
FRAME_BUTTON_DECORATED); FRAME_BUTTON_DECORATED);
free(name);
if (!button) if (!button)
goto free_frame; goto free_frame;
} }