Windows embedder fixes
This commit is contained in:
@@ -43,11 +43,16 @@ class _ThermionWidgetWindowsState extends State<ThermionWidgetWindows> {
|
||||
|
||||
var dpr = MediaQuery.of(context).devicePixelRatio;
|
||||
|
||||
var size = ((context.findRenderObject()) as RenderBox).size;
|
||||
final renderBox = ((context.findRenderObject()) as RenderBox);
|
||||
var size = renderBox.size;
|
||||
var width = (size.width * dpr).ceil();
|
||||
var height = (size.height * dpr).ceil();
|
||||
|
||||
_window = await t.ThermionFlutterPlatform.instance.createWindow(width, height, 0, 0);
|
||||
final offset = renderBox.localToGlobal(Offset.zero);
|
||||
final offsetLeft = (offset.dx * dpr).toInt();
|
||||
final offsetTop = (offset.dy * dpr).toInt();
|
||||
|
||||
_window = await t.ThermionFlutterPlatform.instance.createWindow(width, height, offsetLeft, offsetTop);
|
||||
|
||||
await widget.view.updateViewport(_window!.width, _window!.height);
|
||||
|
||||
@@ -121,11 +126,16 @@ class _ThermionWidgetWindowsState extends State<ThermionWidgetWindows> {
|
||||
var newWidth = newSize.width.ceil();
|
||||
var newHeight = newSize.height.ceil();
|
||||
|
||||
final renderBox = context.findRenderObject() as RenderBox;
|
||||
final offset = renderBox.localToGlobal(Offset.zero);
|
||||
final offsetLeft = (offset.dx * dpr).toInt();
|
||||
final offsetTop = (offset.dy * dpr).toInt();
|
||||
|
||||
await _window?.resize(
|
||||
newWidth,
|
||||
newHeight,
|
||||
0,
|
||||
0,
|
||||
offsetLeft,
|
||||
offsetTop,
|
||||
);
|
||||
|
||||
await widget.view.updateViewport(_window!.width, _window!.height);
|
||||
|
||||
@@ -210,7 +210,7 @@ void ThermionFlutterPlugin::DestroyTexture(
|
||||
void ThermionFlutterPlugin::HandleMethodCall(
|
||||
const flutter::MethodCall<flutter::EncodableValue> &methodCall,
|
||||
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result) {
|
||||
std::cout << methodCall.method_name().c_str() << std::endl;
|
||||
// std::cout << methodCall.method_name().c_str() << std::endl;
|
||||
if (methodCall.method_name() == "usesBackingWindow") {
|
||||
result->Success(flutter::EncodableValue(
|
||||
#ifdef WGL_USE_BACKING_WINDOW
|
||||
@@ -239,13 +239,12 @@ void ThermionFlutterPlugin::HandleMethodCall(
|
||||
int dHeight = *(std::get_if<int>(&(args->at(1))));
|
||||
int dLeft = *(std::get_if<int>(&(args->at(2))));
|
||||
int dTop = *(std::get_if<int>(&(args->at(3))));
|
||||
auto width = (uint32_t)round(dWidth );
|
||||
auto height = (uint32_t)round(dHeight );
|
||||
auto left = (uint32_t)round(dLeft );
|
||||
auto top = (uint32_t)round(dTop );
|
||||
auto width = static_cast<uint32_t>(dWidth);
|
||||
auto height = static_cast<uint32_t>(dHeight);
|
||||
auto left = static_cast<uint32_t>(dLeft);
|
||||
auto top = static_cast<uint32_t>(dTop );
|
||||
|
||||
_context->ResizeRenderingSurface(width, height, left, top);
|
||||
std::cout << "resized window to " << width << "x" << height << " at " << left << "," << top << std::endl;
|
||||
result->Success();
|
||||
#else
|
||||
result->Error("ERROR", "resizeWindow is only available when using a backing window");
|
||||
|
||||
@@ -118,7 +118,7 @@ void WGLContext::CreateRenderingSurface(
|
||||
ResizeRenderingSurface(width, height, left, top);
|
||||
}
|
||||
|
||||
std::cout << "created window size " << width << "x" << height << " at " << left << "," << top << " with backing handle" << _backingWindow->GetHandle() << std::endl;
|
||||
// std::cout << "created window size " << width << "x" << height << " at " << left << "," << top << " with backing handle" << _backingWindow->GetHandle() << std::endl;
|
||||
std::vector<flutter::EncodableValue> resultList;
|
||||
resultList.push_back(flutter::EncodableValue()); // return null for Flutter texture ID
|
||||
resultList.push_back(flutter::EncodableValue()); // return null for hardware texture ID
|
||||
|
||||
Reference in New Issue
Block a user