ReactOS 0.4.15-dev-7953-g1f49173
fullscreen.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Console Server DLL
4 * FILE: win32ss/user/winsrv/consrv/frontends/gui/fullscreen.c
5 * PURPOSE: GUI Terminal Full-screen Mode
6 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include <consrv.h>
12
13#define NDEBUG
14#include <debug.h>
15
16#include "guiterm.h"
17
18/* FUNCTIONS ******************************************************************/
19
20BOOL
22{
23 DEVMODEW DevMode;
24
25 ZeroMemory(&DevMode, sizeof(DevMode));
26 DevMode.dmSize = sizeof(DevMode);
27
28 DevMode.dmDisplayFixedOutput = DMDFO_CENTER; // DMDFO_STRETCH // DMDFO_DEFAULT
29 // DevMode.dmDisplayFlags = DMDISPLAYFLAGS_TEXTMODE;
30 DevMode.dmPelsWidth = 640; // GuiData->ActiveBuffer->ViewSize.X * GuiData->CharWidth;
31 DevMode.dmPelsHeight = 480; // GuiData->ActiveBuffer->ViewSize.Y * GuiData->CharHeight;
32 // DevMode.dmBitsPerPel = 32;
33 DevMode.dmFields = DM_DISPLAYFIXEDOUTPUT | /* DM_DISPLAYFLAGS | DM_BITSPERPEL | */ DM_PELSWIDTH | DM_PELSHEIGHT;
34
36}
37
38VOID
40{
42}
43
44
45// static VOID
46// GuiConsoleResize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam);
47
48VOID
50{
52
53 /*
54 * See:
55 * http://stackoverflow.com/questions/2382464/win32-full-screen-and-hiding-taskbar
56 * http://stackoverflow.com/questions/3549148/fullscreen-management-with-winapi
57 * http://blogs.msdn.com/b/oldnewthing/archive/2010/04/12/9994016.aspx
58 * http://blogs.msdn.com/b/oldnewthing/archive/2005/05/05/414910.aspx
59 * http://stackoverflow.com/questions/1400654/how-do-i-put-my-opengl-app-into-fullscreen-mode
60 * http://nehe.gamedev.net/tutorial/creating_an_opengl_window_win32/13001/
61 * http://www.reocities.com/pcgpe/dibs.html
62 */
63
64 /* If we are already in the given state, just bail out */
65 if (FullScreen == GuiData->GuiInfo.FullScreen) return;
66
67 /* Save the current window state if we are not already full-screen */
68 if (!GuiData->GuiInfo.FullScreen)
69 {
70 GuiData->IsWndMax = IsZoomed(GuiData->hWindow);
71 if (GuiData->IsWndMax)
73
74 /* Save its old position and size and show state */
75 GuiData->WndPl.length = sizeof(WINDOWPLACEMENT);
76 GetWindowPlacement(GuiData->hWindow, &GuiData->WndPl);
77
78 /* Save the old window styles */
79 GuiData->WndStyle = GetWindowLongPtr(GuiData->hWindow, GWL_STYLE );
80 GuiData->WndStyleEx = GetWindowLongPtr(GuiData->hWindow, GWL_EXSTYLE);
81 }
82
83 if (FullScreen)
84 {
86
87 /* Switch to full screen */
88 if (EnterFullScreen(GuiData))
89 {
90 /* Save the new state */
91 Console->FixedSize = TRUE;
92 GuiData->GuiInfo.FullScreen = TRUE;
93
94 GuiData->ActiveBuffer->OldViewSize = GuiData->ActiveBuffer->ViewSize;
95 // GuiData->ActiveBuffer->OldScreenBufferSize = GuiData->ActiveBuffer->ScreenBufferSize;
96
97 /* Change the window styles */
102 // SetWindowPos(GuiData->hWindow, NULL, 0, 0, 0, 0,
103 // SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
104 // SWP_FRAMECHANGED | SWP_SHOWWINDOW);
105
106 /* Reposition the window to the upper-left corner */
107 SetWindowPos(GuiData->hWindow, HWND_TOPMOST, 0, 0, 0, 0,
109
110 /* Make it the foreground window */
112
113 /* Resize it */
114 // // GuiConsoleResizeWindow(GuiData);
115 // GuiConsoleResize(GuiData, SIZE_RESTORED, MAKELPARAM(640, 480));
116
118 // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
119 }
120
122 GuiData->GuiInfo.FullScreen || GuiData->IsWndMax
124 0);
125 // ShowWindowAsync(GuiData->hWindow, SW_RESTORE);
126 }
127 else
128 {
130
131 /* Restore windowing mode */
132 LeaveFullScreen(GuiData);
133
134 /* Save the new state */
135 GuiData->GuiInfo.FullScreen = FALSE;
136 Console->FixedSize = FALSE;
137
138 /*
139 * Restore possible saved dimensions
140 * of the active screen buffer view.
141 */
142 GuiData->ActiveBuffer->ViewSize = GuiData->ActiveBuffer->OldViewSize;
143 // GuiData->ActiveBuffer->ScreenBufferSize = GuiData->ActiveBuffer->OldScreenBufferSize;
144
145 /* Restore the window styles */
147 GuiData->WndStyle);
149 GuiData->WndStyleEx);
150 SetWindowPos(GuiData->hWindow, NULL, 0, 0, 0, 0,
152 SWP_FRAMECHANGED /*| SWP_SHOWWINDOW*/);
153
154
155 /* Restore the window to its original position */
156 SetWindowPlacement(GuiData->hWindow, &GuiData->WndPl);
157
159 GuiData->IsWndMax ? SC_MAXIMIZE : SC_RESTORE,
160 0);
161 // ShowWindowAsync(GuiData->hWindow, SW_RESTORE);
162
163 /* Make it the foreground window */
165
166 /* Resize it */
167 // GuiConsoleResizeWindow(GuiData);
168
169 // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
170 // // ShowWindowAsync(GuiData->hWindow, SW_RESTORE);
171 }
172}
173
174VOID
176{
178 BOOL FullScreen;
179
181
182 /* Switch to full-screen or to windowed mode */
183 FullScreen = !GuiData->GuiInfo.FullScreen;
184 DPRINT("GuiConsoleSwitchFullScreen - Switch to %s ...\n",
185 (FullScreen ? "full-screen" : "windowed mode"));
186
187 SwitchFullScreen(GuiData, FullScreen);
188
190}
191
192/* EOF */
CConsole Console
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL EnterFullScreen(PGUI_CONSOLE_DATA GuiData)
Definition: fullscreen.c:21
VOID LeaveFullScreen(PGUI_CONSOLE_DATA GuiData)
Definition: fullscreen.c:39
VOID SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen)
Definition: fullscreen.c:49
VOID GuiConsoleSwitchFullScreen(PGUI_CONSOLE_DATA GuiData)
Definition: fullscreen.c:175
#define WS_POPUP
Definition: pedump.c:616
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define DPRINT
Definition: sndvol32.h:71
LONG_PTR WndStyleEx
Definition: conwnd.h:58
WINDOWPLACEMENT WndPl
Definition: conwnd.h:60
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:92
PCONSRV_CONSOLE Console
Definition: conwnd.h:91
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:97
LONG_PTR WndStyle
Definition: conwnd.h:57
DWORD dmDisplayFixedOutput
Definition: wingdi.h:1637
DWORD dmFields
Definition: wingdi.h:1622
DWORD dmPelsWidth
Definition: wingdi.h:1648
DWORD dmPelsHeight
Definition: wingdi.h:1649
WORD dmSize
Definition: wingdi.h:1620
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
LONG WINAPI ChangeDisplaySettingsW(LPDEVMODEW lpDevMode, DWORD dwflags)
Definition: display.c:612
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:36
@ CONSOLE_RUNNING
Definition: conio.h:283
#define ZeroMemory
Definition: winbase.h:1712
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define DM_PELSWIDTH
Definition: wingdi.h:1269
#define DMDFO_CENTER
Definition: wingdi.h:1224
#define DM_PELSHEIGHT
Definition: wingdi.h:1270
#define WM_SYSCOMMAND
Definition: winuser.h:1741
#define SWP_FRAMECHANGED
Definition: winuser.h:1240
#define HWND_TOPMOST
Definition: winuser.h:1208
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI GetWindowPlacement(_In_ HWND, _Inout_ WINDOWPLACEMENT *)
#define WS_EX_APPWINDOW
Definition: winuser.h:383
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOMOVE
Definition: winuser.h:1244
#define DISP_CHANGE_SUCCESSFUL
Definition: winuser.h:190
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define CDS_FULLSCREEN
Definition: winuser.h:183
#define SWP_NOSIZE
Definition: winuser.h:1245
BOOL WINAPI IsZoomed(_In_ HWND)
#define SC_MINIMIZE
Definition: winuser.h:2586
#define CDS_RESET
Definition: winuser.h:187
#define SWP_SHOWWINDOW
Definition: winuser.h:1248
#define SWP_NOZORDER
Definition: winuser.h:1247
struct _WINDOWPLACEMENT WINDOWPLACEMENT
#define GWL_STYLE
Definition: winuser.h:852
BOOL WINAPI SetWindowPlacement(_In_ HWND hWnd, _In_ const WINDOWPLACEMENT *)
#define SC_RESTORE
Definition: winuser.h:2598
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SC_MAXIMIZE
Definition: winuser.h:2588
#define GWL_EXSTYLE
Definition: winuser.h:851