commit 12f36cc

uint  ·  2026-06-09 17:49:28 +0000 UTC
parent af23f19
basic-window: add mouse visibility, free/locked toggle
1 files changed,  +26, -3
+26, -3
 1@@ -1,8 +1,11 @@
 2+#include <stdbool.h>
 3 #include <stdlib.h>
 4 
 5 #include "../../maus.h"
 6 
 7 int mx, my;
 8+bool cur_visible = true;
 9+bool cur_locked = false;
10 
11 void handle_ev(Maus* mw, MausEvent* ev)
12 {
13@@ -11,11 +14,31 @@ void handle_ev(Maus* mw, MausEvent* ev)
14 			maus_close(mw);
15 			exit(EXIT_SUCCESS);
16 			break;
17-		case MAUS_EV_KEY:
18-			if (ev->key.key == MAUS_KEY_Q) {
19+		case MAUS_EV_KEY: {
20+			(void)0;
21+
22+			bool* keys = mw->key_syms;
23+			if (keys[MAUS_KEY_Q]) {
24 				maus_close(mw);
25 				exit(EXIT_SUCCESS);
26-			} break;
27+			};
28+			if (keys[MAUS_KEY_P]) {
29+				cur_visible ?
30+				maus_cur_set_mode(mw, MAUS_CURSOR_STATE_HIDDEN) :
31+				maus_cur_set_mode(mw, MAUS_CURSOR_STATE_VISIBLE);
32+
33+				cur_visible = !cur_visible;
34+			}
35+			if (keys[MAUS_KEY_L]) {
36+				cur_locked ?
37+				maus_cur_set_mode(mw, MAUS_CURSOR_STATE_FREE) :
38+				maus_cur_set_mode(mw, MAUS_CURSOR_STATE_LOCKED);
39+
40+				cur_locked = !cur_locked;
41+			}
42+
43+			break;
44+		}
45 		case MAUS_EV_MOUSE_BUTTON:
46 			break;
47 		case MAUS_EV_MOUSE_MOTION: {