mirror of
https://github.com/mpv-player/mpv
synced 2025-04-27 13:49:33 +00:00
Add reinitialization support. Necessary for fullscreen on OSX.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31085 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
4121ce1747
commit
3a34dbc927
@ -1869,6 +1869,8 @@ static int sdl_check_events(void) {
|
|||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
res |= sdl_default_handle_event(&event);
|
res |= sdl_default_handle_event(&event);
|
||||||
}
|
}
|
||||||
|
// poll "events" from within MPlayer code
|
||||||
|
res |= sdl_default_handle_event(NULL);
|
||||||
if (res & VO_EVENT_RESIZE)
|
if (res & VO_EVENT_RESIZE)
|
||||||
sdl_set_mode(0, SDL_OPENGL | SDL_RESIZABLE);
|
sdl_set_mode(0, SDL_OPENGL | SDL_RESIZABLE);
|
||||||
return res;
|
return res;
|
||||||
|
@ -29,9 +29,12 @@
|
|||||||
static int old_w;
|
static int old_w;
|
||||||
static int old_h;
|
static int old_h;
|
||||||
static int mode_flags;
|
static int mode_flags;
|
||||||
|
static int reinit;
|
||||||
|
|
||||||
int vo_sdl_init(void)
|
int vo_sdl_init(void)
|
||||||
{
|
{
|
||||||
|
reinit = 0;
|
||||||
|
|
||||||
if (!SDL_WasInit(SDL_INIT_VIDEO) &&
|
if (!SDL_WasInit(SDL_INIT_VIDEO) &&
|
||||||
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0)
|
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -70,6 +73,9 @@ void vo_sdl_fullscreen(void)
|
|||||||
}
|
}
|
||||||
vo_fs = !vo_fs;
|
vo_fs = !vo_fs;
|
||||||
sdl_set_mode(0, mode_flags);
|
sdl_set_mode(0, mode_flags);
|
||||||
|
// on OSX at least we now need to do a full reinit.
|
||||||
|
// TODO: this should only be set if really necessary.
|
||||||
|
reinit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sdl_set_mode(int bpp, uint32_t flags)
|
int sdl_set_mode(int bpp, uint32_t flags)
|
||||||
@ -111,6 +117,11 @@ static const struct mp_keymap keysym_map[] = {
|
|||||||
int sdl_default_handle_event(SDL_Event *event)
|
int sdl_default_handle_event(SDL_Event *event)
|
||||||
{
|
{
|
||||||
int mpkey;
|
int mpkey;
|
||||||
|
if (!event) {
|
||||||
|
int res = reinit ? VO_EVENT_REINIT : 0;
|
||||||
|
reinit = 0;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case SDL_VIDEORESIZE:
|
case SDL_VIDEORESIZE:
|
||||||
vo_dwidth = event->resize.w;
|
vo_dwidth = event->resize.w;
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#define VO_EVENT_EXPOSE 1
|
#define VO_EVENT_EXPOSE 1
|
||||||
#define VO_EVENT_RESIZE 2
|
#define VO_EVENT_RESIZE 2
|
||||||
#define VO_EVENT_KEYPRESS 4
|
#define VO_EVENT_KEYPRESS 4
|
||||||
|
#define VO_EVENT_REINIT 8
|
||||||
|
|
||||||
/* Obsolete: VOCTRL_QUERY_VAA 1 */
|
/* Obsolete: VOCTRL_QUERY_VAA 1 */
|
||||||
/* does the device support the required format */
|
/* does the device support the required format */
|
||||||
|
@ -650,6 +650,10 @@ glconfig:
|
|||||||
static void check_events(void)
|
static void check_events(void)
|
||||||
{
|
{
|
||||||
int e=glctx.check_events();
|
int e=glctx.check_events();
|
||||||
|
if(e&VO_EVENT_REINIT) {
|
||||||
|
uninitGl();
|
||||||
|
initGl(vo_dwidth, vo_dheight);
|
||||||
|
}
|
||||||
if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight);
|
if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight);
|
||||||
if(e&VO_EVENT_EXPOSE && int_pause) redraw();
|
if(e&VO_EVENT_EXPOSE && int_pause) redraw();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user