summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/CWayland/CWayland.cc15
-rw-r--r--lib/CWayland/CWayland.h3
-rw-r--r--lib/Wayland/Display.lean4
-rw-r--r--lib/Wayland/Native.lean3
4 files changed, 16 insertions, 9 deletions
diff --git a/lib/CWayland/CWayland.cc b/lib/CWayland/CWayland.cc
index abb9ee5..3e6bd0e 100644
--- a/lib/CWayland/CWayland.cc
+++ b/lib/CWayland/CWayland.cc
@@ -179,11 +179,11 @@ lean_obj_res waylean_display_new(b_lean_obj_arg name)
return lean_io_result_mk_ok(waylean_disp);
}
-// Display.roundtrip : (display : @& Display) → IO Unit
-lean_obj_res waylean_display_roundtrip(b_lean_obj_arg display)
+// Display.flush : (display : @& Display) → IO Unit
+lean_obj_res waylean_display_flush(b_lean_obj_arg disp_obj)
{
- wl_display* disp = static_cast<wl_display*>(lean_get_external_data(display));
- if (wl_display_roundtrip(disp) == -1) { return io_result_mk_from_errno("<unknown>"); }
+ wl_display* disp = static_cast<wl_display*>(lean_get_external_data(disp_obj));
+ if (wl_display_flush(disp) == -1) { return io_result_mk_from_errno("<unknown>"); }
return lean_io_result_mk_ok(lean_box(0));
}
@@ -1169,11 +1169,10 @@ lean_obj_res waylean_argument_buffer_read_fd(b_lean_obj_arg buffer_obj)
namespace
{
- int dispatcher_func(const void* user_data, void* target, uint32_t opcode, const wl_message* msg, wl_argument* args)
+ int dispatcher_func(const void* dispatcher_data, void* target, uint32_t opcode, const wl_message* msg, wl_argument* args)
{
- if (!user_data) { return 0; }
-
- auto handler = ref{ (lean_object*)user_data };
+ auto user_data = wl_proxy_get_user_data(static_cast<wl_proxy*>(target));
+ auto handler = ref{ static_cast<lean_object*>(user_data) };
auto buffer = new argument_buffer;
auto buffer_obj = ref::steal(lean_alloc_external(waylean_argument_buffer_class(), buffer));
diff --git a/lib/CWayland/CWayland.h b/lib/CWayland/CWayland.h
index 2db206e..44424a2 100644
--- a/lib/CWayland/CWayland.h
+++ b/lib/CWayland/CWayland.h
@@ -15,7 +15,8 @@ uint32_t waylean_SIGUSR2(void);
// -- Display
-lean_obj_res waylean_display_new(b_lean_obj_arg name);
+lean_obj_res waylean_display_new (b_lean_obj_arg name);
+lean_obj_res waylean_display_flush(b_lean_obj_arg display);
// -- Event Loop
diff --git a/lib/Wayland/Display.lean b/lib/Wayland/Display.lean
index 5747c4d..f07c5ff 100644
--- a/lib/Wayland/Display.lean
+++ b/lib/Wayland/Display.lean
@@ -166,6 +166,10 @@ not be used often. -/
def DisplayM.liftIO (io : IO α) : DisplayM σ α :=
io
+/-- Flush any pending requests. -/
+def DisplayM.flush : DisplayM σ Unit := do
+ (← read).disp.flush
+
/-- Request the application to stop processing events and exit the event loop.
This can be sent at any time and stops the event loop before any further events can be processed. -/
diff --git a/lib/Wayland/Native.lean b/lib/Wayland/Native.lean
index f8943ac..dd138e4 100644
--- a/lib/Wayland/Native.lean
+++ b/lib/Wayland/Native.lean
@@ -46,6 +46,9 @@ opaque SIGUSR2 (u : Unit) : UInt32
@[extern "waylean_display_new"]
opaque Display.new : (name : @& Option String) → IO Display
+@[extern "waylean_display_flush"]
+opaque Display.flush : (display : @& Display) → IO Unit
+
@[extern "waylean_event_loop_new"]
opaque EventLoop.new : IO (EventLoop M)