mirror of https://github.com/mpv-player/mpv
win32: don't use VOCTRL_UPDATE_SCREENINFO
Not very tested. At least it compiles.
This commit is contained in:
parent
836893fed9
commit
41b1ed7b2e
|
@ -171,7 +171,7 @@ out:
|
||||||
static bool config_window_w32(struct MPGLContext *ctx, uint32_t d_width,
|
static bool config_window_w32(struct MPGLContext *ctx, uint32_t d_width,
|
||||||
uint32_t d_height, uint32_t flags)
|
uint32_t d_height, uint32_t flags)
|
||||||
{
|
{
|
||||||
if (!vo_w32_config(ctx->vo, d_width, d_height, flags))
|
if (!vo_w32_config(ctx->vo, flags))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
|
@ -1271,7 +1271,7 @@ static int reconfig(struct vo *vo, struct mp_image_params *params, int flags)
|
||||||
/* w32_common framework call. Creates window on the screen with
|
/* w32_common framework call. Creates window on the screen with
|
||||||
* the given coordinates.
|
* the given coordinates.
|
||||||
*/
|
*/
|
||||||
if (!vo_w32_config(vo, vo->dwidth, vo->dheight, flags)) {
|
if (!vo_w32_config(vo, flags)) {
|
||||||
MP_VERBOSE(priv, "Creating window failed.\n");
|
MP_VERBOSE(priv, "Creating window failed.\n");
|
||||||
return VO_ERROR;
|
return VO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include "common/msg.h"
|
#include "common/msg.h"
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "vo.h"
|
#include "vo.h"
|
||||||
#include "aspect.h"
|
#include "win_state.h"
|
||||||
#include "w32_common.h"
|
#include "w32_common.h"
|
||||||
#include "osdep/io.h"
|
#include "osdep/io.h"
|
||||||
#include "osdep/w32_keyboard.h"
|
#include "osdep/w32_keyboard.h"
|
||||||
|
@ -695,10 +695,7 @@ static BOOL CALLBACK mon_enum(HMONITOR hmon, HDC hdc, LPRECT r, LPARAM p)
|
||||||
struct vo *vo = (void*)p;
|
struct vo *vo = (void*)p;
|
||||||
struct vo_w32_state *w32 = vo->w32;
|
struct vo_w32_state *w32 = vo->w32;
|
||||||
// this defaults to the last screen if specified number does not exist
|
// this defaults to the last screen if specified number does not exist
|
||||||
vo->xinerama_x = r->left;
|
w32->screenrc = (struct mp_rect){r->left, r->top, r->right, r->bottom};
|
||||||
vo->xinerama_y = r->top;
|
|
||||||
vo->opts->screenwidth = r->right - r->left;
|
|
||||||
vo->opts->screenheight = r->bottom - r->top;
|
|
||||||
|
|
||||||
if (w32->mon_cnt == w32->mon_id)
|
if (w32->mon_cnt == w32->mon_id)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -707,49 +704,35 @@ static BOOL CALLBACK mon_enum(HMONITOR hmon, HDC hdc, LPRECT r, LPARAM p)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Update screen information.
|
|
||||||
*
|
|
||||||
* This function should be called in libvo's "control" callback
|
|
||||||
* with parameter VOCTRL_UPDATE_SCREENINFO.
|
|
||||||
* Note that this also enables the new API where geometry and aspect
|
|
||||||
* calculations are done in video_out.c:config_video_out
|
|
||||||
*
|
|
||||||
* Global libvo variables changed:
|
|
||||||
* xinerama_x
|
|
||||||
* xinerama_y
|
|
||||||
* vo_screenwidth
|
|
||||||
* vo_screenheight
|
|
||||||
*/
|
|
||||||
static void w32_update_xinerama_info(struct vo *vo)
|
static void w32_update_xinerama_info(struct vo *vo)
|
||||||
{
|
{
|
||||||
struct vo_w32_state *w32 = vo->w32;
|
struct vo_w32_state *w32 = vo->w32;
|
||||||
struct mp_vo_opts *opts = vo->opts;
|
struct mp_vo_opts *opts = vo->opts;
|
||||||
int screen = opts->fullscreen ? opts->fsscreen_id : opts->screen_id;
|
int screen = opts->fullscreen ? opts->fsscreen_id : opts->screen_id;
|
||||||
vo->xinerama_x = vo->xinerama_y = 0;
|
|
||||||
|
|
||||||
if (opts->fullscreen && screen == -2) {
|
if (opts->fullscreen && screen == -2) {
|
||||||
int tmp;
|
struct mp_rect rc = {
|
||||||
vo->xinerama_x = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
GetSystemMetrics(SM_XVIRTUALSCREEN),
|
||||||
vo->xinerama_y = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
GetSystemMetrics(SM_YVIRTUALSCREEN),
|
||||||
tmp = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
GetSystemMetrics(SM_CXVIRTUALSCREEN),
|
||||||
|
GetSystemMetrics(SM_CYVIRTUALSCREEN),
|
||||||
if (tmp)
|
};
|
||||||
vo->opts->screenwidth = tmp;
|
if (!rc.x1 || !rc.y1) {
|
||||||
|
rc.x1 = w32->screenrc.x1; // assume screenrc.x0==y0==0
|
||||||
tmp = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
rc.x1 = w32->screenrc.y1;
|
||||||
|
}
|
||||||
if (tmp)
|
rc.x1 += rc.x0;
|
||||||
vo->opts->screenheight = tmp;
|
rc.y1 += rc.y0;
|
||||||
|
w32->screenrc = rc;
|
||||||
} else if (screen == -1) {
|
} else if (screen == -1) {
|
||||||
MONITORINFO mi;
|
MONITORINFO mi;
|
||||||
HMONITOR m = MonitorFromWindow(w32->window, MONITOR_DEFAULTTOPRIMARY);
|
HMONITOR m = MonitorFromWindow(w32->window, MONITOR_DEFAULTTOPRIMARY);
|
||||||
mi.cbSize = sizeof(mi);
|
mi.cbSize = sizeof(mi);
|
||||||
GetMonitorInfoW(m, &mi);
|
GetMonitorInfoW(m, &mi);
|
||||||
vo->xinerama_x = mi.rcMonitor.left;
|
w32->screenrc = (struct mp_rect){
|
||||||
vo->xinerama_y = mi.rcMonitor.top;
|
mi.rcMonitor.left, mi.rcMonitor.top,
|
||||||
vo->opts->screenwidth = mi.rcMonitor.right - mi.rcMonitor.left;
|
mi.rcMonitor.right, mi.rcMonitor.bottom,
|
||||||
vo->opts->screenheight = mi.rcMonitor.bottom - mi.rcMonitor.top;
|
};
|
||||||
} else if (screen >= 0) {
|
} else if (screen >= 0) {
|
||||||
w32->mon_cnt = 0;
|
w32->mon_cnt = 0;
|
||||||
w32->mon_id = screen;
|
w32->mon_id = screen;
|
||||||
|
@ -759,6 +742,8 @@ static void w32_update_xinerama_info(struct vo *vo)
|
||||||
|
|
||||||
static void updateScreenProperties(struct vo *vo)
|
static void updateScreenProperties(struct vo *vo)
|
||||||
{
|
{
|
||||||
|
struct vo_w32_state *w32 = vo->w32;
|
||||||
|
|
||||||
DEVMODE dm;
|
DEVMODE dm;
|
||||||
dm.dmSize = sizeof dm;
|
dm.dmSize = sizeof dm;
|
||||||
dm.dmDriverExtra = 0;
|
dm.dmDriverExtra = 0;
|
||||||
|
@ -769,8 +754,7 @@ static void updateScreenProperties(struct vo *vo)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vo->opts->screenwidth = dm.dmPelsWidth;
|
w32->screenrc = (struct mp_rect){0, 0, dm.dmPelsWidth, dm.dmPelsHeight};
|
||||||
vo->opts->screenheight = dm.dmPelsHeight;
|
|
||||||
w32_update_xinerama_info(vo);
|
w32_update_xinerama_info(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -815,10 +799,10 @@ static int reinit_window_state(struct vo *vo)
|
||||||
w32->prev_x, w32->prev_y, w32->prev_width, w32->prev_height);
|
w32->prev_x, w32->prev_y, w32->prev_width, w32->prev_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
vo->dwidth = vo->opts->screenwidth;
|
w32->window_x = w32->screenrc.x0;
|
||||||
vo->dheight = vo->opts->screenheight;
|
w32->window_y = w32->screenrc.y0;
|
||||||
w32->window_x = vo->xinerama_x;
|
vo->dwidth = w32->screenrc.x1 - w32->screenrc.x0;
|
||||||
w32->window_y = vo->xinerama_y;
|
vo->dheight = w32->screenrc.y1 - w32->screenrc.y0;
|
||||||
style &= ~WS_OVERLAPPEDWINDOW;
|
style &= ~WS_OVERLAPPEDWINDOW;
|
||||||
} else {
|
} else {
|
||||||
if (toggle_fs) {
|
if (toggle_fs) {
|
||||||
|
@ -865,8 +849,7 @@ static int reinit_window_state(struct vo *vo)
|
||||||
*
|
*
|
||||||
* \return 1 - Success, 0 - Failure
|
* \return 1 - Success, 0 - Failure
|
||||||
*/
|
*/
|
||||||
int vo_w32_config(struct vo *vo, uint32_t width, uint32_t height,
|
int vo_w32_config(struct vo *vo, uint32_t flags)
|
||||||
uint32_t flags)
|
|
||||||
{
|
{
|
||||||
struct vo_w32_state *w32 = vo->w32;
|
struct vo_w32_state *w32 = vo->w32;
|
||||||
PIXELFORMATDESCRIPTOR pfd;
|
PIXELFORMATDESCRIPTOR pfd;
|
||||||
|
@ -899,10 +882,14 @@ int vo_w32_config(struct vo *vo, uint32_t width, uint32_t height,
|
||||||
if (flags & VOFLAG_HIDDEN)
|
if (flags & VOFLAG_HIDDEN)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
bool reset_size = !(w32->o_dwidth == width && w32->o_dheight == height);
|
struct vo_win_geometry geo;
|
||||||
|
vo_calc_window_geometry(vo, &w32->screenrc, &geo);
|
||||||
|
vo_apply_window_geometry(vo, &geo);
|
||||||
|
|
||||||
w32->o_dwidth = width;
|
bool reset_size = w32->o_dwidth != vo->dwidth || w32->o_dheight != vo->dheight;
|
||||||
w32->o_dheight = height;
|
|
||||||
|
w32->o_dwidth = vo->dwidth;
|
||||||
|
w32->o_dheight = vo->dheight;
|
||||||
|
|
||||||
// the desired size is ignored in wid mode, it always matches the window size.
|
// the desired size is ignored in wid mode, it always matches the window size.
|
||||||
if (vo->opts->WinID < 0) {
|
if (vo->opts->WinID < 0) {
|
||||||
|
@ -914,20 +901,15 @@ int vo_w32_config(struct vo *vo, uint32_t width, uint32_t height,
|
||||||
vo->dwidth = r.right;
|
vo->dwidth = r.right;
|
||||||
vo->dheight = r.bottom;
|
vo->dheight = r.bottom;
|
||||||
} else {
|
} else {
|
||||||
// first vo_config call; vo_config() will always set vo_dx/dy so
|
|
||||||
// that the window is centered on the screen, and this is the only
|
|
||||||
// time we actually want to use vo_dy/dy (this is not sane, and
|
|
||||||
// vo.h should provide a function to query the initial
|
|
||||||
// window position instead)
|
|
||||||
w32->window_bounds_initialized = true;
|
w32->window_bounds_initialized = true;
|
||||||
reset_size = true;
|
reset_size = true;
|
||||||
w32->window_x = w32->prev_x = vo->dx;
|
w32->window_x = w32->prev_x = geo.win.x0;
|
||||||
w32->window_y = w32->prev_y = vo->dy;
|
w32->window_y = w32->prev_y = geo.win.y0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reset_size) {
|
if (reset_size) {
|
||||||
w32->prev_width = vo->dwidth = width;
|
w32->prev_width = vo->dwidth = w32->o_dwidth;
|
||||||
w32->prev_height = vo->dheight = height;
|
w32->prev_height = vo->dheight = w32->o_dheight;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
RECT r;
|
RECT r;
|
||||||
|
@ -948,11 +930,6 @@ int vo_w32_config(struct vo *vo, uint32_t width, uint32_t height,
|
||||||
* be called after your own preinit initialization and you shouldn't do any
|
* be called after your own preinit initialization and you shouldn't do any
|
||||||
* window management on your own.
|
* window management on your own.
|
||||||
*
|
*
|
||||||
* Global libvo variables changed:
|
|
||||||
* vo_w32_window
|
|
||||||
* vo_screenwidth
|
|
||||||
* vo_screenheight
|
|
||||||
*
|
|
||||||
* \return 1 = Success, 0 = Failure
|
* \return 1 = Success, 0 = Failure
|
||||||
*/
|
*/
|
||||||
int vo_w32_init(struct vo *vo)
|
int vo_w32_init(struct vo *vo)
|
||||||
|
@ -1026,9 +1003,6 @@ int vo_w32_init(struct vo *vo)
|
||||||
|
|
||||||
updateScreenProperties(vo);
|
updateScreenProperties(vo);
|
||||||
|
|
||||||
MP_VERBOSE(vo, "win32: running at %dx%d\n",
|
|
||||||
vo->opts->screenwidth, vo->opts->screenheight);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1094,9 +1068,6 @@ int vo_w32_control(struct vo *vo, int *events, int request, void *arg)
|
||||||
vo_w32_border(vo);
|
vo_w32_border(vo);
|
||||||
*events |= VO_EVENT_RESIZE;
|
*events |= VO_EVENT_RESIZE;
|
||||||
return VO_TRUE;
|
return VO_TRUE;
|
||||||
case VOCTRL_UPDATE_SCREENINFO:
|
|
||||||
w32_update_xinerama_info(vo);
|
|
||||||
return VO_TRUE;
|
|
||||||
case VOCTRL_GET_WINDOW_SIZE: {
|
case VOCTRL_GET_WINDOW_SIZE: {
|
||||||
int *s = arg;
|
int *s = arg;
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,14 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include "common/common.h"
|
||||||
|
|
||||||
struct vo_w32_state {
|
struct vo_w32_state {
|
||||||
HWND window;
|
HWND window;
|
||||||
|
|
||||||
|
// Size and virtual position of the current screen.
|
||||||
|
struct mp_rect screenrc;
|
||||||
|
|
||||||
// last non-fullscreen extends (updated only on fullscreen or on initialization)
|
// last non-fullscreen extends (updated only on fullscreen or on initialization)
|
||||||
int prev_width;
|
int prev_width;
|
||||||
int prev_height;
|
int prev_height;
|
||||||
|
@ -66,6 +71,6 @@ int vo_w32_init(struct vo *vo);
|
||||||
void vo_w32_uninit(struct vo *vo);
|
void vo_w32_uninit(struct vo *vo);
|
||||||
int vo_w32_control(struct vo *vo, int *events, int request, void *arg);
|
int vo_w32_control(struct vo *vo, int *events, int request, void *arg);
|
||||||
int vo_w32_check_events(struct vo *vo);
|
int vo_w32_check_events(struct vo *vo);
|
||||||
int vo_w32_config(struct vo *vo, uint32_t, uint32_t, uint32_t);
|
int vo_w32_config(struct vo *vo, uint32_t);
|
||||||
|
|
||||||
#endif /* MPLAYER_W32_COMMON_H */
|
#endif /* MPLAYER_W32_COMMON_H */
|
||||||
|
|
Loading…
Reference in New Issue