чување c1105ac65b1835b533e225e8c5529671e44ecc21
родитељ c696c5a681053c3d27f6e4bc97f9ac856fc0cacb
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Fri, 18 Aug 2023 09:51:07 +0200
Only hide mouse pointer when inside the window, don't draw
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 1, додавања: 1(+), брисања: 27(-)
diff --git a/lav-sdl.c b/lav-sdl.c
@@ -100,7 +100,6 @@ static SDL_Point* location_stack = NULL;
static SDL_FPoint pointer;
static int help_shown = 0;
static int redraw = 1;
-static int draw_pointer = 1;
static SDL_Renderer* renderer = NULL;
static int running = 1;
static float scale_factor = 1.0f;
@@ -329,20 +328,6 @@ draw(void)
if (help_shown)
draw_help_dialog();
- if (draw_pointer)
- {
- SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
- SDL_RenderDrawLineF(renderer, pointer.x - 10 + 1, pointer.y + 1,
- pointer.x + 10 + 1, pointer.y + 1);
- SDL_RenderDrawLineF(renderer, pointer.x + 1, pointer.y - 10 + 1,
- pointer.x + 1, pointer.y + 10 + 1);
- SDL_SetRenderDrawColor(renderer, 255, 255, 255,
- SDL_ALPHA_OPAQUE);
- SDL_RenderDrawLineF(renderer, pointer.x - 10, pointer.y,
- pointer.x + 10, pointer.y);
- SDL_RenderDrawLineF(renderer, pointer.x, pointer.y - 10,
- pointer.x, pointer.y + 10);
- }
SDL_RenderPresent(renderer);
// SDL_RenderFlush(renderer);
}
@@ -575,18 +560,9 @@ handle_event(SDL_Event* event)
if (pointer.x <= 0 || pointer.y <= 0
|| pointer.x + 1 >= screen_width
|| pointer.y + 1 >= screen_height)
- {
- // SDL_SetRelativeMouseMode(SDL_FALSE);
- draw_pointer = 0;
SDL_ShowCursor(1);
- }
else
- {
- // SDL_SetRelativeMouseMode(SDL_TRUE);
- draw_pointer = 1;
SDL_ShowCursor(0);
- }
- redraw = 1;
break;
}
}
@@ -912,6 +888,7 @@ int
main(int argc, char** argv)
{
SDL_Event event;
+ int px, py;
atexit(&cleanup);
@@ -946,10 +923,7 @@ main(int argc, char** argv)
update_size();
animation.active = 0;
- // SDL_SetWindowGrab(window, SDL_TRUE);
- // SDL_SetRelativeMouseMode(SDL_TRUE);
SDL_ShowCursor(0);
- int px, py;
SDL_GetMouseState(&px, &py);
pointer.x = (float)px;
pointer.y = (float)py;