diff options
author | Jean-Francois Mauguit <jfmauguit@mac.com> | 2024-09-24 09:03:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 09:03:25 -0400 |
commit | bab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Winamp/VideoOutputChildDDraw.cpp | |
parent | 4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff) | |
parent | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff) | |
download | winamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz |
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/Winamp/VideoOutputChildDDraw.cpp')
-rw-r--r-- | Src/Winamp/VideoOutputChildDDraw.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/Src/Winamp/VideoOutputChildDDraw.cpp b/Src/Winamp/VideoOutputChildDDraw.cpp new file mode 100644 index 00000000..470a86ce --- /dev/null +++ b/Src/Winamp/VideoOutputChildDDraw.cpp @@ -0,0 +1,66 @@ +#include "main.h" +#include "VideoOutputChildDDraw.h" +#include <ddraw.h> + +class MonitorFinder +{ +public: + MonitorFinder(HMONITOR hm) : m_monitor_to_find(hm), m_found_devguid(0) + {} + + HMONITOR m_monitor_to_find; + int m_found_devguid; + GUID m_devguid; +}; + +static BOOL WINAPI DDEnumCallbackEx(GUID FAR *lpGUID, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext, HMONITOR hm) +{ + MonitorFinder *ovo = (MonitorFinder *)lpContext; + if (ovo->m_found_devguid) return 1; + if (hm == ovo->m_monitor_to_find) + { + ovo->m_devguid = *lpGUID; + ovo->m_found_devguid = 1; + } + return 1; +} + +void VideoOutputChildDDraw::update_monitor_coords() +{ + //find the correct monitor if multiple monitor support is present + m_mon_x = 0; + m_mon_y = 0; + + HMONITOR hm = MonitorFromWindow(parent, 0); + if (hm) + { + HINSTANCE hdd = LoadLibraryW(TEXT("ddraw.dll")); + if (hdd) + { + typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKEXA)(GUID FAR *, LPSTR, LPSTR, LPVOID, HMONITOR); + typedef HRESULT (WINAPI * LPDIRECTDRAWENUMERATEEX)( LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags); + LPDIRECTDRAWENUMERATEEX lpDDEnumEx; + lpDDEnumEx = (LPDIRECTDRAWENUMERATEEX) GetProcAddress(hdd, "DirectDrawEnumerateExW"); + if (lpDDEnumEx) + { + MonitorFinder finder(hm); + + lpDDEnumEx(&DDEnumCallbackEx, &finder, DDENUM_ATTACHEDSECONDARYDEVICES | DDENUM_NONDISPLAYDEVICES); + foundGUID=!!finder.m_found_devguid; + if (foundGUID) + { + m_devguid=finder.m_devguid; + MONITORINFOEXW mi; + memset(&mi, 0, sizeof(mi)); + mi.cbSize = sizeof(mi); + if (GetMonitorInfoA(hm, &mi)) + { + m_mon_x = mi.rcMonitor.left; + m_mon_y = mi.rcMonitor.top; + } + } + } + FreeLibrary(hdd); + } + } +} |