Skip to content

Commit e047dc2

Browse files
committed
Various fixes
1 parent e2e8b69 commit e047dc2

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

src/CMakeLists.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
#Build main launcher executable file
2+
set(SOURCES
3+
launcher.c
4+
launcher.h
5+
util.c
6+
util.h
7+
image.c
8+
image.h
9+
debug.c
10+
debug.h
11+
clock.c
12+
clock.h
13+
)
214
if (UNIX)
3-
add_executable(${EXECUTABLE_TITLE} "launcher.c" "util.c" "image.c" "debug.c" "clock.c")
15+
add_executable(${EXECUTABLE_TITLE} ${SOURCES})
416
endif ()
517
if (WIN32)
618
set(APP_ICON_RESOURCE_WINDOWS "${PROJECT_SOURCE_DIR}/config/${EXECUTABLE_TITLE}.rc")
719
set(MANIFEST_FILE "${PROJECT_BINARY_DIR}/${EXECUTABLE_TITLE}.manifest")
8-
add_executable(${EXECUTABLE_TITLE} WIN32 "launcher.c" "util.c" "image.c" "debug.c" "clock.c" ${MANIFEST_FILE} ${APP_ICON_RESOURCE_WINDOWS})
20+
add_executable(${EXECUTABLE_TITLE} WIN32 ${SOURCES} ${MANIFEST_FILE} ${APP_ICON_RESOURCE_WINDOWS})
921
set_property(TARGET ${EXECUTABLE_TITLE} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
1022
endif()
1123

src/launcher.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,8 @@ static void draw_screen()
806806
if (state.screensaver_active)
807807
SDL_RenderCopy(renderer, screensaver->texture, NULL, NULL);
808808
}
809+
else
810+
SDL_RenderFillRect(renderer, NULL);
809811

810812
// Output to screen
811813
SDL_RenderPresent(renderer);
@@ -1243,6 +1245,7 @@ int main(int argc, char *argv[])
12431245
// Initialize timing
12441246
ticks.main = SDL_GetTicks();
12451247
ticks.last_input = ticks.main;
1248+
ticks.program_start = ticks.main;
12461249

12471250
// Load gamepad overrides
12481251
if (config.gamepad_enabled && config.gamepad_mappings_file != NULL) {
@@ -1397,7 +1400,10 @@ int main(int argc, char *argv[])
13971400
pre_launch();
13981401
}
13991402
#ifdef _WIN32
1400-
else // Sometimes the launcher loses focus when autostarting on Windows
1403+
// Sometimes the launcher will lose focus on Windows when autostarting
1404+
// So if we lose the window focus within 10 seconds of the launcher starting
1405+
// we will grab back th Window focus. This is a bit of a hack
1406+
else if (ticks.main - ticks.program_start < 10000)
14011407
set_foreground_window();
14021408
#endif
14031409
}

src/launcher.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ typedef struct {
127127
// Timing information
128128
typedef struct {
129129
Uint32 main;
130+
Uint32 program_start;
130131
Uint32 application_launched;
131132
Uint32 slideshow_load;
132133
Uint32 last_input;

src/platform/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# Build platform-specific library
22
if (UNIX)
3-
add_library(platform "unix.c")
3+
add_library(platform unix.c unix.h platform.h)
44
target_link_libraries(platform PkgConfig::SDL2)
55
endif ()
66
if (WIN32)
7-
add_library(platform "win32.c")
8-
target_link_libraries(platform SDL2::SDL2main)
7+
add_library(platform win32.c platform.h)
8+
target_link_libraries(platform
9+
$<TARGET_NAME_IF_EXISTS:SDL2::SDL2main>
10+
$<IF:$<TARGET_EXISTS:SDL2::SDL2>,SDL2::SDL2,SDL2::SDL2-static>
11+
)
912
endif ()

0 commit comments

Comments
 (0)