summaryrefslogtreecommitdiff
path: root/Userland/guitest.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-01-14 15:25:34 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-01-14 15:25:34 +0100
commit0c5ecd303cb2e73d1226433b6b0f588f776af766 (patch)
tree782ee8da40f8d61bf519b3d24e75b2f1bfe0e89d /Userland/guitest.cpp
parentb0e3f733759a006622b14f75c5379641ef82776f (diff)
downloadserenity-0c5ecd303cb2e73d1226433b6b0f588f776af766.zip
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.
Diffstat (limited to 'Userland/guitest.cpp')
-rw-r--r--Userland/guitest.cpp33
1 files changed, 33 insertions, 0 deletions
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 <assert.h>
#include <Kernel/GUITypes.h>
#include <Kernel/Syscall.h>
+#include <AK/StdLibExtras.h>
+
+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;
}