# HG changeset patch # User Paper # Date 1698945255 14400 # Node ID 18979b066284426133ea72f62c08b093c658fd9c # Parent bd68e4393e6f74c43f4d36e2c6b975cc846de4bc animia/unix: fix a bunch of stuff that breaks OS X things diff -r bd68e4393e6f -r 18979b066284 dep/animia/include/bsd.h --- a/dep/animia/include/bsd.h Wed Nov 01 15:16:49 2023 -0400 +++ b/dep/animia/include/bsd.h Thu Nov 02 13:14:15 2023 -0400 @@ -7,8 +7,9 @@ namespace Animia { namespace Unix { std::vector get_all_pids(); -std::string get_process_name(int pid); -std::vector get_open_files(int pid); +std::string get_process_name(const int pid); +std::vector get_open_files(const int pid); +std::vector filter_system_files(const std::vector& in); std::unordered_map> get_all_open_files(); } // namespace Unix diff -r bd68e4393e6f -r 18979b066284 dep/animia/include/os.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dep/animia/include/os.h Thu Nov 02 13:14:15 2023 -0400 @@ -0,0 +1,16 @@ +/* can this be moved to cmake? */ +#ifndef __animia__os_h +#define __animia__os_h + +#ifdef __linux__ +# define ON_LINUX +#elif (defined(unix) || defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) +# if (defined(__APPLE__) && defined(__MACH__)) +# define ON_OSX +# endif +# define ON_UNIX +#elif defined(_WIN32) +# define ON_WINDOWS +#endif + +#endif // __animia__os_h \ No newline at end of file diff -r bd68e4393e6f -r 18979b066284 dep/animia/src/bsd.cpp --- a/dep/animia/src/bsd.cpp Wed Nov 01 15:16:49 2023 -0400 +++ b/dep/animia/src/bsd.cpp Thu Nov 02 13:14:15 2023 -0400 @@ -6,6 +6,8 @@ * around the very C-like BSD system functions that are... * kind of unnatural to use in modern C++. **/ +#include "bsd.h" +#include "os.h" #include #include #include @@ -56,7 +58,7 @@ return ret; } -std::string get_process_name(int pid) { +std::string get_process_name(const int pid) { std::string ret; #ifdef __FreeBSD__ struct kinfo_proc* proc = kinfo_getproc(pid); @@ -75,7 +77,7 @@ return ret; } -std::vector get_open_files(int pid) { +std::vector get_open_files(const int pid) { /* note: this is OS X only right now. eventually, I'll find a way to do this in FreeBSD, OpenBSD and the like */ std::vector ret; @@ -103,7 +105,9 @@ if (sz != PROC_PIDFDVNODEPATHINFO_SIZE) continue; - if (vnodeInfo.pfi.fi_openflags & O_WRONLY || vnodeInfo.pfi.fi_openflags & O_RDWR) + /* I *think* this is correct. For some reason, with VLC on macOS this thinks files are read/write, + which is totally unnecessary and even harmful. */ + if ((vnodeInfo.pfi.fi_status & O_ACCMODE) == O_WRONLY) continue; ret.push_back(vnodeInfo.pvip.vip_path); @@ -112,6 +116,21 @@ return ret; } +std::vector filter_system_files(const std::vector& in) { +#ifdef ON_OSX + std::vector ret; + for (const auto& str : in) + /* these are some places nobody would ever want to store media files. */ + if (str.find("/Library") && str.find("/System") && str.find("/Applications") && + str.find("/dev") && str.find("/private")) + ret.push_back(str); + return ret; +#else + return in; +#endif +} + + std::unordered_map> get_all_open_files() { std::unordered_map> map; std::vector pids = get_all_pids(); diff -r bd68e4393e6f -r 18979b066284 dep/animia/src/main.cpp --- a/dep/animia/src/main.cpp Wed Nov 01 15:16:49 2023 -0400 +++ b/dep/animia/src/main.cpp Thu Nov 02 13:14:15 2023 -0400 @@ -1,16 +1,10 @@ #include "bsd.h" +#include "os.h" #include "linux.h" #include "win32.h" #include #include #include -#ifdef __linux__ -# define ON_LINUX -#elif (defined(unix) || defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) -# define ON_UNIX -#elif defined(_WIN32) -# define ON_WINDOWS -#endif namespace Animia { @@ -53,6 +47,8 @@ std::vector filter_system_files(const std::vector& source) { #ifdef ON_WINDOWS return Windows::filter_system_files(source); +#elif defined(ON_OSX) + return Unix::filter_system_files(source); #else return source; #endif diff -r bd68e4393e6f -r 18979b066284 src/gui/pages/now_playing.cc --- a/src/gui/pages/now_playing.cc Wed Nov 01 15:16:49 2023 -0400 +++ b/src/gui/pages/now_playing.cc Thu Nov 02 13:14:15 2023 -0400 @@ -66,6 +66,7 @@ _info.reset(new AnimeInfoWidget(_main.get())); _info->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); + _info->layout()->setContentsMargins(0, 0, 0, 0); main_layout->addWidget(_info.get()); /* "sidebar", includes... just the anime image :) */ diff -r bd68e4393e6f -r 18979b066284 src/gui/widgets/text.cc --- a/src/gui/widgets/text.cc Wed Nov 01 15:16:49 2023 -0400 +++ b/src/gui/widgets/text.cc Thu Nov 02 13:14:15 2023 -0400 @@ -72,8 +72,8 @@ } /* Equivalent to Paragraph(), but is only capable of showing one line. Only - exists because sometimes with SelectableSection it will let you go - out of bounds */ + exists because with SelectableSection it will let you go + out of bounds and that looks really fugly for most things */ Line::Line(QWidget* parent) : QLineEdit(parent) { setFrame(false); setReadOnly(true); diff -r bd68e4393e6f -r 18979b066284 src/track/constants.cc --- a/src/track/constants.cc Wed Nov 01 15:16:49 2023 -0400 +++ b/src/track/constants.cc Thu Nov 02 13:14:15 2023 -0400 @@ -12,7 +12,7 @@ const std::vector media_players = { #ifdef MACOSX - "VLC" + "VLC", "IINA", "QuickTime Player" #elif WIN32 "vlc.exe", "mpc-hc.exe", "mpc-hc64.exe", "wmplayer.exe", "mpv.exe" #else // linux, unix, whatevs