From 52c89c7afb69f9279bf73173df756b5159eb5bfc Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Mon, 5 Feb 2018 12:12:08 +0100 Subject: [PATCH] Add window icon Add a bugdroid icon loaded from an XPM. --- README.md | 7 ++++--- app/meson.build | 1 + app/src/icon.xpm | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ app/src/scrcpy.c | 12 +++++++++++ 4 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 app/src/icon.xpm diff --git a/README.md b/README.md index 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_. #### Linux Install 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_image pacman -S mingw-w64-x86_64-SDL2_net pacman -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 #### Windows diff --git a/app/meson.build b/app/meson.build index 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.xpm new file mode 100644 index 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.c index dc46ef40..0b6d1360 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #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 b goto 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) {