ReactOS  0.4.14-dev-55-g2da92ac
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 
20 BOOL
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 
38 VOID
40 {
42 }
43 
44 
45 // static VOID
46 // GuiConsoleResize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam);
47 
48 VOID
50 {
51  PCONSRV_CONSOLE Console = GuiData->Console;
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 */
111  SetForegroundWindow(GuiData->hWindow);
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 */
164  SetForegroundWindow(GuiData->hWindow);
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 
174 VOID
176 {
177  PCONSRV_CONSOLE Console = GuiData->Console;
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 */
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
LONG WINAPI ChangeDisplaySettingsW(LPDEVMODEW lpDevMode, DWORD dwflags)
Definition: display.c:612
#define TRUE
Definition: types.h:120
struct _WINDOWPLACEMENT WINDOWPLACEMENT
#define SC_RESTORE
Definition: winuser.h:2573
DWORD dmFields
Definition: wingdi.h:1617
#define CDS_FULLSCREEN
Definition: winuser.h:183
LONG_PTR WndStyle
Definition: conwnd.h:56
#define ZeroMemory
Definition: winbase.h:1635
#define GWL_EXSTYLE
Definition: winuser.h:845
#define HWND_TOPMOST
Definition: winuser.h:1194
VOID LeaveFullScreen(PGUI_CONSOLE_DATA GuiData)
Definition: fullscreen.c:39
#define SWP_NOZORDER
Definition: winuser.h:1232
#define PCONSRV_CONSOLE
Definition: conio.h:27
#define WS_CLIPCHILDREN
Definition: pedump.c:619
BOOL WINAPI SetWindowPlacement(_In_ HWND hWnd, _In_ const WINDOWPLACEMENT *)
#define SetWindowLongPtr
Definition: treelist.c:70
#define CDS_RESET
Definition: winuser.h:187
#define DM_PELSWIDTH
Definition: wingdi.h:1268
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SC_MAXIMIZE
Definition: winuser.h:2563
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
DWORD dmDisplayFixedOutput
Definition: wingdi.h:1632
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR WndStyleEx
Definition: conwnd.h:57
void DPRINT(...)
Definition: polytest.cpp:61
BOOL WINAPI GetWindowPlacement(_In_ HWND, _Inout_ WINDOWPLACEMENT *)
VOID SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen)
Definition: fullscreen.c:49
#define DMDFO_CENTER
Definition: wingdi.h:1223
WINDOWPLACEMENT WndPl
Definition: conwnd.h:59
WORD dmSize
Definition: wingdi.h:1615
#define DISP_CHANGE_SUCCESSFUL
Definition: winuser.h:190
DWORD dmPelsWidth
Definition: wingdi.h:1643
VOID GuiConsoleSwitchFullScreen(PGUI_CONSOLE_DATA GuiData)
Definition: fullscreen.c:175
#define SWP_FRAMECHANGED
Definition: winuser.h:1225
BOOL EnterFullScreen(PGUI_CONSOLE_DATA GuiData)
Definition: fullscreen.c:21
#define SC_MINIMIZE
Definition: winuser.h:2561
#define SWP_NOSIZE
Definition: winuser.h:1230
#define GWL_STYLE
Definition: winuser.h:846
#define DM_PELSHEIGHT
Definition: wingdi.h:1269
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WS_POPUP
Definition: pedump.c:616
BOOL WINAPI IsZoomed(_In_ HWND)
#define SWP_SHOWWINDOW
Definition: winuser.h:1233
CConsole Console
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:96
DWORD dmPelsHeight
Definition: wingdi.h:1644
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define SWP_NOMOVE
Definition: winuser.h:1229
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define WS_EX_APPWINDOW
Definition: winuser.h:383
#define GetWindowLongPtr
Definition: treelist.c:73
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define WM_SYSCOMMAND
Definition: winuser.h:1723