From f32e7584defdfc554b24ae30ad5a5067177c4031 Mon Sep 17 00:00:00 2001 From: laoguanyao <806103474@qq.com> Date: Tue, 24 Sep 2024 17:20:05 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8E=9F=E7=94=9Fweb?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=9C=A8=E5=BA=94=E7=94=A8=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E6=94=B9=E5=8F=98=E5=90=8E=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: laoguanyao <806103474@qq.com> --- .../src/main/ets/plugin/platform/PlatformViewsController.ets | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets index 9b29731810..8afcd87043 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/platform/PlatformViewsController.ets @@ -190,6 +190,10 @@ export default class PlatformViewsController implements PlatformViewsAccessibili oldPhysicalHeight = this.viewPhysicalInfo.get(viewId) as number; //高度变化小于3,不做刷新处理,减少闪烁 if (physicalHeight - oldPhysicalHeight < this.dValue) { + + this.setParams(params!, "width", physicalWidth); + this.setParams(params!, "height", oldPhysicalHeight); + onComplete.run(new PlatformViewBufferSize(physicalWidth, oldPhysicalHeight)); return; } -- Gitee From 7a760edfe679356912e5cbf94c8915c3689c72b5 Mon Sep 17 00:00:00 2001 From: zjxi Date: Thu, 26 Sep 2024 21:09:21 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Dflutterview=E4=B8=AD?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=AE=9E=E6=97=B6=E6=9B=B4=E6=96=B0=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=98=BE=E7=A4=BA=E5=A4=A7=E5=B0=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zjxi --- .../flutter/src/main/ets/view/FlutterView.ets | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets index 59038f9f33..54e84044d0 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets @@ -15,12 +15,11 @@ import FlutterEngine from '../embedding/engine/FlutterEngine'; import Log from '../util/Log'; import { DVModel, DVModelChildren, DVModelEvents, DVModelParameters } from './DynamicView/dynamicView'; -import display from '@ohos.display'; +import {display} from '@kit.ArkUI' import FlutterManager from '../embedding/ohos/FlutterManager'; import window from '@ohos.window'; import KeyboardManager from '../embedding/ohos/KeyboardManager'; import MouseCursorPlugin from '../plugin/mouse/MouseCursorPlugin'; -import Any from '../plugin/common/Any'; import Settings from '../embedding/ohos/Settings'; import ArrayList from '@ohos.util.ArrayList'; import { EmbeddingNodeController } from '../embedding/ohos/EmbeddingNodeController'; @@ -155,6 +154,19 @@ export class FlutterView { this.navigationAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR); this.gestureAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM_GESTURE); this.keyboardAvoidArea = this.mainWindow?.getWindowAvoidArea(window.AvoidAreaType.TYPE_KEYBOARD); + + //监听系统设置显示大小改变 + try { + display.on("change", ()=>{ + this.displayInfo = display.getDefaultDisplaySync(); + this.viewportMetrics.devicePixelRatio = this.displayInfo?.densityPixels; + this.viewportMetrics.physicalTouchSlop = 1.0 * this.displayInfo?.densityPixels; + Log.i(TAG, "Display Info: " + JSON.stringify(this.displayInfo)) + this.updateViewportMetrics() + }); + } catch (e) { + Log.e(TAG, "displayInfo error" + JSON.stringify(e)); + } } private windowSizeChangeCallback = (data: window.Size) => { @@ -391,6 +403,7 @@ export class FlutterView { private updateViewportMetrics() { if (this.isAttachedToFlutterEngine()) { + Log.i(TAG, 'updateViewportMetrics devicePixelRatio:' + this.viewportMetrics.devicePixelRatio) this?.flutterEngine?.getFlutterNapi()?.setViewportMetrics(this.viewportMetrics.devicePixelRatio, this.viewportMetrics.physicalWidth, this.viewportMetrics.physicalHeight, -- Gitee From 251ec5bdd6b737b50a8eccfffe748b039bb86f62 Mon Sep 17 00:00:00 2001 From: zjxi Date: Thu, 26 Sep 2024 21:58:29 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Dflutterview=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=AE=9E=E6=97=B6=E6=9B=B4=E6=96=B0=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=EF=BC=8C=E5=A2=9E=E5=8A=A0diplay.off?= =?UTF-8?q?=E6=B3=A8=E9=94=80=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zjxi --- .../flutter/src/main/ets/view/FlutterView.ets | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets index 54e84044d0..b93d423286 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets @@ -161,7 +161,7 @@ export class FlutterView { this.displayInfo = display.getDefaultDisplaySync(); this.viewportMetrics.devicePixelRatio = this.displayInfo?.densityPixels; this.viewportMetrics.physicalTouchSlop = 1.0 * this.displayInfo?.densityPixels; - Log.i(TAG, "Display Info: " + JSON.stringify(this.displayInfo)) + Log.i(TAG, "Display on: " + JSON.stringify(this.displayInfo)) this.updateViewportMetrics() }); } catch (e) { @@ -248,6 +248,18 @@ export class FlutterView { Log.e(TAG, "mainWindow off error: " + JSON.stringify(e)); } this.mainWindow = null; + + try { + display.off("change", ()=>{ + this.displayInfo = display.getDefaultDisplaySync(); + this.viewportMetrics.devicePixelRatio = this.displayInfo?.densityPixels; + this.viewportMetrics.physicalTouchSlop = 1.0 * this.displayInfo?.densityPixels; + Log.i(TAG, "Display Info: " + JSON.stringify(this.displayInfo)) + this.updateViewportMetrics() + }); + } catch (e) { + Log.e(TAG, "displayInfo off error" + JSON.stringify(e)); + } } attachToFlutterEngine(flutterEngine: FlutterEngine): void { -- Gitee From 7d84842a16801302c078dffe2c4bd025f05fe3a2 Mon Sep 17 00:00:00 2001 From: lihui868 Date: Fri, 27 Sep 2024 11:24:50 +0800 Subject: [PATCH 4/4] revert physicalTouchSlop to default Signed-off-by: lihui868 --- .../flutter/src/main/ets/view/FlutterView.ets | 3 --- 1 file changed, 3 deletions(-) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets index b93d423286..0f76a36f53 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/view/FlutterView.ets @@ -140,7 +140,6 @@ export class FlutterView { this.id = viewId this.displayInfo = display.getDefaultDisplaySync(); this.viewportMetrics.devicePixelRatio = this.displayInfo?.densityPixels; - this.viewportMetrics.physicalTouchSlop = 1.0 * this.displayInfo?.densityPixels; this.mainWindow = FlutterManager.getInstance() .getWindowStage(FlutterManager.getInstance().getUIAbility(context)) @@ -160,7 +159,6 @@ export class FlutterView { display.on("change", ()=>{ this.displayInfo = display.getDefaultDisplaySync(); this.viewportMetrics.devicePixelRatio = this.displayInfo?.densityPixels; - this.viewportMetrics.physicalTouchSlop = 1.0 * this.displayInfo?.densityPixels; Log.i(TAG, "Display on: " + JSON.stringify(this.displayInfo)) this.updateViewportMetrics() }); @@ -253,7 +251,6 @@ export class FlutterView { display.off("change", ()=>{ this.displayInfo = display.getDefaultDisplaySync(); this.viewportMetrics.devicePixelRatio = this.displayInfo?.densityPixels; - this.viewportMetrics.physicalTouchSlop = 1.0 * this.displayInfo?.densityPixels; Log.i(TAG, "Display Info: " + JSON.stringify(this.displayInfo)) this.updateViewportMetrics() }); -- Gitee