diff options
author | Christopher Dumas <christopherdumas@gmail.com> | 2019-05-26 10:14:03 -0700 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-27 21:40:53 +0200 |
commit | c23882dde1f8a46f82b599ece5bb4b59606d030b (patch) | |
tree | 549ca3ad885aab8706ef2ff489f5b5b1558d9a33 /Servers/WindowServer | |
parent | 50154a23cbd51f72eeb199b8b56acfa8d7bb694a (diff) | |
download | serenity-c23882dde1f8a46f82b599ece5bb4b59606d030b.zip |
can now tile background and made sure the IRC choose server popup still works
Diffstat (limited to 'Servers/WindowServer')
-rw-r--r-- | Servers/WindowServer/WSCompositor.cpp | 26 | ||||
-rw-r--r-- | Servers/WindowServer/WSCompositor.h | 3 | ||||
-rw-r--r-- | Servers/WindowServer/WSWindowManager.cpp | 35 | ||||
-rw-r--r-- | Servers/WindowServer/WSWindowManager.h | 3 |
4 files changed, 57 insertions, 10 deletions
diff --git a/Servers/WindowServer/WSCompositor.cpp b/Servers/WindowServer/WSCompositor.cpp index ef2b1fd87e..069a82b263 100644 --- a/Servers/WindowServer/WSCompositor.cpp +++ b/Servers/WindowServer/WSCompositor.cpp @@ -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 { diff --git a/Servers/WindowServer/WSCompositor.h b/Servers/WindowServer/WSCompositor.h index f0ea27bf14..ea65bd24bf 100644 --- a/Servers/WindowServer/WSCompositor.h +++ b/Servers/WindowServer/WSCompositor.h @@ -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; }; diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp index 0a534ab43d..1c8f594f13 100644 --- a/Servers/WindowServer/WSWindowManager.cpp +++ b/Servers/WindowServer/WSWindowManager.cpp @@ -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); diff --git a/Servers/WindowServer/WSWindowManager.h b/Servers/WindowServer/WSWindowManager.h index 328fe63dd2..9192a35860 100644 --- a/Servers/WindowServer/WSWindowManager.h +++ b/Servers/WindowServer/WSWindowManager.h @@ -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); |