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)
9 /* INCLUDES *******************************************************************/
12 #include "include/conio.h"
13 #include "include/console.h"
14 #include "include/settings.h"
15 #include "guisettings.h"
21 /* FUNCTIONS ******************************************************************/
24 EnterFullScreen(PGUI_CONSOLE_DATA GuiData
)
28 ZeroMemory(&DevMode
, sizeof(DevMode
));
29 DevMode
.dmSize
= sizeof(DevMode
);
31 DevMode
.dmDisplayFixedOutput
= DMDFO_CENTER
; // DMDFO_STRETCH // DMDFO_DEFAULT
32 // DevMode.dmDisplayFlags = DMDISPLAYFLAGS_TEXTMODE;
33 DevMode
.dmPelsWidth
= 640; // GuiData->ActiveBuffer->ViewSize.X * GuiData->CharWidth;
34 DevMode
.dmPelsHeight
= 480; // GuiData->ActiveBuffer->ViewSize.Y * GuiData->CharHeight;
35 // DevMode.dmBitsPerPel = 32;
36 DevMode
.dmFields
= DM_DISPLAYFIXEDOUTPUT
| /* DM_DISPLAYFLAGS | DM_BITSPERPEL | */ DM_PELSWIDTH
| DM_PELSHEIGHT
;
38 return (ChangeDisplaySettingsW(&DevMode
, CDS_FULLSCREEN
) == DISP_CHANGE_SUCCESSFUL
);
42 LeaveFullScreen(PGUI_CONSOLE_DATA GuiData
)
44 ChangeDisplaySettingsW(NULL
, CDS_RESET
);
49 // GuiConsoleResize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam);
52 SwitchFullScreen(PGUI_CONSOLE_DATA GuiData
, BOOL FullScreen
)
54 PCONSOLE Console
= GuiData
->Console
;
58 * http://stackoverflow.com/questions/2382464/win32-full-screen-and-hiding-taskbar
59 * http://stackoverflow.com/questions/3549148/fullscreen-management-with-winapi
60 * http://blogs.msdn.com/b/oldnewthing/archive/2010/04/12/9994016.aspx
61 * http://blogs.msdn.com/b/oldnewthing/archive/2005/05/05/414910.aspx
62 * http://stackoverflow.com/questions/1400654/how-do-i-put-my-opengl-app-into-fullscreen-mode
63 * http://nehe.gamedev.net/tutorial/creating_an_opengl_window_win32/13001/
64 * http://www.reocities.com/pcgpe/dibs.html
67 /* If we are already in the given state, just bail out */
68 if (FullScreen
== GuiData
->GuiInfo
.FullScreen
) return;
70 /* Save the current window state if we are not already full-screen */
71 if (!GuiData
->GuiInfo
.FullScreen
)
73 GuiData
->IsWndMax
= IsZoomed(GuiData
->hWindow
);
74 if (GuiData
->IsWndMax
)
75 SendMessageW(GuiData
->hWindow
, WM_SYSCOMMAND
, SC_RESTORE
, 0);
77 /* Save its old position and size and show state */
78 GuiData
->WndPl
.length
= sizeof(WINDOWPLACEMENT
);
79 GetWindowPlacement(GuiData
->hWindow
, &GuiData
->WndPl
);
81 /* Save the old window styles */
82 GuiData
->WndStyle
= GetWindowLongPtr(GuiData
->hWindow
, GWL_STYLE
);
83 GuiData
->WndStyleEx
= GetWindowLongPtr(GuiData
->hWindow
, GWL_EXSTYLE
);
88 SendMessageW(GuiData
->hWindow
, WM_SYSCOMMAND
, SC_MINIMIZE
, 0);
90 /* Switch to full screen */
91 if (EnterFullScreen(GuiData
))
93 /* Save the new state */
94 Console
->FixedSize
= TRUE
;
95 GuiData
->GuiInfo
.FullScreen
= TRUE
;
97 GuiData
->ActiveBuffer
->OldViewSize
= GuiData
->ActiveBuffer
->ViewSize
;
98 // GuiData->ActiveBuffer->OldScreenBufferSize = GuiData->ActiveBuffer->ScreenBufferSize;
100 /* Change the window styles */
101 SetWindowLongPtr(GuiData
->hWindow
, GWL_STYLE
,
102 WS_POPUP
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
);
103 SetWindowLongPtr(GuiData
->hWindow
, GWL_EXSTYLE
,
105 // SetWindowPos(GuiData->hWindow, NULL, 0, 0, 0, 0,
106 // SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
107 // SWP_FRAMECHANGED | SWP_SHOWWINDOW);
109 /* Reposition the window to the upper-left corner */
110 SetWindowPos(GuiData
->hWindow
, HWND_TOPMOST
, 0, 0, 0, 0,
111 SWP_NOSIZE
| SWP_FRAMECHANGED
| SWP_SHOWWINDOW
);
113 /* Make it the foreground window */
114 SetForegroundWindow(GuiData
->hWindow
);
117 // // GuiConsoleResizeWindow(GuiData);
118 // GuiConsoleResize(GuiData, SIZE_RESTORED, MAKELPARAM(640, 480));
120 PostMessageW(GuiData
->hWindow
, WM_SYSCOMMAND
, SC_MAXIMIZE
, 0);
121 // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
124 PostMessageW(GuiData
->hWindow
, WM_SYSCOMMAND
,
125 GuiData
->GuiInfo
.FullScreen
|| GuiData
->IsWndMax
126 ? SC_MAXIMIZE
: SC_RESTORE
,
128 // ShowWindowAsync(GuiData->hWindow, SW_RESTORE);
132 SendMessageW(GuiData
->hWindow
, WM_SYSCOMMAND
, SC_MINIMIZE
, 0);
134 /* Restore windowing mode */
135 LeaveFullScreen(GuiData
);
137 /* Save the new state */
138 GuiData
->GuiInfo
.FullScreen
= FALSE
;
139 Console
->FixedSize
= FALSE
;
142 * Restore possible saved dimensions
143 * of the active screen buffer view.
145 GuiData
->ActiveBuffer
->ViewSize
= GuiData
->ActiveBuffer
->OldViewSize
;
146 // GuiData->ActiveBuffer->ScreenBufferSize = GuiData->ActiveBuffer->OldScreenBufferSize;
148 /* Restore the window styles */
149 SetWindowLongPtr(GuiData
->hWindow
, GWL_STYLE
,
151 SetWindowLongPtr(GuiData
->hWindow
, GWL_EXSTYLE
,
152 GuiData
->WndStyleEx
);
153 SetWindowPos(GuiData
->hWindow
, NULL
, 0, 0, 0, 0,
154 SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOZORDER
|
155 SWP_FRAMECHANGED
/*| SWP_SHOWWINDOW*/);
158 /* Restore the window to its original position */
159 SetWindowPlacement(GuiData
->hWindow
, &GuiData
->WndPl
);
161 PostMessageW(GuiData
->hWindow
, WM_SYSCOMMAND
,
162 GuiData
->IsWndMax
? SC_MAXIMIZE
: SC_RESTORE
,
164 // ShowWindowAsync(GuiData->hWindow, SW_RESTORE);
166 /* Make it the foreground window */
167 SetForegroundWindow(GuiData
->hWindow
);
170 // GuiConsoleResizeWindow(GuiData);
172 // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
173 // // ShowWindowAsync(GuiData->hWindow, SW_RESTORE);
178 GuiConsoleSwitchFullScreen(PGUI_CONSOLE_DATA GuiData
)
180 PCONSOLE Console
= GuiData
->Console
;
183 if (!ConDrvValidateConsoleUnsafe(Console
, CONSOLE_RUNNING
, TRUE
)) return;
185 /* Switch to full-screen or to windowed mode */
186 FullScreen
= !GuiData
->GuiInfo
.FullScreen
;
187 DPRINT1("GuiConsoleSwitchFullScreen - Switch to %s ...\n",
188 (FullScreen
? "full-screen" : "windowed mode"));
190 SwitchFullScreen(GuiData
, FullScreen
);
192 LeaveCriticalSection(&Console
->Lock
);