HRESULT SetFullscreen(void) { HRESULT hr=S_OK; LONG lMode; static HWND hDrain=0; if (!pVW) return S_FALSE; // Read current state LIF(pVW->get_FullScreenMode(&lMode)); if (lMode == 0) /* OAFALSE */ { // Save current message drain LIF(pVW->get_MessageDrain((OAHWND *) &hDrain)); // Set message drain to application main window LIF(pVW->put_MessageDrain((OAHWND) g_hwndMain)); // Switch to full-screen mode lMode = -1; /* OATRUE */ LIF(pVW->put_FullScreenMode(lMode)); } return hr; }
HRESULT CPlayWMV::ToggleFullScreen(void) { HRESULT hr = S_OK; LONG lMode = 0; static HWND hDrain = 0; // Don't bother with full-screen for audio-only files if ((m_bAudioOnly) || (!m_pVW)) return S_OK; // Read current state JIF(m_pVW->get_FullScreenMode(&lMode)); if (lMode == 0) /* OAFALSE */ { // Save current message drain LIF(m_pVW->get_MessageDrain((OAHWND *) &hDrain)); // Set message drain to application main window LIF(m_pVW->put_MessageDrain((OAHWND) m_hWnd)); // Switch to full-screen mode lMode = -1; /* OATRUE */ JIF(m_pVW->put_FullScreenMode(lMode)); m_bFullscreen = TRUE; } else { // Switch back to windowed mode lMode = 0; /* OAFALSE */ JIF(m_pVW->put_FullScreenMode(lMode)); // Undo change of message drain LIF(m_pVW->put_MessageDrain((OAHWND) hDrain)); // Reset video window LIF(m_pVW->SetWindowForeground(-1)); // Reclaim keyboard focus for player application UpdateWindow(m_hWnd); SetForegroundWindow(m_hWnd); SetFocus(m_hWnd); m_bFullscreen = FALSE; } return hr; }
static void persistproto(PersistInfo *pi) { /* perms reftbl ... proto */ Proto *p = toproto(pi->L, -1); lua_checkstack(pi->L, 2); /* Persist constant refs */ { int i; pi->writer(pi->L, &p->sizek, sizeof(int), pi->ud); for(i=0; i<p->sizek; i++) { LIF(A,pushobject)(pi->L, &p->k[i]); /* perms reftbl ... proto const */ persist(pi); lua_pop(pi->L, 1); /* perms reftbl ... proto */ } } /* perms reftbl ... proto */ /* serialize inner Proto refs */ { int i; pi->writer(pi->L, &p->sizep, sizeof(int), pi->ud); for(i=0; i<p->sizep; i++) { pushproto(pi->L, p->p[i]); /* perms reftbl ... proto subproto */ persist(pi); lua_pop(pi->L, 1); /* perms reftbl ... proto */ } } /* perms reftbl ... proto */ /* Serialize code */ { pi->writer(pi->L, &p->sizecode, sizeof(int), pi->ud); pi->writer(pi->L, p->code, sizeof(Instruction) * p->sizecode, pi->ud); } /* Serialize misc values */ { pi->writer(pi->L, &p->nups, sizeof(lu_byte), pi->ud); pi->writer(pi->L, &p->numparams, sizeof(lu_byte), pi->ud); pi->writer(pi->L, &p->is_vararg, sizeof(lu_byte), pi->ud); pi->writer(pi->L, &p->maxstacksize, sizeof(lu_byte), pi->ud); } /* We do not currently persist upvalue names, local variable names, * variable lifetimes, line info, or source code. */ }
/* Upvalues are tricky. Here's why. * * A particular upvalue may be either "open", in which case its member v * points into a thread's stack, or "closed" in which case it points to the * upvalue itself. An upvalue is closed under any of the following conditions: * -- The function that initially declared the variable "local" returns * -- The thread in which the closure was created is garbage collected * * To make things wackier, just because a thread is reachable by Lua doesn't * mean it's in our root set. We need to be able to treat an open upvalue * from an unreachable thread as a closed upvalue. * * The solution: * (a) For the purposes of persisting, don't indicate whether an upvalue is * closed or not. * (b) When unpersisting, pretend that all upvalues are closed. * (c) When persisting, persist all open upvalues referenced by a thread * that is persisted, and tag each one with the corresponding stack position * (d) When unpersisting, "reopen" each of these upvalues as the thread is * unpersisted */ static void persistupval(PersistInfo *pi) { /* perms reftbl ... upval */ UpVal *uv = toupval(pi->L, -1); lua_checkstack(pi->L, 1); /* We can't permit the upval to linger around on the stack, as Lua * will bail if its GC finds it. */ lua_pop(pi->L, 1); /* perms reftbl ... */ LIF(A,pushobject)(pi->L, uv->v); /* perms reftbl ... obj */ persist(pi); /* perms reftbl ... obj */ }
static void pushclosure(lua_State *L, Closure *closure) { TValue o; setclvalue(L, &o, closure); LIF(A,pushobject)(L, &o); }
static void pushupval(lua_State *L, UpVal *upval) { TValue o; setuvvalue(L, &o, upval); LIF(A,pushobject)(L, &o); }
static void pushproto(lua_State *L, Proto *proto) { TValue o; setptvalue(L, &o, proto); LIF(A,pushobject)(L, &o); }
static void pushstring(lua_State *L, TString *s) { TValue o; setsvalue(L, &o, s); LIF(A,pushobject)(L, &o); }
HRESULT MPToggleFullScreen(void) { HRESULT hr=S_OK; LONG lMode; static HWND hDrain=0; CWnd m_hWnd; // Don't bother with full-screen for audio-only files if ((g_bAudioOnly_MP) || (!pVW_MP)) return S_OK; // Read current state JIF(pVW_MP->get_FullScreenMode(&lMode)); if (lMode == OAFALSE) { // Save current message drain LIF(pVW_MP->get_MessageDrain((OAHWND *) &hDrain)); // Set message drain to application main window LIF(pVW_MP->put_MessageDrain((OAHWND) (HWND)m_hWnd)); // Switch to full-screen mode lMode = OATRUE; JIF(pVW_MP->put_FullScreenMode(lMode)); g_bFullScreen_MP = TRUE; } else { // Switch back to windowed mode lMode = OAFALSE; JIF(pVW_MP->put_FullScreenMode(lMode)); // Undo change of message drain LIF(pVW_MP->put_MessageDrain((OAHWND) hDrain)); // Reset video window LIF(pVW_MP->SetWindowForeground(-1)); // Reclaim keyboard focus for player application m_hWnd.UpdateWindow(); m_hWnd.SetForegroundWindow(); m_hWnd.SetFocus(); g_bFullScreen_MP = FALSE; } CLEANUP: return(hr); }