diff --git a/sysdata/libraries/sunset_proto/src/server.hb b/sysdata/libraries/sunset_proto/src/server.hb index 0b0319a..4850ce6 100644 --- a/sysdata/libraries/sunset_proto/src/server.hb +++ b/sysdata/libraries/sunset_proto/src/server.hb @@ -1,5 +1,5 @@ .{math, log, string, random, buffer, memory} := @use("../../stn/src/lib.hb"); -.{Color, Surface, new_surface, put_surface, sync, put_rect, put_filled_rect, text, put_text} := @use("../../render/src/lib.hb"); +.{Color, Surface, new_surface, put_surface, sync, put_rect, put_filled_rect, text, put_text, clear, white, black} := @use("../../render/src/lib.hb"); .{Channel, Window, WindowProps, WindowData, MessageHeader, BUFFER_SERVER, BUFFER_CLIENT, message, permissions, recv_header, recv_message, send_message, send_header, await_message} := @use("./lib.hb") WindowServer := struct { @@ -50,8 +50,17 @@ incoming := fn(): bool { surface := new_window_decorations(data.props.dimensions) // decorations { - put_filled_rect(surface, .(0, 0), data.props.dimensions + .(DECO_WIDTH, DECO_HEIGHT_TOP + DECO_HEIGHT_BOTTOM), DECO_COLOUR) - put_filled_rect(surface, .(0, 0), .(data.props.dimensions.x + DECO_WIDTH, DECO_HEIGHT_TOP), DECO_COLOUR) + title := data.props.title + title_length := string.length(title) + deco_length := title_length * 10 + // draw the window tab bar + put_filled_rect(surface, .(0, 0), .(data.props.dimensions.x + DECO_WIDTH + deco_length, DECO_HEIGHT_TOP), DECO_COLOUR) + // Draw the window tab + put_filled_rect(surface, .(0, 0), .(deco_length, DECO_HEIGHT_TOP - 1), DECO_COLOUR_DARKER) + + // Draw the outside box + put_rect(surface, .(0, 0), data.props.dimensions + .(DECO_WIDTH - 1, DECO_HEIGHT_TOP + DECO_HEIGHT_BOTTOM - 1), DECO_COLOUR) + put_text(surface, server.font, .(2, 1), .(0, 0, 0, 255), data.props.title) } server.windows[server.window_count] = .(data, surface) @@ -64,6 +73,7 @@ $DECO_WIDTH := 2 $DECO_HEIGHT_TOP := 20 $DECO_HEIGHT_BOTTOM := 1 $DECO_COLOUR := Color.(100, 200, 255, 255) +$DECO_COLOUR_DARKER := Color.(89, 57, 89, 255) new_window_decorations := fn(dimensions: math.Vec2(uint)): Surface { return new_surface( @@ -122,5 +132,4 @@ render_clients := fn(screen: Surface): void { put_surface(screen, window.surface, window.data.props.position, false) i += 1 } - sync(screen) } \ No newline at end of file diff --git a/sysdata/programs/sunset_server/src/main.hb b/sysdata/programs/sunset_server/src/main.hb index 96f749e..b0ad252 100644 --- a/sysdata/programs/sunset_server/src/main.hb +++ b/sysdata/programs/sunset_server/src/main.hb @@ -1,11 +1,69 @@ sunset := @use("../../../libraries/sunset_proto/src/lib.hb") render := @use("../../../libraries/render/src/lib.hb") +intouch := @use("../../../libraries/intouch/src/lib.hb") main := fn(): void { screen := render.init(true) sunset.server.start() - loop if sunset.server.incoming() { - sunset.server.collect_frames() - sunset.server.render_clients(screen) + render.clear(screen, render.black) + + mouse_x := 0 + mouse_y := 0 + + loop { + mouse_event := intouch.recieve_mouse_event() + if mouse_event != null { + change_x := @as(i16, mouse_event.x_change) + change_x = change_x << 8 + change_x = change_x >> 8 + + mouse_x += change_x + if mouse_x < 0 { + mouse_x = 0 + } + if mouse_x >= screen.width - 20 { + mouse_x = @intcast(screen.width - 21) + } + + change_y := @as(i16, mouse_event.y_change) + change_y = change_y << 8 + change_y = change_y >> 8 + + if mouse_y < 0 { + mouse_y = 0 + } + if mouse_y >= screen.height - 20 { + mouse_y = @intcast(screen.height - 21) + } + mouse_y -= change_y + + if mouse_event.left { + // set_label_text(text_label, "LEFT CLICK\0") + } + if mouse_event.middle { + // set_label_text(text_label, "MIDDLE CLICK\0") + } + if mouse_event.right { + // set_label_text(text_label, "RIGHT CLICK\0") + } + } + { + // render.clear(screen, render.black) + } + + if sunset.server.incoming() { + // render.clear(screen, render.black) + // + sunset.server.collect_frames() + sunset.server.render_clients(screen) + } + + // Mouse cursor + { + render.put_filled_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.black) + render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.white) + } + + render.sync(screen) } } \ No newline at end of file diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index b4fe670..5a32b3e 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -28,8 +28,8 @@ resolution = "1024x768x24" # [boot.limine.ableos.modules.horizon] # path = "boot:///horizon.hbf" -# [boot.limine.ableos.modules.ps2_mouse_driver] -# path = "boot:///ps2_mouse_driver.hbf" +[boot.limine.ableos.modules.ps2_mouse_driver] +path = "boot:///ps2_mouse_driver.hbf" # [boot.limine.ableos.modules.ps2_keyboard_driver] # path = "boot:///ps2_keyboard_driver.hbf"