1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:57:35 +00:00

WindowServer: Fix visibility of WindowSwitcher constructor

Derivatives of Core::Object should be constructed through
ClassName::construct(), to avoid handling ref-counted objects with
refcount zero. Fixing the visibility means that misuses like this are
more difficult.

This commit is separate from the other Servives changes because it
required additional adaption of the code. Note that the old code did
precisely what these changes try to prevent: Create and handle a
ref-counted object with a refcount of zero.
This commit is contained in:
Ben Wiederhake 2021-10-31 23:38:04 +01:00 committed by Andreas Kling
parent 52a1ff4d4b
commit 0e3397aabe
4 changed files with 27 additions and 25 deletions

View file

@ -1084,10 +1084,10 @@ void Compositor::recompute_overlay_rects()
void Compositor::recompute_occlusions()
{
auto& wm = WindowManager::the();
bool is_switcher_visible = wm.m_switcher.is_visible();
bool is_switcher_visible = wm.m_switcher->is_visible();
auto never_occlude = [&](WindowStack& window_stack) {
if (is_switcher_visible) {
switch (wm.m_switcher.mode()) {
switch (wm.m_switcher->mode()) {
case WindowSwitcher::Mode::ShowCurrentDesktop:
// Any window on the currently rendered desktop should not be occluded, even if it's behind
// another window entirely.
@ -1540,7 +1540,7 @@ void Compositor::finish_window_stack_switch()
m_window_stack_transition_animation = nullptr;
auto& wm = WindowManager::the();
if (!wm.m_switcher.is_visible())
if (!wm.m_switcher->is_visible())
previous_window_stack->set_all_occluded(true);
wm.did_switch_window_stack({}, *previous_window_stack, *m_current_window_stack);