mirror of https://github.com/mpv-player/mpv
win32: never call GetClientRect(0, ...)
Sometimes GetClientRect() appeared to fail during init, and since we don't check GetClientRect() calls (because they're on our own window, and logically can never fail), bogus resizes were triggered. This could cause vo_direct3d to fail initialization. The reason was that w32->window was set to 0 during early window initialization: CreateWindow*() can send messages to the new window, even though it hasn't returned yet. This means w32->window is not yet set to our window handle, and functions in WndProc may accidentally pass hwnd=0 to win32 API functions. Fix it by initializing w32->window on opportunity. This also means we always strictly expect that the WndProc is used with our own window only.
This commit is contained in:
parent
64e1132d39
commit
77ad49411a
|
@ -772,7 +772,8 @@ static bool resize_d3d(d3d_priv *priv)
|
|||
{
|
||||
D3DVIEWPORT9 vp = {0, 0, priv->vo->dwidth, priv->vo->dheight, 0, 1};
|
||||
|
||||
MP_VERBOSE(priv, "resize_d3d called.\n");
|
||||
MP_VERBOSE(priv, "resize_d3d %dx%d called.\n",
|
||||
priv->vo->dwidth, priv->vo->dheight);
|
||||
|
||||
/* Make sure that backbuffer is large enough to accomodate the new
|
||||
viewport dimensions. Grow it if necessary. */
|
||||
|
|
|
@ -515,6 +515,9 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
|||
{
|
||||
assert(w32_thread_context);
|
||||
struct vo_w32_state *w32 = w32_thread_context;
|
||||
if (!w32->window)
|
||||
w32->window = hWnd; // can happen during CreateWindow*!
|
||||
assert(w32->window == hWnd);
|
||||
int mouse_button = 0;
|
||||
|
||||
switch (message) {
|
||||
|
@ -522,7 +525,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
|||
// This message is used to wakeup the GUI thread, see wakeup_gui_thread.
|
||||
mp_dispatch_queue_process(w32->dispatch, 0);
|
||||
break;
|
||||
case WM_ERASEBKGND: // no need to erase background seperately
|
||||
case WM_ERASEBKGND: // no need to erase background separately
|
||||
return 1;
|
||||
case WM_PAINT:
|
||||
signal_events(w32, VO_EVENT_EXPOSE);
|
||||
|
|
Loading…
Reference in New Issue