mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:47:35 +00:00
WindowServer+LibGUI: Allow switching windows in/out of fullscreen mode
You can now call GWindow::set_fullscreen(bool) and it will go in or out of fullscreen mode. WindowServer will also remember the previous window rect when switching to fullscreen, and restore it when switching back. :^)
This commit is contained in:
parent
a34f3a3729
commit
d92e26d023
8 changed files with 78 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "WSWindow.h"
|
||||
#include "WSEvent.h"
|
||||
#include "WSEventLoop.h"
|
||||
#include "WSScreen.h"
|
||||
#include "WSWindowManager.h"
|
||||
#include <WindowServer/WSAPITypes.h>
|
||||
#include <WindowServer/WSClientConnection.h>
|
||||
|
@ -354,3 +355,19 @@ void WSWindow::request_close()
|
|||
WSEvent close_request(WSEvent::WindowCloseRequest);
|
||||
event(close_request);
|
||||
}
|
||||
|
||||
void WSWindow::set_fullscreen(bool fullscreen)
|
||||
{
|
||||
if (m_fullscreen == fullscreen)
|
||||
return;
|
||||
m_fullscreen = fullscreen;
|
||||
Rect new_window_rect = m_rect;
|
||||
if (m_fullscreen) {
|
||||
m_saved_nonfullscreen_rect = m_rect;
|
||||
new_window_rect = WSScreen::the().rect();
|
||||
} else if (!m_saved_nonfullscreen_rect.is_empty()) {
|
||||
new_window_rect = m_saved_nonfullscreen_rect;
|
||||
}
|
||||
CEventLoop::current().post_event(*this, make<WSResizeEvent>(m_rect, new_window_rect));
|
||||
set_rect(new_window_rect);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue