Compare commits

...

2 Commits

Author SHA1 Message Date
Bananymous 0228cd4f31 Kernel: Increase userspace stack size and decrease kernel stack
Quake II needs a lot of stack, it was overflowing my 256 KiB stack so
this patch doubles that, so Quake II can run!

Also every thread had 256 KiB kernel stack. This is unnecessarily large
and now dropped to 32 KiB.
2024-11-14 21:03:04 +02:00
Bananymous a859558840 LibGUI: Window Creation takes attributes as an argument
This reduces windows showing/moving once they are opened and setting
their attributes.
2024-11-14 20:57:34 +02:00
7 changed files with 23 additions and 21 deletions

View File

@ -103,8 +103,8 @@ namespace Kernel
// {kernel,userspace}_stack has to be destroyed before page table
BAN::UniqPtr<PageTable> m_keep_alive_page_table;
static constexpr size_t m_kernel_stack_size { PAGE_SIZE * 64 };
static constexpr size_t m_userspace_stack_size { PAGE_SIZE * 64 };
static constexpr size_t m_kernel_stack_size { PAGE_SIZE * 8 };
static constexpr size_t m_userspace_stack_size { PAGE_SIZE * 128 };
BAN::UniqPtr<VirtualRange> m_kernel_stack;
BAN::UniqPtr<VirtualRange> m_userspace_stack;
const pid_t m_tid { 0 };

View File

@ -62,7 +62,7 @@ namespace LibGUI
cleanup();
}
BAN::ErrorOr<BAN::UniqPtr<Window>> Window::create(uint32_t width, uint32_t height, BAN::StringView title)
BAN::ErrorOr<BAN::UniqPtr<Window>> Window::create(uint32_t width, uint32_t height, BAN::StringView title, Attributes attributes)
{
int server_fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (server_fd == -1)
@ -101,7 +101,7 @@ namespace LibGUI
TRY(create_packet.title.append(title));
TRY(create_packet.send_serialized(server_fd));
auto window = TRY(BAN::UniqPtr<Window>::create(server_fd));
auto window = TRY(BAN::UniqPtr<Window>::create(server_fd, attributes));
bool resized = false;
window->set_resize_window_event_callback([&]() { resized = true; });

View File

@ -178,10 +178,20 @@ namespace LibGUI
namespace WindowPacket
{
struct Attributes
{
bool title_bar;
bool movable;
bool focusable;
bool rounded_corners;
bool alpha_channel;
};
DEFINE_PACKET(
WindowCreate,
uint32_t, width,
uint32_t, height,
Attributes, attributes,
BAN::String, title
);
@ -199,15 +209,8 @@ namespace LibGUI
int32_t, y
);
DEFINE_PACKET_EXTRA(
DEFINE_PACKET(
WindowSetAttributes,
struct Attributes {
bool title_bar;
bool movable;
bool focusable;
bool rounded_corners;
bool alpha_channel;
},
Attributes, attributes
);

View File

@ -14,7 +14,7 @@ namespace LibGUI
class Window
{
public:
using Attributes = WindowPacket::WindowSetAttributes::Attributes;
using Attributes = WindowPacket::Attributes;
static constexpr Attributes default_attributes = {
.title_bar = true,
@ -27,7 +27,7 @@ namespace LibGUI
public:
~Window();
static BAN::ErrorOr<BAN::UniqPtr<Window>> create(uint32_t width, uint32_t height, BAN::StringView title);
static BAN::ErrorOr<BAN::UniqPtr<Window>> create(uint32_t width, uint32_t height, BAN::StringView title, Attributes attributes = default_attributes);
void set_pixel(uint32_t x, uint32_t y, uint32_t color)
{
@ -87,8 +87,9 @@ namespace LibGUI
int server_fd() const { return m_server_fd; }
private:
Window(int server_fd)
Window(int server_fd, Attributes attributes)
: m_server_fd(server_fd)
, m_attributes(attributes)
{ }
bool clamp_to_framebuffer(int32_t& x, int32_t& y, uint32_t& width, uint32_t& height) const;

View File

@ -22,15 +22,14 @@ int main()
auto font = MUST(LibFont::Font::load("/usr/share/fonts/lat0-16.psfu"_sv));
auto window = MUST(LibGUI::Window::create(0, font.height() + 2 * padding, "TaskBar"));
auto attributes = LibGUI::Window::default_attributes;
attributes.title_bar = false;
attributes.movable = false;
attributes.focusable = false;
attributes.alpha_channel = false;
attributes.rounded_corners = false;
window->set_attributes(attributes);
auto window = MUST(LibGUI::Window::create(0, font.height() + 2 * padding, "TaskBar", attributes));
window->set_close_window_event_callback([]() {});

View File

@ -110,12 +110,10 @@ void Terminal::run()
m_bg_color = s_colors_dark[0];
m_fg_color = s_colors_bright[7];
m_window = MUST(LibGUI::Window::create(600, 400, "Terminal"_sv));
auto attributes = LibGUI::Window::default_attributes;
attributes.alpha_channel = true;
m_window->set_attributes(attributes);
m_window = MUST(LibGUI::Window::create(600, 400, "Terminal"_sv, attributes));
m_window->fill(m_bg_color);
m_window->invalidate();

View File

@ -67,6 +67,7 @@ void WindowServer::on_window_create(int fd, const LibGUI::WindowPacket::WindowCr
return;
}
window->set_attributes(packet.attributes);
window->set_position({
static_cast<int32_t>((m_framebuffer.width - window->client_width()) / 2),
static_cast<int32_t>((m_framebuffer.height - window->client_height()) / 2),