Skip to content

Commit

Permalink
Set mouse pos to NAN when inside the UI
Browse files Browse the repository at this point in the history
So that we properly register the end of a hover event when we move the
mouse in the UI area.

This fixes a bug with the brush tool that sometimes froze.

Might break some other things though, since this code is not very clear.
  • Loading branch information
guillaumechereau committed Jun 27, 2024
1 parent 253db44 commit 8b2433f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/goxel.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,14 +515,16 @@ int goxel_iter(const inputs_t *inputs)

// Test: update the viewport before the UI.
// Note: the inputs Y coordinates are inverted!
if (!gui_want_capture_mouse()) {
inputs2 = *inputs;
for (i = 0; i < (int)ARRAY_SIZE(inputs2.touches); i++) {
inputs2.touches[i].pos[1] =
inputs->window_size[1] - inputs->touches[i].pos[1];
inputs2 = *inputs;
for (i = 0; i < (int)ARRAY_SIZE(inputs2.touches); i++) {
inputs2.touches[i].pos[1] =
inputs->window_size[1] - inputs->touches[i].pos[1];
if (gui_want_capture_mouse()) {
inputs2.touches[i].pos[0] = NAN;
inputs2.touches[i].pos[1] = NAN;
}
goxel_mouse_in_view(goxel.gui.viewport, &inputs2, true);
}
goxel_mouse_in_view(goxel.gui.viewport, &inputs2, true);

if (DEFINED(SOUND) && time - goxel.last_click_time > 0.1) {
volume_key = volume_get_key(goxel_get_render_volume(goxel.image));
Expand Down Expand Up @@ -707,6 +709,7 @@ void goxel_mouse_in_view(const float viewport[4], const inputs_t *inputs,
float p[3], n[3];
camera_t *camera = get_camera();


painter_t painter = goxel.painter;
gesture_update(goxel.gestures_count, goxel.gestures,
inputs, viewport, NULL);
Expand Down

0 comments on commit 8b2433f

Please sign in to comment.