Spike Wayland compositor, hybrid MoonBit WM, SSD decorations, and wasmtime native host
This commit is contained in:
1 parent
880ecd4102
commit
17a8a46cfd
56 files changed
+8924
-11
No files matched your search
@@ -3,17 +3,20 @@
|
||||
///|
|
||||
fn wasmImportGetTokens(p0 : Int) = "moonplasma:desktop/theme@0.1.0" "get-tokens"
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array16
|
||||
#| local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
@@ -23,9 +26,6 @@ extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#| local.get 1)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array16
|
||||
#| local.get 0)
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
|
||||
///|
|
||||
fn wasmImportSyncWindows(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int) = "moonplasma:wm/policy@0.2.0" "sync-windows"
|
||||
|
||||
///|
|
||||
fn wasmImportOnWindowOpen(p0 : Int, p1 : Int) = "moonplasma:wm/policy@0.2.0" "on-window-open"
|
||||
|
||||
///|
|
||||
fn wasmImportOnWindowClose(p0 : Int64, p1 : Int) = "moonplasma:wm/policy@0.2.0" "on-window-close"
|
||||
|
||||
///|
|
||||
fn wasmImportOnWindowRequest(p0 : Int64, p1 : Int, p2 : Int, p3 : Int, p4 : Int, p5 : Int, p6 : Int, p7 : Int, p8 : Int) = "moonplasma:wm/policy@0.2.0" "on-window-request"
|
||||
|
||||
///|
|
||||
fn wasmImportOnPointer(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int, p5 : Int) = "moonplasma:wm/policy@0.2.0" "on-pointer"
|
||||
|
||||
///|
|
||||
fn wasmImportSetLayoutMode(p0 : Int, p1 : Int, p2 : Int, p3 : Int, p4 : Int, p5 : Int) = "moonplasma:wm/policy@0.2.0" "set-layout-mode"
|
||||
|
||||
///|
|
||||
fn wasmImportStackingOrder(p0 : Int) = "moonplasma:wm/policy@0.2.0" "stacking-order"
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store32(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
|
||||
#| local.tee 1 i32.const 0 call $moonbit.init_array8
|
||||
#| local.get 1)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store8(offset : Int, value : Int) =
|
||||
#|(func (param i32) (param i32) local.get 0 local.get 1 i32.store8)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_store64(offset : Int, value : Int64) =
|
||||
#|(func (param i32) (param i64) local.get 0 local.get 1 i64.store)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load64(offset : Int) -> Int64 =
|
||||
#|(func (param i32) (result i64) local.get 0 i64.load)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import {
|
||||
"moonplasma/desktop/interface/moonplasma/desktop/types" @types,
|
||||
}
|
||||
|
||||
warnings = "-44"
|
||||
@@ -0,0 +1,90 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "moonplasma/desktop/interface/moonplasma/wm/policy"
|
||||
|
||||
import {
|
||||
"moonplasma/desktop/interface/moonplasma/desktop/types",
|
||||
}
|
||||
|
||||
// Values
|
||||
pub fn on_pointer(@types.Point, UInt32?, Bool) -> InputTarget
|
||||
|
||||
pub fn on_window_close(UInt64) -> Array[WmAction]
|
||||
|
||||
pub fn on_window_open(WindowState, @types.Rect) -> Array[WmAction]
|
||||
|
||||
pub fn on_window_request(UInt64, WindowRequest, @types.Rect) -> Array[WmAction]
|
||||
|
||||
pub fn set_layout_mode(LayoutMode, @types.Rect) -> Array[WmAction]
|
||||
|
||||
pub fn stacking_order() -> Array[UInt64]
|
||||
|
||||
pub fn sync_windows(Array[@types.Rect], Array[WindowState]) -> Array[WmAction]
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
pub(all) enum InputTarget {
|
||||
Client((UInt64, @types.Point))
|
||||
Decoration((UInt64, @types.Point))
|
||||
ShellPanel(@types.Point)
|
||||
None
|
||||
}
|
||||
|
||||
pub(all) enum LayoutMode {
|
||||
FLOATING
|
||||
TILING
|
||||
MONOCLE
|
||||
}
|
||||
pub fn LayoutMode::from(Int32) -> Self
|
||||
pub fn LayoutMode::ordinal(Self) -> Int32
|
||||
|
||||
pub(all) struct WindowCaps(Byte)
|
||||
pub fn WindowCaps::default() -> Self
|
||||
pub fn WindowCaps::is_set(Self, WindowCapsFlag) -> Bool
|
||||
pub fn WindowCaps::set(Self, WindowCapsFlag) -> Self
|
||||
pub fn WindowCaps::unset(Self, WindowCapsFlag) -> Self
|
||||
|
||||
pub(all) enum WindowCapsFlag {
|
||||
CAN_MOVE
|
||||
CAN_RESIZE
|
||||
CAN_MAXIMIZE
|
||||
CAN_MINIMIZE
|
||||
CAN_FULLSCREEN
|
||||
}
|
||||
|
||||
pub(all) enum WindowRequest {
|
||||
Maximize(Bool)
|
||||
Fullscreen(Bool)
|
||||
Minimize(Bool)
|
||||
Close
|
||||
Activate
|
||||
MoveTo(@types.Point)
|
||||
ResizeTo(@types.Size)
|
||||
}
|
||||
|
||||
pub(all) struct WindowState {
|
||||
id : UInt64
|
||||
app_id : String
|
||||
title : String
|
||||
geometry : @types.Rect
|
||||
min_size : @types.Size
|
||||
max_size : @types.Size?
|
||||
focused : Bool
|
||||
maximized : Bool
|
||||
fullscreen : Bool
|
||||
workspace : UInt32
|
||||
caps : WindowCaps
|
||||
}
|
||||
|
||||
pub(all) enum WmAction {
|
||||
SetGeometry((UInt64, @types.Rect))
|
||||
Focus(UInt64)
|
||||
Raise(UInt64)
|
||||
Close(UInt64)
|
||||
SetMaximized((UInt64, Bool))
|
||||
SetFullscreen((UInt64, Bool))
|
||||
}
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
@@ -0,0 +1,518 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
///|
|
||||
pub(all) struct WindowCaps(Byte) derive()
|
||||
///|
|
||||
pub fn WindowCaps::default() -> WindowCaps {
|
||||
WindowCaps(b'\x00')
|
||||
}
|
||||
///|
|
||||
pub(all) enum WindowCapsFlag {
|
||||
CAN_MOVE; CAN_RESIZE; CAN_MAXIMIZE; CAN_MINIMIZE; CAN_FULLSCREEN
|
||||
}
|
||||
///|
|
||||
fn WindowCapsFlag::value(self : WindowCapsFlag) -> Byte {
|
||||
match self {
|
||||
CAN_MOVE => ((1U << 0).to_byte())
|
||||
CAN_RESIZE => ((1U << 1).to_byte())
|
||||
CAN_MAXIMIZE => ((1U << 2).to_byte())
|
||||
CAN_MINIMIZE => ((1U << 3).to_byte())
|
||||
CAN_FULLSCREEN => ((1U << 4).to_byte())
|
||||
}
|
||||
}
|
||||
///|
|
||||
pub fn WindowCaps::set(self : Self, other: WindowCapsFlag) -> WindowCaps {
|
||||
let WindowCaps(flag) = self
|
||||
WindowCaps(flag.lor(other.value()))
|
||||
}
|
||||
///|
|
||||
pub fn WindowCaps::unset(self : Self, other: WindowCapsFlag) -> WindowCaps {
|
||||
let WindowCaps(flag) = self
|
||||
WindowCaps(flag.land(other.value().lnot()))
|
||||
}
|
||||
///|
|
||||
pub fn WindowCaps::is_set(self : Self, other: WindowCapsFlag) -> Bool {
|
||||
let WindowCaps(flag) = self
|
||||
(flag.land(other.value()) == other.value())
|
||||
}
|
||||
///|
|
||||
pub(all) enum LayoutMode {
|
||||
FLOATING; TILING; MONOCLE
|
||||
} derive()
|
||||
|
||||
///|
|
||||
pub fn LayoutMode::ordinal(self : LayoutMode) -> Int {
|
||||
match self {
|
||||
FLOATING => 0
|
||||
TILING => 1
|
||||
MONOCLE => 2
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn LayoutMode::from(self : Int) -> LayoutMode {
|
||||
match self {
|
||||
0 => FLOATING
|
||||
1 => TILING
|
||||
2 => MONOCLE
|
||||
_ => panic()
|
||||
}
|
||||
}
|
||||
///|
|
||||
pub(all) struct WindowState {
|
||||
id : UInt64; app_id : String; title : String; geometry : @types.Rect; min_size : @types.Size; max_size : @types.Size?; focused : Bool; maximized : Bool; fullscreen : Bool; workspace : UInt; caps : WindowCaps
|
||||
}
|
||||
///|
|
||||
pub(all) enum WindowRequest {
|
||||
Maximize(Bool)
|
||||
Fullscreen(Bool)
|
||||
Minimize(Bool)
|
||||
Close
|
||||
Activate
|
||||
MoveTo(@types.Point)
|
||||
ResizeTo(@types.Size)
|
||||
}
|
||||
///|
|
||||
pub(all) enum WmAction {
|
||||
SetGeometry((UInt64, @types.Rect))
|
||||
Focus(UInt64)
|
||||
Raise(UInt64)
|
||||
Close(UInt64)
|
||||
SetMaximized((UInt64, Bool))
|
||||
SetFullscreen((UInt64, Bool))
|
||||
}
|
||||
///|
|
||||
pub(all) enum InputTarget {
|
||||
Client((UInt64, @types.Point))
|
||||
Decoration((UInt64, @types.Point))
|
||||
ShellPanel(@types.Point)
|
||||
None
|
||||
}
|
||||
///|
|
||||
/// Called on startup or WM hot-swap to synchronize existing windows.
|
||||
pub fn sync_windows(outputs : Array[@types.Rect], windows : Array[WindowState]) -> Array[WmAction] {
|
||||
let cleanup_list : Array[Int] = []
|
||||
|
||||
let address = mbt_ffi_malloc((outputs).length() * 16);
|
||||
for index = 0; index < (outputs).length(); index = index + 1 {
|
||||
let iter_elem : @types.Rect = (outputs)[(index)]
|
||||
let iter_base = address + (index * 16);
|
||||
mbt_ffi_store32((iter_base) + 0, (iter_elem).x)
|
||||
mbt_ffi_store32((iter_base) + 4, (iter_elem).y)
|
||||
mbt_ffi_store32((iter_base) + 8, ((iter_elem).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 12, ((iter_elem).h).reinterpret_as_int())
|
||||
|
||||
}
|
||||
|
||||
let address2 = mbt_ffi_malloc((windows).length() * 72);
|
||||
for index3 = 0; index3 < (windows).length(); index3 = index3 + 1 {
|
||||
let iter_elem : WindowState = (windows)[(index3)]
|
||||
let iter_base = address2 + (index3 * 72);
|
||||
mbt_ffi_store64((iter_base) + 0, ((iter_elem).id).reinterpret_as_int64())
|
||||
|
||||
let ptr = mbt_ffi_str2ptr((iter_elem).app_id)
|
||||
mbt_ffi_store32((iter_base) + 12, (iter_elem).app_id.length())
|
||||
mbt_ffi_store32((iter_base) + 8, ptr)
|
||||
|
||||
let ptr0 = mbt_ffi_str2ptr((iter_elem).title)
|
||||
mbt_ffi_store32((iter_base) + 20, (iter_elem).title.length())
|
||||
mbt_ffi_store32((iter_base) + 16, ptr0)
|
||||
mbt_ffi_store32((iter_base) + 24, ((iter_elem).geometry).x)
|
||||
mbt_ffi_store32((iter_base) + 28, ((iter_elem).geometry).y)
|
||||
mbt_ffi_store32((iter_base) + 32, (((iter_elem).geometry).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 36, (((iter_elem).geometry).h).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 40, (((iter_elem).min_size).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 44, (((iter_elem).min_size).h).reinterpret_as_int())
|
||||
|
||||
match ((iter_elem).max_size) {
|
||||
None => {
|
||||
mbt_ffi_store8((iter_base) + 48, (0))
|
||||
|
||||
()
|
||||
}
|
||||
Some(payload1) => {
|
||||
mbt_ffi_store8((iter_base) + 48, (1))
|
||||
mbt_ffi_store32((iter_base) + 52, ((payload1).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((iter_base) + 56, ((payload1).h).reinterpret_as_int())
|
||||
|
||||
()
|
||||
}
|
||||
}
|
||||
mbt_ffi_store8((iter_base) + 60, (if (iter_elem).focused { 1 } else { 0 }))
|
||||
mbt_ffi_store8((iter_base) + 61, (if (iter_elem).maximized { 1 } else { 0 }))
|
||||
mbt_ffi_store8((iter_base) + 62, (if (iter_elem).fullscreen { 1 } else { 0 }))
|
||||
mbt_ffi_store32((iter_base) + 64, ((iter_elem).workspace).reinterpret_as_int())
|
||||
|
||||
let WindowCaps(flag) = (iter_elem).caps
|
||||
|
||||
mbt_ffi_store8((iter_base) + 68, flag.to_int())
|
||||
cleanup_list.push(ptr)
|
||||
cleanup_list.push(ptr0)
|
||||
|
||||
}
|
||||
let return_area = mbt_ffi_malloc(8)
|
||||
wasmImportSyncWindows(address, (outputs).length(), address2, (windows).length(), return_area);
|
||||
|
||||
let array : Array[WmAction] = [];
|
||||
for index4 = 0; index4 < (mbt_ffi_load32((return_area) + 4)); index4 = index4 + 1 {
|
||||
let iter_base = (mbt_ffi_load32((return_area) + 0)) + (index4 * 32)
|
||||
|
||||
let lifted = match (mbt_ffi_load8_u((iter_base) + 0)) {
|
||||
0 => {
|
||||
|
||||
WmAction::SetGeometry(((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64(), @types.Rect::{x : mbt_ffi_load32((iter_base) + 16), y : mbt_ffi_load32((iter_base) + 20), w : (mbt_ffi_load32((iter_base) + 24)).reinterpret_as_uint(), h : (mbt_ffi_load32((iter_base) + 28)).reinterpret_as_uint()}))
|
||||
}
|
||||
1 => {
|
||||
|
||||
WmAction::Focus((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64())
|
||||
}
|
||||
2 => {
|
||||
|
||||
WmAction::Raise((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64())
|
||||
}
|
||||
3 => {
|
||||
|
||||
WmAction::Close((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64())
|
||||
}
|
||||
4 => {
|
||||
|
||||
WmAction::SetMaximized(((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64(), (mbt_ffi_load8_u((iter_base) + 16) != 0)))
|
||||
}
|
||||
5 => {
|
||||
|
||||
WmAction::SetFullscreen(((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64(), (mbt_ffi_load8_u((iter_base) + 16) != 0)))
|
||||
}
|
||||
_ => panic()
|
||||
}
|
||||
|
||||
array.push(lifted)
|
||||
}
|
||||
mbt_ffi_free(mbt_ffi_load32((return_area) + 0))
|
||||
let ret = array
|
||||
mbt_ffi_free(address)
|
||||
mbt_ffi_free(address2)
|
||||
mbt_ffi_free(return_area)
|
||||
|
||||
cleanup_list.each(mbt_ffi_free)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
pub fn on_window_open(win : WindowState, work_area : @types.Rect) -> Array[WmAction] {
|
||||
|
||||
let return_area = mbt_ffi_malloc(88)
|
||||
mbt_ffi_store64((return_area) + 0, ((win).id).reinterpret_as_int64())
|
||||
|
||||
let ptr = mbt_ffi_str2ptr((win).app_id)
|
||||
mbt_ffi_store32((return_area) + 12, (win).app_id.length())
|
||||
mbt_ffi_store32((return_area) + 8, ptr)
|
||||
|
||||
let ptr0 = mbt_ffi_str2ptr((win).title)
|
||||
mbt_ffi_store32((return_area) + 20, (win).title.length())
|
||||
mbt_ffi_store32((return_area) + 16, ptr0)
|
||||
mbt_ffi_store32((return_area) + 24, ((win).geometry).x)
|
||||
mbt_ffi_store32((return_area) + 28, ((win).geometry).y)
|
||||
mbt_ffi_store32((return_area) + 32, (((win).geometry).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((return_area) + 36, (((win).geometry).h).reinterpret_as_int())
|
||||
mbt_ffi_store32((return_area) + 40, (((win).min_size).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((return_area) + 44, (((win).min_size).h).reinterpret_as_int())
|
||||
|
||||
match ((win).max_size) {
|
||||
None => {
|
||||
mbt_ffi_store8((return_area) + 48, (0))
|
||||
|
||||
()
|
||||
}
|
||||
Some(payload1) => {
|
||||
mbt_ffi_store8((return_area) + 48, (1))
|
||||
mbt_ffi_store32((return_area) + 52, ((payload1).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((return_area) + 56, ((payload1).h).reinterpret_as_int())
|
||||
|
||||
()
|
||||
}
|
||||
}
|
||||
mbt_ffi_store8((return_area) + 60, (if (win).focused { 1 } else { 0 }))
|
||||
mbt_ffi_store8((return_area) + 61, (if (win).maximized { 1 } else { 0 }))
|
||||
mbt_ffi_store8((return_area) + 62, (if (win).fullscreen { 1 } else { 0 }))
|
||||
mbt_ffi_store32((return_area) + 64, ((win).workspace).reinterpret_as_int())
|
||||
|
||||
let WindowCaps(flag) = (win).caps
|
||||
|
||||
mbt_ffi_store8((return_area) + 68, flag.to_int())
|
||||
mbt_ffi_store32((return_area) + 72, (work_area).x)
|
||||
mbt_ffi_store32((return_area) + 76, (work_area).y)
|
||||
mbt_ffi_store32((return_area) + 80, ((work_area).w).reinterpret_as_int())
|
||||
mbt_ffi_store32((return_area) + 84, ((work_area).h).reinterpret_as_int())
|
||||
let return_area2 = mbt_ffi_malloc(8)
|
||||
wasmImportOnWindowOpen(return_area, return_area2);
|
||||
|
||||
let array : Array[WmAction] = [];
|
||||
for index = 0; index < (mbt_ffi_load32((return_area2) + 4)); index = index + 1 {
|
||||
let iter_base = (mbt_ffi_load32((return_area2) + 0)) + (index * 32)
|
||||
|
||||
let lifted = match (mbt_ffi_load8_u((iter_base) + 0)) {
|
||||
0 => {
|
||||
|
||||
WmAction::SetGeometry(((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64(), @types.Rect::{x : mbt_ffi_load32((iter_base) + 16), y : mbt_ffi_load32((iter_base) + 20), w : (mbt_ffi_load32((iter_base) + 24)).reinterpret_as_uint(), h : (mbt_ffi_load32((iter_base) + 28)).reinterpret_as_uint()}))
|
||||
}
|
||||
1 => {
|
||||
|
||||
WmAction::Focus((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64())
|
||||
}
|
||||
2 => {
|
||||
|
||||
WmAction::Raise((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64())
|
||||
}
|
||||
3 => {
|
||||
|
||||
WmAction::Close((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64())
|
||||
}
|
||||
4 => {
|
||||
|
||||
WmAction::SetMaximized(((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64(), (mbt_ffi_load8_u((iter_base) + 16) != 0)))
|
||||
}
|
||||
5 => {
|
||||
|
||||
WmAction::SetFullscreen(((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64(), (mbt_ffi_load8_u((iter_base) + 16) != 0)))
|
||||
}
|
||||
_ => panic()
|
||||
}
|
||||
|
||||
array.push(lifted)
|
||||
}
|
||||
mbt_ffi_free(mbt_ffi_load32((return_area2) + 0))
|
||||
let ret = array
|
||||
mbt_ffi_free(return_area)
|
||||
mbt_ffi_free(ptr)
|
||||
mbt_ffi_free(ptr0)
|
||||
mbt_ffi_free(return_area2)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
pub fn on_window_close(id : UInt64) -> Array[WmAction] {
|
||||
|
||||
let return_area = mbt_ffi_malloc(8)
|
||||
wasmImportOnWindowClose((id).reinterpret_as_int64(), return_area);
|
||||
|
||||
let array : Array[WmAction] = [];
|
||||
for index = 0; index < (mbt_ffi_load32((return_area) + 4)); index = index + 1 {
|
||||
let iter_base = (mbt_ffi_load32((return_area) + 0)) + (index * 32)
|
||||
|
||||
let lifted = match (mbt_ffi_load8_u((iter_base) + 0)) {
|
||||
0 => {
|
||||
|
||||
WmAction::SetGeometry(((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64(), @types.Rect::{x : mbt_ffi_load32((iter_base) + 16), y : mbt_ffi_load32((iter_base) + 20), w : (mbt_ffi_load32((iter_base) + 24)).reinterpret_as_uint(), h : (mbt_ffi_load32((iter_base) + 28)).reinterpret_as_uint()}))
|
||||
}
|
||||
1 => {
|
||||
|
||||
WmAction::Focus((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64())
|
||||
}
|
||||
2 => {
|
||||
|
||||
WmAction::Raise((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64())
|
||||
}
|
||||
3 => {
|
||||
|
||||
WmAction::Close((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64())
|
||||
}
|
||||
4 => {
|
||||
|
||||
WmAction::SetMaximized(((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64(), (mbt_ffi_load8_u((iter_base) + 16) != 0)))
|
||||
}
|
||||
5 => {
|
||||
|
||||
WmAction::SetFullscreen(((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64(), (mbt_ffi_load8_u((iter_base) + 16) != 0)))
|
||||
}
|
||||
_ => panic()
|
||||
}
|
||||
|
||||
array.push(lifted)
|
||||
}
|
||||
mbt_ffi_free(mbt_ffi_load32((return_area) + 0))
|
||||
let ret = array
|
||||
mbt_ffi_free(return_area)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
pub fn on_window_request(id : UInt64, req : WindowRequest, work_area : @types.Rect) -> Array[WmAction] {
|
||||
|
||||
let (lowered,lowered6,lowered7) = match req {
|
||||
Maximize(payload) => {
|
||||
|
||||
((0), (if payload { 1 } else { 0 }), 0)
|
||||
}
|
||||
Fullscreen(payload0) => {
|
||||
|
||||
((1), (if payload0 { 1 } else { 0 }), 0)
|
||||
}
|
||||
Minimize(payload1) => {
|
||||
|
||||
((2), (if payload1 { 1 } else { 0 }), 0)
|
||||
}
|
||||
Close => {
|
||||
|
||||
((3), 0, 0)
|
||||
}
|
||||
Activate => {
|
||||
|
||||
((4), 0, 0)
|
||||
}
|
||||
MoveTo(payload4) => {
|
||||
|
||||
((5), (payload4).x, (payload4).y)
|
||||
}
|
||||
ResizeTo(payload5) => {
|
||||
|
||||
((6), ((payload5).w).reinterpret_as_int(), ((payload5).h).reinterpret_as_int())
|
||||
}
|
||||
}
|
||||
let return_area = mbt_ffi_malloc(8)
|
||||
wasmImportOnWindowRequest((id).reinterpret_as_int64(), lowered, lowered6, lowered7, (work_area).x, (work_area).y, ((work_area).w).reinterpret_as_int(), ((work_area).h).reinterpret_as_int(), return_area);
|
||||
|
||||
let array : Array[WmAction] = [];
|
||||
for index = 0; index < (mbt_ffi_load32((return_area) + 4)); index = index + 1 {
|
||||
let iter_base = (mbt_ffi_load32((return_area) + 0)) + (index * 32)
|
||||
|
||||
let lifted = match (mbt_ffi_load8_u((iter_base) + 0)) {
|
||||
0 => {
|
||||
|
||||
WmAction::SetGeometry(((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64(), @types.Rect::{x : mbt_ffi_load32((iter_base) + 16), y : mbt_ffi_load32((iter_base) + 20), w : (mbt_ffi_load32((iter_base) + 24)).reinterpret_as_uint(), h : (mbt_ffi_load32((iter_base) + 28)).reinterpret_as_uint()}))
|
||||
}
|
||||
1 => {
|
||||
|
||||
WmAction::Focus((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64())
|
||||
}
|
||||
2 => {
|
||||
|
||||
WmAction::Raise((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64())
|
||||
}
|
||||
3 => {
|
||||
|
||||
WmAction::Close((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64())
|
||||
}
|
||||
4 => {
|
||||
|
||||
WmAction::SetMaximized(((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64(), (mbt_ffi_load8_u((iter_base) + 16) != 0)))
|
||||
}
|
||||
5 => {
|
||||
|
||||
WmAction::SetFullscreen(((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64(), (mbt_ffi_load8_u((iter_base) + 16) != 0)))
|
||||
}
|
||||
_ => panic()
|
||||
}
|
||||
|
||||
array.push(lifted)
|
||||
}
|
||||
mbt_ffi_free(mbt_ffi_load32((return_area) + 0))
|
||||
let ret = array
|
||||
mbt_ffi_free(return_area)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
pub fn on_pointer(pos : @types.Point, button : UInt?, pressed : Bool) -> InputTarget {
|
||||
|
||||
let (lowered, lowered1) = match (button) {
|
||||
None => {
|
||||
|
||||
((0), 0)
|
||||
}
|
||||
Some(payload0) => {
|
||||
|
||||
((1), (payload0).reinterpret_as_int())
|
||||
}
|
||||
}
|
||||
let return_area = mbt_ffi_malloc(24)
|
||||
wasmImportOnPointer((pos).x, (pos).y, lowered, lowered1, (if pressed { 1 } else { 0 }), return_area);
|
||||
|
||||
let lifted = match (mbt_ffi_load8_u((return_area) + 0)) {
|
||||
0 => {
|
||||
|
||||
InputTarget::Client(((mbt_ffi_load64((return_area) + 8)).reinterpret_as_uint64(), @types.Point::{x : mbt_ffi_load32((return_area) + 16), y : mbt_ffi_load32((return_area) + 20)}))
|
||||
}
|
||||
1 => {
|
||||
|
||||
InputTarget::Decoration(((mbt_ffi_load64((return_area) + 8)).reinterpret_as_uint64(), @types.Point::{x : mbt_ffi_load32((return_area) + 16), y : mbt_ffi_load32((return_area) + 20)}))
|
||||
}
|
||||
2 => {
|
||||
|
||||
InputTarget::ShellPanel(@types.Point::{x : mbt_ffi_load32((return_area) + 8), y : mbt_ffi_load32((return_area) + 12)})
|
||||
}
|
||||
3 => {
|
||||
|
||||
InputTarget::None
|
||||
}
|
||||
_ => panic()
|
||||
}
|
||||
let ret = lifted
|
||||
mbt_ffi_free(return_area)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
pub fn set_layout_mode(mode : LayoutMode, work_area : @types.Rect) -> Array[WmAction] {
|
||||
|
||||
let return_area = mbt_ffi_malloc(8)
|
||||
wasmImportSetLayoutMode(mode.ordinal(), (work_area).x, (work_area).y, ((work_area).w).reinterpret_as_int(), ((work_area).h).reinterpret_as_int(), return_area);
|
||||
|
||||
let array : Array[WmAction] = [];
|
||||
for index = 0; index < (mbt_ffi_load32((return_area) + 4)); index = index + 1 {
|
||||
let iter_base = (mbt_ffi_load32((return_area) + 0)) + (index * 32)
|
||||
|
||||
let lifted = match (mbt_ffi_load8_u((iter_base) + 0)) {
|
||||
0 => {
|
||||
|
||||
WmAction::SetGeometry(((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64(), @types.Rect::{x : mbt_ffi_load32((iter_base) + 16), y : mbt_ffi_load32((iter_base) + 20), w : (mbt_ffi_load32((iter_base) + 24)).reinterpret_as_uint(), h : (mbt_ffi_load32((iter_base) + 28)).reinterpret_as_uint()}))
|
||||
}
|
||||
1 => {
|
||||
|
||||
WmAction::Focus((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64())
|
||||
}
|
||||
2 => {
|
||||
|
||||
WmAction::Raise((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64())
|
||||
}
|
||||
3 => {
|
||||
|
||||
WmAction::Close((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64())
|
||||
}
|
||||
4 => {
|
||||
|
||||
WmAction::SetMaximized(((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64(), (mbt_ffi_load8_u((iter_base) + 16) != 0)))
|
||||
}
|
||||
5 => {
|
||||
|
||||
WmAction::SetFullscreen(((mbt_ffi_load64((iter_base) + 8)).reinterpret_as_uint64(), (mbt_ffi_load8_u((iter_base) + 16) != 0)))
|
||||
}
|
||||
_ => panic()
|
||||
}
|
||||
|
||||
array.push(lifted)
|
||||
}
|
||||
mbt_ffi_free(mbt_ffi_load32((return_area) + 0))
|
||||
let ret = array
|
||||
mbt_ffi_free(return_area)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
/// Returns window IDs in bottom-to-top Z-order.
|
||||
pub fn stacking_order() -> Array[UInt64] {
|
||||
|
||||
let return_area = mbt_ffi_malloc(8)
|
||||
wasmImportStackingOrder(return_area);
|
||||
|
||||
let array : Array[UInt64] = [];
|
||||
for index = 0; index < (mbt_ffi_load32((return_area) + 4)); index = index + 1 {
|
||||
let iter_base = (mbt_ffi_load32((return_area) + 0)) + (index * 8)
|
||||
|
||||
array.push((mbt_ffi_load64((iter_base) + 0)).reinterpret_as_uint64())
|
||||
}
|
||||
mbt_ffi_free(mbt_ffi_load32((return_area) + 0))
|
||||
let ret = array
|
||||
mbt_ffi_free(return_area)
|
||||
return ret
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user