summaryrefslogtreecommitdiff
path: root/examples/simple_window.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/simple_window.c')
-rw-r--r--examples/simple_window.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/examples/simple_window.c b/examples/simple_window.c
index e9e6545..fca2f75 100644
--- a/examples/simple_window.c
+++ b/examples/simple_window.c
@@ -87,7 +87,7 @@ static void on_draw(void *ud, struct yasl_surface *s, struct yasl_frame_context
if (failed || smoke_test) yasl_surface_destroy(s);
}
-static int on_init(void *ud, struct yasl_display *display)
+static enum yasl_app_result on_init(void *ud, struct yasl_display *display)
{
(void)ud;
struct yasl_window_spec window_spec = {
@@ -123,19 +123,19 @@ static void pointer_sample(struct yasl_vector2i pos, enum yasl_pointer_device de
pen_tilt_y = pen.tilt_y;
}
-static int on_event(void *ud, const struct yasl_event *ev)
+static enum yasl_app_result on_event(void *ud, const struct yasl_event *ev)
{
(void)ud;
switch (ev->type) {
- case YASL_EVENT_WINDOW_CLOSE_REQUEST:
+ case YASL_EVENT_WINDOW_CLOSE:
return YASL_APP_QUIT;
case YASL_EVENT_WINDOW_RESIZE: {
uint32_t flags = yasl_surface_state(ev->surface);
const char *mode = flags & YASL_STATE_FULLSCREEN ? "fullscreen" :
flags & YASL_STATE_MAXIMIZED ? "maximized" :
flags & YASL_STATE_TILED ? "tiled" : "windowed";
- printf("[YASL] Resized to %dx%d (scale: %.2fx, %s)\n", ev->resize.size.x,
- ev->resize.size.y, (double)ev->resize.scale_120 / YASL_SCALE_UNIT, mode);
+ printf("[YASL] Resized to %dx%d (scale: %.2fx, %s)\n", ev->resize.geometry.size.x,
+ ev->resize.geometry.size.y, (double)ev->resize.geometry.scale_120 / YASL_SCALE_UNIT, mode);
break;
}
case YASL_EVENT_KEY:
@@ -144,22 +144,23 @@ static int on_event(void *ud, const struct yasl_event *ev)
if (ev->key.key == YASL_KEY_SPACE || ev->key.key == YASL_KEY_ENTER)
color_theme++;
break;
- case YASL_EVENT_MOUSE_BUTTON:
- pointer_sample(ev->mouse_button.pos, ev->mouse_button.device, ev->mouse_button.pen);
- if (ev->mouse_button.button == 0) {
- mouse_down = ev->mouse_button.pressed;
- if (!mouse_down) pen_pressure = 0;
+ case YASL_EVENT_POINTER_DOWN:
+ case YASL_EVENT_POINTER_UP:
+ case YASL_EVENT_POINTER_MOTION:
+ pointer_sample(ev->pointer.pos, ev->pointer.device, ev->pointer.pen);
+ if (ev->type == YASL_EVENT_POINTER_DOWN && ev->pointer.button == YASL_BUTTON_PRIMARY) {
+ mouse_down = true;
+ } else if (ev->type == YASL_EVENT_POINTER_UP && ev->pointer.button == YASL_BUTTON_PRIMARY) {
+ mouse_down = false;
+ pen_pressure = 0;
}
break;
- case YASL_EVENT_MOUSE_MOTION:
- pointer_sample(ev->mouse_motion.pos, ev->mouse_motion.device, ev->mouse_motion.pen);
- break;
- case YASL_EVENT_WINDOW_FOCUS:
+ case YASL_EVENT_FOCUS:
if (ev->focus.focused) return YASL_APP_CONTINUE;
/* Fall through to cancel held input on focus loss. */
[[fallthrough]];
case YASL_EVENT_INPUT_RESET:
- case YASL_EVENT_MOUSE_LEAVE:
+ case YASL_EVENT_POINTER_LEAVE:
mouse_x = mouse_y = -1;
mouse_down = false;
pen_pressure = 0;