1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 18:37:34 +00:00

WindowServer+Taskbar: Send WM icon updates as Gfx::ShareableBitmap

Window icons in Taskbar were previously received in WM events with
shbuf ID's. Now that Gfx::ShareableBitmap is backed by anonymous files,
we can easily switch to using those.
This commit is contained in:
Andreas Kling 2021-01-15 23:13:24 +01:00
parent 633915e792
commit 333366a99d
9 changed files with 17 additions and 35 deletions

View file

@ -32,6 +32,7 @@
#include <LibCore/Event.h>
#include <LibGUI/FocusSource.h>
#include <LibGUI/WindowType.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Point.h>
#include <LibGfx/Rect.h>
@ -172,19 +173,16 @@ private:
class WMWindowIconBitmapChangedEvent : public WMEvent {
public:
WMWindowIconBitmapChangedEvent(int client_id, int window_id, int icon_buffer_id, const Gfx::IntSize& icon_size)
WMWindowIconBitmapChangedEvent(int client_id, int window_id, const Gfx::Bitmap* bitmap)
: WMEvent(Event::Type::WM_WindowIconBitmapChanged, client_id, window_id)
, m_icon_buffer_id(icon_buffer_id)
, m_icon_size(icon_size)
, m_bitmap(move(bitmap))
{
}
int icon_buffer_id() const { return m_icon_buffer_id; }
const Gfx::IntSize& icon_size() const { return m_icon_size; }
const Gfx::Bitmap* bitmap() const { return m_bitmap; }
private:
int m_icon_buffer_id;
Gfx::IntSize m_icon_size;
RefPtr<Gfx::Bitmap> m_bitmap;
};
class MultiPaintEvent final : public Event {

View file

@ -777,8 +777,7 @@ void Window::apply_icon()
if (!is_visible())
return;
auto icon = m_icon->to_shareable_bitmap();
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowIconBitmap>(m_window_id, icon);
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowIconBitmap>(m_window_id, m_icon->to_shareable_bitmap());
}
void Window::start_wm_resize()

View file

@ -289,8 +289,9 @@ void WindowServerConnection::handle(const Messages::WindowClient::WM_WindowRectC
void WindowServerConnection::handle(const Messages::WindowClient::WM_WindowIconBitmapChanged& message)
{
if (auto* window = Window::from_window_id(message.wm_id()))
Core::EventLoop::current().post_event(*window, make<WMWindowIconBitmapChangedEvent>(message.client_id(), message.window_id(), message.icon_buffer_id(), message.icon_size()));
if (auto* window = Window::from_window_id(message.wm_id())) {
Core::EventLoop::current().post_event(*window, make<WMWindowIconBitmapChangedEvent>(message.client_id(), message.window_id(), message.bitmap().bitmap()));
}
}
void WindowServerConnection::handle(const Messages::WindowClient::WM_WindowRemoved& message)

View file

@ -60,7 +60,7 @@ bool decode(Decoder& decoder, Gfx::ShareableBitmap& shareable_bitmap)
if (!decoder.decode(size))
return false;
auto bitmap = Gfx::Bitmap::create_with_anon_fd(Gfx::BitmapFormat::RGBA32, anon_file.fd(), size, Gfx::Bitmap::ShouldCloseAnonymousFile::No);
auto bitmap = Gfx::Bitmap::create_with_anon_fd(Gfx::BitmapFormat::RGBA32, anon_file.take_fd(), size, Gfx::Bitmap::ShouldCloseAnonymousFile::Yes);
shareable_bitmap = bitmap->to_shareable_bitmap();
return true;
}