Skip to content

Commit

Permalink
Tweaks to forced fullscreen logic
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanGriffiths committed Oct 4, 2024
1 parent ad96185 commit f24c49c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions examples/mir-x11-kiosk/x11_kiosk_window_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ bool X11KioskWindowManagerPolicy::handle_pointer_event(MirPointerEvent const* ev
return false;
}

#define MIR_LOG_COMPONENT "X11Kiosk"
#include <mir/log.h>

auto X11KioskWindowManagerPolicy::place_new_window(ApplicationInfo const& app_info, WindowSpecification const& request)
-> WindowSpecification
{
Expand All @@ -77,7 +80,8 @@ auto X11KioskWindowManagerPolicy::place_new_window(ApplicationInfo const& app_in
(!specification.parent().is_set() || !specification.parent().value().lock()))
{
specification.state() = mir_window_state_fullscreen;
specification.size() = mir::optional_value<Size>{}; // Ignore requested size (if any) when we maximize
specification.size() = mir::optional_value<Size>{}; // Ignore requested size (if any) when we fullscreen
specification.top_left() = mir::optional_value<Point>{}; // Ignore requested position (if any) when we fullscreen
tools.place_and_size_for_state(specification, WindowInfo{});

if (!request.state().is_set() || request.state().value() != mir_window_state_restored)
Expand All @@ -94,8 +98,22 @@ void X11KioskWindowManagerPolicy::handle_modify_window(WindowInfo& window_info,
if ((window_info.type() == mir_window_type_normal || window_info.type() == mir_window_type_freestyle) &&
!window_info.parent())
{
if (window_info.state() == mir_window_state_fullscreen && modifications.state().is_set())
{
// If the window is already fullscreen, then first restore it
// as otherwise the client may not repaint
WindowSpecification mods;
mods.state() = mir_window_state_restored;
mods.size() = window_info.restore_rect().size;
mods.top_left() = window_info.restore_rect().top_left;

tools.place_and_size_for_state(mods, window_info);
tools.modify_window(window_info, mods);
}

specification.state() = mir_window_state_fullscreen;
specification.size() = mir::optional_value<Size>{}; // Ignore requested size (if any) when we maximize
specification.size() = mir::optional_value<Size>{}; // Ignore requested size (if any) when we fullscreen
specification.top_left() = mir::optional_value<Point>{}; // Ignore requested position (if any) when we fullscreen
tools.place_and_size_for_state(specification, window_info);

if (!modifications.state().is_set() || modifications.state().value() != mir_window_state_restored)
Expand Down

0 comments on commit f24c49c

Please sign in to comment.