This commit is contained in:
Tommy 2022-07-22 16:13:36 +12:00
parent 3cb248f3db
commit aadcc6fbc1
4 changed files with 27 additions and 18 deletions

View file

@ -173,9 +173,9 @@ HWND windows_tray_notification::get_window_handle()
{
SDL_SysWMinfo wmInfo;
SDL_VERSION(&wmInfo.version);
sdl::window* window = video::get_window();
SDL_Window* window = video::get_window();
// SDL 1.2 keeps track of window handles internally whereas SDL 2.0 allows the caller control over which window to use
if (!window || SDL_GetWindowWMInfo (static_cast<SDL_Window *> (*window), &wmInfo) != SDL_TRUE) {
if (!window || SDL_GetWindowWMInfo (window, &wmInfo) != SDL_TRUE) {
return nullptr;
}

View file

@ -28,6 +28,10 @@ uint32_t get_mouse_state(int *x, int *y)
{
uint32_t buttons = SDL_GetMouseState(x, y);
if (video::headless()) {
return buttons;
}
// The game canvas may be offset inside the window,
// as well as potentially having a different size.
rect input_area = video::input_area();

View file

@ -69,14 +69,17 @@ rect input_area_ = {};
namespace video
{
// Forward declarations
void init_window();
void init_test_window();
void init_fake();
void init_test();
bool update_framebuffer();
bool update_test_framebuffer();
point draw_offset();
// Non-public interface
void render_screen(); // exposed and used only in draw_manager.cpp
// Internal functions
static void init_window();
static void init_test_window();
static void init_fake();
static void init_test();
static bool update_framebuffer();
static bool update_test_framebuffer();
static point draw_offset();
void init(fake type)
@ -414,14 +417,6 @@ rect output_area()
return {0, 0, p.x, p.y};
}
point to_output(const point& p)
{
// Multiply p by the integer scale, then add the draw offset if any.
point dsize = current_render_target_.draw_size();
point osize = current_render_target_.get_raw_size();
return (p * (osize / dsize)) + draw_offset();
}
rect to_output(const rect& r)
{
// Multiply r by integer scale, adding draw_offset to the position.
@ -604,6 +599,11 @@ SDL_Renderer* get_renderer()
}
}
SDL_Window* get_window()
{
return *window;
}
std::string current_driver()
{
const char* const drvname = SDL_GetCurrentVideoDriver();

View file

@ -316,4 +316,9 @@ private:
* texture creation. Try not to use it for anything else. */
SDL_Renderer* get_renderer();
/* This should not be used unless absolutely necessary. It's currently used
* for Windows tray notification and that's it. If it can be refactored out
* somehow then that would be best. */
SDL_Window* get_window();
} // namespace video