void Window::DPIToWindowCoords(double *x, double *y) const { double dpix = x != nullptr ? *x : 0.0; double dpiy = y != nullptr ? *y : 0.0; double px = 0.0; double py = 0.0; toPixels(dpix, dpiy, px, py); pixelToWindowCoords(&px, &py); if (x != nullptr) *x = px; if (y != nullptr) *y = py; }
void Keyboard::setTextInput(bool enable, double x, double y, double w, double h) { // SDL_SetTextInputRect expects coordinates in window-space but setTextInput // takes pixels, so we should convert. auto window = Module::getInstance<window::Window>(M_WINDOW); if (window) { window->pixelToWindowCoords(&x, &y); window->pixelToWindowCoords(&w, &h); } SDL_Rect rect = {(int) x, (int) y, (int) w, (int) h}; SDL_SetTextInputRect(&rect); setTextInput(enable); }