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

can now tile background and made sure the IRC choose server popup still works

This commit is contained in:
Christopher Dumas 2019-05-26 10:14:03 -07:00 committed by Andreas Kling
parent 50154a23cb
commit c23882dde1
15 changed files with 127 additions and 44 deletions

View file

@ -16,6 +16,16 @@ WSCompositor& WSCompositor::the()
return s_the;
}
WallpaperMode mode_to_enum(const String& name)
{
if (name == "simple")
return WallpaperMode::Simple;
if (name == "tile")
return WallpaperMode::Tile;
if (name == "center")
return WallpaperMode::Center;
}
WSCompositor::WSCompositor()
{
auto size = WSScreen::the().size();
@ -49,6 +59,9 @@ WSCompositor::WSCompositor()
void WSCompositor::compose()
{
auto& wm = WSWindowManager::the();
if (m_wallpaper_mode == WallpaperMode::Unchecked)
m_wallpaper_mode = mode_to_enum(wm.wm_config()->read_entry("Background", "Mode", "simple"));
auto& ws = WSScreen::the();
auto dirty_rects = move(m_dirty_rects);
@ -77,8 +90,17 @@ void WSCompositor::compose()
if (wm.any_opaque_window_contains_rect(dirty_rect))
continue;
m_back_painter->fill_rect(dirty_rect, wm.m_background_color);
if (m_wallpaper)
m_back_painter->blit(dirty_rect.location(), *m_wallpaper, dirty_rect);
if (m_wallpaper) {
if (m_wallpaper_mode == WallpaperMode::Simple ||
m_wallpaper_mode == WallpaperMode::Unchecked) {
m_back_painter->blit(dirty_rect.location(), *m_wallpaper, dirty_rect);
} else if (m_wallpaper_mode == WallpaperMode::Center) {
// TODO: Implement centered wallpaper
m_back_painter->blit(dirty_rect.location(), *m_wallpaper, dirty_rect);
} else if (m_wallpaper_mode == WallpaperMode::Tile) {
m_back_painter->blit_tiled(dirty_rect.location(), *m_wallpaper, dirty_rect);
}
}
}
auto compose_window = [&] (WSWindow& window) -> IterationDecision {

View file

@ -10,6 +10,8 @@
class Painter;
class WSCursor;
enum class WallpaperMode { Simple, Tile, Center, Unchecked };
class WSCompositor final : public CObject {
public:
static WSCompositor& the();
@ -55,5 +57,6 @@ private:
Rect m_last_geometry_label_rect;
String m_wallpaper_path;
WallpaperMode m_wallpaper_mode { WallpaperMode::Unchecked };
RetainPtr<GraphicsBitmap> m_wallpaper;
};

View file

@ -112,6 +112,25 @@ WSWindowManager::~WSWindowManager()
{
}
Retained<WSCursor> WSWindowManager::get_cursor(const String& name, const Point& hotspot)
{
auto path = m_wm_config->read_entry("Cursor", name, "/res/cursors/arrow.png");
auto gb = GraphicsBitmap::load_from_file(path);
if (gb)
return WSCursor::create(*gb, hotspot);
return WSCursor::create(*GraphicsBitmap::load_from_file("/res/cursors/arrow.png"));
}
Retained<WSCursor> WSWindowManager::get_cursor(const String& name)
{
auto path = m_wm_config->read_entry("Cursor", name, "/res/cursors/arrow.png");
auto gb = GraphicsBitmap::load_from_file(path);
if (gb)
return WSCursor::create(*gb);
return WSCursor::create(*GraphicsBitmap::load_from_file("/res/cursors/arrow.png"));
}
void WSWindowManager::reload_config(bool set_screen)
{
m_wm_config = CConfigFile::get_for_app("WindowManager");
@ -122,14 +141,14 @@ void WSWindowManager::reload_config(bool set_screen)
set_resolution(m_wm_config->read_num_entry("Screen", "Width", 1920),
m_wm_config->read_num_entry("Screen", "Height", 1080));
m_arrow_cursor = WSCursor::create(*GraphicsBitmap::load_from_file(m_wm_config->read_entry("Cursor", "Arrow", "")), { 2, 2 });
m_resize_horizontally_cursor = WSCursor::create(*GraphicsBitmap::load_from_file(m_wm_config->read_entry("Cursor", "ResizeH", "")));
m_resize_vertically_cursor = WSCursor::create(*GraphicsBitmap::load_from_file(m_wm_config->read_entry("Cursor", "ResizeV", "")));
m_resize_diagonally_tlbr_cursor = WSCursor::create(*GraphicsBitmap::load_from_file(m_wm_config->read_entry("Cursor", "ResizeDTLBR", "")));
m_resize_diagonally_bltr_cursor = WSCursor::create(*GraphicsBitmap::load_from_file(m_wm_config->read_entry("Cursor", "ResizeDBLTR", "")));
m_i_beam_cursor = WSCursor::create(*GraphicsBitmap::load_from_file(m_wm_config->read_entry("Cursor", "IBeam", "")));
m_disallowed_cursor = WSCursor::create(*GraphicsBitmap::load_from_file(m_wm_config->read_entry("Cursor", "Disallowed", "")));
m_move_cursor = WSCursor::create(*GraphicsBitmap::load_from_file(m_wm_config->read_entry("Cursor", "Move", "")));
m_arrow_cursor = get_cursor("Arrow", { 2, 2 });
m_resize_horizontally_cursor = get_cursor("ResizeH");
m_resize_vertically_cursor = get_cursor("ResizeV");
m_resize_diagonally_tlbr_cursor = get_cursor("ResizeDTLBR");
m_resize_diagonally_bltr_cursor = get_cursor("ResizeDBLTR");
m_i_beam_cursor = get_cursor("IBeam");
m_disallowed_cursor = get_cursor("Disallowed");
m_move_cursor = get_cursor("Move");
m_background_color = m_wm_config->read_color_entry("Colors", "Background", Color::Red);

View file

@ -121,6 +121,9 @@ public:
WSWindow* active_fullscreen_window() { return (m_active_window && m_active_window->is_fullscreen()) ? m_active_window : nullptr; }
private:
Retained<WSCursor> get_cursor(const String& name);
Retained<WSCursor> get_cursor(const String& name, const Point& hotspot);
void process_mouse_event(WSMouseEvent&, WSWindow*& hovered_window);
void process_event_for_doubleclick(WSWindow& window, WSMouseEvent& event);
void deliver_mouse_event(WSWindow& window, WSMouseEvent& event);