Display and control your Android device
Add window icon
Romain Vimont52c89c7afb69
diff --git a/README.md b/README.mdindex bfd3f2e7..41b38538 100644--- a/README.md+++ b/README.md@@ -7,13 +7,13 @@ This project displays screens of Android devices plugged on USB in live.### Runtime requirements-This projects requires _FFmpeg_, _LibSDL2_ and _LibSDL2-net_.+This projects requires _FFmpeg_, _LibSDL2_, _LibSDL2-image_ and _LibSDL2-net_.#### LinuxInstall the packages from your package manager. For example, on Debian:- sudo apt install ffmpeg libsdl2-2.0.0 libsdl2-net-2.0.0+ sudo apt install ffmpeg libsdl2-2.0.0 libsdl2-image-2.0.0 libsdl2-net-2.0.0#### Windows@@ -21,6 +21,7 @@ Install the packages from your package manager. For example, on Debian:From [MSYS2]:pacman -S mingw-w64-x86_64-SDL2+ pacman -S mingw-w64-x86_64-SDL2_imagepacman -S mingw-w64-x86_64-SDL2_netpacman -S mingw-w64-x86_64-ffmpeg@@ -64,7 +65,7 @@ described below.sudo apt install make gcc openjdk-8-jdk pkg-config meson zip \libavcodec-dev libavformat-dev libavutil-dev \- libsdl2-dev libsdl2-net-dev+ libsdl2-dev libsdl2-image-dev libsdl2-net-dev#### Windowsdiff --git a/app/meson.build b/app/meson.buildindex 8913b7b6..698ff573 100644--- a/app/meson.build+++ b/app/meson.build@@ -26,6 +26,7 @@ dependencies = [dependency('libavcodec'),dependency('libavutil'),dependency('sdl2'),+ dependency('SDL2_image'),dependency('SDL2_net'),]diff --git a/app/src/icon.xpm b/app/src/icon.xpmnew file mode 100644index 00000000..73b29da9--- /dev/null+++ b/app/src/icon.xpm@@ -0,0 +1,53 @@+/* XPM */+static char * icon_xpm[] = {+"48 48 2 1",+" c None",+". c #96C13E",+" .. .. ",+" ... ... ",+" ... ...... ... ",+" ................ ",+" .............. ",+" ................ ",+" .................. ",+" .................... ",+" ..... ........ ..... ",+" ..... ........ ..... ",+" ...................... ",+" ........................ ",+" ........................ ",+" ........................ ",+" ",+" ",+" .... ........................ .... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" ...... ........................ ...... ",+" .... ........................ .... ",+" ........................ ",+" ...................... ",+" ...... ...... ",+" ...... ...... ",+" ...... ...... ",+" ...... ...... ",+" ...... ...... ",+" ...... ...... ",+" ...... ...... ",+" ...... ...... ",+" ...... ...... ",+" .... .... "};diff --git a/app/src/scrcpy.c b/app/src/scrcpy.cindex dc46ef40..0b6d1360 100644--- a/app/src/scrcpy.c+++ b/app/src/scrcpy.c@@ -6,6 +6,7 @@#include <libavformat/avformat.h>#include <sys/time.h>#include <SDL2/SDL.h>+#include <SDL2/SDL_image.h>#include <SDL2/SDL_net.h>#include "command.h"@@ -19,6 +20,8 @@#include "netutil.h"#include "server.h"+#include "icon.xpm"+#define DEVICE_NAME_FIELD_LENGTH 64#define DISPLAY_MARGINS 96@@ -647,6 +650,15 @@ SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 max_size, Uint32 bgoto screen_finally_destroy_renderer;}+ SDL_Surface *icon = IMG_ReadXPMFromArray(icon_xpm);+ if (!icon) {+ SDL_LogError(SDL_LOG_CATEGORY_SYSTEM, "Could not load icon: %s", SDL_GetError());+ ret = SDL_FALSE;+ goto screen_finally_destroy_renderer;+ }+ SDL_SetWindowIcon(window, icon);+ SDL_FreeSurface(icon);+SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Initial texture: %" PRIu16 "x%" PRIu16, frame_size.width, frame_size.height);texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING, frame_size.width, frame_size.height);if (!texture) {