Skip to content

Commit 994bd53

Browse files
CarterLiCopilot
andcommitted
Media (Windows): major code refactor
moves detection code into fastfetch binary Co-authored-by: Copilot <copilot@github.com>
1 parent 383a419 commit 994bd53

7 files changed

Lines changed: 371 additions & 182 deletions

File tree

CMakeLists.txt

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,11 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} -Werror=incompatible-pointe
160160

161161
if(WIN32 OR Haiku)
162162
enable_language(CXX)
163-
set(CMAKE_CXX_STANDARD 17)
163+
if(WIN32)
164+
set(CMAKE_CXX_STANDARD 20)
165+
else()
166+
set(CMAKE_CXX_STANDARD 17)
167+
endif()
164168
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS}")
165169
endif()
166170

@@ -1065,7 +1069,7 @@ elseif(WIN32)
10651069
src/detection/locale/locale_windows.c
10661070
src/detection/localip/localip_windows.c
10671071
src/detection/gamepad/gamepad_windows.c
1068-
src/detection/media/media_windows.c
1072+
src/detection/media/media_windows.cpp
10691073
src/detection/memory/memory_windows.c
10701074
src/detection/mouse/mouse_windows.c
10711075
src/detection/physicalmemory/physicalmemory_linux.c
@@ -1332,6 +1336,14 @@ endif()
13321336
if(WIN32)
13331337
list(APPEND LIBFASTFETCH_SRC src/detection/gpu/gpu_intel.c)
13341338
list(APPEND LIBFASTFETCH_SRC src/detection/gpu/gpu_amd.c)
1339+
1340+
include(CheckIncludeFileCXX)
1341+
CHECK_INCLUDE_FILE_CXX("winrt/Windows.Foundation.h" HAVE_WINRT)
1342+
if(HAVE_WINRT)
1343+
message(STATUS "WinRT headers are available, media detection will use WinRT APIs")
1344+
else()
1345+
message(STATUS "WinRT headers are NOT available, media detection will be disabled")
1346+
endif()
13351347
endif()
13361348
include(CheckFunctionExists)
13371349
check_function_exists(wcwidth HAVE_WCWIDTH)
@@ -1434,7 +1446,7 @@ if(LINUX)
14341446
elseif(ANDROID)
14351447
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE _FILE_OFFSET_BITS=64 "$<$<CONFIG:DEBUG>:__BIONIC_FORTIFY>" "$<$<CONFIG:DEBUG>:__BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED>")
14361448
elseif(WIN32)
1437-
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE WIN32_LEAN_AND_MEAN _WIN32_WINNT=0x0A00 NOMINMAX UNICODE) # "$<$<CONFIG:Release>:_FORTIFY_SOURCE=3>"
1449+
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE WIN32_LEAN_AND_MEAN WINRT_LEAN_AND_MEAN _WIN32_WINNT=0x0A00 NOMINMAX UNICODE) # "$<$<CONFIG:Release>:_FORTIFY_SOURCE=3>"
14381450
elseif(APPLE)
14391451
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE __STDC_WANT_LIB_EXT1__ _FILE_OFFSET_BITS=64 _DARWIN_C_SOURCE)
14401452
elseif(OpenBSD)
@@ -1745,6 +1757,12 @@ elseif(WIN32)
17451757
PRIVATE "mincore"
17461758
)
17471759
endif()
1760+
if(HAVE_WINRT)
1761+
target_link_libraries(libfastfetch
1762+
PRIVATE
1763+
"RuntimeObject"
1764+
)
1765+
endif()
17481766
elseif(FreeBSD)
17491767
target_link_libraries(libfastfetch
17501768
PRIVATE "m"
@@ -1831,20 +1849,6 @@ target_link_libraries(libfastfetch
18311849
target_compile_options(libfastfetch PRIVATE
18321850
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-rtti>)
18331851

1834-
if(WIN32)
1835-
set(CMAKE_CXX_STANDARD 20)
1836-
include(CheckIncludeFileCXX)
1837-
CHECK_INCLUDE_FILE_CXX("winrt/Windows.Foundation.h" HAVE_WINRT)
1838-
if(HAVE_WINRT)
1839-
add_library(ffwinrt MODULE src/detection/media/media_windows.dll.cpp)
1840-
target_link_libraries(ffwinrt PRIVATE "RuntimeObject")
1841-
target_compile_definitions(ffwinrt PRIVATE WIN32_LEAN_AND_MEAN=1 WINRT_LEAN_AND_MEAN=1)
1842-
target_link_options(ffwinrt
1843-
PRIVATE "-static" # stdc++, winpthread, gcc_s, etc.
1844-
)
1845-
endif()
1846-
set(CMAKE_CXX_STANDARD 17)
1847-
endif()
18481852
if(FreeBSD)
18491853
set(CMAKE_REQUIRED_INCLUDES "/usr/local/include" "/usr/include")
18501854
endif()
@@ -1891,6 +1895,8 @@ if(NOT WIN32)
18911895
message(WARNING "pthread_timedjoin_np was not found; networking timeout will not work")
18921896
endif()
18931897
endif()
1898+
elseif(HAVE_WINRT)
1899+
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_WINRT=1)
18941900
endif()
18951901

18961902
set(PACKAGES_DISABLE_LIST "")
@@ -2037,13 +2043,6 @@ if (TARGET flashfetch)
20372043
)
20382044
endif()
20392045

2040-
if (TARGET ffwinrt)
2041-
install(
2042-
TARGETS ffwinrt
2043-
DESTINATION "${CMAKE_INSTALL_BINDIR}"
2044-
)
2045-
endif()
2046-
20472046
install(
20482047
FILES "${CMAKE_SOURCE_DIR}/completions/${CMAKE_PROJECT_NAME}.bash"
20492048
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions"

src/common/impl/init.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ void ffListFeatures(void) {
260260
#if FF_HAVE_EMBEDDED_PCIIDS
261261
"Embedded pciids\n"
262262
#endif
263+
#if FF_HAVE_WINRT
264+
"WinRT headers\n"
265+
#endif
263266
#if FF_WIN81_COMPAT
264267
"Windows 8.1 Compatibility\n"
265268
#endif

src/common/windows/com.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#ifdef __cplusplus
44

5+
#include "common/attributes.h"
56
#include <unknwn.h>
67

78
const char* ffInitCom(void);

src/detection/media/media_windows.c

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)