From 0c5ecd303cb2e73d1226433b6b0f588f776af766 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 14 Jan 2019 15:25:34 +0100 Subject: Share GraphicsBitmaps between the windowing server and the client process. This is pretty cool. :^) GraphicsBitmaps are now mapped into both the server and the client address space (usually at different addresses but that doesn't matter.) Added a GUI syscall for getting a window's backing store, and another one for invalidating a window so that the server redraws it. --- Userland/guitest.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'Userland/guitest.cpp') diff --git a/Userland/guitest.cpp b/Userland/guitest.cpp index 48af3a9d24..c8341b6db8 100644 --- a/Userland/guitest.cpp +++ b/Userland/guitest.cpp @@ -7,6 +7,13 @@ #include #include #include +#include + +int gui_invalidate_window(int window_id) +{ + int rc = syscall(SC_gui_invalidate_window, window_id); + __RETURN_WITH_ERRNO(rc, rc, -1); +} int main(int argc, char** argv) { @@ -26,6 +33,23 @@ int main(int argc, char** argv) return 1; } + GUI_WindowBackingStoreInfo backing; + int rc = syscall(SC_gui_get_window_backing_store, window_id, &backing); + if (rc < 0) { + perror("gui_get_window_backing_store"); + return 1; + } + + sys_printf("(Client) window backing %ux%u @ %p\n", backing.size.width, backing.size.height, backing.pixels); + + fast_dword_fill(backing.pixels, 0x00ff00, backing.size.width * backing.size.height); + + rc = gui_invalidate_window(window_id); + if (rc < 0) { + perror("gui_invalidate_window"); + return 1; + } + for (;;) { GUI_Event event; ssize_t nread = read(fd, &event, sizeof(event)); @@ -41,6 +65,15 @@ int main(int argc, char** argv) case GUI_Event::Type::MouseMove: sys_printf("WID=%x MouseMove %d,%d\n", event.window_id, event.mouse.position.x, event.mouse.position.y); break; } + if (event.type == GUI_Event::Type::MouseDown) { + byte r = rand() % 255; + byte g = rand() % 255; + byte b = rand() % 255; + Color color(r, g, b); + fast_dword_fill(backing.pixels, color.value(), backing.size.width * backing.size.height); + gui_invalidate_window(window_id); + } + } return 0; } -- cgit v1.2.3