[vlc-commits] commit: Windows: remove calls to GetProcAddress for MonitorFromWindow and GetMonitorInfo ( Geoffroy Couprie )

git at videolan.org git at videolan.org
Thu Nov 4 19:57:07 CET 2010


vlc | branch: master | Geoffroy Couprie <geal at videolan.org> | Thu Nov  4 15:46:16 2010 +0100| [a35cc84e1efbc958b60ac7fbb64a1437840d25dc] | committer: Jean-Baptiste Kempf 

Windows: remove calls to GetProcAddress for MonitorFromWindow and GetMonitorInfo

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a35cc84e1efbc958b60ac7fbb64a1437840d25dc
---

 configure.ac                       |    1 +
 modules/video_output/msw/common.h  |    2 -
 modules/video_output/msw/directx.c |   61 ++++++++++++-----------------------
 3 files changed, 22 insertions(+), 42 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2b901f4..ac95209 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3376,6 +3376,7 @@ if test "${enable_directx}" != "no"
 then
   if test "${SYS}" = "mingw32" -o "${SYS}" = "mingwce"
   then
+      VLC_ADD_LIBS([directx],[-luser32])
       AC_CHECK_HEADERS(ddraw.h,
       [ VLC_ADD_PLUGIN([directx aout_directx])
         VLC_ADD_LIBS([directx],[-lgdi32])
diff --git a/modules/video_output/msw/common.h b/modules/video_output/msw/common.h
index 3a67c7d..0fc11e0 100644
--- a/modules/video_output/msw/common.h
+++ b/modules/video_output/msw/common.h
@@ -114,8 +114,6 @@ struct vout_display_sys_t
     /* Multi-monitor support */
     HMONITOR             hmonitor;          /* handle of the current monitor */
     GUID                 *display_driver;
-    HMONITOR             (WINAPI* MonitorFromWindow)(HWND, DWORD);
-    BOOL                 (WINAPI* GetMonitorInfo)(HMONITOR, LPMONITORINFO);
 
     /* Overlay alignment restrictions */
     int          i_align_src_boundary;
diff --git a/modules/video_output/msw/directx.c b/modules/video_output/msw/directx.c
index 1e69c17..330352c 100644
--- a/modules/video_output/msw/directx.c
+++ b/modules/video_output/msw/directx.c
@@ -44,18 +44,11 @@
 #include <vlc_vout_display.h>
 #include <vlc_playlist.h>   /* needed for wallpaper */
 
+#include <windows.h>
+#include <winuser.h>
 #include <ddraw.h>
 #include <commctrl.h>       /* ListView_(Get|Set)* */
 
-#ifndef UNDER_CE
-#   include <multimon.h>
-#endif
-#undef GetSystemMetrics
-
-#ifndef MONITOR_DEFAULTTONEAREST
-#   define MONITOR_DEFAULTTONEAREST 2
-#endif
-
 #include "common.h"
 
 #ifdef UNICODE
@@ -181,16 +174,6 @@ static int Open(vlc_object_t *object)
     }
 
     /* */
-    HMODULE huser32 = GetModuleHandle(_T("USER32"));
-    if (huser32) {
-        sys->MonitorFromWindow = (void*)GetProcAddress(huser32, _T("MonitorFromWindow"));
-        sys->GetMonitorInfo = (void*)GetProcAddress(huser32, _T("GetMonitorInfoA"));
-    } else {
-        sys->MonitorFromWindow = NULL;
-        sys->GetMonitorInfo = NULL;
-    }
-
-    /* */
     sys->use_wallpaper = var_CreateGetBool(vd, "video-wallpaper");
     /* FIXME */
     sys->use_overlay = false;//var_CreateGetBool(vd, "overlay"); /* FIXME */
@@ -366,8 +349,8 @@ static void Manage(vout_display_t *vd)
             DirectXUpdateOverlay(vd, NULL);
 
         /* Check if we are still on the same monitor */
-        if (sys->MonitorFromWindow &&
-            sys->hmonitor != sys->MonitorFromWindow(sys->hwnd, MONITOR_DEFAULTTONEAREST)) {
+        HMONITOR hmon = MonitorFromWindow(sys->hwnd, MONITOR_DEFAULTTONEAREST);
+        if (sys->hmonitor != hmon) {
             vout_display_SendEventPicturesInvalid(vd);
         }
         /* */
@@ -475,7 +458,7 @@ static BOOL WINAPI DirectXOpenDDrawCallback(GUID *guid, LPTSTR desc,
         MONITORINFO monitor_info;
         monitor_info.cbSize = sizeof(MONITORINFO);
 
-        if (sys->GetMonitorInfo(hmon, &monitor_info)) {
+        if (GetMonitorInfoA(hmon, &monitor_info)) {
             RECT rect;
 
             /* Move window to the right screen */
@@ -591,24 +574,22 @@ static int DirectXOpenDDraw(vout_display_t *vd)
     }
 
     /* */
-    if (sys->MonitorFromWindow) {
-        HRESULT (WINAPI *OurDirectDrawEnumerateEx)(LPDDENUMCALLBACKEXA, LPVOID, DWORD);
-        OurDirectDrawEnumerateEx =
-          (void *)GetProcAddress(sys->hddraw_dll, _T("DirectDrawEnumerateExA"));
-
-        if (OurDirectDrawEnumerateEx) {
-            char *device = var_GetString(vd, "directx-device");
-            if (device) {
-                msg_Dbg(vd, "directx-device: %s", device);
-                free(device);
-            }
+    HRESULT (WINAPI *OurDirectDrawEnumerateEx)(LPDDENUMCALLBACKEXA, LPVOID, DWORD);
+    OurDirectDrawEnumerateEx =
+      (void *)GetProcAddress(sys->hddraw_dll, _T("DirectDrawEnumerateExA"));
+
+    if (OurDirectDrawEnumerateEx) {
+        char *device = var_GetString(vd, "directx-device");
+        if (device) {
+            msg_Dbg(vd, "directx-device: %s", device);
+            free(device);
+        }
 
-            sys->hmonitor = sys->MonitorFromWindow(sys->hwnd, MONITOR_DEFAULTTONEAREST);
+        sys->hmonitor = MonitorFromWindow(sys->hwnd, MONITOR_DEFAULTTONEAREST);
 
-            /* Enumerate displays */
-            OurDirectDrawEnumerateEx(DirectXOpenDDrawCallback,
-                                     vd, DDENUM_ATTACHEDSECONDARYDEVICES);
-        }
+        /* Enumerate displays */
+        OurDirectDrawEnumerateEx(DirectXOpenDDrawCallback,
+                                 vd, DDENUM_ATTACHEDSECONDARYDEVICES);
     }
 
     /* Initialize DirectDraw now */
@@ -640,10 +621,10 @@ static int DirectXOpenDDraw(vout_display_t *vd)
     }
 
     /* Get the size of the current display device */
-    if (sys->hmonitor && sys->GetMonitorInfo) {
+    if (sys->hmonitor) {
         MONITORINFO monitor_info;
         monitor_info.cbSize = sizeof(MONITORINFO);
-        sys->GetMonitorInfo(vd->sys->hmonitor, &monitor_info);
+        GetMonitorInfoA(vd->sys->hmonitor, &monitor_info);
         sys->rect_display = monitor_info.rcMonitor;
     } else {
         sys->rect_display.left   = 0;



More information about the vlc-commits mailing list