summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/w32.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/opengl/w32.c')
-rw-r--r--video/out/opengl/w32.c47
1 files changed, 12 insertions, 35 deletions
diff --git a/video/out/opengl/w32.c b/video/out/opengl/w32.c
index 97ad0d6e47..05e2f5c4a3 100644
--- a/video/out/opengl/w32.c
+++ b/video/out/opengl/w32.c
@@ -24,6 +24,7 @@
#include <windows.h>
#include <dwmapi.h>
#include "video/out/w32_common.h"
+#include "video/out/win32/exclusive_hack.h"
#include "common.h"
struct w32_context {
@@ -35,13 +36,6 @@ struct w32_context {
HGLRC context;
HDC hdc;
int flags;
-
- HINSTANCE dwmapi_dll;
- HRESULT (WINAPI *pDwmFlush)(void);
- HRESULT (WINAPI *pDwmIsCompositionEnabled)(BOOL *pfEnabled);
- HRESULT (WINAPI *pDwmEnableMMCSS)(BOOL fEnableMMCSS);
- HRESULT (WINAPI *pDwmGetCompositionTimingInfo)
- (HWND hwnd, DWM_TIMING_INFO *pTimingInfo);
};
static void w32_uninit(MPGLContext *ctx);
@@ -227,17 +221,6 @@ static void create_ctx(void *ptr)
if (!w32_ctx->context)
create_context_w32_old(ctx);
- w32_ctx->dwmapi_dll = LoadLibrary(L"Dwmapi.dll");
- if (w32_ctx->dwmapi_dll) {
- w32_ctx->pDwmFlush = (void *)GetProcAddress(w32_ctx->dwmapi_dll, "DwmFlush");
- w32_ctx->pDwmIsCompositionEnabled =
- (void *)GetProcAddress(w32_ctx->dwmapi_dll, "DwmIsCompositionEnabled");
- w32_ctx->pDwmGetCompositionTimingInfo =
- (void *)GetProcAddress(w32_ctx->dwmapi_dll, "DwmGetCompositionTimingInfo");
- w32_ctx->pDwmEnableMMCSS =
- (void *)GetProcAddress(w32_ctx->dwmapi_dll, "DwmEnableMMCSS");
- }
-
wglMakeCurrent(w32_ctx->hdc, NULL);
}
@@ -255,15 +238,14 @@ static int w32_init(struct MPGLContext *ctx, int flags)
goto fail;
if (!ctx->gl->SwapInterval)
- MP_VERBOSE(ctx->vo, "WGL_EXT_swap_control missing.");
+ MP_VERBOSE(ctx->vo, "WGL_EXT_swap_control missing.\n");
w32_ctx->real_wglSwapInterval = ctx->gl->SwapInterval;
ctx->gl->SwapInterval = w32_swap_interval;
w32_ctx->current_swapinterval = -1;
current_w32_context = w32_ctx;
wglMakeCurrent(w32_ctx->hdc, w32_ctx->context);
- if (w32_ctx->pDwmEnableMMCSS)
- w32_ctx->pDwmEnableMMCSS(TRUE);
+ DwmEnableMMCSS(TRUE);
return 0;
fail:
@@ -297,32 +279,27 @@ static void w32_uninit(MPGLContext *ctx)
wglMakeCurrent(w32_ctx->hdc, 0);
vo_w32_run_on_thread(ctx->vo, destroy_gl, ctx);
- if (w32_ctx->pDwmEnableMMCSS)
- w32_ctx->pDwmEnableMMCSS(FALSE);
-
- if (w32_ctx->dwmapi_dll)
- FreeLibrary(w32_ctx->dwmapi_dll);
- w32_ctx->dwmapi_dll = NULL;
+ DwmEnableMMCSS(FALSE);
vo_w32_uninit(ctx->vo);
}
static bool compositor_active(MPGLContext *ctx)
{
- struct w32_context *w32_ctx = ctx->priv;
-
- if (!w32_ctx->pDwmIsCompositionEnabled || !w32_ctx->pDwmGetCompositionTimingInfo)
- return false;
-
// For Windows 7.
BOOL enabled = 0;
- if (FAILED(w32_ctx->pDwmIsCompositionEnabled(&enabled)) || !enabled)
+ if (FAILED(DwmIsCompositionEnabled(&enabled)) || !enabled)
return false;
// This works at least on Windows 8.1: it returns an error in fullscreen,
// which is also when we get consistent timings without DwmFlush. Might
// be cargo-cult.
DWM_TIMING_INFO info = { .cbSize = sizeof(DWM_TIMING_INFO) };
- if (FAILED(w32_ctx->pDwmGetCompositionTimingInfo(0, &info)))
+ if (FAILED(DwmGetCompositionTimingInfo(0, &info)))
+ return false;
+
+ // Test if a program is running in exclusive fullscreen mode. If so, it's
+ // probably this one, so it's not getting redirected by the compositor.
+ if (mp_w32_is_in_exclusive_mode())
return false;
return true;
@@ -341,7 +318,7 @@ static void w32_swap_buffers(MPGLContext *ctx)
(ctx->dwm_flush_opt == 2) ||
(ctx->dwm_flush_opt == 0 && compositor_active(ctx)))
{
- if (w32_ctx->pDwmFlush && w32_ctx->pDwmFlush() == S_OK)
+ if (DwmFlush() == S_OK)
new_swapinterval = 0;
}
}