Skip to content

Commit

Permalink
x11-kiosk: defer fullscreening of applications until they are placed …
Browse files Browse the repository at this point in the history
…once (#3670)

Fix the "black screen" problem with vmware-view
  • Loading branch information
AlanGriffiths authored Nov 19, 2024
2 parents e72bacc + ed00444 commit cdaf48e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
39 changes: 33 additions & 6 deletions examples/mir-x11-kiosk/x11_kiosk_window_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,22 @@ void X11KioskWindowManagerPolicy::handle_modify_window(WindowInfo& 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 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 (window_info.is_visible() || !modifications.state().is_set() || modifications.state().value() != mir_window_state_restored)
{
specification.state() = mir_window_state_fullscreen;
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)
specification.state() = modifications.state();
if (!modifications.state().is_set() || modifications.state().value() != mir_window_state_restored)
specification.state() = modifications.state();
}
else
{
// We have one X11 application (vmware-view) that doesn't submit any buffers unless it
// can first "restore" its window
tools.place_and_size_for_state(specification, window_info);
}
}

CanonicalWindowManagerPolicy::handle_modify_window(window_info, specification);
Expand All @@ -132,3 +141,21 @@ X11KioskWindowManagerPolicy::confirm_placement_on_display(WindowInfo const& /*wi
{
return new_placement;
}

void X11KioskWindowManagerPolicy::handle_window_ready(miral::WindowInfo& window_info)
{
if ((window_info.type() == mir_window_type_normal || window_info.type() == mir_window_type_freestyle) &&
!window_info.parent())
{
// We have one X11 application (vmware-view) that doesn't submit any buffers unless it
// can first "restore" its window. We've got a buffer now, so we can fullscreen it
if (window_info.state() == mir_window_state_restored)
{
WindowSpecification specification;
specification.state() = mir_window_state_fullscreen;
tools.place_and_size_for_state(specification, WindowInfo{});
tools.modify_window(window_info, specification);
}
}
CanonicalWindowManagerPolicy::handle_window_ready(window_info);
}
3 changes: 2 additions & 1 deletion examples/mir-x11-kiosk/x11_kiosk_window_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ class X11KioskWindowManagerPolicy : public miral::CanonicalWindowManagerPolicy
void handle_modify_window(miral::WindowInfo& window_info, miral::WindowSpecification const& modifications) override;

void handle_request_move(miral::WindowInfo& window_info, MirInputEvent const* input_event) override;
void handle_window_ready(miral::WindowInfo& window_info) override;
void handle_request_resize(miral::WindowInfo& window_info, MirInputEvent const* input_event,
MirResizeEdge edge) override;
MirResizeEdge edge) override;

auto confirm_placement_on_display(const miral::WindowInfo& window_info, MirWindowState new_state,
Rectangle const& new_placement) -> Rectangle override;
Expand Down
6 changes: 0 additions & 6 deletions src/server/scene/surface_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ struct SurfaceDepthLayerObserver : ms::NullSurfaceObserver

ms::SurfaceStack::SurfaceStack(std::shared_ptr<SceneReport> const& report) :
report{report},
scene_changed{false},
surface_observer{std::make_shared<SurfaceDepthLayerObserver>(this)},
multiplexer(linearising_executor)
{
Expand All @@ -153,7 +152,6 @@ mc::SceneElementSequence ms::SurfaceStack::scene_elements_for(mc::CompositorID i
{
RecursiveReadLock lg(guard);

scene_changed = false;
mc::SceneElementSequence elements;
for (auto const& layer : surface_layers)
{
Expand Down Expand Up @@ -227,10 +225,6 @@ void ms::SurfaceStack::remove_input_visualization(

void ms::SurfaceStack::emit_scene_changed()
{
{
RecursiveWriteLock lg(guard);
scene_changed = true;
}
observers.scene_changed();
}

Expand Down
1 change: 0 additions & 1 deletion src/server/scene/surface_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ class SurfaceStack :
Observers observers;
/// If not expired the screen is locked (and only surfaces that appear on the lock screen should be shown)
std::atomic<bool> is_locked = false;
std::atomic<bool> scene_changed;
std::shared_ptr<SurfaceObserver> surface_observer;
SessionLockObserverMultiplexer multiplexer;
};
Expand Down

0 comments on commit cdaf48e

Please sign in to comment.