(sunset) fix mouse cursor and one multi-program crash bug

This commit is contained in:
koniifer 2024-12-26 00:38:46 +00:00
parent 530b62aa3d
commit 986077435f
7 changed files with 28 additions and 50 deletions

6
Cargo.lock generated
View file

@ -213,12 +213,12 @@ dependencies = [
[[package]]
name = "hbbytecode"
version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#3491814b4f1723e6b1f3ae485ed5d3b5cad16df0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#08fc9d6ab6a8dd539255bf45d892f4b7f08776c5"
[[package]]
name = "hblang"
version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#3491814b4f1723e6b1f3ae485ed5d3b5cad16df0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#08fc9d6ab6a8dd539255bf45d892f4b7f08776c5"
dependencies = [
"hashbrown",
"hbbytecode",
@ -229,7 +229,7 @@ dependencies = [
[[package]]
name = "hbvm"
version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#3491814b4f1723e6b1f3ae485ed5d3b5cad16df0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#08fc9d6ab6a8dd539255bf45d892f4b7f08776c5"
dependencies = [
"hbbytecode",
]

View file

@ -61,8 +61,8 @@ impl hbvm::mem::Memory for Memory {
#[inline(always)]
fn log_instr(&mut self, at: Address, regs: &[hbvm::value::Value]) {
//log::debug!("exec: [{:02x}] {}", at.get(), unsafe {
// self.logger.display_instr(at, regs)
//});
log::debug!("exec: [{:02x}] {}", at.get(), unsafe {
self.logger.display_instr(at, regs)
});
}
}

View file

@ -1,5 +1,3 @@
string := @use("string.hb")
$await := fn(buffer_id: uint): void {
return @eca(7, buffer_id)
}
@ -30,7 +28,7 @@ $create_nameless := fn(): uint {
return @eca(1, 0)
}
$delete_buffer := fn(buffer_id: uint): void {
$delete := fn(buffer_id: uint): void {
return @eca(2, buffer_id)
}

View file

@ -26,6 +26,9 @@ $max := fn($T: type, a: T, b: T): T {
return @itf(a > b) * a + @itf(a <= b) * b
}
}
$clamp := fn($T: type, x: T, minimum: T, maximum: T): T {
return max(T, min(T, x, maximum), minimum)
}
$sign := fn($T: type, x: T): i8 {
if signed_int(T) {
return @intcast(x >> @sizeof(T) * 8 - 1) | x != 0

View file

@ -100,7 +100,8 @@ collect_frames := fn(): void {
send_header(message.ack, window.data.channel.client)
ptr := await_message(^Color, window.data.channel.server)
if ptr.header.kind != message.ack {
return
i += 1
continue
}
window.surface.put_surface(
Surface.(

View file

@ -6,14 +6,14 @@ horizon_api := @use("lib:horizon_api");
.{set_color, render_label_to_surface, Label} := horizon_api.widgets.label
stn := @use("stn");
.{Vec2} := stn.math
.{Vec2, clamp} := stn.math
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
img := @embed("sysdata:assets/wallpaper.qoi")
Mouse := struct {
x: uint,
y: uint,
x: int,
y: int,
// TODO: Make this configurable via wm config
cursor_width: u8,
@ -24,7 +24,7 @@ Mouse := struct {
center_x := max_x / 2
center_y := max_y / 2
return Self.(center_x, center_y, 3, max_x, max_y)
return Self.(@bitcast(center_x), @bitcast(center_y), 3, max_x, max_y)
}
/*
center := fn(self: Self){
@ -63,51 +63,26 @@ main := fn(): int {
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
mouse.y -= change_y
if mouse.y < 0 {
mouse.y = 1
}
if mouse.y >= screen.height - 20 {
mouse.y = @intcast(screen.height - 21)
}
mouse.x = clamp(int, mouse.x + mouse_event.x_change, mouse.cursor_width, @bitcast(screen.width - mouse.cursor_width))
mouse.y = clamp(int, mouse.y - mouse_event.y_change, mouse.cursor_width, @bitcast(screen.height - mouse.cursor_width))
if mouse_event.left {
text_label.set_label_text("LEFT CLICK")
}
if mouse_event.middle {
} else if mouse_event.middle {
text_label.set_label_text("MIDDLE CLICK")
}
if mouse_event.right {
} else if mouse_event.right {
text_label.set_label_text("RIGHT CLICK")
}
}
{
screen.clear(render.BLACK)
screen.put_surface(wallpaper, .(0, 0), false)
screen.put_rect(.(0, 0), .(screen.width - 1, screen.height - 1), sunset.server.DECO_COLOUR)
}
if sunset.server.incoming() {
_ = sunset.server.incoming()
sunset.server.collect_frames()
sunset.server.render_clients(screen)
}
{
/* Omnibar */
@ -119,8 +94,9 @@ main := fn(): int {
// Mouse cursor
{
screen.put_filled_circle(.(mouse.x, mouse.y), mouse.cursor_width, sunset.server.DECO_COLOUR_DARKER)
screen.put_circle(.(mouse.x, mouse.y), mouse.cursor_width, sunset.server.DECO_COLOUR)
p := Vec2(uint).(@bitcast(mouse.x), @bitcast(mouse.y))
screen.put_filled_circle(p, mouse.cursor_width, sunset.server.DECO_COLOUR_DARKER)
screen.put_circle(p, mouse.cursor_width, sunset.server.DECO_COLOUR)
}
screen.sync()

View file

@ -38,8 +38,8 @@ resolution = "1024x768x24"
# [boot.limine.ableos.modules.ps2_driver]
# path = "boot:///ps2_driver.hbf"
# [boot.limine.ableos.modules.sunset_client_2]
# path = "boot:///sunset_client_2.hbf"
# [boot.limine.ableos.modules.sunset_client]
# path = "boot:///sunset_client.hbf"
# [boot.limine.ableos.modules.ablefetch]
# path = "boot:///ablefetch.hbf"