diff options
author | wm4 <wm4@nowhere> | 2014-07-26 20:28:36 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-07-26 20:28:36 +0200 |
commit | 9969694ececc82f57306ff0fd3212e264c64c81b (patch) | |
tree | 0e0595faf9d63d5de07f2a0419c6f61047c9b078 | |
parent | 9a3f1f24ca86b299c9d5f8c42eccab7fca26b2dd (diff) | |
download | mpv-9969694ececc82f57306ff0fd3212e264c64c81b.tar.bz2 mpv-9969694ececc82f57306ff0fd3212e264c64c81b.tar.xz |
win32: simplify some --wid embedding code
This looked a bit overcomplicated. We don't care about the window
position (it should always be 0/0, unless the parent program moved it,
which it shouldn't). We don't care about the global on-screen position.
Also, we will just retrieve a WM_SIZE message if our window is resized,
and we don't need to update it manually.
The only thing we have to do is making sure our window fills the parent
window completely.
-rw-r--r-- | video/out/w32_common.c | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/video/out/w32_common.c b/video/out/w32_common.c index 486969e223..8d4a9dfc89 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -692,33 +692,16 @@ static int vo_w32_check_events(struct vo_w32_state *w32) } if (w32->opts->WinID >= 0) { - BOOL res; - RECT r; - POINT p; - res = GetClientRect(w32->window, &r); - - if (res && (r.right != w32->dw || r.bottom != w32->dh)) { - w32->dw = r.right; w32->dh = r.bottom; - w32->vo->dwidth = w32->dw; w32->vo->dheight = w32->dh; - w32->event_flags |= VO_EVENT_RESIZE; - } - - p.x = 0; p.y = 0; - ClientToScreen(w32->window, &p); - - if (p.x != w32->window_x || p.y != w32->window_y) { - w32->window_x = p.x; w32->window_y = p.y; - } - - res = GetClientRect(WIN_ID_TO_HWND(w32->opts->WinID), &r); - - if (res && (r.right != w32->dw || r.bottom != w32->dh)) - MoveWindow(w32->window, 0, 0, r.right, r.bottom, FALSE); - - if (!IsWindow(WIN_ID_TO_HWND(w32->opts->WinID))) { - // Window has probably been closed, e.g. due to program crash + HWND parent = WIN_ID_TO_HWND(w32->opts->WinID); + RECT r, rp; + BOOL res = GetClientRect(w32->window, &r); + res = res && GetClientRect(parent, &rp); + if (res && (r.right != rp.right || r.bottom != rp.bottom)) + MoveWindow(w32->window, 0, 0, rp.right, rp.bottom, FALSE); + + // Window has probably been closed, e.g. due to parent program crash + if (!IsWindow(parent)) mp_input_put_key(w32->input_ctx, MP_KEY_CLOSE_WIN); - } } return w32->event_flags; |