From d25bb30da26eefbe92cd1e59f7ee4b936c1afcec Mon Sep 17 00:00:00 2001 From: Mikhail Burakov Date: Fri, 7 Apr 2023 12:31:59 +0200 Subject: Implement support for mouse events --- main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'main.c') diff --git a/main.c b/main.c index cce66ae..b686980 100644 --- a/main.c +++ b/main.c @@ -98,6 +98,27 @@ static void OnWindowKey(void* user, unsigned key, bool pressed) { } } +static void OnWindowMove(void* user, int dx, int dy) { + if (!InputStreamMouseMove(user, dx, dy)) { + LOG("Failed to handle mouse move"); + g_signal = SIGABRT; + } +} + +static void OnWindowButton(void* user, unsigned button, bool pressed) { + if (!InputStreamMouseButton(user, button, pressed)) { + LOG("Failed to handle mouse button"); + g_signal = SIGABRT; + } +} + +static void OnWindowWheel(void* user, int delta) { + if (!InputStreamMouseWheel(user, delta)) { + LOG("Failed to handle mouse wheel"); + g_signal = SIGABRT; + } +} + static void InputStreamDtor(struct InputStream** input_stream) { if (!*input_stream) return; InputStreamDestroy(*input_stream); @@ -139,6 +160,9 @@ int main(int argc, char* argv[]) { .OnClose = OnWindowClose, .OnFocus = OnWindowFocus, .OnKey = OnWindowKey, + .OnMove = OnWindowMove, + .OnButton = OnWindowButton, + .OnWheel = OnWindowWheel, }; struct Window __attribute__((cleanup(WindowDtor)))* window = WindowCreate(&window_event_handlers, input_stream); -- cgit v1.2.3