Skip to content

Commit

Permalink
WindowServer: Yank out window frame opacity
Browse files Browse the repository at this point in the history
This facility was added in 15a1d9a, but isn't being used for anything.
It wasn't even hooked up to LibGUI for applications to use.
Relevant use-cases, such as the most prominent one in `AnalogClock`, use
`GUI::Window::set_frameless()` instead.
  • Loading branch information
vkoskiv authored and gmta committed Jun 24, 2023
1 parent 6931a5a commit c3f5b51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
20 changes: 4 additions & 16 deletions Userland/Services/WindowServer/WindowFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,14 @@ void WindowFrame::PerScaleRenderedCache::paint(WindowFrame& frame, Gfx::Painter&
// We have a top piece
auto src_rect = rect.intersected(Gfx::Rect { frame_rect.location(), { frame_rect.width(), m_bottom_y } });
if (!src_rect.is_empty())
painter.blit(src_rect.location(), *m_top_bottom, src_rect.translated(-frame_rect.location()), frame.opacity());
painter.blit(src_rect.location(), *m_top_bottom, src_rect.translated(-frame_rect.location()));
}
if (m_bottom_y < top_bottom_height) {
// We have a bottom piece
Gfx::IntRect rect_in_frame { frame_rect.x(), window_rect.bottom(), frame_rect.width(), top_bottom_height - m_bottom_y };
auto src_rect = rect.intersected(rect_in_frame);
if (!src_rect.is_empty())
painter.blit(src_rect.location(), *m_top_bottom, src_rect.translated(-rect_in_frame.x(), -rect_in_frame.y() + m_bottom_y), frame.opacity());
painter.blit(src_rect.location(), *m_top_bottom, src_rect.translated(-rect_in_frame.x(), -rect_in_frame.y() + m_bottom_y));
}
}

Expand All @@ -376,14 +376,14 @@ void WindowFrame::PerScaleRenderedCache::paint(WindowFrame& frame, Gfx::Painter&
Gfx::IntRect rect_in_frame { frame_rect.x(), window_rect.y(), m_right_x, window_rect.height() };
auto src_rect = rect.intersected(rect_in_frame);
if (!src_rect.is_empty())
painter.blit(src_rect.location(), *m_left_right, src_rect.translated(-rect_in_frame.location()), frame.opacity());
painter.blit(src_rect.location(), *m_left_right, src_rect.translated(-rect_in_frame.location()));
}
if (m_right_x < left_right_width) {
// We have a right piece
Gfx::IntRect rect_in_frame { window_rect.right(), window_rect.y(), left_right_width - m_right_x, window_rect.height() };
auto src_rect = rect.intersected(rect_in_frame);
if (!src_rect.is_empty())
painter.blit(src_rect.location(), *m_left_right, src_rect.translated(-rect_in_frame.x() + m_right_x, -rect_in_frame.y()), frame.opacity());
painter.blit(src_rect.location(), *m_left_right, src_rect.translated(-rect_in_frame.x() + m_right_x, -rect_in_frame.y()));
}
}
}
Expand Down Expand Up @@ -549,18 +549,6 @@ void WindowFrame::PerScaleRenderedCache::render(WindowFrame& frame, Screen& scre
m_shadow_dirty = false;
}

void WindowFrame::set_opacity(float opacity)
{
if (m_opacity == opacity)
return;
bool was_opaque = is_opaque();
m_opacity = opacity;
if (was_opaque != is_opaque())
Compositor::the().invalidate_occlusions();
Compositor::the().invalidate_screen(render_rect());
WindowManager::the().notify_opacity_changed(m_window);
}

Gfx::IntRect WindowFrame::inflated_for_shadow(Gfx::IntRect const& frame_rect) const
{
if (auto* shadow = shadow_bitmap()) {
Expand Down
10 changes: 1 addition & 9 deletions Userland/Services/WindowServer/WindowFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,9 @@ class WindowFrame {
void set_has_alpha_channel(bool value) { m_has_alpha_channel = value; }
bool has_shadow() const;

void set_opacity(float);
float opacity() const { return m_opacity; }

bool is_opaque() const
{
if (opacity() < 1.0f)
return false;
if (has_alpha_channel())
return false;
return true;
return !has_alpha_channel();
}

void set_dirty(bool re_render_shadow = false)
Expand Down Expand Up @@ -148,7 +141,6 @@ class WindowFrame {

RefPtr<Core::Timer> m_flash_timer;
size_t m_flash_counter { 0 };
float m_opacity { 1 };
bool m_has_alpha_channel { false };
};

Expand Down

0 comments on commit c3f5b51

Please sign in to comment.