Skip to content

Commit

Permalink
add options to control the behavior of mpv's dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dyphire committed Apr 6, 2024
1 parent 30f9dbd commit 502b155
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- patch
- ci
- 'release/**'
paths-ignore:
Expand Down
1 change: 1 addition & 0 deletions options/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ static const m_option_t mp_vo_opt_list[] = {
{"donotround", DWMWCP_DONOTROUND},
{"round", DWMWCP_ROUND},
{"roundsmall", DWMWCP_ROUNDSMALL})},
{"window-darkmode", OPT_CHOICE(window_dark_mode, {"always", 1}, {"auto", 0}, {"never", -1})},
#endif
#if HAVE_EGL_ANDROID
{"android-surface-size", OPT_SIZE_BOX(android_surface_size)},
Expand Down
1 change: 1 addition & 0 deletions options/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef struct mp_vo_opts {
int window_affinity;
char *mmcss_profile;
int window_corners;
int window_dark_mode;

double display_fps_override;
double timing_offset;
Expand Down
7 changes: 5 additions & 2 deletions video/out/w32_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1269,8 +1269,9 @@ static void update_dark_mode(const struct vo_w32_state *w32)
w32->api.pSetPreferredAppMode(1); // allow dark mode

// if pShouldAppsUseDarkMode is not available, just assume it to be true
const BOOL use_dark_mode = !is_high_contrast() && (!w32->api.pShouldAppsUseDarkMode ||
w32->api.pShouldAppsUseDarkMode());
const BOOL use_dark_mode = w32->opts->window_dark_mode == 1 || (w32->opts->window_dark_mode == 0 &&
!is_high_contrast() && (!w32->api.pShouldAppsUseDarkMode ||
w32->api.pShouldAppsUseDarkMode()));

SetWindowTheme(w32->window, use_dark_mode ? L"DarkMode_Explorer" : L"", NULL);

Expand Down Expand Up @@ -2163,6 +2164,8 @@ static int gui_thread_control(struct vo_w32_state *w32, int request, void *arg)
if (!vo_opts->fullscreen)
update_maximized_state(w32, true);
reinit_window_state(w32);
} else if (changed_option == &vo_opts->window_dark_mode) {
update_dark_mode(w32);
} else if (changed_option == &vo_opts->window_affinity) {
update_affinity(w32);
} else if (changed_option == &vo_opts->ontop) {
Expand Down

0 comments on commit 502b155

Please sign in to comment.