diff options
author | sfan5 <sfan5@live.de> | 2023-01-09 16:03:43 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2023-01-09 16:03:43 +0100 |
commit | bd0b42e5bd47c22592760a244f80e49ec0222892 (patch) | |
tree | 5f538a1473f74ee13d3d1c488c6bf725cef79342 | |
parent | 829775865dbd69db9211cd4b6b6c9b1e5ad82953 (diff) | |
download | mpv-examples-bd0b42e5bd47c22592760a244f80e49ec0222892.tar.bz2 mpv-examples-bd0b42e5bd47c22592760a244f80e49ec0222892.tar.xz |
Update Qt example to fix the HWND casting
ref: https://github.com/mpv-player/mpv/issues/10189
-rw-r--r-- | libmpv/qt/qtexample.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libmpv/qt/qtexample.cpp b/libmpv/qt/qtexample.cpp index 161cc0e..fe85c22 100644 --- a/libmpv/qt/qtexample.cpp +++ b/libmpv/qt/qtexample.cpp @@ -68,8 +68,14 @@ MainWindow::MainWindow(QWidget *parent) : setCentralWidget(mpv_container); mpv_container->setAttribute(Qt::WA_DontCreateNativeAncestors); mpv_container->setAttribute(Qt::WA_NativeWindow); - // If you have a HWND, use: int64_t wid = (intptr_t)hwnd; - int64_t wid = mpv_container->winId(); + auto raw_wid = mpv_container->winId(); +#ifdef _WIN32 + // Truncate to 32-bit, as all Windows handles are. This also ensures + // it doesn't go negative. + int64_t wid = static_cast<uint32_t>(raw_wid); +#else + int64_t wid = raw_wid; +#endif mpv_set_option(mpv, "wid", MPV_FORMAT_INT64, &wid); // Enable default bindings, because we're lazy. Normally, a player using |