diff options
author | Mikhail Burakov <mburakov@mailbox.org> | 2023-04-07 12:31:59 +0200 |
---|---|---|
committer | Mikhail Burakov <mburakov@mailbox.org> | 2023-04-07 13:48:45 +0200 |
commit | d25bb30da26eefbe92cd1e59f7ee4b936c1afcec (patch) | |
tree | 8cf18f86deb8a1231b182929414128074f511742 /main.c | |
parent | 779b65bc22e0463f42161f0e03fee2cef9b2d790 (diff) |
Implement support for mouse events
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -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); |