sdl_input_grabber.cpp 628 B

12345678910111213141516171819202122232425
  1. #include "sdl_input_grabber.h"
  2. #include "simple/sdlcore/utils.hpp"
  3. sdl_input_grabber::sdl_input_grabber() :
  4. video_init( simple::sdlcore::system_flag::video ),
  5. window(SDL_CreateWindow("input grabber", 0,0,0,0, SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS))
  6. {
  7. simple::sdlcore::utils::throw_error(window.get());
  8. }
  9. void sdl_input_grabber::sdl_window_del::operator()(SDL_Window * w) noexcept
  10. {
  11. SDL_DestroyWindow(w);
  12. }
  13. void sdl_input_grabber::grab() noexcept
  14. {
  15. SDL_SetWindowGrab(window.get(), SDL_TRUE);
  16. }
  17. void sdl_input_grabber::release() noexcept
  18. {
  19. SDL_SetWindowGrab(window.get(), SDL_FALSE);
  20. }