mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:17:35 +00:00
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.
This commit is contained in:
parent
b0e3f73375
commit
0c5ecd303c
13 changed files with 139 additions and 46 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue