94 lines
2.9 KiB
Diff
94 lines
2.9 KiB
Diff
From 217ce0880aec7899bf55d295c677a00d6dd69bf2 Mon Sep 17 00:00:00 2001
|
|
From: StableAgOH <stagoh17@gmail.com>
|
|
Date: Tue, 5 Sep 2023 13:45:54 +0800
|
|
Subject: [PATCH] Help scrcpy find the server and icon file
|
|
|
|
Scrcpy uses PREFIX+"/share/scrcpy/scrcpy-server" as the default server
|
|
path, and PREFIX is MINGW_PREFIX (determined at build time).
|
|
Before using the server file, scrcpy checks to see if the path to the
|
|
server file is legal. Since the default server path is an MSYS2 path and
|
|
not a Windows path, the path must not be legal, and scrcpy will not
|
|
be able to find the server file.
|
|
|
|
Scrcpy implements a function (sc_file_get_local_path) that
|
|
gets the program directory and allows you to concatenate a string
|
|
after the path. I used it to splice the program directory with the
|
|
relative path to the server file as the server path, which solved
|
|
the problem.
|
|
|
|
Same for icon file.
|
|
---
|
|
app/src/icon.c | 8 +++++---
|
|
app/src/server.c | 7 ++++---
|
|
2 files changed, 9 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/app/src/icon.c b/app/src/icon.c
|
|
index a8588dd8..1bcd3b74 100644
|
|
--- a/app/src/icon.c
|
|
+++ b/app/src/icon.c
|
|
@@ -14,14 +14,14 @@
|
|
|
|
#include "config.h"
|
|
#include "util/env.h"
|
|
-#ifdef PORTABLE
|
|
-# include "util/file.h"
|
|
-#endif
|
|
+#include "util/file.h"
|
|
#include "util/log.h"
|
|
|
|
#define SCRCPY_PORTABLE_ICON_FILENAME "icon.png"
|
|
#define SCRCPY_DEFAULT_ICON_PATH \
|
|
PREFIX "/share/icons/hicolor/256x256/apps/scrcpy.png"
|
|
+#define SCRCPY_DEFAULT_ICON_RELATIVE_PATH \
|
|
+ "../share/icons/hicolor/256x256/apps/scrcpy.png"
|
|
|
|
static char *
|
|
get_icon_path(void) {
|
|
@@ -33,12 +33,12 @@
|
|
}
|
|
|
|
#ifndef PORTABLE
|
|
- LOGD("Using icon: " SCRCPY_DEFAULT_ICON_PATH);
|
|
- icon_path = strdup(SCRCPY_DEFAULT_ICON_PATH);
|
|
+ icon_path = sc_file_get_local_path(SCRCPY_DEFAULT_ICON_RELATIVE_PATH);
|
|
if (!icon_path) {
|
|
- LOG_OOM();
|
|
+ LOGE("Could not get icon path");
|
|
return NULL;
|
|
}
|
|
+ LOGD("Using icon: %s", icon_path);
|
|
#else
|
|
icon_path = sc_file_get_local_path(SCRCPY_PORTABLE_ICON_FILENAME);
|
|
if (!icon_path) {
|
|
diff --git a/app/src/server.c b/app/src/server.c
|
|
index 4d787ea9..5a43890d 100644
|
|
--- a/app/src/server.c
|
|
+++ b/app/src/server.c
|
|
@@ -19,6 +19,7 @@
|
|
#define SC_SERVER_FILENAME "scrcpy-server"
|
|
|
|
#define SC_SERVER_PATH_DEFAULT PREFIX "/share/scrcpy/" SC_SERVER_FILENAME
|
|
+#define SC_SERVER_RELATIVE_PATH_DEFAULT "../share/scrcpy/" SC_SERVER_FILENAME
|
|
#define SC_DEVICE_SERVER_PATH "/data/local/tmp/scrcpy-server.jar"
|
|
|
|
#define SC_ADB_PORT_DEFAULT 5555
|
|
@@ -34,12 +35,12 @@
|
|
}
|
|
|
|
#ifndef PORTABLE
|
|
- LOGD("Using server: " SC_SERVER_PATH_DEFAULT);
|
|
- server_path = strdup(SC_SERVER_PATH_DEFAULT);
|
|
+ server_path = sc_file_get_local_path(SC_SERVER_RELATIVE_PATH_DEFAULT);
|
|
if (!server_path) {
|
|
- LOG_OOM();
|
|
+ LOGE("Could not get local file path");
|
|
return NULL;
|
|
}
|
|
+ LOGD("Using server: %s", server_path);
|
|
#else
|
|
server_path = sc_file_get_local_path(SC_SERVER_FILENAME);
|
|
if (!server_path) {
|
|
--
|
|
2.42.0.windows.1
|
|
|