diff --git a/base-sysroot.tar.gz b/base-sysroot.tar.gz index 4ed71e86..826e7a70 100644 Binary files a/base-sysroot.tar.gz and b/base-sysroot.tar.gz differ diff --git a/userspace/programs/WindowServer/WindowServer.cpp b/userspace/programs/WindowServer/WindowServer.cpp index c7760e64..5be523aa 100644 --- a/userspace/programs/WindowServer/WindowServer.cpp +++ b/userspace/programs/WindowServer/WindowServer.cpp @@ -13,8 +13,9 @@ #include -WindowServer::WindowServer(Framebuffer& framebuffer) +WindowServer::WindowServer(Framebuffer& framebuffer, int32_t corner_radius) : m_framebuffer(framebuffer) + , m_corner_radius(corner_radius) , m_cursor({ framebuffer.width / 2, framebuffer.height / 2 }) , m_font(MUST(LibFont::Font::load("/usr/share/fonts/lat0-16.psfu"_sv))) { @@ -338,45 +339,43 @@ void WindowServer::invalidate(Rectangle area) { auto& window = *pwindow; - const int32_t corner_radius = 5; - const Rectangle fast_areas[] { { - window.full_x() + corner_radius, + window.full_x() + m_corner_radius, window.full_y(), - window.full_width() - 2 * corner_radius, - corner_radius + window.full_width() - 2 * m_corner_radius, + m_corner_radius }, { window.full_x(), - window.full_y() + corner_radius, + window.full_y() + m_corner_radius, window.full_width(), - window.full_height() - 2 * corner_radius + window.full_height() - 2 * m_corner_radius }, { - window.full_x() + corner_radius, - window.full_y() + window.full_height() - corner_radius, - window.full_width() - 2 * corner_radius, - corner_radius + window.full_x() + m_corner_radius, + window.full_y() + window.full_height() - m_corner_radius, + window.full_width() - 2 * m_corner_radius, + m_corner_radius } }; const Position corner_centers[] { { - window.full_x() + corner_radius, - window.full_y() + corner_radius, + window.full_x() + m_corner_radius, + window.full_y() + m_corner_radius, }, { - window.full_x() + (window.full_width() - 1) - corner_radius, - window.full_y() + corner_radius, + window.full_x() + (window.full_width() - 1) - m_corner_radius, + window.full_y() + m_corner_radius, }, { - window.full_x() + corner_radius, - window.full_y() + (window.full_height() - 1) - corner_radius, + window.full_x() + m_corner_radius, + window.full_y() + (window.full_height() - 1) - m_corner_radius, }, { - window.full_x() + (window.full_width() - 1) - corner_radius, - window.full_y() + (window.full_height() - 1) - corner_radius, + window.full_x() + (window.full_width() - 1) - m_corner_radius, + window.full_y() + (window.full_height() - 1) - m_corner_radius, }, }; @@ -384,26 +383,26 @@ void WindowServer::invalidate(Rectangle area) { window.full_x(), window.full_y(), - corner_radius, - corner_radius + m_corner_radius, + m_corner_radius }, { - window.full_x() + window.full_width() - corner_radius, + window.full_x() + window.full_width() - m_corner_radius, window.full_y(), - corner_radius, - corner_radius + m_corner_radius, + m_corner_radius }, { window.full_x(), - window.full_y() + window.full_height() - corner_radius, - corner_radius, - corner_radius + window.full_y() + window.full_height() - m_corner_radius, + m_corner_radius, + m_corner_radius }, { - window.full_x() + window.full_width() - corner_radius, - window.full_y() + window.full_height() - corner_radius, - corner_radius, - corner_radius + window.full_x() + window.full_width() - m_corner_radius, + window.full_y() + window.full_height() - m_corner_radius, + m_corner_radius, + m_corner_radius } }; @@ -418,7 +417,7 @@ void WindowServer::invalidate(Rectangle area) const int32_t dy = pos.y - corner_centers[i].y; if (2 * (dy > 0) + (dx > 0) != i) continue; - if (dx * dx + dy * dy >= corner_radius * corner_radius) + if (dx * dx + dy * dy >= m_corner_radius * m_corner_radius) return true; } return false; diff --git a/userspace/programs/WindowServer/WindowServer.h b/userspace/programs/WindowServer/WindowServer.h index 7365882d..fb6e22db 100644 --- a/userspace/programs/WindowServer/WindowServer.h +++ b/userspace/programs/WindowServer/WindowServer.h @@ -19,7 +19,7 @@ class WindowServer { public: - WindowServer(Framebuffer& framebuffer); + WindowServer(Framebuffer& framebuffer, int32_t corner_radius); BAN::ErrorOr set_background_image(BAN::UniqPtr); @@ -48,6 +48,8 @@ private: BAN::Vector> m_client_windows; BAN::Vector m_client_fds; + const int32_t m_corner_radius; + BAN::Vector m_pages_to_sync_bitmap; BAN::UniqPtr m_background_image; diff --git a/userspace/programs/WindowServer/main.cpp b/userspace/programs/WindowServer/main.cpp index 755b6fdc..2d341b07 100644 --- a/userspace/programs/WindowServer/main.cpp +++ b/userspace/programs/WindowServer/main.cpp @@ -19,6 +19,7 @@ struct Config { BAN::UniqPtr background_image; + int32_t corner_radius = 0; }; BAN::Optional file_read_line(FILE* file) @@ -88,6 +89,15 @@ Config parse_config() else config.background_image = image.release_value(); } + else if (variable == "corner-radius"_sv) + { + char* endptr = nullptr; + long corner_radius = strtol(value.data(), &endptr, 0); + if (corner_radius < 0 || corner_radius == LONG_MAX || corner_radius >= INT32_MAX) + dwarnln("invalid corner-radius: '{}'", value); + else + config.corner_radius = corner_radius; + } else { dwarnln("Unknown config variable: {}", variable); @@ -176,7 +186,7 @@ int main() auto config = parse_config(); - WindowServer window_server(framebuffer); + WindowServer window_server(framebuffer, config.corner_radius); if (config.background_image) if (auto ret = window_server.set_background_image(BAN::move(config.background_image)); ret.is_error()) dwarnln("Could not set background image: {}", ret.error());