Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SDL_WINDOW_INPUT_FOCUS and SDL_WINDOW_MOUSE_FOCUS

Tags:

flags

sdl-2

What are the SDL_WindowFlags SDL_WINDOW_INPUT_FOCUS and SDL_WINDOW_MOUSE_FOCUS used for ?

If I am not mistaken SDL_WINDOW_INPUT_GRABBED indicates which window is receiving inputs, if any. But I simply cannot see what the two other flags mean. I checked SDL_video.h to see if I could get more information, but what I read didn't help :

SDL_WINDOW_INPUT_GRABBED = 0x00000100,      /**< window has grabbed input focus */
SDL_WINDOW_INPUT_FOCUS = 0x00000200,        /**< window has input focus */
SDL_WINDOW_MOUSE_FOCUS = 0x00000400,        /**< window has mouse focus */

I don't see the difference between "window has grabbed input focus" and "indow has input focus".
Is INPUT_FOCUS only for keyboard input and MOUSE_FOCUS for mouse input ? In that case, why would INPUT_GRABBED not be a combination of these two ?

Furthermore, is it possible to have a window with mouse focus and another with "input" focus (whatever "input" means here, except "mouse"), or something similar ?

like image 207
Nelfeal Avatar asked Jan 11 '23 04:01

Nelfeal


1 Answers

I just realised that SDL_WINDOW_INPUT_GRABBED was not what I thought it was. It is set with SDL_SetWindowGrab and forces the mouse to stay inside the window (so the window has both mouse and keyboard focus).
The INPUT_FOCUS flag indicates whether the window is active or not (has keyboard input, and probably other controller inputs too).
The MOUSE_FOCUS flag indicates whether the mouse is hovering over the window, even if the window is not active.

like image 81
Nelfeal Avatar answered Apr 27 '23 22:04

Nelfeal